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