summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/today/today.cpp142
1 files changed, 109 insertions, 33 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index cb18c1c..dd8d59b 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -50,2 +50,4 @@ static QValueList<TodayPlugin> pluginList;
50 50
51static QMap<QString, TodayPlugin> tempList;
52
51Today::Today( QWidget* parent, const char* name, WFlags fl ) 53Today::Today( QWidget* parent, const char* name, WFlags fl )
@@ -68,3 +70,18 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
68 m_refreshTimer->start( 15000 ); 70 m_refreshTimer->start( 15000 );
69 //init(); 71 m_big_box = 0L;
72
73
74 layout = new QVBoxLayout( this );
75 layout->addWidget( Frame );
76 layout->addWidget( OwnerField );
77
78 m_sv = new QScrollView( this );
79 m_sv->setResizePolicy( QScrollView::AutoOneFit );
80 m_sv->setHScrollBarMode( QScrollView::AlwaysOff );
81 m_sv->setFrameShape( QFrame::NoFrame );
82
83 layout->addWidget( m_sv );
84 layout->setStretchFactor( m_sv,4 );
85
86 qApp->processEvents();
70 loadPlugins(); 87 loadPlugins();
@@ -140,6 +157,2 @@ void Today::init() {
140 157
141 if ( layout ) {
142 delete layout;
143 }
144
145 if ( m_hideBanner ) { 158 if ( m_hideBanner ) {
@@ -152,5 +165,9 @@ void Today::init() {
152 165
153 layout = new QVBoxLayout( this ); 166 if ( m_big_box ) {
154 layout->addWidget( Frame ); 167 delete m_big_box;
155 layout->addWidget( OwnerField ); 168 }
169
170 m_big_box = new QWidget( m_sv->viewport() );
171 m_sv->addChild( m_big_box );
172 m_bblayout = new QVBoxLayout ( m_big_box );
156} 173}
@@ -163,2 +180,3 @@ void Today::loadPlugins() {
163 init(); 180 init();
181
164 QValueList<TodayPlugin>::Iterator tit; 182 QValueList<TodayPlugin>::Iterator tit;
@@ -186,5 +204,3 @@ void Today::loadPlugins() {
186 204
187 qWarning("Found: %d entries !", list.count() ); 205 // QMap<QString, TodayPlugin> tempList;
188
189 QMap<QString, TodayPlugin> tempList;
190 206
@@ -224,2 +240,3 @@ void Today::loadPlugins() {
224 240
241
225 // find out if plugins should be shown 242 // find out if plugins should be shown
@@ -235,3 +252,3 @@ void Today::loadPlugins() {
235 // package the whole thing into a qwidget so it can be shown and hidden 252 // package the whole thing into a qwidget so it can be shown and hidden
236 plugin.guiBox = new QWidget( this ); 253 plugin.guiBox = new QWidget( m_big_box );
237 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); 254 QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox );
@@ -244,16 +261,9 @@ void Today::loadPlugins() {
244 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); 261 connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) );
245 // a scrollview for each plugin 262
246 QScrollView* sv = new QScrollView( plugin.guiBox ); 263 QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox );
247 QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() );
248 // not sure if that is good .-)
249 sv->setMinimumHeight( 12 );
250 sv->setResizePolicy( QScrollView::AutoOneFit );
251 sv->setHScrollBarMode( QScrollView::AlwaysOff );
252 sv->setFrameShape( QFrame::NoFrame );
253 sv->addChild( plugWidget );
254 // make sure the icon is on the top alligned
255 boxLayout->addWidget( plugIcon, 0, AlignTop ); 264 boxLayout->addWidget( plugIcon, 0, AlignTop );
256 boxLayout->addWidget( sv, 0, AlignTop ); 265 boxLayout->addWidget( plugWidget, 0, AlignTop );
257 boxLayout->setStretchFactor( plugIcon, 1 ); 266 boxLayout->setStretchFactor( plugIcon, 1 );
258 boxLayout->setStretchFactor( sv, 9 ); 267 boxLayout->setStretchFactor( plugWidget, 9 );
268
259 // "prebuffer" it in one more list, to get the sorting done 269 // "prebuffer" it in one more list, to get the sorting done
@@ -263,4 +273,4 @@ void Today::loadPlugins() {
263 if ( m_allApplets.isEmpty() ) { 273 if ( m_allApplets.isEmpty() ) {
264 layout->addWidget( plugin.guiBox );
265 pluginList.append( plugin ); 274 pluginList.append( plugin );
275 m_bblayout->addWidget( plugin.guiBox );
266 } 276 }
@@ -269,3 +279,2 @@ void Today::loadPlugins() {
269 else if ( !m_allApplets.contains( plugin.name ) ) { 279 else if ( !m_allApplets.contains( plugin.name ) ) {
270 layout->addWidget( plugin.guiBox );
271 pluginList.append( plugin ); 280 pluginList.append( plugin );
@@ -276,4 +285,6 @@ void Today::loadPlugins() {
276 } 285 }
286
277 } 287 }
278 288
289
279 if ( !m_allApplets.isEmpty() ) { 290 if ( !m_allApplets.isEmpty() ) {
@@ -285,4 +296,4 @@ void Today::loadPlugins() {
285 if ( !( (tempPlugin.name).isEmpty() ) ) { 296 if ( !( (tempPlugin.name).isEmpty() ) ) {
286 layout->addWidget( tempPlugin.guiBox );
287 pluginList.append( tempPlugin ); 297 pluginList.append( tempPlugin );
298 m_bblayout->addWidget( tempPlugin.guiBox );
288 } 299 }
@@ -290,2 +301,3 @@ void Today::loadPlugins() {
290 } 301 }
302 m_bblayout->addStretch( 2 );
291 draw(); 303 draw();
@@ -294,2 +306,4 @@ void Today::loadPlugins() {
294 306
307
308
295/** 309/**
@@ -326,3 +340,3 @@ void Today::draw() {
326 } 340 }
327 layout->addStretch(0); 341 repaint();
328} 342}
@@ -366,3 +380,7 @@ void Today::startConfig() {
366 } 380 }
367 loadPlugins(); 381
382 // make the plugins to reinitialize ( reread its configs )
383 reinitialize();
384 draw();
385
368 } else { 386 } else {
@@ -375,2 +393,59 @@ void Today::startConfig() {
375 393
394
395void Today::reinitialize() {
396
397 Config cfg( "today" );
398 cfg.setGroup( "Plugins" );
399 m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' );
400 m_allApplets = cfg.readListEntry( "AllApplets", ',' );
401
402 /* reinitialize all plugins */
403 QValueList<TodayPlugin>::Iterator it;
404 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
405 if ( !(*it).excludeRefresh ) {
406 (*it).guiPart->reinitialize();
407 qDebug( "reinit" );
408 }
409
410 /* check if plugins is still to be shown */
411 if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) {
412 (*it).active = true;
413 } else {
414 (*it).active = false;
415 }
416
417 }
418
419 cfg.setGroup( "General" );
420 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
421 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
422 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
423
424 // set the date in top label
425 QDate date = QDate::currentDate();
426 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
427
428 if ( m_hideBanner ) {
429 Opiezilla->hide();
430 TodayLabel->hide();
431 } else {
432 Opiezilla->show();
433 TodayLabel->show();
434 }
435
436 delete m_bblayout;
437 m_bblayout = new QVBoxLayout( m_big_box );
438 TodayPlugin tempPlugin;
439 QStringList::Iterator stringit;
440
441 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
442 tempPlugin = ( tempList.find( *stringit ) ).data();
443 if ( !( (tempPlugin.name).isEmpty() ) ) {
444 m_bblayout->addWidget( tempPlugin.guiBox );
445 }
446 }
447 m_bblayout->addStretch( 2 );
448
449}
450
376/** 451/**
@@ -381,4 +456,2 @@ void Today::refresh() {
381 456
382 init();
383
384 QValueList<TodayPlugin>::Iterator it; 457 QValueList<TodayPlugin>::Iterator it;
@@ -387,3 +460,2 @@ void Today::refresh() {
387 (*it).guiPart->refresh(); 460 (*it).guiPart->refresh();
388 layout->addWidget( (*it).guiBox );
389 qDebug( "refresh" ); 461 qDebug( "refresh" );
@@ -391,3 +463,7 @@ void Today::refresh() {
391 } 463 }
392 layout->addStretch(0); 464
465 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) );
466
467 updateGeometry();
468 repaint();
393} 469}