diff options
Diffstat (limited to 'src')
4 files changed, 23 insertions, 17 deletions
diff --git a/src/libs/modelinglib/qmt/model_ui/treemodel.cpp b/src/libs/modelinglib/qmt/model_ui/treemodel.cpp index ce7bb0504e..404599682d 100644 --- a/src/libs/modelinglib/qmt/model_ui/treemodel.cpp +++ b/src/libs/modelinglib/qmt/model_ui/treemodel.cpp @@ -443,7 +443,7 @@ QModelIndex TreeModel::indexOf(const MElement *element) const QMT_CHECK(false); return QModelIndex(); } - QModelIndex parentIndex = indexFromItem(item); + const QModelIndex parentIndex = indexFromItem(item); int row = parentObject->children().indexOf(object); return QStandardItemModel::index(row, 0, parentIndex); } else if (auto relation = dynamic_cast<const MRelation *>(element)) { @@ -454,7 +454,7 @@ QModelIndex TreeModel::indexOf(const MElement *element) const QMT_CHECK(false); return QModelIndex(); } - QModelIndex parentIndex = indexFromItem(item); + const QModelIndex parentIndex = indexFromItem(item); int row = owner->children().size() + owner->relations().indexOf(relation); return QStandardItemModel::index(row, 0, parentIndex); } @@ -519,7 +519,7 @@ void TreeModel::onEndUpdateObject(int row, const MObject *parent) parentIndex = indexFromItem(parentItem); } // reflect updated element in standard item - QModelIndex elementIndex = this->QStandardItemModel::index(row, 0, parentIndex); + const QModelIndex elementIndex = this->QStandardItemModel::index(row, 0, parentIndex); MElement *element = TreeModel::element(elementIndex); if (element) { auto object = dynamic_cast<MObject *>(element); @@ -531,7 +531,7 @@ void TreeModel::onEndUpdateObject(int row, const MObject *parent) } } m_busyState = NotBusy; - emit dataChanged(QStandardItemModel::index(row, 0, parentIndex), QStandardItemModel::index(row, 0, parentIndex)); + emit dataChanged(elementIndex, elementIndex); } void TreeModel::onBeginInsertObject(int row, const MObject *parent) @@ -616,11 +616,11 @@ void TreeModel::onEndUpdateRelation(int row, const MObject *parent) QMT_CHECK(m_objectToItemMap.contains(parent)); ModelItem *parentItem = m_objectToItemMap.value(parent); QMT_ASSERT(parentItem, return); - QModelIndex parentIndex = indexFromItem(parentItem); + const QModelIndex parentIndex = indexFromItem(parentItem); // reflect updated relation in standard item row += parent->children().size(); - QModelIndex elementIndex = QStandardItemModel::index(row, 0, parentIndex); + const QModelIndex elementIndex = QStandardItemModel::index(row, 0, parentIndex); MElement *element = TreeModel::element(elementIndex); if (element) { auto relation = dynamic_cast<MRelation *>(element); @@ -632,7 +632,7 @@ void TreeModel::onEndUpdateRelation(int row, const MObject *parent) } } m_busyState = NotBusy; - emit dataChanged(QStandardItemModel::index(row, 0, parentIndex), QStandardItemModel::index(row, 0, parentIndex)); + emit dataChanged(elementIndex, elementIndex); } void TreeModel::onBeginInsertRelation(int row, const MObject *parent) @@ -707,10 +707,10 @@ void TreeModel::onRelationEndChanged(MRelation *relation, MObject *endObject) QMT_CHECK(m_objectToItemMap.contains(parent)); ModelItem *parentItem = m_objectToItemMap.value(parent); QMT_ASSERT(parentItem, return); - QModelIndex parentIndex = indexFromItem(parentItem); + const QModelIndex parentIndex = indexFromItem(parentItem); int row = parent->children().size() + relation->owner()->relations().indexOf(relation); - QModelIndex elementIndex = QStandardItemModel::index(row, 0, parentIndex); + const QModelIndex elementIndex = QStandardItemModel::index(row, 0, parentIndex); QMT_CHECK(elementIndex.isValid()); auto item = dynamic_cast<ModelItem *>(itemFromIndex(elementIndex)); @@ -720,7 +720,7 @@ void TreeModel::onRelationEndChanged(MRelation *relation, MObject *endObject) if (item->text() != label) item->setText(label); - emit dataChanged(QStandardItemModel::index(row, 0, parentIndex), QStandardItemModel::index(row, 0, parentIndex)); + emit dataChanged(elementIndex, elementIndex); } void TreeModel::onModelDataChanged(const QModelIndex &topleft, const QModelIndex &bottomright) diff --git a/src/plugins/projectexplorer/projectconfigurationmodel.cpp b/src/plugins/projectexplorer/projectconfigurationmodel.cpp index edd87babe0..a3a8d21e48 100644 --- a/src/plugins/projectexplorer/projectconfigurationmodel.cpp +++ b/src/plugins/projectexplorer/projectconfigurationmodel.cpp @@ -75,6 +75,7 @@ void ProjectConfigurationModel::displayNameChanged() if (oldPos < 0) return; + QModelIndex itemIndex; if (oldPos >= 1 && isOrderedBefore(m_projectConfigurations.at(oldPos), m_projectConfigurations.at(oldPos - 1))) { // We need to move up int newPos = oldPos - 1; @@ -88,7 +89,7 @@ void ProjectConfigurationModel::displayNameChanged() m_projectConfigurations.removeAt(oldPos + 1); endMoveRows(); // Not only did we move, we also changed... - emit dataChanged(index(newPos, 0), index(newPos,0)); + itemIndex = index(newPos, 0); } else if (oldPos < m_projectConfigurations.size() - 1 && isOrderedBefore(m_projectConfigurations.at(oldPos + 1), m_projectConfigurations.at(oldPos))) { // We need to move down @@ -103,10 +104,11 @@ void ProjectConfigurationModel::displayNameChanged() endMoveRows(); // We need to subtract one since removing at the old place moves the newIndex down - emit dataChanged(index(newPos - 1, 0), index(newPos - 1, 0)); + itemIndex = index(newPos - 1, 0); } else { - emit dataChanged(index(oldPos, 0), index(oldPos, 0)); + itemIndex = index(oldPos, 0); } + emit dataChanged(itemIndex, itemIndex); } QVariant ProjectConfigurationModel::data(const QModelIndex &index, int role) const diff --git a/src/plugins/projectexplorer/taskmodel.cpp b/src/plugins/projectexplorer/taskmodel.cpp index 5b3511e93c..f256f026cb 100644 --- a/src/plugins/projectexplorer/taskmodel.cpp +++ b/src/plugins/projectexplorer/taskmodel.cpp @@ -148,7 +148,8 @@ void TaskModel::updateTaskFileName(unsigned int id, const QString &fileName) QTC_ASSERT(i != -1, return); if (m_tasks.at(i).taskId == id) { m_tasks[i].file = Utils::FilePath::fromString(fileName); - emit dataChanged(index(i, 0), index(i, 0)); + const QModelIndex itemIndex = index(i, 0); + emit dataChanged(itemIndex, itemIndex); } } @@ -158,7 +159,8 @@ void TaskModel::updateTaskLineNumber(unsigned int id, int line) QTC_ASSERT(i != -1, return); if (m_tasks.at(i).taskId == id) { m_tasks[i].movedLine = line; - emit dataChanged(index(i, 0), index(i, 0)); + const QModelIndex itemIndex = index(i, 0); + emit dataChanged(itemIndex, itemIndex); } } diff --git a/src/plugins/serialterminal/serialdevicemodel.cpp b/src/plugins/serialterminal/serialdevicemodel.cpp index 4a830da154..dc77876f51 100644 --- a/src/plugins/serialterminal/serialdevicemodel.cpp +++ b/src/plugins/serialterminal/serialdevicemodel.cpp @@ -70,8 +70,10 @@ void SerialDeviceModel::disablePort(const QString &portName) return info.portName() == portName; }); - if (i >= 0) - emit dataChanged(index(i), index(i), {Qt::DisplayRole}); + if (i >= 0) { + const QModelIndex itemIndex = index(i); + emit dataChanged(itemIndex, itemIndex, {Qt::DisplayRole}); + } } void SerialDeviceModel::enablePort(const QString &portName) |