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

This commit is contained in:
dfighter1985 2012-08-08 20:56:21 +02:00
parent 02a57e4bf7
commit 9bb6bb99b1
23 changed files with 155 additions and 4 deletions

View file

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

View file

@ -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"));

View file

@ -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;

View file

@ -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();

View file

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

View file

@ -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()

View file

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

View file

@ -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 )

View file

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

View file

@ -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();

View file

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

View file

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

View file

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

View file

@ -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 );

View file

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

View file

@ -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();

View file

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

View file

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

View file

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

View file

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

View file

@ -34,6 +34,7 @@ namespace GUIEditor
void setupFiles( SProjectFiles &projectFiles );
void updateFiles( SProjectFiles &projectFiles );
void clear();
Q_SIGNALS:
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 )
{
if( browser == NULL )
return;
disconnect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
this, SLOT( onPropertyChanged( QtProperty* ) ) );

View file

@ -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 );