|
|
@ -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)
|
|
|
@ -492,109 +474,128 @@ namespace GeorgesQt
|
|
|
|
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() );
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm)
|
|
|
|
|
|
|
|
// contextMenu.addAction("Revert to parent/default...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QAction *selectedItem = contextMenu.exec(QCursor::pos());
|
|
|
|
|
|
|
|
if(selectedItem)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(selectedItem->text() == "Append array entry...")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
nlinfo("requesting to add parent form '%s'", tmpFileName.toUtf8().constData());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Call to add the form and load it into the Georges form.
|
|
|
|
} // Append an array entry...
|
|
|
|
addParentForm(tmpFileName);
|
|
|
|
else if(selectedItem->text() == "Delete array entry...")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// Save the file lookup path for future dialog boxes.
|
|
|
|
}
|
|
|
|
m_lastSheetDir = pathInfo.absolutePath();
|
|
|
|
else if(selectedItem->text() == "Insert after array entry...")
|
|
|
|
}
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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(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 */
|
|
|
|