umbrello: umbrello/dialogs/dontaskagain.h Source File

umbrello 25.04.0 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

dontaskagain.h
Go to the documentation of this file.
1/*
2 SPDX-License-Identifier: GPL-2.0-or-later
3 SPDX-FileCopyrightText: 2018-2020 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
4*/
5
6#ifndef DONTASKAGAIN_H
7#define DONTASKAGAIN_H
8
9// Qt includes
10#include <QList>
11#include <QString>
12#include <QWidget>
13
14// KDE includes
15#include <KLocalizedString>
16
17class QVBoxLayout;
18
25 class DontAskAgainItem {
26public:
27 DontAskAgainItem(const QString &name);
28 virtual ~DontAskAgainItem();
29 QString &name();
30 virtual QString text() const = 0;
31 bool isAll();
32 bool isEnabled();
33 void setEnabled(bool state = true);
34
35protected:
36 QString m_name;
37};
38
39#define DefineDontAskAgainItem(name,key,_text) \
40class DontAskAgainItem##name : public DontAskAgainItem \
41{ \
42public: \
43 DontAskAgainItem##name() : DontAskAgainItem(QStringLiteral(key)) {} \
44 virtual QString text() const { return _text; } \
45}; \
46static DontAskAgainItem##name name;
47
61 class DontAskAgainWidget : public QWidget
62{
63 Q_OBJECT
64public:
65 DontAskAgainWidget(QList<DontAskAgainItem *> &items, QWidget *parent = nullptr);
66 bool apply();
67 void setDefaults();
68
69protected:
70 void addItem(DontAskAgainItem *item);
71 QVBoxLayout *m_layout;
72 QList<DontAskAgainItem *> &m_items;
73
74protected Q_SLOTS:
75 void slotToggled(bool state);
76};
77
102 class DontAskAgainHandler
103{
104public:
105 void addItem(DontAskAgainItem *item);
106 static DontAskAgainHandler &instance();
107 DontAskAgainWidget *createWidget();
108protected:
109 QList<DontAskAgainItem*> m_items;
110};
111
112#endif // DONTASKAGAIN_H
DontAskAgainHandler
Definition dontaskagain.h:103
DontAskAgainHandler::instance
static DontAskAgainHandler & instance()
Definition dontaskagain.cpp:133
DontAskAgainHandler::addItem
void addItem(DontAskAgainItem *item)
Definition dontaskagain.cpp:123
DontAskAgainHandler::createWidget
DontAskAgainWidget * createWidget()
Definition dontaskagain.cpp:128
DontAskAgainHandler::m_items
QList< DontAskAgainItem * > m_items
Definition dontaskagain.h:109
DontAskAgainItem
Definition dontaskagain.h:25
DontAskAgainItem::text
virtual QString text() const =0
DontAskAgainItem::~DontAskAgainItem
virtual ~DontAskAgainItem()
Definition dontaskagain.cpp:27
DontAskAgainItem::isAll
bool isAll()
Definition dontaskagain.cpp:36
DontAskAgainItem::setEnabled
void setEnabled(bool state=true)
Definition dontaskagain.cpp:46
DontAskAgainItem::name
QString & name()
Definition dontaskagain.cpp:31
DontAskAgainItem::isEnabled
bool isEnabled()
Definition dontaskagain.cpp:41
DontAskAgainItem::DontAskAgainItem
DontAskAgainItem(const QString &name)
Definition dontaskagain.cpp:21
DontAskAgainItem::m_name
QString m_name
Definition dontaskagain.h:36
DontAskAgainWidget
Definition dontaskagain.h:62
DontAskAgainWidget::m_items
QList< DontAskAgainItem * > & m_items
Definition dontaskagain.h:72
DontAskAgainWidget::slotToggled
void slotToggled(bool state)
Definition dontaskagain.cpp:108
DontAskAgainWidget::addItem
void addItem(DontAskAgainItem *item)
Definition dontaskagain.cpp:99
DontAskAgainWidget::DontAskAgainWidget
DontAskAgainWidget(QList< DontAskAgainItem * > &items, QWidget *parent=nullptr)
Definition dontaskagain.cpp:56
DontAskAgainWidget::apply
bool apply()
Definition dontaskagain.cpp:69
DontAskAgainWidget::m_layout
QVBoxLayout * m_layout
Definition dontaskagain.h:71
DontAskAgainWidget::setDefaults
void setDefaults()
Definition dontaskagain.cpp:88