Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Ben Boeckel
QtTesting
Commits
d3f17f78
Commit
d3f17f78
authored
Apr 16, 2012
by
Benjamin Long
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bad record when the treeview wasn't on editing behavior
parent
e75fc146
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
38 deletions
+52
-38
pqTestUtility.h
pqTestUtility.h
+5
-8
pqTreeViewEventTranslator.cxx
pqTreeViewEventTranslator.cxx
+42
-27
pqTreeViewEventTranslator.h
pqTreeViewEventTranslator.h
+5
-3
No files found.
pqTestUtility.h
View file @
d3f17f78
...
@@ -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
;
...
...
pqTreeViewEventTranslator.cxx
View file @
d3f17f78
...
@@ -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
);
}
}
}
}
...
...
pqTreeViewEventTranslator.h
View file @
d3f17f78
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment