digiKam
|
The model that holds data for the tag tree displayed in ReverseGeocodingWidget. More...
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 ¤tIndex, 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) |
TreeBranch * | branchFromIndex (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 ¤tIndex, Type whatShouldRemove) |
void | deleteTag (const QModelIndex ¤tIndex) |
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< TagData > | getSpacerAddress (TreeBranch *currentBranch) |
QList< QList< TagData > > | getSpacers () |
QList< TagData > | getTagAddress () |
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 *¤tBranch, 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 | |
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).
|
explicit |
Constructor
externalTagModel | The tag model found in the host application. |
parent | The parent object |
References Digikam::DatabaseFields::Orientation, slotColumnsAboutToBeInserted(), slotColumnsAboutToBeMoved(), slotColumnsAboutToBeRemoved(), slotColumnsInserted(), slotColumnsMoved(), slotColumnsRemoved(), slotLayoutAboutToBeChanged(), slotLayoutChanged(), slotModelAboutToBeReset(), slotRowsAboutToBeInserted(), slotRowsAboutToBeMoved(), slotRowsAboutToBeRemoved(), slotRowsInserted(), slotRowsMoved(), slotRowsRemoved(), slotSourceDataChanged(), slotSourceHeaderDataChanged(), and Digikam::TypeChild.
|
override |
Destructor
void Digikam::RGTagModel::addAllExternalTagsToTreeView | ( | ) |
Add all external tags to the tag tree.
References addExternalTags().
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.
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.
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... |
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().
void Digikam::RGTagModel::addExternalTags | ( | TreeBranch * | parentBranch, |
int | currentRow | ||
) |
Add tags from host application to the tag tree.
parentBranch | The branch that will be parent for the old tag. |
currentRow | The row where this external tag will be added. |
References branchFromIndex(), index(), and rowCount().
Referenced by addAllExternalTagsToTreeView().
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.
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... |
References addDataInTree().
QPersistentModelIndex Digikam::RGTagModel::addNewTag | ( | const QModelIndex & | parent, |
const QString & | newTagName, | ||
const QString & | newElement | ||
) |
Adds a tag containing data returned from backends.
parent | The index of the parent. |
newTagName | The 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().
void Digikam::RGTagModel::addSpacerTag | ( | const QModelIndex & | parent, |
const QString & | spacerName | ||
) |
Adds a spacer tag.
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}... |
References branchFromIndex(), Digikam::TreeBranch::data, parent(), Digikam::TreeBranch::parent, Digikam::TreeBranch::spacerChildren, Digikam::TreeBranch::type, and Digikam::TypeSpacer.
Referenced by addAllSpacersToTag(), and readdTag().
TreeBranch * Digikam::RGTagModel::branchFromIndex | ( | const QModelIndex & | index | ) | const |
Returns the branch found at index
index | Current model index. |
References index().
Referenced by addAllSpacersToTag(), addExternalTags(), addNewTag(), addSpacerTag(), columnCount(), data(), deleteAllSpacersOrNewTags(), deleteTag(), flags(), getTagType(), index(), parent(), rowCount(), and toSourceIndex().
void Digikam::RGTagModel::climbTreeAndGetSpacers | ( | const TreeBranch * | currentBranch | ) |
Gets the spacers addresses below currentBranch. Address means the path from rootTag to currentBranch.
currentBranch | The branch from where the search starts. |
References getSpacerAddress(), Digikam::TreeBranch::newChildren, Digikam::TreeBranch::oldChildren, and Digikam::TreeBranch::spacerChildren.
Referenced by getSpacers().
|
override |
QAbstractItemModel:
References branchFromIndex(), parent(), toSourceIndex(), Digikam::TreeBranch::type, Digikam::TypeNewChild, and Digikam::TypeSpacer.
|
override |
void Digikam::RGTagModel::deleteAllSpacersOrNewTags | ( | const QModelIndex & | currentIndex, |
Type | whatShouldRemove | ||
) |
Deletes all spacers or all new tags.
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. |
References branchFromIndex(), findAndDeleteSpacersOrNewTags(), Digikam::TypeNewChild, and Digikam::TypeSpacer.
void Digikam::RGTagModel::deleteTag | ( | const QModelIndex & | currentIndex | ) |
Deletes a tag.
currentIndex | The 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().
void Digikam::RGTagModel::findAndDeleteSpacersOrNewTags | ( | TreeBranch * | currentBranch, |
int | currentRow, | ||
Type | whatShouldRemove | ||
) |
Deletes all spacers or all new tags below @currentBranch.
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. |
References deleteTag(), Digikam::TreeBranch::newChildren, Digikam::TreeBranch::oldChildren, Digikam::TreeBranch::spacerChildren, Digikam::TypeNewChild, and Digikam::TypeSpacer.
Referenced by deleteAllSpacersOrNewTags().
|
override |
References branchFromIndex(), index(), toSourceIndex(), Digikam::TreeBranch::type, Digikam::TypeNewChild, and Digikam::TypeSpacer.
QModelIndex Digikam::RGTagModel::fromSourceIndex | ( | const QModelIndex & | externalTagModelIndex | ) | const |
Local functions:
Translates the model index from host's tag model to this model.
References Digikam::TreeBranch::data, Digikam::TreeBranch::newChildren, Digikam::TreeBranch::oldChildren, Digikam::TreeBranch::parent, Digikam::TreeBranch::sourceIndex, Digikam::TreeBranch::spacerChildren, Digikam::TreeBranch::type, and Digikam::TypeChild.
Referenced by index(), parent(), slotColumnsAboutToBeInserted(), slotColumnsAboutToBeMoved(), slotColumnsAboutToBeRemoved(), slotRowsAboutToBeInserted(), slotRowsAboutToBeMoved(), and slotSourceDataChanged().
QList< TagData > Digikam::RGTagModel::getSpacerAddress | ( | TreeBranch * | currentBranch | ) |
Gets the address of a spacer. Address means the path from rootTag to currentBranch
currentBranch | The branch where the scan stops. |
References Digikam::TreeBranch::data, Digikam::TreeBranch::parent, Digikam::TagData::tagName, Digikam::TagData::tagType, and Digikam::TreeBranch::type.
Referenced by climbTreeAndGetSpacers().
Gets the address of a tag.
References Digikam::TagData::tagName, and Digikam::TagData::tagType.
Referenced by addDataInTree().
Type Digikam::RGTagModel::getTagType | ( | const QModelIndex & | index | ) | const |
Gets the type of a tag found at index.
index | The index of the tag. |
References branchFromIndex(), index(), and Digikam::TreeBranch::type.
|
override |
|
override |
References branchFromIndex(), fromSourceIndex(), Digikam::TreeBranch::newChildren, parent(), Digikam::TreeBranch::spacerChildren, and toSourceIndex().
Referenced by addExternalTags(), branchFromIndex(), data(), flags(), getTagType(), and parent().
|
override |
References branchFromIndex(), fromSourceIndex(), index(), Digikam::TreeBranch::newChildren, Digikam::TreeBranch::oldChildren, Digikam::TreeBranch::parent, Digikam::TreeBranch::spacerChildren, toSourceIndex(), Digikam::TreeBranch::type, Digikam::TypeChild, Digikam::TypeNewChild, and Digikam::TypeSpacer.
Referenced by addNewTag(), addSpacerTag(), columnCount(), index(), rowCount(), slotColumnsAboutToBeInserted(), slotColumnsAboutToBeRemoved(), slotRowsAboutToBeInserted(), and slotRowsAboutToBeRemoved().
Takes each tag contained in tagAddressList and adds it to the tag tree.
tagAddressList | A list containing new tags. |
References readdTag().
void Digikam::RGTagModel::readdTag | ( | TreeBranch *& | currentBranch, |
int | currentRow, | ||
const QList< TagData > & | tagAddressElements, | ||
int | currentAddressElementIndex | ||
) |
Readds new tags to tag tree.
currentBranch | The branch from where the scan starts. |
currentRow | The row of the currentBranch. |
tagAddressElements | A list containing address elements. Example: {Country}, {City}... |
elementsData | A 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().
|
override |
References branchFromIndex(), Digikam::TreeBranch::newChildren, parent(), Digikam::TreeBranch::spacerChildren, toSourceIndex(), Digikam::TreeBranch::type, and Digikam::TypeChild.
Referenced by addExternalTags().
|
override |
|
override |
|
slot |
References fromSourceIndex(), and parent().
Referenced by RGTagModel().
|
slot |
References fromSourceIndex().
Referenced by RGTagModel().
|
slot |
References fromSourceIndex(), and parent().
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
|
slot |
|
slot |
References fromSourceIndex(), Digikam::TreeBranch::newChildren, parent(), and Digikam::TreeBranch::spacerChildren.
Referenced by RGTagModel().
|
slot |
References fromSourceIndex().
Referenced by RGTagModel().
|
slot |
References parent().
Referenced by RGTagModel().
|
slot |
References Digikam::TreeBranch::oldChildren, Digikam::TreeBranch::parent, Digikam::TreeBranch::sourceIndex, Digikam::TreeBranch::type, and Digikam::TypeChild.
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
|
slot |
References fromSourceIndex().
Referenced by RGTagModel().
|
slot |
Referenced by RGTagModel().
QModelIndex Digikam::RGTagModel::toSourceIndex | ( | const QModelIndex & | tagModelIndex | ) | const |
Translates the model index from this model to host's tag model.
References branchFromIndex(), and Digikam::TreeBranch::sourceIndex.
Referenced by columnCount(), data(), flags(), index(), parent(), and rowCount().