Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
00be6870
Commit
00be6870
authored
Mar 19, 2009
by
hjk
Browse files
allow in-line editing of watcher expressions
parent
6cb5ea76
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/debuggeractions.cpp
View file @
00be6870
...
...
@@ -264,6 +264,11 @@ void QtcSettingsItem::actionTriggered(bool on)
}
}
void
QtcSettingsItem
::
trigger
(
const
QVariant
&
data
)
const
{
m_action
->
setData
(
data
);
m_action
->
trigger
();
}
//////////////////////////////////////////////////////////////////////////
//
...
...
@@ -376,6 +381,9 @@ QtcSettingsPool *theDebuggerSettings()
instance
->
insertItem
(
WatchExpressionInWindow
,
item
);
item
->
setTextPattern
(
QObject
::
tr
(
"Watch expression
\"
%1
\"
in separate window"
));
item
=
new
QtcSettingsItem
(
instance
);
instance
->
insertItem
(
AssignValue
,
item
);
//
// Dumpers
//
...
...
src/plugins/debugger/debuggeractions.h
View file @
00be6870
...
...
@@ -61,6 +61,7 @@ public:
virtual
QAction
*
action
();
virtual
QAction
*
updatedAction
(
const
QString
&
newText
);
Q_SLOT
virtual
void
trigger
(
const
QVariant
&
data
)
const
;
// used for persistency
virtual
QString
settingsKey
()
const
;
...
...
@@ -154,6 +155,7 @@ enum DebuggerSettingsCode
UseDumpers
,
DebugDumpers
,
UseToolTips
,
AssignValue
,
// Source List
ListSourceFiles
,
...
...
src/plugins/debugger/debuggermanager.cpp
View file @
00be6870
...
...
@@ -255,14 +255,10 @@ void DebuggerManager::init()
this
,
SLOT
(
expandChildren
(
QModelIndex
)));
connect
(
localsView
,
SIGNAL
(
requestCollapseChildren
(
QModelIndex
)),
this
,
SLOT
(
collapseChildren
(
QModelIndex
)));
connect
(
localsView
,
SIGNAL
(
requestAssignValue
(
QString
,
QString
)),
this
,
SLOT
(
assignValueInDebugger
(
QString
,
QString
)));
// Watchers
QTreeView
*
watchersView
=
qobject_cast
<
QTreeView
*>
(
m_watchersWindow
);
watchersView
->
setModel
(
m_watchHandler
->
model
());
connect
(
watchersView
,
SIGNAL
(
requestAssignValue
(
QString
,
QString
)),
this
,
SLOT
(
assignValueInDebugger
(
QString
,
QString
)));
connect
(
watchersView
,
SIGNAL
(
requestExpandChildren
(
QModelIndex
)),
this
,
SLOT
(
expandChildren
(
QModelIndex
)));
connect
(
watchersView
,
SIGNAL
(
requestCollapseChildren
(
QModelIndex
)),
...
...
@@ -271,6 +267,8 @@ void DebuggerManager::init()
this
,
SIGNAL
(
sessionValueRequested
(
QString
,
QVariant
*
)));
connect
(
m_watchHandler
,
SIGNAL
(
setSessionValueRequested
(
QString
,
QVariant
)),
this
,
SIGNAL
(
setSessionValueRequested
(
QString
,
QVariant
)));
connect
(
theDebuggerSetting
(
AssignValue
)
->
action
(),
SIGNAL
(
triggered
()),
this
,
SLOT
(
assignValueInDebugger
()));
// Tooltip
QTreeView
*
tooltipView
=
qobject_cast
<
QTreeView
*>
(
m_tooltipWindow
);
...
...
@@ -965,6 +963,12 @@ void DebuggerManager::exitDebugger()
emit
debuggingFinished
();
}
void
DebuggerManager
::
assignValueInDebugger
()
{
if
(
QAction
*
action
=
qobject_cast
<
QAction
*>
(
sender
()))
{
qDebug
()
<<
"HANDLING "
<<
action
->
data
().
toString
();
}
}
void
DebuggerManager
::
assignValueInDebugger
(
const
QString
&
expr
,
const
QString
&
value
)
{
QTC_ASSERT
(
m_engine
,
return
);
...
...
src/plugins/debugger/debuggermanager.h
View file @
00be6870
...
...
@@ -237,6 +237,7 @@ public slots:
void
sessionLoaded
();
void
aboutToSaveSession
();
void
assignValueInDebugger
();
void
assignValueInDebugger
(
const
QString
&
expr
,
const
QString
&
value
);
void
executeDebuggerCommand
(
const
QString
&
command
);
...
...
src/plugins/debugger/watchhandler.cpp
View file @
00be6870
...
...
@@ -375,23 +375,6 @@ WatchHandler::WatchHandler()
SIGNAL
(
triggered
()),
this
,
SLOT
(
removeWatchExpression
()));
}
bool
WatchHandler
::
setData
(
const
QModelIndex
&
idx
,
const
QVariant
&
value
,
int
role
)
{
/*
Q_UNUSED(idx);
Q_UNUSED(value);
Q_UNUSED(role);
if (role == VisualRole) {
QString iname = inameFromIndex(index);
setDisplayedIName(iname, value.toBool());
return true;
}
return true;
*/
return
QAbstractItemModel
::
setData
(
idx
,
value
,
role
);
}
static
QString
niceType
(
QString
type
)
{
if
(
type
.
contains
(
"std::"
))
{
...
...
@@ -457,6 +440,9 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
const
WatchData
&
data
=
m_displaySet
.
at
(
node
);
switch
(
role
)
{
case
Qt
::
EditRole
:
return
data
.
exp
;
case
Qt
::
DisplayRole
:
{
switch
(
idx
.
column
())
{
case
0
:
return
data
.
name
;
...
...
@@ -543,7 +529,7 @@ Qt::ItemFlags WatchHandler::flags(const QModelIndex &idx) const
// enabled, editable, selectable, checkable, and can be used both as the
// source of a drag and drop operation and as a drop target.
static
const
ItemFlags
DefaultN
otEditable
=
static
const
ItemFlags
n
otEditable
=
ItemIsSelectable
|
ItemIsDragEnabled
|
ItemIsDropEnabled
...
...
@@ -551,12 +537,15 @@ Qt::ItemFlags WatchHandler::flags(const QModelIndex &idx) const
// | ItemIsTristate
|
ItemIsEnabled
;
static
const
ItemFlags
DefaultEditable
=
DefaultNotEditable
|
ItemIsEditable
;
static
const
ItemFlags
editable
=
notEditable
|
ItemIsEditable
;
const
WatchData
&
data
=
m_displaySet
.
at
(
node
);
return
idx
.
column
()
==
1
&&
data
.
isWatcher
()
?
DefaultEditable
:
DefaultNotEditable
;
if
(
data
.
isWatcher
()
&&
idx
.
column
()
==
0
)
return
editable
;
// watcher names are
if
(
idx
.
column
()
==
1
)
return
editable
;
// values are editable
return
notEditable
;
}
QVariant
WatchHandler
::
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
...
...
src/plugins/debugger/watchhandler.h
View file @
00be6870
...
...
@@ -146,7 +146,6 @@ public:
//
// QAbstractItemModel
//
bool
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
);
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QModelIndex
index
(
int
,
int
,
const
QModelIndex
&
idx
)
const
;
QModelIndex
parent
(
const
QModelIndex
&
idx
)
const
;
...
...
src/plugins/debugger/watchwindow.cpp
View file @
00be6870
...
...
@@ -31,12 +31,15 @@
#include
"debuggeractions.h"
#include
<utils/qtcassert.h>
#include
<QtCore/QDebug>
#include
<QtCore/QTimer>
#include
<QtGui/QAction>
#include
<QtGui/QContextMenuEvent>
#include
<QtGui/QHeaderView>
#include
<QtGui/QItemDelegate>
#include
<QtGui/QLineEdit>
#include
<QtGui/QMenu>
#include
<QtGui/QResizeEvent>
...
...
@@ -44,8 +47,58 @@
using
namespace
Debugger
::
Internal
;
/////////////////////////////////////////////////////////////////////
//
// WatchDelegate
//
/////////////////////////////////////////////////////////////////////
enum
{
INameRole
=
Qt
::
UserRole
,
VisualRole
,
ExpandedRole
};
class
WatchDelegate
:
public
QItemDelegate
{
public:
WatchDelegate
(
QObject
*
parent
)
:
QItemDelegate
(
parent
)
{}
QWidget
*
createEditor
(
QWidget
*
parent
,
const
QStyleOptionViewItem
&
,
const
QModelIndex
&
)
const
{
return
new
QLineEdit
(
parent
);
}
void
setEditorData
(
QWidget
*
editor
,
const
QModelIndex
&
index
)
const
{
QLineEdit
*
lineEdit
=
qobject_cast
<
QLineEdit
*>
(
editor
);
QTC_ASSERT
(
lineEdit
,
return
);
lineEdit
->
setText
(
index
.
model
()
->
data
(
index
,
Qt
::
EditRole
).
toString
());
}
void
setModelData
(
QWidget
*
editor
,
QAbstractItemModel
*
,
const
QModelIndex
&
index
)
const
{
QLineEdit
*
lineEdit
=
qobject_cast
<
QLineEdit
*>
(
editor
);
QTC_ASSERT
(
lineEdit
,
return
);
QString
value
=
lineEdit
->
text
();
QString
exp
=
index
.
model
()
->
data
(
index
,
Qt
::
EditRole
).
toString
();
if
(
index
.
column
()
==
1
)
{
// the value column
theDebuggerSetting
(
AssignValue
)
->
trigger
(
exp
+
'='
+
value
);
}
else
if
(
index
.
column
()
==
0
)
{
// the watcher name column
theDebuggerSetting
(
RemoveWatchExpression
)
->
trigger
(
exp
);
theDebuggerSetting
(
WatchExpression
)
->
trigger
(
lineEdit
->
text
());
}
}
void
updateEditorGeometry
(
QWidget
*
editor
,
const
QStyleOptionViewItem
&
option
,
const
QModelIndex
&
)
const
{
editor
->
setGeometry
(
option
.
rect
);
}
};
/////////////////////////////////////////////////////////////////////
//
// WatchWindow
...
...
@@ -53,16 +106,14 @@ enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole };
/////////////////////////////////////////////////////////////////////
WatchWindow
::
WatchWindow
(
Type
type
,
QWidget
*
parent
)
:
QTreeView
(
parent
)
,
m_alwaysResizeColumnsToContents
(
true
),
m_type
(
type
)
:
QTreeView
(
parent
),
m_alwaysResizeColumnsToContents
(
true
),
m_type
(
type
)
{
setWindowTitle
(
tr
(
"Locals and Watchers"
));
setAlternatingRowColors
(
true
);
setIndentation
(
indentation
()
*
9
/
10
);
setUniformRowHeights
(
true
);
setItemDelegate
(
new
WatchDelegate
(
this
));
connect
(
itemDelegate
(),
SIGNAL
(
commitData
(
QWidget
*
)),
this
,
SLOT
(
handleChangedItem
(
QWidget
*
)));
connect
(
this
,
SIGNAL
(
expanded
(
QModelIndex
)),
this
,
SLOT
(
expandNode
(
QModelIndex
)));
connect
(
this
,
SIGNAL
(
collapsed
(
QModelIndex
)),
...
...
@@ -104,6 +155,7 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction
*
act2
=
new
QAction
(
"Always adjust column widths to contents"
,
&
menu
);
act2
->
setCheckable
(
true
);
act2
->
setChecked
(
m_alwaysResizeColumnsToContents
);
//QAction *act3 = 0;
QAction
*
act4
=
0
;
menu
.
addAction
(
act1
);
...
...
@@ -124,7 +176,10 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
//act4 = theDebuggerSetting(WatchExpressionInWindow)->action();
//act4->setCheckable(true);
//act4->setChecked(visual);
// FIXME: menu.addAction(act4);
//menu.addAction(act4);
//act3 = new QAction(tr("Add to watch window..."), &menu);
//menu.addAction(act3);
menu
.
addSeparator
();
menu
.
addAction
(
theDebuggerSetting
(
RecheckDumpers
)
->
action
());
...
...
@@ -140,6 +195,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
setAlwaysResizeColumnsToContents
(
!
m_alwaysResizeColumnsToContents
);
else
if
(
act
==
act4
)
model
()
->
setData
(
mi0
,
!
visual
,
VisualRole
);
else
if
(
act
==
act4
)
model
()
->
setData
(
mi0
,
!
visual
,
VisualRole
);
}
void
WatchWindow
::
resizeColumnsToContents
()
...
...
@@ -200,10 +257,3 @@ void WatchWindow::resetHelper(const QModelIndex &idx)
}
}
void
WatchWindow
::
handleChangedItem
(
QWidget
*
widget
)
{
QLineEdit
*
lineEdit
=
qobject_cast
<
QLineEdit
*>
(
widget
);
if
(
lineEdit
)
requestAssignValue
(
"foo"
,
lineEdit
->
text
());
}
src/plugins/debugger/watchwindow.h
View file @
00be6870
...
...
@@ -58,12 +58,10 @@ public slots:
void
setModel
(
QAbstractItemModel
*
model
);
signals:
void
requestAssignValue
(
const
QString
&
exp
,
const
QString
&
value
);
void
requestExpandChildren
(
const
QModelIndex
&
idx
);
void
requestCollapseChildren
(
const
QModelIndex
&
idx
);
private
slots
:
void
handleChangedItem
(
QWidget
*
);
void
expandNode
(
const
QModelIndex
&
index
);
void
collapseNode
(
const
QModelIndex
&
index
);
...
...
tests/manual/gdbdebugger/simple/app.cpp
View file @
00be6870
...
...
@@ -702,6 +702,7 @@ void testStdVector()
void
testQString
()
{
int
i
=
0
;
QString
str
=
"Hello "
;
str
+=
" big, "
;
str
+=
" fat "
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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