summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
Unidiff
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 91028c8..1f758f2 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -61,25 +61,26 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
61#if defined(Q_WS_QWS) 61#if defined(Q_WS_QWS)
62#if !defined(QT_NO_COP) 62#if !defined(QT_NO_COP)
63 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); 63 QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this );
64 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 64 connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
65 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 65 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
66#endif 66#endif
67#endif 67#endif
68 68
69 setOwnerField(); 69 setOwnerField();
70 m_refreshTimer = new QTimer( this ); 70 m_refreshTimer = new QTimer( this );
71 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 71 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
72 m_refreshTimer->start( 15000 ); 72 m_refreshTimer->start( 15000 );
73 refresh(); 73 init();
74 loadPlugins();
74 showMaximized(); 75 showMaximized();
75} 76}
76 77
77/** 78/**
78 * Qcop receive method. 79 * Qcop receive method.
79 */ 80 */
80void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 81void Today::channelReceived( const QCString &msg, const QByteArray & data ) {
81 QDataStream stream( data, IO_ReadOnly ); 82 QDataStream stream( data, IO_ReadOnly );
82 if ( msg == "message(QString)" ) { 83 if ( msg == "message(QString)" ) {
83 QString message; 84 QString message;
84 stream >> message; 85 stream >> message;
85 setOwnerField( message ); 86 setOwnerField( message );
@@ -127,24 +128,39 @@ void Today::setOwnerField( QString &message ) {
127 */ 128 */
128void Today::init() { 129void Today::init() {
129 // read config 130 // read config
130 Config cfg( "today" ); 131 Config cfg( "today" );
131 132
132 cfg.setGroup( "Plugins" ); 133 cfg.setGroup( "Plugins" );
133 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); 134 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
134 m_allApplets = cfg.readListEntry( "AllApplets", ',' ); 135 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
135 136
136 cfg.setGroup( "General" ); 137 cfg.setGroup( "General" );
137 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 138 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
138 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 139 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
140
141
142 // qDebug(" refresh ");
143 // set the date in top label
144 QDate date = QDate::currentDate();
145 QString time = ( tr( date.toString() ) );
146
147 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) );
148
149 if ( layout ) {
150 delete layout;
151 }
152 layout = new QVBoxLayout( this );
153 layout->addWidget( Frame );
154 layout->addWidget( OwnerField );
139} 155}
140 156
141 157
142/** 158/**
143 * Load the plugins 159 * Load the plugins
144 */ 160 */
145void Today::loadPlugins() { 161void Today::loadPlugins() {
146 162
147 // extra list for plugins that exclude themself from periodic refresh 163 // extra list for plugins that exclude themself from periodic refresh
148 QMap<QString, TodayPlugin> pluginListRefreshExclude; 164 QMap<QString, TodayPlugin> pluginListRefreshExclude;
149 165
150 QValueList<TodayPlugin>::Iterator tit; 166 QValueList<TodayPlugin>::Iterator tit;
@@ -257,24 +273,25 @@ void Today::loadPlugins() {
257 if ( !m_allApplets.isEmpty() ) { 273 if ( !m_allApplets.isEmpty() ) {
258 TodayPlugin tempPlugin; 274 TodayPlugin tempPlugin;
259 QStringList::Iterator stringit; 275 QStringList::Iterator stringit;
260 276
261 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 277 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
262 tempPlugin = ( tempList.find( *stringit ) ).data(); 278 tempPlugin = ( tempList.find( *stringit ) ).data();
263 if ( !( (tempPlugin.name).isEmpty() ) ) { 279 if ( !( (tempPlugin.name).isEmpty() ) ) {
264 layout->addWidget( tempPlugin.guiBox ); 280 layout->addWidget( tempPlugin.guiBox );
265 pluginList.append( tempPlugin ); 281 pluginList.append( tempPlugin );
266 } 282 }
267 } 283 }
268 } 284 }
285 draw();
269} 286}
270 287
271 288
272/** 289/**
273 * Repaint method. Reread all fields. 290 * Repaint method. Reread all fields.
274 */ 291 */
275void Today::draw() { 292void Today::draw() {
276 293
277 if ( pluginList.count() == 0 ) { 294 if ( pluginList.count() == 0 ) {
278 QLabel *noPlugins = new QLabel( this ); 295 QLabel *noPlugins = new QLabel( this );
279 noPlugins->setText( tr( "No plugins found" ) ); 296 noPlugins->setText( tr( "No plugins found" ) );
280 layout->addWidget( noPlugins ); 297 layout->addWidget( noPlugins );
@@ -331,55 +348,46 @@ void Today::startConfig() {
331 // set the order/activate tab 348 // set the order/activate tab
332 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), 349 conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(),
333 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); 350 Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) );
334 } 351 }
335 352
336 if ( conf.exec() == QDialog::Accepted ) { 353 if ( conf.exec() == QDialog::Accepted ) {
337 conf.writeConfig(); 354 conf.writeConfig();
338 TodayConfigWidget *confWidget; 355 TodayConfigWidget *confWidget;
339 for ( confWidget = configWidgetList.first(); confWidget != 0; 356 for ( confWidget = configWidgetList.first(); confWidget != 0;
340 confWidget = configWidgetList.next() ) { 357 confWidget = configWidgetList.next() ) {
341 confWidget->writeConfig(); 358 confWidget->writeConfig();
342 } 359 }
343 refresh(); 360 loadPlugins();
344 } else { 361 } else {
345 // since refresh is not called in that case , reconnect the signal 362 // since refresh is not called in that case , reconnect the signal
346 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 363 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
347 } 364 }
348} 365}
349 366
350 367
351/** 368/**
352 * Refresh for the view. Reload all applets 369 * Refresh for the view. Reload all applets
353 * 370 *
354 */ 371 */
355void Today::refresh() { 372void Today::refresh() {
356 init(); 373 init();
357 374
358 // qDebug(" refresh "); 375 QValueList<TodayPlugin>::Iterator it;
359 // set the date in top label 376 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
360 QDate date = QDate::currentDate(); 377 if ( !(*it).excludeRefresh ) {
361 QString time = ( tr( date.toString() ) ); 378 (*it).guiPart->refresh();
362 379 qDebug( "refresh" );
363 DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); 380 }
364
365 if ( layout ) {
366 delete layout;
367 } 381 }
368 layout = new QVBoxLayout( this );
369 layout->addWidget( Frame );
370 layout->addWidget( OwnerField );
371
372 loadPlugins();
373 draw();
374} 382}
375 383
376void Today::startApplication() { 384void Today::startApplication() {
377 QCopEnvelope e( "QPE/System", "execute(QString)" ); 385 QCopEnvelope e( "QPE/System", "execute(QString)" );
378 e << QString( sender()->name() ); 386 e << QString( sender()->name() );
379} 387}
380 388
381/** 389/**
382 * launch addressbook (personal card) 390 * launch addressbook (personal card)
383 */ 391 */
384void Today::editCard() { 392void Today::editCard() {
385 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); 393 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" );