Changed: #1306 small additions/bug fixed here and there for your viewing pleasure :)
This commit is contained in:
parent
414e0e92f9
commit
e9887d5943
10 changed files with 102 additions and 72 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ private:
|
|||
Ui::CGeorgesDirTreeDialog m_ui;
|
||||
|
||||
CGeorgesFileSystemModel *m_dirModel;
|
||||
CGeorgesFileSystemProxyModel *m_proxyModel;
|
||||
//CGeorgesFileSystemProxyModel *m_proxyModel;
|
||||
QString m_ldPath;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -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<CGeorgesTreeViewDialog*>(sender()));
|
||||
i = m_dockedWidgets.size();
|
||||
int j = i;
|
||||
}
|
||||
|
||||
} /* namespace Plugin */
|
||||
|
|
|
@ -44,6 +44,7 @@ public Q_SLOTS:
|
|||
void save();
|
||||
void settingsChanged();
|
||||
void loadFile(const QString fileName);
|
||||
void closingTreeView();
|
||||
|
||||
private:
|
||||
void readSettings();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
//{
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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<CGeorgesFormProxyModel *>(_ui.treeView->model());
|
||||
//CGeorgesFormModel *m =
|
||||
// dynamic_cast<CGeorgesFormModel *>(mp->sourceModel());
|
||||
//QModelIndex in = mp->mapToSource(index);
|
||||
CGeorgesFormProxyModel * proxyModel =
|
||||
dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model());
|
||||
CGeorgesFormModel *model =
|
||||
dynamic_cast<CGeorgesFormModel *>(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()
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -573,12 +573,15 @@ namespace Plugin
|
|||
void CGeorgesFormModel::loadFormHeader()
|
||||
{
|
||||
|
||||
CFormItem *fi_pars = new CFormItem(m_rootElm, QList<QVariant>() << "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<QVariant>() << str, fi_pars));
|
||||
CFormItem *fi_pars = new CFormItem(m_rootElm, QList<QVariant>() << "parents" << "" << "", m_rootItem);
|
||||
m_rootItem->appendChild(fi_pars);
|
||||
|
||||
Q_FOREACH(QString str, m_parents)
|
||||
{
|
||||
fi_pars->appendChild(new CFormItem(m_rootElm, QList<QVariant>() << str << "" << "", fi_pars));
|
||||
}
|
||||
}
|
||||
|
||||
/*QStringList dfns = _dependencies["dfn"];
|
||||
|
|
Loading…
Reference in a new issue