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
@@ -1,409 +1,485 @@
1/* 1/*
2 * today.cpp 2 * today.cpp
3 * 3 *
4 * copyright : (c) 2002,2003 by Maximilian Reiß 4 * copyright : (c) 2002,2003 by Maximilian Reiß
5 * email : harlekin@handhelds.org 5 * email : harlekin@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17 17
18 18
19#define QTOPIA_INTERNAL_LANGLIST 19#define QTOPIA_INTERNAL_LANGLIST
20 20
21#include "today.h" 21#include "today.h"
22 22
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/global.h> 26#include <qpe/global.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/contact.h> 28#include <qpe/contact.h>
29#include <qpe/timestring.h> 29#include <qpe/timestring.h>
30 30
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qwhatsthis.h> 34#include <qwhatsthis.h>
35#include <qtranslator.h> 35#include <qtranslator.h>
36 36
37struct TodayPlugin { 37struct TodayPlugin {
38 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} 38 TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {}
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
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
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 */
77void Today::channelReceived( const QCString &msg, const QByteArray & data ) { 94void 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;
82 setOwnerField( message ); 99 setOwnerField( message );
83 } 100 }
84} 101}
85 102
86void Today::setRefreshTimer( int interval ) { 103void Today::setRefreshTimer( int interval ) {
87 104
88 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 105 disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
89 106
90 // 0 is "never" case 107 // 0 is "never" case
91 if ( !interval == 0 ) { 108 if ( !interval == 0 ) {
92 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); 109 connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) );
93 m_refreshTimer->changeInterval( interval ); 110 m_refreshTimer->changeInterval( interval );
94 } 111 }
95} 112}
96 113
97 114
98/** 115/**
99 * Initialises the owner field with the default value, the username 116 * Initialises the owner field with the default value, the username
100 */ 117 */
101void Today::setOwnerField() { 118void Today::setOwnerField() {
102 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); 119 QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" );
103 if ( QFile::exists( file ) ) { 120 if ( QFile::exists( file ) ) {
104 Contact cont = Contact::readVCard( file )[0]; 121 Contact cont = Contact::readVCard( file )[0];
105 QString returnString = cont.fullName(); 122 QString returnString = cont.fullName();
106 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); 123 OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" );
107 } else { 124 } else {
108 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); 125 OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" );
109 } 126 }
110} 127}
111 128
112/** 129/**
113 * Set the owner field with a given QString, for example per qcop. 130 * Set the owner field with a given QString, for example per qcop.
114 */ 131 */
115void Today::setOwnerField( QString &message ) { 132void Today::setOwnerField( QString &message ) {
116 if ( !message.isEmpty() ) { 133 if ( !message.isEmpty() ) {
117 OwnerField->setText( "<b>" + message + "</b>" ); 134 OwnerField->setText( "<b>" + message + "</b>" );
118 } 135 }
119} 136}
120 137
121/** 138/**
122 * Init stuff needed for today. Reads the config file. 139 * Init stuff needed for today. Reads the config file.
123 */ 140 */
124void Today::init() { 141void 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 */
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 ) {
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;
202 plugin.iface = iface; 218 plugin.iface = iface;
203 plugin.name = QString(*it); 219 plugin.name = QString(*it);
204 220
205 QString type = (*it).left( (*it).find(".") ); 221 QString type = (*it).left( (*it).find(".") );
206 222
207 // grr, sharp rom does not know Global::languageList(); 223 // grr, sharp rom does not know Global::languageList();
208 // QStringList langs = Global::languageList(); 224 // QStringList langs = Global::languageList();
209 QString tfn = QPEApplication::qpeDir() + "/i18n/"; 225 QString tfn = QPEApplication::qpeDir() + "/i18n/";
210 QDir langDir = tfn; 226 QDir langDir = tfn;
211 QStringList langs = langDir.entryList("*", QDir::Dirs ); 227 QStringList langs = langDir.entryList("*", QDir::Dirs );
212 228
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 */
298void Today::draw() { 312void 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
307 uint count = 0; 321 uint count = 0;
308 TodayPlugin plugin; 322 TodayPlugin plugin;
309 for ( uint i = 0; i < pluginList.count(); i++ ) { 323 for ( uint i = 0; i < pluginList.count(); i++ ) {
310 plugin = pluginList[i]; 324 plugin = pluginList[i];
311 325
312 if ( plugin.active ) { 326 if ( plugin.active ) {
313 // qDebug( plugin.name + " is ACTIVE " ); 327 // qDebug( plugin.name + " is ACTIVE " );
314 plugin.guiBox->show(); 328 plugin.guiBox->show();
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 */
334void Today::startConfig() { 348void 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
340 TodayConfig conf( this, "dialog", true ); 354 TodayConfig conf( this, "dialog", true );
341 355
342 TodayPlugin plugin; 356 TodayPlugin plugin;
343 QList<TodayConfigWidget> configWidgetList; 357 QList<TodayConfigWidget> configWidgetList;
344 358
345 for ( int i = pluginList.count() - 1; i >= 0; i-- ) { 359 for ( int i = pluginList.count() - 1; i >= 0; i-- ) {
346 plugin = pluginList[i]; 360 plugin = pluginList[i];
347 361
348 // load the config widgets in the tabs 362 // load the config widgets in the tabs
349 if ( plugin.guiPart->configWidget( this ) != 0l ) { 363 if ( plugin.guiPart->configWidget( this ) != 0l ) {
350 TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); 364 TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 );
351 configWidgetList.append( widget ); 365 configWidgetList.append( widget );
352 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() 366 conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig()
353 , plugin.guiPart->appName() ); 367 , plugin.guiPart->appName() );
354 } 368 }
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
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() {
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 */
403void Today::editCard() { 479void Today::editCard() {
404 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); 480 QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" );
405} 481}
406 482
407Today::~Today() { 483Today::~Today() {
408} 484}
409 485