author | waspe <waspe> | 2003-11-04 16:41:07 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-11-04 16:41:07 (UTC) |
commit | da5c9b06fe0081050ab8165cf3d189dbc8117bf6 (patch) (unidiff) | |
tree | 30dd36ad48413c39aa348ff5a49e130ef6ee2e4e /core/pim | |
parent | efcd8d6a743261194b55df3afeec956fde9886d4 (diff) | |
download | opie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.zip opie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.tar.gz opie-da5c9b06fe0081050ab8165cf3d189dbc8117bf6.tar.bz2 |
resolved merge conflict
-rw-r--r-- | core/pim/today/today.cpp | 152 |
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 | |||
@@ -39,43 +39,60 @@ struct TodayPlugin { | |||
39 | QLibrary *library; | 39 | QLibrary *library; |
40 | QInterfacePtr<TodayPluginInterface> iface; | 40 | QInterfacePtr<TodayPluginInterface> iface; |
41 | TodayPluginObject *guiPart; | 41 | TodayPluginObject *guiPart; |
42 | QWidget *guiBox; | 42 | QWidget *guiBox; |
43 | QString name; | 43 | QString name; |
44 | bool active; | 44 | bool active; |
45 | bool excludeRefresh; | 45 | bool excludeRefresh; |
46 | int pos; | 46 | int pos; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | static QValueList<TodayPlugin> pluginList; | 49 | static QValueList<TodayPlugin> pluginList; |
50 | 50 | ||
51 | static QMap<QString, TodayPlugin> tempList; | ||
52 | |||
51 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 53 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
52 | : TodayBase( parent, name, fl ) { | 54 | : TodayBase( parent, name, fl ) { |
53 | 55 | ||
54 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); | 56 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); |
55 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); | 57 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); |
56 | 58 | ||
57 | #if defined(Q_WS_QWS) | 59 | #if defined(Q_WS_QWS) |
58 | #if !defined(QT_NO_COP) | 60 | #if !defined(QT_NO_COP) |
59 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); | 61 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); |
60 | connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 62 | connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), |
61 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 63 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); |
62 | #endif | 64 | #endif |
63 | #endif | 65 | #endif |
64 | 66 | ||
65 | setOwnerField(); | 67 | setOwnerField(); |
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 | } |
73 | 90 | ||
74 | /** | 91 | /** |
75 | * Qcop receive method. | 92 | * Qcop receive method. |
76 | */ | 93 | */ |
77 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | 94 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { |
78 | QDataStream stream( data, IO_ReadOnly ); | 95 | QDataStream stream( data, IO_ReadOnly ); |
79 | if ( msg == "message(QString)" ) { | 96 | if ( msg == "message(QString)" ) { |
80 | QString message; | 97 | QString message; |
81 | stream >> message; | 98 | stream >> message; |
@@ -123,79 +140,78 @@ void Today::setOwnerField( QString &message ) { | |||
123 | */ | 140 | */ |
124 | void Today::init() { | 141 | void Today::init() { |
125 | // read config | 142 | // read config |
126 | Config cfg( "today" ); | 143 | Config cfg( "today" ); |
127 | 144 | ||
128 | cfg.setGroup( "Plugins" ); | 145 | cfg.setGroup( "Plugins" ); |
129 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 146 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
130 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 147 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
131 | 148 | ||
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(); |
147 | TodayLabel->hide(); | 160 | TodayLabel->hide(); |
148 | } else { | 161 | } else { |
149 | Opiezilla->show(); | 162 | Opiezilla->show(); |
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 | /** |
159 | * Load the plugins | 176 | * Load the plugins |
160 | */ | 177 | */ |
161 | void Today::loadPlugins() { | 178 | void 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 ) { |
167 | (*tit).guiBox->hide(); | 185 | (*tit).guiBox->hide(); |
168 | (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); | 186 | (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); |
169 | delete (*tit).guiBox; | 187 | delete (*tit).guiBox; |
170 | (*tit).library->unload(); | 188 | (*tit).library->unload(); |
171 | delete (*tit).library; | 189 | delete (*tit).library; |
172 | } | 190 | } |
173 | pluginList.clear(); | 191 | pluginList.clear(); |
174 | } | 192 | } |
175 | 193 | ||
176 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 194 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
177 | qWarning("Searching for Plugins in: %s", path.latin1()); | 195 | qWarning("Searching for Plugins in: %s", path.latin1()); |
178 | #ifdef Q_OS_MACX | 196 | #ifdef Q_OS_MACX |
179 | QDir dir( path, "lib*.dylib" ); | 197 | QDir dir( path, "lib*.dylib" ); |
180 | #else | 198 | #else |
181 | QDir dir( path, "lib*.so" ); | 199 | QDir dir( path, "lib*.so" ); |
182 | #endif | 200 | #endif |
183 | 201 | ||
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; |
193 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 209 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
194 | 210 | ||
195 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 211 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
196 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 212 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
197 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); | 213 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); |
198 | qDebug( QString(*it) ); | 214 | qDebug( QString(*it) ); |
199 | 215 | ||
200 | TodayPlugin plugin; | 216 | TodayPlugin plugin; |
201 | plugin.library = lib; | 217 | plugin.library = lib; |
@@ -213,94 +229,92 @@ void Today::loadPlugins() { | |||
213 | for (QStringList::ConstIterator lit = langs.begin(); lit!=langs.end(); ++lit) { | 229 | for (QStringList::ConstIterator lit = langs.begin(); lit!=langs.end(); ++lit) { |
214 | QString lang = *lit; | 230 | QString lang = *lit; |
215 | qDebug( "Languages: " + lang ); | 231 | qDebug( "Languages: " + lang ); |
216 | QTranslator * trans = new QTranslator( qApp ); | 232 | QTranslator * trans = new QTranslator( qApp ); |
217 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; | 233 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; |
218 | if ( trans->load( tfn ) ) { | 234 | if ( trans->load( tfn ) ) { |
219 | qApp->installTranslator( trans ); | 235 | qApp->installTranslator( trans ); |
220 | } else { | 236 | } else { |
221 | delete trans; | 237 | delete trans; |
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; |
228 | } else { | 245 | } else { |
229 | plugin.active = false; | 246 | plugin.active = false; |
230 | } | 247 | } |
231 | 248 | ||
232 | plugin.guiPart = plugin.iface->guiPart(); | 249 | plugin.guiPart = plugin.iface->guiPart(); |
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 ); |
240 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 257 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
241 | plugIcon->setPixmap( plugPix ); | 258 | plugIcon->setPixmap( plugPix ); |
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; |
282 | 293 | ||
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 | */ |
298 | void Today::draw() { | 312 | void Today::draw() { |
299 | 313 | ||
300 | if ( pluginList.count() == 0 ) { | 314 | if ( pluginList.count() == 0 ) { |
301 | QLabel *noPlugins = new QLabel( this ); | 315 | QLabel *noPlugins = new QLabel( this ); |
302 | noPlugins->setText( tr( "No plugins found" ) ); | 316 | noPlugins->setText( tr( "No plugins found" ) ); |
303 | layout->addWidget( noPlugins ); | 317 | layout->addWidget( noPlugins ); |
304 | return; | 318 | return; |
305 | } | 319 | } |
306 | 320 | ||
@@ -315,25 +329,25 @@ void Today::draw() { | |||
315 | } else { | 329 | } else { |
316 | // qDebug( plugin.name + " is INACTIVE" ); | 330 | // qDebug( plugin.name + " is INACTIVE" ); |
317 | plugin.guiBox->hide(); | 331 | plugin.guiBox->hide(); |
318 | } | 332 | } |
319 | count++; | 333 | count++; |
320 | } | 334 | } |
321 | 335 | ||
322 | if ( count == 0 ) { | 336 | if ( count == 0 ) { |
323 | QLabel *noPluginsActive = new QLabel( this ); | 337 | QLabel *noPluginsActive = new QLabel( this ); |
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 | ||
331 | /** | 345 | /** |
332 | * The method for the configuration dialog. | 346 | * The method for the configuration dialog. |
333 | */ | 347 | */ |
334 | void Today::startConfig() { | 348 | void Today::startConfig() { |
335 | 349 | ||
336 | // disconnect timer to prevent problems while being on config dialog | 350 | // disconnect timer to prevent problems while being on config dialog |
337 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 351 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
338 | m_refreshTimer->stop( ); | 352 | m_refreshTimer->stop( ); |
339 | 353 | ||
@@ -355,50 +369,112 @@ void Today::startConfig() { | |||
355 | // set the order/activate tab | 369 | // set the order/activate tab |
356 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), | 370 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), |
357 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); | 371 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); |
358 | } | 372 | } |
359 | 373 | ||
360 | if ( conf.exec() == QDialog::Accepted ) { | 374 | if ( conf.exec() == QDialog::Accepted ) { |
361 | conf.writeConfig(); | 375 | conf.writeConfig(); |
362 | TodayConfigWidget *confWidget; | 376 | TodayConfigWidget *confWidget; |
363 | for ( confWidget = configWidgetList.first(); confWidget != 0; | 377 | for ( confWidget = configWidgetList.first(); confWidget != 0; |
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 | |||
395 | void 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 | */ |
380 | void Today::refresh() { | 455 | void 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 | ||
395 | void Today::startApplication() { | 471 | void Today::startApplication() { |
396 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 472 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
397 | e << QString( sender()->name() ); | 473 | e << QString( sender()->name() ); |
398 | } | 474 | } |
399 | 475 | ||
400 | /** | 476 | /** |
401 | * launch addressbook (personal card) | 477 | * launch addressbook (personal card) |
402 | */ | 478 | */ |
403 | void Today::editCard() { | 479 | void Today::editCard() { |
404 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); | 480 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); |