Commit 4d42969a authored by Benjamin Long's avatar Benjamin Long

Few modifications for a easier integration with paraview

parent d3f17f78
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
~XMLEventSource() { delete this->XMLStream; } ~XMLEventSource() { delete this->XMLStream; }
protected: protected:
virtual bool setContent(const QString& xmlfilename) virtual void setContent(const QString& xmlfilename)
{ {
delete this->XMLStream; delete this->XMLStream;
this->XMLStream = NULL; this->XMLStream = NULL;
...@@ -91,7 +91,7 @@ protected: ...@@ -91,7 +91,7 @@ protected:
if (!xml.open(QIODevice::ReadOnly)) if (!xml.open(QIODevice::ReadOnly))
{ {
qDebug() << "Failed to load " << xmlfilename; qDebug() << "Failed to load " << xmlfilename;
return false; return;
} }
QByteArray data = xml.readAll(); QByteArray data = xml.readAll();
this->XMLStream = new QXmlStreamReader(data); this->XMLStream = new QXmlStreamReader(data);
...@@ -114,7 +114,7 @@ protected: ...@@ -114,7 +114,7 @@ protected:
{ {
qDebug() << "Invalid xml" << endl; qDebug() << "Invalid xml" << endl;
} }
return true; return;
} }
int getNextEvent(QString& widget, QString& command, QString& int getNextEvent(QString& widget, QString& command, QString&
......
...@@ -49,10 +49,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -49,10 +49,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream> #include <iostream>
using namespace std; using namespace std;
//-----------------------------------------------------------------------------
namespace namespace
{ {
static QList<QPointer<QTimer> > RegisteredTimers; static QList<QPointer<QTimer> > RegisteredTimers;
void processTimers() void processTimers()
{ {
foreach (QTimer* timer, RegisteredTimers) foreach (QTimer* timer, RegisteredTimers)
...@@ -83,7 +84,6 @@ pqEventDispatcher::pqEventDispatcher(QObject* parentObject) : ...@@ -83,7 +84,6 @@ pqEventDispatcher::pqEventDispatcher(QObject* parentObject) :
this->PlayBackPaused = false; this->PlayBackPaused = false;
this->PlayBackOneStep = false; this->PlayBackOneStep = false;
this->PlayBackStoped = false; this->PlayBackStoped = false;
this->TimeStep = 1;
#ifdef __APPLE__ #ifdef __APPLE__
this->BlockTimer.setInterval(1000); this->BlockTimer.setInterval(1000);
...@@ -149,7 +149,7 @@ void pqEventDispatcher::awake() ...@@ -149,7 +149,7 @@ void pqEventDispatcher::awake()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void pqEventDispatcher::setTimeStep(int value) void pqEventDispatcher::setTimeStep(int value)
{ {
this->TimeStep = value; EventPlaybackDelay = value;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -140,7 +140,6 @@ protected: ...@@ -140,7 +140,6 @@ protected:
bool PlayBackOneStep; bool PlayBackOneStep;
bool PlayBackStoped; bool PlayBackStoped;
static bool DeferMenuTimeouts; static bool DeferMenuTimeouts;
int TimeStep;
pqEventSource* ActiveSource; pqEventSource* ActiveSource;
pqEventPlayer* ActivePlayer; pqEventPlayer* ActivePlayer;
......
...@@ -135,8 +135,7 @@ void pqEventPlayer::playEvent(const QString& Object, ...@@ -135,8 +135,7 @@ void pqEventPlayer::playEvent(const QString& Object,
{ {
emit this->eventAboutToBePlayed(Object, Command, Arguments); emit this->eventAboutToBePlayed(Object, Command, Arguments);
// If we can't find an object with the right name, we're done ... // If we can't find an object with the right name, we're done ...
QString messageError; QObject* const object = pqObjectNaming::GetObject(Object);
QObject* const object = pqObjectNaming::GetObject(Object, messageError);
if(!object && Object.contains(QString("QScrollBar"))) if(!object && Object.contains(QString("QScrollBar")))
{ {
...@@ -147,7 +146,8 @@ void pqEventPlayer::playEvent(const QString& Object, ...@@ -147,7 +146,8 @@ void pqEventPlayer::playEvent(const QString& Object,
if(!object && Command != "comment") if(!object && Command != "comment")
{ {
emit this->errorMessage(messageError); qCritical() << pqObjectNaming::lastErrorMessage();
emit this->errorMessage(pqObjectNaming::lastErrorMessage());
Error = true; Error = true;
return; return;
} }
...@@ -167,7 +167,9 @@ void pqEventPlayer::playEvent(const QString& Object, ...@@ -167,7 +167,9 @@ void pqEventPlayer::playEvent(const QString& Object,
// The event wasn't handled at all ... // The event wasn't handled at all ...
if(!accepted) if(!accepted)
{ {
messageError = QString("Unhandled event %1 object %2\n").arg(Command, object->objectName()); QString messageError =
QString("Unhandled event %1 object %2\n")
.arg(Command, object->objectName());
qCritical() << messageError; qCritical() << messageError;
emit this->errorMessage(messageError); emit this->errorMessage(messageError);
Error = true; Error = true;
...@@ -177,7 +179,9 @@ void pqEventPlayer::playEvent(const QString& Object, ...@@ -177,7 +179,9 @@ void pqEventPlayer::playEvent(const QString& Object,
// The event was handled, but there was a problem ... // The event was handled, but there was a problem ...
if(accepted && error) if(accepted && error)
{ {
messageError = QString("Event error %1 object %2\n").arg(Command, object->objectName()); QString messageError =
QString("Event error %1 object %2\n")
.arg(Command, object->objectName());
qCritical() << messageError; qCritical() << messageError;
emit this->errorMessage(messageError); emit this->errorMessage(messageError);
Error = true; Error = true;
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
/** Set the filename for contents. /** Set the filename for contents.
Returns true for valid file, false for invalid file */ Returns true for valid file, false for invalid file */
virtual bool setContent(const QString& filename) = 0; virtual void setContent(const QString& filename) = 0;
/** tell the source to stop feeding in events */ /** tell the source to stop feeding in events */
virtual void stop() {} virtual void stop() {}
......
...@@ -55,8 +55,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -55,8 +55,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QToolButton> #include <QToolButton>
#include <QtDebug> #include <QtDebug>
/** Returns the name of an object as if it was unnamed.
*/ namespace
{
QString ErrorMessage;
}
/** Returns the name of an object as if it was unnamed.*/
static const QString InternalGetNameAsUnnamed(QObject& Object) static const QString InternalGetNameAsUnnamed(QObject& Object)
{ {
QString result; QString result;
...@@ -178,7 +183,7 @@ const QString pqObjectNaming::GetName(QObject& Object) ...@@ -178,7 +183,7 @@ const QString pqObjectNaming::GetName(QObject& Object)
return name; return name;
} }
QObject* pqObjectNaming::GetObject(const QString& Name, QString& messageError) QObject* pqObjectNaming::GetObject(const QString& Name)
{ {
QObject* result = 0; QObject* result = 0;
QObject* lastObject = 0; QObject* lastObject = 0;
...@@ -241,10 +246,10 @@ QObject* pqObjectNaming::GetObject(const QString& Name, QString& messageError) ...@@ -241,10 +246,10 @@ QObject* pqObjectNaming::GetObject(const QString& Name, QString& messageError)
if(result) if(result)
return result; return result;
messageError = QString("Couldn't find object %1\n").arg(Name);
if(lastObject) if(lastObject)
ErrorMessage = QString("Couldn't find object %1\n").arg(Name);
{ {
messageError += QString("Found up to %1\n").arg( ErrorMessage += QString("Found up to %1\n").arg(
pqObjectNaming::GetName(*lastObject)); pqObjectNaming::GetName(*lastObject));
} }
if(lastObject) if(lastObject)
...@@ -253,10 +258,11 @@ QObject* pqObjectNaming::GetObject(const QString& Name, QString& messageError) ...@@ -253,10 +258,11 @@ QObject* pqObjectNaming::GetObject(const QString& Name, QString& messageError)
lastObject->findChildren<QObject*>(names[names.size()-1]); lastObject->findChildren<QObject*>(names[names.size()-1]);
foreach(QObject* o, matches) foreach(QObject* o, matches)
{ {
messageError += QString("\tPossible match: %1\n").arg(pqObjectNaming::GetName(*o)); ErrorMessage += QString("\tPossible match: %1\n").arg(pqObjectNaming::GetName(*o));
} }
} }
qCritical() << messageError;
qCritical() << ErrorMessage ;
return 0; return 0;
} }
...@@ -279,3 +285,9 @@ void pqObjectNaming::DumpHierarchy(QObject& object, QStringList& results) ...@@ -279,3 +285,9 @@ void pqObjectNaming::DumpHierarchy(QObject& object, QStringList& results)
DumpHierarchy(*children[i], results); DumpHierarchy(*children[i], results);
} }
} }
QString pqObjectNaming::lastErrorMessage()
{
return ErrorMessage;
}
...@@ -33,10 +33,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -33,10 +33,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _pqObjectNaming_h #ifndef _pqObjectNaming_h
#define _pqObjectNaming_h #define _pqObjectNaming_h
#include <QString>
#include "QtTestingExport.h" #include "QtTestingExport.h"
class QObject; class QObject;
class QString;
class QStringList; class QStringList;
/// Provides functionality to ensuring that Qt objects can be uniquely identified for recording and playback of regression tests /// Provides functionality to ensuring that Qt objects can be uniquely identified for recording and playback of regression tests
...@@ -46,12 +47,15 @@ public: ...@@ -46,12 +47,15 @@ public:
/// Returns a unique identifier for the given object that can be serialized for later regression test playback /// Returns a unique identifier for the given object that can be serialized for later regression test playback
static const QString GetName(QObject& Object); static const QString GetName(QObject& Object);
/// Given a unique identifier returned by GetName(), returns the corresponding object, or NULL /// Given a unique identifier returned by GetName(), returns the corresponding object, or NULL
static QObject* GetObject(const QString& Name, QString& Message); static QObject* GetObject(const QString& Name);
/** Dumps the widget hierarchy to a string */ /** Dumps the widget hierarchy to a string */
static void DumpHierarchy(QStringList& results); static void DumpHierarchy(QStringList& results);
/** Dumps a subtree of the widget hierarchy to a string */ /** Dumps a subtree of the widget hierarchy to a string */
static void DumpHierarchy(QObject& Object, QStringList& results); static void DumpHierarchy(QObject& Object, QStringList& results);
/// Recover the last error message
static QString lastErrorMessage();
}; };
#endif // !_pqObjectNaming_h #endif // !_pqObjectNaming_h
...@@ -140,11 +140,11 @@ void pqTestUtility::stopTests() ...@@ -140,11 +140,11 @@ void pqTestUtility::stopTests()
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void pqTestUtility::playTests(const QString& filename) bool pqTestUtility::playTests(const QString& filename)
{ {
QStringList files; QStringList files;
files << filename; files << filename;
this->playTests(files); return this->playTests(files);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -174,10 +174,8 @@ bool pqTestUtility::playTests(const QStringList& filenames) ...@@ -174,10 +174,8 @@ bool pqTestUtility::playTests(const QStringList& filenames)
iter = this->EventSources.find(suffix); iter = this->EventSources.find(suffix);
if(info.isReadable() && iter != this->EventSources.end()) if(info.isReadable() && iter != this->EventSources.end())
{ {
if(!iter.value()->setContent(filename)) iter.value()->setContent(filename);
{
return false;
}
// QEventLoop loop; // QEventLoop loop;
// QTimer::singleShot(100, &loop, SLOT(quit())); // QTimer::singleShot(100, &loop, SLOT(quit()));
// loop.exec(); // loop.exec();
......
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
QString convertFromDataDirectory(const QString& file); QString convertFromDataDirectory(const QString& file);
public slots: public slots:
void playTests(const QString& filename); bool playTests(const QString& filename);
void openPlayerDialog(); void openPlayerDialog();
void stopTests(); void stopTests();
......
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