forked from qt-creator/qt-creator
debugger: use new actions for watchers window/manager communication
This commit is contained in:
@@ -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
|
||||
//
|
||||
|
||||
@@ -150,6 +150,8 @@ enum DebuggerActionCode
|
||||
WatchModelUpdate,
|
||||
UseToolTips,
|
||||
AssignValue,
|
||||
ExpandItem,
|
||||
CollapseItem,
|
||||
|
||||
RecheckDumpers,
|
||||
UsePrebuiltDumpers,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -231,8 +231,6 @@ public slots:
|
||||
|
||||
void addToWatchWindow();
|
||||
void updateWatchModel();
|
||||
void expandChildren(const QModelIndex &idx);
|
||||
void collapseChildren(const QModelIndex &idx);
|
||||
|
||||
void sessionLoaded();
|
||||
void aboutToSaveSession();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user