summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMakePresetItemModel.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-02-20 22:23:11 (GMT)
committerBrad King <brad.king@kitware.com>2023-02-20 22:55:49 (GMT)
commit5cda8a399398020bba462bbf70609d3a37bb8c18 (patch)
tree88f28b0c01519394279300fbbed0bea298792058 /Source/QtDialog/QCMakePresetItemModel.cxx
parentd18806e67336d96a9a22b860246de3f1c518ce40 (diff)
downloadCMake-5cda8a399398020bba462bbf70609d3a37bb8c18.zip
CMake-5cda8a399398020bba462bbf70609d3a37bb8c18.tar.gz
CMake-5cda8a399398020bba462bbf70609d3a37bb8c18.tar.bz2
cmake-gui: Fix conversion warnings about Qt indexing types
Qt 5 uses `int` for indexing, and Qt 6 uses `qsizetype`. Add helper types and casts to the appropriate type to avoid conversion warnings.
Diffstat (limited to 'Source/QtDialog/QCMakePresetItemModel.cxx')
-rw-r--r--Source/QtDialog/QCMakePresetItemModel.cxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/Source/QtDialog/QCMakePresetItemModel.cxx b/Source/QtDialog/QCMakePresetItemModel.cxx
index 7ada2a5..31a6000 100644
--- a/Source/QtDialog/QCMakePresetItemModel.cxx
+++ b/Source/QtDialog/QCMakePresetItemModel.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "QCMakePresetItemModel.h"
+#include "QCMakeSizeType.h"
#include <QFont>
QCMakePresetItemModel::QCMakePresetItemModel(QObject* parent)
@@ -27,7 +28,8 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const
if (index.internalId() == SEPARATOR_INDEX) {
return QVariant{};
}
- auto const& preset = this->m_presets[index.internalId()];
+ auto const& preset =
+ this->m_presets[static_cast<cm_qsizetype>(index.internalId())];
return preset.displayName.isEmpty() ? preset.name : preset.displayName;
}
case Qt::ToolTipRole:
@@ -37,7 +39,8 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const
if (index.internalId() == SEPARATOR_INDEX) {
return QVariant{};
}
- return this->m_presets[index.internalId()].description;
+ return this->m_presets[static_cast<cm_qsizetype>(index.internalId())]
+ .description;
case Qt::UserRole:
if (index.internalId() == CUSTOM_INDEX) {
return QVariant{};
@@ -45,7 +48,8 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const
if (index.internalId() == SEPARATOR_INDEX) {
return QVariant{};
}
- return QVariant::fromValue(this->m_presets[index.internalId()]);
+ return QVariant::fromValue(
+ this->m_presets[static_cast<cm_qsizetype>(index.internalId())]);
case Qt::FontRole:
if (index.internalId() == CUSTOM_INDEX) {
QFont font;
@@ -64,7 +68,8 @@ Qt::ItemFlags QCMakePresetItemModel::flags(const QModelIndex& index) const
Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
if (index.internalId() != SEPARATOR_INDEX &&
(index.internalId() == CUSTOM_INDEX ||
- this->m_presets[index.internalId()].enabled)) {
+ this->m_presets[static_cast<cm_qsizetype>(index.internalId())]
+ .enabled)) {
flags |= Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
return flags;
@@ -78,7 +83,7 @@ int QCMakePresetItemModel::rowCount(const QModelIndex& parent) const
if (this->m_presets.empty()) {
return 1;
}
- return this->m_presets.size() + 2;
+ return static_cast<int>(this->m_presets.size() + 2);
}
int QCMakePresetItemModel::columnCount(const QModelIndex& parent) const
@@ -139,5 +144,5 @@ int QCMakePresetItemModel::presetNameToRow(const QString& name) const
index++;
}
- return this->m_presets.size() + 1;
+ return static_cast<int>(this->m_presets.size() + 1);
}