Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
045e6dd1
Commit
045e6dd1
authored
Dec 08, 2008
by
hjk
Browse files
simplify WatchWindow expansion handling a bit
parent
44cc9a2b
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/watchhandler.cpp
View file @
045e6dd1
...
...
@@ -488,6 +488,13 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
case
VisualRole
:
return
m_displayedINames
.
contains
(
data
.
iname
);
case
ExpandedRole
:
//qDebug() << " FETCHING: " << data.iname
// << m_expandedINames.contains(data.iname)
// << m_expandedINames;
// Level 0 and 1 are always expanded
return
node
<
4
||
m_expandedINames
.
contains
(
data
.
iname
);
default:
break
;
}
...
...
src/plugins/debugger/watchhandler.h
View file @
045e6dd1
...
...
@@ -135,7 +135,7 @@ public:
bool
changed
;
};
enum
{
INameRole
=
Qt
::
UserRole
,
VisualRole
};
enum
{
INameRole
=
Qt
::
UserRole
,
VisualRole
,
ExpandedRole
};
class
WatchHandler
:
public
QAbstractItemModel
...
...
src/plugins/debugger/watchwindow.cpp
View file @
045e6dd1
...
...
@@ -46,7 +46,7 @@
using
namespace
Debugger
::
Internal
;
enum
{
INameRole
=
Qt
::
UserRole
,
VisualRole
};
enum
{
INameRole
=
Qt
::
UserRole
,
VisualRole
,
ExpandedRole
};
/////////////////////////////////////////////////////////////////////
//
...
...
@@ -75,8 +75,6 @@ void WatchWindow::expandNode(const QModelIndex &idx)
//QModelIndex mi0 = idx.sibling(idx.row(), 0);
//QString iname = model()->data(mi0, INameRole).toString();
//QString name = model()->data(mi0, Qt::DisplayRole).toString();
//if (isExpanded(idx))
// return;
emit
requestExpandChildren
(
idx
);
}
...
...
@@ -174,6 +172,7 @@ void WatchWindow::reset()
QTreeView
::
reset
();
setRootIndex
(
model
()
->
index
(
row
,
0
,
model
()
->
index
(
0
,
0
)));
//setRootIndex(model()->index(0, 0));
resetHelper
(
model
()
->
index
(
0
,
0
));
}
void
WatchWindow
::
setModel
(
QAbstractItemModel
*
model
)
...
...
@@ -185,57 +184,16 @@ void WatchWindow::setModel(QAbstractItemModel *model)
header
()
->
setResizeMode
(
QHeaderView
::
ResizeToContents
);
if
(
m_type
!=
LocalsType
)
header
()
->
hide
();
connect
(
model
,
SIGNAL
(
modelAboutToBeReset
()),
this
,
SLOT
(
modelAboutToBeReset
()));
connect
(
model
,
SIGNAL
(
modelReset
()),
this
,
SLOT
(
modelReset
()));
}
void
WatchWindow
::
modelAboutToBeReset
()
{
//qDebug() << "Model about to be reset";
m_expandedItems
.
clear
();
m_expandedItems
.
insert
(
"local"
);
m_expandedItems
.
insert
(
"watch"
);
modelAboutToBeResetHelper
(
model
()
->
index
(
0
,
0
));
//qDebug() << " expanded: " << m_expandedItems;
}
void
WatchWindow
::
modelAboutToBeResetHelper
(
const
QModelIndex
&
idx
)
{
QString
iname
=
model
()
->
data
(
idx
,
INameRole
).
toString
();
//qDebug() << "Model about to be reset helper" << iname << idx
// << isExpanded(idx);
if
(
isExpanded
(
idx
))
m_expandedItems
.
insert
(
iname
);
for
(
int
i
=
0
,
n
=
model
()
->
rowCount
(
idx
);
i
!=
n
;
++
i
)
{
QModelIndex
idx1
=
model
()
->
index
(
i
,
0
,
idx
);
modelAboutToBeResetHelper
(
idx1
);
}
}
void
WatchWindow
::
modelReset
()
{
collapseAll
();
expand
(
model
()
->
index
(
0
,
0
));
modelResetHelper
(
model
()
->
index
(
0
,
0
));
}
void
WatchWindow
::
modelR
esetHelper
(
const
QModelIndex
&
idx
)
void
WatchWindow
::
r
esetHelper
(
const
QModelIndex
&
idx
)
{
QString
name
=
model
()
->
data
(
idx
,
Qt
::
DisplayRole
).
toString
();
QString
iname
=
model
()
->
data
(
idx
,
INameRole
).
toString
();
//qDebug() << "Model reset helper" << iname << name;
if
(
m_expandedItems
.
contains
(
iname
))
{
if
(
model
()
->
data
(
idx
,
ExpandedRole
).
toBool
())
{
expand
(
idx
);
for
(
int
i
=
0
,
n
=
model
()
->
rowCount
(
idx
);
i
!=
n
;
++
i
)
{
QModelIndex
idx1
=
model
()
->
index
(
i
,
0
,
idx
);
modelR
esetHelper
(
idx1
);
r
esetHelper
(
idx1
);
}
}
else
{
// if (!iname.isEmpty())
// collapse(idx);
}
}
...
...
src/plugins/debugger/watchwindow.h
View file @
045e6dd1
...
...
@@ -72,20 +72,16 @@ private slots:
void
handleChangedItem
(
QWidget
*
);
void
expandNode
(
const
QModelIndex
&
index
);
void
collapseNode
(
const
QModelIndex
&
index
);
void
modelAboutToBeReset
();
void
modelReset
();
private:
void
contextMenuEvent
(
QContextMenuEvent
*
ev
);
void
editItem
(
const
QModelIndex
&
idx
);
void
reset
();
/* reimpl */
void
modelAboutToBeResetHelper
(
const
QModelIndex
&
idx
);
void
modelResetHelper
(
const
QModelIndex
&
idx
);
bool
m_alwaysResizeColumnsToContents
;
Type
m_type
;
QSet
<
QString
>
m_expandedItems
;
};
...
...
Write
Preview
Supports
Markdown
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