@@ -40,7 +40,7 @@ void SelectionFilterModel::load()
40
40
beginResetModel ();
41
41
42
42
m_types.clear ();
43
- m_types << SelectionFilterType::ALL ;
43
+ m_types << SelectionFilterType::ALL_NOTATION_ELEMENTS ;
44
44
45
45
for (size_t i = 0 ; i < mu::engraving::NUMBER_OF_SELECTION_FILTER_TYPES; i++) {
46
46
m_types << static_cast <SelectionFilterType>(1 << i);
@@ -81,8 +81,12 @@ QVariant SelectionFilterModel::data(const QModelIndex& index, int role) const
81
81
return isFiltered (type);
82
82
83
83
case IsIndeterminateRole:
84
- if (type == SelectionFilterType::ALL) {
85
- return !isFiltered (SelectionFilterType::ALL) && !isFiltered (SelectionFilterType::NONE);
84
+ if (type == SelectionFilterType::ALL_NOTATION_ELEMENTS) {
85
+ const unsigned int masked = filteredTypes () & static_cast <int >(SelectionFilterType::ALL_NOTATION_ELEMENTS);
86
+ const bool hasNonZeroNotationElements = masked != static_cast <int >(SelectionFilterType::NONE);
87
+
88
+ // Indeterminate if some notation elements types are selected, but not all...
89
+ return hasNonZeroNotationElements && !isFiltered (SelectionFilterType::ALL_NOTATION_ELEMENTS);
86
90
}
87
91
88
92
return false ;
@@ -110,7 +114,7 @@ bool SelectionFilterModel::setData(const QModelIndex& index, const QVariant& dat
110
114
const bool filtered = data.toBool ();
111
115
112
116
setFiltered (type, filtered);
113
- if (type == SelectionFilterType::ALL ) {
117
+ if (type == SelectionFilterType::ALL_NOTATION_ELEMENTS ) {
114
118
emit dataChanged (this ->index (0 ), this ->index (rowCount () - 1 ), { IsSelectedRole, IsIndeterminateRole });
115
119
} else {
116
120
emit dataChanged (this ->index (0 ), this ->index (0 ), { IsSelectedRole, IsIndeterminateRole });
@@ -157,6 +161,11 @@ INotationInteractionPtr SelectionFilterModel::currentNotationInteraction() const
157
161
return currentNotation () ? currentNotation ()->interaction () : nullptr ;
158
162
}
159
163
164
+ unsigned int SelectionFilterModel::filteredTypes () const
165
+ {
166
+ return currentNotationInteraction () ? currentNotationInteraction ()->currentSelectionFilter () : 0 ;
167
+ }
168
+
160
169
bool SelectionFilterModel::isFiltered (SelectionFilterType type) const
161
170
{
162
171
return currentNotationInteraction () ? currentNotationInteraction ()->isSelectionTypeFiltered (type) : false ;
@@ -172,7 +181,7 @@ void SelectionFilterModel::setFiltered(SelectionFilterType type, bool filtered)
172
181
QString SelectionFilterModel::titleForType (SelectionFilterType type) const
173
182
{
174
183
switch (type) {
175
- case SelectionFilterType::ALL :
184
+ case SelectionFilterType::ALL_NOTATION_ELEMENTS :
176
185
return muse::qtrc (" notation" , " All" );
177
186
case SelectionFilterType::FIRST_VOICE:
178
187
return muse::qtrc (" notation" , " Voice %1" ).arg (1 );
@@ -220,8 +229,7 @@ QString SelectionFilterModel::titleForType(SelectionFilterType type) const
220
229
return muse::qtrc (" notation" , " Tremolos" );
221
230
case SelectionFilterType::GRACE_NOTE:
222
231
return muse::qtrc (" notation" , " Grace notes" );
223
- case SelectionFilterType::NONE:
224
- break ;
232
+ default : break ;
225
233
}
226
234
227
235
return {};
0 commit comments