summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -1,68 +1,94 @@
/*
* LGPLv2 zecke@handhelds.org
*/
#ifndef ODP_OPIE_UI_OPLUGIN_CONFIG_H
#define ODP_OPIE_UI_OPLUGIN_CONFIG_H
#include <qwidget.h>
namespace Opie {
namespace Core {
class OPluginManager;
class OGenericPluginLoader;
}
namespace Ui {
/**
* With this widget you can configure one or many PluginLoaders either
* through an already existing Opie::Core::OPluginManager or Opie::Core::OGenericPluginLoader
* The sorted state will be read from the Loader.
*
* As with Opie::Ui::OKeyConfigWidget you can have two options. To either apply your changes
* directly through Opie::Core::OPluginManager or to use Queued where you manually need to
* call save.
*
- * Internally we operate on Opie::Core::OPluginManager.
+ * Internally we operate on Opie::Core::OPluginManager. You can insert any numbers of loaders
+ * or pluginmanagers. But you need to call load() after you've inserted new items.
*
* @see Opie::Ui::OKeyConfigWidget
* @see Opie::Core::OPluginLoader
* @see Opie::Core::OPluginManager
*
* @author zecke
* @since Opie 1.1.5
*
*/
class OPluginConfigWidget : public QWidget {
public:
enum ChangeMode { Queued, Immediate };
OPluginConfigWidget( QWidget* wid = 0, const char* name = 0, WFlags fl = 0);
OPluginConfig( Opie::Core::OPluginManager* manager, QWidget* wid = 0,
const char* name = 0, WFlags fl = 0);
OPluginConfig( Opie::Core::OGenericPluginLoader* loader, QWidget* wid, const char* name,
WFlags fl );
- ~OPluginConfig();
+ virtual ~OPluginConfig();
- void setChangeMode( enum Mode );
+ void setChangeMode( enum ChangeMode );
ChangeMode mode()const;
void insert( const QString&, const Opie::Core::OPluginManager* );
- void insert( const QString&, const Opie::Core::OPluginLoader* );
+ void insert( const QString&, const Opie::Core::OGenericPluginLoader* );
signals:
/**
- * @param item The new OPluginItem
+ * A PluginItem was changed. This signal is only emitted if you're
+ * in the immediate ChangeMode.
+ * This is emitted on any change ( disable,enable,pos)
+ *
+ * @param item The OPluginItem that was changed. This is how it looks now
+ * @param old_state If it was enabled before
*/
void pluginChanged ( const Opie::Core::OPluginItem& item, bool old_state);
+
+ /**
+ * emitted only if you're in Immediate when an Item was enabled
+ *
+ * @param item The Item that was enabled
+ */
void pluginEnabled ( const Opie::Core::OPluginItem& item);
+
+ /**
+ * emitted only if you're in Immediate when an Item was enabled
+ *
+ * @param item The Item was disabled
+ */
void pluginDisabled( const Opie::Core::OPluginItem& item);
+
+ /**
+ * Data was saved(). Normally this is emitted when save() is called
+ * @see changed
+ */
+ void changed();
public:
void load();
void save();
private:
+ ChangeMode m_mode;
+ QMap<Opie::Core::OPluginManager*, bool> m_items;
};
}
}
#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 @@
+/*
+ * LGPLv2 2004 zecke@handhelds.org
+ */
+
+
+#include "opluginconfig.h"
+
+#include <opie/opluginloader.h>
+
+using Opie::Core::OPluginManager;
+using Opie::Core::OGenericPluginLoader;
+
+namespace Opie {
+namespace Ui {
+
+}
+}
+
+/**
+ * C'tor compatible with all Qt Widgets in its arguments.
+ * After constructing you need to insert and call load()
+ *
+ * The default mode is Queued
+ *
+ * @param wid the Widget
+ * @param name The name of the widget
+ * @param fl The widget flags you may want to set
+ *
+ * @see QWidget::QWidget
+ */
+OPluginConfigWidget::OPluginConfigWidget( QWidget* wid, const char *name, WFlags fl )
+ : QWidget( wid, name, fl ), m_mode( Queued )
+{
+}
+
+/**
+ * C'tor where you can give a Opie::Core::OPluginManager and additional optional
+ * parameters.
+ *
+ * This call insert for the OPluginManager you pass to this method. You'll still
+ * need to call load after constructing this widget.
+ *
+ * Ownership will not be transfered
+ *
+ * The default mode is Queued
+ *
+ * @param manager The OPluginManager you pass
+ * @param wid The QWidget parent
+ * @param name the Name of the widget
+ * @param fl Possible Flags
+ *
+ */
+OPluginConfigWidget::OPluginConfigWidget( Opie::Core::OPluginManager* manager,
+ QWidget* wid, const char* name, WFlags fl )
+ : QWidget( wid, name, fl ), m_mode( Queued )
+{
+ insert( QString::null, manager );
+}
+
+
+/**
+ * C'tor where you can give a Opie::Core::OGenericPluginLoader and additional optional
+ * parameters. Internally we use a Opie::Core::OPluginManager on top of the loader.
+ *
+ * This call insert for the Opie::Core::OGenericPluginLoader you pass to this method.
+ * You'll still need to call load() after constructing this widget.
+ *
+ * It is still your OGenericPluginLoader and ownership is not transfered.
+ *
+ * The default mode is Queued
+ *
+ * @param manager The OGenericPluginLoader you pass
+ * @param wid The QWidget parent
+ * @param name the Name of the widget
+ * @param fl Possible Flags
+ *
+ */
+OPluginConfigWidget::OPluginConfigWidget( Opie::Core::OGenericPluginLoader* load,
+ QWidget* wid, const char* name, WFlags fl )
+ : QWidget( wid, name, fl ), m_mode( Queued )
+{
+ insert( QString::null, load );
+}
+
+/**
+ * d'tor. This does not save the changes if your in Queued mode
+ * make sure to call save() before destructing this widget.
+ */
+OPluginConfigWidget::~OPluginConfigWidget() {
+//
+}
+
+/**
+ * Set the ChangeMode of this widget. Currently there are two possible values.
+ * Immediate - all changes by the user are immediately applied and signals are emitted
+ * the signals emitted are plugin* and also changed() due calling save internally
+ * Queued - changes need to be saved manually. save() emits changed()
+ *
+ * @param mode the ChangeMode to use. Either use Immediate or Queued
+ */
+void OPluginConfigWidget::setChangeMode( enum OPluginConfigWidget::ChangeMode mode ) {
+ m_mode = mode;
+}
+
+/**
+ * Return the Mode
+ *
+ * @return Returns the change mode this widget is in.
+ * @see OPluginConfigWidget::ChangeMode
+ * @see OPluginConfigWidget::setChangeMode
+ */
+OPluginConfigWidget::ChangeMode OPluginConfigWidget::mode()const{
+ return m_mode;
+}
+
+/**
+ * Insert a PluginManager directly. Ownership is not transfered.
+ *
+ * @param name The name represented to the user
+ * @param mana The manager which should be inserted
+ */
+void OPluginConfigWidget::insert( const QString& name, const Opie::Core::OPluginManager* mana) {
+
+}
+
+/**
+ *
+ * @param name The name
+ *
+ */
+void OPluginConfigWidget::insert( const QString& name, const Opie::Core::OGenericPluginLoader* load) {
+
+}
+
+}
+}