From d0c381ed9415c668977c42d62629aade93801dd1 Mon Sep 17 00:00:00 2001 From: sfb Date: Tue, 7 Jun 2011 12:14:10 -0500 Subject: [PATCH] Changed: Added 'data directory' box and re-arranged filters. --- .../mission_compiler_main_window.cpp | 82 +++++++++++++++--- .../mission_compiler_main_window.h | 5 ++ .../mission_compiler_main_window.ui | 86 ++++++++++++++----- 3 files changed, 137 insertions(+), 36 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp index e760d9f94..f7da41ff2 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include "../core/icore.h" #include "../core/imenu_manager.h" @@ -27,6 +29,7 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) : { ui->setupUi(this); + m_lastDir = "."; m_compileLog = ""; updateCompileLog(); @@ -35,24 +38,11 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) : m_undoStack = new QUndoStack(this); - // Populate the "all" primitives box. - QStringList list; - std::vector paths; - NLMISC::CPath::getFileList("primitive", paths); - - std::vector::iterator itr = paths.begin(); - while( itr != paths.end() ) - { - const char *path2 = (*itr).c_str(); - list << path2; - ++itr; - } - m_regexpFilter = new QRegExp(); m_regexpFilter->setPatternSyntax(QRegExp::FixedString); m_regexpFilter->setCaseSensitivity(Qt::CaseInsensitive); - m_allPrimitivesModel = new QStringListModel(list, this); + m_allPrimitivesModel = new QStringListModel(this); m_filteredProxyModel = new QSortFilterProxyModel(this); m_filteredProxyModel->setSourceModel(m_allPrimitivesModel); m_filteredProxyModel->setDynamicSortFilter(true); @@ -65,12 +55,63 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) : connect(ui->actionValidate, SIGNAL(triggered()), this, SLOT(handleValidation())); connect(ui->actionCompile, SIGNAL(triggered()), this, SLOT(handleCompile())); connect(ui->actionPublish, SIGNAL(triggered()), this, SLOT(handlePublish())); + connect(ui->allPrimitivesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(handleAllDoubleClick(const QModelIndex &))); + connect(ui->dataDirButton, SIGNAL(clicked()), this, SLOT(handleDataDirButton())); + connect(ui->dataDirEdit, SIGNAL(textChanged(const QString &)), this, SLOT(handleDataDirChanged(const QString &))); + + // Set the default data dir to the primitives path. + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(Core::Constants::DATA_PATH_SECTION); + m_lastDir = settings->value(Core::Constants::PRIMITIVES_PATH).toString(); + ui->dataDirEdit->setText(m_lastDir); + populateAllPrimitives(m_lastDir); + settings->endGroup(); NLLIGO::Register(); m_ligoConfig.readPrimitiveClass(NLMISC::CPath::lookup("world_editor_classes.xml").c_str(), false); NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig; } +void MissionCompilerMainWindow::populateAllPrimitives(const QString &dataDir) +{ + // First we need to clear out the models entirely. + QStringList emptyList; + m_selectedPrimitivesModel->setStringList(emptyList); + m_allPrimitivesModel->setStringList(emptyList); + + + // Populate the "all" primitives box. + QStringList list; + + // Filter for only primitive files. + QStringList filters; + filters << "*.primitive"; + + QDirIterator it(dataDir, filters, QDir::Files, QDirIterator::Subdirectories|QDirIterator::FollowSymlinks); + while(it.hasNext()) + { + it.next(); + list << it.fileName(); + } + + m_allPrimitivesModel->setStringList(list); +} +void MissionCompilerMainWindow::handleDataDirChanged(const QString &text) +{ + populateAllPrimitives(text); +} + +void MissionCompilerMainWindow::handleDataDirButton() +{ + QString newPath = QFileDialog::getExistingDirectory(this, "", m_lastDir); + if(!newPath.isEmpty()) + { + ui->dataDirEdit->setText(newPath); + m_lastDir = newPath; + populateAllPrimitives(newPath); + } +} + void MissionCompilerMainWindow::handleFilterChanged(const QString &text) { m_regexpFilter->setPattern(text); @@ -87,6 +128,19 @@ void MissionCompilerMainWindow::handlePublish() compileMission(true); } +void MissionCompilerMainWindow::handleAllDoubleClick(const QModelIndex &index) +{ + const QAbstractItemModel *model = index.model(); + QString item = model->data(index).toString(); + nlinfo("all primitives was double clicked: %s", item.toAscii().data()); + + m_filteredProxyModel->removeRows(index.row(),1); + + QStringList list = m_selectedPrimitivesModel->stringList(); + list << item; + m_selectedPrimitivesModel->setStringList(list); +} + void MissionCompilerMainWindow::compileMission(bool publish) { uint nbMission = 0; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h index 7c4feb78a..2248a7cc5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.h @@ -38,11 +38,15 @@ public Q_SLOTS: void handleValidation(); void handleCompile(); void handlePublish(); + void handleAllDoubleClick(const QModelIndex &index); + void handleDataDirButton(); + void handleDataDirChanged(const QString &text); private: Ui::MissionCompilerMainWindow *ui; void updateCompileLog(); + void populateAllPrimitives(const QString &dataDir = QString()); bool parsePrimForMissions(NLLIGO::IPrimitive const *prim, TMissionContainer &missions); void compileMission(bool publish=false); @@ -53,6 +57,7 @@ private: QSortFilterProxyModel *m_filteredProxyModel; QRegExp *m_regexpFilter; QString m_compileLog; + QString m_lastDir; NLLIGO::CLigoConfig m_ligoConfig; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.ui b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.ui index 865cb20d2..a995f0dab 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.ui @@ -33,7 +33,7 @@ Mission Compiler Options - + @@ -132,7 +132,7 @@ - + true @@ -157,7 +157,7 @@ - + true @@ -182,41 +182,83 @@ - + All Primitives - + Selected Primitives - - - - - - Filter - - - - - - - type filter here - - - - + + + + Filter Criteria + + + + + + + + Data Directory + + + + + + + + + + ... + + + + + + + + + + + Filter + + + + + + + type filter here + + + + + + + horizontalLayoutWidget + dataDirLabel + horizontalLayoutWidget + + + + + 0 + 0 + 776 + 426 + + Publish Options