Changed: Enabled custom context menu signal to open a menu at the mouse position.
This commit is contained in:
parent
bc2ecb6023
commit
098c6b96eb
2 changed files with 96 additions and 92 deletions
|
@ -1,91 +1,91 @@
|
||||||
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||||
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
|
// Copyright (C) 2011 Adrian Jaekel <aj at elane2k dot com>
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
// License, or (at your option) any later version.
|
// License, or (at your option) any later version.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU Affero General Public License for more details.
|
// GNU Affero General Public License for more details.
|
||||||
//
|
//
|
||||||
// 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/>.
|
||||||
|
|
||||||
#ifndef FORMITEM_H
|
#ifndef FORMITEM_H
|
||||||
#define FORMITEM_H
|
#define FORMITEM_H
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/georges/u_form.h>
|
#include <nel/georges/u_form.h>
|
||||||
#include <nel/georges/u_form_elm.h>
|
#include <nel/georges/u_form_elm.h>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace GeorgesQt
|
namespace GeorgesQt
|
||||||
{
|
{
|
||||||
|
|
||||||
class CFormItem
|
class CFormItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// What is the sub object ?
|
// What is the sub object ?
|
||||||
enum TSub
|
enum TSub
|
||||||
{
|
{
|
||||||
Null, // Nothing in this node (root ?)
|
Null, // Nothing in this node (root ?)
|
||||||
Header, // Header node
|
Header, // Header node
|
||||||
Type, // This node is a type
|
Type, // This node is a type
|
||||||
Dfn, // This node is a dfn
|
Dfn, // This node is a dfn
|
||||||
Form, // This node is a form
|
Form, // This node is a form
|
||||||
};
|
};
|
||||||
|
|
||||||
CFormItem();
|
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 *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;
|
||||||
QVariant data(int column) const;
|
QVariant data(int column) const;
|
||||||
int row() const;
|
int row() const;
|
||||||
CFormItem *parent();
|
CFormItem *parent();
|
||||||
bool setData(int column, const QVariant &value);
|
bool setData(int column, const QVariant &value);
|
||||||
|
|
||||||
TSub nodeType() { return _Type; }
|
TSub nodeType() { return _Type; }
|
||||||
std::string formName() { return _FormName; }
|
std::string formName() { return _FormName; }
|
||||||
|
|
||||||
std::string name() { return _Name; }
|
std::string name() { return _Name; }
|
||||||
void setName(std::string name) { _Name = name; }
|
void setName(std::string name) { _Name = name; }
|
||||||
|
|
||||||
uint structId() { return _StructId; }
|
uint structId() { return _StructId; }
|
||||||
|
|
||||||
NLGEORGES::UForm *form() { return m_form; }
|
NLGEORGES::UForm *form() { return m_form; }
|
||||||
|
|
||||||
bool isEditable(int column);
|
bool isEditable(int column);
|
||||||
bool isArray();
|
bool isArray();
|
||||||
bool isArrayMember();
|
bool isArrayMember();
|
||||||
|
|
||||||
QIcon getItemImage(CFormItem *rootItem);
|
QIcon getItemImage(CFormItem *rootItem);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<CFormItem*> childItems;
|
QList<CFormItem*> childItems;
|
||||||
QList<QVariant> itemData;
|
QList<QVariant> itemData;
|
||||||
CFormItem *parentItem;
|
CFormItem *parentItem;
|
||||||
NLGEORGES::UFormElm* formElm;
|
NLGEORGES::UFormElm* formElm;
|
||||||
NLGEORGES::UForm *m_form;
|
NLGEORGES::UForm *m_form;
|
||||||
|
|
||||||
uint _StructId;
|
uint _StructId;
|
||||||
std::string _Name;
|
std::string _Name;
|
||||||
std::string _FormName;
|
std::string _FormName;
|
||||||
TSub _Type;
|
TSub _Type;
|
||||||
uint _Slot;
|
uint _Slot;
|
||||||
|
|
||||||
}; // CFormItem
|
}; // CFormItem
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // FORMITEM_H
|
#endif // FORMITEM_H
|
||||||
|
|
|
@ -74,6 +74,10 @@ namespace GeorgesQt
|
||||||
|
|
||||||
m_form = 0;
|
m_form = 0;
|
||||||
|
|
||||||
|
m_ui.treeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
|
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_header, SIGNAL(headerClicked(int)),
|
connect(m_header, SIGNAL(headerClicked(int)),
|
||||||
|
@ -522,7 +526,7 @@ namespace GeorgesQt
|
||||||
// else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm)
|
// else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm)
|
||||||
// contextMenu.addAction("Revert to parent/default...");
|
// contextMenu.addAction("Revert to parent/default...");
|
||||||
|
|
||||||
// QAction *selectedItem = contextMenu.exec(globalPos);
|
QAction *selectedItem = contextMenu.exec(QCursor::pos());
|
||||||
// if(selectedItem)
|
// if(selectedItem)
|
||||||
// {
|
// {
|
||||||
// if(selectedItem->text() == "Add parent...")
|
// if(selectedItem->text() == "Add parent...")
|
||||||
|
|
Loading…
Reference in a new issue