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