summaryrefslogtreecommitdiff
path: root/core/pim
authorharlekin <harlekin>2004-06-03 20:36:44 (UTC)
committer harlekin <harlekin>2004-06-03 20:36:44 (UTC)
commit52f849d3031f9d2fad2272ad069e7a1456c0ee54 (patch) (unidiff)
tree7d03d229363b81c40d180ee99d168e99c4f6c06e /core/pim
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 (limited to 'core/pim') (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
@@ -14,13 +14,12 @@
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#define QTOPIA_INTERNAL_LANGLIST
18
19#include "today.h" 17#include "today.h"
20 18
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>
25#include <qpe/resource.h> 24#include <qpe/resource.h>
26#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
@@ -31,21 +30,23 @@
31#include <qwhatsthis.h> 30#include <qwhatsthis.h>
32 31
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 ) {
@@ -55,6 +56,7 @@ 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 );
59 connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 61 connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
60 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); 62 this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) );
@@ -62,12 +64,8 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
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 );
72 layout->addWidget( Frame ); 70 layout->addWidget( Frame );
73 layout->addWidget( OwnerField ); 71 layout->addWidget( OwnerField );
@@ -80,8 +78,12 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
80 layout->addWidget( m_sv ); 78 layout->addWidget( m_sv );
81 layout->setStretchFactor( m_sv,4 ); 79 layout->setStretchFactor( m_sv,4 );
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 );
86} 88}
87 89
@@ -100,7 +102,6 @@ void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
100void Today::setRefreshTimer( int interval ) { 102void Today::setRefreshTimer( int interval ) {
101 103
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
105 if ( !interval == 0 ) { 106 if ( !interval == 0 ) {
106 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 107 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
@@ -132,16 +133,16 @@ void Today::setOwnerField( QString &message ) {
132 } 133 }
133} 134}
134 135
136
135/** 137/**
136 * Init stuff needed for today. Reads the config file. 138 * Init stuff needed for today. Reads the config file.
137 */ 139 */
138void Today::init() { 140void 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
146 cfg.setGroup( "General" ); 147 cfg.setGroup( "General" );
147 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 148 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
@@ -169,75 +170,27 @@ void Today::init() {
169 m_bblayout = new QVBoxLayout ( m_big_box ); 170 m_bblayout = new QVBoxLayout ( m_big_box );
170} 171}
171 172
173
172/** 174/**
173 * Load the plugins 175 * Load the plugins
174 */ 176 */
175void Today::loadPlugins() { 177void 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
242 plugin.guiPart = plugin.iface->guiPart(); 195 plugin.guiPart = plugin.iface->guiPart();
243 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 196 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
@@ -249,7 +202,8 @@ void Today::loadPlugins() {
249 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 202 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
250 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); 203 OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox );
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() );
254 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 208 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
255 209
@@ -259,79 +213,11 @@ void Today::loadPlugins() {
259 boxLayout->setStretchFactor( plugIcon, 1 ); 213 boxLayout->setStretchFactor( plugIcon, 1 );
260 boxLayout->setStretchFactor( plugWidget, 9 ); 214 boxLayout->setStretchFactor( plugWidget, 9 );
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 );
269 } 218 }
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}
336 222
337 223
@@ -345,69 +231,24 @@ void Today::startConfig() {
345 m_refreshTimer->stop( ); 231 m_refreshTimer->stop( );
346 232
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
367 if ( conf.exec() == QDialog::Accepted ) { 236 if ( conf.exec() == QDialog::Accepted ) {
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
382 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 242 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
383 } 243 }
384} 244}
385 245
386 246
387 247void Today::initialize() {
388void Today::reinitialize() {
389 248
390 Config cfg( "today" ); 249 Config cfg( "today" );
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
412 cfg.setGroup( "General" ); 253 cfg.setGroup( "General" );
413 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 254 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
@@ -426,19 +267,45 @@ void Today::reinitialize() {
426 TodayLabel->show(); 267 TodayLabel->show();
427 } 268 }
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}
443 310
444/** 311/**
@@ -447,13 +314,13 @@ void Today::reinitialize() {
447 */ 314 */
448void Today::refresh() { 315void 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
458 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); 325 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) );
459 326
@@ -461,11 +328,13 @@ void Today::refresh() {
461 repaint(); 328 repaint();
462} 329}
463 330
331
464void Today::startApplication() { 332void Today::startApplication() {
465 QCopEnvelope e( "QPE/System", "execute(QString)" ); 333 QCopEnvelope e( "QPE/System", "execute(QString)" );
466 e << QString( sender()->name() ); 334 e << QString( sender()->name() );
467} 335}
468 336
337
469/** 338/**
470 * launch addressbook (personal card) 339 * launch addressbook (personal card)
471 */ 340 */
@@ -473,6 +342,13 @@ void Today::editCard() {
473 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); 342 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" );
474} 343}
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}
478 354
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
@@ -22,6 +22,7 @@
22 22
23#include <opie2/todayplugininterface.h> 23#include <opie2/todayplugininterface.h>
24#include <opie2/oclickablelabel.h> 24#include <opie2/oclickablelabel.h>
25#include <opie2/opluginloader.h>
25 26
26#include <qpe/qlibrary.h> 27#include <qpe/qlibrary.h>
27 28
@@ -31,6 +32,13 @@
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 {
35 43
36 Q_OBJECT 44 Q_OBJECT
@@ -38,7 +46,9 @@ class Today : public TodayBase {
38 public: 46 public:
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
43private slots: 53private slots:
44 void startConfig(); 54 void startConfig();
@@ -50,14 +60,13 @@ private:
50 void init(); 60 void init();
51 void setOwnerField(); 61 void setOwnerField();
52 void setOwnerField(QString &string); 62 void setOwnerField(QString &string);
53 void loadPlugins(); 63 void initialize();
54 void draw();
55 void reinitialize();
56 64
57 void setRefreshTimer( int ); 65 void setRefreshTimer( int );
58 66
59private slots: 67private 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: 71 private:
63 TodayConfig *conf; 72 TodayConfig *conf;
@@ -68,7 +77,8 @@ private slots:
68 QWidget* m_big_box; 77 QWidget* m_big_box;
69 QVBoxLayout *m_bblayout; 78 QVBoxLayout *m_bblayout;
70 79
71 80 Opie::Core::OPluginLoader *m_pluginLoader;
81 Opie::Core::OPluginManager *m_manager;
72 82
73 QTimer *m_refreshTimer; 83 QTimer *m_refreshTimer;
74 84
@@ -78,5 +88,4 @@ private slots:
78 int m_maxCharClip; 88 int m_maxCharClip;
79 int m_hideBanner; 89 int m_hideBanner;
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
@@ -16,7 +16,10 @@
16 16
17#include "todayconfig.h" 17#include "todayconfig.h"
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>
21#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
22#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
@@ -31,6 +34,11 @@
31#include <qwhatsthis.h> 34#include <qwhatsthis.h>
32 35
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 {
35 43
36public: 44public:
@@ -68,7 +76,8 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
68 m_appletListView->addColumn( "PluginList" ); 76 m_appletListView->addColumn( "PluginList" );
69 m_appletListView->header()->hide(); 77 m_appletListView->header()->hide();
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 );
73 new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) ); 82 new ToolButton( vbox1, tr( "Move Up" ), "up", this , SLOT( moveSelectedUp() ) );
74 new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) ); 83 new ToolButton( vbox1, tr( "Move Down" ), "down", this , SLOT( moveSelectedDown() ) );
@@ -84,21 +93,47 @@ TodayConfig::TodayConfig( QWidget* parent, const char* name, bool modal )
84 tab3Layout->addWidget( m_guiMisc ); 93 tab3Layout->addWidget( m_guiMisc );
85 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) ); 94 TabWidget3->addTab( tab_3, "SettingsIcon", tr( "Misc" ) );
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();
92 QPEApplication::showDialog( this ); 99 QPEApplication::showDialog( this );
93} 100}
94 101
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/**
97 * Autostart, uses the new (opie only) autostart method in the launcher code. 132 * Autostart, uses the new (opie only) autostart method in the launcher code.
98 * If registered against that today ist started on each resume. 133 * If registered against that today ist started on each resume.
99 */ 134 */
100void TodayConfig::setAutoStart() { 135void TodayConfig::setAutoStart() {
101 Config cfg( "today" ); 136 OConfig cfg( "today" );
102 cfg.setGroup( "Autostart" ); 137 cfg.setGroup( "Autostart" );
103 if ( m_autoStart ) { 138 if ( m_autoStart ) {
104 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" ); 139 QCopEnvelope e( "QPE/System", "autoStart(QString,QString,QString)" );
@@ -116,7 +151,7 @@ void TodayConfig::setAutoStart() {
116 * Read the config part 151 * Read the config part
117 */ 152 */
118void TodayConfig::readConfig() { 153void TodayConfig::readConfig() {
119 Config cfg( "today" ); 154 OConfig cfg( "today" );
120 cfg.setGroup( "Autostart" ); 155 cfg.setGroup( "Autostart" );
121 m_autoStart = cfg.readNumEntry( "autostart", 1 ); 156 m_autoStart = cfg.readNumEntry( "autostart", 1 );
122 m_guiMisc->CheckBoxAuto->setChecked( m_autoStart ); 157 m_guiMisc->CheckBoxAuto->setChecked( m_autoStart );
@@ -128,43 +163,30 @@ void TodayConfig::readConfig() {
128 m_guiMisc->SpinBoxIconSize->setValue( m_iconSize ); 163 m_guiMisc->SpinBoxIconSize->setValue( m_iconSize );
129 m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 ); 164 m_guiMisc->SpinRefresh->setValue( cfg.readNumEntry( "checkinterval", 15000 ) / 1000 );
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}
136 167
137/** 168/**
138 * Write the config part 169 * Write the config part
139 */ 170 */
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 }
162 } 186 }
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
169 cfg.setGroup( "Autostart" ); 191 cfg.setGroup( "Autostart" );
170 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked(); 192 m_autoStart = m_guiMisc->CheckBoxAuto->isChecked();
@@ -180,6 +202,14 @@ void TodayConfig::writeConfig() {
180 202
181 // set autostart settings 203 // set autostart settings
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}
184 214
185 215
@@ -202,30 +232,19 @@ void TodayConfig::moveSelectedDown() {
202/** 232/**
203 * Set up the icons in the order/active tab 233 * Set up the icons in the order/active tab
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() ) {
211 item->setPixmap( 0, icon ); 242 item->setPixmap( 0, 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
@@ -20,6 +20,7 @@
20#include "todayconfigmiscbase.h" 20#include "todayconfigmiscbase.h"
21 21
22#include <opie2/otabwidget.h> 22#include <opie2/otabwidget.h>
23#include <opie2/opluginloader.h>
23 24
24#include <qvariant.h> 25#include <qvariant.h>
25#include <qdialog.h> 26#include <qdialog.h>
@@ -30,6 +31,14 @@ class QLabel;
30class QSpinBox; 31class QSpinBox;
31class QTabWidget; 32class 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 {
34 43
35 Q_OBJECT 44 Q_OBJECT
@@ -41,17 +50,17 @@ public:
41 Opie::Ui::OTabWidget* TabWidget3; 50 Opie::Ui::OTabWidget* TabWidget3;
42 51
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();
50 void moveSelectedDown(); 58 void moveSelectedDown();
51 59
52private: 60private:
53 void setAutoStart(); 61 void setAutoStart();
54 void readConfig(); 62 void readConfig();
63 void pluginManagement( Opie::Core::OPluginItem plugItem);
55 64
56 QListView* m_appletListView; 65 QListView* m_appletListView;
57 QMap<QString,QCheckListItem*> m_applets; 66 QMap<QString,QCheckListItem*> m_applets;
@@ -67,6 +76,11 @@ private:
67 QLabel* TextLabel1, *TextLabel4; 76 QLabel* TextLabel1, *TextLabel4;
68 QSpinBox* SpinBox7; 77 QSpinBox* SpinBox7;
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;
71}; 85};
72 86