Changeset View
Changeset View
Standalone View
Standalone View
kcms/componentchooser/componentchooser.h
Show All 11 Lines | |||||
12 | * published by the Free Software Foundationi * | 12 | * published by the Free Software Foundationi * | ||
13 | * * | 13 | * * | ||
14 | ***************************************************************************/ | 14 | ***************************************************************************/ | ||
15 | 15 | | |||
16 | #ifndef _COMPONENTCHOOSER_H_ | 16 | #ifndef _COMPONENTCHOOSER_H_ | ||
17 | #define _COMPONENTCHOOSER_H_ | 17 | #define _COMPONENTCHOOSER_H_ | ||
18 | 18 | | |||
19 | #include "ui_componentchooser_ui.h" | 19 | #include "ui_componentchooser_ui.h" | ||
20 | #include "ui_componentconfig_ui.h" | | |||
21 | #include <QHash> | 20 | #include <QHash> | ||
22 | 21 | | |||
23 | 22 | | |||
24 | #include <QVBoxLayout> | 23 | #include <QVBoxLayout> | ||
25 | 24 | | |||
26 | #include <kservice.h> | 25 | #include <kservice.h> | ||
27 | 26 | | |||
28 | class QListWidgetItem; | 27 | class QWidget; | ||
29 | class KConfig; | 28 | class KConfig; | ||
30 | 29 | | |||
31 | /* The CfgPlugin class is an exception. It is LGPL. It will be parted of the plugin interface | 30 | /* The CfgPlugin class is an exception. It is LGPL. It will be parted of the plugin interface | ||
32 | which I plan for KDE 3.2. | 31 | which I plan for KDE 3.2. | ||
33 | */ | 32 | */ | ||
34 | class CfgPlugin | 33 | class CfgPlugin | ||
35 | { | 34 | { | ||
36 | public: | 35 | public: | ||
37 | CfgPlugin(){} | 36 | CfgPlugin(){} | ||
38 | virtual ~CfgPlugin(){} | 37 | virtual ~CfgPlugin(){} | ||
39 | virtual void load(KConfig *cfg)=0; | 38 | virtual void load(KConfig *cfg)=0; | ||
40 | virtual void save(KConfig *cfg)=0; | 39 | virtual void save(KConfig *cfg)=0; | ||
41 | virtual void defaults()=0; | 40 | virtual void defaults()=0; | ||
42 | virtual bool isDefaults() const=0; | 41 | virtual bool isDefaults() const=0; | ||
43 | }; | 42 | virtual bool hasChanged() const=0; | ||
44 | | ||||
45 | class CfgComponent: public QWidget, public Ui::ComponentConfig_UI, public CfgPlugin | | |||
46 | { | | |||
47 | Q_OBJECT | | |||
48 | public: | | |||
49 | CfgComponent(QWidget *parent); | | |||
50 | ~CfgComponent() override; | | |||
51 | void load(KConfig *cfg) override; | | |||
52 | void save(KConfig *cfg) override; | | |||
53 | void defaults() override; | | |||
54 | bool isDefaults() const override; | | |||
55 | | ||||
56 | protected: | | |||
57 | QHash<QString, QString> m_lookupDict,m_revLookupDict; | | |||
58 | 43 | | |||
59 | protected Q_SLOTS: | | |||
60 | void slotComponentChanged(const QString&); | | |||
61 | Q_SIGNALS: | | |||
62 | void changed(bool); | | |||
63 | void defaulted(bool); | | |||
64 | }; | 44 | }; | ||
65 | 45 | | |||
66 | class ComponentChooser : public QWidget, public Ui::ComponentChooser_UI | 46 | class ComponentChooser : public QWidget, public Ui::ComponentChooser_UI | ||
67 | { | 47 | { | ||
68 | 48 | | |||
69 | Q_OBJECT | 49 | Q_OBJECT | ||
70 | 50 | | |||
71 | public: | 51 | public: | ||
72 | ComponentChooser(QWidget *parent=nullptr); | 52 | ComponentChooser(QWidget *parent=nullptr); | ||
73 | ~ComponentChooser() override; | 53 | ~ComponentChooser() override; | ||
74 | void load(); | 54 | void load(); | ||
75 | void save(); | 55 | void save(); | ||
76 | void restoreDefault(); | 56 | void restoreDefault(); | ||
77 | 57 | | |||
78 | private: | 58 | private: | ||
79 | QString latestEditedService; | | |||
80 | bool somethingChanged; | | |||
81 | QWidget *configWidget; | | |||
82 | QVBoxLayout *myLayout; | | |||
83 | QMap<QString, QWidget*> configWidgetMap; | 59 | QMap<QString, QWidget*> configWidgetMap; | ||
84 | 60 | | |||
85 | void loadConfigWidget(const QString &, const QString &, const QString &); | 61 | QWidget *loadConfigWidget(const QString &cfgType); | ||
86 | 62 | | |||
87 | protected Q_SLOTS: | 63 | protected Q_SLOTS: | ||
88 | void emitChanged(bool); | 64 | void emitChanged(bool); | ||
89 | void slotServiceSelected(QListWidgetItem *); | | |||
90 | 65 | | |||
91 | Q_SIGNALS: | 66 | Q_SIGNALS: | ||
92 | void changed(bool); | 67 | void changed(bool); | ||
93 | void defaulted(bool); | 68 | void defaulted(bool); | ||
94 | | ||||
95 | }; | 69 | }; | ||
96 | 70 | | |||
97 | 71 | | |||
98 | #endif | 72 | #endif |