Commit 706d5cd1 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by GitHub

Merge pull request #35 from yumin/contextmenu-guard-in-itemview

Add guard for context menu in some view event players
parents eb26392e fd198ce4
......@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QList>
#include <QListWidget>
#include <QWheelEvent>
#include <QMenu>
#include "pqEventDispatcher.h"
......@@ -110,7 +111,10 @@ pqAbstractItemViewEventPlayer::pqAbstractItemViewEventPlayer(QObject* p)
bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
QAbstractItemView* object = qobject_cast<QAbstractItemView*>(Object);
if (!object)
QMenu* contextMenu= qobject_cast<QMenu*>(Object);
// if this a QMenu (potentially a context menu of the view),
// we should not move onto parent
if (!object && !contextMenu)
{
// mouse events go to the viewport widget
object = qobject_cast<QAbstractItemView*>(Object->parent());
......
......@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//#include <QKeyEvent>
#include <QAbstractItemView>
#include <QDebug>
#include <QMenu>
//-----------------------------------------------------------------------------
pqAbstractItemViewEventPlayerBase::pqAbstractItemViewEventPlayerBase(QObject* parentObject)
: Superclass(parentObject)
......@@ -94,7 +95,10 @@ bool pqAbstractItemViewEventPlayerBase::playEvent(
const QString& arguments, int eventType, bool& error)
{
QAbstractItemView* abstractItemView= qobject_cast<QAbstractItemView*>(object);
if(!abstractItemView)
QMenu* contextMenu= qobject_cast<QMenu*>(object);
// if this a QMenu (potentially a context menu of the view),
// we should not move onto parent
if(!abstractItemView && !contextMenu)
{
// mouse events go to the viewport widget
abstractItemView = qobject_cast<QAbstractItemView*>(object->parent());
......
......@@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "pqTreeViewEventPlayer.h"
#include <QTreeWidget>
#include <QMenu>
#include <QDebug>
//-----------------------------------------------------------------------------
......@@ -50,7 +51,10 @@ bool pqTreeViewEventPlayer::playEvent(
const QString& arguments, int eventType, bool& error)
{
QTreeView* treeView= qobject_cast<QTreeView*>(object);
if(!treeView)
QMenu* contextMenu= qobject_cast<QMenu*>(object);
// if this a QMenu (potentially a context menu of the view),
// we should not move onto parent
if(!treeView && !contextMenu)
{
// mouse events go to the viewport widget
treeView = qobject_cast<QTreeView*>(object->parent());
......
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