From e6df7a770303c57e8eaa9027417adbefc8a7887b Mon Sep 17 00:00:00 2001 From: sfb Date: Thu, 26 Apr 2012 13:05:53 -0500 Subject: [PATCH] Changed: #1306 Implemented add/removing parent sheets, moved everything out of Plugin and into GeorgesQt namespace to eliminate ambiguity with other plugins. --- .../georges_editor/expandable_headerview.cpp | 2 +- .../georges_editor/expandable_headerview.h | 2 +- .../plugins/georges_editor/formdelegate.cpp | 4 +- .../src/plugins/georges_editor/formdelegate.h | 2 +- .../src/plugins/georges_editor/formitem.cpp | 2 +- .../src/plugins/georges_editor/formitem.h | 2 +- .../src/plugins/georges_editor/georges.cpp | 4 +- .../src/plugins/georges_editor/georges.h | 4 +- .../georges_editor/georges_dirtree_dialog.cpp | 4 +- .../georges_editor/georges_dirtree_dialog.h | 4 +- .../georges_editor/georges_editor_constants.h | 4 +- .../georges_editor/georges_editor_form.cpp | 4 +- .../georges_editor/georges_editor_form.h | 4 +- .../georges_editor/georges_editor_plugin.cpp | 4 +- .../georges_editor/georges_editor_plugin.h | 4 +- .../georges_filesystem_model.cpp | 4 +- .../georges_editor/georges_filesystem_model.h | 4 +- .../georges_treeview_dialog.cpp | 134 ++++++++++++++++-- .../georges_editor/georges_treeview_dialog.h | 9 +- .../georges_editor/georgesform_model.cpp | 31 +++- .../georges_editor/georgesform_model.h | 10 +- .../georgesform_proxy_model.cpp | 4 +- .../georges_editor/georgesform_proxy_model.h | 4 +- 23 files changed, 192 insertions(+), 58 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.cpp index 7ae482824..2967be435 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.cpp @@ -22,7 +22,7 @@ #include #include -namespace Plugin +namespace GeorgesQt { ExpandableHeaderView::ExpandableHeaderView(Qt::Orientation orientation, QWidget * parent) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.h index 596bf5ba1..f7f26eafc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/expandable_headerview.h @@ -20,7 +20,7 @@ // Qt includes #include -namespace Plugin +namespace GeorgesQt { class ExpandableHeaderView : public QHeaderView { diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.cpp index 4d04bc6b5..be358d065 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.cpp @@ -37,7 +37,7 @@ #include "georgesform_proxy_model.h" #include "formitem.h" -namespace Plugin +namespace GeorgesQt { FormDelegate::FormDelegate(QObject *parent) @@ -275,4 +275,4 @@ namespace Plugin QRect r = option.rect; editor->setGeometry(r); } -} /* namespace Plugin */ +} /* namespace GeorgesQt */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.h index a309da1fc..486308536 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formdelegate.h @@ -19,7 +19,7 @@ #include -namespace Plugin +namespace GeorgesQt { class FormDelegate : public QStyledItemDelegate diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp index 205e18a52..68f29064d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.cpp @@ -23,7 +23,7 @@ #include #include -namespace Plugin +namespace GeorgesQt { CFormItem::CFormItem(NLGEORGES::UFormElm* elm, const QList &data, CFormItem *parent, diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h index b85b12275..80efce5d5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h @@ -24,7 +24,7 @@ #include #include -namespace Plugin +namespace GeorgesQt { class CFormItem diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges.cpp index b93f93ec4..50e007d90 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges.cpp @@ -28,7 +28,7 @@ using namespace NLGEORGES; -namespace Plugin +namespace GeorgesQt { CGeorges::CGeorges(): FormLoader(0) @@ -61,4 +61,4 @@ namespace Plugin return type; } -} /* namespace Plugin */ +} /* namespace GeorgesQt */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges.h index eb9a6b7da..6d7455d3b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges.h @@ -38,7 +38,7 @@ namespace NLGEORGES using namespace NLGEORGES; -namespace Plugin +namespace GeorgesQt { /** @@ -64,6 +64,6 @@ namespace Plugin };/* class CGeorges */ -} /* namespace Plugin */ +} /* namespace GeorgesQt */ #endif // GEORGES_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_dirtree_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_dirtree_dialog.cpp index de7a105ab..163ec7877 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_dirtree_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_dirtree_dialog.cpp @@ -23,7 +23,7 @@ // NeL includes -namespace Plugin +namespace GeorgesQt { CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent) @@ -109,4 +109,4 @@ void CGeorgesDirTreeDialog::ldPathChanged(QString path) } } -} /* namespace NLQT */ \ No newline at end of file +} /* namespace GeorgesQt */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_dirtree_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_dirtree_dialog.h index fa783bca0..dc717617e 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_dirtree_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_dirtree_dialog.h @@ -28,7 +28,7 @@ #include "ui_georges_dirtree_form.h" #include "georges_filesystem_model.h" -namespace Plugin +namespace GeorgesQt { class CGeorgesDirTreeDialog: public QDockWidget @@ -57,6 +57,6 @@ private Q_SLOTS: }; /* CGEorgesDirTreeDialog */ -} /* namespace NLQT */ +} /* namespace GeorgesQt */ #endif // GEORGES_DIRTREE_DIALOG_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_constants.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_constants.h index bb9fe3306..cccede9fc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_constants.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_constants.h @@ -17,7 +17,7 @@ #ifndef GEORGES_EDITOR_CONSTANTS_H #define GEORGES_EDITOR_CONSTANTS_H -namespace Plugin +namespace GeorgesQt { namespace Constants { @@ -26,6 +26,6 @@ const char * const GEORGES_EDITOR_SECTION = "GeorgesEditor"; } // namespace Constants -} // namespace Plugin +} // namespace GeorgesQt #endif // GEORGES_EDITOR_CONSTANTS_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.cpp index 0cc5b9542..a9666c8db 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.cpp @@ -33,7 +33,7 @@ #include #include -namespace Plugin +namespace GeorgesQt { GeorgesEditorForm::GeorgesEditorForm(QWidget *parent) @@ -271,4 +271,4 @@ namespace Plugin } } } -} /* namespace Plugin */ +} /* namespace GeorgesQt */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.h index 6b270ca3d..c991f8b9f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_form.h @@ -23,7 +23,7 @@ // Qt includes #include -namespace Plugin +namespace GeorgesQt { class CGeorgesDirTreeDialog; @@ -70,6 +70,6 @@ private: CGeorgesTreeViewDialog *m_lastActiveDock; }; /* class GeorgesEditorForm */ -} /* namespace Plugin */ +} /* namespace GeorgesQt */ #endif // GEORGES_EDITOR_FORM_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_plugin.cpp index 199bc20ca..7dd0be5cd 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_plugin.cpp @@ -27,7 +27,7 @@ // Qt includes #include -namespace Plugin +namespace GeorgesQt { GeorgesEditorPlugin::~GeorgesEditorPlugin() @@ -97,4 +97,4 @@ QWidget *GeorgesEditorContext::widget() } -Q_EXPORT_PLUGIN(Plugin::GeorgesEditorPlugin) \ No newline at end of file +Q_EXPORT_PLUGIN(GeorgesQt::GeorgesEditorPlugin) \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_plugin.h index fabdd600c..e21d8c57a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_editor_plugin.h @@ -38,7 +38,7 @@ namespace ExtensionSystem class IPluginSpec; } -namespace Plugin +namespace GeorgesQt { class GeorgesEditorForm; class GeorgesEditorPlugin : public QObject, public ExtensionSystem::IPlugin @@ -93,6 +93,6 @@ public: GeorgesEditorForm *m_georgesEditorForm; }; -} // namespace Plugin +} // namespace GeorgesQt #endif // LANDSCAPE_EDITOR_PLUGIN_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_filesystem_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_filesystem_model.cpp index 4e021f681..7f405fb75 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_filesystem_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_filesystem_model.cpp @@ -19,7 +19,7 @@ #include #include -namespace Plugin +namespace GeorgesQt { CGeorgesFileSystemModel::CGeorgesFileSystemModel(QString ldPath, QObject *parent) @@ -159,6 +159,6 @@ void CGeorgesFileSystemModel::checkLDPath() // } // return QSortFilterProxyModel::data(index, role); //} -} /* namespace NLQT */ +} /* namespace GeorgesQt */ /* end of file */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_filesystem_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_filesystem_model.h index 03eb5ecc2..6c7a26055 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_filesystem_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_filesystem_model.h @@ -20,7 +20,7 @@ #include #include -namespace Plugin +namespace GeorgesQt { class CGeorgesFileSystemModel : public QFileSystemModel @@ -74,6 +74,6 @@ private Q_SLOTS: // bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; //}; -} /* namespace NLQT */ +} /* namespace GeorgesQt */ #endif // GEORGES_FILESYSTEM_MODEL_H \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp index ac72cd747..dccb5f07b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -27,7 +27,14 @@ #include #include #include +#include #include +#include +#include + +// OVQT Includes +#include "../core/icore.h" +#include "../core/core_constants.h" // Project includes #include "georges.h" @@ -40,7 +47,7 @@ using namespace NLMISC; using namespace NLGEORGES; -namespace Plugin +namespace GeorgesQt { CGeorgesTreeViewDialog::CGeorgesTreeViewDialog(QWidget *parent /*= 0*/) @@ -51,6 +58,11 @@ namespace Plugin m_georges = new CGeorges; loadedForm = ""; + // Set the default sheet dir dir to the level design path. + m_lastSheetDir = "."; + QSettings *settings = Core::ICore::instance()->settings(); + m_lastSheetDir = settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString(); + settings->endGroup(); m_ui.setupUi(this); m_header = new ExpandableHeaderView(Qt::Horizontal, m_ui.treeView); @@ -208,9 +220,34 @@ namespace Plugin } } - void CGeorgesTreeViewDialog::addParentForm(CForm *form) + void CGeorgesTreeViewDialog::addParentForm(QString parentFormNm) { - //((CForm*)_form)->insertParent(((CForm*)_form)->getParentCount(), form->getFilename().c_str(), form); + // Try to load the form + NLGEORGES::UForm *uParentForm = m_georges->loadForm(parentFormNm.toStdString()); + NLGEORGES::CForm *parentForm = dynamic_cast(uParentForm); + NLGEORGES::CForm *mainForm = static_cast(m_form); + + CGeorgesFormProxyModel * proxyModel = dynamic_cast(m_ui.treeView->model()); + CGeorgesFormModel *model = dynamic_cast(proxyModel->sourceModel()); + + if(parentForm) + { + if (mainForm != parentForm) + { + // Check it is the same dfn + if (parentForm->Elements.FormDfn == mainForm->Elements.FormDfn) + { + // This is the parent form selector + if(!mainForm->insertParent(mainForm->getParentCount(),parentFormNm.toStdString().c_str(), parentForm)) + nlwarning("Failed to add parent form: %s", parentFormNm.toStdString().c_str()); + else + { + nlinfo("Successfullyadded parent form: %s", parentFormNm.toStdString().c_str()); + model->addParentForm(parentFormNm); + } + } + } + } } void CGeorgesTreeViewDialog::modifiedFile( ) @@ -393,6 +430,7 @@ namespace Plugin void CGeorgesTreeViewDialog::showContextMenu(const QPoint &pos) { QMenu contextMenu; + QMenu *structContext = NULL; QPoint globalPos = this->mapToGlobal(pos); // Fisrt we're going to see if we've right clicked on a new item and select it. @@ -410,32 +448,100 @@ namespace Plugin CFormItem *item = m->getItem(sourceIndex); - if ((item->parent() && item->parent()->data(0) == "parents") || item->data(0) == "parents") + // Right click on the "parents" item + if (item->data(0) == "parents") contextMenu.addAction("Add parent..."); + // Right click on a parent item + else if(item->parent() && item->parent()->data(0) == "parents") + { + contextMenu.addAction("Add parent..."); + contextMenu.addAction("Remove parent"); + } else if(item->getFormElm()->isArray()) contextMenu.addAction("Add array entry..."); else if(item->getFormElm()->isStruct()) - contextMenu.addAction("Add element..."); + { + QMenu *structContext = new QMenu("Add struct element...", this); + contextMenu.addMenu(structContext); + + NLGEORGES::UFormDfn *defn = item->getFormElm()->getStructDfn(); + if(defn) + { + for(uint defnNum=0; defnNum < defn->getNumEntry(); defnNum++) + { + std::string entryName; + std::string dummy; + UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; + bool result = defn->getEntryName(defnNum, entryName); + bool result2 = item->getFormElm()->getValueByName(dummy, entryName.c_str(), NLGEORGES::UFormElm::Eval, whereV); + + + if(result2 && *whereV != UFormElm::ValueForm) + { + structContext->addAction(entryName.c_str()); + } + delete whereV; + } + } + } else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm) contextMenu.addAction("Revert to parent/default..."); - else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueParentForm) - contextMenu.addAction("Override parent/default value..."); - else - contextMenu.addAction("Add element..."); QAction *selectedItem = contextMenu.exec(globalPos); if(selectedItem) { if(selectedItem->text() == "Add parent...") { - QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select parent sheets...")); + // Get the file extension of the form so we can build a dialog pattern. + QString file = m_form->getFilename().c_str(); + file = file.remove(0,file.indexOf(".")+1); + QString filePattern = "Parent Sheets (*."+file+")"; + + nlinfo("parent defn name '%s'", file.toStdString().c_str()); + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select parent sheets..."), m_lastSheetDir, filePattern); if(!fileNames.isEmpty()) { - // add some parents. + Q_FOREACH(QString fileToParent, fileNames) + { + // Get just the filename. Georges doesn't want the path. + QFileInfo pathInfo( fileToParent ); + QString tmpFileName( pathInfo.fileName() ); + + nlinfo("requesting to add parent form '%s'", tmpFileName.toStdString().c_str()); + + // Call to add the form and load it into the Georges form. + addParentForm(tmpFileName); + + // Save the file lookup path for future dialog boxes. + m_lastSheetDir = pathInfo.absolutePath(); + } } + m_ui.treeView->expandAll(); } - } - } + else if(selectedItem->text() == "Remove parent") + { + NLGEORGES::CForm *form = static_cast(m_form); + QString parentFileName = item->data(0).toString(); + + for(uint num = 0; num < form->getParentCount(); num++) + { + QString curParentName = form->getParent(num)->getFilename().c_str(); + if(parentFileName == curParentName) + { + form->removeParent(num); + m->removeParentForm(parentFileName); + break; + } + } + + m_ui.treeView->expandAll(); + } + + } // if selected context menu item is valid. + } // if 'm' model valid. + + if(structContext) + delete structContext; } -} /* namespace NLQT */ +} /* namespace GeorgesQt */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.h index 8c2db3d47..a7ff4c375 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.h @@ -40,7 +40,7 @@ namespace NLGEORGES using namespace NLGEORGES; -namespace Plugin +namespace GeorgesQt { class CGeorges; @@ -57,7 +57,7 @@ namespace Plugin void setModified(bool m) {m_modified = m;} CForm* getFormByName(const QString); - void addParentForm(CForm *form); + void addParentForm(QString parentFormNm); void write ( ); @@ -97,10 +97,13 @@ namespace Plugin QUndoStack *m_undoStack; + /// Contains a record of the last directory a sheet file dialog was opened for. + QString m_lastSheetDir; + bool m_modified; }; /* CGeorgesTreeViewDialog */ -} /* namespace NLQT */ +} /* namespace GeorgesQt */ #endif // GEORGES_TREEVIEWER_DIALOG_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp index f6b9c441b..ca016e052 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.cpp @@ -40,16 +40,16 @@ using namespace NLGEORGES; -namespace Plugin +namespace GeorgesQt { CGeorgesFormModel::CGeorgesFormModel(UFormElm *rootElm, QMap< QString, QStringList> deps, QString comment, QStringList parents, bool *expanded, QObject *parent) : QAbstractItemModel(parent) { - QList rootData; - rootData << "Value" << "Data" << "Extra";// << "Type"; + + m_rootData << "Value" << "Data" << "Extra";// << "Type"; m_rootElm = rootElm; - m_rootItem = new CFormItem(m_rootElm, rootData); + m_rootItem = new CFormItem(m_rootElm, m_rootData); m_dependencies = deps; m_comments = comment; m_parents = parents; @@ -669,6 +669,27 @@ namespace Plugin Q_EMIT layoutAboutToBeChanged(); Q_EMIT layoutChanged(); } -} /* namespace Plugin */ + + void CGeorgesFormModel::addParentForm(QString parentForm) + { + beginResetModel(); + m_parents.push_back(parentForm); + delete m_rootItem; + m_rootItem = new CFormItem(m_rootElm, m_rootData); + setupModelData(); + endResetModel(); + } + + void CGeorgesFormModel::removeParentForm(QString parentForm) + { + beginResetModel(); + m_parents.removeOne(parentForm); + + delete m_rootItem; + m_rootItem = new CFormItem(m_rootElm, m_rootData); + setupModelData(); + endResetModel(); + } +} /* namespace GeorgesQt */ /* end of file */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h index 0d8ce6e69..05fadc498 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_model.h @@ -29,7 +29,7 @@ namespace NLGEORGES { class UFormElm; } -namespace Plugin +namespace GeorgesQt { class CFormItem; @@ -56,6 +56,9 @@ namespace Plugin bool showDefaults() { return m_showDefaults;} void setShowParents( bool show ); void setShowDefaults( bool show ); + void addParentForm(QString parentForm); + void removeParentForm(QString parentForm); + NLGEORGES::UFormElm *getRootForm() { return m_rootElm; } private: void setupModelData(); @@ -64,6 +67,7 @@ namespace Plugin CFormItem* m_rootItem; NLGEORGES::UFormElm* m_rootElm; + QList m_rootData; QMap< QString, QStringList> m_dependencies; QString m_comments; QStringList m_parents; @@ -71,10 +75,10 @@ namespace Plugin bool m_showParents; bool m_showDefaults; - bool *m_expanded; + bool *m_expanded; };/* class CGeorgesFormModel */ -} /* namespace Plugin */ +} /* namespace GeorgesQt */ #endif // GEORGESFORM_MODEL_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.cpp index ae3720a57..a99997925 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.cpp @@ -23,7 +23,7 @@ #include "georgesform_proxy_model.h" #include "georgesform_model.h" -namespace Plugin +namespace GeorgesQt { bool CGeorgesFormProxyModel::filterAcceptsRow(int sourceRow, @@ -76,6 +76,6 @@ namespace Plugin { return QSortFilterProxyModel::filterAcceptsColumn(sourceRow, sourceParent); } -} /* namespace Plugin */ +} /* namespace GeorgesQt */ /* end of file */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.h index 570913dab..73c384a99 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georgesform_proxy_model.h @@ -20,7 +20,7 @@ // Qt includes #include -namespace Plugin +namespace GeorgesQt { class CGeorgesFormProxyModel : public QSortFilterProxyModel @@ -40,6 +40,6 @@ namespace Plugin };/* class CGeorgesFormProxyModel */ -} /* namespace NLQT */ +} /* namespace GeorgesQt */ #endif // GEORGESFORM_PROXY_MODEL_H