Merged Georges Editor branch.

--HG--
branch : gsoc2014-dfighter
hg/feature/cdb-packed
dfighter1985 11 years ago
commit f882abca07

@ -1,12 +1,14 @@
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}
${QT_INCLUDES}) ${QT_INCLUDES}
${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/qtpropertybrowser)
FILE(GLOB SRC *.cpp *.h) FILE(GLOB SRC *.cpp *.h)
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h) ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
SET(OVQT_PLUG_GEORGES_EDITOR_HDR georges_editor_plugin.h SET(OVQT_PLUG_GEORGES_EDITOR_HDR georges_editor_plugin.h
georges_editor_form.h georges_editor_form.h
@ -36,7 +38,7 @@ SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
ADD_LIBRARY(ovqt_plugin_georges_editor MODULE ${SRC} ${OVQT_PLUG_GEORGES_EDITOR_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_GEORGES_EDITOR_UI_HDRS} ${OVQT_PLUGIN_GEORGES_EDITOR_RC_SRCS}) ADD_LIBRARY(ovqt_plugin_georges_editor MODULE ${SRC} ${OVQT_PLUG_GEORGES_EDITOR_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_GEORGES_EDITOR_UI_HDRS} ${OVQT_PLUGIN_GEORGES_EDITOR_RC_SRCS})
TARGET_LINK_LIBRARIES(ovqt_plugin_georges_editor ovqt_plugin_core nelmisc nelgeorges ${QT_LIBRARIES}) TARGET_LINK_LIBRARIES(ovqt_plugin_georges_editor ovqt_plugin_core nelmisc nelgeorges qt_property_browser ${QT_LIBRARIES})
NL_DEFAULT_PROPS(ovqt_plugin_georges_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Georges Editor") NL_DEFAULT_PROPS(ovqt_plugin_georges_editor "NeL, Tools, 3D: Object Viewer Qt Plugin: Georges Editor")
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_georges_editor) NL_ADD_RUNTIME_FLAGS(ovqt_plugin_georges_editor)

@ -0,0 +1,103 @@
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Project includes
#include "actions.h"
#include "formitem.h"
#include "georgesform_model.h"
// Qt includes
// NeL includes
#include <nel/misc/debug.h>
#include <nel/misc/file.h>
#include <nel/misc/o_xml.h>
#include <nel/georges/u_form_loader.h>
#include <nel/georges/form.h>
#include <nel/georges/u_form.h>
#include <nel/georges/u_type.h>
namespace GeorgesQt
{
CUndoFormArrayRenameCommand::CUndoFormArrayRenameCommand(CGeorgesFormModel *model, CFormItem *item, const QVariant &value, QUndoCommand *parent)
: QUndoCommand("Rename Form Array Member", parent), m_model(model), m_item(item)
{
m_newValue = value.toString();
}
void CUndoFormArrayRenameCommand::redo()
{
update(true);
}
void CUndoFormArrayRenameCommand::undo()
{
update(false);
}
void CUndoFormArrayRenameCommand::update(bool redo)
{
// Get the parent node
const NLGEORGES::CFormDfn *parentDfn;
uint indexDfn;
const NLGEORGES::CFormDfn *nodeDfn;
const NLGEORGES::CType *nodeType;
NLGEORGES::CFormElm *node;
NLGEORGES::UFormDfn::TEntryType type;
bool isArray;
bool vdfnArray;
NLGEORGES::CForm *form=static_cast<NLGEORGES::CForm*>(m_item->form());
NLGEORGES::CFormElm *elm = static_cast<NLGEORGES::CFormElm*>(&form->Elements);
nlverify ( elm->getNodeByName (m_item->formName().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, isArray, vdfnArray, true, NLGEORGES_FIRST_ROUND) );
if (node)
{
std::string tmpName;
node->getFormName(tmpName);
NLGEORGES::CFormElmArray* array = static_cast<NLGEORGES::CFormElmArray*> (node->getParent ());
// In the redo stage save the old value, just in case.
if(redo)
{
// If the name of the element is empty then give it a nice default.
if(array->Elements[m_item->structId()].Name.empty())
{
m_oldValue.append("#");
m_oldValue.append(QString("%1").arg(m_item->structId()));
}
else
{
m_oldValue = QString::fromStdString(array->Elements[m_item->structId()].Name);
}
}
QString value;
if(redo)
value = m_newValue;
else
value = m_oldValue;
array->Elements[m_item->structId()].Name = value.toStdString();
m_item->setName(value.toStdString());
m_model->emitDataChanged(m_model->index(m_item->row(), 0, m_item));
}
}
}

@ -0,0 +1,48 @@
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef ACTIONS_H
#define ACTIONS_H
#include <QtGui/QUndoCommand>
#include <QModelIndex>
namespace GeorgesQt
{
class CFormItem;
class CGeorgesFormModel;
class CUndoFormArrayRenameCommand : public QUndoCommand
{
public:
CUndoFormArrayRenameCommand(CGeorgesFormModel *model, CFormItem *item, const QVariant &value, QUndoCommand *parent = 0);
~CUndoFormArrayRenameCommand() {}
void redo();
void undo();
void update(bool redo);
protected:
CFormItem *m_item;
CGeorgesFormModel *m_model;
QString m_newValue;
QString m_oldValue;
};
}
#endif // ACTIONS_H

@ -38,6 +38,8 @@
#include "georgesform_proxy_model.h" #include "georgesform_proxy_model.h"
#include "formitem.h" #include "formitem.h"
#if 0
namespace GeorgesQt namespace GeorgesQt
{ {
@ -277,3 +279,5 @@ namespace GeorgesQt
editor->setGeometry(r); editor->setGeometry(r);
} }
} /* namespace GeorgesQt */ } /* namespace GeorgesQt */
#endif // 0

@ -19,6 +19,8 @@
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#if 0
namespace GeorgesQt namespace GeorgesQt
{ {
@ -38,4 +40,6 @@ namespace GeorgesQt
}; };
} }
#endif // 0
#endif // FORMDELEGATE_H #endif // FORMDELEGATE_H

