Commit d3f17f78 authored by Benjamin Long's avatar Benjamin Long

Fix bad record when the treeview wasn't on editing behavior

parent e75fc146
......@@ -89,7 +89,6 @@ public:
/// it does not return until the test has been played or aborted due to
/// failure. Returns true if the test played successfully.
virtual bool playTests(const QStringList& filenames);
/// start the recording of tests to a file
Q_INVOKABLE void recordTests(const QString& filename);
......@@ -99,13 +98,11 @@ public:
QMap<QObject*, QString> objectStateProperty() const;
/// add a directory for recording/playback of file dialogs
void addDataDirectory(const QString& label, const QDir& path);
/// remove a directory for recording/playback of file dialogs
void removeDataDirectory(const QString& label);
/// given filename convert to one of the data directories
QString convertToDataDirectory(const QString& file);
/// give a filename convert from one of the data directories
QString convertFromDataDirectory(const QString& file);
......@@ -121,12 +118,12 @@ signals:
void stopped(const QString& filename, bool error);
protected:
pqEventDispatcher Dispatcher;
pqEventPlayer Player;
pqEventTranslator Translator;
bool PlayingTest;
pqEventDispatcher Dispatcher;
pqEventPlayer Player;
pqEventTranslator Translator;
bool PlayingTest;
QMap<QString, pqEventSource*> EventSources;
QMap<QString, pqEventSource*> EventSources;
QMap<QString, pqEventObserver*> EventObservers;
QMap<QString, QDir> DataDirectories;
......
......@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
pqTreeViewEventTranslator::pqTreeViewEventTranslator(QObject* parentObject)
: Superclass(parentObject)
{
this->Editing = false;
}
//-----------------------------------------------------------------------------
......@@ -68,45 +69,57 @@ bool pqTreeViewEventTranslator::translateEvent(
QKeyEvent* ke = static_cast<QKeyEvent*>(tr_event);
QModelIndex index = treeWidget->currentIndex();
QString str_index = this->getIndexAsString(index);
if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return)
if (this->Editing)
{
QVariant value = treeWidget->model()->data(index);
qDebug() << value << str_index;
emit this->recordEvent(treeWidget, "editAccepted",
QString("%1,%2").arg(str_index, value.toString()));
}
if (ke->key() == Qt::Key_Escape)
{
emit this->recordEvent(treeWidget, "editCancel", str_index);
if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return)
{
QVariant value = treeWidget->model()->data(index);
this->Editing = false;
emit this->recordEvent(treeWidget, "editAccepted",
QString("%1,%2").arg(str_index, value.toString()));
}
if (ke->key() == Qt::Key_Escape)
{
this->Editing = false;
emit this->recordEvent(treeWidget, "editCancel", str_index);
}
}
if (ke->key() == Qt::Key_F2)
{
this->Editing = true;
emit this->recordEvent(treeWidget, "edit", str_index);
}
}
if (tr_event->type() == QEvent::FocusIn)
if (tr_event->type() == QEvent::Enter && treeWidget == object)
{
if(this->TreeView)
qDebug() << "Focus IN";
if (this->TreeView != object)
{
QObject::disconnect(this->TreeView, 0, this, 0);
QObject::disconnect(this->TreeView->selectionModel(), 0, this, 0);
if(this->TreeView)
{
qDebug() << "disconnected";
QObject::disconnect(this->TreeView, 0, this, 0);
QObject::disconnect(this->TreeView->selectionModel(), 0, this, 0);
}
qDebug() << "connect";
QObject::connect(treeWidget, SIGNAL(clicked(const QModelIndex&)),
this, SLOT(onClicked(const QModelIndex&)));
QObject::connect(treeWidget, SIGNAL(activated(const QModelIndex&)),
this, SLOT(onActivated(const QModelIndex&)));
QObject::connect(treeWidget, SIGNAL(doubleClicked(const QModelIndex&)),
this, SLOT(onDoubleClicked(const QModelIndex&)));
QObject::connect(treeWidget, SIGNAL(expanded(const QModelIndex&)),
this, SLOT(onExpanded(const QModelIndex&)));
QObject::connect(treeWidget, SIGNAL(collapsed(const QModelIndex&)),
this, SLOT(onCollapsed(const QModelIndex&)));
QObject::connect(treeWidget->selectionModel(),
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(onCurrentChanged(const QModelIndex&)));
this->TreeView = treeWidget;
}
QObject::connect(treeWidget, SIGNAL(clicked(const QModelIndex&)),
this, SLOT(onClicked(const QModelIndex&)));
QObject::connect(treeWidget, SIGNAL(activated(const QModelIndex&)),
this, SLOT(onActivated(const QModelIndex&)));
QObject::connect(treeWidget, SIGNAL(doubleClicked(const QModelIndex&)),
this, SLOT(onDoubleClicked(const QModelIndex&)));
QObject::connect(treeWidget, SIGNAL(expanded(const QModelIndex&)),
this, SLOT(onExpanded(const QModelIndex&)));
QObject::connect(treeWidget, SIGNAL(collapsed(const QModelIndex&)),
this, SLOT(onCollapsed(const QModelIndex&)));
QObject::connect(treeWidget->selectionModel(),
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(onCurrentChanged(const QModelIndex&)));
this->TreeView = treeWidget;
}
return true;
}
......@@ -128,6 +141,7 @@ void pqTreeViewEventTranslator::onClicked(
== QAbstractItemView::SelectedClicked &&
index == oldIndex)
{
this->Editing = true;
emit this->recordEvent(treeWidget, "edit", str_index);
}
oldIndex = index;
......@@ -150,6 +164,7 @@ void pqTreeViewEventTranslator::onDoubleClicked(const QModelIndex& index)
if ((treeWidget->editTriggers() & QAbstractItemView::DoubleClicked)
== QAbstractItemView::DoubleClicked)
{
this->Editing = true;
emit this->recordEvent(treeWidget, "edit", str_index);
}
}
......
......@@ -60,13 +60,15 @@ private slots:
void onCollapsed(const QModelIndex&);
void onCurrentChanged(const QModelIndex&);
private:
QString getIndexAsString(const QModelIndex&);
protected:
QPointer<QTreeView> TreeView;
bool Editing;
private:
pqTreeViewEventTranslator(const pqTreeViewEventTranslator&); // Not implemented.
void operator=(const pqTreeViewEventTranslator&); // Not implemented.
QString getIndexAsString(const QModelIndex&);
};
#endif
......
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