Commit 8f6cfd29 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

ENH: Added support to record/playback events from a QTextEdit widget.

parent 4e9c06d0
......@@ -35,6 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QComboBox>
#include <QLineEdit>
#include <QtDebug>
#include <QTextDocument>
#include <QTextEdit>
pqAbstractStringEventPlayer::pqAbstractStringEventPlayer(QObject* p)
: pqWidgetEventPlayer(p)
......@@ -75,6 +77,12 @@ bool pqAbstractStringEventPlayer::playEvent(QObject* Object, const QString& Comm
return true;
}
if (QTextEdit* const object = qobject_cast<QTextEdit*>(Object))
{
object->document()->setPlainText(value);
return true;
}
qCritical() << "calling set_string on unhandled type " << Object;
Error = true;
......
......@@ -35,6 +35,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QEvent>
#include <QLineEdit>
#include <QSpinBox>
#include <QTextDocument>
#include <QTextEdit>
pqLineEditEventTranslator::pqLineEditEventTranslator(QObject* p)
: pqWidgetEventTranslator(p)
......@@ -44,18 +46,30 @@ pqLineEditEventTranslator::pqLineEditEventTranslator(QObject* p)
bool pqLineEditEventTranslator::translateEvent(QObject* Object, QEvent* Event, bool& /*Error*/)
{
QLineEdit* const object = qobject_cast<QLineEdit*>(Object);
if(!object)
QTextEdit* const teObject = qobject_cast<QTextEdit*>(Object);
if(!object && !teObject)
{
return false;
}
// If this line edit is part of a spinbox, don't translate events (the spinbox translator will receive the final value directly)
if(qobject_cast<QSpinBox*>(Object->parent()))
{
return false;
}
switch(Event->type())
{
case QEvent::KeyRelease:
{
emit recordEvent(Object, "set_string", object->text());
if (object)
{
emit recordEvent(Object, "set_string", object->text());
}
else if (teObject)
{
emit recordEvent(Object, "set_string", teObject->document()->toPlainText());
}
}
break;
default:
......
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