forked from qt-creator/qt-creator
debugger: remove unnecessary first level in WatchModel
There used to be a single 'Locals' etc item of the true root that was never shown anyway. Removing this also renders using setRootIndex() in WatchWindow unnecessary.
This commit is contained in:
@@ -2699,7 +2699,7 @@ bool GdbEngine::showToolTip()
|
|||||||
WatchModel *model = handler->model(TooltipsWatch);
|
WatchModel *model = handler->model(TooltipsWatch);
|
||||||
QString iname = tooltipINameForExpression(m_toolTipExpression);
|
QString iname = tooltipINameForExpression(m_toolTipExpression);
|
||||||
model->setActiveData(iname);
|
model->setActiveData(iname);
|
||||||
WatchItem *item = model->findItem(iname, model->dummyRoot());
|
WatchItem *item = model->findItem(iname, model->rootItem());
|
||||||
if (!item) {
|
if (!item) {
|
||||||
hideDebuggerToolTip();
|
hideDebuggerToolTip();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -52,8 +52,6 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
// creates debug output regarding pending watch data results
|
|
||||||
//#define DEBUG_PENDING 1
|
|
||||||
// creates debug output for accesses to the model
|
// creates debug output for accesses to the model
|
||||||
//#define DEBUG_MODEL 1
|
//#define DEBUG_MODEL 1
|
||||||
|
|
||||||
@@ -285,57 +283,46 @@ WatchModel::WatchModel(WatchHandler *handler, WatchType type)
|
|||||||
m_root->hasChildren = 1;
|
m_root->hasChildren = 1;
|
||||||
m_root->state = 0;
|
m_root->state = 0;
|
||||||
m_root->name = WatchHandler::tr("Root");
|
m_root->name = WatchHandler::tr("Root");
|
||||||
|
m_root->parent = 0;
|
||||||
WatchItem *item = new WatchItem;
|
m_root->fetchTriggered = true;
|
||||||
|
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case LocalsWatch:
|
case LocalsWatch:
|
||||||
item->iname = QLatin1String("local");
|
m_root->iname = QLatin1String("local");
|
||||||
item->name = WatchHandler::tr("Locals");
|
m_root->name = WatchHandler::tr("Locals");
|
||||||
break;
|
break;
|
||||||
case WatchersWatch:
|
case WatchersWatch:
|
||||||
item->iname = QLatin1String("watch");
|
m_root->iname = QLatin1String("watch");
|
||||||
item->name = WatchHandler::tr("Watchers");
|
m_root->name = WatchHandler::tr("Watchers");
|
||||||
break;
|
break;
|
||||||
case TooltipsWatch:
|
case TooltipsWatch:
|
||||||
item->iname = QLatin1String("tooltip");
|
m_root->iname = QLatin1String("tooltip");
|
||||||
item->name = WatchHandler::tr("Tooltip");
|
m_root->name = WatchHandler::tr("Tooltip");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
item->hasChildren = true;
|
|
||||||
item->state = 0;
|
|
||||||
item->parent = m_root;
|
|
||||||
item->fetchTriggered = true;
|
|
||||||
|
|
||||||
m_root->children.append(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WatchItem *WatchModel::dummyRoot() const
|
WatchItem *WatchModel::rootItem() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!m_root->children.isEmpty(), return 0);
|
return m_root;
|
||||||
return m_root->children.front();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchModel::reinitialize()
|
void WatchModel::reinitialize()
|
||||||
{
|
{
|
||||||
WatchItem *item = dummyRoot();
|
int n = m_root->children.size();
|
||||||
QTC_ASSERT(item, return);
|
|
||||||
QModelIndex index = watchIndex(item);
|
|
||||||
int n = item->children.size();
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
//MODEL_DEBUG("REMOVING " << n << " CHILDREN OF " << item->iname);
|
//MODEL_DEBUG("REMOVING " << n << " CHILDREN OF " << m_root->iname);
|
||||||
|
QModelIndex index = watchIndex(m_root);
|
||||||
beginRemoveRows(index, 0, n - 1);
|
beginRemoveRows(index, 0, n - 1);
|
||||||
qDeleteAll(item->children);
|
qDeleteAll(m_root->children);
|
||||||
item->children.clear();
|
m_root->children.clear();
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchModel::removeOutdated()
|
void WatchModel::removeOutdated()
|
||||||
{
|
{
|
||||||
WatchItem *item = dummyRoot();
|
foreach (WatchItem *child, m_root->children)
|
||||||
QTC_ASSERT(item, return);
|
|
||||||
foreach (WatchItem *child, item->children)
|
|
||||||
removeOutdatedHelper(child);
|
removeOutdatedHelper(child);
|
||||||
#if DEBUG_MODEL
|
#if DEBUG_MODEL
|
||||||
#if USE_MODEL_TEST
|
#if USE_MODEL_TEST
|
||||||
@@ -551,6 +538,8 @@ QModelIndex WatchModel::index(int row, int column, const QModelIndex &parent) co
|
|||||||
|
|
||||||
const WatchItem *item = watchItem(parent);
|
const WatchItem *item = watchItem(parent);
|
||||||
QTC_ASSERT(item, return QModelIndex());
|
QTC_ASSERT(item, return QModelIndex());
|
||||||
|
if (row >= item->children.size())
|
||||||
|
return QModelIndex();
|
||||||
return createIndex(row, column, (void*)(item->children.at(row)));
|
return createIndex(row, column, (void*)(item->children.at(row)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,8 +565,6 @@ QModelIndex WatchModel::parent(const QModelIndex &idx) const
|
|||||||
|
|
||||||
int WatchModel::rowCount(const QModelIndex &idx) const
|
int WatchModel::rowCount(const QModelIndex &idx) const
|
||||||
{
|
{
|
||||||
if (!idx.isValid())
|
|
||||||
return 1;
|
|
||||||
if (idx.column() > 0)
|
if (idx.column() > 0)
|
||||||
return 0;
|
return 0;
|
||||||
return watchItem(idx)->children.size();
|
return watchItem(idx)->children.size();
|
||||||
@@ -807,7 +794,7 @@ void WatchModel::insertData(const WatchData &data)
|
|||||||
emit dataChanged(idx, idx.sibling(idx.row(), 2));
|
emit dataChanged(idx, idx.sibling(idx.row(), 2));
|
||||||
} else {
|
} else {
|
||||||
// add new entry
|
// add new entry
|
||||||
//MODEL_DEBUG("INSERT : " << data.iname << data.value);
|
//MODEL_DEBUG("ADD : " << data.iname << data.value);
|
||||||
WatchItem *item = new WatchItem(data);
|
WatchItem *item = new WatchItem(data);
|
||||||
item->parent = parent;
|
item->parent = parent;
|
||||||
item->generation = generationCounter;
|
item->generation = generationCounter;
|
||||||
@@ -1008,7 +995,7 @@ void WatchHandler::removeWatchExpression(const QString &exp)
|
|||||||
{
|
{
|
||||||
MODEL_DEBUG("REMOVE WATCH: " << exp);
|
MODEL_DEBUG("REMOVE WATCH: " << exp);
|
||||||
m_watcherNames.remove(exp);
|
m_watcherNames.remove(exp);
|
||||||
foreach (WatchItem *item, m_watchers->dummyRoot()->children) {
|
foreach (WatchItem *item, m_watchers->rootItem()->children) {
|
||||||
if (item->exp == exp) {
|
if (item->exp == exp) {
|
||||||
m_watchers->removeItem(item);
|
m_watchers->removeItem(item);
|
||||||
saveWatchers();
|
saveWatchers();
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ private:
|
|||||||
void reinitialize();
|
void reinitialize();
|
||||||
void removeOutdated();
|
void removeOutdated();
|
||||||
void removeOutdatedHelper(WatchItem *item);
|
void removeOutdatedHelper(WatchItem *item);
|
||||||
WatchItem *dummyRoot() const;
|
WatchItem *rootItem() const;
|
||||||
void removeItem(WatchItem *item);
|
void removeItem(WatchItem *item);
|
||||||
void setActiveData(const QString &data) { m_activeData = data; }
|
void setActiveData(const QString &data) { m_activeData = data; }
|
||||||
|
|
||||||
|
|||||||
@@ -144,12 +144,6 @@ void WatchWindow::collapseNode(const QModelIndex &idx)
|
|||||||
model()->setData(idx, false, ExpandedRole);
|
model()->setData(idx, false, ExpandedRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchWindow::reset()
|
|
||||||
{
|
|
||||||
QTreeView::reset();
|
|
||||||
setRootIndex(model()->index(0, 0, QModelIndex()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WatchWindow::keyPressEvent(QKeyEvent *ev)
|
void WatchWindow::keyPressEvent(QKeyEvent *ev)
|
||||||
{
|
{
|
||||||
if (ev->key() == Qt::Key_Delete && m_type == WatchersType) {
|
if (ev->key() == Qt::Key_Delete && m_type == WatchersType) {
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ public slots:
|
|||||||
void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); }
|
void setAlternatingRowColorsHelper(bool on) { setAlternatingRowColors(on); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reset();
|
|
||||||
Q_SLOT void resetHelper();
|
Q_SLOT void resetHelper();
|
||||||
Q_SLOT void expandNode(const QModelIndex &idx);
|
Q_SLOT void expandNode(const QModelIndex &idx);
|
||||||
Q_SLOT void collapseNode(const QModelIndex &idx);
|
Q_SLOT void collapseNode(const QModelIndex &idx);
|
||||||
|
|||||||
Reference in New Issue
Block a user