CHANGED: #1471 Added and implemented File->Close option.

--HG--
branch : gsoc2012-gui-editor
This commit is contained in:
dfighter1985 2012-08-08 20:56:21 +02:00
parent dca5394f4e
commit ce86607415
23 changed files with 155 additions and 4 deletions

View file

@ -64,7 +64,11 @@ public:
virtual void save(){} virtual void save(){}
virtual void saveAs(){}
virtual void newDocument(){} virtual void newDocument(){}
virtual void close(){}
}; };
} // namespace Core } // namespace Core

View file

@ -169,12 +169,18 @@ void MainWindow::save()
void MainWindow::saveAs() void MainWindow::saveAs()
{ {
m_contextManager->currentContext()->saveAs();
} }
void MainWindow::saveAll() void MainWindow::saveAll()
{ {
} }
void MainWindow::close()
{
m_contextManager->currentContext()->close();
}
void MainWindow::cut() void MainWindow::cut()
{ {
} }
@ -288,6 +294,12 @@ void MainWindow::createActions()
connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll())); connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll()));
m_saveAllAction->setEnabled(false); 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 = new QAction(tr("E&xit"), this);
m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q"))); m_exitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
m_exitAction->setStatusTip(tr("Exit the application")); m_exitAction->setStatusTip(tr("Exit the application"));
@ -383,6 +395,7 @@ void MainWindow::createMenus()
m_fileMenu->addAction(m_saveAction); m_fileMenu->addAction(m_saveAction);
m_fileMenu->addAction(m_saveAsAction); m_fileMenu->addAction(m_saveAsAction);
m_fileMenu->addAction(m_saveAllAction); m_fileMenu->addAction(m_saveAllAction);
m_fileMenu->addAction(m_closeAction);
m_fileMenu->addSeparator(); m_fileMenu->addSeparator();
m_recentFilesMenu = m_fileMenu->addMenu(tr("Recent &Files")); m_recentFilesMenu = m_fileMenu->addMenu(tr("Recent &Files"));

View file

@ -71,6 +71,7 @@ private Q_SLOTS:
void save(); void save();
void saveAs(); void saveAs();
void saveAll(); void saveAll();
void close();
void cut(); void cut();
void copy(); void copy();
void paste(); void paste();
@ -124,6 +125,7 @@ private:
QAction *m_saveAction; QAction *m_saveAction;
QAction *m_saveAsAction; QAction *m_saveAsAction;
QAction *m_saveAllAction; QAction *m_saveAllAction;
QAction *m_closeAction;
QAction *m_exitAction; QAction *m_exitAction;
QAction *m_cutAction; QAction *m_cutAction;
QAction *m_copyAction; QAction *m_copyAction;

View file

