From ce866074151d267a15a2398c7b740be24633e75e Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 8 Aug 2012 20:56:21 +0200 Subject: [PATCH] CHANGED: #1471 Added and implemented File->Close option. --HG-- branch : gsoc2012-gui-editor --- .../src/plugins/core/icontext.h | 4 ++ .../src/plugins/core/main_window.cpp | 13 +++++ .../src/plugins/core/main_window.h | 2 + .../src/plugins/gui_editor/action_editor.cpp | 8 ++++ .../src/plugins/gui_editor/action_editor.h | 1 + .../plugins/gui_editor/gui_editor_context.cpp | 12 +++++ .../plugins/gui_editor/gui_editor_context.h | 4 ++ .../plugins/gui_editor/gui_editor_window.cpp | 47 +++++++++++++++++++ .../plugins/gui_editor/gui_editor_window.h | 4 ++ .../src/plugins/gui_editor/link_editor.cpp | 9 ++++ .../src/plugins/gui_editor/link_editor.h | 1 + .../src/plugins/gui_editor/link_list.cpp | 6 +++ .../src/plugins/gui_editor/link_list.h | 1 + .../src/plugins/gui_editor/nelgui_widget.cpp | 17 +++++-- .../src/plugins/gui_editor/nelgui_widget.h | 1 + .../src/plugins/gui_editor/proc_editor.cpp | 6 +++ .../src/plugins/gui_editor/proc_editor.h | 1 + .../src/plugins/gui_editor/proc_list.cpp | 6 +++ .../src/plugins/gui_editor/proc_list.h | 1 + .../src/plugins/gui_editor/project_window.cpp | 5 ++ .../src/plugins/gui_editor/project_window.h | 1 + .../gui_editor/property_browser_ctrl.cpp | 8 ++++ .../gui_editor/property_browser_ctrl.h | 1 + 23 files changed, 155 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h index b0c4d0426..d2cbb412c 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h @@ -64,7 +64,11 @@ public: virtual void save(){} + virtual void saveAs(){} + virtual void newDocument(){} + + virtual void close(){} }; } // namespace Core diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp index bf0380637..2247274a6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp @@ -169,12 +169,18 @@ void MainWindow::save() void MainWindow::saveAs() { + m_contextManager->currentContext()->saveAs(); } void MainWindow::saveAll() { } +void MainWindow::close() +{ + m_contextManager->currentContext()->close(); +} + void MainWindow::cut() { } @@ -288,6 +294,12 @@ void MainWindow::createActions() connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll())); m_saveAllAction->setEnabled(false); + m_closeAction = new QAction(tr("Close"), this); + m_closeAction->setShortcut(QKeySequence::Close); + menuManager()->registerAction(m_closeAction, Constants::CLOSE); + connect(m_closeAction, SIGNAL(triggered()), this, SLOT(close())); + m_closeAction->setEnabled(false); + m_exitAction = new QAction(tr("E&xit"), this); m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); m_exitAction->setStatusTip(tr("Exit the application")); @@ -383,6 +395,7 @@ void MainWindow::createMenus() m_fileMenu->addAction(m_saveAction); m_fileMenu->addAction(m_saveAsAction); m_fileMenu->addAction(m_saveAllAction); + m_fileMenu->addAction(m_closeAction); m_fileMenu->addSeparator(); m_recentFilesMenu = m_fileMenu->addMenu(tr("Recent &Files")); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h index a75126823..11bfd22b6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h @@ -71,6 +71,7 @@ private Q_SLOTS: void save(); void saveAs(); void saveAll(); + void close(); void cut(); void copy(); void paste(); @@ -124,6 +125,7 @@ private: QAction *m_saveAction; QAction *m_saveAsAction; QAction *m_saveAllAction; + QAction *m_closeAction; QAction *m_exitAction; QAction *m_cutAction; QAction *m_copyAction; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp index 8f73d4474..c82ad0d3b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.cpp @@ -40,6 +40,14 @@ namespace GUIEditor condEdit->setText( currentAction->Conditions.c_str() ); } + void ActionEditor::clear() + { + currentAction = NULL; + handlerEdit->clear(); + paramsEdit->clear(); + condEdit->clear(); + } + void ActionEditor::onOkButtonClicked() { currentAction->Parameters = paramsEdit->text().toStdString(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h index 5dd4fb105..272e80e90 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/action_editor.h @@ -33,6 +33,7 @@ namespace GUIEditor ActionEditor( QWidget *parent = NULL ); ~ActionEditor(); void setCurrentAction( NLGUI::CProcAction *action ); + void clear(); private Q_SLOTS: void onOkButtonClicked(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp index 248090261..b3bfb2900 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.cpp @@ -39,10 +39,22 @@ namespace GUIEditor void GUIEditorContext::newDocument() { + m_guiEditorWindow->newDocument(); } void GUIEditorContext::save() { + m_guiEditorWindow->save(); + } + + void GUIEditorContext::saveAs() + { + m_guiEditorWindow->saveAs(); + } + + void GUIEditorContext::close() + { + m_guiEditorWindow->close(); } QWidget *GUIEditorContext::widget() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h index c6fdd7e7b..70c0b5ebc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_context.h @@ -47,6 +47,10 @@ namespace GUIEditor void newDocument(); void save(); + + void saveAs(); + + void close(); virtual QUndoStack *undoStack(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp index 8b40abe34..66231486f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.cpp @@ -169,6 +169,47 @@ namespace GUIEditor setCursor( Qt::ArrowCursor ); } + void GUIEditorWindow::newDocument() + { + } + + void GUIEditorWindow::save() + { + if( currentProject.isEmpty() ) + return; + + } + + void GUIEditorWindow::saveAs() + { + if( currentProject.isEmpty() ) + return; + + } + + void GUIEditorWindow::close() + { + if( currentProject.isEmpty() ) + return; + + QMessageBox::StandardButton reply = QMessageBox::question( this, + tr( "Closing project" ), + tr( "Are you sure you want to close this project?" ), + QMessageBox::Yes | QMessageBox::No ); + if( reply != QMessageBox::Yes ) + return; + + projectFiles.clearAll(); + projectWindow->clear(); + hierarchyView->clearHierarchy(); + viewPort->reset(); + browserCtrl.clear(); + linkList->clear(); + procList->clear(); + + currentProject = ""; + } + void GUIEditorWindow::onProjectFilesChanged() { setCursor( Qt::WaitCursor ); @@ -190,11 +231,17 @@ namespace GUIEditor Core::MenuManager *mm = Core::ICore::instance()->menuManager(); //QAction *newAction = mm->action( Core::Constants::NEW ); QAction *saveAction = mm->action( Core::Constants::SAVE ); + QAction *saveAsAction = mm->action( Core::Constants::SAVE_AS ); + QAction *closeAction = mm->action( Core::Constants::CLOSE ); //if( newAction != NULL ) // newAction->setEnabled( true ); if( saveAction != NULL ) saveAction->setEnabled( true ); + if( saveAsAction != NULL ) + saveAsAction->setEnabled( true ); + if( closeAction != NULL ) + closeAction->setEnabled( true ); QMenu *menu = mm->menu( Core::Constants::M_TOOLS ); if( menu != NULL ) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h index 1e3527d19..f2132e932 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/gui_editor_window.h @@ -50,6 +50,10 @@ public: public Q_SLOTS: void open(); + void newDocument(); + void save(); + void saveAs(); + void close(); private Q_SLOTS: void onProjectFilesChanged(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp index 9fda82432..c44eb0e1f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.cpp @@ -61,6 +61,15 @@ namespace GUIEditor condEdit->setText( data.cond.c_str() ); } + void LinkEditor::clear() + { + expressionEdit->clear(); + targetEdit->clear(); + ahEdit->clear(); + ahParamEdit->clear(); + condEdit->clear(); + } + void LinkEditor::onOKButtonClicked() { IParser *parser = CWidgetManager::getInstance()->getParser(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h index 5211eaa46..892deee9d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_editor.h @@ -31,6 +31,7 @@ namespace GUIEditor ~LinkEditor(); void setup(); void setLinkId( uint32 linkId ); + void clear(); Q_SIGNALS: void okClicked(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_list.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_list.cpp index 33c71ddc1..778966d45 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_list.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_list.cpp @@ -50,6 +50,12 @@ namespace GUIEditor delete linkEditor; } + void LinkList::clear() + { + linkTree->clear(); + linkEditor->clear(); + } + void LinkList::onGUILoaded() { linkTree->clear(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_list.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_list.h index 514707e45..2f5bb977e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_list.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/link_list.h @@ -30,6 +30,7 @@ namespace GUIEditor public: LinkList( QWidget *parent = NULL ); ~LinkList(); + void clear(); public Q_SLOTS: void onGUILoaded(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp index dd491ba57..d34e1bd38 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp @@ -74,11 +74,8 @@ namespace GUIEditor bool NelGUIWidget::parse( SProjectFiles &files ) { - guiLoaded = false; - CWidgetManager::getInstance()->reset(); + reset(); IParser *parser = CWidgetManager::getInstance()->getParser(); - parser->removeAll(); - CViewRenderer::getInstance()->reset(); std::vector< std::string >::iterator itr; for( itr = files.mapFiles.begin(); itr != files.mapFiles.end(); ++itr ) @@ -112,6 +109,18 @@ namespace GUIEditor return true; } + void NelGUIWidget::reset() + { + guiLoaded = false; + if( timerID != 0 ) + killTimer( timerID ); + timerID = 0; + CWidgetManager::getInstance()->reset(); + CWidgetManager::getInstance()->getParser()->removeAll(); + CViewRenderer::getInstance()->reset(); + clear(); + } + void NelGUIWidget::draw() { getDriver()->clearBuffers( NLMISC::CRGBA::Black ); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h index bfd2f56d2..90a19c877 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h @@ -34,6 +34,7 @@ namespace GUIEditor void init(); bool parse( SProjectFiles &files ); void draw(); + void reset(); Q_SIGNALS: void guiLoadComplete(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp index fee1b1195..b837d6f59 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.cpp @@ -60,6 +60,12 @@ namespace GUIEditor setWindowTitle( QString( "Procedure Editor - %1" ).arg( currentProc ) ); } + void ProcEditor::clear() + { + actionList->clear(); + actionEditor->clear(); + } + void ProcEditor::onEditButtonClicked() { int row = actionList->currentRow(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h index 088edc895..630e8dc7a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_editor.h @@ -32,6 +32,7 @@ namespace GUIEditor ~ProcEditor(); void setCurrentProc( const QString &name ); + void clear(); private Q_SLOTS: void onEditButtonClicked(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_list.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_list.cpp index f855a2108..8356d4dd6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_list.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_list.cpp @@ -42,6 +42,12 @@ namespace GUIEditor delete procEditor; } + void ProcList::clear() + { + procList->clear(); + procEditor->clear(); + } + void ProcList::onGUILoaded() { setupProcList(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_list.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_list.h index a5a83b2eb..27d85f0d8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_list.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/proc_list.h @@ -30,6 +30,7 @@ namespace GUIEditor public: ProcList( QWidget *parent = NULL ); ~ProcList(); + void clear(); public Q_SLOTS: void onGUILoaded(); 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 ebce92c33..da9cbe472 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 @@ -104,6 +104,11 @@ namespace GUIEditor } } + void ProjectWindow::clear() + { + fileTree->clear(); + } + void ProjectWindow::onAddButtonClicked() { if( fileTree->currentItem() == NULL ) 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 71ce77ed8..0922cd476 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 @@ -34,6 +34,7 @@ namespace GUIEditor void setupFiles( SProjectFiles &projectFiles ); void updateFiles( SProjectFiles &projectFiles ); + void clear(); Q_SIGNALS: void projectFilesChanged(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp index 223837a9b..c86d207f4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.cpp @@ -54,10 +54,18 @@ namespace GUIEditor } } + void CPropBrowserCtrl::clear() + { + browser->clear(); + disconnect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ), + this, SLOT( onPropertyChanged( QtProperty* ) ) ); + } + void CPropBrowserCtrl::onSelectionChanged( std::string &id ) { if( browser == NULL ) return; + disconnect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ), this, SLOT( onPropertyChanged( QtProperty* ) ) ); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h index 5e4747cdc..1a6c62fed 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/property_browser_ctrl.h @@ -46,6 +46,7 @@ namespace GUIEditor ~CPropBrowserCtrl(); void setBrowser( QtTreePropertyBrowser *b ); void setupWidgetInfo( const std::map< std::string, SWidgetInfo > &info ); + void clear(); public Q_SLOTS: void onSelectionChanged( std::string &id );