forked from qt-creator/qt-creator
debugger: replace a workaround to update the [+] marker when items by a less intrusive one
This commit is contained in:
@@ -352,7 +352,6 @@ QString WatchData::shadowedName(const QString &name, int seen)
|
|||||||
WatchModel::WatchModel(WatchHandler *handler, WatchType type)
|
WatchModel::WatchModel(WatchHandler *handler, WatchType type)
|
||||||
: QAbstractItemModel(handler), m_handler(handler), m_type(type)
|
: QAbstractItemModel(handler), m_handler(handler), m_type(type)
|
||||||
{
|
{
|
||||||
m_inExtraLayoutChanged = false;
|
|
||||||
m_root = new WatchItem;
|
m_root = new WatchItem;
|
||||||
m_root->hasChildren = 1;
|
m_root->hasChildren = 1;
|
||||||
m_root->state = 0;
|
m_root->state = 0;
|
||||||
@@ -414,15 +413,6 @@ void WatchModel::endCycle()
|
|||||||
{
|
{
|
||||||
removeOutdated();
|
removeOutdated();
|
||||||
emit enableUpdates(true);
|
emit enableUpdates(true);
|
||||||
// Prevent 'fetchMore()' from being triggered.
|
|
||||||
m_inExtraLayoutChanged = true;
|
|
||||||
emit layoutChanged();
|
|
||||||
QTimer::singleShot(0, this, SLOT(resetExtraLayoutChanged()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WatchModel::resetExtraLayoutChanged()
|
|
||||||
{
|
|
||||||
m_inExtraLayoutChanged = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchModel::dump()
|
void WatchModel::dump()
|
||||||
@@ -678,14 +668,11 @@ bool WatchModel::canFetchMore(const QModelIndex &index) const
|
|||||||
{
|
{
|
||||||
WatchItem *item = watchItem(index);
|
WatchItem *item = watchItem(index);
|
||||||
QTC_ASSERT(item, return false);
|
QTC_ASSERT(item, return false);
|
||||||
return !m_inExtraLayoutChanged && index.isValid()
|
return index.isValid() && !m_fetchTriggered.contains(item->iname);
|
||||||
&& !m_fetchTriggered.contains(item->iname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchModel::fetchMore(const QModelIndex &index)
|
void WatchModel::fetchMore(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
if (m_inExtraLayoutChanged)
|
|
||||||
return;
|
|
||||||
QTC_ASSERT(index.isValid(), return);
|
QTC_ASSERT(index.isValid(), return);
|
||||||
WatchItem *item = watchItem(index);
|
WatchItem *item = watchItem(index);
|
||||||
QTC_ASSERT(item, return);
|
QTC_ASSERT(item, return);
|
||||||
@@ -1019,8 +1006,8 @@ void WatchModel::insertData(const WatchData &data)
|
|||||||
}
|
}
|
||||||
QModelIndex index = watchIndex(parent);
|
QModelIndex index = watchIndex(parent);
|
||||||
if (WatchItem *oldItem = findItem(data.iname, parent)) {
|
if (WatchItem *oldItem = findItem(data.iname, parent)) {
|
||||||
// overwrite old entry
|
bool hadChildren = oldItem->hasChildren;
|
||||||
//MODEL_DEBUG("OVERWRITE : " << data.iname << data.value);
|
// Overwrite old entry.
|
||||||
bool changed = !data.value.isEmpty()
|
bool changed = !data.value.isEmpty()
|
||||||
&& data.value != oldItem->value
|
&& data.value != oldItem->value
|
||||||
&& data.value != strNotInScope;
|
&& data.value != strNotInScope;
|
||||||
@@ -1029,9 +1016,19 @@ void WatchModel::insertData(const WatchData &data)
|
|||||||
oldItem->generation = generationCounter;
|
oldItem->generation = generationCounter;
|
||||||
QModelIndex idx = watchIndex(oldItem);
|
QModelIndex idx = watchIndex(oldItem);
|
||||||
emit dataChanged(idx, idx.sibling(idx.row(), 2));
|
emit dataChanged(idx, idx.sibling(idx.row(), 2));
|
||||||
|
|
||||||
|
// This works around http://bugreports.qt.nokia.com/browse/QTBUG-7115
|
||||||
|
// by creating and destroying a dummy child item.
|
||||||
|
if (!hadChildren && oldItem->hasChildren) {
|
||||||
|
WatchData dummy = data;
|
||||||
|
dummy.iname = data.iname + ".x";
|
||||||
|
dummy.hasChildren = false;
|
||||||
|
dummy.setAllUnneeded();
|
||||||
|
insertData(dummy);
|
||||||
|
destroyItem(findItem(dummy.iname, m_root));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// add new entry
|
// Add new entry.
|
||||||
//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;
|
||||||
|
|||||||
@@ -233,7 +233,6 @@ private:
|
|||||||
void dump();
|
void dump();
|
||||||
void dumpHelper(WatchItem *item);
|
void dumpHelper(WatchItem *item);
|
||||||
void emitAllChanged();
|
void emitAllChanged();
|
||||||
Q_SLOT void resetExtraLayoutChanged();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void enableUpdates(bool);
|
void enableUpdates(bool);
|
||||||
@@ -245,9 +244,6 @@ private:
|
|||||||
WatchType m_type;
|
WatchType m_type;
|
||||||
WatchItem *m_root;
|
WatchItem *m_root;
|
||||||
QSet<QByteArray> m_fetchTriggered;
|
QSet<QByteArray> m_fetchTriggered;
|
||||||
// Part of the workaround to update the [+] marker when items
|
|
||||||
// are added to a container.
|
|
||||||
bool m_inExtraLayoutChanged;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WatchHandler : public QObject
|
class WatchHandler : public QObject
|
||||||
|
|||||||
Reference in New Issue
Block a user