CHANGED: #1471 Project file changes in the project window will now be applied. Also it will cause the GUI XML files to be reparsed and the NelGUI widget to be redrawn.

This commit is contained in:
dfighter1985 2012-07-20 03:50:23 +02:00
parent c0551fdbfa
commit 57ddbde003
5 changed files with 88 additions and 5 deletions

View file

@ -43,6 +43,7 @@ namespace GUIEditor
{
QString _lastDir;
std::map< std::string, SWidgetInfo > widgetInfo;
SProjectFiles projectFiles;
GUIEditorWindow::GUIEditorWindow(QWidget *parent) :
QMainWindow(parent)
@ -53,6 +54,7 @@ namespace GUIEditor
linkEditor = new LinkEditor;
procEditor = new ProcEditor;
projectWindow = new ProjectWindow;
connect( projectWindow, SIGNAL( projectFilesChanged() ), this, SLOT( onProjectFilesChanged() ) );
viewPort = new NelGUIWidget;
setCentralWidget( viewPort );
@ -138,11 +140,34 @@ namespace GUIEditor
setCursor( Qt::ArrowCursor );
return;
}
SProjectFiles projectFiles;
projectFiles.clear();
parser.getProjectFiles( projectFiles );
currentProject = parser.getProjectName().c_str();
projectWindow->setupFiles( projectFiles );
viewPort->parse( projectFiles );
if( viewPort->parse( projectFiles ) )
viewPort->draw();
else
{
QMessageBox::critical( this,
tr( "Error parsing GUI XML files" ),
tr( "There was an error while parsing the GUI XML files. See the log file for details." ) );
}
setCursor( Qt::ArrowCursor );
}
void GUIEditorWindow::onProjectFilesChanged()
{
setCursor( Qt::WaitCursor );
projectWindow->updateFiles( projectFiles );
if( !viewPort->parse( projectFiles ) )
{
QMessageBox::critical( this,
tr( "Error parsing GUI XML files" ),
tr( "There was an error while parsing the GUI XML files. See the log file for details." ) );
}
else
viewPort->draw();
setCursor( Qt::ArrowCursor );

View file

@ -49,6 +49,7 @@ public Q_SLOTS:
void open();
private Q_SLOTS:
void onProjectFilesChanged();
private:
void createMenus();

View file

@ -28,6 +28,12 @@ namespace GUIEditor
public:
std::vector< std::string > guiFiles;
std::vector< std::string > mapFiles;
void clear()
{
guiFiles.clear();
mapFiles.clear();
}
};
}

View file

@ -25,7 +25,9 @@ namespace GUIEditor
QWidget( parent )
{
setupUi( this );
connect( okButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) );
filesChanged = false;
connect( okButton, SIGNAL( clicked(bool) ), this, SLOT( onOKButtonClicked() ) );
connect( cancelButton, SIGNAL( clicked(bool) ), this, SLOT( hide() ) );
connect( addButton, SIGNAL( clicked(bool) ), this, SLOT( onAddButtonClicked() ) );
@ -73,6 +75,35 @@ namespace GUIEditor
}
}
void ProjectWindow::updateFiles( SProjectFiles &projectFiles )
{
projectFiles.clear();
QTreeWidgetItem *topItem;
topItem = fileTree->topLevelItem( 0 );
if( topItem != NULL )
{
int c = topItem->childCount();
for( int i = 0; i < c; i++ )
{
QTreeWidgetItem *item = topItem->child( i );
projectFiles.guiFiles.push_back( item->text( 0 ).toStdString() );
}
}
topItem = fileTree->topLevelItem( 1 );
if( topItem != NULL )
{
int c = topItem->childCount();
for( int i = 0; i < c; i++ )
{
QTreeWidgetItem *item = topItem->child( i );
projectFiles.mapFiles.push_back( item->text( 0 ).toStdString() );
}
}
}
void ProjectWindow::onAddButtonClicked()
{
if( fileTree->currentItem() == NULL )
@ -99,6 +130,7 @@ namespace GUIEditor
{
QTreeWidgetItem *newItem = new QTreeWidgetItem( item );
newItem->setText( 0, newFile );
filesChanged = true;
}
}
@ -120,9 +152,23 @@ namespace GUIEditor
QMessageBox::Yes | QMessageBox::Cancel );
if( reply == QMessageBox::Yes )
{
fileTree->currentItem()->parent()->removeChild( fileTree->currentItem() );
filesChanged = true;
}
}
void ProjectWindow::onOKButtonClicked()
{
hide();
if( filesChanged )
{
filesChanged = false;
Q_EMIT projectFilesChanged();
}
}
}

View file

@ -33,13 +33,18 @@ namespace GUIEditor
~ProjectWindow();
void setupFiles( SProjectFiles &projectFiles );
void updateFiles( SProjectFiles &projectFiles );
Q_SIGNALS:
void projectFilesChanged();
private Q_SLOTS:
void onAddButtonClicked();
void onRemoveButtonClicked();
void onOKButtonClicked();
private:
bool filesChanged;
};
}