| digiKam Developer Documentation Professional Photo Management with the Power of Open Source

Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | List of all members
Digikam::ItemModel Class Reference
Inheritance diagram for Digikam::ItemModel:

## 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
ItemInfo | imageInfo (const QString &filePath) const
ItemInfo | imageInfo (int row) const
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
QModelIndex | indexForItemInfo (const ItemInfo &info, const QVariant &extraValue) const
QModelIndex | indexForPath (const QString &filePath) const
bool | isEmpty () const
bool | isRefreshing () const
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)
Public Member Functions inherited from Digikam::DragDropModelImplementation
| 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
Protected Attributes inherited from Digikam::DragDropModelImplementation
AbstractItemDragDropHandler * | m_dragDropHandler = nullptr

## Member Enumeration Documentation

## ◆ ItemModelRoles

enum Digikam::ItemModel::ItemModelRoles

Enumerator
ItemModelPointerRole | An ItemModel pointer to this model.
ThumbnailRole | Returns A thumbnail pixmap. May be implemented by subclasses. It's either a valid pixmap or a null QVariant.
CreationDateRole | Returns A QDateTime with the creation date
ExtraDataRole | Returns An 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.

## Member Function Documentation

## ◆ addItemInfo()

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.

Note
  These methods do not prevent addition of duplicate entries.

## ◆ addItemInfoSynchronously()

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.

Note
  These methods do not prevent addition of duplicate entries.

## ◆ allRefreshingFinished

void Digikam::ItemModel::allRefreshingFinished | ( |  | ) |
| signal

The model is in polished, clean situation right now.

## ◆ ensureHasItemInfo()

void Digikam::ItemModel::ensureHasItemInfo | ( | const ItemInfo & | info | ) |

Method returns immediately, the addition may happen later asynchronously. These methods prevent the addition of duplicate entries.

## ◆ imageInfo() [1/2]

ItemInfo Digikam::ItemModel::imageInfo | ( | const QModelIndex & | index | ) | const

Returns
  The ItemInfo object, reference or image id from the underlying data pointed to by the index. 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.

## ◆ imageInfo() [2/2]

ItemInfo Digikam::ItemModel::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).

Note
  imageInfoRef will crash if index is invalid.

## ◆ imageInfosAboutToBeAdded

void Digikam::ItemModel::imageInfosAboutToBeAdded | ( | const QList< ItemInfo > & | infos | ) |
| signal

This signal is sent before the model data is changed and views are informed.

## ◆ imageInfosAboutToBeRemoved

void Digikam::ItemModel::imageInfosAboutToBeRemoved | ( | const QList< ItemInfo > & | infos | ) |
| 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().

## ◆ imageInfosAdded

void Digikam::ItemModel::imageInfosAdded | ( | const QList< ItemInfo > & | infos | ) |
| signal

This signal is sent after the model data is changed and views are informed.

## ◆ imageInfosCleared()

virtual void Digikam::ItemModel::imageInfosCleared | ( |  | ) |
| inline protected virtual

Reimplemented in Digikam::ItemThumbnailModel, and Digikam::LightTableItemListModel.

## ◆ imageInfosRemoved

void Digikam::ItemModel::imageInfosRemoved | ( | const QList< ItemInfo > & | infos | ) |
| 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().

## ◆ indexForItemInfo()

QModelIndex Digikam::ItemModel::indexForItemInfo | ( | const ItemInfo & | info | ) | const

Returns
  The index for the given ItemInfo or id, if contained in this model.

## ◆ indexForPath()

QModelIndex Digikam::ItemModel::indexForPath | ( | const QString & | filePath | ) | const

Returns
  The index or ItemInfo object from the underlying data for the given file path. 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.

## ◆ isRefreshing()

bool Digikam::ItemModel::isRefreshing | ( |  | ) | const

Returns
  True if this model is currently refreshing. For a preprocessor this means that, although the preprocessor may currently have processed all it got, more batches are to be expected.

## ◆ prepareImageInfosAboutToBeRemoved()

virtual void Digikam::ItemModel::prepareImageInfosAboutToBeRemoved | ( | int | ,
|  | int |
| ) |  |
| inline protected virtual

Reimplemented in Digikam::LightTableItemListModel.

## ◆ readyForIncrementalRefresh

void Digikam::ItemModel::readyForIncrementalRefresh | ( |  | ) |
| signal

This is guaranteed only for the scope of emitting this signal.

## ◆ requestIncrementalRefresh()

void Digikam::ItemModel::requestIncrementalRefresh | ( |  | ) |
| protected

The signal will be emitted inline if the model is ready right now.

## ◆ retrieveItemInfo()

ItemInfo Digikam::ItemModel::retrieveItemInfo | ( | const QModelIndex & | index | ) |
| static

The index may be from a QSortFilterProxyModel as long as an ItemModel is at the end.

## ◆ setKeepsFilePathCache()

void Digikam::ItemModel::setKeepsFilePathCache | ( | bool | keepCache | ) |

Default is false.

## ◆ setPreprocessor()

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 re-add 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.

## ◆ setSendRemovalSignals()

void Digikam::ItemModel::setSendRemovalSignals | ( | bool | send | ) |

Default is false

## ◆ setWatchFlags()

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).

## ◆ startIncrementalRefresh()

void Digikam::ItemModel::startIncrementalRefresh | ( |  | ) |
| protected

You shall only call this method from a slot connected to readyForIncrementalRefresh(). To initiate an incremental refresh, call requestIncrementalRefresh().

## ◆ startRefresh()

void Digikam::ItemModel::startRefresh | ( |  | ) |
| protected

No incremental refreshes will be started while listing. A clearItemInfos() always stops listing, calling finishRefresh() is then not necessary.