diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 77d29803d5c6dc89a2db9b453f7792806974a720..0a281d4fbcf70efdfc42e2f881c2930e133cb60e 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -340,6 +340,9 @@ DebuggerSettings *theDebuggerSettings() DebuggerAction *item = 0; + // + // View + // item = new DebuggerAction(instance); instance->insertItem(AdjustColumnWidths, item); item->setText(QObject::tr("Adjust column widths to contents")); @@ -349,6 +352,9 @@ DebuggerSettings *theDebuggerSettings() item->setText(QObject::tr("Always adjust column widths to contents")); item->setCheckable(true); + // + // Locals & Watchers + // item = new DebuggerAction(instance); instance->insertItem(WatchExpression, item); item->setTextPattern(QObject::tr("Watch expression \"%1\"")); @@ -365,6 +371,14 @@ DebuggerSettings *theDebuggerSettings() item = new DebuggerAction(instance); instance->insertItem(AssignValue, item); + item = new DebuggerAction(instance); + instance->insertItem(ExpandItem, item); + item->setText(QObject::tr("Expand item")); + + item = new DebuggerAction(instance); + instance->insertItem(CollapseItem, item); + item->setText(QObject::tr("Collapse item")); + // // Dumpers // diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index cdb3d99cca8e4f6f17204b5c39bcd6e567b0b396..75029ab9526e1d492432e4ea0aa09914ed1a2893 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -150,6 +150,8 @@ enum DebuggerActionCode WatchModelUpdate, UseToolTips, AssignValue, + ExpandItem, + CollapseItem, RecheckDumpers, UsePrebuiltDumpers, diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 5b7bb4be8ed236a70bcd5f1b980b9e37d6fb30eb..e68a359a31a8cf8d26246ab66afe7d9ccb12e041 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -251,18 +251,10 @@ void DebuggerManager::init() // Locals QTreeView *localsView = qobject_cast<QTreeView *>(m_localsWindow); localsView->setModel(m_watchHandler->model()); - connect(localsView, SIGNAL(requestExpandChildren(QModelIndex)), - this, SLOT(expandChildren(QModelIndex))); - connect(localsView, SIGNAL(requestCollapseChildren(QModelIndex)), - this, SLOT(collapseChildren(QModelIndex))); // Watchers QTreeView *watchersView = qobject_cast<QTreeView *>(m_watchersWindow); watchersView->setModel(m_watchHandler->model()); - connect(watchersView, SIGNAL(requestExpandChildren(QModelIndex)), - this, SLOT(expandChildren(QModelIndex))); - connect(watchersView, SIGNAL(requestCollapseChildren(QModelIndex)), - this, SLOT(collapseChildren(QModelIndex))); connect(m_watchHandler, SIGNAL(sessionValueRequested(QString,QVariant*)), this, SIGNAL(sessionValueRequested(QString,QVariant*))); connect(m_watchHandler, SIGNAL(setSessionValueRequested(QString,QVariant)), @@ -718,18 +710,6 @@ void DebuggerManager::updateWatchModel() m_engine->updateWatchModel(); } -void DebuggerManager::expandChildren(const QModelIndex &idx) -{ - QTC_ASSERT(m_watchHandler, return); - m_watchHandler->expandChildren(idx); -} - -void DebuggerManager::collapseChildren(const QModelIndex &idx) -{ - QTC_ASSERT(m_watchHandler, return); - m_watchHandler->collapseChildren(idx); -} - QVariant DebuggerManager::sessionValue(const QString &name) { // this is answered by the plugin diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 77e629e38e501eedc93fe38613cdc65e6fba08eb..414ef429631d8c588283e6be5574d86a3c4b36e1 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -231,8 +231,6 @@ public slots: void addToWatchWindow(); void updateWatchModel(); - void expandChildren(const QModelIndex &idx); - void collapseChildren(const QModelIndex &idx); void sessionLoaded(); void aboutToSaveSession(); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index cfe0eb5338ceb24ee530b0d54f175a4ca8a2f918..0342f22c7e395d209f14aedf01288fc4ec12c621 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -370,9 +370,12 @@ WatchHandler::WatchHandler() connect(theDebuggerAction(WatchExpression), SIGNAL(triggered()), this, SLOT(watchExpression())); - connect(theDebuggerAction(RemoveWatchExpression), SIGNAL(triggered()), this, SLOT(removeWatchExpression())); + connect(theDebuggerAction(ExpandItem), + SIGNAL(triggered()), this, SLOT(expandChildren())); + connect(theDebuggerAction(CollapseItem), + SIGNAL(triggered()), this, SLOT(collapseChildren())); } static QString niceType(QString type) @@ -785,15 +788,19 @@ void WatchHandler::cleanup() emit reset(); } -void WatchHandler::collapseChildren(const QModelIndex &idx) +void WatchHandler::collapseChildren() +{ + if (QAction *act = qobject_cast<QAction *>(sender())) + collapseChildren(act->data().toString()); +} + +void WatchHandler::collapseChildren(const QString &iname) { if (m_inChange || m_completeSet.isEmpty()) { - qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx; + qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << iname; return; } - QTC_ASSERT(checkIndex(idx.internalId()), return); - QString iname0 = m_displaySet.at(idx.internalId()).iname; - MODEL_DEBUG("COLLAPSE NODE" << iname0); + MODEL_DEBUG("COLLAPSE NODE" << iname); #if 0 QString iname1 = iname0 + '.'; for (int i = m_completeSet.size(); --i >= 0; ) { @@ -806,19 +813,32 @@ void WatchHandler::collapseChildren(const QModelIndex &idx) } } #endif - m_expandedINames.remove(iname0); + m_expandedINames.remove(iname); //MODEL_DEBUG(toString()); //rebuildModel(); } -void WatchHandler::expandChildren(const QModelIndex &idx) +void WatchHandler::expandChildren() +{ + if (QAction *act = qobject_cast<QAction *>(sender())) + expandChildren(act->data().toString()); +} + +void WatchHandler::expandChildren(const QString &iname) { if (m_inChange || m_completeSet.isEmpty()) { - //qDebug() << "WATCHHANDLER: EXPAND IGNORED" << idx; + //qDebug() << "WATCHHANDLER: EXPAND IGNORED" << iname; return; } - int index = idx.internalId(); - if (index == 0) + int index = -1; + for (int i = 0; i != m_displaySet.size(); ++i) { + if (m_displaySet.at(i).iname == iname) { + index = i; + break; + } + } + + if (index == -1) return; QTC_ASSERT(index >= 0, qDebug() << toString() << index; return); QTC_ASSERT(index < m_completeSet.size(), qDebug() << toString() << index; return); @@ -832,8 +852,7 @@ void WatchHandler::expandChildren(const QModelIndex &idx) // "expand()" signals folr the root item from time to time. // Try to handle that gracfully. //MODEL_DEBUG(toString()); - qDebug() << "FIXME: expandChildren, no data " << display.iname << "found" - << idx; + qDebug() << "FIXME: expandChildren, no data " << display.iname << "found"; //rebuildModel(); return; } diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index a41920381568e8c08c0fc5836566b4a6b7b8abd8..6701eecda34baf9de1a95553eef7deb9b7b2d721 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -165,8 +165,10 @@ public: Q_SLOT void removeWatchExpression(const QString &exp); void reinitializeWatchers(); - void collapseChildren(const QModelIndex &idx); - void expandChildren(const QModelIndex &idx); + Q_SLOT void collapseChildren(); + Q_SLOT void expandChildren(); + Q_SLOT void collapseChildren(const QString &iname); + Q_SLOT void expandChildren(const QString &iname); void rebuildModel(); // unconditionally version of above void showEditValue(const WatchData &data); diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index de30e8f38065c5ca265f9acb38850821f1923bd6..55759b1462c6c01f0dd84d582bba7d72a218fc50 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -125,19 +125,16 @@ WatchWindow::WatchWindow(Type type, QWidget *parent) 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(); - emit requestExpandChildren(idx); + QModelIndex mi0 = idx.sibling(idx.row(), 0); + QVariant iname = model()->data(mi0, INameRole); + theDebuggerAction(ExpandItem)->trigger(iname); } void WatchWindow::collapseNode(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(); - //qDebug() << "COLLAPSE NODE " << idx; - emit requestCollapseChildren(idx); + QModelIndex mi0 = idx.sibling(idx.row(), 0); + QVariant iname = model()->data(mi0, INameRole); + theDebuggerAction(CollapseItem)->trigger(iname); } void WatchWindow::keyPressEvent(QKeyEvent *ev) diff --git a/src/plugins/debugger/watchwindow.h b/src/plugins/debugger/watchwindow.h index bf6995edb4adae1bee3eb4310b771bac9e595cc2..ff26a693362bb6a18283f46c925619d6599186bd 100644 --- a/src/plugins/debugger/watchwindow.h +++ b/src/plugins/debugger/watchwindow.h @@ -57,15 +57,10 @@ public slots: void setAlwaysResizeColumnsToContents(bool on = true); void setModel(QAbstractItemModel *model); -signals: - void requestExpandChildren(const QModelIndex &idx); - void requestCollapseChildren(const QModelIndex &idx); - -private slots: - void expandNode(const QModelIndex &index); - void collapseNode(const QModelIndex &index); - private: + Q_SLOT void expandNode(const QModelIndex &index); + Q_SLOT void collapseNode(const QModelIndex &index); + void keyPressEvent(QKeyEvent *ev); void contextMenuEvent(QContextMenuEvent *ev); void editItem(const QModelIndex &idx);