mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-18 21:26:12 +00:00
Merging default into cdb_refactoring.
--HG-- branch : cdb-refactoring
This commit is contained in:
commit
34b88eee65
26 changed files with 260 additions and 69 deletions
|
@ -76,9 +76,10 @@ ENDMACRO(NL_TARGET_DRIVER)
|
||||||
# Argument:
|
# Argument:
|
||||||
###
|
###
|
||||||
MACRO(NL_DEFAULT_PROPS name label)
|
MACRO(NL_DEFAULT_PROPS name label)
|
||||||
IF(NOT MSVC10)
|
# Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name.
|
||||||
SET_TARGET_PROPERTIES(${name} PROPERTIES PROJECT_LABEL ${label})
|
# CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819
|
||||||
ENDIF(NOT MSVC10)
|
STRING(REGEX REPLACE "\\:" " -" proj_label ${label})
|
||||||
|
SET_TARGET_PROPERTIES(${name} PROPERTIES PROJECT_LABEL ${proj_label})
|
||||||
GET_TARGET_PROPERTY(type ${name} TYPE)
|
GET_TARGET_PROPERTY(type ${name} TYPE)
|
||||||
IF(${type} STREQUAL SHARED_LIBRARY)
|
IF(${type} STREQUAL SHARED_LIBRARY)
|
||||||
# Set versions only if target is a shared library
|
# Set versions only if target is a shared library
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
ExpandableHeaderView::ExpandableHeaderView(Qt::Orientation orientation, QWidget * parent)
|
ExpandableHeaderView::ExpandableHeaderView(Qt::Orientation orientation, QWidget * parent)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
class ExpandableHeaderView : public QHeaderView
|
class ExpandableHeaderView : public QHeaderView
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include "georgesform_proxy_model.h"
|
#include "georgesform_proxy_model.h"
|
||||||
#include "formitem.h"
|
#include "formitem.h"
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
FormDelegate::FormDelegate(QObject *parent)
|
FormDelegate::FormDelegate(QObject *parent)
|
||||||
|
@ -275,4 +275,4 @@ namespace Plugin
|
||||||
QRect r = option.rect;
|
QRect r = option.rect;
|
||||||
editor->setGeometry(r);
|
editor->setGeometry(r);
|
||||||
}
|
}
|
||||||
} /* namespace Plugin */
|
} /* namespace GeorgesQt */
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class FormDelegate : public QStyledItemDelegate
|
class FormDelegate : public QStyledItemDelegate
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <nel/georges/u_type.h>
|
#include <nel/georges/u_type.h>
|
||||||
#include <nel/georges/form.h>
|
#include <nel/georges/form.h>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
CFormItem::CFormItem(NLGEORGES::UFormElm* elm, const QList<QVariant> &data, CFormItem *parent,
|
CFormItem::CFormItem(NLGEORGES::UFormElm* elm, const QList<QVariant> &data, CFormItem *parent,
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class CFormItem
|
class CFormItem
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
using namespace NLGEORGES;
|
using namespace NLGEORGES;
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
CGeorges::CGeorges(): FormLoader(0)
|
CGeorges::CGeorges(): FormLoader(0)
|
||||||
|
@ -61,4 +61,4 @@ namespace Plugin
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace Plugin */
|
} /* namespace GeorgesQt */
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace NLGEORGES
|
||||||
|
|
||||||
using namespace NLGEORGES;
|
using namespace NLGEORGES;
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,6 +64,6 @@ namespace Plugin
|
||||||
|
|
||||||
};/* class CGeorges */
|
};/* class CGeorges */
|
||||||
|
|
||||||
} /* namespace Plugin */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
#endif // GEORGES_H
|
#endif // GEORGES_H
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent)
|
CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent)
|
||||||
|
@ -109,4 +109,4 @@ void CGeorgesDirTreeDialog::ldPathChanged(QString path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace NLQT */
|
} /* namespace GeorgesQt */
|
|
@ -28,7 +28,7 @@
|
||||||
#include "ui_georges_dirtree_form.h"
|
#include "ui_georges_dirtree_form.h"
|
||||||
#include "georges_filesystem_model.h"
|
#include "georges_filesystem_model.h"
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class CGeorgesDirTreeDialog: public QDockWidget
|
class CGeorgesDirTreeDialog: public QDockWidget
|
||||||
|
@ -57,6 +57,6 @@ private Q_SLOTS:
|
||||||
|
|
||||||
}; /* CGEorgesDirTreeDialog */
|
}; /* CGEorgesDirTreeDialog */
|
||||||
|
|
||||||
} /* namespace NLQT */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
#endif // GEORGES_DIRTREE_DIALOG_H
|
#endif // GEORGES_DIRTREE_DIALOG_H
|
||||||
|
|
|
@ -44,6 +44,9 @@
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#ifndef GEORGES_EDITOR_CONSTANTS_H
|
#ifndef GEORGES_EDITOR_CONSTANTS_H
|
||||||
#define GEORGES_EDITOR_CONSTANTS_H
|
#define GEORGES_EDITOR_CONSTANTS_H
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
namespace Constants
|
namespace Constants
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,6 @@ const char * const GEORGES_EDITOR_SECTION = "GeorgesEditor";
|
||||||
|
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace Plugin
|
} // namespace GeorgesQt
|
||||||
|
|
||||||
#endif // GEORGES_EDITOR_CONSTANTS_H
|
#endif // GEORGES_EDITOR_CONSTANTS_H
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
GeorgesEditorForm::GeorgesEditorForm(QWidget *parent)
|
GeorgesEditorForm::GeorgesEditorForm(QWidget *parent)
|
||||||
|
@ -112,24 +112,9 @@ namespace Plugin
|
||||||
|
|
||||||
void GeorgesEditorForm::open()
|
void GeorgesEditorForm::open()
|
||||||
{
|
{
|
||||||
/*qDebug() << "GeorgesEditorForm::open()";
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Form"));
|
||||||
if (!m_dockedWidgets.size())
|
if(!fileName.isNull())
|
||||||
{
|
loadFile(fileName);
|
||||||
m_dockedWidgets.append(new CGeorgesTreeViewDialog(m_mainDock));
|
|
||||||
m_mainDock->addDockWidget(Qt::RightDockWidgetArea, m_dockedWidgets.last());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_dockedWidgets.append(new CGeorgesTreeViewDialog(m_mainDock));
|
|
||||||
Q_ASSERT(m_dockedWidgets.size() > 1);
|
|
||||||
m_mainDock->tabifyDockWidget(m_dockedWidgets.at(m_dockedWidgets.size() - 2), m_dockedWidgets.last());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// TODO: FileDialog & loadFile();
|
|
||||||
//m_mainDock->addDockWidget(Qt::TopDockWidgetArea, new CGeorgesTreeViewDialog(m_mainDock, true));
|
|
||||||
//m_mainDock->addDockWidget(Qt::LeftDockWidgetArea, new CGeorgesTreeViewDialog(m_mainDock, true));
|
|
||||||
//QString fileName = QFileDialog::getOpenFileName();
|
|
||||||
//loadFile(fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeorgesEditorForm::newFile()
|
void GeorgesEditorForm::newFile()
|
||||||
|
@ -191,6 +176,7 @@ namespace Plugin
|
||||||
if (!m_dockedWidgets.size())
|
if (!m_dockedWidgets.size())
|
||||||
{
|
{
|
||||||
CGeorgesTreeViewDialog *dock = new CGeorgesTreeViewDialog(m_mainDock);
|
CGeorgesTreeViewDialog *dock = new CGeorgesTreeViewDialog(m_mainDock);
|
||||||
|
dock->setUndoStack(m_undoStack);
|
||||||
m_lastActiveDock = dock;
|
m_lastActiveDock = dock;
|
||||||
m_dockedWidgets.append(dock);
|
m_dockedWidgets.append(dock);
|
||||||
|
|
||||||
|
@ -212,6 +198,7 @@ namespace Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CGeorgesTreeViewDialog *dock = new CGeorgesTreeViewDialog(m_mainDock);
|
CGeorgesTreeViewDialog *dock = new CGeorgesTreeViewDialog(m_mainDock);
|
||||||
|
dock->setUndoStack(m_undoStack);
|
||||||
m_dockedWidgets.append(dock);
|
m_dockedWidgets.append(dock);
|
||||||
|
|
||||||
connect(m_dockedWidgets.last(), SIGNAL(closing()),
|
connect(m_dockedWidgets.last(), SIGNAL(closing()),
|
||||||
|
@ -284,4 +271,4 @@ namespace Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* namespace Plugin */
|
} /* namespace GeorgesQt */
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QUndoStack>
|
#include <QtGui/QUndoStack>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class CGeorgesDirTreeDialog;
|
class CGeorgesDirTreeDialog;
|
||||||
|
@ -70,6 +70,6 @@ private:
|
||||||
CGeorgesTreeViewDialog *m_lastActiveDock;
|
CGeorgesTreeViewDialog *m_lastActiveDock;
|
||||||
}; /* class GeorgesEditorForm */
|
}; /* class GeorgesEditorForm */
|
||||||
|
|
||||||
} /* namespace Plugin */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
#endif // GEORGES_EDITOR_FORM_H
|
#endif // GEORGES_EDITOR_FORM_H
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
GeorgesEditorPlugin::~GeorgesEditorPlugin()
|
GeorgesEditorPlugin::~GeorgesEditorPlugin()
|
||||||
|
@ -97,4 +97,4 @@ QWidget *GeorgesEditorContext::widget()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(Plugin::GeorgesEditorPlugin)
|
Q_EXPORT_PLUGIN(GeorgesQt::GeorgesEditorPlugin)
|
|
@ -38,7 +38,7 @@ namespace ExtensionSystem
|
||||||
class IPluginSpec;
|
class IPluginSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
class GeorgesEditorForm;
|
class GeorgesEditorForm;
|
||||||
class GeorgesEditorPlugin : public QObject, public ExtensionSystem::IPlugin
|
class GeorgesEditorPlugin : public QObject, public ExtensionSystem::IPlugin
|
||||||
|
@ -93,6 +93,6 @@ public:
|
||||||
GeorgesEditorForm *m_georgesEditorForm;
|
GeorgesEditorForm *m_georgesEditorForm;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plugin
|
} // namespace GeorgesQt
|
||||||
|
|
||||||
#endif // LANDSCAPE_EDITOR_PLUGIN_H
|
#endif // LANDSCAPE_EDITOR_PLUGIN_H
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
CGeorgesFileSystemModel::CGeorgesFileSystemModel(QString ldPath, QObject *parent)
|
CGeorgesFileSystemModel::CGeorgesFileSystemModel(QString ldPath, QObject *parent)
|
||||||
|
@ -159,6 +159,6 @@ void CGeorgesFileSystemModel::checkLDPath()
|
||||||
// }
|
// }
|
||||||
// return QSortFilterProxyModel::data(index, role);
|
// return QSortFilterProxyModel::data(index, role);
|
||||||
//}
|
//}
|
||||||
} /* namespace NLQT */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
/* end of file */
|
/* end of file */
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <QtGui/QFileSystemModel>
|
#include <QtGui/QFileSystemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class CGeorgesFileSystemModel : public QFileSystemModel
|
class CGeorgesFileSystemModel : public QFileSystemModel
|
||||||
|
@ -74,6 +74,6 @@ private Q_SLOTS:
|
||||||
// bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
// bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
||||||
//};
|
//};
|
||||||
|
|
||||||
} /* namespace NLQT */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
#endif // GEORGES_FILESYSTEM_MODEL_H
|
#endif // GEORGES_FILESYSTEM_MODEL_H
|
|
@ -21,12 +21,20 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/path.h>
|
#include <nel/misc/path.h>
|
||||||
#include <nel/misc/file.h>
|
#include <nel/misc/file.h>
|
||||||
#include <nel/misc/o_xml.h>
|
#include <nel/misc/o_xml.h>
|
||||||
|
#include <nel/georges/u_form_loader.h>
|
||||||
#include <nel/georges/form.h>
|
#include <nel/georges/form.h>
|
||||||
|
#include <nel/georges/u_form.h>
|
||||||
|
#include <nel/georges/u_type.h>
|
||||||
|
|
||||||
|
// OVQT Includes
|
||||||
|
#include "../core/icore.h"
|
||||||
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "georges.h"
|
#include "georges.h"
|
||||||
|
@ -39,7 +47,7 @@
|
||||||
using namespace NLMISC;
|
using namespace NLMISC;
|
||||||
using namespace NLGEORGES;
|
using namespace NLGEORGES;
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
CGeorgesTreeViewDialog::CGeorgesTreeViewDialog(QWidget *parent /*= 0*/)
|
CGeorgesTreeViewDialog::CGeorgesTreeViewDialog(QWidget *parent /*= 0*/)
|
||||||
|
@ -50,6 +58,11 @@ namespace Plugin
|
||||||
m_georges = new CGeorges;
|
m_georges = new CGeorges;
|
||||||
|
|
||||||
loadedForm = "";
|
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_ui.setupUi(this);
|
||||||
m_header = new ExpandableHeaderView(Qt::Horizontal, m_ui.treeView);
|
m_header = new ExpandableHeaderView(Qt::Horizontal, m_ui.treeView);
|
||||||
|
@ -65,6 +78,10 @@ namespace Plugin
|
||||||
FormDelegate *formdelegate = new FormDelegate(this);
|
FormDelegate *formdelegate = new FormDelegate(this);
|
||||||
m_ui.treeView->setItemDelegateForColumn(1, formdelegate);
|
m_ui.treeView->setItemDelegateForColumn(1, formdelegate);
|
||||||
|
|
||||||
|
// Set up custom context menu.
|
||||||
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&)));
|
||||||
|
|
||||||
connect(m_ui.treeView, SIGNAL(doubleClicked (QModelIndex)),
|
connect(m_ui.treeView, SIGNAL(doubleClicked (QModelIndex)),
|
||||||
this, SLOT(doubleClicked (QModelIndex)));
|
this, SLOT(doubleClicked (QModelIndex)));
|
||||||
connect(m_ui.checkBoxParent, SIGNAL(toggled(bool)),
|
connect(m_ui.checkBoxParent, SIGNAL(toggled(bool)),
|
||||||
|
@ -203,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<NLGEORGES::CForm*>(uParentForm);
|
||||||
|
NLGEORGES::CForm *mainForm = static_cast<NLGEORGES::CForm*>(m_form);
|
||||||
|
|
||||||
|
CGeorgesFormProxyModel * proxyModel = dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model());
|
||||||
|
CGeorgesFormModel *model = dynamic_cast<CGeorgesFormModel *>(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( )
|
void CGeorgesTreeViewDialog::modifiedFile( )
|
||||||
|
@ -385,4 +427,121 @@ namespace Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace NLQT */
|
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.
|
||||||
|
QModelIndex &index = this->m_ui.treeView->currentIndex();
|
||||||
|
|
||||||
|
if(!index.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CGeorgesFormProxyModel * mp = dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model());
|
||||||
|
CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(mp->sourceModel());
|
||||||
|
QModelIndex sourceIndex = mp->mapToSource(index);
|
||||||
|
|
||||||
|
if (m)
|
||||||
|
{
|
||||||
|
|
||||||
|
CFormItem *item = m->getItem(sourceIndex);
|
||||||
|
|
||||||
|
// 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())
|
||||||
|
{
|
||||||
|
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...");
|
||||||
|
|
||||||
|
QAction *selectedItem = contextMenu.exec(globalPos);
|
||||||
|
if(selectedItem)
|
||||||
|
{
|
||||||
|
if(selectedItem->text() == "Add parent...")
|
||||||
|
{
|
||||||
|
// 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())
|
||||||
|
{
|
||||||
|
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<NLGEORGES::CForm *>(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 GeorgesQt */
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QDockWidget>
|
#include <QtGui/QDockWidget>
|
||||||
|
#include <QtGui/QUndoCommand>
|
||||||
|
#include <QtGui/QUndoStack>
|
||||||
|
|
||||||
|
|
||||||
// STL includes
|
// STL includes
|
||||||
|
|
||||||
|
@ -37,7 +40,7 @@ namespace NLGEORGES
|
||||||
|
|
||||||
using namespace NLGEORGES;
|
using namespace NLGEORGES;
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class CGeorges;
|
class CGeorges;
|
||||||
|
@ -54,12 +57,16 @@ namespace Plugin
|
||||||
void setModified(bool m) {m_modified = m;}
|
void setModified(bool m) {m_modified = m;}
|
||||||
|
|
||||||
CForm* getFormByName(const QString);
|
CForm* getFormByName(const QString);
|
||||||
void addParentForm(CForm *form);
|
void addParentForm(QString parentFormNm);
|
||||||
|
|
||||||
void write ( );
|
void write ( );
|
||||||
|
|
||||||
QTabWidget* tabWidget() { return m_ui.treeViewTabWidget; }
|
QTabWidget* tabWidget() { return m_ui.treeViewTabWidget; }
|
||||||
|
|
||||||
|
void setUndoStack(QUndoStack *stack) {
|
||||||
|
m_undoStack = stack;
|
||||||
|
}
|
||||||
|
|
||||||
QString loadedForm;
|
QString loadedForm;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -75,6 +82,7 @@ namespace Plugin
|
||||||
void loadFormIntoDialog(CForm *form = 0);
|
void loadFormIntoDialog(CForm *form = 0);
|
||||||
void modifiedFile( );
|
void modifiedFile( );
|
||||||
void checkVisibility(bool);
|
void checkVisibility(bool);
|
||||||
|
void showContextMenu(const QPoint &pos);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void doubleClicked ( const QModelIndex & index );
|
void doubleClicked ( const QModelIndex & index );
|
||||||
|
@ -87,10 +95,15 @@ namespace Plugin
|
||||||
UForm *m_form;
|
UForm *m_form;
|
||||||
CGeorges *m_georges;
|
CGeorges *m_georges;
|
||||||
|
|
||||||
|
QUndoStack *m_undoStack;
|
||||||
|
|
||||||
|
/// Contains a record of the last directory a sheet file dialog was opened for.
|
||||||
|
QString m_lastSheetDir;
|
||||||
|
|
||||||
bool m_modified;
|
bool m_modified;
|
||||||
|
|
||||||
}; /* CGeorgesTreeViewDialog */
|
}; /* CGeorgesTreeViewDialog */
|
||||||
|
|
||||||
} /* namespace NLQT */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
#endif // GEORGES_TREEVIEWER_DIALOG_H
|
#endif // GEORGES_TREEVIEWER_DIALOG_H
|
||||||
|
|
|
@ -63,6 +63,9 @@
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
|
|
@ -40,16 +40,16 @@
|
||||||
|
|
||||||
using namespace NLGEORGES;
|
using namespace NLGEORGES;
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
CGeorgesFormModel::CGeorgesFormModel(UFormElm *rootElm, QMap< QString, QStringList> deps,
|
CGeorgesFormModel::CGeorgesFormModel(UFormElm *rootElm, QMap< QString, QStringList> deps,
|
||||||
QString comment, QStringList parents, bool *expanded, QObject *parent) : QAbstractItemModel(parent)
|
QString comment, QStringList parents, bool *expanded, QObject *parent) : QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
QList<QVariant> rootData;
|
|
||||||
rootData << "Value" << "Data" << "Extra";// << "Type";
|
m_rootData << "Value" << "Data" << "Extra";// << "Type";
|
||||||
m_rootElm = rootElm;
|
m_rootElm = rootElm;
|
||||||
m_rootItem = new CFormItem(m_rootElm, rootData);
|
m_rootItem = new CFormItem(m_rootElm, m_rootData);
|
||||||
m_dependencies = deps;
|
m_dependencies = deps;
|
||||||
m_comments = comment;
|
m_comments = comment;
|
||||||
m_parents = parents;
|
m_parents = parents;
|
||||||
|
@ -669,6 +669,27 @@ namespace Plugin
|
||||||
Q_EMIT layoutAboutToBeChanged();
|
Q_EMIT layoutAboutToBeChanged();
|
||||||
Q_EMIT layoutChanged();
|
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 */
|
/* end of file */
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace NLGEORGES {
|
||||||
class UFormElm;
|
class UFormElm;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class CFormItem;
|
class CFormItem;
|
||||||
|
@ -56,6 +56,9 @@ namespace Plugin
|
||||||
bool showDefaults() { return m_showDefaults;}
|
bool showDefaults() { return m_showDefaults;}
|
||||||
void setShowParents( bool show );
|
void setShowParents( bool show );
|
||||||
void setShowDefaults( bool show );
|
void setShowDefaults( bool show );
|
||||||
|
void addParentForm(QString parentForm);
|
||||||
|
void removeParentForm(QString parentForm);
|
||||||
|
NLGEORGES::UFormElm *getRootForm() { return m_rootElm; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupModelData();
|
void setupModelData();
|
||||||
|
@ -64,6 +67,7 @@ namespace Plugin
|
||||||
|
|
||||||
CFormItem* m_rootItem;
|
CFormItem* m_rootItem;
|
||||||
NLGEORGES::UFormElm* m_rootElm;
|
NLGEORGES::UFormElm* m_rootElm;
|
||||||
|
QList<QVariant> m_rootData;
|
||||||
QMap< QString, QStringList> m_dependencies;
|
QMap< QString, QStringList> m_dependencies;
|
||||||
QString m_comments;
|
QString m_comments;
|
||||||
QStringList m_parents;
|
QStringList m_parents;
|
||||||
|
@ -75,6 +79,6 @@ namespace Plugin
|
||||||
|
|
||||||
};/* class CGeorgesFormModel */
|
};/* class CGeorgesFormModel */
|
||||||
|
|
||||||
} /* namespace Plugin */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
#endif // GEORGESFORM_MODEL_H
|
#endif // GEORGESFORM_MODEL_H
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "georgesform_proxy_model.h"
|
#include "georgesform_proxy_model.h"
|
||||||
#include "georgesform_model.h"
|
#include "georgesform_model.h"
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
bool CGeorgesFormProxyModel::filterAcceptsRow(int sourceRow,
|
bool CGeorgesFormProxyModel::filterAcceptsRow(int sourceRow,
|
||||||
|
@ -76,6 +76,6 @@ namespace Plugin
|
||||||
{
|
{
|
||||||
return QSortFilterProxyModel::filterAcceptsColumn(sourceRow, sourceParent);
|
return QSortFilterProxyModel::filterAcceptsColumn(sourceRow, sourceParent);
|
||||||
}
|
}
|
||||||
} /* namespace Plugin */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
/* end of file */
|
/* end of file */
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
namespace Plugin
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class CGeorgesFormProxyModel : public QSortFilterProxyModel
|
class CGeorgesFormProxyModel : public QSortFilterProxyModel
|
||||||
|
@ -40,6 +40,6 @@ namespace Plugin
|
||||||
|
|
||||||
};/* class CGeorgesFormProxyModel */
|
};/* class CGeorgesFormProxyModel */
|
||||||
|
|
||||||
} /* namespace NLQT */
|
} /* namespace GeorgesQt */
|
||||||
|
|
||||||
#endif // GEORGESFORM_PROXY_MODEL_H
|
#endif // GEORGESFORM_PROXY_MODEL_H
|
||||||
|
|
Loading…
Reference in a new issue