forked from qt-creator/qt-creator
Qt6: Adapt to removed QMap functionality
QMap::iterator::operator+() was removed in 14090760a8, necessitating extra code using std::next/prev to workaround. QMap::unite is gone, the replacement QMap::insert was only introduced in 5.15. QMap key values need to have an operator==() available. Task-number: QTCREATORBUG-24098 Change-Id: Ic4cf429ab18cad58b1218180de40eb65586afd77 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -36,6 +36,11 @@ class QTCREATOR_UTILS_EXPORT DictKey
|
|||||||
public:
|
public:
|
||||||
DictKey(const QString &name, Qt::CaseSensitivity cs) : name(name), caseSensitivity(cs) {}
|
DictKey(const QString &name, Qt::CaseSensitivity cs) : name(name), caseSensitivity(cs) {}
|
||||||
|
|
||||||
|
friend bool operator==(const DictKey &k1, const DictKey &k2)
|
||||||
|
{
|
||||||
|
return k1.name.compare(k2.name, k1.caseSensitivity) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
Qt::CaseSensitivity caseSensitivity;
|
Qt::CaseSensitivity caseSensitivity;
|
||||||
};
|
};
|
||||||
|
@@ -106,8 +106,8 @@ NameValueModel::~NameValueModel() = default;
|
|||||||
|
|
||||||
QString NameValueModel::indexToVariable(const QModelIndex &index) const
|
QString NameValueModel::indexToVariable(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
return d->m_resultNameValueDictionary.key(d->m_resultNameValueDictionary.constBegin()
|
const auto it = std::next(d->m_resultNameValueDictionary.constBegin(), index.row());
|
||||||
+ index.row());
|
return d->m_resultNameValueDictionary.key(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NameValueModel::setBaseNameValueDictionary(const NameValueDictionary &dictionary)
|
void NameValueModel::setBaseNameValueDictionary(const NameValueDictionary &dictionary)
|
||||||
@@ -150,7 +150,8 @@ QVariant NameValueModel::data(const QModelIndex &index, int role) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
const auto resultIterator = d->m_resultNameValueDictionary.constBegin() + index.row();
|
const auto resultIterator = std::next(d->m_resultNameValueDictionary.constBegin(), index.row());
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
|
@@ -267,7 +267,7 @@ static void insertPosition(QMap<int, int> *map, int position)
|
|||||||
|
|
||||||
bool gluedWithPrev = false;
|
bool gluedWithPrev = false;
|
||||||
if (itNext != map->begin()) {
|
if (itNext != map->begin()) {
|
||||||
auto itPrev = itNext - 1;
|
auto itPrev = std::prev(itNext);
|
||||||
const int keyStart = itPrev.key();
|
const int keyStart = itPrev.key();
|
||||||
const int keyEnd = itPrev.value();
|
const int keyEnd = itPrev.value();
|
||||||
if (position >= keyStart && position <= keyEnd)
|
if (position >= keyStart && position <= keyEnd)
|
||||||
@@ -285,7 +285,7 @@ static void insertPosition(QMap<int, int> *map, int position)
|
|||||||
itNext = map->erase(itNext);
|
itNext = map->erase(itNext);
|
||||||
if (gluedWithPrev) {
|
if (gluedWithPrev) {
|
||||||
// glue with prev and next
|
// glue with prev and next
|
||||||
auto itPrev = itNext - 1;
|
auto itPrev = std::prev(itNext);
|
||||||
*itPrev = keyEnd;
|
*itPrev = keyEnd;
|
||||||
} else {
|
} else {
|
||||||
// glue with next
|
// glue with next
|
||||||
|
@@ -328,7 +328,7 @@ int SideDiffEditorWidget::blockNumberForFileIndex(int fileIndex) const
|
|||||||
if (fileIndex < 0 || fileIndex >= m_fileInfo.count())
|
if (fileIndex < 0 || fileIndex >= m_fileInfo.count())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return (m_fileInfo.constBegin() + fileIndex).key();
|
return std::next(m_fileInfo.constBegin(), fileIndex).key();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SideDiffEditorWidget::fileIndexForBlockNumber(int blockNumber) const
|
int SideDiffEditorWidget::fileIndexForBlockNumber(int blockNumber) const
|
||||||
|
@@ -587,7 +587,7 @@ int UnifiedDiffEditorWidget::blockNumberForFileIndex(int fileIndex) const
|
|||||||
if (fileIndex < 0 || fileIndex >= m_fileInfo.count())
|
if (fileIndex < 0 || fileIndex >= m_fileInfo.count())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return (m_fileInfo.constBegin() + fileIndex).key();
|
return std::next(m_fileInfo.constBegin(), fileIndex).key();
|
||||||
}
|
}
|
||||||
|
|
||||||
int UnifiedDiffEditorWidget::fileIndexForBlockNumber(int blockNumber) const
|
int UnifiedDiffEditorWidget::fileIndexForBlockNumber(int blockNumber) const
|
||||||
|
@@ -697,8 +697,13 @@ void FakeVimExCommandsPage::apply()
|
|||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
globalCommandMapping.clear();
|
globalCommandMapping.clear();
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
globalCommandMapping.insert(defaultMap);
|
||||||
|
globalCommandMapping.insert(newMapping);
|
||||||
|
#else
|
||||||
globalCommandMapping.unite(defaultMap);
|
globalCommandMapping.unite(defaultMap);
|
||||||
globalCommandMapping.unite(newMapping);
|
globalCommandMapping.unite(newMapping);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -950,8 +955,13 @@ void FakeVimUserCommandsPage::apply()
|
|||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
userMap.clear();
|
userMap.clear();
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||||
|
userMap.insert(dd->m_defaultUserCommandMap);
|
||||||
|
userMap.insert(current);
|
||||||
|
#else
|
||||||
userMap.unite(dd->m_defaultUserCommandMap);
|
userMap.unite(dd->m_defaultUserCommandMap);
|
||||||
userMap.unite(current);
|
userMap.unite(current);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -486,16 +486,16 @@ void TextEditorOverlay::mapEquivalentSelections()
|
|||||||
m_equivalentSelections.clear();
|
m_equivalentSelections.clear();
|
||||||
m_equivalentSelections.resize(m_selections.size());
|
m_equivalentSelections.resize(m_selections.size());
|
||||||
|
|
||||||
QMap<QString, int> all;
|
QMultiMap<QString, int> all;
|
||||||
for (int i = 0; i < m_selections.size(); ++i)
|
for (int i = 0; i < m_selections.size(); ++i)
|
||||||
all.insertMulti(selectionText(i).toLower(), i);
|
all.insert(selectionText(i).toLower(), i);
|
||||||
|
|
||||||
const QList<QString> &uniqueKeys = all.uniqueKeys();
|
const QList<QString> &uniqueKeys = all.uniqueKeys();
|
||||||
foreach (const QString &key, uniqueKeys) {
|
foreach (const QString &key, uniqueKeys) {
|
||||||
QList<int> indexes;
|
QList<int> indexes;
|
||||||
const auto cAll = all;
|
const auto cAll = all;
|
||||||
QMap<QString, int>::const_iterator lbit = cAll.lowerBound(key);
|
QMultiMap<QString, int>::const_iterator lbit = cAll.lowerBound(key);
|
||||||
QMap<QString, int>::const_iterator ubit = cAll.upperBound(key);
|
QMultiMap<QString, int>::const_iterator ubit = cAll.upperBound(key);
|
||||||
while (lbit != ubit) {
|
while (lbit != ubit) {
|
||||||
indexes.append(lbit.value());
|
indexes.append(lbit.value());
|
||||||
++lbit;
|
++lbit;
|
||||||
|
Reference in New Issue
Block a user