diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 1792e4705d62cbad99c769d999ca01daab5498f9..1041c2edcc697a246d403879ca0c96575c6c50ad 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -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; } diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 989b99b3d225685aba343f291ef21fca09c4cad9..f27e167dc1b4891f1d3ffe751de00e3b337f3e9c 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -135,7 +135,7 @@ public: bool changed; }; -enum { INameRole = Qt::UserRole, VisualRole }; +enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole }; class WatchHandler : public QAbstractItemModel diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index d528bf09242af9ca1c40557f191790efb319673d..f49b7073aeff5bf32e9e77920ba5b2f807eb92c7 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -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::modelResetHelper(const QModelIndex &idx) +void WatchWindow::resetHelper(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); } } diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index 8b9b5d13ae4c64efb3ab8fc3d5e24b7af17dd8e3..33aafe1d59b50acccd5d94bb1739ebd7ce617811 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -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; };