CHANGED: #1471 Implemented add/remove file functionality for the project window.

--HG--
branch : gsoc2012-gui-editor
hg/feature/sse2
dfighter1985 13 years ago
parent a08cadf314
commit 203f12d2cd

@ -16,6 +16,8 @@
#include "project_window.h"
#include <QInputDialog>
#include <QMessageBox>
namespace GUIEditor
{
@ -25,6 +27,9 @@ namespace GUIEditor
setupUi( this );
connect( okButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) );
connect( cancelButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) );
connect( addButton, SIGNAL( clicked(bool) ), this, SLOT( onAddButtonClicked() ) );
connect( removeButton, SIGNAL( clicked(bool) ), this, SLOT( onRemoveButtonClicked() ) );
}
ProjectWindow::~ProjectWindow()
@ -43,6 +48,44 @@ namespace GUIEditor
}
fileList->sortItems();
}
void ProjectWindow::onAddButtonClicked()
{
bool ok;
QString newFile = QInputDialog::getText( this,
tr( "Adding file to project" ),
tr( "Which file do you want to add?" ),
QLineEdit::Normal,
QString(),
&ok );
if( ok )
{
fileList->addItem( newFile );
fileList->sortItems();
}
}
void ProjectWindow::onRemoveButtonClicked()
{
if( fileList->count() == 0 )
return;
QMessageBox::StandardButton reply;
QString text;
if( fileList->currentRow() >= 0 )
text = fileList->item( fileList->currentRow() )->text();
reply = QMessageBox::question( this,
tr( "Removing file from project" ),
tr( "Are you sure you want to remove '%1' from the project?" ).arg( text ),
QMessageBox::Yes | QMessageBox::Cancel );
QListWidgetItem *item;
if( reply == QMessageBox::Yes )
item = fileList->takeItem( fileList->currentRow() );
delete item;
}
}

@ -33,7 +33,12 @@ namespace GUIEditor
void setupFileList( const std::vector< std::string > &fileNames );
private Q_SLOTS:
void onAddButtonClicked();
void onRemoveButtonClicked();
private:
};
}

Loading…
Cancel
Save