Warning, file /office/calligra/libs/widgets/KoResourceItemChooserContextMenu.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *    This file is part of the KDE project
0003  *    Copyright (c) 2013 Sascha Suelzer <s.suelzer@gmail.com>
0004  *
0005  *    This library is free software; you can redistribute it and/or
0006  *    modify it under the terms of the GNU Library General Public
0007  *    License as published by the Free Software Foundation; either
0008  *    version 2 of the License, or (at your option) any later version.
0009  *
0010  *    This library is distributed in the hope that it will be useful,
0011  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  *    Library General Public License for more details.
0014  *
0015  *    You should have received a copy of the GNU Library General Public License
0016  *    along with this library; see the file COPYING.LIB.  If not, write to
0017  *    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  *  * Boston, MA 02110-1301, USA.
0019  * */
0020 
0021 #ifndef KORESOURCEITEMCHOOSERCONTEXTMENU_H
0022 #define KORESOURCEITEMCHOOSERCONTEXTMENU_H
0023 
0024 #include <QMenu>
0025 #include <QWidgetAction>
0026 #include <QLabel>
0027 
0028 class KLineEdit;
0029 class KoResource;
0030 
0031 
0032 class ContextMenuExistingTagAction : public QAction
0033 {
0034     Q_OBJECT
0035 public:
0036     explicit ContextMenuExistingTagAction( KoResource * resource, const QString &tag, QObject* parent = 0);
0037     ~ContextMenuExistingTagAction() override = default;
0038 
0039 Q_SIGNALS:
0040     void triggered(KoResource * resource, const QString &tag);
0041 
0042 protected Q_SLOTS:
0043     void onTriggered();
0044 
0045 private:
0046     KoResource * m_resource;
0047     QString m_tag;
0048 };
0049 
0050 /*!
0051  *  A line edit QWidgetAction.
0052  *  Default behavior: Closes its parent upon triggering.
0053  */
0054 class KoLineEditAction : public QWidgetAction
0055 {
0056     Q_OBJECT
0057 public:
0058     explicit KoLineEditAction(QObject* parent);
0059     ~KoLineEditAction() override = default;
0060     void setIcon(const QIcon &icon);
0061     void closeParentOnTrigger(bool closeParent);
0062     bool closeParentOnTrigger();
0063     void setPlaceholderText(const QString& clickMessage);
0064     void setText(const QString& text);
0065     void setVisible(bool showAction);
0066 
0067     Q_SIGNALS:
0068     void triggered(const QString &tag);
0069 
0070 protected Q_SLOTS:
0071     void onTriggered(const QString& text);
0072 
0073 private:
0074     bool m_closeParentOnTrigger;
0075     QLabel * m_label;
0076     KLineEdit * m_editBox;
0077 };
0078 
0079 class NewTagAction : public KoLineEditAction
0080 {
0081     Q_OBJECT
0082 public:
0083     explicit NewTagAction (KoResource* resource, QMenu* parent);
0084     ~NewTagAction() override = default;
0085 
0086     Q_SIGNALS:
0087     void triggered(KoResource * resource, const QString &tag);
0088 
0089 protected Q_SLOTS:
0090     void onTriggered(const QString& tagName);
0091 
0092 private:
0093     KoResource * m_resource;
0094 };
0095 
0096 class KoResourceItemChooserContextMenu :  public QMenu
0097 {
0098     Q_OBJECT
0099 public:
0100     explicit KoResourceItemChooserContextMenu
0101     (
0102         KoResource* resource,
0103         const QStringList& resourceTags,
0104         const QString& currentlySelectedTag,
0105         const QStringList& allTags
0106     );
0107     ~KoResourceItemChooserContextMenu() override = default;
0108 
0109 Q_SIGNALS:
0110     /// Emitted when a resource should be added to an existing tag.
0111     void resourceTagAdditionRequested(KoResource* resource, const QString& tag);
0112     /// Emitted when a resource should be removed from an existing tag.
0113     void resourceTagRemovalRequested(KoResource* resource, const QString& tag);
0114     /// Emitted when a resource should be added to a new tag, which will need to be created.
0115     void resourceAssignmentToNewTagRequested(KoResource* resource, const QString& tag);
0116 
0117 };
0118 
0119 #endif // KORESOURCEITEMCHOOSERCONTEXTMENU_H