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) (show whitespace changes)
-rw-r--r--core/pim/today/today.cpp292
-rw-r--r--core/pim/today/today.h21
-rw-r--r--core/pim/today/todayconfig.cpp117
-rw-r--r--core/pim/today/todayconfig.h18
4 files changed, 183 insertions, 265 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,17 +32,19 @@
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
@@ -57,2 +58,3 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
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 );
@@ -64,8 +66,4 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
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,66 +178,17 @@ 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;
180 if ( !pluginList.isEmpty() ) {
181 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
182 (*tit).guiBox->hide();
183 (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) );
184 delete (*tit).guiBox;
185 (*tit).library->unload();
186 delete (*tit).library;
187 }
188 pluginList.clear();
189 }
190
191 QString path = QPEApplication::qpeDir() + "/plugins/today";
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 181
199 QStringList list = dir.entryList(); 182 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
200 QStringList::Iterator it;
201 183
202 // QMap<QString, TodayPlugin> tempList; 184 m_manager = new OPluginManager( m_pluginLoader );
185 m_manager->load();
203 186
204 for ( it = list.begin(); it != list.end(); ++it ) { 187 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
205 QInterfacePtr<TodayPluginInterface> iface; 188 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( *it, IID_TodayPluginInterface );
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 189
213 TodayPlugin plugin; 190 TodayPlugin plugin;
214 plugin.library = lib;
215 plugin.iface = iface; 191 plugin.iface = iface;
216 plugin.name = QString(*it); 192 plugin.name = (*it).name();
217 193 plugin.oplugin = (*it);
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 194
@@ -251,3 +204,4 @@ void Today::loadPlugins() {
251 plugIcon->setPixmap( plugPix ); 204 plugIcon->setPixmap( plugPix );
252 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 205 QWhatsThis::add
206 ( plugIcon, tr("Click here to launch the associated app") );
253 plugIcon->setName( plugin.guiPart->appName() ); 207 plugIcon->setName( plugin.guiPart->appName() );
@@ -261,8 +215,3 @@ void Today::loadPlugins() {
261 215
262 // "prebuffer" it in one more list, to get the sorting done 216 pluginList.insert( plugin.name, plugin );
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 ); 217 m_bblayout->addWidget( plugin.guiBox );
@@ -270,66 +219,3 @@ void Today::loadPlugins() {
270 219
271 // if plugin is not yet in the list, add it to the layout too 220 m_bblayout->addStretch( 1 );
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
270 if ( m_bblayout ) {
429 delete m_bblayout; 271 delete m_bblayout;
272 }
430 m_bblayout = new QVBoxLayout( m_big_box ); 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;
431 TodayPlugin tempPlugin; 282 TodayPlugin tempPlugin;
432 QStringList::Iterator stringit; 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
288 tempPlugin = ( pluginList.find( (*it).name() ).data() );
436 if ( !( (tempPlugin.name).isEmpty() ) ) { 289 if ( !( (tempPlugin.name).isEmpty() ) ) {
290 if ( (*it).isEnabled() ) {
291 iface->guiPart()->reinitialize();
292 odebug << "reinit" << oendl;
293 tempPlugin.guiBox->show();
437 m_bblayout->addWidget( tempPlugin.guiBox ); 294 m_bblayout->addWidget( tempPlugin.guiBox );
295 count++;
296 } else {
297 tempPlugin.guiBox->hide();
438 } 298 }
439 } 299 }
440 m_bblayout->addStretch( 2 ); 300 }
441 301 if ( count == 0 ) {
302 QLabel *noPluginsActive = new QLabel( this );
303 noPluginsActive->setText( tr( "No plugins activated" ) );
304 layout->addWidget( noPluginsActive );
305 }
306 }
307 m_bblayout->addStretch( 1 );
308 repaint();
442} 309}
@@ -449,9 +316,9 @@ 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 );
321 iface->guiPart()->refresh();
454 odebug << "refresh" << oendl; 322 odebug << "refresh" << oendl;
455 } 323 }
456 }
457 324
@@ -463,2 +330,3 @@ void Today::refresh() {
463 330
331
464void Today::startApplication() { 332void Today::startApplication() {
@@ -468,2 +336,3 @@ void Today::startApplication() {
468 336
337
469/** 338/**
@@ -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
@@ -33,2 +34,9 @@ class 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 {
@@ -40,3 +48,5 @@ class Today : public TodayBase {
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,2 +68,3 @@ 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
@@ -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 {
@@ -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,22 +171,15 @@ void TodayConfig::readConfig() {
140void TodayConfig::writeConfig() { 171void TodayConfig::writeConfig() {
141 Config cfg( "today" ); 172 OConfig cfg( "today" );
142 cfg.setGroup( "Plugins" );
143 if ( m_applets_changed ) {
144 QStringList exclude;
145 QStringList include;
146 QStringList all_applets;
147 173
148 QListViewItemIterator list_it( m_appletListView ); 174 int position = m_appletListView->childCount();
149 175
176 QListViewItemIterator list_it( m_appletListView );
177 //
150 // this makes sure the names get saved in the order selected 178 // this makes sure the names get saved in the order selected
151 for ( ; list_it.current(); ++list_it ) { 179 for ( ; list_it.current(); ++list_it ) {
152 QMap <QString, QCheckListItem *>::Iterator it; 180 OPluginItem::List lst = m_pluginLoader->allAvailable( true );
153 for ( it = m_applets.begin(); it != m_applets. end (); ++it ) { 181 for ( OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) {
154 if ( list_it.current() == (*it) && !(*it)-> isOn () ) { 182 if ( QString::compare( (*it).name() , list_it.current()->text(0) ) == 0 ) {
155 exclude << it.key(); 183 (*it).setPosition(position--);
156 } else if ( list_it.current() == (*it) && (*it)-> isOn () ){ 184 m_pluginManager->setEnabled( (*it),((QCheckListItem*)list_it.current())->isOn() );
157 include << it.key();
158 }
159 if ( list_it.current() == (*it) ) {
160 all_applets << it.key();
161 } 185 }
@@ -163,6 +187,4 @@ void TodayConfig::writeConfig() {
163 } 187 }
164 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 188
165 cfg.writeEntry( "IncludeApplets", include, ',' ); 189 m_pluginManager->save();
166 cfg.writeEntry( "AllApplets", all_applets, ',' );
167 }
168 190
@@ -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,7 +234,8 @@ void TodayConfig::moveSelectedDown() {
204 */ 234 */
205void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon ) { 235void TodayConfig::pluginManagement( OPluginItem plugItem ) {
206 236
207 QCheckListItem *item; 237 QCheckListItem *item = new QCheckListItem( m_appletListView, plugItem.name(), QCheckListItem::CheckBox );
208 item = new QCheckListItem( m_appletListView, name, QCheckListItem::CheckBox );
209 238
239 TodayPluginInterface* iface = m_pluginLoader->load<TodayPluginInterface>( plugItem, IID_TodayPluginInterface );
240 QPixmap icon = Resource::loadPixmap( iface->guiPart()->pixmapNameWidget() );
210 if ( !icon.isNull() ) { 241 if ( !icon.isNull() ) {
@@ -212,20 +243,8 @@ void TodayConfig::pluginManagement( QString libName, QString name, QPixmap icon
212 } 243 }
213 244 item->setOn( plugItem.isEnabled() );
214 if ( m_excludeApplets.find( libName ) == m_excludeApplets.end() ) { 245 previousItem = item;
215 item->setOn( TRUE );
216 } 246 }
217 247
218 m_applets[libName] = item;
219
220 // kind of hack to get the first tab as default.
221 TabWidget3->setCurrentTab( tab_2 );
222}
223 248
224void TodayConfig::appletChanged() {
225 m_applets_changed = true;
226}
227
228
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;