digiKam
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

void addAllExternalTagsToTreeView ()
 
void addAllSpacersToTag (const QModelIndex &currentIndex, const QStringList &spacerList, int spacerListIndex)
 
void addDataInTree (TreeBranch *currentBranch, int currentRow, const QStringList &addressElements, const QStringList &elementsData)
 
void addExternalTags (TreeBranch *parentBranch, int currentRow)
 
QList< QList< TagData > > addNewData (const QStringList &elements, const QStringList &resultedData)
 
QPersistentModelIndex addNewTag (const QModelIndex &parent, const QString &newTagName, const QString &newElement)
 
void addSpacerTag (const QModelIndex &parent, const QString &spacerName)
 
TreeBranchbranchFromIndex (const QModelIndex &index) const
 
void climbTreeAndGetSpacers (const TreeBranch *currentBranch)
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 QAbstractItemModel: More...
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
void deleteAllSpacersOrNewTags (const QModelIndex &currentIndex, Type whatShouldRemove)
 
void deleteTag (const QModelIndex &currentIndex)
 
void findAndDeleteSpacersOrNewTags (TreeBranch *currentBranch, int currentRow, Type whatShouldRemove)
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QModelIndex fromSourceIndex (const QModelIndex &externalTagModelIndex) const
 Local functions: More...
 
QList< TagDatagetSpacerAddress (TreeBranch *currentBranch)
 
QList< QList< TagData > > getSpacers ()
 
QList< TagDatagetTagAddress ()
 
Type getTagType (const QModelIndex &index) const
 
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)
 
void readdTag (TreeBranch *&currentBranch, int currentRow, const QList< TagData > &tagAddressElements, int currentAddressElementIndex)
 
 RGTagModel (QAbstractItemModel *const externalTagModel, QObject *const parent=nullptr)
 
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
 
 ~RGTagModel () override
 

Detailed Description

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

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

◆ ~RGTagModel()

Digikam::RGTagModel::~RGTagModel ( )
override

Destructor

Member Function Documentation

◆ addAllExternalTagsToTreeView()

void Digikam::RGTagModel::addAllExternalTagsToTreeView ( )

Add all external tags to the tag tree.

References addExternalTags().

◆ addAllSpacersToTag()

void Digikam::RGTagModel::addAllSpacersToTag ( const QModelIndex &  currentIndex,
const QStringList &  spacerList,
int  spacerListIndex 
)

Adds all spacers found in spacerList to the tag tree.

References addSpacerTag(), branchFromIndex(), Digikam::TreeBranch::data, and Digikam::TreeBranch::spacerChildren.

◆ addDataInTree()

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

The function starts to scan the tree starting with currentBranch. 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
currentBranchThe branch from where the scan starts.
currentRowThe row of the current branch.
addressElementsA list containing address elements. Example: {Country}, {City}...
elementsDataA list containing the name of each address element found in elements. Example: France, Paris...

References addNewTag(), Digikam::TreeBranch::data, getTagAddress(), Digikam::TreeBranch::newChildren, Digikam::TreeBranch::oldChildren, Digikam::TreeBranch::spacerChildren, Digikam::TreeBranch::type, Digikam::TypeChild, Digikam::TypeNewChild, and Digikam::TypeSpacer.

Referenced by addNewData().

◆ addExternalTags()

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

Add tags from host application to the tag tree.

Parameters
parentBranchThe branch that will be parent for the old tag.
currentRowThe row where this external tag will be added.

References branchFromIndex(), index(), and rowCount().

Referenced by addAllExternalTagsToTreeView().

◆ addNewData()

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

Add new tags to tag tree. 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
elementsA list containing address elements. Example: {Country}, {City}...
resultedDataA list containing the name of each address element found in elements. Example: France, Paris...
Returns
A list containing new tags

References addDataInTree().

◆ addNewTag()

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

Adds a tag containing data returned from backends.

Parameters
parentThe index of the parent.
newTagNameThe name of the new tag.

References branchFromIndex(), Digikam::TreeBranch::data, Digikam::TreeBranch::help, Digikam::TreeBranch::newChildren, parent(), Digikam::TreeBranch::parent, Digikam::TreeBranch::spacerChildren, Digikam::TreeBranch::type, and Digikam::TypeNewChild.

