digiKam Developer Documentation: Digikam::RGTagModel Class Reference

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

Loading...
Searching...
No Matches
Public Slots | Public Member Functions | List of all members
Digikam::RGTagModel Class Reference

The model that holds data for the tag tree displayed in ReverseGeocodingWidget. More...

Inheritance diagram for Digikam::RGTagModel:

## Public Slots
void | slotColumnsAboutToBeInserted (const QModelIndex &parent, int start, int end)
void | slotColumnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
void | slotColumnsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
void | slotColumnsInserted ()
void | slotColumnsMoved ()
void | slotColumnsRemoved ()
void | slotLayoutAboutToBeChanged ()
void | slotLayoutChanged ()
void | slotModelAboutToBeReset ()
void | slotModelReset ()
void | slotRowsAboutToBeInserted (const QModelIndex &parent, int start, int end)
void | slotRowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
void | slotRowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
void | slotRowsInserted ()
void | slotRowsMoved ()
void | slotRowsRemoved ()
void | slotSourceDataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
void | slotSourceHeaderDataChanged (const Qt::Orientation orientation, int first, int last)

## Public Member Functions
| RGTagModel (QAbstractItemModel *const externalTagModel, QObject *const parent=nullptr)
| Constructor.
| ~RGTagModel () override
| Destructor.
void | addAllExternalTagsToTreeView ()
| Add all external tags to the tag tree.
void | addAllSpacersToTag (const QModelIndex &currentIndex, const QStringList &spacerList, int spacerListIndex)
| Adds all spacers found in spacerList to the tag tree.
void | addDataInTree (TreeBranch *currentBranch, int currentRow, const QStringList &addressElements, const QStringList &elementsData)
| The function starts to scan the tree starting with currentBranch.
void | addExternalTags (TreeBranch *parentBranch, int currentRow)
| Add tags from host application to the tag tree.
QList< QList< TagData > > | addNewData (const QStringList &elements, const QStringList &resultedData)
| Add new tags to tag tree.
QPersistentModelIndex | addNewTag (const QModelIndex &parent, const QString &newTagName, const QString &newElement)
| Adds a tag containing data returned from backends.
void | addSpacerTag (const QModelIndex &parent, const QString &spacerName)
| Adds a spacer tag.
TreeBranch * | branchFromIndex (const QModelIndex &index) const
| Returns the branch found at index.
void | climbTreeAndGetSpacers (const TreeBranch *currentBranch)
| Gets the spacers addresses below currentBranch.
int | columnCount (const QModelIndex &parent=QModelIndex()) const override
| QAbstractItemModel.
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override
void | deleteAllSpacersOrNewTags (const QModelIndex &currentIndex, Type whatShouldRemove)
| Deletes all spacers or all new tags.
void | deleteTag (const QModelIndex &currentIndex)
| Deletes a tag.
void | findAndDeleteSpacersOrNewTags (TreeBranch *currentBranch, int currentRow, Type whatShouldRemove)
| Deletes all spacers or all new tags below current branch.
Qt::ItemFlags | flags (const QModelIndex &index) const override
QModelIndex | fromSourceIndex (const QModelIndex &externalTagModelIndex) const
| Local functions.
QList< TagData > | getSpacerAddress (TreeBranch *currentBranch)
| Gets the address of a spacer.
QList< QList< TagData > > | getSpacers ()
| Gets all spacers.
QList< TagData > | getTagAddress ()
| Gets the address of a tag.
Type | getTagType (const QModelIndex &index) const
| Gets the type of a tag found at index.
QVariant | headerData (int section, Qt::Orientation orientation, int role) const override
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
QModelIndex | parent (const QModelIndex &index) const override
void | readdNewTags (const QList< QList< TagData > > &tagAddressList)
| Takes each tag contained in tagAddressList and adds it to the tag tree.
void | readdTag (TreeBranch *&currentBranch, int currentRow, const QList< TagData > &tagAddressElements, int currentAddressElementIndex)
| Reads new tags to tag tree.
int | rowCount (const QModelIndex &parent=QModelIndex()) const override
bool | setData (const QModelIndex &index, const QVariant &value, int role) override
bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role) override
QModelIndex | toSourceIndex (const QModelIndex &tagModelIndex) const
| Translates the model index from this model to host's tag model.

## Detailed Description

