![]() |
digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
|
Public Types | |
enum | ItemModelRoles { ItemModelPointerRole = Qt::UserRole , ItemModelInternalId = Qt::UserRole + 1 , ThumbnailRole = Qt::UserRole + 2 , CreationDateRole = Qt::UserRole + 3 , ExtraDataRole = Qt::UserRole + 5 , ExtraDataDuplicateCount = Qt::UserRole + 6 , LTLeftPanelRole = Qt::UserRole + 50 , LTRightPanelRole = Qt::UserRole + 51 , SubclassRoles = Qt::UserRole + 100 , FilterModelRoles = Qt::UserRole + 500 } |
Public Slots | |
void | reAddingFinished () |
void | reAddItemInfos (const QList< ItemInfo > &infos, const QList< QVariant > &extraValues) |
Signals | |
void | allRefreshingFinished () |
Signals that the model has finished currently with all scheduled refreshing, full or incremental, and all preprocessing. | |
void | imageChange (const ImageChangeset &, const QItemSelection &) |
If an ImageChangeset affected indexes of this model with changes as set in watchFlags(), this signal contains the changeset and the affected indexes. | |
void | imageInfosAboutToBeAdded (const QList< ItemInfo > &infos) |
Informs that ItemInfos will be added to the model. | |
void | imageInfosAboutToBeRemoved (const QList< ItemInfo > &infos) |
Informs that ItemInfos will be removed from the model. | |
void | imageInfosAdded (const QList< ItemInfo > &infos) |
Informs that ItemInfos have been added to the model. | |
void | imageInfosRemoved (const QList< ItemInfo > &infos) |
Informs that ItemInfos have been removed from the model. | |
void | imageTagChange (const ImageTagChangeset &, const QItemSelection &) |
If an ImageTagChangeset affected indexes of this model, this signal contains the changeset and the affected indexes. | |
void | preprocess (const QList< ItemInfo > &infos, const QList< QVariant > &) |
Connect to this signal only if you are the current preprocessor. | |
void | processAdded (const QList< ItemInfo > &infos, const QList< QVariant > &) |
void | readyForIncrementalRefresh () |
Signals that the model is right now ready to start an incremental refresh. | |
Public Member Functions | |
ItemModel (QObject *const parent=nullptr) | |
void | addItemInfo (const ItemInfo &info) |
Main entry point for subclasses adding image infos to the model. | |
void | addItemInfos (const QList< ItemInfo > &infos) |
void | addItemInfos (const QList< ItemInfo > &infos, const QList< QVariant > &extraValues) |
void | addItemInfosSynchronously (const QList< ItemInfo > &infos) |
void | addItemInfosSynchronously (const QList< ItemInfo > &infos, const QList< QVariant > &extraValues) |
void | addItemInfoSynchronously (const ItemInfo &info) |
addItemInfo() is asynchronous if a prepocessor is set. | |
void | clearItemInfos () |
Clears image infos and resets model. | |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
void | ensureHasGroupedImages (const ItemInfo &groupLeader) |
Ensure that all images grouped on the given leader are contained in the model. | |
void | ensureHasItemInfo (const ItemInfo &info) |
Add the given entries. | |
void | ensureHasItemInfos (const QList< ItemInfo > &infos) |
void | ensureHasItemInfos (const QList< ItemInfo > &infos, const QList< QVariant > &extraValues) |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
bool | hasImage (const ItemInfo &info) const |
bool | hasImage (const ItemInfo &info, const QVariant &extraValue) const |
bool | hasImage (qlonglong id) const |
bool | hasImage (qlonglong id, const QVariant &extraValue) const |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
qlonglong | imageId (const QModelIndex &index) const |
qlonglong | imageId (int row) const |
QList< qlonglong > | imageIds () const |
QList< qlonglong > | imageIds (const QList< QModelIndex > &indexes) const |
ItemInfo | imageInfo (const QModelIndex &index) const |
Returns the ItemInfo object, reference or image id from the underlying data pointed to by the index. | |
ItemInfo | imageInfo (const QString &filePath) const |
ItemInfo | imageInfo (int row) const |
Returns the ItemInfo object, reference or image id from the underlying data of the given row (parent is the invalid QModelIndex, column is 0). | |
ItemInfo & | imageInfoRef (const QModelIndex &index) const |
ItemInfo & | imageInfoRef (int row) const |
QList< ItemInfo > | imageInfos () const |
QList< ItemInfo > | imageInfos (const QList< QModelIndex > &indexes) const |
QList< ItemInfo > | imageInfos (const QString &filePath) const |
QModelIndex | index (int row, int column=0, const QModelIndex &parent=QModelIndex()) const override |
QList< QModelIndex > | indexesForImageId (qlonglong id) const |
QList< QModelIndex > | indexesForItemInfo (const ItemInfo &info) const |
QList< QModelIndex > | indexesForPath (const QString &filePath) const |
QModelIndex | indexForImageId (qlonglong id) const |
QModelIndex | indexForImageId (qlonglong id, const QVariant &extraValue) const |
QModelIndex | indexForItemInfo (const ItemInfo &info) const |
Return the index for the given ItemInfo or id, if contained in this model. | |
QModelIndex | indexForItemInfo (const ItemInfo &info, const QVariant &extraValue) const |
QModelIndex | indexForPath (const QString &filePath) const |
Returns the index or ItemInfo object from the underlying data for the given file path. | |
bool | isEmpty () const |
bool | isRefreshing () const |
Returns true if this model is currently refreshing. | |
int | itemCount () const |
bool | keepsFilePathCache () const |
int | numberOfIndexesForImageId (qlonglong id) const |
int | numberOfIndexesForItemInfo (const ItemInfo &info) const |
void | removeIndex (const QModelIndex &indexes) |
Directly remove the given indexes or infos from the model. | |
void | removeIndexes (const QList< QModelIndex > &indexes) |
void | removeItemInfo (const ItemInfo &info) |
void | removeItemInfos (const QList< ItemInfo > &infos) |
void | removeItemInfos (const QList< ItemInfo > &infos, const QList< QVariant > &extraValues) |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
void | setItemInfos (const QList< ItemInfo > &infos) |
Clears and adds the infos. | |
void | setKeepsFilePathCache (bool keepCache) |
If a cache is kept, lookup by file path is fast, without a cache it is O(n). | |
DECLARE_MODEL_DRAG_DROP_METHODS void | setPreprocessor (QObject *const processor) |
Install an object as a preprocessor for ItemInfos added to this model. | |
void | setSendRemovalSignals (bool send) |
Enable sending of imageInfosAboutToBeRemoved and imageInfosRemoved signals. | |
void | setWatchFlags (const DatabaseFields::Set &set) |
Set a set of database fields to watch. | |
QList< ItemInfo > | uniqueItemInfos () const |
void | unsetPreprocessor (QObject *const processor) |
![]() | |
DragDropModelImplementation ()=default | |
A class providing a sample implementation for a QAbstractItemModel redirecting drag-and-drop support to a handler. | |
virtual Qt::ItemFlags | dragDropFlags (const QModelIndex &index) const |
Call from your flags() method, adding the relevant drag drop flags. | |
Qt::ItemFlags | dragDropFlagsV2 (const QModelIndex &index) const |
This is an alternative approach to dragDropFlags(). | |
AbstractItemDragDropHandler * | dragDropHandler () const |
bool | dropMimeData (const QMimeData *, Qt::DropAction, int, int, const QModelIndex &) |
virtual bool | isDragEnabled (const QModelIndex &index) const |
virtual bool | isDropEnabled (const QModelIndex &index) const |
QMimeData * | mimeData (const QModelIndexList &indexes) const |
QStringList | mimeTypes () const |
void | setDragDropHandler (AbstractItemDragDropHandler *handler) |
Set a drag drop handler. | |
Qt::DropActions | supportedDropActions () const |
Implements the relevant QAbstractItemModel methods for drag and drop. | |
Static Public Member Functions | |
static qlonglong | retrieveImageId (const QModelIndex &index) |
static ItemInfo | retrieveItemInfo (const QModelIndex &index) |
Retrieves the imageInfo object from the data() method of the given index. | |
Protected Slots | |
virtual void | slotAlbumChange (const AlbumChangeset &changeset) |
virtual void | slotImageChange (const ImageChangeset &changeset) |
virtual void | slotImageTagChange (const ImageTagChangeset &changeset) |
Protected Member Functions | |
void | emitDataChangedForAll () |
void | emitDataChangedForSelection (const QItemSelection &selection) |
void | finishIncrementalRefresh () |
void | finishRefresh () |
bool | hasIncrementalRefreshPending () const |
virtual void | imageInfosCleared () |
Called when the internal storage is cleared. | |
virtual void | prepareImageInfosAboutToBeRemoved (int, int) |
Called before rowsAboutToBeRemoved. | |
void | requestIncrementalRefresh () |
As soon as the model is ready to start an incremental refresh, the signal readyForIncrementalRefresh() will be emitted. | |
void | startIncrementalRefresh () |
Starts an incremental refresh operation. | |
void | startRefresh () |
Subclasses that add ItemInfos in batches shall call startRefresh() when they start sending batches and finishRefresh() when they have finished. | |
Additional Inherited Members | |
![]() | |
AbstractItemDragDropHandler * | m_dragDropHandler = nullptr |
Enumerator | |
---|---|
ItemModelPointerRole | An ItemModel* pointer to this model. |
ThumbnailRole | Returns a thumbnail pixmap. May be implemented by subclasses. Returns either a valid pixmap or a null QVariant. |
CreationDateRole | Returns a QDateTime with the creation date. |
ExtraDataRole | Return (optional) extraData field. |
ExtraDataDuplicateCount | Returns the number of duplicate indexes for the same image id. |
LTLeftPanelRole | Roles which are defined here but not implemented by ItemModel Returns position of item in Left Light Table preview. |
LTRightPanelRole | Returns position of item in Right Light Table preview. |
SubclassRoles | For use by subclasses. |
FilterModelRoles | For use by filter models. |
void Digikam::ItemModel::addItemInfo | ( | const ItemInfo & | info | ) |
If you list entries not unique per image id, you must add an extraValue so that every entry is unique by imageId and extraValues. Please note that these methods do not prevent addition of duplicate entries.
void Digikam::ItemModel::addItemInfoSynchronously | ( | const ItemInfo & | info | ) |
This method first adds the info, synchronously. Only afterwards, the preprocessor will have the opportunity to process it. This method also bypasses any incremental updates. Please note that these methods do not prevent addition of duplicate entries.
|
signal |
The model is in polished, clean situation right now.
void Digikam::ItemModel::ensureHasItemInfo | ( | const ItemInfo & | info | ) |
Method returns immediately, the addition may happen later asynchronously. These methods prevent the addition of duplicate entries.
ItemInfo Digikam::ItemModel::imageInfo | ( | const QModelIndex & | index | ) | const |
If the index is not valid, imageInfo will return a null ItemInfo, imageId will return 0, imageInfoRef must not be called with an invalid index.
ItemInfo Digikam::ItemModel::imageInfo | ( | int | row | ) | const |
Note that imageInfoRef will crash if index is invalid.
|
signal |
This signal is sent before the model data is changed and views are informed.
|
signal |
This signal is sent before the model data is changed and views are informed. Note: You need to explicitly enable sending of this signal. It is not sent in clearItemInfos().
|
signal |
This signal is sent after the model data is changed and views are informed.
|
inlineprotectedvirtual |
Reimplemented in Digikam::ItemThumbnailModel.
|
signal |
This signal is sent after the model data is changed and views are informed. * Note: You need to explicitly enable sending of this signal. It is not sent in clearItemInfos().
QModelIndex Digikam::ItemModel::indexForPath | ( | const QString & | filePath | ) | const |
This is fast if keepsFilePathCache is enabled. The file path is as returned by ItemInfo.filePath(). In case of multiple occurrences of the same file, the simpler variants return any one found first, use the QList methods to retrieve all occurrences.
bool Digikam::ItemModel::isRefreshing | ( | ) | const |
For a preprocessor this means that, although the preprocessor may currently have processed all it got, more batches are to be expected.
|
signal |
This is guaranteed only for the scope of emitting this signal.
|
protected |
The signal will be emitted inline if the model is ready right now.
|
static |
The index may be from a QSortFilterProxyModel as long as an ItemModel is at the end.
void Digikam::ItemModel::setKeepsFilePathCache | ( | bool | keepCache | ) |
Default is false.
void Digikam::ItemModel::setPreprocessor | ( | QObject *const | processor | ) |
For every QList of ItemInfos added to addItemInfo, the signal preprocess() will be emitted. The preprocessor may process the items and shall then readd them by calling reAddItemInfos(). It may take some time to process. It shall discard any held infos when the modelReset() signal is sent. It shall call readdFinished() when no reset occurred and all infos on the way have been readded. This means that only after calling this method, you shall make three connections (preprocess -> your slot, your signal -> reAddItemInfos, your signal -> reAddingFinished) and make or already hold a connection modelReset() -> your slot. There is only one preprocessor at a time, a previously set object will be disconnected.
void Digikam::ItemModel::setSendRemovalSignals | ( | bool | send | ) |
Default: false
void Digikam::ItemModel::setWatchFlags | ( | const DatabaseFields::Set & | set | ) |
If either of these is changed, dataChanged() will be emitted. Default is no flag (no signal will be emitted).
|
protected |
You shall only call this method from a slot connected to readyForIncrementalRefresh(). To initiate an incremental refresh, call requestIncrementalRefresh().
|
protected |
No incremental refreshes will be started while listing. A clearItemInfos() always stops listing, calling finishRefresh() is then not necessary.