@ -40,6 +40,14 @@ namespace GUIEditor
condEdit->setText( currentAction->Conditions.c_str() ); condEdit->setText( currentAction->Conditions.c_str() );
} }
void ActionEditor::clear()
{
currentAction = NULL;
handlerEdit->clear();
paramsEdit->clear();
condEdit->clear();
}
void ActionEditor::onOkButtonClicked() void ActionEditor::onOkButtonClicked()
{ {
currentAction->Parameters = paramsEdit->text().toStdString(); currentAction->Parameters = paramsEdit->text().toStdString();

View file

@ -33,6 +33,7 @@ namespace GUIEditor
ActionEditor( QWidget *parent = NULL ); ActionEditor( QWidget *parent = NULL );
~ActionEditor(); ~ActionEditor();
void setCurrentAction( NLGUI::CProcAction *action ); void setCurrentAction( NLGUI::CProcAction *action );
void clear();
private Q_SLOTS: private Q_SLOTS:
void onOkButtonClicked(); void onOkButtonClicked();

View file

@ -39,10 +39,22 @@ namespace GUIEditor
void GUIEditorContext::newDocument() void GUIEditorContext::newDocument()
{ {
m_guiEditorWindow->newDocument();
} }
void GUIEditorContext::save() void GUIEditorContext::save()
{ {
m_guiEditorWindow->save();
}
void GUIEditorContext::saveAs()
{
m_guiEditorWindow->saveAs();
}
void GUIEditorContext::close()
{
m_guiEditorWindow->close();
} }
QWidget *GUIEditorContext::widget() QWidget *GUIEditorContext::widget()

View file

@ -47,6 +47,10 @@ namespace GUIEditor
void newDocument(); void newDocument();
void save(); void save();
void saveAs();
void close();
virtual QUndoStack *undoStack(); virtual QUndoStack *undoStack();

View file

@ -169,6 +169,47 @@ namespace GUIEditor
setCursor( Qt::ArrowCursor ); 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() void GUIEditorWindow::onProjectFilesChanged()
{ {
setCursor( Qt::WaitCursor ); setCursor( Qt::WaitCursor );
@ -190,11 +231,17 @@ namespace GUIEditor
Core::MenuManager *mm = Core::ICore::instance()->menuManager(); Core::MenuManager *mm = Core::ICore::instance()->menuManager();
//QAction *newAction = mm->action( Core::Constants::NEW ); //QAction *newAction = mm->action( Core::Constants::NEW );
QAction *saveAction = mm->action( Core::Constants::SAVE ); 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 ) //if( newAction != NULL )
// newAction->setEnabled( true ); // newAction->setEnabled( true );
if( saveAction != NULL ) if( saveAction != NULL )
saveAction->setEnabled( true ); saveAction->setEnabled( true );
if( saveAsAction != NULL )
saveAsAction->setEnabled( true );
if( closeAction != NULL )
closeAction->setEnabled( true );
QMenu *menu = mm->menu( Core::Constants::M_TOOLS ); QMenu *menu = mm->menu( Core::Constants::M_TOOLS );
if( menu != NULL ) if( menu != NULL )

View file

@ -50,6 +50,10 @@ public:
public Q_SLOTS: public Q_SLOTS:
void open(); void open();
void newDocument();
void save();
void saveAs();
void close();
private Q_SLOTS: private Q_SLOTS:
void onProjectFilesChanged(); void onProjectFilesChanged();

View file

@ -61,6 +61,15 @@ namespace GUIEditor
condEdit->setText( data.cond.c_str() ); condEdit->setText( data.cond.c_str() );
} }
void LinkEditor::clear()
{
expressionEdit->clear();
targetEdit->clear();
ahEdit->clear();
ahParamEdit->clear();
condEdit->clear();
}
void LinkEditor::onOKButtonClicked() void LinkEditor::onOKButtonClicked()
{ {
IParser *parser = CWidgetManager::getInstance()->getParser(); IParser *parser = CWidgetManager::getInstance()->getParser();

View file

@ -31,6 +31,7 @@ namespace GUIEditor
~LinkEditor(); ~LinkEditor();
void setup(); void setup();
void setLinkId( uint32 linkId ); void setLinkId( uint32 linkId );
void clear();
Q_SIGNALS: Q_SIGNALS:
void okClicked(); void okClicked();

View file

@ -50,6 +50,12 @@ namespace GUIEditor
delete linkEditor; delete linkEditor;
} }
void LinkList::clear()
{
linkTree->clear();
linkEditor->clear();
}
void LinkList::onGUILoaded() void LinkList::onGUILoaded()
{ {
linkTree->clear(); linkTree->clear();

View file

@ -30,6 +30,7 @@ namespace GUIEditor
public: public:
LinkList( QWidget *parent = NULL ); LinkList( QWidget *parent = NULL );
~LinkList(); ~LinkList();
void clear();
public Q_SLOTS: public Q_SLOTS:
void onGUILoaded(); void onGUILoaded();

View file

@ -74,11 +74,8 @@ namespace GUIEditor
bool NelGUIWidget::parse( SProjectFiles &files ) bool NelGUIWidget::parse( SProjectFiles &files )
{ {
guiLoaded = false; reset();
CWidgetManager::getInstance()->reset();
IParser *parser = CWidgetManager::getInstance()->getParser(); IParser *parser = CWidgetManager::getInstance()->getParser();
parser->removeAll();
CViewRenderer::getInstance()->reset();
std::vector< std::string >::iterator itr; std::vector< std::string >::iterator itr;
for( itr = files.mapFiles.begin(); itr != files.mapFiles.end(); ++itr ) for( itr = files.mapFiles.begin(); itr != files.mapFiles.end(); ++itr )
@ -112,6 +109,18 @@ namespace GUIEditor
return true; 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() void NelGUIWidget::draw()
{ {
getDriver()->clearBuffers( NLMISC::CRGBA::Black ); getDriver()->clearBuffers( NLMISC::CRGBA::Black );

View file

@ -34,6 +34,7 @@ namespace GUIEditor
void init(); void init();
bool parse( SProjectFiles &files ); bool parse( SProjectFiles &files );
void draw(); void draw();
void reset();
Q_SIGNALS: Q_SIGNALS:
void guiLoadComplete(); void guiLoadComplete();

View file

@ -60,6 +60,12 @@ namespace GUIEditor
setWindowTitle( QString( "Procedure Editor - %1" ).arg( currentProc ) ); setWindowTitle( QString( "Procedure Editor - %1" ).arg( currentProc ) );
} }
void ProcEditor::clear()
{
actionList->clear();
actionEditor->clear();
}
void ProcEditor::onEditButtonClicked() void ProcEditor::onEditButtonClicked()
{ {
int row = actionList->currentRow(); int row = actionList->currentRow();

View file

@ -32,6 +32,7 @@ namespace GUIEditor
~ProcEditor(); ~ProcEditor();
void setCurrentProc( const QString &name ); void setCurrentProc( const QString &name );
void clear();
private Q_SLOTS: private Q_SLOTS:
void onEditButtonClicked(); void onEditButtonClicked();

View file

@ -42,6 +42,12 @@ namespace GUIEditor
delete procEditor; delete procEditor;
} }
void ProcList::clear()
{
procList->clear();
procEditor->clear();
}
void ProcList::onGUILoaded() void ProcList::onGUILoaded()
{ {
setupProcList(); setupProcList();

View file

@ -30,6 +30,7 @@ namespace GUIEditor
public: public:
ProcList( QWidget *parent = NULL ); ProcList( QWidget *parent = NULL );
~ProcList(); ~ProcList();
void clear();
public Q_SLOTS: public Q_SLOTS:
void onGUILoaded(); void onGUILoaded();

View file

@ -104,6 +104,11 @@ namespace GUIEditor
} }
} }
void ProjectWindow::clear()
{
fileTree->clear();
}
void ProjectWindow::onAddButtonClicked() void ProjectWindow::onAddButtonClicked()
{ {
if( fileTree->currentItem() == NULL ) if( fileTree->currentItem() == NULL )

View file

@ -34,6 +34,7 @@ namespace GUIEditor
void setupFiles( SProjectFiles &projectFiles ); void setupFiles( SProjectFiles &projectFiles );
void updateFiles( SProjectFiles &projectFiles ); void updateFiles( SProjectFiles &projectFiles );
void clear();
Q_SIGNALS: Q_SIGNALS:
void projectFilesChanged(); void projectFilesChanged();

View file

@ -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 ) void CPropBrowserCtrl::onSelectionChanged( std::string &id )
{ {
if( browser == NULL ) if( browser == NULL )
return; return;
disconnect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ), disconnect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
this, SLOT( onPropertyChanged( QtProperty* ) ) ); this, SLOT( onPropertyChanged( QtProperty* ) ) );

View file

@ -46,6 +46,7 @@ namespace GUIEditor
~CPropBrowserCtrl(); ~CPropBrowserCtrl();
void setBrowser( QtTreePropertyBrowser *b ); void setBrowser( QtTreePropertyBrowser *b );
void setupWidgetInfo( const std::map< std::string, SWidgetInfo > &info ); void setupWidgetInfo( const std::map< std::string, SWidgetInfo > &info );
void clear();
public Q_SLOTS: public Q_SLOTS:
void onSelectionChanged( std::string &id ); void onSelectionChanged( std::string &id );