Commit d01fff5a authored by Mathieu Westphal's avatar Mathieu Westphal

Adding support for QPlainTextEdit

parent ddf024ca
......@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QtDebug>
#include <QTextDocument>
#include <QTextEdit>
#include <QPlainTextEdit>
#include "pqObjectNaming.h"
......@@ -88,6 +89,14 @@ bool pqAbstractStringEventPlayer::playEvent(QObject* Object, const QString& Comm
return true;
}
if (QPlainTextEdit* const object = qobject_cast<QPlainTextEdit*>(Object))
{
object->setFocus(Qt::OtherFocusReason);
object->document()->setPlainText(value);
object->clearFocus();
return true;
}
qCritical() << "calling set_string on unhandled type " << Object;
Error = true;
......
......@@ -124,7 +124,7 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* object,
}
// Check property value
if (propertyValue.toString() != arguments)
if (propertyValue.toString().replace("\t", " ") != arguments)
{
QString errorMessage = object->objectName() + " property value is: " + propertyValue.toString()
+ ". Expecting: "+ arguments + ".";
......
......@@ -169,7 +169,7 @@ bool pqBasicWidgetEventTranslator::translateEvent(QObject* object,
QString propName = metaProp.name();
// Record check event
emit recordEvent(pqEventTypes::CHECK_EVENT, widget, propName, widget->property(propName.toAscii().data()).toString());
emit recordEvent(pqEventTypes::CHECK_EVENT, widget, propName, widget->property(propName.toAscii().data()).toString().replace("\t", " "));
return true;
}
}
......
......@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QSpinBox>
#include <QTextDocument>
#include <QTextEdit>
#include <QPlainTextEdit>
#include <QKeyEvent>
#include "pqEventTypes.h"
......@@ -52,14 +53,16 @@ bool pqLineEditEventTranslator::translateEvent(QObject* object, QEvent* event, i
QObject* tmpObject = object;
QLineEdit* leObject = qobject_cast<QLineEdit*>(object);
QTextEdit* teObject = qobject_cast<QTextEdit*>(object);
if(!leObject && !teObject && object->parent() != NULL)
QPlainTextEdit* pteObject = qobject_cast<QPlainTextEdit*>(object);
if(!leObject && !teObject && !pteObject && object->parent() != NULL)
{
// MouseEvent can be received by viewport
tmpObject = object->parent();
leObject = qobject_cast<QLineEdit*>(tmpObject);
teObject = qobject_cast<QTextEdit*>(tmpObject);
pteObject = qobject_cast<QPlainTextEdit*>(tmpObject);
}
if(!leObject && !teObject)
if(!leObject && !teObject && !pteObject)
{
return false;
}
......@@ -89,6 +92,11 @@ bool pqLineEditEventTranslator::translateEvent(QObject* object, QEvent* event, i
{
emit recordEvent(tmpObject, "set_string", teObject->document()->toPlainText());
}
else if (pteObject)
{
emit recordEvent(tmpObject, "set_string", pteObject->document()->toPlainText());
}
}
// if we record F2 event, will cause some issue with the TreeView
// Need test to know if we need to record those events
......@@ -106,7 +114,7 @@ bool pqLineEditEventTranslator::translateEvent(QObject* object, QEvent* event, i
else if (eventType == pqEventTypes::CHECK_EVENT)
{
// TextEdit only, LineEdit does not need specific check
if (teObject != NULL)
if (teObject != NULL || pteObject != NULL)
{
if (event->type() == QEvent::MouseMove)
{
......@@ -115,8 +123,16 @@ bool pqLineEditEventTranslator::translateEvent(QObject* object, QEvent* event, i
// Clicking while checking, actual check event
if (event->type() == QEvent::MouseButtonRelease)
{
emit this->recordEvent(pqEventTypes::CHECK_EVENT, teObject,
"html", teObject->toHtml());
if(teObject != NULL)
{
emit this->recordEvent(pqEventTypes::CHECK_EVENT, teObject,
"plainText", teObject->toPlainText().replace("\t", " "));
}
else /* if (pteObject != NULL)*/
{
emit this->recordEvent(pqEventTypes::CHECK_EVENT, pteObject,
"plainText", pteObject->toPlainText().replace("\t", " "));
}
return true;
}
}
......
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