From a840d7ad24f930d4cd066106c829fb63a7a52bf6 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 18 Jul 2012 20:32:35 +0200 Subject: [PATCH] CHANGED: #1471 Implemented add/remove file functionality for the project window. --- .../src/plugins/gui_editor/project_window.cpp | 43 +++++++++++++++++++ .../src/plugins/gui_editor/project_window.h | 5 +++ 2 files changed, 48 insertions(+) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.cpp index cebbfe848..d8ab678a0 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.cpp @@ -16,6 +16,8 @@ #include "project_window.h" +#include +#include 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; + } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.h index 155c171e8..26fa28918 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.h @@ -33,7 +33,12 @@ namespace GUIEditor void setupFileList( const std::vector< std::string > &fileNames ); + private Q_SLOTS: + void onAddButtonClicked(); + void onRemoveButtonClicked(); + private: + }; }