Warning, file /maui/mauikit-filebrowsing/src/code/tagslist.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #pragma once 0002 #include <QObject> 0003 #include <QStringList> 0004 0005 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0006 #include <MauiKit3/Core/mauilist.h> 0007 #else 0008 #include <MauiKit4/Core/mauilist.h> 0009 #endif 0010 0011 /** 0012 * @brief The TagsList class 0013 * A model ready to be consumed by QML. Has basic support for browsing and handling, associating, adding and removing tags. 0014 * 0015 * This is a basic model for most actions supported by the MauiKit File Browsing Tagging system. For more details on supported actions and complete API documentation refer to the Tagging page. 0016 * @see Tagging 0017 * 0018 * @note This class is exposed as a QML type with the name of `TagsListModel`. 0019 */ 0020 class TagsList : public MauiList 0021 { 0022 Q_OBJECT 0023 Q_DISABLE_COPY(TagsList) 0024 0025 /** 0026 * Whether the retrieved tags should be only associated to the current application or to any other app. 0027 * By default this is set to `true`, so the lookup will be only matching tags associated to the given URLs that were created by the current application. 0028 */ 0029 Q_PROPERTY(bool strict READ getStrict WRITE setStrict NOTIFY strictChanged) 0030 0031 /** 0032 * The list of file URLs to look for their tags. 0033 */ 0034 Q_PROPERTY(QStringList urls READ getUrls WRITE setUrls NOTIFY urlsChanged) 0035 0036 /** 0037 * The resulting list of tag names that were found. 0038 */ 0039 Q_PROPERTY(QStringList tags READ getTags NOTIFY tagsChanged) 0040 0041 public: 0042 explicit TagsList(QObject *parent = nullptr); 0043 0044 const FMH::MODEL_LIST &items() const override; 0045 0046 bool getStrict() const; 0047 void setStrict(const bool &value); 0048 0049 QStringList getUrls() const; 0050 void setUrls(const QStringList &value); 0051 0052 QStringList getTags() const; 0053 0054 void componentComplete() override final; 0055 0056 private: 0057 FMH::MODEL_LIST list; 0058 void setList(); 0059 0060 bool strict = true; 0061 QStringList m_urls; 0062 0063 void append(const FMH::MODEL &tag); 0064 0065 Q_SIGNALS: 0066 void strictChanged(); 0067 void urlsChanged(); 0068 void tagsChanged(); 0069 0070 public Q_SLOTS: 0071 0072 /** 0073 * @brief Adds a given tag to the model, if the tag already exists in the model then nothing happens. 0074 * @note This operation does not inserts the tag to the tagging data base. To insert a new tag see the insert function. 0075 * @see insert 0076 * @param tag the tag to be added to the model 0077 */ 0078 void append(const QString &tag); 0079 0080 /** 0081 * @brief Adds a given tag map to the model, if the tag map already exists in the model then nothing happens. 0082 * @note This operation does not inserts the tag to the tagging data base. 0083 * @param tag the tag map to be added to the model. The supported key values are: `tag`, `color`, `date` 0084 */ 0085 void appendItem(const QVariantMap &tag); 0086 0087 /** 0088 * @brief Adds a given list of tags to the model. Tags that already exists in the model are ignored. 0089 * @param tags list of tags to be added to the model. 0090 * @see append 0091 */ 0092 void append(const QStringList &tags); 0093 0094 /** 0095 * @brief Inserts a tag to the tagging data base. 0096 * @param tag to be inserted 0097 * @return if the tag already exists in the data base then it return false, if the operation is successful returns true otherwise false 0098 */ 0099 bool insert(const QString &tag); 0100 0101 /** 0102 * @brief Associates a given tag to the current file URLs set to the URLs property 0103 * @param tag a tag to be associated, if the tag doesn't exists then it gets created 0104 */ 0105 void insertToUrls(const QString &tag); 0106 0107 /** 0108 * @brief Updates a list of tags associated to the current file URLs. All the previous tags associated to each file URL are removed and replaced by the new ones 0109 * @param tags tags to be updated 0110 */ 0111 void updateToUrls(const QStringList &tags); 0112 0113 /** 0114 * @brief Removes a tag from the model at a given index. The tag is removed from the model but not from the tagging data base 0115 * @param index index position of the tag in the model. If the model has been filtered or ordered using the MauiKit BaseModel then it should use the mapped index. 0116 * @return 0117 */ 0118 bool remove(const int &index); 0119 0120 /** 0121 * @brief Removes a tag at the given index in the model from the given file URL. This removes the associated file URL from the tagging data base and the tag from the model 0122 * @param index index of the tag in the model 0123 * @param url file URL 0124 */ 0125 void removeFrom(const int &index, const QString &url); 0126 0127 /** 0128 * @brief Removes a tag at a given index in the model from the all the file URLs currently set 0129 * @param index index of the tag in the model. 0130 */ 0131 void removeFromUrls(const int &index); 0132 0133 /** 0134 * @brief Removes a given tag name from the current list of file URLs set 0135 * @param tag the tag name 0136 */ 0137 void removeFromUrls(const QString &tag); 0138 0139 /** 0140 * @brief Removes a tag from the tagging data base. This operation will remove the association of the tag to the current application making the request, meaning that if the tag is also associated to another application then the tag will be conserved. 0141 * @param index 0142 */ 0143 void erase(const int &index); 0144 0145 /** 0146 * @brief Reloads the model, checking the tags from the given list of file URLs 0147 */ 0148 void refresh(); 0149 0150 /** 0151 * @brief Checks whether a given tag name is already in the model list 0152 * @param tag tag name to look up 0153 * @return whether the tag exists 0154 */ 0155 bool contains(const QString &tag); 0156 }; 0157