diff --git a/libs/widgets/KoResourceTagStore.h b/libs/widgets/KoResourceTagStore.h index 0cc3435db9..b4e46fd1a3 100644 --- a/libs/widgets/KoResourceTagStore.h +++ b/libs/widgets/KoResourceTagStore.h @@ -1,91 +1,100 @@ /* This file is part of the KDE project Copyright (c) 2011 Sven Langkamp Copyright (c) 2011 Srikanth Tiyyagura + Copyright (c) 2017 Aniketh Girish This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef KORESOURCETAGSTORE_H #define KORESOURCETAGSTORE_H #include #include "kritawidgets_export.h" class KoResourceServerBase; class KoResource; class QStringList; class QString; /** - * KoResourceTagging allows to add and delete tags to resources and also search reources using tags + * KoResourceTagStore class maintains all the tags and this is the place where tags are all + * stored, Basically TagStore is the place where tags saved could be accessed and manupilated. + * The handles the addition, deletion/blacklisting of tags. All the other stuff like + * searching through the tagstore is also maintained here. */ class KRITAWIDGETS_EXPORT KoResourceTagStore { public: /** * Constructs a KoResourceTagging object * */ explicit KoResourceTagStore(KoResourceServerBase *resourceServer); ~KoResourceTagStore(); QStringList assignedTagsList(const KoResource *resource) const; /// remote the given resource from the tagstore void removeResource(const KoResource *resource); /// Add the given tag to the tag store. The resource can be empty, in which case /// the tag is added but unused void addTag(KoResource* resource, const QString& tag); /// Remove the given tag for the given resource. It will be blacklisted if there are no users left. void delTag(KoResource* resource, const QString& tag); /// Remove the tag altogether. It will be blacklisted, too. void delTag(const QString& tag); /// @return a list of all the tags in this store QStringList tagNamesList() const; /// Return a list of filenames for the given tag QStringList searchTag(const QString& query) const; + /// loads the tags are saved. void loadTags(); + void serializeTags(); private: friend class KoResourceTaggingTest; + /// Tags are saved as a list of XML file, This reads the tags as XML from the tagStore. void readXMLFile(const QString &tagstore); + + /// Write tags to the tagStore. void writeXMLFile(const QString &tagstore); /// To check whether the resource belongs to the present server or not bool isServerResource(const QString &resourceName) const; /// If resource filenames have no extensions, then we add "-krita.extension". QString adjustedFileName(const QString &fileName) const; /// Removes the adjustements before going to the server QStringList removeAdjustedFileNames(QStringList fileNamesList) const; class Private; Private * const d; }; #endif // KORESOURCETAGSTORE_H diff --git a/libs/widgets/KoResourceTaggingManager.h b/libs/widgets/KoResourceTaggingManager.h index e9c2bf4fcd..1231adc0a3 100644 --- a/libs/widgets/KoResourceTaggingManager.h +++ b/libs/widgets/KoResourceTaggingManager.h @@ -1,93 +1,98 @@ /* * This file is part of the KDE project * Copyright (c) 2002 Patrick Julien * Copyright (c) 2007 Jan Hambrecht * Copyright (c) 2007 Sven Langkamp * Copyright (C) 2011 Srikanth Tiyyagura * Copyright (c) 2011 José Luis Vergara * Copyright (c) 2013 Sascha Suelzer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KORESOURCETAGGINGMANAGER_H #define KORESOURCETAGGINGMANAGER_H #include class QWidget; class QStringList; class QString; class QPoint; class KoTagFilterWidget; class KoTagChooserWidget; class KoResourceModel; class KoResource; /** - * @brief The KoResourceTaggingManager class is ... - * - * XXX: this needs to be documented! + * @brief The KoResourceTaggingManager class is Widget class which controls Tagging + * Management functionalities. Widgets to show tagging area is created in this class. */ + class KoResourceTaggingManager : public QObject { Q_OBJECT public: explicit KoResourceTaggingManager(KoResourceModel* model, QWidget* parent); ~KoResourceTaggingManager() override; void showTaggingBar(bool show); QStringList availableTags() const; void contextMenuRequested(KoResource* currentResource, QPoint pos); void allowTagModification( bool set ); bool allowTagModification(); KoTagFilterWidget* tagFilterWidget(); KoTagChooserWidget* tagChooserWidget(); Q_SIGNALS: void updateView(); private Q_SLOTS: + /// unDeleteTag allows the user to undo the delete operation that they have done on a certain Tag. void undeleteTag(const QString& tagToUndelete); + void purgeTagUndeleteList(); void contextCreateNewTag(KoResource* resource, const QString& tag); void contextCreateNewTag(const QString& tag); void syncTagBoxEntryRemoval(const QString& tag); void syncTagBoxEntryAddition(const QString& tag); void syncTagBoxEntries(); void tagSaveButtonPressed(); void contextRemoveTagFromResource(KoResource* resource, const QString& tag); void contextAddTagToResource(KoResource* resource, const QString& tag); + + /// renameTag renames the tag from it's oldName to the newName user wants it to be. void renameTag(const QString &oldName, const QString &newName); + void tagChooserIndexChanged(const QString& lineEditText); void tagSearchLineEditTextChanged(const QString& lineEditText); void removeTagFromComboBox(const QString& tag); private: void contextMenuRequested(KoResource* resource, const QStringList& resourceTags, const QPoint& pos); void enableContextMenu(bool enable); void removeResourceTag(KoResource* resource, const QString& tagName); void addResourceTag(KoResource* resource, const QString& tagName); void updateTaggedResourceView(); class Private; Private* const d; }; #endif // KORESOURCETAGGINGINTERFACE_H