Changed: #1306 small additions/bug fixed here and there for your viewing pleasure :)

This commit is contained in:
aquiles 2011-08-16 20:48:24 +02:00
parent 414e0e92f9
commit e9887d5943
10 changed files with 102 additions and 72 deletions

View file

@ -28,8 +28,7 @@ namespace Plugin
CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent) CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent)
:QDockWidget(parent), :QDockWidget(parent),
m_ldPath(ldPath), m_ldPath(ldPath)
m_proxyModel(0)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
@ -38,10 +37,10 @@ CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent)
QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton)); QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton));
m_dirModel = new CGeorgesFileSystemModel(m_ldPath); m_dirModel = new CGeorgesFileSystemModel(m_ldPath);
m_proxyModel = new CGeorgesFileSystemProxyModel(this); //m_proxyModel = new CGeorgesFileSystemProxyModel(this);
m_proxyModel->setSourceModel(m_dirModel); //m_proxyModel->setSourceModel(m_dirModel);
m_ui.dirTree->setModel(m_proxyModel); m_ui.dirTree->setModel(m_dirModel);
// TODO: filtering in tree model is ... complicated - so hide it for now // TODO: filtering in tree model is ... complicated - so hide it for now
m_ui.filterLineEdit->hide(); m_ui.filterLineEdit->hide();
@ -51,7 +50,7 @@ CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent)
if (m_dirModel->isCorrectLDPath()) if (m_dirModel->isCorrectLDPath())
{ {
m_dirModel->setRootPath(m_ldPath); 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 else
{ {
@ -72,9 +71,9 @@ CGeorgesDirTreeDialog::~CGeorgesDirTreeDialog()
void CGeorgesDirTreeDialog::fileSelected(QModelIndex index) 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; m_ldPath = path;
delete m_dirModel; delete m_dirModel;
delete m_proxyModel; //delete m_proxyModel;
m_dirModel = new CGeorgesFileSystemModel(m_ldPath); m_dirModel = new CGeorgesFileSystemModel(m_ldPath);
m_proxyModel = new CGeorgesFileSystemProxyModel(this); //m_proxyModel = new CGeorgesFileSystemProxyModel(this);
m_proxyModel->setSourceModel(m_dirModel); //m_proxyModel->setSourceModel(m_dirModel);
m_ui.dirTree->setModel(m_proxyModel); m_ui.dirTree->setModel(m_dirModel);
if (m_dirModel->isCorrectLDPath()) if (m_dirModel->isCorrectLDPath())
{ {
m_dirModel->setRootPath(m_ldPath); 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 else
{ {

View file

@ -45,7 +45,7 @@ private:
Ui::CGeorgesDirTreeDialog m_ui; Ui::CGeorgesDirTreeDialog m_ui;
CGeorgesFileSystemModel *m_dirModel; CGeorgesFileSystemModel *m_dirModel;
CGeorgesFileSystemProxyModel *m_proxyModel; //CGeorgesFileSystemProxyModel *m_proxyModel;
QString m_ldPath; QString m_ldPath;
Q_SIGNALS: Q_SIGNALS:

View file

@ -198,23 +198,48 @@ namespace Plugin
{ {
m_dockedWidgets.append(new CGeorgesTreeViewDialog(m_mainDock)); m_dockedWidgets.append(new CGeorgesTreeViewDialog(m_mainDock));
m_mainDock->addDockWidget(Qt::RightDockWidgetArea, m_dockedWidgets.last()); m_mainDock->addDockWidget(Qt::RightDockWidgetArea, m_dockedWidgets.last());
connect(m_dockedWidgets.last(), SIGNAL(closing()),
this, SLOT(closingTreeView()));
} }
else else
{ {
Q_FOREACH(QDockWidget *wgt, m_dockedWidgets)
{
if (info.fileName() == wgt->windowTitle())
{
wgt->raise();
return;
}
}
m_dockedWidgets.append(new CGeorgesTreeViewDialog(m_mainDock)); m_dockedWidgets.append(new CGeorgesTreeViewDialog(m_mainDock));
connect(m_dockedWidgets.last(), SIGNAL(closing()),
this, SLOT(closingTreeView()));
Q_ASSERT(m_dockedWidgets.size() > 1); Q_ASSERT(m_dockedWidgets.size() > 1);
m_mainDock->tabifyDockWidget(m_dockedWidgets.at(m_dockedWidgets.size() - 2), m_dockedWidgets.last()); m_mainDock->tabifyDockWidget(m_dockedWidgets.at(m_dockedWidgets.size() - 2), m_dockedWidgets.last());
} }
CForm *form = m_dockedWidgets.last()->getFormByName(info.fileName()); CForm *form = m_dockedWidgets.last()->getFormByName(info.fileName());
if (form) if (form)
{ {
// delete newView;
// newView = createTreeView(fileName);
m_dockedWidgets.last()->setForm(form); m_dockedWidgets.last()->setForm(form);
m_dockedWidgets.last()->loadFormIntoDialog(form); m_dockedWidgets.last()->loadFormIntoDialog(form);
//setCurrentFile(info.fileName()); QApplication::processEvents();
// return; 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<CGeorgesTreeViewDialog*>(sender()));
i = m_dockedWidgets.size();
int j = i;
}
} /* namespace Plugin */ } /* namespace Plugin */

View file

@ -44,6 +44,7 @@ public Q_SLOTS:
void save(); void save();
void settingsChanged(); void settingsChanged();
void loadFile(const QString fileName); void loadFile(const QString fileName);
void closingTreeView();
private: private:
void readSettings(); void readSettings();

View file

@ -90,8 +90,9 @@ QString GeorgesEditorPlugin::description() const
QStringList GeorgesEditorPlugin::dependencies() const QStringList GeorgesEditorPlugin::dependencies() const
{ {
QStringList list; QStringList list;
list.append(Core::Constants::OVQT_CORE_PLUGIN); // TODO
list.append("ObjectViewer"); // TODO //list.append(Core::Constants::OVQT_CORE_PLUGIN);
//list.append("ObjectViewer");
return list; return list;
} }

View file

@ -28,8 +28,10 @@ CGeorgesFileSystemModel::CGeorgesFileSystemModel(QString ldPath, QObject *parent
m_correct(false) m_correct(false)
{ {
checkLDPath(); 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() CGeorgesFileSystemModel::~CGeorgesFileSystemModel()
@ -39,6 +41,8 @@ CGeorgesFileSystemModel::~CGeorgesFileSystemModel()
void CGeorgesFileSystemModel::dir(const QString &dir) 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); QModelIndex i = index(dir);
if (hasChildren(i)) { if (hasChildren(i)) {
@ -117,18 +121,18 @@ void CGeorgesFileSystemModel::checkLDPath()
// return (!indexNode->populatedChildren);*/ // return (!indexNode->populatedChildren);*/
//} //}
CGeorgesFileSystemProxyModel::CGeorgesFileSystemProxyModel(QObject *parent) : QSortFilterProxyModel(parent) //CGeorgesFileSystemProxyModel::CGeorgesFileSystemProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
{ //{
setFilterCaseSensitivity(Qt::CaseInsensitive); // 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 // TODO this is not perfect as it could be
// eg it should filter all dirs which have no entry // eg it should filter all dirs which have no entry
QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); //QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
if (sourceModel()->hasChildren(idx)) //if (sourceModel()->hasChildren(idx))
{ //{
// QString d = sourceModel()->data(idx).toString(); // QString d = sourceModel()->data(idx).toString();
// //QModelIndex i = mapFromSource(source_parent); // //QModelIndex i = mapFromSource(source_parent);
// //if (hasChildren(i)) { // //if (hasChildren(i)) {
@ -139,10 +143,10 @@ bool CGeorgesFileSystemProxyModel::filterAcceptsRow(int source_row, const QModel
// bool test = filterAcceptsRow(c, child); // bool test = filterAcceptsRow(c, child);
// }*/ // }*/
// } // }
return true; // return true;
} //}
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); //return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
} //}
//QVariant CGeorgesFileSystemProxyModel::data ( const QModelIndex & index, int role ) const //QVariant CGeorgesFileSystemProxyModel::data ( const QModelIndex & index, int role ) const
//{ //{

View file

@ -61,18 +61,18 @@ private Q_SLOTS:
// A modified QSortFilterProxyModel that always accepts the root nodes in the tree // A modified QSortFilterProxyModel that always accepts the root nodes in the tree
// so filtering is only done on the children. // so filtering is only done on the children.
class CGeorgesFileSystemProxyModel : public QSortFilterProxyModel //class CGeorgesFileSystemProxyModel : public QSortFilterProxyModel
{ //{
Q_OBJECT // Q_OBJECT
public: //public:
CGeorgesFileSystemProxyModel(QObject *parent = 0); // CGeorgesFileSystemProxyModel(QObject *parent = 0);
//QVariant data(const QModelIndex& index, int role) const ; //QVariant data(const QModelIndex& index, int role) const ;
protected: //protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; // bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
}; //};
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -31,7 +31,7 @@
#include "georges.h" #include "georges.h"
#include "georgesform_model.h" #include "georgesform_model.h"
#include "georgesform_proxy_model.h" #include "georgesform_proxy_model.h"
//#include "formitem.h" #include "formitem.h"
//#include "formdelegate.h" //#include "formdelegate.h"
using namespace NLMISC; using namespace NLMISC;
@ -72,7 +72,6 @@ namespace Plugin
{ {
//delete _ui.treeView->itemDelegateForColumn(1); //delete _ui.treeView->itemDelegateForColumn(1);
delete m_form; delete m_form;
deleteLater();
//QSettings settings("RyzomCore", "GeorgesQt"); //QSettings settings("RyzomCore", "GeorgesQt");
//settings.setValue("dirViewGeometry", saveGeometry()); //settings.setValue("dirViewGeometry", saveGeometry());
} }
@ -288,11 +287,18 @@ namespace Plugin
void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index ) void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index )
{ {
// TODO: this is messy :( perhaps this can be done better // TODO: this is messy :( perhaps this can be done better
//CGeorgesFormProxyModel * mp = CGeorgesFormProxyModel * proxyModel =
// dynamic_cast<CGeorgesFormProxyModel *>(_ui.treeView->model()); dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model());
//CGeorgesFormModel *m = CGeorgesFormModel *model =
// dynamic_cast<CGeorgesFormModel *>(mp->sourceModel()); dynamic_cast<CGeorgesFormModel *>(proxyModel->sourceModel());
//QModelIndex in = mp->mapToSource(index); 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 //// col containing additional stuff like icons
//if (index.column() == 2) //if (index.column() == 2)
@ -344,20 +350,8 @@ namespace Plugin
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event) void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
{ {
/*if (Modules::mainWin().getEmptyView() == this) Q_EMIT closing();
{
event->ignore();
}
else
{
if(Modules::mainWin().getTreeViewList().size() == 1)
{
Modules::mainWin().createEmptyView(
Modules::mainWin().getTreeViewList().takeFirst());
}
Modules::mainWin().getTreeViewList().removeOne(this);
deleteLater(); deleteLater();
}*/
} }
void CGeorgesTreeViewDialog::filterRows() void CGeorgesTreeViewDialog::filterRows()

View file

@ -67,10 +67,13 @@ namespace Plugin
Q_SIGNALS: Q_SIGNALS:
void changeFile(QString); void changeFile(QString);
void modified(bool); void modified(bool);
void closing();
public Q_SLOTS: public Q_SLOTS:
void setForm(const CForm*); void setForm(const CForm*);
void loadFormIntoDialog(CForm *form = 0); void loadFormIntoDialog(CForm *form = 0);
void modifiedFile( ); void modifiedFile( );
private Q_SLOTS: private Q_SLOTS:
void doubleClicked ( const QModelIndex & index ); void doubleClicked ( const QModelIndex & index );
void filterRows(); void filterRows();

View file

@ -573,12 +573,15 @@ namespace Plugin
void CGeorgesFormModel::loadFormHeader() void CGeorgesFormModel::loadFormHeader()
{ {
CFormItem *fi_pars = new CFormItem(m_rootElm, QList<QVariant>() << "parents", m_rootItem); if (m_parents.size())
{
CFormItem *fi_pars = new CFormItem(m_rootElm, QList<QVariant>() << "parents" << "" << "", m_rootItem);
m_rootItem->appendChild(fi_pars); m_rootItem->appendChild(fi_pars);
Q_FOREACH(QString str, m_parents) Q_FOREACH(QString str, m_parents)
{ {
fi_pars->appendChild(new CFormItem(m_rootElm, QList<QVariant>() << str, fi_pars)); fi_pars->appendChild(new CFormItem(m_rootElm, QList<QVariant>() << str << "" << "", fi_pars));
}
} }
/*QStringList dfns = _dependencies["dfn"]; /*QStringList dfns = _dependencies["dfn"];