From 421a434c872456b9154bf494f3f30df2c9f7cff3 Mon Sep 17 00:00:00 2001 From: aquiles Date: Tue, 16 Aug 2011 20:48:24 +0200 Subject: [PATCH] Changed: #1306 small additions/bug fixed here and there for your viewing pleasure :) --- .../georges_editor/georges_dirtree_dialog.cpp | 25 ++++++------- .../georges_editor/georges_dirtree_dialog.h | 2 +- .../georges_editor/georges_editor_form.cpp | 37 ++++++++++++++++--- .../georges_editor/georges_editor_form.h | 1 + .../georges_editor/georges_editor_plugin.cpp | 5 ++- .../georges_filesystem_model.cpp | 34 +++++++++-------- .../georges_editor/georges_filesystem_model.h | 16 ++++---- .../georges_treeview_dialog.cpp | 36 ++++++++---------- .../georges_editor/georges_treeview_dialog.h | 5 ++- .../georges_editor/georgesform_model.cpp | 13 ++++--- 10 files changed, 102 insertions(+), 72 deletions(-) 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 2a1151164..de7a105ab 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 @@ -28,8 +28,7 @@ namespace Plugin CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent) :QDockWidget(parent), - m_ldPath(ldPath), - m_proxyModel(0) + m_ldPath(ldPath) { m_ui.setupUi(this); @@ -38,10 +37,10 @@ CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent) QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton)); m_dirModel = new CGeorgesFileSystemModel(m_ldPath); - m_proxyModel = new CGeorgesFileSystemProxyModel(this); + //m_proxyModel = new CGeorgesFileSystemProxyModel(this); - m_proxyModel->setSourceModel(m_dirModel); - m_ui.dirTree->setModel(m_proxyModel); + //m_proxyModel->setSourceModel(m_dirModel); + m_ui.dirTree->setModel(m_dirModel); // TODO: filtering in tree model is ... complicated - so hide it for now m_ui.filterLineEdit->hide(); @@ -51,7 +50,7 @@ CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent) if (m_dirModel->isCorrectLDPath()) { m_dirModel->setRootPath(m_ldPath); - m_ui.dirTree->setRootIndex(m_proxyModel->mapFromSource(m_dirModel->index(m_ldPath))); + m_ui.dirTree->setRootIndex(m_dirModel->index(m_ldPath)); } else { @@ -72,9 +71,9 @@ CGeorgesDirTreeDialog::~CGeorgesDirTreeDialog() void CGeorgesDirTreeDialog::fileSelected(QModelIndex index) { - if (index.isValid() && !m_dirModel->isDir(m_proxyModel->mapToSource(index))) + if (index.isValid() && !m_dirModel->isDir(index)) { - Q_EMIT selectedForm(m_dirModel->fileName(m_proxyModel->mapToSource(index))); + Q_EMIT selectedForm(m_dirModel->fileName(index)); } } @@ -91,18 +90,18 @@ void CGeorgesDirTreeDialog::ldPathChanged(QString path) m_ldPath = path; delete m_dirModel; - delete m_proxyModel; + //delete m_proxyModel; m_dirModel = new CGeorgesFileSystemModel(m_ldPath); - m_proxyModel = new CGeorgesFileSystemProxyModel(this); + //m_proxyModel = new CGeorgesFileSystemProxyModel(this); - m_proxyModel->setSourceModel(m_dirModel); - m_ui.dirTree->setModel(m_proxyModel); + //m_proxyModel->setSourceModel(m_dirModel); + m_ui.dirTree->setModel(m_dirModel); if (m_dirModel->isCorrectLDPath()) { m_dirModel->setRootPath(m_ldPath); - m_ui.dirTree->setRootIndex(m_proxyModel->mapFromSource(m_dirModel->index(m_ldPath))); + m_ui.dirTree->setRootIndex(m_dirModel->index(m_ldPath)); } else { 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 d81897bf3..fa783bca0 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 @@ -45,7 +45,7 @@ private: Ui::CGeorgesDirTreeDialog m_ui; CGeorgesFileSystemModel *m_dirModel; - CGeorgesFileSystemProxyModel *m_proxyModel; + //CGeorgesFileSystemProxyModel *m_proxyModel; QString m_ldPath; Q_SIGNALS: 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 21aa6d8c6..c623d440b 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 @@ -198,23 +198,48 @@ namespace Plugin { m_dockedWidgets.append(new CGeorgesTreeViewDialog(m_mainDock)); m_mainDock->addDockWidget(Qt::RightDockWidgetArea, m_dockedWidgets.last()); + connect(m_dockedWidgets.last(), SIGNAL(closing()), + this, SLOT(closingTreeView())); } else { + + Q_FOREACH(QDockWidget *wgt, m_dockedWidgets) + { + if (info.fileName() == wgt->windowTitle()) + { + wgt->raise(); + return; + } + } m_dockedWidgets.append(new CGeorgesTreeViewDialog(m_mainDock)); + connect(m_dockedWidgets.last(), SIGNAL(closing()), + this, SLOT(closingTreeView())); Q_ASSERT(m_dockedWidgets.size() > 1); m_mainDock->tabifyDockWidget(m_dockedWidgets.at(m_dockedWidgets.size() - 2), m_dockedWidgets.last()); } CForm *form = m_dockedWidgets.last()->getFormByName(info.fileName()); if (form) { - // delete newView; - // newView = createTreeView(fileName); - m_dockedWidgets.last()->setForm(form); - m_dockedWidgets.last()->loadFormIntoDialog(form); - //setCurrentFile(info.fileName()); - // return; + m_dockedWidgets.last()->setForm(form); + m_dockedWidgets.last()->loadFormIntoDialog(form); + QApplication::processEvents(); + m_dockedWidgets.last()->raise(); + connect(m_dockedWidgets.last(), SIGNAL(changeFile(QString)), + m_georgesDirTreeDialog, SLOT(changeFile(QString))); + } + else + { + m_dockedWidgets.last()->close(); } } + void GeorgesEditorForm::closingTreeView() + { + int i = m_dockedWidgets.size(); + m_dockedWidgets.removeAll(qobject_cast(sender())); + i = m_dockedWidgets.size(); + int j = i; + } + } /* namespace Plugin */ 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 9e938f62c..4ed91a5f6 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 @@ -44,6 +44,7 @@ public Q_SLOTS: void save(); void settingsChanged(); void loadFile(const QString fileName); + void closingTreeView(); private: void readSettings(); 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 e6cad341d..9ea9ae5ff 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 @@ -90,8 +90,9 @@ QString GeorgesEditorPlugin::description() const QStringList GeorgesEditorPlugin::dependencies() const { QStringList list; - list.append(Core::Constants::OVQT_CORE_PLUGIN); - list.append("ObjectViewer"); // TODO + // TODO + //list.append(Core::Constants::OVQT_CORE_PLUGIN); + //list.append("ObjectViewer"); return list; } 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 796b3c457..4e021f681 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 @@ -28,8 +28,10 @@ CGeorgesFileSystemModel::CGeorgesFileSystemModel(QString ldPath, QObject *parent m_correct(false) { checkLDPath(); - connect(this, SIGNAL(directoryLoaded(QString)), - this, SLOT(dir(const QString))); + + // this yielded no relevant performance boost on my observations + //connect(this, SIGNAL(directoryLoaded(QString)), + // this, SLOT(dir(const QString))); } CGeorgesFileSystemModel::~CGeorgesFileSystemModel() @@ -39,6 +41,8 @@ CGeorgesFileSystemModel::~CGeorgesFileSystemModel() void CGeorgesFileSystemModel::dir(const QString &dir) { + // in theory this should prefetch all directory entries for the + // filesystem model to speed up later work QModelIndex i = index(dir); if (hasChildren(i)) { @@ -117,18 +121,18 @@ void CGeorgesFileSystemModel::checkLDPath() // return (!indexNode->populatedChildren);*/ //} -CGeorgesFileSystemProxyModel::CGeorgesFileSystemProxyModel(QObject *parent) : QSortFilterProxyModel(parent) -{ - setFilterCaseSensitivity(Qt::CaseInsensitive); -} +//CGeorgesFileSystemProxyModel::CGeorgesFileSystemProxyModel(QObject *parent) : QSortFilterProxyModel(parent) +//{ +// setFilterCaseSensitivity(Qt::CaseInsensitive); +//} -bool CGeorgesFileSystemProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const -{ +//bool CGeorgesFileSystemProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +//{ // TODO this is not perfect as it could be // eg it should filter all dirs which have no entry - QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); - if (sourceModel()->hasChildren(idx)) - { + //QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); + //if (sourceModel()->hasChildren(idx)) + //{ // QString d = sourceModel()->data(idx).toString(); // //QModelIndex i = mapFromSource(source_parent); // //if (hasChildren(i)) { @@ -139,10 +143,10 @@ bool CGeorgesFileSystemProxyModel::filterAcceptsRow(int source_row, const QModel // bool test = filterAcceptsRow(c, child); // }*/ // } - return true; - } - return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); -} + // return true; + //} + //return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); +//} //QVariant CGeorgesFileSystemProxyModel::data ( const QModelIndex & index, int role ) const //{ 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 8ee06b3ef..03eb5ecc2 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 @@ -61,18 +61,18 @@ private Q_SLOTS: // A modified QSortFilterProxyModel that always accepts the root nodes in the tree // so filtering is only done on the children. - class CGeorgesFileSystemProxyModel : public QSortFilterProxyModel - { - Q_OBJECT + //class CGeorgesFileSystemProxyModel : public QSortFilterProxyModel + //{ + // Q_OBJECT - public: - CGeorgesFileSystemProxyModel(QObject *parent = 0); + //public: + // CGeorgesFileSystemProxyModel(QObject *parent = 0); //QVariant data(const QModelIndex& index, int role) const ; - protected: - bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; - }; + //protected: + // bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; + //}; } /* namespace NLQT */ 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 2bcef52cb..09556a21a 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 @@ -31,7 +31,7 @@ #include "georges.h" #include "georgesform_model.h" #include "georgesform_proxy_model.h" -//#include "formitem.h" +#include "formitem.h" //#include "formdelegate.h" using namespace NLMISC; @@ -72,7 +72,6 @@ namespace Plugin { //delete _ui.treeView->itemDelegateForColumn(1); delete m_form; - deleteLater(); //QSettings settings("RyzomCore", "GeorgesQt"); //settings.setValue("dirViewGeometry", saveGeometry()); } @@ -288,11 +287,18 @@ namespace Plugin void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index ) { // TODO: this is messy :( perhaps this can be done better - //CGeorgesFormProxyModel * mp = - // dynamic_cast(_ui.treeView->model()); - //CGeorgesFormModel *m = - // dynamic_cast(mp->sourceModel()); - //QModelIndex in = mp->mapToSource(index); + CGeorgesFormProxyModel * proxyModel = + dynamic_cast(m_ui.treeView->model()); + CGeorgesFormModel *model = + dynamic_cast(proxyModel->sourceModel()); + QModelIndex sourceIndex = proxyModel->mapToSource(index); + + CFormItem *item = model->getItem(sourceIndex); + + if (item->parent() && item->parent()->data(0) == "parents") + { + Q_EMIT changeFile(CPath::lookup(item->data(0).toString().toStdString(),false).c_str()); + } //// col containing additional stuff like icons //if (index.column() == 2) @@ -344,20 +350,8 @@ namespace Plugin void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event) { - /*if (Modules::mainWin().getEmptyView() == this) - { - event->ignore(); - } - else - { - if(Modules::mainWin().getTreeViewList().size() == 1) - { - Modules::mainWin().createEmptyView( - Modules::mainWin().getTreeViewList().takeFirst()); - } - Modules::mainWin().getTreeViewList().removeOne(this); - deleteLater(); - }*/ + Q_EMIT closing(); + deleteLater(); } void CGeorgesTreeViewDialog::filterRows() 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 dee1216ca..9d4f02e5d 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 @@ -64,13 +64,16 @@ namespace Plugin protected: void closeEvent(QCloseEvent *event); - Q_SIGNALS: + Q_SIGNALS: void changeFile(QString); void modified(bool); + void closing(); + public Q_SLOTS: void setForm(const CForm*); void loadFormIntoDialog(CForm *form = 0); void modifiedFile( ); + private Q_SLOTS: void doubleClicked ( const QModelIndex & index ); void filterRows(); 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 234c2d169..0ec8f785a 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 @@ -573,12 +573,15 @@ namespace Plugin void CGeorgesFormModel::loadFormHeader() { - CFormItem *fi_pars = new CFormItem(m_rootElm, QList() << "parents", m_rootItem); - m_rootItem->appendChild(fi_pars); - - Q_FOREACH(QString str, m_parents) + if (m_parents.size()) { - fi_pars->appendChild(new CFormItem(m_rootElm, QList() << str, fi_pars)); + CFormItem *fi_pars = new CFormItem(m_rootElm, QList() << "parents" << "" << "", m_rootItem); + m_rootItem->appendChild(fi_pars); + + Q_FOREACH(QString str, m_parents) + { + fi_pars->appendChild(new CFormItem(m_rootElm, QList() << str << "" << "", fi_pars)); + } } /*QStringList dfns = _dependencies["dfn"];