#2131 AppFwk : Wire up custom menu slot once

When this signal is wired up multiple times, the context menu shows up after activating a menu item in the context menu
This commit is contained in:
Magne Sjaastad
2017-11-14 09:22:11 +01:00
parent e729ae02da
commit cebe3009e7

View File

@@ -195,9 +195,6 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
} }
else if (PdmUiTreeSelectionQModel::isMultipleValueField(fieldValue)) else if (PdmUiTreeSelectionQModel::isMultipleValueField(fieldValue))
{ {
connect(m_treeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(customMenuRequested(QPoint)));
caf::PdmUiObjectHandle* uiObject = uiObj(field()->fieldHandle()->ownerObject()); caf::PdmUiObjectHandle* uiObject = uiObj(field()->fieldHandle()->ownerObject());
if (uiObject) if (uiObject)
{ {
@@ -216,7 +213,6 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
else else
{ {
m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
m_treeView->setContextMenuPolicy(Qt::CustomContextMenu);
} }
if (!m_attributes.showTextFilter) if (!m_attributes.showTextFilter)
@@ -291,6 +287,9 @@ QWidget* PdmUiTreeSelectionEditor::createEditorWidget(QWidget* parent)
m_treeView = treeViewHeightHint; m_treeView = treeViewHeightHint;
m_treeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_treeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(customMenuRequested(QPoint)));
layout->addWidget(treeViewHeightHint); layout->addWidget(treeViewHeightHint);
return frame; return frame;
@@ -324,7 +323,7 @@ void PdmUiTreeSelectionEditor::customMenuRequested(const QPoint& pos)
} }
} }
if (onlyHeadersInSelection) if (onlyHeadersInSelection && selectedIndexes.size() > 0)
{ {
{ {
QAction* act = new QAction("Sub Items On", this); QAction* act = new QAction("Sub Items On", this);