Commit a17ccb76 authored by Julien Finet's avatar Julien Finet

Merge pull request #3 from finetjul/ignore-commands

Ignore events conditionally based on their command name
parents 696fd40c 820dccb7
......@@ -75,7 +75,7 @@ struct pqEventTranslator::pqImplementation
/// Stores the working set of widget translators
QList<pqWidgetEventTranslator*> Translators;
/// Stores the set of objects that should be ignored when translating events
QSet<QObject*> IgnoredObjects;
QMap<QObject*, QRegExp> IgnoredObjects;
// list of widgets for which mouse propagation will happen
// we'll only translate the first and ignore the rest
......@@ -218,9 +218,9 @@ pqEventComment* pqEventTranslator::eventComment() const
}
// ----------------------------------------------------------------------------
void pqEventTranslator::ignoreObject(QObject* Object)
void pqEventTranslator::ignoreObject(QObject* object, QRegExp commandFilter)
{
this->Implementation->IgnoredObjects.insert(Object);
this->Implementation->IgnoredObjects.insert(object, commandFilter);
}
// ----------------------------------------------------------------------------
......@@ -283,7 +283,13 @@ void pqEventTranslator::onRecordEvent(QObject* Object,
const QString& Arguments)
{
if(this->Implementation->IgnoredObjects.contains(Object))
return;
{
QRegExp commandFilter = this->Implementation->IgnoredObjects.value(Object);
if(Command.contains(commandFilter))
{
return;
}
}
QString name;
// When sender is pqEventObject, the Object name can be NULL.
......
......@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "QtTestingExport.h"
#include <QObject>
#include <QRegExp>
class pqEventComment;
class pqTestUtility;
......@@ -83,9 +84,10 @@ public:
pqEventComment* eventComment() const;
/// Adds a Qt object to a list of objects that should be ignored when
/// translating events (useful to prevent recording UI events from being
/// translating events which command is equivalent to the regexp
/// (useful to prevent recording UI events from being
/// captured as part of the recording)
void ignoreObject(QObject* Object);
void ignoreObject(QObject* object, QRegExp commandFilter = QRegExp("*", Qt::CaseInsensitive, QRegExp::Wildcard));
/// start listening to the GUI and translating events
void start();
......
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