pqRecordEventsDialog.cxx 6.46 KB
Newer Older
1 2 3 4 5
/*=========================================================================

   Program: ParaView
   Module:    pqRecordEventsDialog.cxx

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
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
   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.

=========================================================================*/

33 34 35 36
// Qt includes
#include <QDebug>
#include <QFile>
#include <QFileDialog>
37
#include <QPushButton>
38 39 40 41
#include <QTextStream>
#include <QTimer>

// QtTesting includes
42
#include "pqEventComment.h"
43
#include "pqEventRecorder.h"
44
#include "pqEventTypes.h"
45
#include "pqRecordEventsDialog.h"
46
#include "pqTestUtility.h"
47

48 49 50 51 52 53 54 55
#include "ui_pqRecordEventsDialog.h"

//////////////////////////////////////////////////////////////////////////////////
// pqImplementation

struct pqRecordEventsDialog::pqImplementation
{
public:
56 57 58
  pqImplementation(pqEventRecorder* recorder,
                   pqTestUtility* testUtility)
    : Recorder(recorder), TestUtility(testUtility)
59 60 61 62 63
  {
  }
  
  ~pqImplementation()
  {
64 65
    this->Recorder = 0;
    this->TestUtility = 0;
66 67 68 69
  }

  Ui::pqRecordEventsDialog Ui;

70 71
  pqEventRecorder*    Recorder;
  pqTestUtility*      TestUtility;
72 73 74 75 76
};

///////////////////////////////////////////////////////////////////////////////////
// pqRecordEventsDialog

77 78 79 80
// ----------------------------------------------------------------------------
pqRecordEventsDialog::pqRecordEventsDialog(pqEventRecorder* recorder,
                                           pqTestUtility* testUtility,
                                           QWidget* Parent)
81
  : QDialog(Parent),
82
    Implementation(new pqImplementation(recorder, testUtility))
83 84
{
  this->Implementation->Ui.setupUi(this);
85
  this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
86

87
  this->ignoreObject(this);
88

89 90 91
  this->setWindowTitle(tr("Recording User Input"));
  this->setObjectName("");

92
  QObject::connect(this->Implementation->TestUtility->eventTranslator(),
Mathieu Westphal's avatar
Mathieu Westphal committed
93 94
                   SIGNAL(recordEvent(QString,QString,QString, int)),
                   this, SLOT(onEventRecorded(QString,QString,QString, int)));
95

96 97 98
  QObject::connect(this->Implementation->Ui.commentAddButton,
                   SIGNAL(clicked()),
                   this, SLOT(addComment()));
99

Mathieu Westphal's avatar
Mathieu Westphal committed
100 101 102 103 104
  QObject::connect(this->Implementation->Ui.checkButton,
                   SIGNAL(toggled(bool)),
                   this->Implementation->Recorder,
                   SLOT(check(bool)));

105 106 107
  QObject::connect(this->Implementation->Ui.recordPauseButton,
                   SIGNAL(toggled(bool)),
                   this->Implementation->Recorder,
Mathieu Westphal's avatar
Mathieu Westphal committed
108
                   SLOT(unpause(bool)));
109

110 111 112 113 114
  QObject::connect(this->Implementation->Ui.continuousFlush,
                   SIGNAL(toggled(bool)),
                   this->Implementation->Recorder,
                   SLOT(setContinuousFlush(bool)));

115 116 117 118 119
  QObject::connect(this->Implementation->Ui.recordInteractionTimings,
                   SIGNAL(toggled(bool)),
                   this->Implementation->Recorder,
                   SLOT(setRecordInteractionTimings(bool)));

120 121 122 123 124 125 126 127
  QObject::connect(this->Implementation->Recorder,
                   SIGNAL(started()),
                   this,
                   SLOT(updateUi()));
  QObject::connect(this->Implementation->Recorder,
                   SIGNAL(stopped()),
                   this,
                   SLOT(updateUi()));
128 129
}

130
// ----------------------------------------------------------------------------
131 132 133 134 135
pqRecordEventsDialog::~pqRecordEventsDialog()
{
  delete Implementation;
}

136 137 138 139 140 141 142 143 144 145
// ----------------------------------------------------------------------------
void pqRecordEventsDialog::ignoreObject(QObject* object)
{
  this->Implementation->TestUtility->eventTranslator()->ignoreObject(object);
  foreach(QObject* child, object->children())
    {
    this->ignoreObject(child);
    }
}

146 147
// ----------------------------------------------------------------------------
void pqRecordEventsDialog::done(int value)
148
{
149
  this->Implementation->TestUtility->stopRecords(value);
150
  QDialog::done(value);
151
}
152 153

// ----------------------------------------------------------------------------
154
void pqRecordEventsDialog::onEventRecorded(const QString& widget,
155
                                           const QString& command,
156 157
                                           const QString& argument,
                                           int eventType)
158
{
159 160 161 162 163
  if (!this->Implementation->Recorder->isRecording())
    {
    return;
    }

164 165 166 167 168 169
  this->Implementation->Ui.eventWidgetEdit->setText(widget);
  this->Implementation->Ui.eventCommandEdit->setText(command);
  this->Implementation->Ui.eventArgumentEdit->setText(argument);
  int newValue = this->Implementation->Ui.nbEvents->value() + 1;
  this->Implementation->Ui.nbEvents->display(newValue);
}
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185

// ----------------------------------------------------------------------------
void pqRecordEventsDialog::addComment()
{
  if (this->Implementation->Ui.blockingCheckBox->isChecked())
    {
    this->Implementation->Recorder->translator()->eventComment()->recordCommentBlock(
        this->Implementation->Ui.commentTextEdit->toPlainText());
    }
  else
    {
    this->Implementation->Recorder->translator()->eventComment()->recordComment(
        this->Implementation->Ui.commentTextEdit->toPlainText());
    }
  this->Implementation->Ui.commentTextEdit->clear();
}
186 187 188 189 190 191 192

// ----------------------------------------------------------------------------
void pqRecordEventsDialog::updateUi()
{
  this->Implementation->Ui.recordPauseButton->setChecked(
      this->Implementation->Recorder->isRecording());
}