author | harlekin <harlekin> | 2002-10-31 21:24:44 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-31 21:24:44 (UTC) |
commit | 5409ca99206235961e964b42f5b7826bae95a42e (patch) (unidiff) | |
tree | 85904bd8eaffcffac2e65a2a8c3a0ca1234df318 | |
parent | 9453519728734e52aac9ea81a4ca3a867f013bda (diff) | |
download | opie-5409ca99206235961e964b42f5b7826bae95a42e.zip opie-5409ca99206235961e964b42f5b7826bae95a42e.tar.gz opie-5409ca99206235961e964b42f5b7826bae95a42e.tar.bz2 |
fixes for the new exclude from refresh system
-rw-r--r-- | core/pim/today/today.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 3eda5c0..01ef02d 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,385 +1,400 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp | 2 | * today.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by Maximilian Reiß | 4 | * copyright : (c) 2002 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 | #include "today.h" | 18 | #include "today.h" |
19 | #include <opie/todayconfigwidget.h> | 19 | #include <opie/todayconfigwidget.h> |
20 | 20 | ||
21 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/contact.h> | 26 | #include <qpe/contact.h> |
27 | 27 | ||
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qpixmap.h> | 33 | #include <qpixmap.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qhbox.h> | 35 | #include <qhbox.h> |
36 | #include <opie/otabwidget.h> | 36 | #include <opie/otabwidget.h> |
37 | #include <qdialog.h> | 37 | #include <qdialog.h> |
38 | #include <qwhatsthis.h> | 38 | #include <qwhatsthis.h> |
39 | 39 | ||
40 | 40 | ||
41 | struct TodayPlugin { | 41 | struct TodayPlugin { |
42 | QLibrary *library; | 42 | QLibrary *library; |
43 | TodayPluginInterface *iface; | 43 | TodayPluginInterface *iface; |
44 | TodayPluginObject *guiPart; | 44 | TodayPluginObject *guiPart; |
45 | QWidget *guiBox; | 45 | QWidget *guiBox; |
46 | QString name; | 46 | QString name; |
47 | bool active; | 47 | bool active; |
48 | bool excludeRefresh; | 48 | bool excludeRefresh; |
49 | int pos; | 49 | int pos; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static QValueList<TodayPlugin> pluginList; | 52 | static QValueList<TodayPlugin> pluginList; |
53 | 53 | ||
54 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 54 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
55 | : TodayBase( parent, name, fl ) { | 55 | : TodayBase( parent, name, fl ) { |
56 | 56 | ||
57 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); | 57 | QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); |
58 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); | 58 | QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); |
59 | 59 | ||
60 | #if defined(Q_WS_QWS) | 60 | #if defined(Q_WS_QWS) |
61 | #if !defined(QT_NO_COP) | 61 | #if !defined(QT_NO_COP) |
62 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); | 62 | QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); |
63 | connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), | 63 | connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), |
64 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); | 64 | this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); |
65 | #endif | 65 | #endif |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | setOwnerField(); | 68 | setOwnerField(); |
69 | m_refreshTimer = new QTimer( this ); | 69 | m_refreshTimer = new QTimer( this ); |
70 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 70 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
71 | m_refreshTimer->start( 15000 ); | 71 | m_refreshTimer->start( 15000 ); |
72 | refresh(); | 72 | refresh(); |
73 | showMaximized(); | 73 | showMaximized(); |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Qcop receive method. | 77 | * Qcop receive method. |
78 | */ | 78 | */ |
79 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { | 79 | void Today::channelReceived( const QCString &msg, const QByteArray & data ) { |
80 | QDataStream stream( data, IO_ReadOnly ); | 80 | QDataStream stream( data, IO_ReadOnly ); |
81 | if ( msg == "message(QString)" ) { | 81 | if ( msg == "message(QString)" ) { |
82 | QString message; | 82 | QString message; |
83 | stream >> message; | 83 | stream >> message; |
84 | setOwnerField( message ); | 84 | setOwnerField( message ); |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | void Today::setRefreshTimer( int interval ) { | 88 | void Today::setRefreshTimer( int interval ) { |
89 | 89 | ||
90 | 90 | ||
91 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 91 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
92 | 92 | ||
93 | // 0 is "never" case | 93 | // 0 is "never" case |
94 | if ( !interval == 0 ) { | 94 | if ( !interval == 0 ) { |
95 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 95 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
96 | m_refreshTimer->changeInterval( interval ); | 96 | m_refreshTimer->changeInterval( interval ); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | /** | 101 | /** |
102 | * Initialises the owner field with the default value, the username | 102 | * Initialises the owner field with the default value, the username |
103 | */ | 103 | */ |
104 | void Today::setOwnerField() { | 104 | void Today::setOwnerField() { |
105 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); | 105 | QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); |
106 | if ( QFile::exists( file ) ) { | 106 | if ( QFile::exists( file ) ) { |
107 | Contact cont = Contact::readVCard( file )[0]; | 107 | Contact cont = Contact::readVCard( file )[0]; |
108 | QString returnString = cont.fullName(); | 108 | QString returnString = cont.fullName(); |
109 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); | 109 | OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); |
110 | } else { | 110 | } else { |
111 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); | 111 | OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * Set the owner field with a given QString, for example per qcop. | 116 | * Set the owner field with a given QString, for example per qcop. |
117 | */ | 117 | */ |
118 | void Today::setOwnerField( QString &message ) { | 118 | void Today::setOwnerField( QString &message ) { |
119 | if ( !message.isEmpty() ) { | 119 | if ( !message.isEmpty() ) { |
120 | OwnerField->setText( "<b>" + message + "</b>" ); | 120 | OwnerField->setText( "<b>" + message + "</b>" ); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | /** | 125 | /** |
126 | * Init stuff needed for today. Reads the config file. | 126 | * Init stuff needed for today. Reads the config file. |
127 | */ | 127 | */ |
128 | void Today::init() { | 128 | void Today::init() { |
129 | // read config | 129 | // read config |
130 | Config cfg( "today" ); | 130 | Config cfg( "today" ); |
131 | 131 | ||
132 | cfg.setGroup( "Plugins" ); | 132 | cfg.setGroup( "Plugins" ); |
133 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); | 133 | m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); |
134 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); | 134 | m_allApplets = cfg.readListEntry( "AllApplets", ',' ); |
135 | 135 | ||
136 | cfg.setGroup( "General" ); | 136 | cfg.setGroup( "General" ); |
137 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); | 137 | m_iconSize = cfg.readNumEntry( "IconSize", 18 ); |
138 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); | 138 | setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | /** | 142 | /** |
143 | * Load the plugins | 143 | * Load the plugins |
144 | */ | 144 | */ |
145 | void Today::loadPlugins() { | 145 | void Today::loadPlugins() { |
146 | 146 | ||
147 | // extra list for plugins that exclude themself from periodic refresh | 147 | // extra list for plugins that exclude themself from periodic refresh |
148 | QMap<QString, TodayPlugin> pluginListRefreshExclude; | 148 | QMap<QString, TodayPlugin> pluginListRefreshExclude; |
149 | 149 | ||
150 | QValueList<TodayPlugin>::Iterator tit; | 150 | QValueList<TodayPlugin>::Iterator tit; |
151 | if ( !pluginList.isEmpty() ) { | 151 | if ( !pluginList.isEmpty() ) { |
152 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { | 152 | for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { |
153 | if ( (*tit).excludeRefresh ) { | 153 | if ( (*tit).excludeRefresh ) { |
154 | pluginListRefreshExclude.insert( (*tit).name , (*tit) ); | 154 | pluginListRefreshExclude.insert( (*tit).name , (*tit) ); |
155 | qDebug( "Found an plug that does not want refresh feature" ); | 155 | qDebug( "Found an plugin that does not want refresh feature" ); |
156 | } else { | 156 | } else { |
157 | (*tit).library->unload(); | 157 | (*tit).library->unload(); |
158 | delete (*tit).library; | 158 | delete (*tit).library; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | pluginList.clear(); | 161 | pluginList.clear(); |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | QString path = QPEApplication::qpeDir() + "/plugins/today"; | 165 | QString path = QPEApplication::qpeDir() + "/plugins/today"; |
166 | QDir dir( path, "lib*.so" ); | 166 | QDir dir( path, "lib*.so" ); |
167 | 167 | ||
168 | QStringList list = dir.entryList(); | 168 | QStringList list = dir.entryList(); |
169 | QStringList::Iterator it; | 169 | QStringList::Iterator it; |
170 | 170 | ||
171 | QMap<QString, TodayPlugin> tempList; | 171 | QMap<QString, TodayPlugin> tempList; |
172 | 172 | ||
173 | for ( it = list.begin(); it != list.end(); ++it ) { | 173 | for ( it = list.begin(); it != list.end(); ++it ) { |
174 | TodayPluginInterface *iface = 0; | 174 | TodayPluginInterface *iface = 0; |
175 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 175 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
176 | 176 | ||
177 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 177 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); |
178 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 178 | if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
179 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); | 179 | qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); |
180 | qDebug( QString(*it) ); | 180 | qDebug( QString(*it) ); |
181 | 181 | ||
182 | // If plugin is exludes from refresh, get it in the list again here. | 182 | // If plugin is exludes from refresh, get it in the list again here. |
183 | 183 | ||
184 | if ( pluginListRefreshExclude.contains( (*it) ) ) { | 184 | if ( pluginListRefreshExclude.contains( (*it) ) ) { |
185 | tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] ); | 185 | |
186 | qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name ); | 186 | // if its not in allApplets list, add it to a layout |
187 | if ( !m_allApplets.contains( pluginListRefreshExclude[(*it)].name ) ) { | ||
188 | qDebug( "NUGASDA" ); | ||
189 | layout->addWidget( pluginListRefreshExclude[(*it)].guiBox ); | ||
190 | pluginList.append( pluginListRefreshExclude[(*it)] ); | ||
191 | } else { | ||
192 | tempList.insert( pluginListRefreshExclude[(*it)].name, pluginListRefreshExclude[(*it)] ); | ||
193 | qDebug( "TEST2 " + pluginListRefreshExclude[(*it)].name ); | ||
194 | } | ||
187 | } else { | 195 | } else { |
188 | 196 | ||
189 | TodayPlugin plugin; | 197 | TodayPlugin plugin; |
190 | plugin.library = lib; | 198 | plugin.library = lib; |
191 | plugin.iface = iface; | 199 | plugin.iface = iface; |
192 | plugin.name = QString(*it); | 200 | plugin.name = QString(*it); |
193 | 201 | ||
194 | // find out if plugins should be shown | 202 | // find out if plugins should be shown |
195 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { | 203 | if ( m_excludeApplets.grep( *it ).isEmpty() ) { |
196 | plugin.active = true; | 204 | plugin.active = true; |
197 | } else { | 205 | } else { |
198 | plugin.active = false; | 206 | plugin.active = false; |
199 | } | 207 | } |
208 | |||
200 | plugin.guiPart = plugin.iface->guiPart(); | 209 | plugin.guiPart = plugin.iface->guiPart(); |
201 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); | 210 | plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); |
202 | 211 | ||
203 | // package the whole thing into a qwidget so it can be shown and hidden | 212 | // package the whole thing into a qwidget so it can be shown and hidden |
204 | plugin.guiBox = new QWidget( this ); | 213 | plugin.guiBox = new QWidget( this ); |
205 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); | 214 | QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); |
206 | QPixmap plugPix; | 215 | QPixmap plugPix; |
207 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); | 216 | plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); |
208 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); | 217 | OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); |
209 | plugIcon->setPixmap( plugPix ); | 218 | plugIcon->setPixmap( plugPix ); |
210 | QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); | 219 | QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); |
211 | plugIcon->setName( plugin.guiPart->appName() ); | 220 | plugIcon->setName( plugin.guiPart->appName() ); |
212 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); | 221 | connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); |
213 | // a scrollview for each plugin | 222 | // a scrollview for each plugin |
214 | QScrollView* sv = new QScrollView( plugin.guiBox ); | 223 | QScrollView* sv = new QScrollView( plugin.guiBox ); |
215 | QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); | 224 | QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); |
216 | // not sure if that is good .-) | 225 | // not sure if that is good .-) |
217 | sv->setMinimumHeight( 10 ); | 226 | sv->setMinimumHeight( 10 ); |
218 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 227 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
219 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 228 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
220 | sv->setFrameShape( QFrame::NoFrame ); | 229 | sv->setFrameShape( QFrame::NoFrame ); |
221 | sv->addChild( plugWidget ); | 230 | sv->addChild( plugWidget ); |
222 | // make sure the icon is on the top alligned | 231 | // make sure the icon is on the top alligned |
223 | boxLayout->addWidget( plugIcon, 0, AlignTop ); | 232 | boxLayout->addWidget( plugIcon, 0, AlignTop ); |
224 | boxLayout->addWidget( sv, 0, AlignTop ); | 233 | boxLayout->addWidget( sv, 0, AlignTop ); |
225 | boxLayout->setStretchFactor( plugIcon, 1 ); | 234 | boxLayout->setStretchFactor( plugIcon, 1 ); |
226 | boxLayout->setStretchFactor( sv, 9 ); | 235 | boxLayout->setStretchFactor( sv, 9 ); |
227 | // "prebuffer" it in one more list, to get the sorting done | 236 | // "prebuffer" it in one more list, to get the sorting done |
228 | tempList.insert( plugin.name, plugin ); | 237 | tempList.insert( plugin.name, plugin ); |
229 | 238 | ||
230 | // on first start the list is off course empty | 239 | // on first start the list is off course empty |
231 | if ( m_allApplets.isEmpty() ) { | 240 | if ( m_allApplets.isEmpty() ) { |
232 | layout->addWidget( plugin.guiBox ); | 241 | layout->addWidget( plugin.guiBox ); |
233 | pluginList.append( plugin ); | 242 | pluginList.append( plugin ); |
234 | } | 243 | } |
244 | |||
245 | // if plugin is not yet in the list, add it to the layout too | ||
246 | if ( !m_allApplets.contains( plugin.name ) ) { | ||
247 | layout->addWidget( plugin.guiBox ); | ||
248 | pluginList.append( plugin ); | ||
249 | } | ||
235 | } | 250 | } |
236 | } else { | 251 | } else { |
237 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); | 252 | qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); |
238 | delete lib; | 253 | delete lib; |
239 | } | 254 | } |
240 | } | 255 | } |
241 | 256 | ||
242 | if ( !m_allApplets.isEmpty() ) { | 257 | if ( !m_allApplets.isEmpty() ) { |
243 | TodayPlugin tempPlugin; | 258 | TodayPlugin tempPlugin; |
244 | QStringList::Iterator stringit; | 259 | QStringList::Iterator stringit; |
245 | 260 | ||
246 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { | 261 | for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { |
247 | tempPlugin = ( tempList.find( *stringit ) ).data(); | 262 | tempPlugin = ( tempList.find( *stringit ) ).data(); |
248 | if ( !( (tempPlugin.name).isEmpty() ) ) { | 263 | if ( !( (tempPlugin.name).isEmpty() ) ) { |
249 | layout->addWidget( tempPlugin.guiBox ); | 264 | layout->addWidget( tempPlugin.guiBox ); |
250 | pluginList.append( tempPlugin ); | 265 | pluginList.append( tempPlugin ); |
251 | } | 266 | } |
252 | } | 267 | } |
253 | } | 268 | } |
254 | } | 269 | } |
255 | 270 | ||
256 | 271 | ||
257 | /** | 272 | /** |
258 | * Repaint method. Reread all fields. | 273 | * Repaint method. Reread all fields. |
259 | */ | 274 | */ |
260 | void Today::draw() { | 275 | void Today::draw() { |
261 | 276 | ||
262 | if ( pluginList.count() == 0 ) { | 277 | if ( pluginList.count() == 0 ) { |
263 | QLabel *noPlugins = new QLabel( this ); | 278 | QLabel *noPlugins = new QLabel( this ); |
264 | noPlugins->setText( tr( "No plugins found" ) ); | 279 | noPlugins->setText( tr( "No plugins found" ) ); |
265 | layout->addWidget( noPlugins ); | 280 | layout->addWidget( noPlugins ); |
266 | return; | 281 | return; |
267 | } | 282 | } |
268 | 283 | ||
269 | uint count = 0; | 284 | uint count = 0; |
270 | TodayPlugin plugin; | 285 | TodayPlugin plugin; |
271 | for ( uint i = 0; i < pluginList.count(); i++ ) { | 286 | for ( uint i = 0; i < pluginList.count(); i++ ) { |
272 | plugin = pluginList[i]; | 287 | plugin = pluginList[i]; |
273 | 288 | ||
274 | if ( plugin.active ) { | 289 | if ( plugin.active ) { |
275 | // qDebug( plugin.name + " is ACTIVE " ); | 290 | // qDebug( plugin.name + " is ACTIVE " ); |
276 | plugin.guiBox->show(); | 291 | plugin.guiBox->show(); |
277 | } else { | 292 | } else { |
278 | // qDebug( plugin.name + " is INACTIVE" ); | 293 | // qDebug( plugin.name + " is INACTIVE" ); |
279 | plugin.guiBox->hide(); | 294 | plugin.guiBox->hide(); |
280 | } | 295 | } |
281 | count++; | 296 | count++; |
282 | } | 297 | } |
283 | 298 | ||
284 | if ( count == 0 ) { | 299 | if ( count == 0 ) { |
285 | QLabel *noPluginsActive = new QLabel( this ); | 300 | QLabel *noPluginsActive = new QLabel( this ); |
286 | noPluginsActive->setText( tr( "No plugins activated" ) ); | 301 | noPluginsActive->setText( tr( "No plugins activated" ) ); |
287 | layout->addWidget( noPluginsActive ); | 302 | layout->addWidget( noPluginsActive ); |
288 | } | 303 | } |
289 | layout->addStretch(0); | 304 | layout->addStretch(0); |
290 | } | 305 | } |
291 | 306 | ||
292 | 307 | ||
293 | /** | 308 | /** |
294 | * The method for the configuration dialog. | 309 | * The method for the configuration dialog. |
295 | */ | 310 | */ |
296 | void Today::startConfig() { | 311 | void Today::startConfig() { |
297 | 312 | ||
298 | // disconnect timer to prevent problems while being on config dialog | 313 | // disconnect timer to prevent problems while being on config dialog |
299 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 314 | disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
300 | 315 | ||
301 | TodayConfig conf( this, "dialog", true ); | 316 | TodayConfig conf( this, "dialog", true ); |
302 | 317 | ||
303 | TodayPlugin plugin; | 318 | TodayPlugin plugin; |
304 | QList<TodayConfigWidget> configWidgetList; | 319 | QList<TodayConfigWidget> configWidgetList; |
305 | 320 | ||
306 | for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { | 321 | for ( int i = pluginList.count() - 1 ; i >= 0; i-- ) { |
307 | plugin = pluginList[i]; | 322 | plugin = pluginList[i]; |
308 | 323 | ||
309 | // load the config widgets in the tabs | 324 | // load the config widgets in the tabs |
310 | if ( plugin.guiPart->configWidget( this ) != 0l ) { | 325 | if ( plugin.guiPart->configWidget( this ) != 0l ) { |
311 | TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); | 326 | TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); |
312 | configWidgetList.append( widget ); | 327 | configWidgetList.append( widget ); |
313 | conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() | 328 | conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() |
314 | , plugin.guiPart->appName() ); | 329 | , plugin.guiPart->appName() ); |
315 | } | 330 | } |
316 | // set the order/activate tab | 331 | // set the order/activate tab |
317 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), | 332 | conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), |
318 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); | 333 | Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); |
319 | } | 334 | } |
320 | 335 | ||
321 | if ( conf.exec() == QDialog::Accepted ) { | 336 | if ( conf.exec() == QDialog::Accepted ) { |
322 | conf.writeConfig(); | 337 | conf.writeConfig(); |
323 | TodayConfigWidget *confWidget; | 338 | TodayConfigWidget *confWidget; |
324 | for ( confWidget = configWidgetList.first(); confWidget != 0; | 339 | for ( confWidget = configWidgetList.first(); confWidget != 0; |
325 | confWidget = configWidgetList.next() ) { | 340 | confWidget = configWidgetList.next() ) { |
326 | confWidget->writeConfig(); | 341 | confWidget->writeConfig(); |
327 | } | 342 | } |
328 | refresh(); | 343 | refresh(); |
329 | } else { | 344 | } else { |
330 | // since refresh is not called in that case , reconnect the signal | 345 | // since refresh is not called in that case , reconnect the signal |
331 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | 346 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); |
332 | } | 347 | } |
333 | } | 348 | } |
334 | 349 | ||
335 | 350 | ||
336 | /** | 351 | /** |
337 | * Refresh for the view. Reload all applets | 352 | * Refresh for the view. Reload all applets |
338 | * | 353 | * |
339 | */ | 354 | */ |
340 | void Today::refresh() { | 355 | void Today::refresh() { |
341 | init(); | 356 | init(); |
342 | 357 | ||
343 | qDebug(" refresh "); | 358 | qDebug(" refresh "); |
344 | // set the date in top label | 359 | // set the date in top label |
345 | QDate date = QDate::currentDate(); | 360 | QDate date = QDate::currentDate(); |
346 | QString time = ( tr( date.toString() ) ); | 361 | QString time = ( tr( date.toString() ) ); |
347 | 362 | ||
348 | DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); | 363 | DateLabel->setText( QString( "<font color=#FFFFFF>" + time + "</font>" ) ); |
349 | 364 | ||
350 | if ( layout ) { | 365 | if ( layout ) { |
351 | delete layout; | 366 | delete layout; |
352 | } | 367 | } |
353 | layout = new QVBoxLayout( this ); | 368 | layout = new QVBoxLayout( this ); |
354 | layout->addWidget( Frame ); | 369 | layout->addWidget( Frame ); |
355 | layout->addWidget( OwnerField ); | 370 | layout->addWidget( OwnerField ); |
356 | 371 | ||
357 | loadPlugins(); | 372 | loadPlugins(); |
358 | draw(); | 373 | draw(); |
359 | } | 374 | } |
360 | 375 | ||
361 | void Today::startAddressbook() { | 376 | void Today::startAddressbook() { |
362 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 377 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
363 | e << QString( "addressbook" ); | 378 | e << QString( "addressbook" ); |
364 | } | 379 | } |
365 | 380 | ||
366 | 381 | ||
367 | void Today::startApplication() { | 382 | void Today::startApplication() { |
368 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 383 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
369 | e << QString( sender()->name() ); | 384 | e << QString( sender()->name() ); |
370 | } | 385 | } |
371 | 386 | ||
372 | /** | 387 | /** |
373 | * launch addressbook (personal card) | 388 | * launch addressbook (personal card) |
374 | */ | 389 | */ |
375 | void Today::editCard() { | 390 | void Today::editCard() { |
376 | startAddressbook(); | 391 | startAddressbook(); |
377 | while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { | 392 | while( !QCopChannel::isRegistered( "QPE/Addressbook" ) ) { |
378 | qApp->processEvents(); | 393 | qApp->processEvents(); |
379 | } | 394 | } |
380 | QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); | 395 | QCopEnvelope v( "QPE/Addressbook", "editPersonalAndClose()" ); |
381 | } | 396 | } |
382 | 397 | ||
383 | Today::~Today() { | 398 | Today::~Today() { |
384 | } | 399 | } |
385 | 400 | ||