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 734a7fcd9..677f14d18 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
@@ -138,12 +138,10 @@ namespace GUIEditor
setCursor( Qt::ArrowCursor );
return;
}
-
- std::vector< std::string > fileNames;
-
- parser.getProjectFileNames( fileNames );
+ SProjectFiles projectFiles;
+ parser.getProjectFiles( projectFiles );
currentProject = parser.getProjectName().c_str();
- projectWindow->setupFileList( fileNames );
+ projectWindow->setupFiles( projectFiles );
setCursor( Qt::ArrowCursor );
}
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 d8bae62c5..6d4b304d5 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
@@ -1,17 +1,17 @@
-// Object Viewer Qt GUI Editor plugin
-// Copyright (C) 2010 Winch Gate Property Limited
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
+// Object Viewer Qt GUI Editor plugin
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
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 334c15f4e..d91856e96 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
@@ -1,17 +1,17 @@
-// Object Viewer Qt GUI Editor plugin
-// Copyright (C) 2010 Winch Gate Property Limited
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
+// Object Viewer Qt GUI Editor plugin
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_file_parser.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_file_parser.cpp
index 0ce40a5ac..e0a7a4885 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_file_parser.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_file_parser.cpp
@@ -44,10 +44,12 @@ namespace GUIEditor
return true;
}
- void CProjectFileParser::getProjectFileNames( std::vector< std::string > &names ) const
+ void CProjectFileParser::getProjectFiles( SProjectFiles &projectFiles ) const
{
- names.resize( fileNames.size() );
- std::copy( fileNames.begin(), fileNames.end(), names.begin() );
+ projectFiles.guiFiles.resize( files.guiFiles.size() );
+ projectFiles.mapFiles.resize( files.mapFiles.size() );
+ std::copy( files.guiFiles.begin(), files.guiFiles.end(), projectFiles.guiFiles.begin() );
+ std::copy( files.mapFiles.begin(), files.mapFiles.end(), projectFiles.mapFiles.begin() );
}
bool CProjectFileParser::parseXMLFile(QFile &f)
@@ -72,7 +74,10 @@ namespace GUIEditor
if( !parseHeader( reader ) )
return false;
- if( !parseFiles( reader ) )
+ if( !parseGUIFiles( reader ) )
+ return false;
+
+ if( !parseMapFiles( reader ) )
return false;
return true;
@@ -98,25 +103,57 @@ namespace GUIEditor
return true;
}
- bool CProjectFileParser::parseFiles( QXmlStreamReader &reader )
+ bool CProjectFileParser::parseGUIFiles( QXmlStreamReader &reader )
{
- while( !reader.atEnd() && !( reader.isStartElement() && reader.name() == "files" ) )
+ while( !reader.atEnd() && !( reader.isStartElement() && reader.name() == "guifiles" ) )
reader.readNext();
if( reader.atEnd() )
return false;
- while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "files" ) ) )
+ while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "guifiles" ) ) )
{
if( reader.isStartElement() && ( reader.name() == "file" ) )
{
QString fileName = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement );
- if( !fileName.isEmpty() )
- fileNames.push_back( fileName.toStdString() );
+ if( fileName.isEmpty() )
+ return false;
+ files.guiFiles.push_back( fileName.toStdString() );
+
}
reader.readNext();
}
- if( fileNames.empty() )
+ reader.readNext();
+ if( reader.atEnd() )
+ return false;
+
+ if( files.guiFiles.empty() )
+ return false;
+
+ return true;
+ }
+
+ bool CProjectFileParser::parseMapFiles( QXmlStreamReader &reader )
+ {
+ while( !reader.atEnd() && !( reader.isStartElement() && reader.name() == "mapfiles" ) )
+ reader.readNext();
+ if( reader.atEnd() )
+ return false;
+
+ while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "mapfiles" ) ) )
+ {
+ if( reader.isStartElement() && ( reader.name() == "file" ) )
+ {
+ QString fileName = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement );
+ if( fileName.isEmpty() )
+ return false;
+ files.mapFiles.push_back( fileName.toStdString() );
+
+ }
+
+ reader.readNext();
+ }
+ if( files.mapFiles.empty() )
return false;
return true;
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_file_parser.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_file_parser.h
index f51a7ef93..6e739025a 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_file_parser.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_file_parser.h
@@ -22,6 +22,7 @@
#include
#include
#include
+#include "project_files.h"
namespace GUIEditor
{
@@ -34,14 +35,15 @@ namespace GUIEditor
bool parseProjectFile( std::string &name );
const std::string& getProjectName() const{ return projectName; }
- void getProjectFileNames( std::vector< std::string > &names ) const;
+ void getProjectFiles( SProjectFiles &projectFiles ) const;
private:
bool parseXMLFile( QFile &f );
bool parseHeader( QXmlStreamReader &reader );
- bool parseFiles( QXmlStreamReader &reader );
+ bool parseGUIFiles( QXmlStreamReader &reader );
+ bool parseMapFiles( QXmlStreamReader &reader );
- std::vector< std::string > fileNames;
+ SProjectFiles files;
std::string projectName;
};
}
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_files.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_files.h
new file mode 100644
index 000000000..314495d57
--- /dev/null
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_files.h
@@ -0,0 +1,36 @@
+// Object Viewer Qt GUI Editor plugin
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+#ifndef PROJECT_FILES_H
+#define PROJECT_FILES_H
+
+#include
+#include
+
+namespace GUIEditor
+{
+ struct SProjectFiles
+ {
+ public:
+ std::vector< std::string > guiFiles;
+ std::vector< std::string > mapFiles;
+ };
+}
+
+#endif
+
+
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 d8ab678a0..e499a48d6 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
@@ -36,21 +36,57 @@ namespace GUIEditor
{
}
- void ProjectWindow::setupFileList( const std::vector< std::string > &fileNames )
+ void ProjectWindow::setupFiles( SProjectFiles &projectFiles )
{
- fileList->clear();
-
- std::vector< std::string >::const_iterator itr;
- for( itr = fileNames.begin(); itr != fileNames.end(); ++itr )
+ QTreeWidgetItem *topItem = fileTree->topLevelItem( 0 );
+ if( topItem != NULL )
{
- const std::string &s = *itr;
- fileList->addItem( s.c_str() );
+ QList< QTreeWidgetItem* > childList = topItem->takeChildren();
+ QListIterator< QTreeWidgetItem* > it( childList );
+ while( it.hasNext() )
+ delete it.next();
+ childList.clear();
+
+ std::vector< std::string >::iterator itr;
+ for( itr = projectFiles.guiFiles.begin(); itr != projectFiles.guiFiles.end(); ++itr )
+ {
+ QTreeWidgetItem *item = new QTreeWidgetItem( topItem );
+ item->setText( 0, itr->c_str() );
+ }
+ }
+
+ topItem = fileTree->topLevelItem( 1 );
+ if( topItem != NULL )
+ {
+ QList< QTreeWidgetItem* > childList = topItem->takeChildren();
+ QListIterator< QTreeWidgetItem* > it( childList );
+ while( it.hasNext() )
+ delete it.next();
+ childList.clear();
+
+ std::vector< std::string >::iterator itr;
+ for( itr = projectFiles.mapFiles.begin(); itr != projectFiles.mapFiles.end(); ++itr )
+ {
+ QTreeWidgetItem *item = new QTreeWidgetItem( topItem );
+ item->setText( 0, itr->c_str() );
+ }
}
- fileList->sortItems();
}
void ProjectWindow::onAddButtonClicked()
{
+ if( fileTree->currentItem() == NULL )
+ return;
+
+ QTreeWidgetItem *item = fileTree->currentItem();
+ QTreeWidgetItem *parent = item->parent();
+
+ while( parent != NULL )
+ {
+ item = parent;
+ parent = parent->parent();
+ }
+
bool ok;
QString newFile = QInputDialog::getText( this,
tr( "Adding file to project" ),
@@ -61,30 +97,33 @@ namespace GUIEditor
if( ok )
{
- fileList->addItem( newFile );
- fileList->sortItems();
+ QTreeWidgetItem *newItem = new QTreeWidgetItem( item );
+ newItem->setText( 0, newFile );
}
}
void ProjectWindow::onRemoveButtonClicked()
{
- if( fileList->count() == 0 )
+ if( fileTree->currentItem() == NULL )
+ return;
+
+ if( ( fileTree->topLevelItem( 0 )->childCount() == 0 ) || ( fileTree->topLevelItem( 1 )->childCount() == 0 ) )
+ return;
+ // Can't delete top-level item
+ if( fileTree->currentItem()->parent() == NULL )
return;
QMessageBox::StandardButton reply;
- QString text;
- if( fileList->currentRow() >= 0 )
- text = fileList->item( fileList->currentRow() )->text();
+ QString text = fileTree->currentItem()->text( 0 );
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;
+ fileTree->currentItem()->parent()->removeChild( fileTree->currentItem() );
+
}
}
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 26fa28918..97242ea75 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
@@ -21,6 +21,7 @@
#include
#include
#include "ui_project_window.h"
+#include "project_files.h"
namespace GUIEditor
{
@@ -31,7 +32,7 @@ namespace GUIEditor
ProjectWindow( QWidget *parent = NULL );
~ProjectWindow();
- void setupFileList( const std::vector< std::string > &fileNames );
+ void setupFiles( SProjectFiles &projectFiles );
private Q_SLOTS:
void onAddButtonClicked();
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.ui
index 2b67bd8fb..cea87173b 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.ui
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/project_window.ui
@@ -6,8 +6,8 @@
0
0
- 379
- 335
+ 451
+ 320
@@ -15,7 +15,23 @@
-
-
+
+
+
+ Files
+
+
+
-
+
+ GUI XML files
+
+
+ -
+
+ Texture map files
+
+
+
-