From c5cafc7accaaec1e5d647abbf743ad057397ef42 Mon Sep 17 00:00:00 2001 From: mattraykowski Date: Sun, 21 Oct 2012 13:48:02 -0700 Subject: [PATCH] Changed: Enabled custom context menu signal to open a menu at the mouse position. --HG-- branch : branch-features-geqt-plugin --- .../src/plugins/georges_editor/formitem.h | 182 +++++++++--------- .../georges_treeview_dialog.cpp | 6 +- 2 files changed, 96 insertions(+), 92 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h index 258a339db..cc2dafece 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/formitem.h @@ -1,91 +1,91 @@ -// Object Viewer Qt - Georges Editor Plugin - MMORPG Framework -// Copyright (C) 2011 Adrian Jaekel -// -// 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 . - -#ifndef FORMITEM_H -#define FORMITEM_H - -// NeL includes -#include -#include - -// Qt includes -#include -#include - -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 childItems; - QList 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 +// Copyright (C) 2011 Adrian Jaekel +// +// 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 . + +#ifndef FORMITEM_H +#define FORMITEM_H + +// NeL includes +#include +#include + +// Qt includes +#include +#include + +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 childItems; + QList 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 diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp index c058e6a20..b2db0edb1 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -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...")