From 9521c1627157bf15824b5b55b9782b87cc610df6 Mon Sep 17 00:00:00 2001 From: zecke Date: Fri, 28 May 2004 16:20:57 +0000 Subject: Ideas of the API of the Generic PluginLoader --- 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 @@ -21,7 +21,8 @@ namespace Ui { * 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 @@ -40,26 +41,51 @@ public: 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 m_items; }; } 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 + +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) { + +} + +} +} -- cgit v0.9.0.2