diff --git a/Resources/QtTesting.qrc b/Resources/QtTesting.qrc index 00fccef0f400aed29dbb37138fcebbeeeb85fecb..c4f75c4f9309115e715803afaecdb5bd11942d78 100644 --- a/Resources/QtTesting.qrc +++ b/Resources/QtTesting.qrc @@ -7,5 +7,7 @@ Icons/stop.png Icons/clear.svg Icons/info.png + Icons/minus.png + Icons/plus.png diff --git a/Resources/QtTestingIcons.qrc b/Resources/QtTestingIcons.qrc deleted file mode 100644 index 9edc01f2d9d3709861dd0d004280db01b978e345..0000000000000000000000000000000000000000 --- a/Resources/QtTestingIcons.qrc +++ /dev/null @@ -1,9 +0,0 @@ - - - Icons/frameForward.png - Icons/pause.png - Icons/repeat.png - Icons/timePlay.png - Icons/stop.png - - diff --git a/pqEventDispatcher.cxx b/pqEventDispatcher.cxx index 8b8fe3e5f8228540e7faa91ca12fa6e13106bfe5..3b973cc26e1ec94539cc2e3e58e6cb66b7d473bc 100644 --- a/pqEventDispatcher.cxx +++ b/pqEventDispatcher.cxx @@ -225,7 +225,7 @@ bool pqEventDispatcher::playEvents(pqEventSource& source, pqEventPlayer& player) this->PlayBackFinished = false; while (!this->PlayBackFinished) { - qDebug() << "while Loop"; +// qDebug() << "while Loop"; if(!this->PlayBackPaused) { this->playEvent(); diff --git a/pqEventPlayer.cxx b/pqEventPlayer.cxx index 872f1a258ae7ce8dc7d2f14c631cdb205c89b637..c337319519466820b84653e0e668e5903603fe5e 100644 --- a/pqEventPlayer.cxx +++ b/pqEventPlayer.cxx @@ -93,7 +93,6 @@ void pqEventPlayer::addWidgetEventPlayer(pqWidgetEventPlayer* Player) bool pqEventPlayer::removeWidgetEventPlayer(const QString& className) { int index = this->getWidgetEventPlayerIndex(className); - qDebug() << "Index : " << index << this->Players.at(index)->metaObject()->className(); if (index == -1) { return false; diff --git a/pqEventTranslator.cxx b/pqEventTranslator.cxx index 849b7e5187bfde0f190b1169cb015a655b8c69a9..d4c3a59489fd9b0f15050932d7f146b0ffd4b89c 100644 --- a/pqEventTranslator.cxx +++ b/pqEventTranslator.cxx @@ -146,7 +146,6 @@ bool pqEventTranslator::removeWidgetEventTranslator(const QString& className) } this->Implementation->Translators.remove(index); - qDebug() << "Translator : " << this->Implementation->Translators; return true; } diff --git a/pqPlayBackEventsDialog.cxx b/pqPlayBackEventsDialog.cxx index 2575e39cccd2d4707d72b21d13d09acf80817a94..a45d1b78beff8a30344a0a0e90dbb9f49c3d267b 100644 --- a/pqPlayBackEventsDialog.cxx +++ b/pqPlayBackEventsDialog.cxx @@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ +#include "pqCommentEventPlayer.h" #include "pqEventDispatcher.h" #include "pqEventPlayer.h" #include "pqPlayBackEventsDialog.h" @@ -40,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include #include #include @@ -62,6 +64,7 @@ public: void init(pqPlayBackEventsDialog* dialog); void setProgressBarsValue(int value); void setProgressBarValue(int row, int value); + QString setMaxLenght(const QString& name, int max); Ui::pqPlayBackEventsDialog Ui; @@ -69,7 +72,7 @@ public: pqEventDispatcher& Dispatcher; pqTestUtility* TestUtility; - int CurrentLine; + int CurrentLine; // Add counter to the Dispatcher int MaxLines; int CurrentFile; QStringList Filenames; @@ -101,18 +104,46 @@ void pqPlayBackEventsDialog::pqImplementation::init(pqPlayBackEventsDialog* dial { this->Ui.setupUi(dialog); + this->Ui.loadFileButton->setIcon( + QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon)); + + this->Ui.playerErrorTextLabel->setVisible(false); + this->Ui.playerErrorIconLabel->setVisible(false); + this->Ui.infoErrorTextLabel->setVisible(false); + this->Ui.infoErrorIconLabel->setVisible(false); + this->Ui.logBrowser->setVisible(false); + + pqWidgetEventPlayer* widgetPlayer = + this->Player.getWidgetEventPlayer(QString("pqCommentEventPlayer")); + pqCommentEventPlayer* commentPlayer = + qobject_cast(widgetPlayer); + if (commentPlayer) + { + commentPlayer->setCommentEnabled(true); + QObject::connect(commentPlayer, SIGNAL(comment(QString)), + this->Ui.logBrowser, SLOT(append(QString))); + qDebug() << "Comment player : " << commentPlayer; + } + + dialog->setMaximumHeight(dialog->minimumSizeHint().height()); + QObject::connect(&this->Player, SIGNAL(eventAboutToBePlayed(QString, QString, QString)), dialog, SLOT(onEventAboutToBePlayed(QString, QString, QString))); QObject::connect(this->Ui.timeStepSpinBox, SIGNAL(valueChanged(int)), - &this->Dispatcher, SLOT(changeTimeStep(int))); + &this->Dispatcher, SLOT(setTimeStep(int))); QObject::connect(this->Ui.loadFileButton, SIGNAL(clicked()), - dialog, SLOT(onLoadFiles())); + dialog, SLOT(loadFiles())); + QObject::connect(this->Ui.plusButton, SIGNAL(clicked()), + dialog, SLOT(insertFiles())); + QObject::connect(this->Ui.minusButton, SIGNAL(clicked()), + dialog, SLOT(removeFiles())); + QObject::connect(this->Ui.playPauseButton, SIGNAL(clicked(bool)), dialog, SLOT(onPlayOrPause(bool))); QObject::connect(this->Ui.stopButton, SIGNAL(clicked()), - this->TestUtility, SLOT(stop())); + this->TestUtility, SLOT(stopTests())); QObject::connect(this->Ui.stepButton, SIGNAL(clicked()), &this->Dispatcher, SLOT(oneStep())); @@ -123,9 +154,12 @@ void pqPlayBackEventsDialog::pqImplementation::init(pqPlayBackEventsDialog* dial dialog, SLOT(updateUi())); QObject::connect(&this->Dispatcher, SIGNAL(paused()), dialog, SLOT(updateUi())); - QObject::connect(&this->Dispatcher, SIGNAL(started()), + QObject::connect(&this->Dispatcher, SIGNAL(restarted()), dialog, SLOT(updateUi())); + QObject::connect(&this->Player, SIGNAL(errorMessage(QString)), + this->Ui.logBrowser, SLOT(append(QString))); + } // ---------------------------------------------------------------------------- @@ -138,13 +172,25 @@ void pqPlayBackEventsDialog::pqImplementation::setProgressBarsValue(int value) } // ---------------------------------------------------------------------------- -void pqPlayBackEventsDialog::pqImplementation::setProgressBarValue(int row, int value) +void pqPlayBackEventsDialog::pqImplementation::setProgressBarValue(int row, + int value) { QWidget* widget = this->Ui.tableWidget->cellWidget(row, 2); QProgressBar* progressBar = qobject_cast(widget); progressBar->setValue(value); } +// ---------------------------------------------------------------------------- +QString pqPlayBackEventsDialog::pqImplementation::setMaxLenght(const QString& name, + int max) +{ + if(name.length() > max) + { + return name.left(max/2) + "..." + name.right(max/2); + } + return name; +} + /////////////////////////////////////////////////////////////////////////////////// // pqPlayBackEventsDialog @@ -157,8 +203,8 @@ pqPlayBackEventsDialog::pqPlayBackEventsDialog(pqEventPlayer& Player, , Implementation(new pqImplementation(Player, Dispatcher, TestUtility)) { this->Implementation->init(this); - - this->onLoadFiles(); + this->setAttribute(Qt::WA_DeleteOnClose); + this->loadFiles(); } // ---------------------------------------------------------------------------- @@ -168,15 +214,14 @@ pqPlayBackEventsDialog::~pqPlayBackEventsDialog() } // ---------------------------------------------------------------------------- -void pqPlayBackEventsDialog::done(const int& value) +void pqPlayBackEventsDialog::done(int value) { this->Implementation->TestUtility->stopTests(); QDialog::done(value); - delete this; } // ---------------------------------------------------------------------------- -QStringList pqPlayBackEventsDialog::fileNamesSelected() +QStringList pqPlayBackEventsDialog::selectedFileNames() const { QStringList list; for(int i = 0; i < this->Implementation->Ui.tableWidget->rowCount(); ++i) @@ -204,42 +249,77 @@ void pqPlayBackEventsDialog::onEventAboutToBePlayed(const QString& Object, } // ---------------------------------------------------------------------------- -void pqPlayBackEventsDialog::onLoadFiles() +void pqPlayBackEventsDialog::loadFiles() { - QStringList filenames = QFileDialog::getOpenFileNames(this, "Macro File Name", + QFileDialog* dialog = new QFileDialog(this, "Macro File Name", QString(), "XML Files (*.xml)"); - if (!filenames.isEmpty()) + dialog->setFileMode(QFileDialog::ExistingFiles); + if (dialog->exec()) { - this->Implementation->Filenames = filenames; - + this->Implementation->Filenames = dialog->selectedFiles(); + this->Implementation->Ui.tableWidget->setRowCount(0); this->loadFiles(this->Implementation->Filenames); + } + delete dialog; +} - this->updateUi(); +// ---------------------------------------------------------------------------- +void pqPlayBackEventsDialog::insertFiles() +{ + QFileDialog* dialog = new QFileDialog(this, "Macro File Name", + QString(), "XML Files (*.xml)"); + dialog->setFileMode(QFileDialog::ExistingFiles); + if (dialog->exec()) + { + this->Implementation->Filenames << dialog->selectedFiles(); + this->loadFiles(dialog->selectedFiles()); } + delete dialog; } // ---------------------------------------------------------------------------- -void pqPlayBackEventsDialog::loadFiles(const QStringList& filenames) +void pqPlayBackEventsDialog::removeFiles() { - int rowCount = this->Implementation->Ui.tableWidget->rowCount(); - for(int i = 0 ; i < rowCount ; i++) + if (QMessageBox::Ok == QMessageBox::warning(this, QString("Remove files"), + QString("Are you sure you want to \n" + "remove all checked files ?\n"), + QMessageBox::Ok, + QMessageBox::Cancel)) { - this->Implementation->Ui.tableWidget->removeRow(0); + foreach(QString file, this->selectedFileNames()) + { + int index = this->Implementation->Filenames.indexOf(file); + this->Implementation->Ui.tableWidget->removeRow(index); + this->Implementation->Filenames.removeAt(index); + } } +} + +// ---------------------------------------------------------------------------- +void pqPlayBackEventsDialog::loadFiles(const QStringList& filenames) +{ for(int i = 0 ; i < filenames.count() ; i++) { - QFileInfo info(filenames[i]); - this->Implementation->Ui.tableWidget->insertRow(i); - this->Implementation->Ui.tableWidget->setItem( - i, 1, new QTableWidgetItem(info.fileName())); - this->Implementation->Ui.tableWidget->setCellWidget( - i, 2, new QProgressBar(this->Implementation->Ui.tableWidget)); - this->Implementation->setProgressBarsValue(0); - QCheckBox* check = new QCheckBox(this->Implementation->Ui.tableWidget); - check->setChecked(true); - this->Implementation->Ui.tableWidget->setCellWidget(i, 0, check); - this->Implementation->Ui.tableWidget->resizeColumnToContents(0); + this->addFile(filenames[i]); } + this->Implementation->Ui.tableWidget->resizeColumnToContents(0); +} + +// ---------------------------------------------------------------------------- +void pqPlayBackEventsDialog::addFile(const QString& filename) +{ + QFileInfo info(filename); + int newIndex = this->Implementation->Ui.tableWidget->rowCount(); + this->Implementation->Ui.tableWidget->insertRow(newIndex); + this->Implementation->Ui.tableWidget->setItem( + newIndex, 1, new QTableWidgetItem(info.fileName())); + this->Implementation->Ui.tableWidget->setCellWidget( + newIndex, 2, new QProgressBar(this->Implementation->Ui.tableWidget)); + this->Implementation->setProgressBarValue(newIndex, 0); + QCheckBox* check = new QCheckBox(this->Implementation->Ui.tableWidget); + check->setChecked(true); + this->Implementation->Ui.tableWidget->setCellWidget(newIndex, 0, check); + this->updateUi(); } // ---------------------------------------------------------------------------- @@ -249,7 +329,7 @@ void pqPlayBackEventsDialog::onPlayOrPause(bool playOrPause) { if(!this->Implementation->TestUtility->playingTest()) { - QStringList newList = this->fileNamesSelected(); + QStringList newList = this->selectedFileNames(); this->Implementation->TestUtility->playTests(newList); } else @@ -266,9 +346,11 @@ void pqPlayBackEventsDialog::onPlayOrPause(bool playOrPause) // ---------------------------------------------------------------------------- void pqPlayBackEventsDialog::onStarted(const QString& filename) { - this->Implementation->CurrentFile = this->Implementation->Filenames.indexOf(filename); + this->Implementation->CurrentFile = + this->Implementation->Filenames.indexOf(filename); this->Implementation->Ui.tableWidget->setCurrentCell( - this->Implementation->CurrentFile, 1, QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent); + this->Implementation->CurrentFile, 1, + QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent); this->Implementation->MaxLines = 0; this->Implementation->CurrentLine = 0; @@ -276,12 +358,14 @@ void pqPlayBackEventsDialog::onStarted(const QString& filename) QFile file(filename); QFileInfo infoFile(file); file.open(QIODevice::ReadOnly); + this->Implementation->Ui.logBrowser->append(QString("Start file : %1").arg( + infoFile.fileName())); QTextStream stream(&file); this->Implementation->Ui.currentFileLabel->setText(infoFile.fileName()); while(!stream.atEnd()) { QString line = stream.readLine(); - if(line.replace(" ", "").startsWith("Implementation->MaxLines; } @@ -295,36 +379,59 @@ void pqPlayBackEventsDialog::updateUi() this->Implementation->Ui.playPauseButton->setEnabled( !this->Implementation->Filenames.isEmpty()); this->Implementation->Ui.stepButton->setEnabled( - this->Implementation->TestUtility->playingTest() && this->Implementation->Dispatcher.isPaused()); + this->Implementation->TestUtility->playingTest() && + this->Implementation->Dispatcher.isPaused()); this->Implementation->Ui.stopButton->setEnabled( this->Implementation->TestUtility->playingTest()); // Play or pause this->Implementation->Ui.playPauseButton->setChecked( - this->Implementation->TestUtility->playingTest() && !this->Implementation->Dispatcher.isPaused()); + this->Implementation->TestUtility->playingTest() && + !this->Implementation->Dispatcher.isPaused()); - // loadFile button + // loadFile, plus and minus buttons this->Implementation->Ui.loadFileButton->setEnabled( !this->Implementation->TestUtility->playingTest()); + this->Implementation->Ui.plusButton->setEnabled( + !this->Implementation->TestUtility->playingTest()); + this->Implementation->Ui.minusButton->setEnabled( + !this->Implementation->TestUtility->playingTest()); // Time step this->Implementation->Ui.timeStepSpinBox->setEnabled( !this->Implementation->Filenames.isEmpty()); + // Error feedback + this->Implementation->Ui.playerErrorTextLabel->setVisible( + !this->Implementation->Dispatcher.status()); + this->Implementation->Ui.playerErrorIconLabel->setVisible( + !this->Implementation->Dispatcher.status()); + this->Implementation->Ui.infoErrorTextLabel->setVisible( + !this->Implementation->Dispatcher.status()); + this->Implementation->Ui.infoErrorIconLabel->setVisible( + !this->Implementation->Dispatcher.status()); + QString command = tr("Command : "); QString argument = tr("Argument(s) : "); QString object = tr("Object : "); if(this->Implementation->TestUtility->playingTest() && !this->Implementation->CurrentEvent.isEmpty()) { - command += this->Implementation->CurrentEvent[1]; - argument += this->Implementation->CurrentEvent[2].right(25); - object += this->Implementation->CurrentEvent[0].right(20); + command += this->Implementation->setMaxLenght( + this->Implementation->CurrentEvent[1], 40); + argument += this->Implementation->setMaxLenght( + this->Implementation->CurrentEvent[2], 40); + object += this->Implementation->setMaxLenght( + this->Implementation->CurrentEvent[0], 40); this->Implementation->setProgressBarValue(this->Implementation->CurrentFile, - static_cast((static_cast(this->Implementation->CurrentLine)/static_cast(this->Implementation->MaxLines-1))*100)); + static_cast((static_cast( + this->Implementation->CurrentLine)/static_cast( + this->Implementation->MaxLines-1))*100)); } else { + this->Implementation->Ui.currentFileLabel->setText( + QString("No Test is playing ...")); this->Implementation->setProgressBarsValue(0); } this->Implementation->Ui.commandLabel->setText(command); diff --git a/pqPlayBackEventsDialog.h b/pqPlayBackEventsDialog.h index a032206dc321501083c3fa2936cb3e935e78b575..6f08f98bb2ecda12ff1e503b69af9b30cf82d0f0 100644 --- a/pqPlayBackEventsDialog.h +++ b/pqPlayBackEventsDialog.h @@ -55,17 +55,20 @@ public: private slots: void onEventAboutToBePlayed(const QString&,const QString&,const QString&); - void onLoadFiles(); + void loadFiles(); + void insertFiles(); + void removeFiles(); void onPlayOrPause(bool); void onStarted(const QString&); public slots: - virtual void done(const int&); + virtual void done(int); void updateUi(); private: void loadFiles(const QStringList& filenames); - QStringList fileNamesSelected(); + void addFile(const QString& filename); + QStringList selectedFileNames() const; pqPlayBackEventsDialog(const pqPlayBackEventsDialog&); // Not Implemented pqPlayBackEventsDialog& operator=(const pqPlayBackEventsDialog&); // Not Implemented diff --git a/pqPlayBackEventsDialog.ui b/pqPlayBackEventsDialog.ui index 1eaf9877471380e2a275055ae7951789583e33fd..c61a6560eccee21056e7ac8964cece468641e87f 100644 --- a/pqPlayBackEventsDialog.ui +++ b/pqPlayBackEventsDialog.ui @@ -9,16 +9,22 @@ 0 0 - 360 - 261 + 378 + 376 - + 0 0 + + + 0 + 0 + + 16777215 @@ -31,9 +37,33 @@ false + + false + + + QLayout::SetDefaultConstraint + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + QTabWidget::North @@ -67,13 +97,16 @@ Player + + QLayout::SetMaximumSize + true - + 0 0 @@ -164,23 +197,120 @@ - - - QLayout::SetDefaultConstraint - + - + + + + 18 + 18 + + + + + + + :/Icons/clear.svg + + + true + + + + + + + + + + + + 170 + 0 + 0 + + + + + + + + + 170 + 0 + 0 + + + + + + + + + 106 + 104 + 100 + + + + + + + + + 75 + true + + + + Error occured + + + + + Qt::Horizontal - 40 + 200 20 + + + + + + + + :/Icons/minus.png:/Icons/minus.png + + + + + + + + + + + :/Icons/plus.png:/Icons/plus.png + + + + 24 + 24 + + + + false + + + @@ -190,7 +320,7 @@ - Load Scripts + Open Scripts @@ -207,12 +337,143 @@ Info + + QLayout::SetMaximumSize + - - - No file is playing + + + QLayout::SetDefaultConstraint - + + + + + 0 + 0 + + + + No file is playing + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 18 + 18 + + + + + + + :/Icons/clear.svg + + + true + + + + + + + + + + + + 170 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 170 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 106 + 104 + 100 + + + + + + + 190 + 190 + 190 + + + + + + + + + 75 + true + + + + Error occured + + + + @@ -220,7 +481,7 @@ true - + 0 0 @@ -238,6 +499,9 @@ false + + QLayout::SetNoConstraint + @@ -280,51 +544,35 @@ + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Qt::Horizontal + + + QLayout::SetFixedSize - - - - Time step : - - - - - - - false - - - ms - - - 0 - - - 1000 - - - 10 - - - 0 - - - - - - - Qt::Vertical - - - @@ -398,12 +646,94 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Time step : + + + + + + + false + + + + 0 + 0 + + + + ms + + + 0 + + + 1000 + + + 10 + + + 100 + + + + + + + Logs + + + + + + + + 0 + 0 + + + + - + + + radioButton + clicked(bool) + logBrowser + setVisible(bool) + + + 51 + 238 + + + 130 + 269 + + + +