Commit fffafb97 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.navigator: adding context menu to navigator

Change-Id: I1e0993c4e4adf7c797a659665c5c515fc390b950
Reviewed-on: http://codereview.qt.nokia.com/791Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent dde8ef0c
......@@ -37,7 +37,7 @@
#include <nodeproperty.h>
#include <metainfo.h>
#include <qgraphicswidget.h>
#include <abstractview.h>
#include <qmlmodelview.h>
#include <rewriterview.h>
#include <invalididexception.h>
#include <rewritingexception.h>
......@@ -376,7 +376,7 @@ NavigatorTreeModel::ItemRow NavigatorTreeModel::itemRowForNode(const ModelNode &
return m_nodeItemHash.value(node);
}
void NavigatorTreeModel::setView(AbstractView *view)
void NavigatorTreeModel::setView(QmlModelView *view)
{
m_view = view;
m_hiddenProperties.clear();
......@@ -641,4 +641,10 @@ void NavigatorTreeModel::setVisible(const QModelIndex &index, bool visible)
itemRow.visibilityItem->setCheckState(visible ? Qt::Checked : Qt::Unchecked);
}
void NavigatorTreeModel::openContextMenu(const QPoint &p)
{
if (m_view)
m_view->showContextMenu(p, QPoint(), false);
}
} // QmlDesigner
......@@ -42,7 +42,7 @@
namespace QmlDesigner {
class Model;
class AbstractView;
class QmlModelView;
class ModelNode;
class NavigatorTreeModel : public QStandardItemModel
......@@ -98,7 +98,7 @@ public:
int column,
const QModelIndex &parent);
void setView(AbstractView *view);
void setView(QmlModelView *view);
void clearView();
QModelIndex indexForNode(const ModelNode &node) const;
......@@ -117,6 +117,7 @@ public:
void setId(const QModelIndex &index, const QString &id);
void setVisible(const QModelIndex &index, bool visible);
void openContextMenu(const QPoint &p);
private slots:
void handleChangedItem(QStandardItem *item);
......@@ -142,7 +143,7 @@ private:
private:
QHash<ModelNode, ItemRow> m_nodeItemHash;
QHash<uint, ModelNode> m_nodeHash;
QWeakPointer<AbstractView> m_view;
QWeakPointer<QmlModelView> m_view;
bool m_blockItemChangedSignal;
......
......@@ -44,6 +44,7 @@
#include <QLineEdit>
#include <QPen>
#include <QPixmapCache>
#include <QMouseEvent>
static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
......@@ -179,6 +180,19 @@ NavigatorTreeView::NavigatorTreeView(QWidget *parent)
style->setParent(this);
}
bool NameItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *, const QStyleOptionViewItem &, const QModelIndex &)
{
if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::RightButton) {
m_TreeModel->openContextMenu(mouseEvent->globalPos());
mouseEvent->accept();
return true;
}
}
return false;
}
QSize IconCheckboxItemDelegate::sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
......
......@@ -84,6 +84,9 @@ class NameItemDelegate : public QStyledItemDelegate
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
protected:
bool editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index );
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
......
......@@ -93,7 +93,7 @@ NavigatorWidget *NavigatorView::widget()
void NavigatorView::modelAttached(Model *model)
{
AbstractView::modelAttached(model);
QmlModelView::modelAttached(model);
m_treeModel->setView(this);
......@@ -112,7 +112,7 @@ void NavigatorView::modelAttached(Model *model)
void NavigatorView::modelAboutToBeDetached(Model *model)
{
m_treeModel->clearView();
AbstractView::modelAboutToBeDetached(model);
QmlModelView::modelAboutToBeDetached(model);
}
void NavigatorView::importsChanged(const QList<Import> &/*addedImports*/, const QList<Import> &/*removedImports*/)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment