17 #ifndef QGSATTRIBUTETABLEMODEL_H
18 #define QGSATTRIBUTETABLEMODEL_H
20 #include <QAbstractTableModel>
22 #include <QModelIndex>
56 FeatureIdRole = Qt::UserRole,
76 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
82 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
90 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
97 QVariant data(
const QModelIndex &index,
int role )
const override;
105 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
111 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
118 void reload(
const QModelIndex &index1,
const QModelIndex &index2 );
123 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
145 int fieldIdx(
int col )
const;
150 int fieldCol(
int idx )
const;
178 void executeAction( QUuid action,
const QModelIndex &idx )
const;
183 void executeMapLayerAction(
QgsMapLayerAction *action,
const QModelIndex &idx )
const;
189 QgsFeature feature(
const QModelIndex &idx )
const;
198 void prefetchColumnData(
int column );
206 void prefetchSortData(
const QString &expression,
unsigned long cacheIndex = 0 );
213 QString sortCacheExpression(
unsigned long cacheIndex = 0 )
const;
251 int extraColumns()
const;
257 void setExtraColumns(
int extraColumns );
265 virtual void loadLayer();
272 void fieldConditionalStyleChanged(
const QString &fieldName );
282 void progress(
int i,
bool &cancel )
SIP_SKIP;
290 virtual void updatedFields();
297 virtual void editCommandEnded();
302 virtual void attributeDeleted(
int idx );
310 virtual void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
327 virtual void layerDeleted();
339 QVector<QgsEditorWidgetFactory *> mWidgetFactories;
340 QVector<QgsFieldFormatter *> mFieldFormatters;
341 QVector<QVariant> mAttributeWidgetCaches;
342 QVector<QVariantMap> mWidgetConfigs;
344 QHash<QgsFeatureId, int> mIdRowMap;
345 QHash<int, QgsFeatureId> mRowIdMap;
346 mutable QHash<QgsFeatureId, QList<QgsConditionalStyle> > mRowStylesMap;
353 virtual void loadAttributes();
374 QHash<QgsFeatureId, QVariant> sortCache;
377 std::vector<SortCache> mSortCaches;
381 int mExtraColumns = 0;
384 bool mBulkEditCommandRunning =
false;
387 bool mResettingModel =
false;
390 void bulkEditCommandStarted();
393 void bulkEditCommandEnded();
396 QMap<QPair<QgsFeatureId, int>, QVariant> mAttributeValueChanges;
399 QList<QgsFeatureId> mInsertedRowsChanges;
402 bool mIsCleaningUpAfterRollback =
false;
404 friend class TestQgsAttributeTable;