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

0001 /*
0002     SPDX-FileCopyrightText: 2006-2010 Sebastian Trueg <trueg@kde.org>
0003     SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef _BALOO_TAG_WIDGET_H_
0009 #define _BALOO_TAG_WIDGET_H_
0010 
0011 #include "widgets_export.h"
0012 
0013 #include <QWidget>
0014 
0015 #include <memory>
0016 
0017 namespace Baloo
0018 {
0019 class TagWidgetPrivate;
0020 
0021 /**
0022  * \class TagWidget tagwidget.h
0023  *
0024  * \brief Allows to change a selection of tags.
0025  *
0026  * TagWidget provides a simple GUI interface to assign tags.
0027  *
0028  * \author Sebastian Trueg <trueg@kde.org>
0029  */
0030 class BALOO_WIDGETS_EXPORT TagWidget : public QWidget
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     /**
0036      * Constructor
0037      */
0038     explicit TagWidget(QWidget *parent = nullptr);
0039 
0040     /**
0041      * Destructor
0042      */
0043     ~TagWidget() override;
0044 
0045     /**
0046      * The list of selected tags.
0047      *
0048      * \return The list of all tags that are currently selected. In case
0049      * resources to be tagged have been selected this list matches the
0050      * tags assigned to the resources.
0051      *
0052      * \since 4.5
0053      */
0054     QStringList selectedTags() const;
0055 
0056     /**
0057      * The alignment of the tags in the widget.
0058      *
0059      * \since 4.5
0060      */
0061     Qt::Alignment alignment() const;
0062 
0063     /**
0064      * If the widget is read only
0065      */
0066     bool readOnly() const;
0067 
0068 Q_SIGNALS:
0069     /**
0070      * This signal is emitted whenever a tag is clicked.
0071      */
0072     void tagClicked(const QString &);
0073 
0074     /**
0075      * Emitted whenever the selection of tags changes.
0076      *
0077      * \since 4.5
0078      */
0079     void selectionChanged(const QStringList &tags);
0080 
0081 public Q_SLOTS:
0082     /**
0083      * Set the list of selected tags. In case resources have been
0084      * set via setTaggedResource() or setTaggedResources() their
0085      * list of tags is changed automatically.
0086      *
0087      * \since 4.5
0088      */
0089     void setSelectedTags(const QStringList &tags);
0090 
0091     /**
0092      * Set the alignment to use. Only horizontal alignment flags make a
0093      * difference.
0094      *
0095      * \since 4.5
0096      */
0097     void setAlignment(Qt::Alignment alignment);
0098 
0099     /**
0100      * Set the TagWidget as read only
0101      */
0102     void setReadyOnly(bool readOnly = true);
0103 
0104 private:
0105     std::unique_ptr<TagWidgetPrivate> const d;
0106 };
0107 }
0108 
0109 #endif