File indexing completed on 2024-04-21 04:39:56

0001 /*
0002     SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz@gmx.at>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #ifndef KEDIT_TAGS_DIALOG_H
0008 #define KEDIT_TAGS_DIALOG_H
0009 
0010 #include <QDialog>
0011 #include <QHash>
0012 
0013 class QLineEdit;
0014 class KJob;
0015 class QTreeView;
0016 class QTreeWidgetItem;
0017 class QPushButton;
0018 class QTimer;
0019 class QStandardItemModel;
0020 class QSortFilterProxyModel;
0021 class QStandardItem;
0022 
0023 /**
0024  * @brief Dialog to edit a list of Baloo tags.
0025  *
0026  * It is possible for the user to add existing tags,
0027  * create new tags or to remove tags.
0028  *
0029  * @see KMetaDataConfigurationDialog
0030  */
0031 class KEditTagsDialog : public QDialog
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     explicit KEditTagsDialog(const QStringList &tags, QWidget *parent = nullptr);
0037 
0038     ~KEditTagsDialog() override;
0039 
0040     QStringList tags() const;
0041 
0042 private Q_SLOTS:
0043     void slotTextEdited(const QString &text);
0044     void slotAcceptedButtonClicked();
0045 
0046     void slotItemActivated(const QModelIndex &index);
0047 
0048 private:
0049     void setupModel(const QStringList &allTags, const QStringList &selectedTags);
0050     QStandardItem *ensureItemForTagExists(const QString tag);
0051     QStandardItem *addTag(QStandardItem *parentItem, const QString &cannonicalTagPath, const QString &tagName);
0052     QStandardItem *findTag(const QString tag);
0053     QStandardItem *findSubItem(QString split, QStandardItem *parentItem);
0054 
0055     QStringList m_tags;
0056     QStringList m_allTags;
0057     QTreeView *m_treeView = nullptr;
0058     QLineEdit *m_newTagEdit = nullptr;
0059     QStandardItemModel *m_model = nullptr;
0060     QStandardItem *m_newItem = nullptr;
0061 };
0062 
0063 #endif