The RGTagModel class is a wrapper above QAbstractItemModel. It helds data for the tag tree displayed in ReverseGeocodingWidget. The model gets the data from the tag model of host application and displays it in a QTreeView. It stores three type of tags: old tags (the tags that belong to the host's tag model), spacer tags (tags representing address elements or custom tags) and new tags (tags containing data retrieved from backend).

## Constructor & Destructor Documentation

## ◆ RGTagModel()

Digikam::RGTagModel::RGTagModel | ( | QAbstractItemModel *const | externalTagModel,
|  | QObject *const | parent = `nullptr`
| ) |  |
| explicit

Parameters

  externalTagModel | The tag model found in the host application.
  parent | The parent object

## Member Function Documentation

## ◆ addDataInTree()

void Digikam::RGTagModel::addDataInTree | ( | TreeBranch * | currentBranch,
|  | int | currentRow,
|  | const QStringList & | addressElements,
|  | const QStringList & | elementsData
| ) |  |

When it finds a spacer containing an address element, it looks to see if the address element is found in addressElements list. If it's found, a new tag is added.

Parameters

  currentBranch | The branch from where the scan starts.
  currentRow | The row of the current branch.
  addressElements | A list containing address elements. Example: {Country}, {City}...
  elementsData | A list containing the name of each address element found in elements. Example: France, Paris...

## ◆ addExternalTags()

void Digikam::RGTagModel::addExternalTags | ( | TreeBranch * | parentBranch,
|  | int | currentRow
| ) |  |

Parameters

  parentBranch | The branch that will be parent for the old tag.
  currentRow | The row where this external tag will be added.

## ◆ addNewData()

QList< QList< TagData > > Digikam::RGTagModel::addNewData | ( | const QStringList & | elements,
|  | const QStringList & | resultedData
| ) |  |

The function starts to scan the tree from root level. When it finds a spacer containing an address element, it looks to see if the address element is found in elements list. If it's found, a new tag is added.

Parameters

  elements | A list containing address elements. Example: {Country}, {City}...
  resultedData | A list containing the name of each address element found in elements. Example: France, Paris...

Returns
  A list containing new tags

## ◆ addNewTag()

QPersistentModelIndex Digikam::RGTagModel::addNewTag | ( | const QModelIndex & | parent,
|  | const QString & | newTagName,
|  | const QString & | newElement
| ) |  |

Parameters

  parent | The index of the parent.
  newTagName | The name of the new tag.
  newElement | The new element of the tag.

## ◆ addSpacerTag()

void Digikam::RGTagModel::addSpacerTag | ( | const QModelIndex & | parent,
|  | const QString & | spacerName
| ) |  |

Parameters

  parent | The index of the parent. If parent == QModelIndex(), then the spacer is added to top-level
  spacerName | The name of the spacer. If it's an address element, the address element name will have the form {addressElement}.For example: {Country}, {City}...

## ◆ branchFromIndex()

TreeBranch * Digikam::RGTagModel::branchFromIndex | ( | const QModelIndex & | index | ) | const

Parameters

  index | Current model index.

Returns
  The branch for the current index.

## ◆ climbTreeAndGetSpacers()

void Digikam::RGTagModel::climbTreeAndGetSpacers | ( | const TreeBranch * | currentBranch | ) |

Address means the path from rootTag to currentBranch.

Parameters

  currentBranch | The branch from where the search starts.

## ◆ deleteAllSpacersOrNewTags()

void Digikam::RGTagModel::deleteAllSpacersOrNewTags | ( | const QModelIndex & | currentIndex,
|  | Type | whatShouldRemove
| ) |  |

Parameters

  currentIndex | If whatShouldRemove represents a spacer, the function will remove all spacers below currentIndex.If whatShouldRemove represents a new tag, the function will delete all new tags.
  whatShouldRemove | The tag type that should be removed. The options are: spacers or new tags.

## ◆ deleteTag()

void Digikam::RGTagModel::deleteTag | ( | const QModelIndex & | currentIndex | ) |

Parameters

  currentIndex | The tag found at this index will be deleted.

## ◆ findAndDeleteSpacersOrNewTags()

void Digikam::RGTagModel::findAndDeleteSpacersOrNewTags | ( | TreeBranch * | currentBranch,
|  | int | currentRow,
|  | Type | whatShouldRemove
| ) |  |

Parameters

  currentBranch | The tree branch from where the scan starts.
  currentRow | The row of current branch.
  whatShouldRemove | The tag type that should to be removed. The options are: spacers or new tags.

## ◆ fromSourceIndex()

QModelIndex Digikam::RGTagModel::fromSourceIndex | ( | const QModelIndex & | externalTagModelIndex | ) | const

Translates the model index from host's tag model to this model.

Returns
  The index of current old tag.

## ◆ getSpacerAddress()

QList< TagData > Digikam::RGTagModel::getSpacerAddress | ( | TreeBranch * | currentBranch | ) |

Address means the path from rootTag to currentBranch

Parameters

  currentBranch | The branch where the scan stops.

Returns
  The tag address of currentBranch

## ◆ getSpacers()

QList< QList< TagData > > Digikam::RGTagModel::getSpacers | ( |  | ) |

Returns
  The spacer list.

## ◆ getTagType()

Type Digikam::RGTagModel::getTagType | ( | const QModelIndex & | index | ) | const

Parameters

  index | The index of the tag.

Returns
  The type of the tag found at index.

## ◆ readdNewTags()

void Digikam::RGTagModel::readdNewTags | ( | const QList< QList< TagData > > & | tagAddressList | ) |

Parameters

  tagAddressList | A list containing new tags.

## ◆ readdTag()

void Digikam::RGTagModel::readdTag | ( | TreeBranch *& | currentBranch,
|  | int | currentRow,
|  | const QList< TagData > & | tagAddressElements,
|  | int | currentAddressElementIndex
| ) |  |

Parameters

  currentBranch | The branch from where the scan starts.
  currentRow | The row of the currentBranch.
  tagAddressElements | A list containing address elements. Example: {Country}, {City}...
  currentAddressElementIndex | The current element in the tag address list.

Note
  tagAddressElements contains address tag: Places,Spain,Barcelona readdTag climbs the tree and checks on each level if tagAddressElements[level] is found. if the tag is found, it climbs up the next level else, it recreates the new tag and climbs up that tree.

## ◆ toSourceIndex()

QModelIndex Digikam::RGTagModel::toSourceIndex | ( | const QModelIndex & | tagModelIndex | ) | const

Returns
  The index of a tag in host's tag model.