Changed: Enabled custom context menu signal to open a menu at the mouse position.

This commit is contained in:
mattraykowski 2012-10-21 13:48:02 -07:00
parent bc2ecb6023
commit 098c6b96eb
2 changed files with 96 additions and 92 deletions

View file

@ -1,91 +1,91 @@
// 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 FORMITEM_H
#define FORMITEM_H
// NeL includes
#include <nel/georges/u_form.h>
#include <nel/georges/u_form_elm.h>
// Qt includes
#include <QList>
#include <QVariant>
namespace GeorgesQt
{
class CFormItem
{
public:
// What is the sub object ?
enum TSub
{
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();
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);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
int row() const;
CFormItem *parent();
bool setData(int column, const QVariant &value);
TSub nodeType() { return _Type; }
std::string formName() { return _FormName; }
std::string name() { return _Name; }
void setName(std::string name) { _Name = name; }
uint structId() { return _StructId; }
NLGEORGES::UForm *form() { return m_form; }
bool isEditable(int column);
bool isArray();
bool isArrayMember();
QIcon getItemImage(CFormItem *rootItem);
private:
QList<CFormItem*> childItems;
QList<QVariant> itemData;
CFormItem *parentItem;
NLGEORGES::UFormElm* formElm;
NLGEORGES::UForm *m_form;
uint _StructId;
std::string _Name;
std::string _FormName;
TSub _Type;
uint _Slot;
}; // CFormItem
}
#endif // FORMITEM_H
// 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 FORMITEM_H
#define FORMITEM_H
// NeL includes
#include <nel/georges/u_form.h>
#include <nel/georges/u_form_elm.h>
// Qt includes
#include <QList>
#include <QVariant>
namespace GeorgesQt
{
class CFormItem
{
public:
// What is the sub object ?
enum TSub
{
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();
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);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
int row() const;
CFormItem *parent();
bool setData(int column, const QVariant &value);
TSub nodeType() { return _Type; }
std::string formName() { return _FormName; }
std::string name() { return _Name; }
void setName(std::string name) { _Name = name; }
uint structId() { return _StructId; }
NLGEORGES::UForm *form() { return m_form; }
bool isEditable(int column);
bool isArray();
bool isArrayMember();
QIcon getItemImage(CFormItem *rootItem);
private:
QList<CFormItem*> childItems;
QList<QVariant> itemData;
CFormItem *parentItem;
NLGEORGES::UFormElm* formElm;
NLGEORGES::UForm *m_form;
uint _StructId;
std::string _Name;
std::string _FormName;
TSub _Type;
uint _Slot;
}; // CFormItem
}
#endif // FORMITEM_H

View file

@ -74,6 +74,10 @@ namespace GeorgesQt
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)),
this, SLOT(doubleClicked (QModelIndex)));
connect(m_header, SIGNAL(headerClicked(int)),
@ -522,7 +526,7 @@ namespace GeorgesQt
// else if(item->getFormElm()->isAtom() && item->valueFrom() == NLGEORGES::UFormElm::ValueForm)
// contextMenu.addAction("Revert to parent/default...");
// QAction *selectedItem = contextMenu.exec(globalPos);
QAction *selectedItem = contextMenu.exec(QCursor::pos());
// if(selectedItem)
// {
// if(selectedItem->text() == "Add parent...")