Commit 3f3d5921 authored by Mathieu Westphal's avatar Mathieu Westphal

Adding QListView support

parent 8d2c17f7
......@@ -126,6 +126,8 @@ SET(MOC_SRCS
pqEventSource.h
pqEventTranslator.h
pqLineEditEventTranslator.h
pqListViewEventPlayer.h
pqListViewEventTranslator.h
pqMenuEventTranslator.h
pqNativeFileDialogEventPlayer.h
pqNativeFileDialogEventTranslator.h
......@@ -211,6 +213,8 @@ SET(QtTesting_SOURCES
pqEventRecorder.cxx
pqEventTranslator.cxx
pqLineEditEventTranslator.cxx
pqListViewEventPlayer.cxx
pqListViewEventTranslator.cxx
pqMenuEventTranslator.cxx
pqNativeFileDialogEventPlayer.cxx
pqNativeFileDialogEventTranslator.cxx
......@@ -264,6 +268,8 @@ SET(QtTesting_DEVEL_HEADERS
pqEventTranslator.h
pqEventTypes.h
pqLineEditEventTranslator.h
pqListViewEventPlayer.h
pqListViewEventTranslator.h
pqMenuEventTranslator.h
pqNativeFileDialogEventPlayer.h
pqNativeFileDialogEventTranslator.h
......
......@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqAbstractActivateEventPlayer.h"
#include "pqAbstractBooleanEventPlayer.h"
#include "pqAbstractDoubleEventPlayer.h"
#include "pq3DViewEventPlayer.h"
#include "pqAbstractIntEventPlayer.h"
#include "pqAbstractItemViewEventPlayer.h"
#include "pqAbstractMiscellaneousEventPlayer.h"
......@@ -42,12 +43,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqBasicWidgetEventPlayer.h"
#include "pqComboBoxEventPlayer.h"
#include "pqCommentEventPlayer.h"
#include "pqListViewEventPlayer.h"
#include "pqNativeFileDialogEventPlayer.h"
#include "pqObjectNaming.h"
#include "pqTabBarEventPlayer.h"
#include "pqTreeViewEventPlayer.h"
#include "pqTableViewEventPlayer.h"
#include "pqNativeFileDialogEventPlayer.h"
#include "pq3DViewEventPlayer.h"
#include "pqTreeViewEventPlayer.h"
#include "pqEventTypes.h"
#include <QApplication>
......@@ -79,6 +80,7 @@ void pqEventPlayer::addDefaultWidgetEventPlayers(pqTestUtility* util)
addWidgetEventPlayer(new pqComboBoxEventPlayer());
addWidgetEventPlayer(new pqTreeViewEventPlayer());
addWidgetEventPlayer(new pqTableViewEventPlayer());
addWidgetEventPlayer(new pqListViewEventPlayer());
addWidgetEventPlayer(new pqAbstractMiscellaneousEventPlayer());
addWidgetEventPlayer(new pq3DViewEventPlayer("QGLWidget"));
addWidgetEventPlayer(new pqNativeFileDialogEventPlayer(util));
......
......@@ -43,13 +43,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqEventComment.h"
#include "pqEventTypes.h"
#include "pqLineEditEventTranslator.h"
#include "pqListViewEventTranslator.h"
#include "pqMenuEventTranslator.h"
#include "pqNativeFileDialogEventTranslator.h"
#include "pqObjectNaming.h"
#include "pqSpinBoxEventTranslator.h"
#include "pqTabBarEventTranslator.h"
#include "pqTreeViewEventTranslator.h"
#include "pqTableViewEventTranslator.h"
#include "pqTreeViewEventTranslator.h"
#include <QCoreApplication>
#include <QtDebug>
......@@ -168,6 +169,7 @@ void pqEventTranslator::addDefaultWidgetEventTranslators(pqTestUtility* util)
addWidgetEventTranslator(new pqTabBarEventTranslator());
addWidgetEventTranslator(new pqTreeViewEventTranslator());
addWidgetEventTranslator(new pqTableViewEventTranslator());
addWidgetEventTranslator(new pqListViewEventTranslator());
addWidgetEventTranslator(new pq3DViewEventTranslator("QGLWidget"));
addWidgetEventTranslator(new pqNativeFileDialogEventTranslator(util));
}
......@@ -531,6 +533,10 @@ bool pqEventTranslator::eventFilter(QObject* object, QEvent* event)
// Cannot check widget , Inform user trying to check uncheckable widget
qWarning() << "Error checking an event for object, widget type not supported.";
qWarning() << "Name of the widget:" << widget->objectName() << ". Type of the widget:" << widget->metaObject()->className();
if (widget->parent() != NULL)
{
qWarning() << "Type of parent widget:" << widget->parent()->metaObject()->className();
}
}
// Block all input events, so the UI is static but still drawn.
// Except for MouseMove
......
/*=========================================================================
Program: ParaView
Module: pqListViewEventPlayer.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "pqListViewEventPlayer.h"
#include <QListView>
//-----------------------------------------------------------------------------
pqListViewEventPlayer::pqListViewEventPlayer(QObject* parentObject)
: Superclass(parentObject)
{
}
//-----------------------------------------------------------------------------
pqListViewEventPlayer::~pqListViewEventPlayer()
{
}
//-----------------------------------------------------------------------------0000000
bool pqListViewEventPlayer::playEvent(
QObject* object, const QString& command,
const QString& arguments, int eventType, bool& error)
{
QListView* listView= qobject_cast<QListView*>(object);
if(!listView)
{
// mouse events go to the viewport widget
listView = qobject_cast<QListView*>(object->parent());
}
if(!listView)
{
return false;
}
return this->Superclass::playEvent(object, command, arguments, eventType, error);
}
/*=========================================================================
Program: ParaView
Module: pqListViewEventPlayer.h
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef __pqListViewEventPlayer_h
#define __pqListViewEventPlayer_h
#include "pqAbstractItemViewEventPlayerBase.h"
/// pqListViewEventPlayer is a player for QTableWidget. Plays back the state
/// recorded using pqListViewEventTranslator.
class QTTESTING_EXPORT pqListViewEventPlayer : public pqAbstractItemViewEventPlayerBase
{
Q_OBJECT
typedef pqAbstractItemViewEventPlayerBase Superclass;
public:
pqListViewEventPlayer(QObject* parent=0);
~pqListViewEventPlayer();
bool playEvent(QObject* object, const QString& command,
const QString& arguments, int eventType, bool& error);
private:
pqListViewEventPlayer(const pqListViewEventPlayer&); // Not implemented.
void operator=(const pqListViewEventPlayer&); // Not implemented.
};
#endif
/*=========================================================================
Program: ParaView
Module: pqListViewEventTranslator.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "pqListViewEventTranslator.h"
#include <QListView>
#include <QHeaderView>
//-----------------------------------------------------------------------------
pqListViewEventTranslator::pqListViewEventTranslator(QObject* parentObject)
: Superclass(parentObject)
{
}
//-----------------------------------------------------------------------------
pqListViewEventTranslator::~pqListViewEventTranslator()
{
}
//-----------------------------------------------------------------------------
void pqListViewEventTranslator::onEnteredCheck(const QModelIndex& item)
{
// Recover list View
QListView* listView = qobject_cast<QListView*>(this->AbstractItemView);
// Get a visual rectangle of the item
QRect visualRect = listView->visualRect(item);
// Translate the rect of margins and headers
visualRect.translate(listView->contentsMargins().left(),
listView->contentsMargins().top());
// Stor item and signal that a specific overlay is ready to be drawn
this->ModelItemCheck = &item;
emit this->specificOverlay(visualRect);
}
//-----------------------------------------------------------------------------
bool pqListViewEventTranslator::findCorrectedAbstractItemView(QObject* object,
QAbstractItemView*& abstractItemView) const
{
// Ignore QHeaderView event specifically
if (qobject_cast<QHeaderView*>(object))
{
abstractItemView = NULL;
return false;
}
abstractItemView = qobject_cast<QListView*>(object);
if (!abstractItemView)
{
// mouse events go to the viewport widget
abstractItemView = qobject_cast<QListView*>(object->parent());
}
if (!abstractItemView)
{
return false;
}
return true;
}
/*=========================================================================
Program: ParaView
Module: pqListViewEventTranslator.h
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef __pqListViewEventTranslator_h
#define __pqListViewEventTranslator_h
#include "pqAbstractItemViewEventTranslatorBase.h"
/// Event recorder for QTableView. Records the toggling of the check states for
/// Table widget items. The recorded state can be played back using
/// pqListViewEventPlayer.
class QTTESTING_EXPORT pqListViewEventTranslator : public pqAbstractItemViewEventTranslatorBase
{
Q_OBJECT
typedef pqAbstractItemViewEventTranslatorBase Superclass;
public:
pqListViewEventTranslator(QObject* parent=0);
~pqListViewEventTranslator();
/// find and set the corrected abstract item view
virtual bool findCorrectedAbstractItemView(QObject* object,
QAbstractItemView*& abstractItemView) const;
protected slots:
/// Compute a visual rectangle for the item and signal it
void onEnteredCheck(const QModelIndex&);
private:
pqListViewEventTranslator(const pqListViewEventTranslator&); // Not implemented.
void operator=(const pqListViewEventTranslator&); // Not implemented.
};
#endif
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