summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-06-03 20:36:44 (UTC)
committer harlekin <harlekin>2004-06-03 20:36:44 (UTC)
commit52f849d3031f9d2fad2272ad069e7a1456c0ee54 (patch) (unidiff)
tree7d03d229363b81c40d180ee99d168e99c4f6c06e
parent74109985fd9ebdffd6cf0416207a69b17b563fd6 (diff)
downloadopie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.zip
opie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.tar.gz
opie-52f849d3031f9d2fad2272ad069e7a1456c0ee54.tar.bz2
updated today to use the new opluginloader, migration not finished yet but mostly working
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp372
-rw-r--r--core/pim/today/today.h27
-rw-r--r--core/pim/today/todayconfig.cpp137
-rw-r--r--core/pim/today/todayconfig.h18
4 files changed, 236 insertions, 318 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 0a6269e..a8c8651 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -16,4 +16,2 @@
16 16
17#define QTOPIA_INTERNAL_LANGLIST
18
19#include "today.h" 17#include "today.h"
@@ -21,4 +19,5 @@
21#include <opie2/odebug.h> 19#include <opie2/odebug.h>
20#include <opie2/opluginloader.h>
21#include <opie2/oconfig.h>
22 22
23#include <qpe/config.h>
24#include <qpe/qcopenvelope_qws.h> 23#include <qpe/qcopenvelope_qws.h>
@@ -33,20 +32,22 @@
33using namespace Opie::Ui; 32using namespace Opie::Ui;
33using Opie::Core::OPluginItem;
34using Opie::Core::OPluginLoader;
35using Opie::Core::OPluginManager;
36using Opie::Core::OConfig;
37
38
34struct TodayPlugin { 39struct TodayPlugin {
35 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} 40TodayPlugin() : iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
36 QLibrary *library;
37 QInterfacePtr<TodayPluginInterface> iface; 41 QInterfacePtr<TodayPluginInterface> iface;
38 TodayPluginObject *guiPart; 42 TodayPluginObject *guiPart;
43 OPluginItem oplugin;
39 QWidget *guiBox; 44 QWidget *guiBox;
40 QString name; 45 QString name;
41 bool active;
42 bool excludeRefresh; 46 bool excludeRefresh;
43 int pos;
44}; 47};
45 48
46static QValueList<TodayPlugin> pluginList; 49static QMap<QString, TodayPlugin> pluginList;
47
48static QMap<QString, TodayPlugin> tempList;
49 50
50Today::Today( QWidget* parent, const char* name, WFlags fl ) 51Today::Today( QWidget* parent, const char* name, WFlags fl )
51 : TodayBase( parent, name, fl ) { 52: TodayBase( parent, name, fl ) {
52 53
@@ -55,4 +56,5 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
55 56
56#if defined(Q_WS_QWS) 57 #if defined(Q_WS_QWS)
57#if !defined(QT_NO_COP) 58 #if !defined(QT_NO_COP)
59
58 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 60 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
@@ -60,12 +62,8 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
60 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); 62 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) );
61#endif 63 #endif
62#endif 64 #endif
63 65
64 setOwnerField(); 66 setOwnerField();
65 m_refreshTimer = new QTimer( this );
66 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
67 m_refreshTimer->start( 15000 );
68 m_big_box = 0L; 67 m_big_box = 0L;
69 68
70
71 layout = new QVBoxLayout( this ); 69 layout = new QVBoxLayout( this );
@@ -82,4 +80,8 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
82 80
83 qApp->processEvents(); 81 m_refreshTimer = new QTimer( this );
82 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
83
84 init();
84 loadPlugins(); 85 loadPlugins();
86 initialize();
85 QPEApplication::showWidget( this ); 87 QPEApplication::showWidget( this );
@@ -102,3 +104,2 @@ void Today::setRefreshTimer( int interval ) {
102 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 104 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
103
104 // 0 is "never" case 105 // 0 is "never" case
@@ -134,2 +135,3 @@ void Today::setOwnerField( QString &message ) {
134 135
136
135/** 137/**
@@ -139,7 +141,6 @@ void Today::init() {
139 // read config 141 // read config
140 Config cfg( "today" ); 142 OConfig cfg( "today" );
141
142 cfg.setGroup( "Plugins" ); 143 cfg.setGroup( "Plugins" );
143 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 144 // m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
144 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 145 // m_allApplets = cfg.readListEntry( "AllApplets", ',' );
145 146
@@ -171,2 +172,3 @@ void Today::init() {
171 172
173
172/** 174/**
@@ -176,160 +178,44 @@ void Today::loadPlugins() {
176 178
177 init(); 179 m_pluginLoader = new OPluginLoader( "today", true );
178 180 m_pluginLoader->setAutoDelete( true );
179 QValueList<TodayPlugin>::Iterator tit; 181
180 if ( !pluginList.isEmpty() ) { 182 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
181 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 183
182 (*tit).guiBox->hide(); 184 m_manager = new OPluginManager( m_pluginLoader );
183 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); 185 m_manager->load();
184 delete (*tit).guiBox; 186
185 (*tit).library->unload(); 187 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
186 delete (*tit).library; 188 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
187 } 189
188 pluginList.clear(); 190 TodayPlugin plugin;
191 plugin.iface = iface;
192 plugin.name = (*it).name();
193 plugin.oplugin = (*it);
194
195 plugin.guiPart = plugin.iface->guiPart();
196 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
197
198 // package the whole thing into a qwidget so it can be shown and hidden
199 plugin.guiBox = new QWidget( m_big_box );
200 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
201 QPixmap plugPix;
202 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
203 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
204 plugIcon->setPixmap( plugPix );
205 QWhatsThis::add
206 ( plugIcon, tr("Click here to launch the associated app") );
207 plugIcon->setName( plugin.guiPart->appName() );
208 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
209
210 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox );
211 boxLayout->addWidget( plugIcon, 0, AlignTop );
212 boxLayout->addWidget( plugWidget, 0, AlignTop );
213 boxLayout->setStretchFactor( plugIcon, 1 );
214 boxLayout->setStretchFactor( plugWidget, 9 );
215
216 pluginList.insert( plugin.name, plugin );
217 m_bblayout->addWidget(plugin.guiBox);
189 } 218 }
190 219
191 QString path = QPEApplication::qpeDir() + "/plugins/today"; 220 m_bblayout->addStretch( 1 );
192#ifdef Q_OS_MACX
193 owarn << "Searching for Plugins in: " << path << oendl;
194 QDir dir( path, "lib*.dylib" );
195#else
196 QDir dir( path, "lib*.so" );
197#endif
198
199 QStringList list = dir.entryList();
200 QStringList::Iterator it;
201
202 // QMap<QString, TodayPlugin> tempList;
203
204 for ( it = list.begin(); it != list.end(); ++it ) {
205 QInterfacePtr<TodayPluginInterface> iface;
206 QLibrary *lib = new QLibrary( path + "/" + *it );
207
208 odebug << "querying: " << path + "/" + *it << oendl;
209 if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
210 odebug << "accepted: " << path + "/" + *it << oendl;
211 odebug << *it << oendl;
212
213 TodayPlugin plugin;
214 plugin.library = lib;
215 plugin.iface = iface;
216 plugin.name = QString(*it);
217
218 QString type = (*it).left( (*it).find(".") );
219
220 QString lang;
221 Config config("locale");
222 config.setGroup("Language");
223 lang = config.readEntry( "Language", "en" );
224
225 odebug << "Languages: " << lang << oendl;
226 QTranslator * trans = new QTranslator( qApp );
227 QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm";
228 if ( trans->load( tfn ) ) {
229 qApp->installTranslator( trans );
230 } else {
231 delete trans;
232 }
233
234
235 // find out if plugins should be shown
236 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
237 plugin.active = true;
238 } else {
239 plugin.active = false;
240 }
241
242 plugin.guiPart = plugin.iface->guiPart();
243 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
244
245 // package the whole thing into a qwidget so it can be shown and hidden
246 plugin.guiBox = new QWidget( m_big_box );
247 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
248 QPixmap plugPix;
249 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
250 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
251 plugIcon->setPixmap( plugPix );
252 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
253 plugIcon->setName( plugin.guiPart->appName() );
254 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
255
256 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox );
257 boxLayout->addWidget( plugIcon, 0, AlignTop );
258 boxLayout->addWidget( plugWidget, 0, AlignTop );
259 boxLayout->setStretchFactor( plugIcon, 1 );
260 boxLayout->setStretchFactor( plugWidget, 9 );
261
262 // "prebuffer" it in one more list, to get the sorting done
263 tempList.insert( plugin.name, plugin );
264
265 // on first start the list is off course empty
266 if ( m_allApplets.isEmpty() ) {
267 pluginList.append( plugin );
268 m_bblayout->addWidget( plugin.guiBox );
269 }
270
271 // if plugin is not yet in the list, add it to the layout too
272 else if ( !m_allApplets.contains( plugin.name ) ) {
273 pluginList.append( plugin );
274 }
275 } else {
276 odebug << "could not recognize " << path + "/" + *it << oendl;
277 delete lib;
278 }
279
280 }
281
282
283 if ( !m_allApplets.isEmpty() ) {
284 TodayPlugin tempPlugin;
285 QStringList::Iterator stringit;
286
287 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
288 tempPlugin = ( tempList.find( *stringit ) ).data();
289 if ( !( (tempPlugin.name).isEmpty() ) ) {
290 pluginList.append( tempPlugin );
291 m_bblayout->addWidget( tempPlugin.guiBox );
292 }
293 }
294 }
295 m_bblayout->addStretch( 2 );
296 draw();
297}
298
299
300
301
302/**
303 * Repaint method. Reread all fields.
304 */
305void Today::draw() {
306
307 if ( pluginList.count() == 0 ) {
308 QLabel *noPlugins = new QLabel( this );
309 noPlugins->setText( tr( "No plugins found" ) );
310 layout->addWidget( noPlugins );
311 return;
312 }
313
314 uint count = 0;
315 TodayPlugin plugin;
316 for ( uint i = 0; i < pluginList.count(); i++ ) {
317 plugin = pluginList[i];
318
319 if ( plugin.active ) {
320 //odebug << plugin.name << " is ACTIVE " << oendl;
321 plugin.guiBox->show();
322 } else {
323 //odebug << plugin.name << " is INACTIVE " << oendl;
324 plugin.guiBox->hide();
325 }
326 count++;
327 }
328
329 if ( count == 0 ) {
330 QLabel *noPluginsActive = new QLabel( this );
331 noPluginsActive->setText( tr( "No plugins activated" ) );
332 layout->addWidget( noPluginsActive );
333 }
334 repaint();
335} 221}
@@ -347,20 +233,3 @@ void Today::startConfig() {
347 TodayConfig conf( this, "dialog", true ); 233 TodayConfig conf( this, "dialog", true );
348 234 conf.setUpPlugins( m_manager, m_pluginLoader );
349 TodayPlugin plugin;
350 QList<TodayConfigWidget> configWidgetList;
351
352 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
353 plugin = pluginList[i];
354
355 // load the config widgets in the tabs
356 if ( plugin.guiPart->configWidget( this ) != 0l ) {
357 TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 );
358 configWidgetList.append( widget );
359 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig()
360 , plugin.guiPart->appName() );
361 }
362 // set the order/activate tab
363 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
364 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
365 }
366 235
@@ -368,14 +237,5 @@ void Today::startConfig() {
368 conf.writeConfig(); 237 conf.writeConfig();
369 TodayConfigWidget *confWidget; 238 initialize();
370 for ( confWidget = configWidgetList.first(); confWidget != 0;
371 confWidget = configWidgetList.next() ) {
372 confWidget->writeConfig();
373 }
374
375 // make the plugins to reinitialize ( reread its configs )
376 reinitialize();
377 draw();
378
379 } else { 239 } else {
380 // since refresh is not called in that case , reconnect the signal 240 // since reinitialize is not called in that case , reconnect the signal
381 m_refreshTimer->start( 15000 ); // get the config value in here later 241 m_refreshTimer->start( 15000 ); // get the config value in here later
@@ -386,4 +246,3 @@ void Today::startConfig() {
386 246
387 247void Today::initialize() {
388void Today::reinitialize() {
389 248
@@ -391,21 +250,3 @@ void Today::reinitialize() {
391 cfg.setGroup( "Plugins" ); 250 cfg.setGroup( "Plugins" );
392 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
393 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
394
395 /* reinitialize all plugins */
396 QValueList<TodayPlugin>::Iterator it;
397 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
398 if ( !(*it).excludeRefresh ) {
399 (*it).guiPart->reinitialize();
400 odebug << "reinit" << oendl;
401 }
402 251
403 /* check if plugins is still to be shown */
404 if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) {
405 (*it).active = true;
406 } else {
407 (*it).active = false;
408 }
409
410 }
411 252
@@ -428,15 +269,41 @@ void Today::reinitialize() {
428 269
429 delete m_bblayout; 270 if ( m_bblayout ) {
430 m_bblayout = new QVBoxLayout( m_big_box ); 271 delete m_bblayout;
431 TodayPlugin tempPlugin; 272 }
432 QStringList::Iterator stringit; 273 m_bblayout = new QVBoxLayout ( m_big_box );
274
275 if ( pluginList.count() == 0 ) {
276 QLabel *noPlugins = new QLabel( this );
277 noPlugins->setText( tr( "No plugins found" ) );
278 layout->addWidget( noPlugins );
279 } else {
280
281 uint count = 0;
282 TodayPlugin tempPlugin;
283 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
284 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
433 285
434 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 286 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
435 tempPlugin = ( tempList.find( *stringit ) ).data(); 287
436 if ( !( (tempPlugin.name).isEmpty() ) ) { 288 tempPlugin = ( pluginList.find( (*it).name() ).data() );
437 m_bblayout->addWidget( tempPlugin.guiBox ); 289 if ( !( (tempPlugin.name).isEmpty() ) ) {
290 if ( (*it).isEnabled() ) {
291 iface->guiPart()->reinitialize();
292 odebug << "reinit" << oendl;
293 tempPlugin.guiBox->show();
294 m_bblayout->addWidget(tempPlugin.guiBox);
295 count++;
296 } else {
297 tempPlugin.guiBox->hide();
298 }
299 }
300 }
301 if ( count == 0 ) {
302 QLabel *noPluginsActive = new QLabel( this );
303 noPluginsActive->setText( tr( "No plugins activated" ) );
304 layout->addWidget( noPluginsActive );
438 } 305 }
439 } 306 }
440 m_bblayout->addStretch( 2 ); 307 m_bblayout->addStretch( 1 );
441 308 repaint();
442} 309}
@@ -449,8 +316,8 @@ void Today::refresh() {
449 316
450 QValueList<TodayPlugin>::Iterator it; 317 OPluginItem::List lst = m_pluginLoader->filtered( true );
451 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 318
452 if ( !(*it).excludeRefresh ) { 319 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
453 (*it).guiPart->refresh(); 320 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
454 odebug << "refresh" << oendl; 321 iface->guiPart()->refresh();
455 } 322 odebug << "refresh" << oendl;
456 } 323 }
@@ -463,2 +330,3 @@ void Today::refresh() {
463 330
331
464void Today::startApplication() { 332void Today::startApplication() {
@@ -468,5 +336,6 @@ void Today::startApplication() {
468 336
337
469/** 338/**
470 * launch addressbook (personal card) 339* launch addressbook (personal card)
471 */ 340*/
472void Today::editCard() { 341void Today::editCard() {
@@ -475,3 +344,10 @@ void Today::editCard() {
475 344
345
476Today::~Today() { 346Today::~Today() {
347 if (m_pluginLoader) {
348 delete m_pluginLoader;
349 }
350 if (m_manager) {
351 delete m_manager;
352 }
477} 353}
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index 89170e1..c947ae1 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -24,2 +24,3 @@
24#include <opie2/oclickablelabel.h> 24#include <opie2/oclickablelabel.h>
25#include <opie2/opluginloader.h>
25 26
@@ -30,5 +31,12 @@
30 31
31 32
32class QVBoxLayout; 33class QVBoxLayout;
33 34
35namespace Opie {
36 namespace Core {
37 class OPluginManager;
38 class OPluginLoader;
39 }
40}
41
34class Today : public TodayBase { 42class Today : public TodayBase {
@@ -37,6 +45,8 @@ class Today : public TodayBase {
37 45
38 public: 46public:
39 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 47 Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
40 ~Today(); 48 ~Today();
41 static QString appName() { return QString::fromLatin1("today"); } 49 static QString appName() {
50 return QString::fromLatin1("today");
51 }
42 52
@@ -52,5 +62,3 @@ private:
52 void setOwnerField(QString &string); 62 void setOwnerField(QString &string);
53 void loadPlugins(); 63 void initialize();
54 void draw();
55 void reinitialize();
56 64
@@ -60,4 +68,5 @@ private slots:
60 void channelReceived(const QCString &msg, const QByteArray & data); 68 void channelReceived(const QCString &msg, const QByteArray & data);
69 void loadPlugins();
61 70
62 private: 71private:
63 TodayConfig *conf; 72 TodayConfig *conf;
@@ -70,3 +79,4 @@ private slots:
70 79
71 80 Opie::Core::OPluginLoader *m_pluginLoader;
81 Opie::Core::OPluginManager *m_manager;
72 82
@@ -80,3 +90,2 @@ private slots:
80}; 90};
81
82#endif 91#endif
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp
index 4f0877c..c9823d4 100644
--- a/core/pim/today/todayconfig.cpp
+++ b/core/pim/today/todayconfig.cpp
@@ -18,3 +18,6 @@
18 18
19#include <qpe/config.h> 19#include <opie2/oconfig.h>
20#include <opie2/opluginloader.h>
21#include <opie2/todayplugininterface.h>
22
20#include <qpe/resource.h> 23#include <qpe/resource.h>
@@ -33,2 +36,7 @@
33using namespace Opie::Ui; 36using namespace Opie::Ui;
37using Opie::Core::OConfig;
38using Opie::Core::OPluginManager;
39using Opie::Core::OPluginLoader;
40using Opie::Core::OPluginItem;
41
34class ToolButton : public QToolButton { 42class ToolButton : public QToolButton {
@@ -37,3 +45,3 @@ public:
37 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 45 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
38 : QToolButton( parent, name ) { 46: QToolButton( parent, name ) {
39 setPixmap( Resource::loadPixmap( icon ) ); 47 setPixmap( Resource::loadPixmap( icon ) );
@@ -53,3 +61,3 @@ public:
53TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal ) 61TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
54 : QDialog( parent, name, modal, WStyle_ContextHelp ) { 62: QDialog( parent, name, modal, WStyle_ContextHelp ) {
55 63
@@ -70,3 +78,4 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
70 m_appletListView->setSorting( -1 ); 78 m_appletListView->setSorting( -1 );
71 QWhatsThis::add( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) ); 79 QWhatsThis::add
80 ( m_appletListView, tr( "Check a checkbox to activate/deactivate a plugin or use the arrow buttons on the right to change the appearance order" ) );
72 QVBox *vbox1 = new QVBox( hbox1 ); 81 QVBox *vbox1 = new QVBox( hbox1 );
@@ -86,6 +95,4 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
86 95
87 m_applets_changed = false;
88
89 connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) ); 96 connect ( m_appletListView , SIGNAL( clicked(QListViewItem*) ), this, SLOT( appletChanged() ) );
90 97 previousItem = 0l;
91 readConfig(); 98 readConfig();
@@ -95,2 +102,30 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
95 102
103void TodayConfig::setUpPlugins( OPluginManager * plugManager, OPluginLoader *plugLoader ) {
104
105
106 m_pluginManager = plugManager;
107 m_pluginLoader = plugLoader;
108
109 OPluginItem::List inLst = m_pluginLoader->allAvailable( true );
110
111 OPluginItem::List lst;
112 for ( OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) {
113 lst.prepend((*it));
114
115 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
116
117 if ( iface->guiPart()->configWidget(this) != 0l ) {
118 TodayConfigWidget* widget = iface->guiPart()->configWidget( TabWidget3 );
119 TabWidget3->addTab( widget, iface->guiPart()->pixmapNameConfig()
120 , iface->guiPart()->appName() );
121 }
122 }
123
124 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
125 pluginManagement( (*it) );
126 }
127
128 TabWidget3->setCurrentTab( tab_2 );
129}
130
96/** 131/**
@@ -100,3 +135,3 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
100void TodayConfig::setAutoStart() { 135void TodayConfig::setAutoStart() {
101 Config cfg( "today" ); 136 OConfig cfg( "today" );
102 cfg.setGroup( "Autostart" ); 137 cfg.setGroup( "Autostart" );
@@ -118,3 +153,3 @@ void TodayConfig::setAutoStart() {
118void TodayConfig::readConfig() { 153void TodayConfig::readConfig() {
119 Config cfg( "today" ); 154 OConfig cfg( "today" );
120 cfg.setGroup( "Autostart" ); 155 cfg.setGroup( "Autostart" );
@@ -130,6 +165,2 @@ void TodayConfig::readConfig() {
130 m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) ); 165 m_guiMisc->CheckBoxHide->setChecked( cfg.readNumEntry( "HideBanner", 0 ) );
131
132
133 cfg.setGroup( "Plugins" );
134 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
135} 166}
@@ -140,33 +171,24 @@ void TodayConfig::readConfig() {
140void TodayConfig::writeConfig() { 171void TodayConfig::writeConfig() {
141 Config cfg( "today" ); 172 OConfig cfg( "today" );
142 cfg.setGroup( "Plugins" ); 173
143 if ( m_applets_changed ) { 174 int position = m_appletListView->childCount();
144 QStringList exclude; 175
145 QStringList include; 176 QListViewItemIterator list_it( m_appletListView );
146 QStringList all_applets; 177 //
147 178 // this makes sure the names get saved in the order selected
148 QListViewItemIterator list_it( m_appletListView ); 179 for ( ; list_it.current(); ++list_it ) {
149 180 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
150 // this makes sure the names get saved in the order selected 181 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
151 for ( ; list_it.current(); ++list_it ) { 182 if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) {
152 QMap <QString, QCheckListItem *>::Iterator it; 183 (*it).setPosition(position--);
153 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { 184 m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() );
154 if ( list_it.current() == (*it) && !(*it)-> isOn () ) {
155 exclude << it.key();
156 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){
157 include << it.key();
158 }
159 if ( list_it.current() == (*it) ) {
160 all_applets << it.key();
161 }
162 } 185 }
163 } 186 }
164 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
165 cfg.writeEntry( "IncludeApplets", include, ',' );
166 cfg.writeEntry( "AllApplets", all_applets, ',' );
167 } 187 }
168 188
189 m_pluginManager->save();
190
169 cfg.setGroup( "Autostart" ); 191 cfg.setGroup( "Autostart" );
170 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); 192 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked();
171 cfg.writeEntry( "autostart", m_autoStart ); 193 cfg.writeEntry( "autostart", m_autoStart );
172 m_autoStartTimer = m_guiMisc->SpinBoxTime->value(); 194 m_autoStartTimer = m_guiMisc->SpinBoxTime->value();
@@ -182,2 +204,10 @@ void TodayConfig::writeConfig() {
182 setAutoStart(); 204 setAutoStart();
205
206 OPluginItem::List lst = m_pluginManager->managedPlugins();
207 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
208 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
209 if ( iface->guiPart()->configWidget(this) != 0l ) {
210 iface->guiPart()->configWidget(this)->writeConfig();
211 }
212 }
183} 213}
@@ -204,23 +234,13 @@ void TodayConfig::moveSelectedDown() {
204 */ 234 */
205void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { 235void TodayConfig::pluginManagement( OPluginItem plugItem ) {
206
207 QCheckListItem *item;
208 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox );
209 236
210 if ( !icon.isNull() ) { 237 QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox );
211 item->setPixmap( 0, icon );
212 }
213
214 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) {
215 item->setOn( TRUE );
216 }
217
218 m_applets[libName] = item;
219 238
220 // kind of hack to get the first tab as default. 239 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface );
221 TabWidget3->setCurrentTab( tab_2 ); 240 QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() );
222} 241 if ( !icon.isNull() ) {
223 242 item->setPixmap( 0, icon );
224void TodayConfig::appletChanged() { 243 }
225 m_applets_changed = true; 244 item->setOn( plugItem.isEnabled() );
245 previousItem = item;
226} 246}
@@ -228,4 +248,3 @@ void TodayConfig::appletChanged() {
228 248
229TodayConfig::~TodayConfig() {
230}
231 249
250TodayConfig::~TodayConfig() {}
diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h
index 2b6c507..ab79f31 100644
--- a/core/pim/today/todayconfig.h
+++ b/core/pim/today/todayconfig.h
@@ -22,2 +22,3 @@
22#include <opie2/otabwidget.h> 22#include <opie2/otabwidget.h>
23#include <opie2/opluginloader.h>
23 24
@@ -32,2 +33,10 @@ class QTabWidget;
32 33
34namespace Opie {
35 namespace Core {
36 class OPluginManager;
37 class OPluginLoader;
38 class OPluginItem;
39 }
40}
41
33class TodayConfig : public QDialog { 42class TodayConfig : public QDialog {
@@ -43,7 +52,6 @@ public:
43 void writeConfig(); 52 void writeConfig();
44 void pluginManagement( QString libName, QString name, QPixmap icon );
45 53
54 void setUpPlugins( Opie::Core::OPluginManager * plugManager, Opie::Core::OPluginLoader * plugLoader );
46 55
47protected slots: 56protected slots:
48 void appletChanged();
49 void moveSelectedUp(); 57 void moveSelectedUp();
@@ -54,2 +62,3 @@ private:
54 void readConfig(); 62 void readConfig();
63 void pluginManagement( Opie::Core::OPluginItem plugItem);
55 64
@@ -69,2 +78,7 @@ private:
69 78
79 Opie::Core::OPluginManager *m_pluginManager;
80 Opie::Core::OPluginLoader *m_pluginLoader;
81
82 QCheckListItem *previousItem;
83
70 TodayConfigMiscBase *m_guiMisc; 84 TodayConfigMiscBase *m_guiMisc;