summaryrefslogtreecommitdiff
authorzecke <zecke>2004-05-28 16:20:57 (UTC)
committer zecke <zecke>2004-05-28 16:20:57 (UTC)
commit9521c1627157bf15824b5b55b9782b87cc610df6 (patch) (unidiff)
treeee0d9dc734e8db0e85a3e4d6ad0ee548c31f4115
parent8db08a3d320e48924d0ccd78d2bd177e316fff90 (diff)
downloadopie-9521c1627157bf15824b5b55b9782b87cc610df6.zip
opie-9521c1627157bf15824b5b55b9782b87cc610df6.tar.gz
opie-9521c1627157bf15824b5b55b9782b87cc610df6.tar.bz2
Ideas of the API of the Generic PluginLoader
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/opluginconfig.h36
-rw-r--r--libopie2/opieui/opluginconfigwidget.cpp136
2 files changed, 167 insertions, 5 deletions
diff --git a/libopie2/opieui/opluginconfig.h b/libopie2/opieui/opluginconfig.h
index bfee5bf..0db1fcb 100644
--- a/libopie2/opieui/opluginconfig.h
+++ b/libopie2/opieui/opluginconfig.h
@@ -8,61 +8,87 @@
8 8
9namespace Opie { 9namespace Opie {
10namespace Core { 10namespace Core {
11 class OPluginManager; 11 class OPluginManager;
12 class OGenericPluginLoader; 12 class OGenericPluginLoader;
13} 13}
14namespace Ui { 14namespace Ui {
15/** 15/**
16 * With this widget you can configure one or many PluginLoaders either 16 * With this widget you can configure one or many PluginLoaders either
17 * through an already existing Opie::Core::OPluginManager or Opie::Core::OGenericPluginLoader 17 * through an already existing Opie::Core::OPluginManager or Opie::Core::OGenericPluginLoader
18 * The sorted state will be read from the Loader. 18 * The sorted state will be read from the Loader.
19 * 19 *
20 * As with Opie::Ui::OKeyConfigWidget you can have two options. To either apply your changes 20 * As with Opie::Ui::OKeyConfigWidget you can have two options. To either apply your changes
21 * directly through Opie::Core::OPluginManager or to use Queued where you manually need to 21 * directly through Opie::Core::OPluginManager or to use Queued where you manually need to
22 * call save. 22 * call save.
23 * 23 *
24 * Internally we operate on Opie::Core::OPluginManager. 24 * Internally we operate on Opie::Core::OPluginManager. You can insert any numbers of loaders
25 * or pluginmanagers. But you need to call load() after you've inserted new items.
25 * 26 *
26 * @see Opie::Ui::OKeyConfigWidget 27 * @see Opie::Ui::OKeyConfigWidget
27 * @see Opie::Core::OPluginLoader 28 * @see Opie::Core::OPluginLoader
28 * @see Opie::Core::OPluginManager 29 * @see Opie::Core::OPluginManager
29 * 30 *
30 * @author zecke 31 * @author zecke
31 * @since Opie 1.1.5 32 * @since Opie 1.1.5
32 * 33 *
33 */ 34 */
34class OPluginConfigWidget : public QWidget { 35class OPluginConfigWidget : public QWidget {
35public: 36public:
36 enum ChangeMode { Queued, Immediate }; 37 enum ChangeMode { Queued, Immediate };
37 OPluginConfigWidget( QWidget* wid = 0, const char* name = 0, WFlags fl = 0); 38 OPluginConfigWidget( QWidget* wid = 0, const char* name = 0, WFlags fl = 0);
38 OPluginConfig( Opie::Core::OPluginManager* manager, QWidget* wid = 0, 39 OPluginConfig( Opie::Core::OPluginManager* manager, QWidget* wid = 0,
39 const char* name = 0, WFlags fl = 0); 40 const char* name = 0, WFlags fl = 0);
40 OPluginConfig( Opie::Core::OGenericPluginLoader* loader, QWidget* wid, const char* name, 41 OPluginConfig( Opie::Core::OGenericPluginLoader* loader, QWidget* wid, const char* name,
41 WFlags fl ); 42 WFlags fl );
42 43
43 ~OPluginConfig(); 44 virtual ~OPluginConfig();
44 45
45 void setChangeMode( enum Mode ); 46 void setChangeMode( enum ChangeMode );
46 ChangeMode mode()const; 47 ChangeMode mode()const;
47 48
48 void insert( const QString&, const Opie::Core::OPluginManager* ); 49 void insert( const QString&, const Opie::Core::OPluginManager* );
49 void insert( const QString&, const Opie::Core::OPluginLoader* ); 50 void insert( const QString&, const Opie::Core::OGenericPluginLoader* );
50 51
51signals: 52signals:
52 /** 53 /**
53 * @param item The new OPluginItem 54 * A PluginItem was changed. This signal is only emitted if you're
55 * in the immediate ChangeMode.
56 * This is emitted on any change ( disable,enable,pos)
57 *
58 * @param item The OPluginItem that was changed. This is how it looks now
59 * @param old_state If it was enabled before
54 */ 60 */
55 void pluginChanged ( const Opie::Core::OPluginItem& item, bool old_state); 61 void pluginChanged ( const Opie::Core::OPluginItem& item, bool old_state);
62
63 /**
64 * emitted only if you're in Immediate when an Item was enabled
65 *
66 * @param item The Item that was enabled
67 */
56 void pluginEnabled ( const Opie::Core::OPluginItem& item); 68 void pluginEnabled ( const Opie::Core::OPluginItem& item);
69
70 /**
71 * emitted only if you're in Immediate when an Item was enabled
72 *
73 * @param item The Item was disabled
74 */
57 void pluginDisabled( const Opie::Core::OPluginItem& item); 75 void pluginDisabled( const Opie::Core::OPluginItem& item);
76
77 /**
78 * Data was saved(). Normally this is emitted when save() is called
79 * @see changed
80 */
81 void changed();
58public: 82public:
59 83
60 void load(); 84 void load();
61 void save(); 85 void save();
62private: 86private:
87 ChangeMode m_mode;
88 QMap<Opie::Core::OPluginManager*, bool> m_items;
63 89
64}; 90};
65} 91}
66} 92}
67 93
68#endif 94#endif
diff --git a/libopie2/opieui/opluginconfigwidget.cpp b/libopie2/opieui/opluginconfigwidget.cpp
new file mode 100644
index 0000000..359e7a1
--- a/dev/null
+++ b/libopie2/opieui/opluginconfigwidget.cpp
@@ -0,0 +1,136 @@
1/*
2 * LGPLv2 2004 zecke@handhelds.org
3 */
4
5
6#include "opluginconfig.h"
7
8#include <opie/opluginloader.h>
9
10using Opie::Core::OPluginManager;
11using Opie::Core::OGenericPluginLoader;
12
13namespace Opie {
14namespace Ui {
15
16}
17}
18
19/**
20 * C'tor compatible with all Qt Widgets in its arguments.
21 * After constructing you need to insert and call load()
22 *
23 * The default mode is Queued
24 *
25 * @param wid the Widget
26 * @param name The name of the widget
27 * @param fl The widget flags you may want to set
28 *
29 * @see QWidget::QWidget
30 */
31OPluginConfigWidget::OPluginConfigWidget( QWidget* wid, const char *name, WFlags fl )
32 : QWidget( wid, name, fl ), m_mode( Queued )
33{
34}
35
36/**
37 * C'tor where you can give a Opie::Core::OPluginManager and additional optional
38 * parameters.
39 *
40 * This call insert for the OPluginManager you pass to this method. You'll still
41 * need to call load after constructing this widget.
42 *
43 * Ownership will not be transfered
44 *
45 * The default mode is Queued
46 *
47 * @param manager The OPluginManager you pass
48 * @param wid The QWidget parent
49 * @param name the Name of the widget
50 * @param fl Possible Flags
51 *
52 */
53OPluginConfigWidget::OPluginConfigWidget( Opie::Core::OPluginManager* manager,
54 QWidget* wid, const char* name, WFlags fl )
55 : QWidget( wid, name, fl ), m_mode( Queued )
56{
57 insert( QString::null, manager );
58}
59
60
61/**
62 * C'tor where you can give a Opie::Core::OGenericPluginLoader and additional optional
63 * parameters. Internally we use a Opie::Core::OPluginManager on top of the loader.
64 *
65 * This call insert for the Opie::Core::OGenericPluginLoader you pass to this method.
66 * You'll still need to call load() after constructing this widget.
67 *
68 * It is still your OGenericPluginLoader and ownership is not transfered.
69 *
70 * The default mode is Queued
71 *
72 * @param manager The OGenericPluginLoader you pass
73 * @param wid The QWidget parent
74 * @param name the Name of the widget
75 * @param fl Possible Flags
76 *
77 */
78OPluginConfigWidget::OPluginConfigWidget( Opie::Core::OGenericPluginLoader* load,
79 QWidget* wid, const char* name, WFlags fl )
80 : QWidget( wid, name, fl ), m_mode( Queued )
81{
82 insert( QString::null, load );
83}
84
85/**
86 * d'tor. This does not save the changes if your in Queued mode
87 * make sure to call save() before destructing this widget.
88 */
89OPluginConfigWidget::~OPluginConfigWidget() {
90//
91}
92
93/**
94 * Set the ChangeMode of this widget. Currently there are two possible values.
95 * Immediate - all changes by the user are immediately applied and signals are emitted
96 * the signals emitted are plugin* and also changed() due calling save internally
97 * Queued - changes need to be saved manually. save() emits changed()
98 *
99 * @param mode the ChangeMode to use. Either use Immediate or Queued
100 */
101void OPluginConfigWidget::setChangeMode( enum OPluginConfigWidget::ChangeMode mode ) {
102 m_mode = mode;
103}
104
105/**
106 * Return the Mode
107 *
108 * @return Returns the change mode this widget is in.
109 * @see OPluginConfigWidget::ChangeMode
110 * @see OPluginConfigWidget::setChangeMode
111 */
112OPluginConfigWidget::ChangeMode OPluginConfigWidget::mode()const{
113 return m_mode;
114}
115
116/**
117 * Insert a PluginManager directly. Ownership is not transfered.
118 *
119 * @param name The name represented to the user
120 * @param mana The manager which should be inserted
121 */
122void OPluginConfigWidget::insert( const QString& name, const Opie::Core::OPluginManager* mana) {
123
124}
125
126/**
127 *
128 * @param name The name
129 *
130 */
131void OPluginConfigWidget::insert( const QString& name, const Opie::Core::OGenericPluginLoader* load) {
132
133}
134
135}
136}