Fix jumping aircraft when selecting variants
Always sort on the primary aircraft name, otherwise select a variant triggers a re-sort of the list which is confusing for the user.
This commit is contained in:
parent
a311e744ff
commit
8f9afcd796
2 changed files with 11 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue