summaryrefslogtreecommitdiff
authorwaspe <waspe>2003-11-04 16:41:07 (UTC)
committer waspe <waspe>2003-11-04 16:41:07 (UTC)
commitda5c9b06fe0081050ab8165cf3d189dbc8117bf6 (patch) (unidiff)
tree30dd36ad48413c39aa348ff5a49e130ef6ee2e4e
parentefcd8d6a743261194b55df3afeec956fde9886d4 (diff)
downloadopie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.zip
opie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.tar.gz
opie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.tar.bz2
resolved merge conflict
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp152
1 files changed, 114 insertions, 38 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
@@ -48,6 +48,8 @@ struct TodayPlugin {
48 48
49static QValueList<TodayPlugin> pluginList; 49static 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 )
52 : TodayBase( parent, name, fl ) { 54 : TodayBase( parent, name, fl ) {
53 55
@@ -66,7 +68,22 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
66 m_refreshTimer = new QTimer( this ); 68 m_refreshTimer = new QTimer( this );
67 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 69 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
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();
71 showMaximized(); 88 showMaximized();
72} 89}
@@ -132,15 +149,11 @@ void Today::init() {
132 cfg.setGroup( "General" ); 149 cfg.setGroup( "General" );
133 m_iconSize = cfg.readNumEntry( "IconSize", 18 ); 150 m_iconSize = cfg.readNumEntry( "IconSize", 18 );
134 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); 151 m_hideBanner = cfg.readNumEntry( "HideBanner", 0 );
135 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); 152 setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) );
136 153
137 // set the date in top label 154 // set the date in top label
138 QDate date = QDate::currentDate(); 155 QDate date = QDate::currentDate();
139 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); 156 DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) );
140
141 if ( layout ) {
142 delete layout;
143 }
144 157
145 if ( m_hideBanner ) { 158 if ( m_hideBanner ) {
146 Opiezilla->hide(); 159 Opiezilla->hide();
@@ -150,9 +163,13 @@ void Today::init() {
150 TodayLabel->show(); 163 TodayLabel->show();
151 } 164 }
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}
157 174
158/** 175/**
@@ -161,6 +178,7 @@ void Today::init() {
161void Today::loadPlugins() { 178void Today::loadPlugins() {
162 179
163 init(); 180 init();
181
164 QValueList<TodayPlugin>::Iterator tit; 182 QValueList<TodayPlugin>::Iterator tit;
165 if ( !pluginList.isEmpty() ) { 183 if ( !pluginList.isEmpty() ) {
166 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { 184 for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) {
@@ -184,9 +202,7 @@ void Today::loadPlugins() {
184 QStringList list = dir.entryList(); 202 QStringList list = dir.entryList();
185 QStringList::Iterator it; 203 QStringList::Iterator it;
186 204
187 qWarning("Found: %d entries !", list.count() ); 205 // QMap<QString, TodayPlugin> tempList;
188
189 QMap<QString, TodayPlugin> tempList;
190 206
191 for ( it = list.begin(); it != list.end(); ++it ) { 207 for ( it = list.begin(); it != list.end(); ++it ) {
192 QInterfacePtr<TodayPluginInterface> iface; 208 QInterfacePtr<TodayPluginInterface> iface;
@@ -222,6 +238,7 @@ void Today::loadPlugins() {
222 } 238 }
223 } 239 }
224 240
241
225 // find out if plugins should be shown 242 // find out if plugins should be shown
226 if ( m_excludeApplets.grep( *it ).isEmpty() ) { 243 if ( m_excludeApplets.grep( *it ).isEmpty() ) {
227 plugin.active = true; 244 plugin.active = true;
@@ -233,7 +250,7 @@ void Today::loadPlugins() {
233 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); 250 plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh();
234 251
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 );
238 QPixmap plugPix; 255 QPixmap plugPix;
239 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); 256 plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 );
@@ -242,40 +259,34 @@ void Today::loadPlugins() {
242 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); 259 QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") );
243 plugIcon->setName( plugin.guiPart->appName() ); 260 plugIcon->setName( plugin.guiPart->appName() );
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 );
259 // "prebuffer" it in one more list, to get the sorting done 268
269 // "prebuffer" it in one more list, to get the sorting done
260 tempList.insert( plugin.name, plugin ); 270 tempList.insert( plugin.name, plugin );
261 271
262 // on first start the list is off course empty 272 // on first start the list is off course empty
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 }
267 277
268 // if plugin is not yet in the list, add it to the layout too 278 // if plugin is not yet in the list, add it to the layout too
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 );
272 } 281 }
273 } else { 282 } else {
274 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); 283 qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() );
275 delete lib; 284 delete lib;
276 } 285 }
286
277 } 287 }
278 288
289
279 if ( !m_allApplets.isEmpty() ) { 290 if ( !m_allApplets.isEmpty() ) {
280 TodayPlugin tempPlugin; 291 TodayPlugin tempPlugin;
281 QStringList::Iterator stringit; 292 QStringList::Iterator stringit;
@@ -283,15 +294,18 @@ void Today::loadPlugins() {
283 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { 294 for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) {
284 tempPlugin = ( tempList.find( *stringit ) ).data(); 295 tempPlugin = ( tempList.find( *stringit ) ).data();
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 }
289 } 300 }
290 } 301 }
302 m_bblayout->addStretch( 2 );
291 draw(); 303 draw();
292} 304}
293 305
294 306
307
308
295/** 309/**
296 * Repaint method. Reread all fields. 310 * Repaint method. Reread all fields.
297 */ 311 */
@@ -324,7 +338,7 @@ void Today::draw() {
324 noPluginsActive->setText( tr( "No plugins activated" ) ); 338 noPluginsActive->setText( tr( "No plugins activated" ) );
325 layout->addWidget( noPluginsActive ); 339 layout->addWidget( noPluginsActive );
326 } 340 }
327 layout->addStretch(0); 341 repaint();
328} 342}
329 343
330 344
@@ -364,32 +378,94 @@ void Today::startConfig() {
364 confWidget = configWidgetList.next() ) { 378 confWidget = configWidgetList.next() ) {
365 confWidget->writeConfig(); 379 confWidget->writeConfig();
366 } 380 }
367 loadPlugins(); 381
382 // make the plugins to reinitialize ( reread its configs )
383 reinitialize();
384 draw();
385
368 } else { 386 } else {
369 // since refresh is not called in that case , reconnect the signal 387 // since refresh is not called in that case , reconnect the signal
370 m_refreshTimer->start( 15000 ); // get the config value in here later 388 m_refreshTimer->start( 15000 ); // get the config value in here later
371 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 389 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
372 } 390 }
373} 391}
374 392
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/**
377 * Refresh for the view. Reload all applets 452 * Refresh for the view. Reload all applets
378 * 453 *
379 */ 454 */
380void Today::refresh() { 455void Today::refresh() {
381 456
382 init();
383
384 QValueList<TodayPlugin>::Iterator it; 457 QValueList<TodayPlugin>::Iterator it;
385 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 458 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
386 if ( !(*it).excludeRefresh ) { 459 if ( !(*it).excludeRefresh ) {
387 (*it).guiPart->refresh(); 460 (*it).guiPart->refresh();
388 layout->addWidget( (*it).guiBox );
389 qDebug( "refresh" ); 461 qDebug( "refresh" );
390 } 462 }
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}
394 470
395void Today::startApplication() { 471void Today::startApplication() {