@ -14,27 +14,26 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h" // Project includes
#include "formitem.h" #include "formitem.h"
#include "actions.h"
#include "georges_editor_form.h"
// Qt includes // Qt includes
#include <QIcon>
// NeL includes // NeL includes
#include <nel/misc/o_xml.h> #include <nel/misc/o_xml.h>
#include <nel/misc/debug.h>
#include <nel/georges/u_type.h> #include <nel/georges/u_type.h>
#include <nel/georges/form.h> #include <nel/georges/form.h>
using namespace NLGEORGES;
namespace GeorgesQt namespace GeorgesQt
{ {
CFormItem::CFormItem()
CFormItem::CFormItem(NLGEORGES::UFormElm* elm, const QList<QVariant> &data, CFormItem *parent,
NLGEORGES::UFormElm::TWhereIsValue wV, NLGEORGES::UFormElm::TWhereIsNode wN)
{ {
parentItem = parent;
itemData = data;
formElm = elm;
whereV = wV;
whereN = wN;
} }
CFormItem::~CFormItem() CFormItem::~CFormItem()
@ -60,12 +59,14 @@ namespace GeorgesQt
int CFormItem::columnCount() const int CFormItem::columnCount() const
{ {
//nlinfo("columnCount %d",itemData.count()); //nlinfo("columnCount %d",itemData.count());
return itemData.count(); //return itemData.count();
return 1;
} }
QVariant CFormItem::data(int column) const QVariant CFormItem::data(int column) const
{ {
return itemData.value(column); //return itemData.value(column);
return QVariant(_Name.c_str());
} }
CFormItem *CFormItem::parent() CFormItem *CFormItem::parent()
@ -83,81 +84,149 @@ namespace GeorgesQt
bool CFormItem::setData(int column, const QVariant &value) bool CFormItem::setData(int column, const QVariant &value)
{ {
if (column < 0 || column >= itemData.size()) nlwarning("This should not be called anymore.");
return false;
}
bool CFormItem::isEditable(int column)
{
// Ensure only valid types can be edited.
if(_Type == Null)
return false; return false;
// TODO: default values // Make sure only the first column (name) can be editted.
if (!formElm) if (column != 0)
return false; return false;
itemData[column] = value; if(isArrayMember())
if (formElm->isAtom()) return true;
return false;
}
bool CFormItem::isArray()
{
// If it wasn't a root node then lets check the node type.
const NLGEORGES::CFormDfn *parentDfn;
uint indexDfn;
const NLGEORGES::CFormDfn *nodeDfn;
const NLGEORGES::CType *nodeType;
NLGEORGES::CFormElm *node;
NLGEORGES::UFormDfn::TEntryType type;
bool array;
bool parentVDfnArray;
NLGEORGES::CForm *form = static_cast<CForm*>(m_form);
NLGEORGES::CFormElm *elm = static_cast<CFormElm*>(&form->getRootNode());
nlverify ( elm->getNodeByName (_FormName.c_str(), &parentDfn, indexDfn,
&nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );
if(array && node)
return true;
return false;
}
bool CFormItem::isArrayMember()
{
CFormItem *parent = this->parent();
// If it wasn't a root node then lets check the node type.
const NLGEORGES::CFormDfn *parentDfn;
uint indexDfn;
const NLGEORGES::CFormDfn *nodeDfn;
const NLGEORGES::CType *nodeType;
NLGEORGES::CFormElm *parentNode;
NLGEORGES::UFormDfn::TEntryType type;
bool array;
bool parentVDfnArray;
NLGEORGES::CForm *form = static_cast<CForm*>(m_form);
NLGEORGES::CFormElm *elm = static_cast<CFormElm*>(&form->getRootNode());
nlverify ( elm->getNodeByName (parent->formName ().c_str (), &parentDfn, indexDfn,
&nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );
if(array && parentNode)
return true;
return false;
}
QIcon CFormItem::getItemImage(CFormItem *rootItem)
{
if(_Type == CFormItem::Null)
{ {
const NLGEORGES::UType *type = formElm->getType(); return QIcon(":/images/root.ico");
if (type) }
else if(_Type == CFormItem::Form)
{
// If the parent is the root item then this is the content.
if(parentItem == rootItem)
return QIcon(":/images/root.ico");
// If it wasn't a root node then lets check the node type.
const NLGEORGES::CFormDfn *parentDfn;
uint indexDfn;
const NLGEORGES::CFormDfn *nodeDfn;
const NLGEORGES::CType *nodeType;
NLGEORGES::CFormElm *node;
NLGEORGES::UFormDfn::TEntryType type;
bool array;
bool parentVDfnArray;
NLGEORGES::CForm *form = static_cast<CForm*>(m_form);
NLGEORGES::CFormElm *elm = static_cast<CFormElm*>(&form->getRootNode());
nlverify ( elm->getNodeByName (_FormName.c_str(), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) );
if(array)
{
return QIcon(":/images/array.ico");
}
else
{ {
switch (type->getType()) if(type == NLGEORGES::UFormDfn::EntryType)
{
if(parentDfn)
{
// Not sure what the hell to do with this. Gets filename from parent dfn?
}
return QIcon(":/images/zfee51.ico");
}
else if(type == NLGEORGES::UFormDfn::EntryDfn)
{ {
case NLGEORGES::UType::UnsignedInt: if(parentDfn)
case NLGEORGES::UType::SignedInt:
case NLGEORGES::UType::Double:
case NLGEORGES::UType::String:
if (parentItem->formElm->isArray())
{ {
//((NLGEORGES::CFormElm*)parentItem->formElm);//->arrayInsertNodeByName( // Not sure what the hell to do with this. Gets filename from parent dfn?
//if(parentItem->formElm->getArrayNode(elmName, num))
//{
//}
bool ok;
// TODO: the node can be renamed from eg "#0" to "foobar"
int arrayIndex = itemData[0].toString().remove("#").toInt(&ok);
if(ok)
{
NLGEORGES::UFormElm *elmt = 0;
if(parentItem->formElm->getArrayNode(&elmt, arrayIndex) && elmt)
{
if (elmt->isAtom())
{
((NLGEORGES::CFormElmAtom*)elmt)->setValue(value.toString().toUtf8().constData());
nldebug(QString("array element string %1 %2")
.arg(itemData[0].toString()).arg(value.toString())
.toUtf8().constData());
}
}
}
} }
else return QIcon(":/images/struct.ico");
}
else if(type == NLGEORGES::UFormDfn::EntryVirtualDfn)
{
if(node)
{ {
if(parentItem->formElm->setValueByName( // Not sure what the hell to do with this. Gets filename from parent dfn?
value.toString().toUtf8().constData(), std::string dfnName;
itemData[0].toString().toUtf8().constData())) NLMISC::safe_cast<NLGEORGES::CFormElmVirtualStruct*>(node)->getDfnName(dfnName);
{ // return dfnName.c_str() ?
nldebug(QString("string %1 %2")
.arg(itemData[0].toString()).arg(value.toString())
.toUtf8().constData());
}
else
{
nldebug(QString("FAILED string %1 %2")
.arg(itemData[0].toString()).arg(value.toString())
.toUtf8().constData());
}
} }
break; return QIcon(":/images/vstruct.ico");
case NLGEORGES::UType::Color:
nldebug("Color is TODO");
break;
default:
break;
} }
} }
//return QIcon(":/images/struct.ico");
} }
else return QIcon();
{
nldebug("setting sth other than Atom");
}
//formElm->setValueByName();
return true;
} }
CFormItem *CFormItem::add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr)
{
CFormItem *newNode = new CFormItem();
newNode->_Type = type;
newNode->_Name = name;
newNode->parentItem = this;
newNode->_StructId = structId;
newNode->_FormName = formName;
newNode->_Slot = slot;
newNode->m_form = formPtr;
appendChild(newNode);
return newNode;
}
} }

@ -18,6 +18,7 @@
#define FORMITEM_H #define FORMITEM_H
// NeL includes // NeL includes
#include <nel/georges/u_form.h>
#include <nel/georges/u_form_elm.h> #include <nel/georges/u_form_elm.h>
// Qt includes // Qt includes
@ -28,17 +29,25 @@ namespace GeorgesQt
{ {
class CFormItem class CFormItem
{ {
public: public:
CFormItem(NLGEORGES::UFormElm *elm, const QList<QVariant> &data, // What is the sub object ?
CFormItem *parent = 0, enum TSub
NLGEORGES::UFormElm::TWhereIsValue = NLGEORGES::UFormElm::ValueForm, {
NLGEORGES::UFormElm::TWhereIsNode = NLGEORGES::UFormElm::NodeForm); Null, // Nothing in this node (root ?)
Header, // Header node
Type, // This node is a type
Dfn, // This node is a dfn
Form, // This node is a form
};
CFormItem();
~CFormItem(); ~CFormItem();
void appendChild(CFormItem *child); void appendChild(CFormItem *child);
CFormItem *add (TSub type, const char *name, uint structId, const char *formName, uint slot, NLGEORGES::UForm *formPtr);
CFormItem *child(int row); CFormItem *child(int row);
int childCount() const; int childCount() const;
int columnCount() const; int columnCount() const;
@ -46,23 +55,36 @@ namespace GeorgesQt
int row() const; int row() const;
CFormItem *parent(); CFormItem *parent();
bool setData(int column, const QVariant &value); bool setData(int column, const QVariant &value);
NLGEORGES::UFormElm* getFormElm() {return formElm;}
NLGEORGES::UFormElm::TWhereIsValue valueFrom() TSub nodeType() { return _Type; }
{ std::string formName() { return _FormName; }
return whereV;
} std::string name() { return _Name; }
NLGEORGES::UFormElm::TWhereIsNode nodeFrom() void setName(std::string name) { _Name = name; }
{
return whereN; uint structId() { return _StructId; }
}
NLGEORGES::UForm *form() { return m_form; }
private:
bool isEditable(int column);
bool isArray();
bool isArrayMember();
QIcon getItemImage(CFormItem *rootItem);
private:
QList<CFormItem*> childItems; QList<CFormItem*> childItems;
QList<QVariant> itemData; QList<QVariant> itemData;
CFormItem *parentItem; CFormItem *parentItem;
NLGEORGES::UFormElm* formElm; NLGEORGES::UFormElm* formElm;
NLGEORGES::UFormElm::TWhereIsValue whereV; NLGEORGES::UForm *m_form;
NLGEORGES::UFormElm::TWhereIsNode whereN;
uint _StructId;
std::string _Name;
std::string _FormName;
TSub _Type;
uint _Slot;
}; // CFormItem }; // CFormItem
} }

@ -1,5 +1,12 @@
<RCC> <RCC>
<qresource> <qresource>
<file>images/array.ico</file>
<file>images/header.ico</file>
<file>images/hold.ico</file>
<file>images/root.ico</file>
<file>images/struct.ico</file>
<file>images/vstruct.ico</file>
<file>images/zfee51.ico</file>
<file>images/ic_nel_georges_editor.png</file> <file>images/ic_nel_georges_editor.png</file>
</qresource> </qresource>
</RCC> </RCC>

@ -36,6 +36,7 @@
namespace GeorgesQt namespace GeorgesQt
{ {
QUndoStack *GeorgesEditorForm::UndoStack = NULL;
GeorgesEditorForm::GeorgesEditorForm(QWidget *parent) GeorgesEditorForm::GeorgesEditorForm(QWidget *parent)
: QMainWindow(parent), : QMainWindow(parent),
@ -62,7 +63,7 @@ namespace GeorgesQt
m_mainDock->setDockNestingEnabled(true); m_mainDock->setDockNestingEnabled(true);
layout->addWidget(m_mainDock); layout->addWidget(m_mainDock);
m_undoStack = new QUndoStack(this); UndoStack = new QUndoStack(this);
Core::MenuManager *menuManager = Core::ICore::instance()->menuManager(); Core::MenuManager *menuManager = Core::ICore::instance()->menuManager();
m_openAction = menuManager->action(Core::Constants::OPEN); m_openAction = menuManager->action(Core::Constants::OPEN);
@ -115,7 +116,7 @@ namespace GeorgesQt
QUndoStack *GeorgesEditorForm::undoStack() const QUndoStack *GeorgesEditorForm::undoStack() const
{ {
return m_undoStack; return UndoStack;
} }
void GeorgesEditorForm::open() void GeorgesEditorForm::open()
@ -212,7 +213,7 @@ namespace GeorgesQt
} }
CGeorgesTreeViewDialog *dock = new CGeorgesTreeViewDialog(m_mainDock); CGeorgesTreeViewDialog *dock = new CGeorgesTreeViewDialog(m_mainDock);
dock->setUndoStack(m_undoStack); dock->setUndoStack(UndoStack);
m_lastActiveDock = dock; m_lastActiveDock = dock;
m_dockedWidgets.append(dock); m_dockedWidgets.append(dock);

@ -38,6 +38,8 @@ public:
QUndoStack *undoStack() const; QUndoStack *undoStack() const;
static QUndoStack *UndoStack;
public Q_SLOTS: public Q_SLOTS:
void open(); void open();
void loadFile(const QString fileName); void loadFile(const QString fileName);
@ -54,7 +56,6 @@ private:
void readSettings(); void readSettings();
void writeSettings(); void writeSettings();
QUndoStack *m_undoStack;
Ui::GeorgesEditorForm m_ui; Ui::GeorgesEditorForm m_ui;
CGeorgesDirTreeDialog *m_georgesDirTreeDialog; CGeorgesDirTreeDialog *m_georgesDirTreeDialog;

@ -14,14 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "georges_treeview_dialog.h" #include "georges_treeview_dialog.h"
#include "georges.h"
#include "georgesform_model.h"
#include "georgesform_proxy_model.h"
#include "formitem.h"
#include "formdelegate.h"
#include "expandable_headerview.h"
// Qt includes // Qt includes
#include <QtGui/QWidget> #include <QtGui/QWidget>
@ -43,6 +36,14 @@
#include "../core/icore.h" #include "../core/icore.h"
#include "../core/core_constants.h" #include "../core/core_constants.h"
// Project includes
#include "georges.h"
#include "georgesform_model.h"
#include "georgesform_proxy_model.h"
#include "formitem.h"
#include "formdelegate.h"
#include "expandable_headerview.h"
using namespace NLMISC; using namespace NLMISC;
using namespace NLGEORGES; using namespace NLGEORGES;
@ -60,7 +61,7 @@ namespace GeorgesQt
// Set the default sheet dir dir to the level design path. // Set the default sheet dir dir to the level design path.
m_lastSheetDir = "."; m_lastSheetDir = ".";
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Core::Constants::DATA_PATH_SECTION); settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
m_lastSheetDir = settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString(); m_lastSheetDir = settings->value(Core::Constants::LEVELDESIGN_PATH, "l:/leveldesign").toString();
settings->endGroup(); settings->endGroup();
@ -71,23 +72,14 @@ namespace GeorgesQt
m_ui.treeView->header()->setStretchLastSection(true); m_ui.treeView->header()->setStretchLastSection(true);
m_ui.treeViewTabWidget->setTabEnabled (2,false); m_ui.treeViewTabWidget->setTabEnabled (2,false);
m_ui.checkBoxParent->setStyleSheet("background-color: rgba(0,255,0,30)");
m_ui.checkBoxDefaults->setStyleSheet("background-color: rgba(255,0,0,30)");
m_form = 0; m_form = 0;
FormDelegate *formdelegate = new FormDelegate(this); m_ui.treeView->setContextMenuPolicy(Qt::CustomContextMenu);
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(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)),
this, SLOT(filterRows()));
connect(m_ui.checkBoxDefaults, SIGNAL(toggled(bool)),
this, SLOT(filterRows()));
connect(m_header, SIGNAL(headerClicked(int)), connect(m_header, SIGNAL(headerClicked(int)),
this, SLOT(headerClicked(int))); this, SLOT(headerClicked(int)));
} }
@ -101,12 +93,12 @@ namespace GeorgesQt
void CGeorgesTreeViewDialog::headerClicked(int section) void CGeorgesTreeViewDialog::headerClicked(int section)
{ {
if (section == 0) if (section == 0)
{ {
if (*(m_header->expanded())) if (*(m_header->expanded()))
m_ui.treeView->expandAll(); m_ui.treeView->expandAll();
else else
m_ui.treeView->collapseAll(); m_ui.treeView->collapseAll();
} }
} }
void CGeorgesTreeViewDialog::setForm(const CForm *form) void CGeorgesTreeViewDialog::setForm(const CForm *form)
@ -116,30 +108,30 @@ namespace GeorgesQt
NLGEORGES::CForm* CGeorgesTreeViewDialog::getFormByName(const QString formName) NLGEORGES::CForm* CGeorgesTreeViewDialog::getFormByName(const QString formName)
{ {
if(NLMISC::CPath::exists(formName.toUtf8().constData())) if(NLMISC::CPath::exists(formName.toStdString()))
{ {
//NLGEORGES::CForm *form = dynamic_cast<NLGEORGES::CForm*>(m_georges->loadForm(formName.toUtf8())); //NLGEORGES::CForm *form = dynamic_cast<NLGEORGES::CForm*>(m_georges->loadForm(formName.toStdString()));
return (NLGEORGES::CForm *)m_georges->loadForm(formName.toUtf8().constData()); return (NLGEORGES::CForm *)m_georges->loadForm(formName.toStdString());
} }
//else //else
//{ //{
// CForm *form = 0; // CForm *form = 0;
// // Load the DFN // // Load the DFN
// std::string extStr = NLMISC::CFile::getExtension( formName.toUtf8() ); // std::string extStr = NLMISC::CFile::getExtension( formName.toStdString() );
// QString dfnName = QString("%1.dfn").arg(extStr.c_str()); // QString dfnName = QString("%1.dfn").arg(extStr.c_str());
// UFormDfn *formdfn; // UFormDfn *formdfn;
// if (NLMISC::CPath::exists(dfnName.toUtf8())) // if (NLMISC::CPath::exists(dfnName.toStdString()))
// { // {
// formdfn = _georges->loadFormDfn (dfnName.toUtf8()); // formdfn = _georges->loadFormDfn (dfnName.toStdString());
// if (!formdfn) // if (!formdfn)
// { // {
// nlwarning("Failed to load dfn: %s", dfnName.toUtf8()); // nlwarning("Failed to load dfn: %s", dfnName.toStdString().c_str());
// return 0; // return 0;
// } // }
// } // }
// else // else
// { // {
// nlwarning("Cannot find dfn: %s", dfnName.toUtf8()); // nlwarning("Cannot find dfn: %s", dfnName.toStdString().c_str());
// return 0; // return 0;
// } // }
@ -155,56 +147,56 @@ namespace GeorgesQt
// } // }
// return form; // return form;
//} //}
nlinfo("File '%s' does not exist!", formName.toUtf8().constData()); nlinfo("File '%s' does not exist!", formName.toStdString().c_str());
return 0; return 0;
} }
NLGEORGES::CForm* CGeorgesTreeViewDialog::getFormByDfnName(const QString dfnName) NLGEORGES::CForm* CGeorgesTreeViewDialog::getFormByDfnName(const QString dfnName)
{ {
if(NLMISC::CPath::exists(dfnName.toUtf8().constData())) if(NLMISC::CPath::exists(dfnName.toStdString()))
{ {
// Create a new form object. // Create a new form object.
NLGEORGES::CForm *form = new NLGEORGES::CForm(); NLGEORGES::CForm *form = new NLGEORGES::CForm();
m_form = form; m_form = form;
// Retrieve a copy of the root definition. // Retrieve a copy of the root definition.
NLGEORGES::CFormDfn *formDfn = dynamic_cast<NLGEORGES::CFormDfn *>(m_georges->loadFormDfn(dfnName.toUtf8().constData())); NLGEORGES::CFormDfn *formDfn = dynamic_cast<NLGEORGES::CFormDfn *>(m_georges->loadFormDfn(dfnName.toStdString()));
// Next we'll use the root node to build a new form. // Next we'll use the root node to build a new form.
NLGEORGES::CFormElmStruct *fes = dynamic_cast<NLGEORGES::CFormElmStruct *>(getRootNode(0)); NLGEORGES::CFormElmStruct *fes = dynamic_cast<NLGEORGES::CFormElmStruct *>(getRootNode(0));
fes->build(formDfn); fes->build(formDfn);
// And then initialize the held elements; // And then initialize the held elements;
for(uint i = 0; i<NLGEORGES::CForm::HeldElementCount; i++) for(uint i = 0; i<NLGEORGES::CForm::HeldElementCount; i++)
{ {
fes = dynamic_cast<NLGEORGES::CFormElmStruct *>(getRootNode(i+1)); fes = dynamic_cast<NLGEORGES::CFormElmStruct *>(getRootNode(i+1));
fes->build(formDfn); fes->build(formDfn);
} }
return form; return form;
} }
nlinfo("File '%s' does not exist!", dfnName.toUtf8().constData()); nlinfo("File '%s' does not exist!", dfnName.toStdString().c_str());
return NULL; return NULL;
} }
NLGEORGES::CFormElm *CGeorgesTreeViewDialog::getRootNode(uint slot) NLGEORGES::CFormElm *CGeorgesTreeViewDialog::getRootNode(uint slot)
{ {
NLGEORGES::CForm *form = getFormPtr(); NLGEORGES::CForm *form = getFormPtr();
if(slot == 0) if(slot == 0)
{ {
const NLGEORGES::UFormElm &formElm = form->getRootNode(); const NLGEORGES::UFormElm &formElm = form->getRootNode();
return (NLGEORGES::CFormElm *)&formElm; return (NLGEORGES::CFormElm *)&formElm;
} }
// Make sure the slot value is valid and then return the corresponding element. // Make sure the slot value is valid and then return the corresponding element.
nlassert(slot < NLGEORGES::CForm::HeldElementCount+1); nlassert(slot < NLGEORGES::CForm::HeldElementCount+1);
return getFormPtr()->HeldElements[slot-1]; return getFormPtr()->HeldElements[slot-1];
} }
NLGEORGES::CForm *CGeorgesTreeViewDialog::getFormPtr() NLGEORGES::CForm *CGeorgesTreeViewDialog::getFormPtr()
{ {
return dynamic_cast<NLGEORGES::CForm *>(m_form); return dynamic_cast<NLGEORGES::CForm *>(m_form);
} }
void CGeorgesTreeViewDialog::loadFormIntoDialog(CForm *form) void CGeorgesTreeViewDialog::loadFormIntoDialog(CForm *form)
@ -218,14 +210,16 @@ namespace GeorgesQt
UFormElm *root = 0; UFormElm *root = 0;
root = &m_form->getRootNode(); root = &m_form->getRootNode();
// Extract the parent forms into the list of parents in the dialog.
QStringList parents; QStringList parents;
uint cnt = form->getParentCount(); uint cnt = form->getParentCount();
for (uint i = 0; i < cnt /*form->getParentCount()*/; i++) for (uint i = 0; i < cnt /*form->getParentCount()*/; i++)
{ {
UForm *u = m_form->getParentForm(i); UForm *u = m_form->getParentForm(i);
parents << u->getFilename().c_str(); parents << u->getFilename().c_str();
} }
// Exact the comment box for the dialog.
QString comments; QString comments;
comments = m_form->getComment().c_str(); comments = m_form->getComment().c_str();
@ -249,22 +243,15 @@ namespace GeorgesQt
nlinfo("typ's %d",deps["typ"].count()); nlinfo("typ's %d",deps["typ"].count());
nlinfo("dfn's %d",deps["dfn"].count()); nlinfo("dfn's %d",deps["dfn"].count());
//nlwarning(strList.join(";").toUtf8()); //nlwarning(strList.join(";").toStdString().c_str());
if (root) if (root)
{ {
loadedForm = m_form->getFilename().c_str(); loadedForm = m_form->getFilename().c_str();
CGeorgesFormModel *model = new CGeorgesFormModel(root,deps,comments,parents,m_header->expanded()); CGeorgesFormModel *model = new CGeorgesFormModel(m_form,deps,comments,parents,m_header->expanded());
CGeorgesFormProxyModel *proxyModel = new CGeorgesFormProxyModel(); m_ui.treeView->setModel(model);
proxyModel->setSourceModel(model);
m_ui.treeView->setModel(proxyModel);
m_ui.treeView->expandAll(); m_ui.treeView->expandAll();
// this is a debug output row
m_ui.treeView->hideColumn(3);
filterRows();
// //_ui.treeView->setRowHidden(0,QModelIndex(),true);
connect(model, SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), connect(model, SIGNAL(dataChanged(const QModelIndex, const QModelIndex)),
this, SLOT(modifiedFile())); this, SLOT(modifiedFile()));
@ -276,12 +263,11 @@ namespace GeorgesQt
void CGeorgesTreeViewDialog::addParentForm(QString parentFormNm) void CGeorgesTreeViewDialog::addParentForm(QString parentFormNm)
{ {
// Try to load the form // Try to load the form
NLGEORGES::UForm *uParentForm = m_georges->loadForm(parentFormNm.toUtf8().constData()); NLGEORGES::UForm *uParentForm = m_georges->loadForm(parentFormNm.toStdString());
NLGEORGES::CForm *parentForm = dynamic_cast<NLGEORGES::CForm*>(uParentForm); NLGEORGES::CForm *parentForm = dynamic_cast<NLGEORGES::CForm*>(uParentForm);
NLGEORGES::CForm *mainForm = static_cast<NLGEORGES::CForm*>(m_form); NLGEORGES::CForm *mainForm = static_cast<NLGEORGES::CForm*>(m_form);
CGeorgesFormProxyModel * proxyModel = dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model()); CGeorgesFormModel *model = dynamic_cast<CGeorgesFormModel *>(m_ui.treeView->model());
CGeorgesFormModel *model = dynamic_cast<CGeorgesFormModel *>(proxyModel->sourceModel());
if(parentForm) if(parentForm)
{ {
@ -291,11 +277,11 @@ namespace GeorgesQt
if (parentForm->Elements.FormDfn == mainForm->Elements.FormDfn) if (parentForm->Elements.FormDfn == mainForm->Elements.FormDfn)
{ {
// This is the parent form selector // This is the parent form selector
if(!mainForm->insertParent(mainForm->getParentCount(),parentFormNm.toUtf8(), parentForm)) if(!mainForm->insertParent(mainForm->getParentCount(),parentFormNm.toStdString().c_str(), parentForm))
nlwarning("Failed to add parent form: %s", parentFormNm.toUtf8().constData()); nlwarning("Failed to add parent form: %s", parentFormNm.toStdString().c_str());
else else
{ {
nlinfo("Successfullyadded parent form: %s", parentFormNm.toUtf8().constData()); nlinfo("Successfullyadded parent form: %s", parentFormNm.toStdString().c_str());
model->addParentForm(parentFormNm); model->addParentForm(parentFormNm);
} }
} }
@ -316,12 +302,12 @@ namespace GeorgesQt
void CGeorgesTreeViewDialog::write( ) void CGeorgesTreeViewDialog::write( )
{ {
NLMISC::COFile file; NLMISC::COFile file;
std::string s = NLMISC::CPath::lookup(loadedForm.toUtf8().constData(), false); std::string s = NLMISC::CPath::lookup(loadedForm.toStdString(), false);
if(file.open (s)) if(file.open (s))
{ {
try try
{ {
// if (loadedForm.contains(".typ")) // if (loadedForm.contains(".typ"))
// { // {
// //nlassert (Type != NULL); // //nlassert (Type != NULL);
@ -334,7 +320,7 @@ namespace GeorgesQt
// // flushValueChange (); // // flushValueChange ();
// //} // //}
// //Type->write (xmlStream.getDocument (), theApp.Georges4CVS); // //Type->write (xmlStream.getDocument (), theApp.Georges4CVS);
// //modify (NULL, NULL, false); // //modify (NULL, NULL, false);
// //flushValueChange (); // //flushValueChange ();
// //UpdateAllViews (NULL); // //UpdateAllViews (NULL);
// //return TRUE; // //return TRUE;
@ -356,9 +342,9 @@ namespace GeorgesQt
// } // }
// else // else
// { // {
nlassert (m_form != NULL); nlassert (m_form != NULL);
// Write the file // Write the file
// /*if (IsModified ()) // /*if (IsModified ())
// { // {
// ((CForm*)(UForm*)Form)->Header.MinorVersion++; // ((CForm*)(UForm*)Form)->Header.MinorVersion++;
@ -380,33 +366,29 @@ namespace GeorgesQt
// // Get the left view // // Get the left view
// //CView* pView = getLeftView (); // //CView* pView = getLeftView ();
// } // }
} }
catch (Exception &e) catch (Exception &e)
{ {
nlerror("Error while loading file: %s", e.what()); nlerror("Error while loading file: %s", e.what());
} }
} }
else else
{ {
nlerror("Can't open the file %s for writing.", s.c_str()); nlerror("Can't open the file %s for writing.", s.c_str());
} }
} }
void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index ) void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index )
{ {
// TODO: this is messy :( perhaps this can be done better //CGeorgesFormModel *model =
CGeorgesFormProxyModel * proxyModel = // dynamic_cast<CGeorgesFormModel *>((m_ui.treeView->model());
dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model());
CGeorgesFormModel *model =
dynamic_cast<CGeorgesFormModel *>(proxyModel->sourceModel());
QModelIndex sourceIndex = proxyModel->mapToSource(index);
CFormItem *item = model->getItem(sourceIndex); //CFormItem *item = model->getItem(index);
if (item->parent() && item->parent()->data(0) == "parents") //if (item->parent() && item->parent()->data(0) == "parents")
{ //{
Q_EMIT changeFile(CPath::lookup(item->data(0).toString().toUtf8().constData(),false).c_str()); // 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)
@ -415,7 +397,7 @@ namespace GeorgesQt
// CFormItem *item = m->getItem(in2); // CFormItem *item = m->getItem(in2);
// QString value = item->data(1).toString(); // QString value = item->data(1).toString();
// QString path = CPath::lookup(value.toUtf8(),false).c_str(); // QString path = CPath::lookup(value.toStdString(),false).c_str();
// if(value.contains(".tga") || value.contains(".png")) // if(value.contains(".tga") || value.contains(".png"))
// { // {
@ -443,7 +425,7 @@ namespace GeorgesQt
// { // {
// Modules::objViewInt()->resetScene(); // Modules::objViewInt()->resetScene();
// //Modules::config().configRemapExtensions(); // //Modules::config().configRemapExtensions();
// Modules::objViewInt()->loadMesh(path.toUtf8(),""); // Modules::objViewInt()->loadMesh(path.toStdString(),"");
// } // }
// return; // return;
// } // }
@ -472,12 +454,12 @@ namespace GeorgesQt
void CGeorgesTreeViewDialog::filterRows() void CGeorgesTreeViewDialog::filterRows()
{ {
CGeorgesFormProxyModel * mp = dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model()); //CGeorgesFormProxyModel * mp = dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model());
CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(mp->sourceModel()); //CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(mp->sourceModel());
if (m) { //if (m) {
m->setShowParents(m_ui.checkBoxParent->isChecked()); // m->setShowParents(m_ui.checkBoxParent->isChecked());
m->setShowDefaults(m_ui.checkBoxDefaults->isChecked()); // m->setShowDefaults(m_ui.checkBoxDefaults->isChecked());
} //}
} }
void CGeorgesTreeViewDialog::showContextMenu(const QPoint &pos) void CGeorgesTreeViewDialog::showContextMenu(const QPoint &pos)
@ -485,116 +467,135 @@ namespace GeorgesQt
QMenu contextMenu; QMenu contextMenu;
QMenu *structContext = NULL; QMenu *structContext = NULL;
QPoint globalPos = this->mapToGlobal(pos); QPoint globalPos = this->mapToGlobal(pos);
// Fisrt we're going to see if we've right clicked on a new item and select it. // Fisrt we're going to see if we've right clicked on a new item and select it.
const QModelIndex &index = this->m_ui.treeView->currentIndex(); const QModelIndex &index = this->m_ui.treeView->currentIndex();
if(!index.isValid()) if(!index.isValid())
return; return;
CGeorgesFormProxyModel * mp = dynamic_cast<CGeorgesFormProxyModel *>(m_ui.treeView->model()); CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(m_ui.treeView->model());
CGeorgesFormModel *m = dynamic_cast<CGeorgesFormModel *>(mp->sourceModel());
QModelIndex sourceIndex = mp->mapToSource(index);
if (m) if(m)
{ {
CFormItem *item = m->getItem(index);
CFormItem *item = m->getItem(sourceIndex);
// Right click on the "parents" item // Right click on the "parents" item
if (item->data(0) == "parents") // if (item->data(0) == "parents")
contextMenu.addAction("Add parent..."); // contextMenu.addAction("Add parent...");
// Right click on a parent item // // Right click on a parent item
else if(item->parent() && item->parent()->data(0) == "parents") // else if(item->parent() && item->parent()->data(0) == "parents")
// {
// contextMenu.addAction("Add parent...");
// contextMenu.addAction("Remove parent");
// }
if(item->isArray())
{ {
contextMenu.addAction("Add parent..."); contextMenu.addAction("Append array entry...");
contextMenu.addAction("Remove parent");
} }
else if(item->getFormElm()->isArray()) else if(item->isArrayMember())
contextMenu.addAction("Add array entry...");
else if(item->getFormElm()->isStruct())
{ {
QMenu *structContext = new QMenu("Add struct element...", this); contextMenu.addAction("Delete array entry...");
contextMenu.addMenu(structContext); contextMenu.addAction("Insert after array entry...");
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) // else if(item->getFormElm()->isStruct())
contextMenu.addAction("Revert to parent/default..."); // {
// QMenu *structContext = new QMenu("Add struct element...", this);
// contextMenu.addMenu(structContext);
QAction *selectedItem = contextMenu.exec(globalPos); // NLGEORGES::UFormDfn *defn = item->getFormElm()->getStructDfn();
if(selectedItem) // if(defn)
{ // {
if(selectedItem->text() == "Add parent...") // for(uint defnNum=0; defnNum < defn->getNumEntry(); defnNum++)
{ // {
// Get the file extension of the form so we can build a dialog pattern. // std::string entryName;
QString file = m_form->getFilename().c_str(); // std::string dummy;
file = file.remove(0,file.indexOf(".")+1); // UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue;
QString filePattern = "Parent Sheets (*."+file+")"; // bool result = defn->getEntryName(defnNum, entryName);
// bool result2 = item->getFormElm()->getValueByName(dummy, entryName.c_str(), NLGEORGES::UFormElm::Eval, whereV);
nlinfo("parent defn name '%s'", file.toUtf8().constData());
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select parent sheets..."), m_lastSheetDir, filePattern); //
if(!fileNames.isEmpty()) // if(result2 && *whereV != UFormElm::ValueForm)
{ // {
Q_FOREACH(QString fileToParent, fileNames) // structContext->addAction(entryName.c_str());
{ // }
// Get just the filename. Georges doesn't want the path. // delete whereV;
QFileInfo pathInfo( fileToParent ); // }
QString tmpFileName( pathInfo.fileName() ); // }
// }
nlinfo("requesting to add parent form '%s'", tmpFileName.toUtf8().constData()); // else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm)
// contextMenu.addAction("Revert to parent/default...");
// 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++) QAction *selectedItem = contextMenu.exec(QCursor::pos());
{ if(selectedItem)
QString curParentName = form->getParent(num)->getFilename().c_str(); {
if(parentFileName == curParentName) if(selectedItem->text() == "Append array entry...")
{ {
form->removeParent(num);
m->removeParentForm(parentFileName);
break;
}
}
m_ui.treeView->expandAll();
}
} // if selected context menu item is valid. } // Append an array entry...
else if(selectedItem->text() == "Delete array entry...")
{
}
else if(selectedItem->text() == "Insert after array entry...")
{
}
// 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 'm' model valid.
if(structContext) //if(structContext)
delete structContext; // delete structContext;
} }
} /* namespace GeorgesQt */ } /* namespace GeorgesQt */

@ -57,14 +57,14 @@ namespace GeorgesQt
bool isModified() {return m_modified;} bool isModified() {return m_modified;}
void setModified(bool m) {m_modified = m;} void setModified(bool m) {m_modified = m;}
NLGEORGES::CForm* getFormByName(const QString formName); NLGEORGES::CForm* getFormByName(const QString formName);
NLGEORGES::CForm* getFormByDfnName(const QString dfnName); NLGEORGES::CForm* getFormByDfnName(const QString dfnName);
/// Retrieves the root element based on the slot (document or held elements.) /// Retrieves the root element based on the slot (document or held elements.)
NLGEORGES::CFormElm *getRootNode(uint slot); NLGEORGES::CFormElm *getRootNode(uint slot);
/// Returns the form as a CForm pointer. /// Returns the form as a CForm pointer.
NLGEORGES::CForm *getFormPtr(); NLGEORGES::CForm *getFormPtr();
void addParentForm(QString parentFormNm); void addParentForm(QString parentFormNm);

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>564</width>
<height>300</height> <height>525</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -18,8 +18,8 @@
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>199</width> <width>280</width>
<height>165</height> <height>242</height>
</size> </size>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
@ -29,9 +29,21 @@
<string/> <string/>
</property> </property>
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="treeViewTabWidget"> <widget class="QTabWidget" name="treeViewTabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="tabPosition"> <property name="tabPosition">
<enum>QTabWidget::West</enum> <enum>QTabWidget::West</enum>
</property> </property>
@ -39,60 +51,40 @@
<number>0</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="form_tab"> <widget class="QWidget" name="form_tab">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<attribute name="title"> <attribute name="title">
<string>Form</string> <string>Form</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="bottomMargin"> <item>
<number>0</number> <widget class="QSplitter" name="splitter">
</property>
<item row="0" column="0" colspan="4">
<widget class="QTreeView" name="treeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxParent">
<property name="text">
<string>Parent</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <widget class="QTreeView" name="treeView">
<size> <property name="sizePolicy">
<width>40</width> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<height>20</height> <horstretch>0</horstretch>
</size> <verstretch>0</verstretch>
</property> </sizepolicy>
</spacer> </property>
</item> <property name="minimumSize">
<item row="1" column="1"> <size>
<widget class="QCheckBox" name="checkBoxDefaults"> <width>0</width>
<property name="text"> <height>0</height>
<string>Defaults</string> </size>
</property> </property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
<widget class="QtTreePropertyBrowser" name="propertiesBrowser" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -126,8 +118,14 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<resources> <customwidgets>
<include location="georges_editor.qrc"/> <customwidget>
</resources> <class>QtTreePropertyBrowser</class>
<extends>QWidget</extends>
<header>qttreepropertybrowser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/> <connections/>
</ui> </ui>

@ -27,6 +27,10 @@
namespace NLGEORGES { namespace NLGEORGES {
class UFormElm; class UFormElm;
class UForm;
class CFormElmStruct;
class CFormDfn;
class CFormElmArray;
} }
namespace GeorgesQt namespace GeorgesQt
@ -36,9 +40,8 @@ namespace GeorgesQt
class CGeorgesFormModel : public QAbstractItemModel class CGeorgesFormModel : public QAbstractItemModel
{ {
public: public:
CGeorgesFormModel(NLGEORGES::UFormElm *root, QMap< QString, QStringList> deps, CGeorgesFormModel(NLGEORGES::UForm *form, QMap< QString, QStringList> deps,
QString comment, QStringList parents, bool* expanded, QObject *parent = 0); QString comment, QStringList parents, bool* expanded, QObject *parent = 0);
~CGeorgesFormModel(); ~CGeorgesFormModel();
@ -47,6 +50,7 @@ namespace GeorgesQt
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex index(int row, int column, CFormItem *item) const;
QModelIndex parent(const QModelIndex &index) const; QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const;
@ -58,15 +62,26 @@ namespace GeorgesQt
void setShowDefaults( bool show ); void setShowDefaults( bool show );
void addParentForm(QString parentForm); void addParentForm(QString parentForm);
void removeParentForm(QString parentForm); void removeParentForm(QString parentForm);
NLGEORGES::UFormElm *getRootForm() { return m_rootElm; } NLGEORGES::UFormElm *getRootForm() { return m_rootElm; }
CFormItem *addStruct (CFormItem *parent, NLGEORGES::CFormElmStruct *_struct, NLGEORGES::CFormDfn *parentDfn,
const char *name, uint structId, const char *formName, uint slot);
CFormItem *addArray(CFormItem *parent, NLGEORGES::CFormElmArray *array, NLGEORGES::CFormDfn *rootDfn,
const char *name, uint structId, const char *formName, uint slot);
void emitDataChanged(const QModelIndex &index)
{
Q_EMIT dataChanged(index, index);
}
private: private:
void setupModelData(); void setupModelData();
void loadFormData(NLGEORGES::UFormElm *rootElm, CFormItem *parent); void loadFormData(NLGEORGES::UFormElm *rootElm, CFormItem *parent);
void loadFormHeader(); void loadFormHeader();
NLGEORGES::UForm* m_form;
CFormItem* m_rootItem; CFormItem* m_rootItem;
NLGEORGES::UFormElm* m_rootElm; NLGEORGES::UFormElm* m_rootElm;
QList<QVariant> m_rootData; QList<QVariant> m_rootData;
QMap< QString, QStringList> m_dependencies; QMap< QString, QStringList> m_dependencies;
QString m_comments; QString m_comments;

@ -14,15 +14,17 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "georgesform_proxy_model.h"
#include "formitem.h"
#include "georgesform_model.h"
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
#include <nel/georges/u_form_elm.h> #include <nel/georges/u_form_elm.h>
// project includes
#include "formitem.h"
#include "georgesform_proxy_model.h"
#include "georgesform_model.h"
#if 0
namespace GeorgesQt namespace GeorgesQt
{ {
@ -78,4 +80,5 @@ namespace GeorgesQt
} }
} /* namespace GeorgesQt */ } /* namespace GeorgesQt */
#endif // 0
/* end of file */ /* end of file */

@ -20,6 +20,7 @@
// Qt includes // Qt includes
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#if 0
namespace GeorgesQt namespace GeorgesQt
{ {
@ -41,5 +42,5 @@ namespace GeorgesQt
};/* class CGeorgesFormProxyModel */ };/* class CGeorgesFormProxyModel */
} /* namespace GeorgesQt */ } /* namespace GeorgesQt */
#endif // 0
#endif // GEORGESFORM_PROXY_MODEL_H #endif // GEORGESFORM_PROXY_MODEL_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

@ -66,7 +66,7 @@ CMainWindow::CMainWindow(QWidget *parent)
_isGraphicsInitialized(false), _isGraphicsInitialized(false),
_isGraphicsEnabled(false), _isGraphicsEnabled(false),
_isSoundInitialized(false), _isSoundInitialized(false),
_isSoundEnabled(true), _isSoundEnabled(false), // MTR workaround for sheet id nonsense
_GraphicsViewport(NULL), _GraphicsViewport(NULL),
_lastDir("."), _lastDir("."),
_mouseMode(NL3D::U3dMouseListener::edit3d) _mouseMode(NL3D::U3dMouseListener::edit3d)

Loading…
Cancel
Save