mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-15 12:09:06 +00:00
CHANGED: #1471 Implemented add/remove file functionality for the project window.
This commit is contained in:
parent
d9cbf2b9f1
commit
e0ffb76eaa
2 changed files with 48 additions and 0 deletions
|
@ -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…
Reference in a new issue