Referenced by addDataInTree(), and readdTag().

◆ addSpacerTag()

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

Adds a spacer tag.

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

References branchFromIndex(), Digikam::TreeBranch::data, parent(), Digikam::TreeBranch::parent, Digikam::TreeBranch::spacerChildren, Digikam::TreeBranch::type, and Digikam::TypeSpacer.

Referenced by addAllSpacersToTag(), and readdTag().

◆ branchFromIndex()

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

Returns the branch found at index

Parameters
indexCurrent model index.
Returns
The branch for the current index.

References index().

Referenced by addAllSpacersToTag(), addExternalTags(), addNewTag(), addSpacerTag(), columnCount(), data(), deleteAllSpacersOrNewTags(), deleteTag(), flags(), getTagType(), index(), parent(), rowCount(), and toSourceIndex().

◆ climbTreeAndGetSpacers()

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

Gets the spacers addresses below currentBranch. Address means the path from rootTag to currentBranch.

Parameters
currentBranchThe branch from where the search starts.

References getSpacerAddress(), Digikam::TreeBranch::newChildren, Digikam::TreeBranch::oldChildren, and Digikam::TreeBranch::spacerChildren.

Referenced by getSpacers().

◆ columnCount()

int Digikam::RGTagModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

◆ data()

QVariant Digikam::RGTagModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
override

◆ deleteAllSpacersOrNewTags()

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

Deletes all spacers or all new tags.

Parameters
currentIndexIf 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.
whatShouldRemoveThe tag type that should be removed. The options are: spacers or new tags.

References branchFromIndex(), findAndDeleteSpacersOrNewTags(), Digikam::TypeNewChild, and Digikam::TypeSpacer.

◆ deleteTag()

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

Deletes a tag.

Parameters
currentIndexThe tag found at this index will be deleted.

References branchFromIndex(), Digikam::TreeBranch::newChildren, Digikam::TreeBranch::spacerChildren, Digikam::TreeBranch::type, and Digikam::TypeChild.

Referenced by findAndDeleteSpacersOrNewTags().

◆ findAndDeleteSpacersOrNewTags()

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

Deletes all spacers or all new tags below @currentBranch.

Parameters
currentBranchThe tree branch from where the scan starts.
currentRowThe row of current branch.
whatShouldRemoveThe tag type that should to be removed. The options are: spacers or new tags.

References deleteTag(), Digikam::TreeBranch::newChildren, Digikam::TreeBranch::oldChildren, Digikam::TreeBranch::spacerChildren, Digikam::TypeNewChild, and Digikam::TypeSpacer.

Referenced by deleteAllSpacersOrNewTags().

◆ flags()

Qt::ItemFlags Digikam::RGTagModel::flags ( const QModelIndex &  index) const
override

◆ fromSourceIndex()

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

◆ getSpacerAddress()

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

Gets the address of a spacer. Address means the path from rootTag to currentBranch

Parameters
currentBranchThe branch where the scan stops.
Returns
The tag address of currentBranch

References Digikam::TreeBranch::data, Digikam::TreeBranch::parent, Digikam::TagData::tagName, Digikam::TagData::tagType, and Digikam::TreeBranch::type.

Referenced by climbTreeAndGetSpacers().

◆ getSpacers()

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

Gets all spacers.

Returns
The spacer list.

References climbTreeAndGetSpacers().

◆ getTagAddress()

QList< TagData > Digikam::RGTagModel::getTagAddress ( )

Gets the address of a tag.

References Digikam::TagData::tagName, and Digikam::TagData::tagType.

Referenced by addDataInTree().

◆ getTagType()

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

Gets the type of a tag found at index.

Parameters
indexThe index of the tag.
Returns
The type of the tag found at index.

References branchFromIndex(), index(), and Digikam::TreeBranch::type.

◆ headerData()

QVariant Digikam::RGTagModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const
override

◆ index()

QModelIndex Digikam::RGTagModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

◆ parent()

◆ readdNewTags()

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

Takes each tag contained in tagAddressList and adds it to the tag tree.

Parameters
tagAddressListA list containing new tags.

References readdTag().

◆ readdTag()

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

Readds new tags to tag tree.

