-rw-r--r-- | core/pim/today/config.in | 2 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 22 |
2 files changed, 13 insertions, 11 deletions
diff --git a/core/pim/today/config.in b/core/pim/today/config.in index c4377e4..c663fc1 100644 --- a/core/pim/today/config.in +++ b/core/pim/today/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config TODAY | 1 | config TODAY |
2 | boolean "opie-today (today gives an overview of appointments and todos)" | 2 | boolean "opie-today (today gives an overview of appointments and todos)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && LIBOPIE2PIM | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM |
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index ebcd2dd..3ddb88d 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,476 +1,478 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp | 2 | * today.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002,2003,2004 by Maximilian Reiß | 4 | * copyright : (c) 2002,2003,2004 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 | #define QTOPIA_INTERNAL_LANGLIST | 17 | #define QTOPIA_INTERNAL_LANGLIST |
18 | 18 | ||
19 | #include "today.h" | 19 | #include "today.h" |
20 | 20 | ||
21 | #include <opie2/odebug.h> | ||
22 | |||
21 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
24 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/contact.h> | 27 | #include <qpe/contact.h> |
26 | 28 | ||
27 | #include <qdir.h> | 29 | #include <qdir.h> |
28 | #include <qtimer.h> | 30 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
30 | 32 | ||
31 | using namespace Opie::Ui; | 33 | using namespace Opie::Ui; |
32 | struct TodayPlugin { | 34 | struct TodayPlugin { |
33 | TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} | 35 | TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} |
34 | QLibrary *library; | 36 | QLibrary *library; |
35 | QInterfacePtr<TodayPluginInterface> iface; | 37 | QInterfacePtr<TodayPluginInterface> iface; |
36 | TodayPluginObject *guiPart; | 38 | TodayPluginObject *guiPart; |
37 | QWidget *guiBox; | 39 | QWidget *guiBox; |
38 | QString name; | 40 | QString name; |
39 | bool active; | 41 | bool active; |
40 | bool excludeRefresh; | 42 | bool excludeRefresh; |
41 | int pos; | 43 | int pos; |
42 | }; | 44 | }; |
43 | 45 | ||
44 | static QValueList<TodayPlugin> pluginList; | 46 | static QValueList<TodayPlugin> pluginList; |
45 | 47 | ||
46 | static QMap<QString, TodayPlugin> tempList; | 48 | static QMap<QString, TodayPlugin> tempList; |
47 | 49 | ||
48 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 50 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
49 | : TodayBase( parent, name, fl ) { | 51 | : TodayBase( parent, name, fl ) { |
50 | 52 | ||
51 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); | 53 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); |
52 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); | 54 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); |
53 | 55 | ||
54 | #if defined(Q_WS_QWS) | 56 | #if defined(Q_WS_QWS) |
55 | #if !defined(QT_NO_COP) | 57 | #if !defined(QT_NO_COP) |
56 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); | 58 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); |
57 | connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 59 | connect ( todayChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
58 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); | 60 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); |
59 | #endif | 61 | #endif |
60 | #endif | 62 | #endif |
61 | 63 | ||
62 | setOwnerField(); | 64 | setOwnerField(); |
63 | m_refreshTimer = new QTimer( this ); | 65 | m_refreshTimer = new QTimer( this ); |
64 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 66 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
65 | m_refreshTimer->start( 15000 ); | 67 | m_refreshTimer->start( 15000 ); |
66 | m_big_box = 0L; | 68 | m_big_box = 0L; |
67 | 69 | ||
68 | 70 | ||
69 | layout = new QVBoxLayout( this ); | 71 | layout = new QVBoxLayout( this ); |
70 | layout->addWidget( Frame ); | 72 | layout->addWidget( Frame ); |
71 | layout->addWidget( OwnerField ); | 73 | layout->addWidget( OwnerField ); |
72 | 74 | ||
73 | m_sv = new QScrollView( this ); | 75 | m_sv = new QScrollView( this ); |
74 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); | 76 | m_sv->setResizePolicy( QScrollView::AutoOneFit ); |
75 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 77 | m_sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
76 | m_sv->setFrameShape( QFrame::NoFrame ); | 78 | m_sv->setFrameShape( QFrame::NoFrame ); |
77 | 79 | ||
78 | layout->addWidget( m_sv ); | 80 | layout->addWidget( m_sv ); |
79 | layout->setStretchFactor( m_sv,4 ); | 81 | layout->setStretchFactor( m_sv,4 ); |
80 | 82 | ||
81 | qApp->processEvents(); | 83 | qApp->processEvents(); |
82 | loadPlugins(); | 84 | loadPlugins(); |
83 | QPEApplication::showWidget( this ); | 85 | QPEApplication::showWidget( this ); |
84 | } | 86 | } |
85 | 87 | ||
86 | /** | 88 | /** |
87 | * Qcop receive method. | 89 | * Qcop receive method. |
88 | */ | 90 | */ |
89 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | 91 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { |
90 | QDataStream stream( data, IO_ReadOnly ); | 92 | QDataStream stream( data, IO_ReadOnly ); |
91 | if ( msg == "message(QString)" ) { | 93 | if ( msg == "message(QString)" ) { |
92 | QString message; | 94 | QString message; |
93 | stream >> message; | 95 | stream >> message; |
94 | setOwnerField( message ); | 96 | setOwnerField( message ); |
95 | } | 97 | } |
96 | } | 98 | } |
97 | 99 | ||
98 | void Today::setRefreshTimer( int interval ) { | 100 | void Today::setRefreshTimer( int interval ) { |
99 | 101 | ||
100 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 102 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
101 | 103 | ||
102 | // 0 is "never" case | 104 | // 0 is "never" case |
103 | if ( !interval == 0 ) { | 105 | if ( !interval == 0 ) { |
104 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 106 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
105 | m_refreshTimer->changeInterval( interval ); | 107 | m_refreshTimer->changeInterval( interval ); |
106 | } | 108 | } |
107 | } | 109 | } |
108 | 110 | ||
109 | 111 | ||
110 | /** | 112 | /** |
111 | * Initialises the owner field with the default value, the username | 113 | * Initialises the owner field with the default value, the username |
112 | */ | 114 | */ |
113 | void Today::setOwnerField() { | 115 | void Today::setOwnerField() { |
114 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); | 116 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); |
115 | if ( QFile::exists( file ) ) { | 117 | if ( QFile::exists( file ) ) { |
116 | Contact cont = Contact::readVCard( file )[0]; | 118 | Contact cont = Contact::readVCard( file )[0]; |
117 | QString returnString = cont.fullName(); | 119 | QString returnString = cont.fullName(); |
118 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); | 120 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); |
119 | } else { | 121 | } else { |
120 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); | 122 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); |
121 | } | 123 | } |
122 | } | 124 | } |
123 | 125 | ||
124 | /** | 126 | /** |
125 | * Set the owner field with a given QString, for example per qcop. | 127 | * Set the owner field with a given QString, for example per qcop. |
126 | */ | 128 | */ |
127 | void Today::setOwnerField( QString &message ) { | 129 | void Today::setOwnerField( QString &message ) { |
128 | if ( !message.isEmpty() ) { | 130 | if ( !message.isEmpty() ) { |
129 | OwnerField->setText( "<b>" + message + "</b>" ); | 131 | OwnerField->setText( "<b>" + message + "</b>" ); |
130 | } | 132 | } |
131 | } | 133 | } |
132 | 134 | ||
133 | /** | 135 | /** |
134 | * Init stuff needed for today. Reads the config file. | 136 | * Init stuff needed for today. Reads the config file. |
135 | */ | 137 | */ |
136 | void Today::init() { | 138 | void Today::init() { |
137 | // read config | 139 | // read config |
138 | Config cfg( "today" ); | 140 | Config cfg( "today" ); |
139 | 141 | ||
140 | cfg.setGroup( "Plugins" ); | 142 | cfg.setGroup( "Plugins" ); |
141 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 143 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
142 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 144 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
143 | 145 | ||
144 | cfg.setGroup( "General" ); | 146 | cfg.setGroup( "General" ); |
145 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 147 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
146 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 148 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
147 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 149 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
148 | 150 | ||
149 | // set the date in top label | 151 | // set the date in top label |
150 | QDate date = QDate::currentDate(); | 152 | QDate date = QDate::currentDate(); |
151 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 153 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
152 | 154 | ||
153 | if ( m_hideBanner ) { | 155 | if ( m_hideBanner ) { |
154 | Opiezilla->hide(); | 156 | Opiezilla->hide(); |
155 | TodayLabel->hide(); | 157 | TodayLabel->hide(); |
156 | } else { | 158 | } else { |
157 | Opiezilla->show(); | 159 | Opiezilla->show(); |
158 | TodayLabel->show(); | 160 | TodayLabel->show(); |
159 | } | 161 | } |
160 | 162 | ||
161 | if ( m_big_box ) { | 163 | if ( m_big_box ) { |
162 | delete m_big_box; | 164 | delete m_big_box; |
163 | } | 165 | } |
164 | 166 | ||
165 | m_big_box = new QWidget( m_sv->viewport() ); | 167 | m_big_box = new QWidget( m_sv->viewport() ); |
166 | m_sv->addChild( m_big_box ); | 168 | m_sv->addChild( m_big_box ); |
167 | m_bblayout = new QVBoxLayout ( m_big_box ); | 169 | m_bblayout = new QVBoxLayout ( m_big_box ); |
168 | } | 170 | } |
169 | 171 | ||
170 | /** | 172 | /** |
171 | * Load the plugins | 173 | * Load the plugins |
172 | */ | 174 | */ |
173 | void Today::loadPlugins() { | 175 | void Today::loadPlugins() { |
174 | 176 | ||
175 | init(); | 177 | init(); |
176 | 178 | ||
177 | QValueList<TodayPlugin>::Iterator tit; | 179 | QValueList<TodayPlugin>::Iterator tit; |
178 | if ( !pluginList.isEmpty() ) { | 180 | if ( !pluginList.isEmpty() ) { |
179 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { | 181 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
180 | (*tit).guiBox->hide(); | 182 | (*tit).guiBox->hide(); |
181 | (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); | 183 | (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); |
182 | delete (*tit).guiBox; | 184 | delete (*tit).guiBox; |
183 | (*tit).library->unload(); | 185 | (*tit).library->unload(); |
184 | delete (*tit).library; | 186 | delete (*tit).library; |
185 | } | 187 | } |
186 | pluginList.clear(); | 188 | pluginList.clear(); |
187 | } | 189 | } |
188 | 190 | ||
189 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 191 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
190 | #ifdef Q_OS_MACX | 192 | #ifdef Q_OS_MACX |
191 | qWarning("Searching for Plugins in: %s", path.latin1()); | 193 | Opie::Core::owarn << "Searching for Plugins in: " << path << oendl; |
192 | QDir dir( path, "lib*.dylib" ); | 194 | QDir dir( path, "lib*.dylib" ); |
193 | #else | 195 | #else |
194 | QDir dir( path, "lib*.so" ); | 196 | QDir dir( path, "lib*.so" ); |
195 | #endif | 197 | #endif |
196 | 198 | ||
197 | QStringList list = dir.entryList(); | 199 | QStringList list = dir.entryList(); |
198 | QStringList::Iterator it; | 200 | QStringList::Iterator it; |
199 | 201 | ||
200 | // QMap<QString, TodayPlugin> tempList; | 202 | // QMap<QString, TodayPlugin> tempList; |
201 | 203 | ||
202 | for ( it = list.begin(); it != list.end(); ++it ) { | 204 | for ( it = list.begin(); it != list.end(); ++it ) { |
203 | QInterfacePtr<TodayPluginInterface> iface; | 205 | QInterfacePtr<TodayPluginInterface> iface; |
204 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 206 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
205 | 207 | ||
206 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 208 | Opie::Core::odebug << "querying: " << path + "/" + *it << oendl; |
207 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 209 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
208 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); | 210 | Opie::Core::odebug << "accepted: " << path + "/" + *it << oendl; |
209 | qDebug( QString(*it) ); | 211 | Opie::Core::odebug << *it << oendl; |
210 | 212 | ||
211 | TodayPlugin plugin; | 213 | TodayPlugin plugin; |
212 | plugin.library = lib; | 214 | plugin.library = lib; |
213 | plugin.iface = iface; | 215 | plugin.iface = iface; |
214 | plugin.name = QString(*it); | 216 | plugin.name = QString(*it); |
215 | 217 | ||
216 | QString type = (*it).left( (*it).find(".") ); | 218 | QString type = (*it).left( (*it).find(".") ); |
217 | 219 | ||
218 | QString lang; | 220 | QString lang; |
219 | Config config("locale"); | 221 | Config config("locale"); |
220 | config.setGroup("Language"); | 222 | config.setGroup("Language"); |
221 | lang = config.readEntry( "Language", "en" ); | 223 | lang = config.readEntry( "Language", "en" ); |
222 | 224 | ||
223 | qDebug( "Languages: " + lang ); | 225 | Opie::Core::odebug << "Languages: " << lang << oendl; |
224 | QTranslator * trans = new QTranslator( qApp ); | 226 | QTranslator * trans = new QTranslator( qApp ); |
225 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; | 227 | QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; |
226 | if ( trans->load( tfn ) ) { | 228 | if ( trans->load( tfn ) ) { |
227 | qApp->installTranslator( trans ); | 229 | qApp->installTranslator( trans ); |
228 | } else { | 230 | } else { |
229 | delete trans; | 231 | delete trans; |
230 | } | 232 | } |
231 | 233 | ||
232 | 234 | ||
233 | // find out if plugins should be shown | 235 | // find out if plugins should be shown |
234 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { | 236 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { |
235 | plugin.active = true; | 237 | plugin.active = true; |
236 | } else { | 238 | } else { |
237 | plugin.active = false; | 239 | plugin.active = false; |
238 | } | 240 | } |
239 | 241 | ||
240 | plugin.guiPart = plugin.iface->guiPart(); | 242 | plugin.guiPart = plugin.iface->guiPart(); |
241 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); | 243 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); |
242 | 244 | ||
243 | // package the whole thing into a qwidget so it can be shown and hidden | 245 | // package the whole thing into a qwidget so it can be shown and hidden |
244 | plugin.guiBox = new QWidget( m_big_box ); | 246 | plugin.guiBox = new QWidget( m_big_box ); |
245 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); | 247 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); |
246 | QPixmap plugPix; | 248 | QPixmap plugPix; |
247 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); | 249 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); |
248 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 250 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
249 | plugIcon->setPixmap( plugPix ); | 251 | plugIcon->setPixmap( plugPix ); |
250 | QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); | 252 | QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); |
251 | plugIcon->setName( plugin.guiPart->appName() ); | 253 | plugIcon->setName( plugin.guiPart->appName() ); |
252 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); | 254 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); |
253 | 255 | ||
254 | QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); | 256 | QWidget *plugWidget = plugin.guiPart->widget( plugin.guiBox ); |
255 | boxLayout->addWidget( plugIcon, 0, AlignTop ); | 257 | boxLayout->addWidget( plugIcon, 0, AlignTop ); |
256 | boxLayout->addWidget( plugWidget, 0, AlignTop ); | 258 | boxLayout->addWidget( plugWidget, 0, AlignTop ); |
257 | boxLayout->setStretchFactor( plugIcon, 1 ); | 259 | boxLayout->setStretchFactor( plugIcon, 1 ); |
258 | boxLayout->setStretchFactor( plugWidget, 9 ); | 260 | boxLayout->setStretchFactor( plugWidget, 9 ); |
259 | 261 | ||
260 | // "prebuffer" it in one more list, to get the sorting done | 262 | // "prebuffer" it in one more list, to get the sorting done |
261 | tempList.insert( plugin.name, plugin ); | 263 | tempList.insert( plugin.name, plugin ); |
262 | 264 | ||
263 | // on first start the list is off course empty | 265 | // on first start the list is off course empty |
264 | if ( m_allApplets.isEmpty() ) { | 266 | if ( m_allApplets.isEmpty() ) { |
265 | pluginList.append( plugin ); | 267 | pluginList.append( plugin ); |
266 | m_bblayout->addWidget( plugin.guiBox ); | 268 | m_bblayout->addWidget( plugin.guiBox ); |
267 | } | 269 | } |
268 | 270 | ||
269 | // if plugin is not yet in the list, add it to the layout too | 271 | // if plugin is not yet in the list, add it to the layout too |
270 | else if ( !m_allApplets.contains( plugin.name ) ) { | 272 | else if ( !m_allApplets.contains( plugin.name ) ) { |
271 | pluginList.append( plugin ); | 273 | pluginList.append( plugin ); |
272 | } | 274 | } |
273 | } else { | 275 | } else { |
274 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); | 276 | Opie::Core::odebug << "could not recognize " << path + "/" + *it << oendl; |
275 | delete lib; | 277 | delete lib; |
276 | } | 278 | } |
277 | 279 | ||
278 | } | 280 | } |
279 | 281 | ||
280 | 282 | ||
281 | if ( !m_allApplets.isEmpty() ) { | 283 | if ( !m_allApplets.isEmpty() ) { |
282 | TodayPlugin tempPlugin; | 284 | TodayPlugin tempPlugin; |
283 | QStringList::Iterator stringit; | 285 | QStringList::Iterator stringit; |
284 | 286 | ||
285 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { | 287 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { |
286 | tempPlugin = ( tempList.find( *stringit ) ).data(); | 288 | tempPlugin = ( tempList.find( *stringit ) ).data(); |
287 | if ( !( (tempPlugin.name).isEmpty() ) ) { | 289 | if ( !( (tempPlugin.name).isEmpty() ) ) { |
288 | pluginList.append( tempPlugin ); | 290 | pluginList.append( tempPlugin ); |
289 | m_bblayout->addWidget( tempPlugin.guiBox ); | 291 | m_bblayout->addWidget( tempPlugin.guiBox ); |
290 | } | 292 | } |
291 | } | 293 | } |
292 | } | 294 | } |
293 | m_bblayout->addStretch( 2 ); | 295 | m_bblayout->addStretch( 2 ); |
294 | draw(); | 296 | draw(); |
295 | } | 297 | } |
296 | 298 | ||
297 | 299 | ||
298 | 300 | ||
299 | 301 | ||
300 | /** | 302 | /** |
301 | * Repaint method. Reread all fields. | 303 | * Repaint method. Reread all fields. |
302 | */ | 304 | */ |
303 | void Today::draw() { | 305 | void Today::draw() { |
304 | 306 | ||
305 | if ( pluginList.count() == 0 ) { | 307 | if ( pluginList.count() == 0 ) { |
306 | QLabel *noPlugins = new QLabel( this ); | 308 | QLabel *noPlugins = new QLabel( this ); |
307 | noPlugins->setText( tr( "No plugins found" ) ); | 309 | noPlugins->setText( tr( "No plugins found" ) ); |
308 | layout->addWidget( noPlugins ); | 310 | layout->addWidget( noPlugins ); |
309 | return; | 311 | return; |
310 | } | 312 | } |
311 | 313 | ||
312 | uint count = 0; | 314 | uint count = 0; |
313 | TodayPlugin plugin; | 315 | TodayPlugin plugin; |
314 | for ( uint i = 0; i < pluginList.count(); i++ ) { | 316 | for ( uint i = 0; i < pluginList.count(); i++ ) { |
315 | plugin = pluginList[i]; | 317 | plugin = pluginList[i]; |
316 | 318 | ||
317 | if ( plugin.active ) { | 319 | if ( plugin.active ) { |
318 | // qDebug( plugin.name + " is ACTIVE " ); | 320 | //Opie::Core::odebug << plugin.name << " is ACTIVE " << oendl; |
319 | plugin.guiBox->show(); | 321 | plugin.guiBox->show(); |
320 | } else { | 322 | } else { |
321 | // qDebug( plugin.name + " is INACTIVE" ); | 323 | //Opie::Core::odebug << plugin.name << " is INACTIVE " << oendl; |
322 | plugin.guiBox->hide(); | 324 | plugin.guiBox->hide(); |
323 | } | 325 | } |
324 | count++; | 326 | count++; |
325 | } | 327 | } |
326 | 328 | ||
327 | if ( count == 0 ) { | 329 | if ( count == 0 ) { |
328 | QLabel *noPluginsActive = new QLabel( this ); | 330 | QLabel *noPluginsActive = new QLabel( this ); |
329 | noPluginsActive->setText( tr( "No plugins activated" ) ); | 331 | noPluginsActive->setText( tr( "No plugins activated" ) ); |
330 | layout->addWidget( noPluginsActive ); | 332 | layout->addWidget( noPluginsActive ); |
331 | } | 333 | } |
332 | repaint(); | 334 | repaint(); |
333 | } | 335 | } |
334 | 336 | ||
335 | 337 | ||
336 | /** | 338 | /** |
337 | * The method for the configuration dialog. | 339 | * The method for the configuration dialog. |
338 | */ | 340 | */ |
339 | void Today::startConfig() { | 341 | void Today::startConfig() { |
340 | 342 | ||
341 | // disconnect timer to prevent problems while being on config dialog | 343 | // disconnect timer to prevent problems while being on config dialog |
342 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 344 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
343 | m_refreshTimer->stop( ); | 345 | m_refreshTimer->stop( ); |
344 | 346 | ||
345 | TodayConfig conf( this, "dialog", true ); | 347 | TodayConfig conf( this, "dialog", true ); |
346 | 348 | ||
347 | TodayPlugin plugin; | 349 | TodayPlugin plugin; |
348 | QList<TodayConfigWidget> configWidgetList; | 350 | QList<TodayConfigWidget> configWidgetList; |
349 | 351 | ||
350 | for ( int i = pluginList.count() - 1; i >= 0; i-- ) { | 352 | for ( int i = pluginList.count() - 1; i >= 0; i-- ) { |
351 | plugin = pluginList[i]; | 353 | plugin = pluginList[i]; |
352 | 354 | ||
353 | // load the config widgets in the tabs | 355 | // load the config widgets in the tabs |
354 | if ( plugin.guiPart->configWidget( this ) != 0l ) { | 356 | if ( plugin.guiPart->configWidget( this ) != 0l ) { |
355 | TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); | 357 | TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); |
356 | configWidgetList.append( widget ); | 358 | configWidgetList.append( widget ); |
357 | conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() | 359 | conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() |
358 | , plugin.guiPart->appName() ); | 360 | , plugin.guiPart->appName() ); |
359 | } | 361 | } |
360 | // set the order/activate tab | 362 | // set the order/activate tab |
361 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), | 363 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), |
362 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); | 364 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); |
363 | } | 365 | } |
364 | 366 | ||
365 | if ( conf.exec() == QDialog::Accepted ) { | 367 | if ( conf.exec() == QDialog::Accepted ) { |
366 | conf.writeConfig(); | 368 | conf.writeConfig(); |
367 | TodayConfigWidget *confWidget; | 369 | TodayConfigWidget *confWidget; |
368 | for ( confWidget = configWidgetList.first(); confWidget != 0; | 370 | for ( confWidget = configWidgetList.first(); confWidget != 0; |
369 | confWidget = configWidgetList.next() ) { | 371 | confWidget = configWidgetList.next() ) { |
370 | confWidget->writeConfig(); | 372 | confWidget->writeConfig(); |
371 | } | 373 | } |
372 | 374 | ||
373 | // make the plugins to reinitialize ( reread its configs ) | 375 | // make the plugins to reinitialize ( reread its configs ) |
374 | reinitialize(); | 376 | reinitialize(); |
375 | draw(); | 377 | draw(); |
376 | 378 | ||
377 | } else { | 379 | } else { |
378 | // since refresh is not called in that case , reconnect the signal | 380 | // since refresh is not called in that case , reconnect the signal |
379 | m_refreshTimer->start( 15000 ); // get the config value in here later | 381 | m_refreshTimer->start( 15000 ); // get the config value in here later |
380 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 382 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
381 | } | 383 | } |
382 | } | 384 | } |
383 | 385 | ||
384 | 386 | ||
385 | 387 | ||
386 | void Today::reinitialize() { | 388 | void Today::reinitialize() { |
387 | 389 | ||
388 | Config cfg( "today" ); | 390 | Config cfg( "today" ); |
389 | cfg.setGroup( "Plugins" ); | 391 | cfg.setGroup( "Plugins" ); |
390 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 392 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
391 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 393 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
392 | 394 | ||
393 | /* reinitialize all plugins */ | 395 | /* reinitialize all plugins */ |
394 | QValueList<TodayPlugin>::Iterator it; | 396 | QValueList<TodayPlugin>::Iterator it; |
395 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 397 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
396 | if ( !(*it).excludeRefresh ) { | 398 | if ( !(*it).excludeRefresh ) { |
397 | (*it).guiPart->reinitialize(); | 399 | (*it).guiPart->reinitialize(); |
398 | qDebug( "reinit" ); | 400 | Opie::Core::odebug << "reinit" << oendl; |
399 | } | 401 | } |
400 | 402 | ||
401 | /* check if plugins is still to be shown */ | 403 | /* check if plugins is still to be shown */ |
402 | if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) { | 404 | if ( m_excludeApplets.grep( (*it).name ).isEmpty() ) { |
403 | (*it).active = true; | 405 | (*it).active = true; |
404 | } else { | 406 | } else { |
405 | (*it).active = false; | 407 | (*it).active = false; |
406 | } | 408 | } |
407 | 409 | ||
408 | } | 410 | } |
409 | 411 | ||
410 | cfg.setGroup( "General" ); | 412 | cfg.setGroup( "General" ); |
411 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 413 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
412 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); | 414 | m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); |
413 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 415 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
414 | 416 | ||
415 | // set the date in top label | 417 | // set the date in top label |
416 | QDate date = QDate::currentDate(); | 418 | QDate date = QDate::currentDate(); |
417 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); | 419 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); |
418 | 420 | ||
419 | if ( m_hideBanner ) { | 421 | if ( m_hideBanner ) { |
420 | Opiezilla->hide(); | 422 | Opiezilla->hide(); |
421 | TodayLabel->hide(); | 423 | TodayLabel->hide(); |
422 | } else { | 424 | } else { |
423 | Opiezilla->show(); | 425 | Opiezilla->show(); |
424 | TodayLabel->show(); | 426 | TodayLabel->show(); |
425 | } | 427 | } |
426 | 428 | ||
427 | delete m_bblayout; | 429 | delete m_bblayout; |
428 | m_bblayout = new QVBoxLayout( m_big_box ); | 430 | m_bblayout = new QVBoxLayout( m_big_box ); |
429 | TodayPlugin tempPlugin; | 431 | TodayPlugin tempPlugin; |
430 | QStringList::Iterator stringit; | 432 | QStringList::Iterator stringit; |
431 | 433 | ||
432 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { | 434 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { |
433 | tempPlugin = ( tempList.find( *stringit ) ).data(); | 435 | tempPlugin = ( tempList.find( *stringit ) ).data(); |
434 | if ( !( (tempPlugin.name).isEmpty() ) ) { | 436 | if ( !( (tempPlugin.name).isEmpty() ) ) { |
435 | m_bblayout->addWidget( tempPlugin.guiBox ); | 437 | m_bblayout->addWidget( tempPlugin.guiBox ); |
436 | } | 438 | } |
437 | } | 439 | } |
438 | m_bblayout->addStretch( 2 ); | 440 | m_bblayout->addStretch( 2 ); |
439 | 441 | ||
440 | } | 442 | } |
441 | 443 | ||
442 | /** | 444 | /** |
443 | * Refresh for the view. Reload all applets | 445 | * Refresh for the view. Reload all applets |
444 | * | 446 | * |
445 | */ | 447 | */ |
446 | void Today::refresh() { | 448 | void Today::refresh() { |
447 | 449 | ||
448 | QValueList<TodayPlugin>::Iterator it; | 450 | QValueList<TodayPlugin>::Iterator it; |
449 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 451 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
450 | if ( !(*it).excludeRefresh ) { | 452 | if ( !(*it).excludeRefresh ) { |
451 | (*it).guiPart->refresh(); | 453 | (*it).guiPart->refresh(); |
452 | qDebug( "refresh" ); | 454 | Opie::Core::odebug << "refresh" << oendl; |
453 | } | 455 | } |
454 | } | 456 | } |
455 | 457 | ||
456 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); | 458 | DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( QDate::currentDate() ) + "</font>" ) ); |
457 | 459 | ||
458 | updateGeometry(); | 460 | updateGeometry(); |
459 | repaint(); | 461 | repaint(); |
460 | } | 462 | } |
461 | 463 | ||
462 | void Today::startApplication() { | 464 | void Today::startApplication() { |
463 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 465 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
464 | e << QString( sender()->name() ); | 466 | e << QString( sender()->name() ); |
465 | } | 467 | } |
466 | 468 | ||
467 | /** | 469 | /** |
468 | * launch addressbook (personal card) | 470 | * launch addressbook (personal card) |
469 | */ | 471 | */ |
470 | void Today::editCard() { | 472 | void Today::editCard() { |
471 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); | 473 | QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); |
472 | } | 474 | } |
473 | 475 | ||
474 | Today::~Today() { | 476 | Today::~Today() { |
475 | } | 477 | } |
476 | 478 | ||