16 #include <QItemSelectionModel>
31 : QSortFilterProxyModel( parent )
33 , mFilterMode( ShowAll )
34 , mSelectedOnTop( false )
37 setDynamicSortFilter(
true );
39 connect(
layer(), SIGNAL( selectionChanged() ), SLOT( selectionChanged() ) );
49 if ( leftSelected && !rightSelected )
53 else if ( rightSelected && !leftSelected )
63 if ( leftData.isNull() )
66 if ( rightData.isNull() )
69 switch ( leftData.type() )
73 case QVariant::LongLong:
74 case QVariant::ULongLong:
75 return leftData.toLongLong() < rightData.toLongLong();
77 case QVariant::Double:
78 return leftData.toDouble() < rightData.toDouble();
81 return leftData.toDate() < rightData.toDate();
83 case QVariant::DateTime:
84 return leftData.toDateTime() < rightData.toDateTime();
87 return leftData.toString().localeAwareCompare( rightData.toString() ) < 0;
102 if ( mSelectedOnTop != selectedOnTop )
106 if ( sortColumn() == -1 )
116 mTableModel = sourceModel;
123 return mSelectedOnTop;
128 mFilteredFeatures = ids;
136 for (
int i = 0; i < rowCount(); ++i )
138 QModelIndex row =
index( i, 0 );
146 if ( filterMode != mFilterMode )
170 Q_UNUSED( sourceParent );
171 switch ( mFilterMode )
190 const QList<QgsFeatureId> addedFeatures = editBuffer->
addedFeatures().keys();
193 return addedFeatures.contains( fid ) || changedFeatures.contains( fid );
211 void QgsAttributeTableFilterModel::selectionChanged()
218 else if ( mSelectedOnTop )
220 sort( sortColumn(), sortOrder() );
235 mFilteredFeatures.clear();
244 if (
layer()->hasScaleBasedVisibility() &&
285 mFilteredFeatures << f.
id();
288 if ( t.elapsed() > 5000 )
291 emit progress( i, cancel );
320 QModelIndexList indexes;
321 foreach ( QModelIndex idx,
masterModel()->idToIndexList( fid ) )
332 return mapToSource( proxyIndex );
338 return mapFromSource( sourceIndex );