diff --git a/src/GUI/AircraftModel.cxx b/src/GUI/AircraftModel.cxx index beeb26d9c..54ca58ea8 100644 --- a/src/GUI/AircraftModel.cxx +++ b/src/GUI/AircraftModel.cxx @@ -289,6 +289,11 @@ QVariant AircraftItemModel::dataFromItem(AircraftItemPtr item, const DelegateSta if (role >= AircraftVariantDescriptionRole) { int variantIndex = role - AircraftVariantDescriptionRole; + if (variantIndex == 0) { + return item->description; + } + + Q_ASSERT(variantIndex < item->variants.size()); return item->variants.at(variantIndex)->description; } @@ -471,7 +476,7 @@ QVariant AircraftItemModel::packageThumbnail(PackageRef p, const DelegateState& bool AircraftItemModel::setData(const QModelIndex &index, const QVariant &value, int role) { int row = index.row(); - int newValue = value.toInt(); + quint32 newValue = value.toUInt(); if (role == AircraftVariantRole) { if (m_delegateStates[row].variant == newValue) { diff --git a/src/GUI/AircraftSearchFilterModel.cxx b/src/GUI/AircraftSearchFilterModel.cxx index bd26107c0..a906f5cd0 100644 --- a/src/GUI/AircraftSearchFilterModel.cxx +++ b/src/GUI/AircraftSearchFilterModel.cxx @@ -10,7 +10,11 @@ AircraftProxyModel::AircraftProxyModel(QObject *pr, QAbstractItemModel * source) setSourceModel(source); setSortCaseSensitivity(Qt::CaseInsensitive); setFilterCaseSensitivity(Qt::CaseInsensitive); - setSortRole(Qt::DisplayRole); + + // important we sort on the primary name role and not Qt::DisplayRole + // otherwise the aircraft jump when switching variant + setSortRole(AircraftVariantDescriptionRole); + setDynamicSortFilter(true); // kick off initial sort