Parameters
currentBranchThe branch from where the scan starts.
currentRowThe row of the currentBranch.
tagAddressElementsA list containing address elements. Example: {Country}, {City}...
elementsDataA list containing the name of each address element found in elements. Example: France, Paris...

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.

References addNewTag(), addSpacerTag(), Digikam::TreeBranch::newChildren, Digikam::TreeBranch::oldChildren, Digikam::TreeBranch::spacerChildren, Digikam::TypeChild, Digikam::TypeNewChild, and Digikam::TypeSpacer.

Referenced by readdNewTags().

◆ rowCount()

int Digikam::RGTagModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

◆ setData()

bool Digikam::RGTagModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)
override

◆ setHeaderData()

bool Digikam::RGTagModel::setHeaderData ( int  section,
Qt::Orientation  orientation,
const QVariant &  value,
int  role 
)
override

◆ slotColumnsAboutToBeInserted

void Digikam::RGTagModel::slotColumnsAboutToBeInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
slot

References fromSourceIndex(), and parent().

Referenced by RGTagModel().

◆ slotColumnsAboutToBeMoved

void Digikam::RGTagModel::slotColumnsAboutToBeMoved ( const QModelIndex &  sourceParent,
int  sourceStart,
int  sourceEnd,
const QModelIndex &  destinationParent,
int  destinationColumn 
)
slot

References fromSourceIndex().

Referenced by RGTagModel().

◆ slotColumnsAboutToBeRemoved

void Digikam::RGTagModel::slotColumnsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
slot

References fromSourceIndex(), and parent().

Referenced by RGTagModel().

◆ slotColumnsInserted

void Digikam::RGTagModel::slotColumnsInserted ( )
slot

Referenced by RGTagModel().

◆ slotColumnsMoved

void Digikam::RGTagModel::slotColumnsMoved ( )
slot

Referenced by RGTagModel().

◆ slotColumnsRemoved

void Digikam::RGTagModel::slotColumnsRemoved ( )
slot

Referenced by RGTagModel().

◆ slotLayoutAboutToBeChanged

void Digikam::RGTagModel::slotLayoutAboutToBeChanged ( )
slot

Referenced by RGTagModel().

◆ slotLayoutChanged

void Digikam::RGTagModel::slotLayoutChanged ( )
slot

Referenced by RGTagModel().

◆ slotModelAboutToBeReset

void Digikam::RGTagModel::slotModelAboutToBeReset ( )
slot

Referenced by RGTagModel().

◆ slotModelReset

void Digikam::RGTagModel::slotModelReset ( )
slot

◆ slotRowsAboutToBeInserted

void Digikam::RGTagModel::slotRowsAboutToBeInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
slot

◆ slotRowsAboutToBeMoved

void Digikam::RGTagModel::slotRowsAboutToBeMoved ( const QModelIndex &  sourceParent,
int  sourceStart,
int  sourceEnd,
const QModelIndex &  destinationParent,
int  destinationRow 
)
slot

References fromSourceIndex().

Referenced by RGTagModel().

◆ slotRowsAboutToBeRemoved

void Digikam::RGTagModel::slotRowsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
slot

References parent().

Referenced by RGTagModel().

◆ slotRowsInserted

◆ slotRowsMoved

void Digikam::RGTagModel::slotRowsMoved ( )
slot

Referenced by RGTagModel().

◆ slotRowsRemoved

void Digikam::RGTagModel::slotRowsRemoved ( )
slot

Referenced by RGTagModel().

◆ slotSourceDataChanged

void Digikam::RGTagModel::slotSourceDataChanged ( const QModelIndex &  topLeft,
const QModelIndex &  bottomRight 
)
slot

References fromSourceIndex().

Referenced by RGTagModel().

◆ slotSourceHeaderDataChanged

void Digikam::RGTagModel::slotSourceHeaderDataChanged ( const Qt::Orientation  orientation,
int  first,
int  last 
)
slot

Referenced by RGTagModel().

◆ toSourceIndex()

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

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

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

References branchFromIndex(), and Digikam::TreeBranch::sourceIndex.

Referenced by columnCount(), data(), flags(), index(), parent(), and rowCount().


The documentation for this class was generated from the following files: