pqEventPlayer.h 4.65 KB
Newer Older
1 2 3 4 5
/*=========================================================================

   Program: ParaView
   Module:    pqEventPlayer.h

6
   Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7 8 9
   All rights reserved.

   ParaView is a free software; you can redistribute it and/or modify it
Mathieu Westphal's avatar
Mathieu Westphal committed
10
   under the terms of the ParaView license version 1.2.
11

12
   See License_v1.2.txt for the full ParaView license.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
   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 _pqEventPlayer_h
#define _pqEventPlayer_h

#include "QtTestingExport.h"

38
#include <QList>
39 40 41 42
#include <QObject>
#include <QString>

class pqWidgetEventPlayer;
43
class pqTestUtility;
44 45 46

/**
Manages playback of test-cases, demos, tutorials, etc.
Mathieu Westphal's avatar
Mathieu Westphal committed
47 48
pqEventPlayer converts high-level ParaView events
(button click, row selection, etc) into low-level Qt events
49
that drive the user interface.
50

Mathieu Westphal's avatar
Mathieu Westphal committed
51 52
The high-level events created by pqEventTranslator are fed to
pqEventPlayer::playEvent() one-by-one, which passes each event
53 54 55
through a collection of pqWidgetEventPlayer objects.  Each
pqWidgetEventPlayer has the chance to ignore the event or
accept and update the program state using low-level Qt events.
56

Mathieu Westphal's avatar
Mathieu Westphal committed
57
pqEventDispatcher is an example of an object that can retrieve
58 59
high-level events from a pqEventSource object, feeding them
to pqEventPlayer.
60

Mathieu Westphal's avatar
Mathieu Westphal committed
61 62 63 64
For specialized Qt widgets it may be necessary to create "custom"
pqWidgetEventPlayer derivatives, which can be added to pqEventPlayer
using the addWidgetEventPlayer() method.
pqWidgetEventPlayer objects are searched in order for
65 66 67
event playback, so you can also use this mechanism to
"override" the builtin event players.

68 69
\sa pqWidgetEventPlayer, pqEventTranslator, pqEventDispatcher,
pqEventSource, pqXMLEventSource
70 71
*/

72
class QTTESTING_EXPORT pqEventPlayer : public QObject
73 74
{
  Q_OBJECT
75

76 77
public:
  pqEventPlayer();
78
  ~pqEventPlayer() override;
79

Mathieu Westphal's avatar
Mathieu Westphal committed
80 81
  /** Adds the default set of widget players to the current working set.
  Players are executed in-order, so you can call addWidgetEventPlayer()
82
  before this function to override default players. */
83
  void addDefaultWidgetEventPlayers(pqTestUtility* util);
Mathieu Westphal's avatar
Mathieu Westphal committed
84
  /** Adds a new player to the current working set of widget players.
85
  pqEventPlayer assumes control of the lifetime of the supplied object. */
86
  void addWidgetEventPlayer(pqWidgetEventPlayer*);
87 88 89 90 91
  /** Method to get a specific player */
  bool removeWidgetEventPlayer(const QString& className);
  /** Method to get a specific player */
  pqWidgetEventPlayer* getWidgetEventPlayer(const QString& className);

92 93 94
  /** Method to return the list of widget event players added previously*/
  QList<pqWidgetEventPlayer*> players() const;

95
  /** This method is called with each high-level ParaView event, which
Mathieu Westphal's avatar
Mathieu Westphal committed
96
  will invoke the corresponding low-level Qt functionality in-turn.
97 98 99
  If there was an error playing the event, Error argument will be set
  to "true".  Note: Currently there is no guarantee that playEvent()
  will return immediately, since the functionality it invokes may enter
100
  a separate event loop (a modal dialog or context menu, for example).
Mathieu Westphal's avatar
Mathieu Westphal committed
101
  Check event will not modify ui but check a widget value*/
102 103 104 105
  void playEvent(const QString& object, const QString& command, const QString& arguments,
    int eventType, bool& Error);
  void playEvent(
    const QString& object, const QString& command, const QString& arguments, bool& Error);
106 107

signals:
108 109 110
  void eventAboutToBePlayed(
    const QString& Object, const QString& Command, const QString& Arguments);
  void eventPlayed(const QString& Object, const QString& Command, const QString& Arguments);
111
  void errorMessage(const QString&);
112 113

private:
114 115
  int getWidgetEventPlayerIndex(const QString& className);

116 117 118
  pqEventPlayer(const pqEventPlayer&);
  pqEventPlayer& operator=(const pqEventPlayer&);

119
  /// Stores the working set of widget players
120 121 122 123
  QList<pqWidgetEventPlayer*> Players;
};

#endif // !_pqEventPlayer_h