forked from qt-creator/qt-creator
simplify WatchWindow expansion handling a bit
This commit is contained in:
@@ -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()
|
||||
void WatchWindow::resetHelper(const QModelIndex &idx)
|
||||
{
|
||||
//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::modelResetHelper(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);
|
||||
modelResetHelper(idx1);
|
||||
resetHelper(idx1);
|
||||
}
|
||||
} else {
|
||||
// if (!iname.isEmpty())
|
||||
// collapse(idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user