File indexing completed on 2024-05-26 05:14:44

0001 /*
0002     This file is part of Akonadi
0003 
0004     SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include "akonadiwidgets_export.h"
0012 // AkonadiCore
0013 #include "akonadi/tag.h"
0014 
0015 #include <QWidget>
0016 
0017 #include <memory>
0018 
0019 namespace Akonadi
0020 {
0021 class TagModel;
0022 class TagEditWidgetPrivate;
0023 
0024 /**
0025  * A widget that offers facilities to add/remove tags and optionally provides a way to select tags.
0026  *
0027  * @since 4.13
0028  */
0029 class AKONADIWIDGETS_EXPORT TagEditWidget : public QWidget
0030 {
0031     Q_OBJECT
0032 public:
0033     explicit TagEditWidget(QWidget *parent = nullptr);
0034     explicit TagEditWidget(Akonadi::TagModel *model, QWidget *parent = nullptr, bool enableSelection = false);
0035     ~TagEditWidget() override;
0036 
0037     void setModel(Akonadi::TagModel *model);
0038     Akonadi::TagModel *model() const;
0039 
0040     void setSelectionEnabled(bool enabled);
0041     bool selectionEnabled() const;
0042 
0043     void setSelection(const Akonadi::Tag::List &tags);
0044     [[nodiscard]] Akonadi::Tag::List selection() const;
0045 
0046 protected:
0047     bool eventFilter(QObject *watched, QEvent *event) override;
0048 
0049 private:
0050     std::unique_ptr<TagEditWidgetPrivate> const d;
0051 };
0052 
0053 }