Skip to content

Commit

Permalink
Fix value relation editor widget serious warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jul 2, 2024
1 parent dd0f49a commit f6e28b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
20 changes: 9 additions & 11 deletions src/core/featurechecklistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,25 +206,23 @@ void FeatureCheckListModel::toggleCheckAll( const bool toggleChecked )
}
}

void FeatureCheckListModel::setChecked( const QModelIndex &index )
void FeatureCheckListModel::setChecked( const QModelIndex &idx )
{
beginResetModel();

if ( !mAllowMulti )
{
mCheckedEntries.clear();
emit dataChanged( index( 0, 0, QModelIndex() ), index( rowCount() - 1, 0, QModelIndex() ), QList<int>() << CheckedRole );
}

mCheckedEntries.append( FeatureListModel::data( index, FeatureListModel::KeyFieldRole ).toString() );
endResetModel();

mCheckedEntries.append( FeatureListModel::data( idx, FeatureListModel::KeyFieldRole ).toString() );
emit dataChanged( idx, idx, QList<int>() << CheckedRole );
emit listUpdated();
}

void FeatureCheckListModel::setUnchecked( const QModelIndex &index )
void FeatureCheckListModel::setUnchecked( const QModelIndex &idx )
{
beginResetModel();
mCheckedEntries.removeAll( FeatureListModel::data( index, FeatureListModel::KeyFieldRole ).toString() );
endResetModel();

mCheckedEntries.removeAll( FeatureListModel::data( idx, FeatureListModel::KeyFieldRole ).toString() );
emit dataChanged( idx, idx, QList<int>() << CheckedRole );
emit listUpdated();
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/featurechecklistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class FeatureCheckListModel : public FeatureListModel
void listUpdated();

private:
void setChecked( const QModelIndex &index );
void setUnchecked( const QModelIndex &index );
void setChecked( const QModelIndex &idx );
void setUnchecked( const QModelIndex &idx );
QMetaType::Type fkType() const;

QgsField mAttributeField;
Expand Down
6 changes: 1 addition & 5 deletions src/qml/editorwidgets/ValueRelation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ EditorWidgetBase {

checked: model.checked

onCheckedChanged: {
model.checked = checked
}

indicator.height: 16
indicator.width: 16
indicator.implicitHeight: 24
Expand Down Expand Up @@ -147,7 +143,7 @@ EditorWidgetBase {

onClicked: {
if (isEnabled) {
checkBox.checked = !checkBox.checked
model.checked = !model.checked
}
}
}
Expand Down

1 comment on commit f6e28b2

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.