forked from qt-creator/qt-creator
fix expansion state of "dummy" items in locals&watchers after frame changes
This commit is contained in:
@@ -320,6 +320,51 @@ static WatchData take(const QString &iname, QList<WatchData> *list)
|
||||
}
|
||||
|
||||
|
||||
static QList<WatchData> initialSet()
|
||||
{
|
||||
QList<WatchData> result;
|
||||
|
||||
WatchData root;
|
||||
root.state = 0;
|
||||
root.level = 0;
|
||||
root.row = 0;
|
||||
root.name = "Root";
|
||||
root.parentIndex = -1;
|
||||
root.childIndex.append(1);
|
||||
root.childIndex.append(2);
|
||||
root.childIndex.append(3);
|
||||
result.append(root);
|
||||
|
||||
WatchData local;
|
||||
local.iname = "local";
|
||||
local.name = "Locals";
|
||||
local.state = 0;
|
||||
local.level = 1;
|
||||
local.row = 0;
|
||||
local.parentIndex = 0;
|
||||
result.append(local);
|
||||
|
||||
WatchData tooltip;
|
||||
tooltip.iname = "tooltip";
|
||||
tooltip.name = "Tooltip";
|
||||
tooltip.state = 0;
|
||||
tooltip.level = 1;
|
||||
tooltip.row = 1;
|
||||
tooltip.parentIndex = 0;
|
||||
result.append(tooltip);
|
||||
|
||||
WatchData watch;
|
||||
watch.iname = "watch";
|
||||
watch.name = "Watchers";
|
||||
watch.state = 0;
|
||||
watch.level = 1;
|
||||
watch.row = 2;
|
||||
watch.parentIndex = 0;
|
||||
result.append(watch);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WatchHandler
|
||||
@@ -332,7 +377,8 @@ WatchHandler::WatchHandler()
|
||||
m_inFetchMore = false;
|
||||
m_inChange = false;
|
||||
|
||||
cleanModel();
|
||||
m_completeSet = initialSet();
|
||||
m_incompleteSet.clear();
|
||||
m_displaySet = m_completeSet;
|
||||
}
|
||||
|
||||
@@ -380,6 +426,7 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
|
||||
int node = idx.internalId();
|
||||
if (node < 0)
|
||||
return QVariant();
|
||||
QWB_ASSERT(node < m_displaySet.size(), return QVariant());
|
||||
|
||||
const WatchData &data = m_displaySet.at(node);
|
||||
|
||||
@@ -558,10 +605,13 @@ void WatchHandler::rebuildModel()
|
||||
MODEL_DEBUG("RECREATE MODEL, CURRENT SET:\n" << toString());
|
||||
#endif
|
||||
|
||||
QHash<QString, int> oldTopINames;
|
||||
QHash<QString, QString> oldValues;
|
||||
for (int i = 0, n = m_oldSet.size(); i != n; ++i) {
|
||||
WatchData &data = m_oldSet[i];
|
||||
oldValues[data.iname] = data.value;
|
||||
if (data.level == 2)
|
||||
++oldTopINames[data.iname];
|
||||
}
|
||||
#ifdef DEBUG_PENDING
|
||||
MODEL_DEBUG("OLD VALUES: " << oldValues);
|
||||
@@ -575,6 +625,9 @@ void WatchHandler::rebuildModel()
|
||||
|
||||
qSort(m_completeSet.begin(), m_completeSet.end(), &iNameSorter);
|
||||
|
||||
// This helps to decide whether the view has completely changed or not.
|
||||
QHash<QString, int> topINames;
|
||||
|
||||
QHash<QString, int> iname2idx;
|
||||
|
||||
for (int i = m_completeSet.size(); --i > 0; ) {
|
||||
@@ -582,7 +635,10 @@ void WatchHandler::rebuildModel()
|
||||
data.parentIndex = 0;
|
||||
data.childIndex.clear();
|
||||
iname2idx[data.iname] = i;
|
||||
if (data.level == 2)
|
||||
++topINames[data.iname];
|
||||
}
|
||||
//qDebug() << "TOPINAMES: " << topINames << "\nOLD: " << oldTopINames;
|
||||
|
||||
for (int i = 1; i < m_completeSet.size(); ++i) {
|
||||
WatchData &data = m_completeSet[i];
|
||||
@@ -603,7 +659,13 @@ void WatchHandler::rebuildModel()
|
||||
&& data.value != strNotInScope;
|
||||
}
|
||||
|
||||
//emit layoutAboutToBeChanged();
|
||||
emit layoutAboutToBeChanged();
|
||||
|
||||
if (oldTopINames != topINames) {
|
||||
m_displaySet = initialSet();
|
||||
m_expandedINames.clear();
|
||||
emit reset();
|
||||
}
|
||||
|
||||
m_displaySet = m_completeSet;
|
||||
|
||||
@@ -668,11 +730,6 @@ void WatchHandler::rebuildModel()
|
||||
emit reset();
|
||||
//qDebug() << "WATCHHANDLER: RESET EMITTED";
|
||||
m_inChange = false;
|
||||
//emit layoutChanged();
|
||||
//QSet<QString> einames = m_expandedINames;
|
||||
//einames.insert("local");
|
||||
//einames.insert("watch");
|
||||
//emit expandedItems(einames);
|
||||
|
||||
#if DEBUG_MODEL
|
||||
#if USE_MODEL_TEST
|
||||
@@ -691,8 +748,11 @@ void WatchHandler::cleanup()
|
||||
m_oldSet.clear();
|
||||
m_expandedINames.clear();
|
||||
m_displayedINames.clear();
|
||||
cleanModel();
|
||||
|
||||
m_incompleteSet.clear();
|
||||
m_completeSet = initialSet();
|
||||
m_displaySet = m_completeSet;
|
||||
|
||||
#if 0
|
||||
for (EditWindows::ConstIterator it = m_editWindows.begin();
|
||||
it != m_editWindows.end(); ++it) {
|
||||
@@ -707,7 +767,7 @@ void WatchHandler::cleanup()
|
||||
void WatchHandler::collapseChildren(const QModelIndex &idx)
|
||||
{
|
||||
if (m_inChange || m_completeSet.isEmpty()) {
|
||||
//qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx;
|
||||
qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx;
|
||||
return;
|
||||
}
|
||||
QWB_ASSERT(checkIndex(idx.internalId()), return);
|
||||
@@ -879,56 +939,10 @@ void WatchHandler::removeWatchExpression(const QString &iname)
|
||||
emit watchModelUpdateRequested();
|
||||
}
|
||||
|
||||
void WatchHandler::cleanModel()
|
||||
{
|
||||
// This uses data stored in m_oldSet to re-create a new set
|
||||
// one-by-one
|
||||
m_completeSet.clear();
|
||||
m_incompleteSet.clear();
|
||||
|
||||
WatchData root;
|
||||
root.state = 0;
|
||||
root.level = 0;
|
||||
root.row = 0;
|
||||
root.name = "Root";
|
||||
root.parentIndex = -1;
|
||||
root.childIndex.append(1);
|
||||
root.childIndex.append(2);
|
||||
root.childIndex.append(3);
|
||||
m_completeSet.append(root);
|
||||
|
||||
WatchData local;
|
||||
local.iname = "local";
|
||||
local.name = "Locals";
|
||||
local.state = 0;
|
||||
local.level = 1;
|
||||
local.row = 0;
|
||||
local.parentIndex = 0;
|
||||
m_completeSet.append(local);
|
||||
|
||||
WatchData tooltip;
|
||||
tooltip.iname = "tooltip";
|
||||
tooltip.name = "Tooltip";
|
||||
tooltip.state = 0;
|
||||
tooltip.level = 1;
|
||||
tooltip.row = 1;
|
||||
tooltip.parentIndex = 0;
|
||||
m_completeSet.append(tooltip);
|
||||
|
||||
WatchData watch;
|
||||
watch.iname = "watch";
|
||||
watch.name = "Watchers";
|
||||
watch.state = 0;
|
||||
watch.level = 1;
|
||||
watch.row = 2;
|
||||
watch.parentIndex = 0;
|
||||
m_completeSet.append(watch);
|
||||
}
|
||||
|
||||
|
||||
void WatchHandler::reinitializeWatchers()
|
||||
{
|
||||
cleanModel();
|
||||
m_completeSet = initialSet();
|
||||
m_incompleteSet.clear();
|
||||
|
||||
// copy over all watchers and mark all watchers as incomplete
|
||||
for (int i = 0, n = m_oldSet.size(); i < n; ++i) {
|
||||
|
||||
@@ -192,7 +192,6 @@ signals:
|
||||
private:
|
||||
WatchData takeData(const QString &iname);
|
||||
QString toString() const;
|
||||
void cleanModel();
|
||||
|
||||
bool m_expandPointers;
|
||||
bool m_inChange;
|
||||
|
||||
@@ -57,7 +57,6 @@ enum { INameRole = Qt::UserRole, VisualRole };
|
||||
WatchWindow::WatchWindow(Type type, QWidget *parent)
|
||||
: QTreeView(parent), m_type(type)
|
||||
{
|
||||
m_blocked = false;
|
||||
setWindowTitle(tr("Locals and Watchers"));
|
||||
setAlternatingRowColors(true);
|
||||
setIndentation(indentation() * 9/10);
|
||||
@@ -76,12 +75,8 @@ 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();
|
||||
//qDebug() << "\n\nEXPAND NODE " // << iname << name
|
||||
// << idx << (m_blocked ? "blocked" : "passed");
|
||||
//if (isExpanded(idx))
|
||||
// return;
|
||||
//if (m_blocked)
|
||||
// return;
|
||||
emit requestExpandChildren(idx);
|
||||
}
|
||||
|
||||
@@ -91,8 +86,6 @@ void WatchWindow::collapseNode(const QModelIndex &idx)
|
||||
//QString iname = model()->data(mi0, INameRole).toString();
|
||||
//QString name = model()->data(mi0, Qt::DisplayRole).toString();
|
||||
//qDebug() << "COLLAPSE NODE " << idx;
|
||||
if (m_blocked)
|
||||
return;
|
||||
emit requestCollapseChildren(idx);
|
||||
}
|
||||
|
||||
@@ -201,7 +194,6 @@ void WatchWindow::setModel(QAbstractItemModel *model)
|
||||
|
||||
void WatchWindow::modelAboutToBeReset()
|
||||
{
|
||||
m_blocked = true;
|
||||
//qDebug() << "Model about to be reset";
|
||||
m_expandedItems.clear();
|
||||
m_expandedItems.insert("local");
|
||||
@@ -225,10 +217,9 @@ void WatchWindow::modelAboutToBeResetHelper(const QModelIndex &idx)
|
||||
|
||||
void WatchWindow::modelReset()
|
||||
{
|
||||
//qDebug() << "Model reset";
|
||||
collapseAll();
|
||||
expand(model()->index(0, 0));
|
||||
modelResetHelper(model()->index(0, 0));
|
||||
m_blocked = false;
|
||||
}
|
||||
|
||||
void WatchWindow::modelResetHelper(const QModelIndex &idx)
|
||||
@@ -242,6 +233,9 @@ void WatchWindow::modelResetHelper(const QModelIndex &idx)
|
||||
QModelIndex idx1 = model()->index(i, 0, idx);
|
||||
modelResetHelper(idx1);
|
||||
}
|
||||
} else {
|
||||
// if (!iname.isEmpty())
|
||||
// collapse(idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ private:
|
||||
|
||||
bool m_alwaysResizeColumnsToContents;
|
||||
Type m_type;
|
||||
bool m_blocked;
|
||||
QSet<QString> m_expandedItems;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user