summaryrefslogtreecommitdiff
authoralwin <alwin>2004-11-11 21:10:16 (UTC)
committer alwin <alwin>2004-11-11 21:10:16 (UTC)
commitd2d25a3c1e60a34436cd93e5214a35b3edd05c6c (patch) (unidiff)
tree0c1bd62dd09e7a86292399f68c823b7eb6ae031e
parente85cf7184c3444e26c1858d0564fa5d3614dd7b5 (diff)
downloadopie-d2d25a3c1e60a34436cd93e5214a35b3edd05c6c.zip
opie-d2d25a3c1e60a34436cd93e5214a35b3edd05c6c.tar.gz
opie-d2d25a3c1e60a34436cd93e5214a35b3edd05c6c.tar.bz2
- flush icon cache if reloading all documents
- send QCop message when the doctab is enabled/disabled so the disabled widget appears or the doc-list will reread
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp610
-rw-r--r--core/launcher/documentlist.h3
-rw-r--r--core/launcher/launcher.cpp107
-rw-r--r--core/launcher/launcher.h1
-rw-r--r--core/launcher/launcherview.cpp4
-rw-r--r--core/launcher/server.cpp210
6 files changed, 483 insertions, 452 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index d8e7a83..9781a32 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -1,803 +1,811 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "documentlist.h" 20#include "documentlist.h"
21#include "serverinterface.h" 21#include "serverinterface.h"
22#include "mediadlg.h" 22#include "mediadlg.h"
23 23
24/* OPIE */ 24/* OPIE */
25#include <opie2/oglobal.h> 25#include <opie2/oglobal.h>
26#include <opie2/odebug.h> 26#include <opie2/odebug.h>
27#include <qtopia/config.h> 27#include <qtopia/config.h>
28#include <qtopia/mimetype.h> 28#include <qtopia/mimetype.h>
29#include <qtopia/resource.h> 29#include <qtopia/resource.h>
30#include <qtopia/private/categories.h> 30#include <qtopia/private/categories.h>
31#include <qtopia/qpeapplication.h> 31#include <qtopia/qpeapplication.h>
32#include <qtopia/applnk.h> 32#include <qtopia/applnk.h>
33#include <qtopia/storage.h> 33#include <qtopia/storage.h>
34#ifdef Q_WS_QWS 34#ifdef Q_WS_QWS
35#include <qtopia/qcopenvelope_qws.h> 35#include <qtopia/qcopenvelope_qws.h>
36#endif 36#endif
37using namespace Opie::Core; 37using namespace Opie::Core;
38 38
39/* QT */ 39/* QT */
40#include <qtimer.h> 40#include <qtimer.h>
41#include <qfileinfo.h> 41#include <qfileinfo.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43#include <qfile.h> 43#include <qfile.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qpainter.h> 45#include <qpainter.h>
46#include <qimage.h> 46#include <qimage.h>
47#include <qcopchannel_qws.h> 47#include <qcopchannel_qws.h>
48#include <qlistview.h> 48#include <qlistview.h>
49#include <qlist.h> 49#include <qlist.h>
50#include <qpixmap.h> 50#include <qpixmap.h>
51 51
52 52
53AppLnkSet *DocumentList::appLnkSet = 0; 53AppLnkSet *DocumentList::appLnkSet = 0;
54 54
55static const int MAX_SEARCH_DEPTH = 10; 55static const int MAX_SEARCH_DEPTH = 10;
56 56
57 57
58class DocumentListPrivate : public QObject { 58class DocumentListPrivate : public QObject {
59 Q_OBJECT 59 Q_OBJECT
60public: 60public:
61 DocumentListPrivate( ServerInterface *gui ); 61 DocumentListPrivate( ServerInterface *gui );
62 ~DocumentListPrivate(); 62 ~DocumentListPrivate();
63 63
64 void initialize(); 64 void initialize();
65 65
66 const QString nextFile(); 66 const QString nextFile();
67 const DocLnk *iterate(); 67 const DocLnk *iterate();
68 bool store( DocLnk* dl ); 68 bool store( DocLnk* dl );
69 void estimatedPercentScanned(); 69 void estimatedPercentScanned();
70 void appendDocpath(FileSystem*); 70 void appendDocpath(FileSystem*);
71 71
72 72
73 DocLnkSet dls; 73 DocLnkSet dls;
74 QDict<void> reference; 74 QDict<void> reference;
75 QDictIterator<void> *dit; 75 QDictIterator<void> *dit;
76 enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; 76 enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state;
77 77
78 QStringList docPaths; 78 QStringList docPaths;
79 unsigned int docPathsSearched; 79 unsigned int docPathsSearched;
80 80
81 int searchDepth; 81 int searchDepth;
82 QDir *listDirs[MAX_SEARCH_DEPTH]; 82 QDir *listDirs[MAX_SEARCH_DEPTH];
83 const QFileInfoList *lists[MAX_SEARCH_DEPTH]; 83 const QFileInfoList *lists[MAX_SEARCH_DEPTH];
84 unsigned int listPositions[MAX_SEARCH_DEPTH]; 84 unsigned int listPositions[MAX_SEARCH_DEPTH];
85 85
86 StorageInfo *storage; 86 StorageInfo *storage;
87 87
88 int tid; 88 int tid;
89 89
90 ServerInterface *serverGui; 90 ServerInterface *serverGui;
91 91
92 bool needToSendAllDocLinks; 92 bool needToSendAllDocLinks;
93 bool sendAppLnks; 93 bool sendAppLnks;
94 bool sendDocLnks; 94 bool sendDocLnks;
95 bool scanDocs; 95 bool scanDocs;
96}; 96};
97 97
98 98
99/* 99/*
100 * scandocs will be read from Config 100 * scandocs will be read from Config
101 */ 101 */
102DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, 102DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/,
103 QObject *parent, const char *name ) 103 QObject *parent, const char *name )
104 : QObject( parent, name ) 104 : QObject( parent, name )
105{ 105{
106 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 106 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
107 d = new DocumentListPrivate( serverGui ); 107 d = new DocumentListPrivate( serverGui );
108 d->needToSendAllDocLinks = false; 108 d->needToSendAllDocLinks = false;
109 109
110 Config cfg( "Launcher" ); 110 Config cfg( "Launcher" );
111 cfg.setGroup( "DocTab" ); 111 cfg.setGroup( "DocTab" );
112 d->scanDocs = cfg.readBoolEntry( "Enable", true ); 112 d->scanDocs = cfg.readBoolEntry( "Enable", true );
113 odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl; 113 odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl;
114 114
115 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); 115 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) );
116} 116}
117 117
118void DocumentList::startInitialScan() 118void DocumentList::startInitialScan()
119{ 119{
120 reloadAppLnks(); 120 reloadAppLnks();
121 reloadDocLnks(); 121 reloadDocLnks();
122} 122}
123 123
124DocumentList::~DocumentList() 124DocumentList::~DocumentList()
125{ 125{
126 delete appLnkSet; 126 delete appLnkSet;
127 delete d; 127 delete d;
128} 128}
129 129
130 130
131void DocumentList::add( const DocLnk& doc ) 131void DocumentList::add( const DocLnk& doc )
132{ 132{
133 if ( d->serverGui && QFile::exists( doc.file() ) ) 133 if ( d->serverGui && QFile::exists( doc.file() ) )
134 d->serverGui->documentAdded( doc ); 134 d->serverGui->documentAdded( doc );
135} 135}
136 136
137 137
138void DocumentList::start() 138void DocumentList::start()
139{ 139{
140 resume(); 140 resume();
141} 141}
142 142
143 143
144void DocumentList::pause() 144void DocumentList::pause()
145{ 145{
146 //odebug << "pause " << d->tid << "" << oendl; 146 //odebug << "pause " << d->tid << "" << oendl;
147 killTimer( d->tid ); 147 killTimer( d->tid );
148 d->tid = 0; 148 d->tid = 0;
149} 149}
150 150
151 151
152void DocumentList::resume() 152void DocumentList::resume()
153{ 153{
154 if ( d->tid == 0 ) { 154 if ( d->tid == 0 ) {
155 d->tid = startTimer( 20 ); 155 d->tid = startTimer( 20 );
156 //odebug << "resumed " << d->tid << "" << oendl; 156 //odebug << "resumed " << d->tid << "" << oendl;
157 } 157 }
158} 158}
159 159
160/* 160/*
161void DocumentList::resend() 161void DocumentList::resend()
162{ 162{
163 // Re-emits all the added items to the list (firstly letting everyone know to 163 // Re-emits all the added items to the list (firstly letting everyone know to
164 // clear what they have as it is being sent again) 164 // clear what they have as it is being sent again)
165 pause(); 165 pause();
166 emit allRemoved(); 166 emit allRemoved();
167 QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); 167 QTimer::singleShot( 5, this, SLOT( resendWorker() ) );
168} 168}
169 169
170 170
171void DocumentList::resendWorker() 171void DocumentList::resendWorker()
172{ 172{
173 const QList<DocLnk> &list = d->dls.children(); 173 const QList<DocLnk> &list = d->dls.children();
174 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) 174 for ( QListIterator<DocLnk> it( list ); it.current(); ++it )
175 add( *(*it) ); 175 add( *(*it) );
176 resume(); 176 resume();
177} 177}
178*/ 178*/
179 179
180void DocumentList::rescan() 180void DocumentList::rescan()
181{ 181{
182 //odebug << "rescan" << oendl; 182 //odebug << "rescan" << oendl;
183 pause(); 183 pause();
184 d->initialize(); 184 d->initialize();
185 resume(); 185 resume();
186} 186}
187 187
188 188
189void DocumentList::timerEvent( QTimerEvent *te ) 189void DocumentList::timerEvent( QTimerEvent *te )
190{ 190{
191 if ( te->timerId() == d->tid ) { 191 if ( te->timerId() == d->tid ) {
192 // Do 3 at a time 192 // Do 3 at a time
193 if ( d->serverGui ) 193 if ( d->serverGui )
194 d->serverGui->aboutToAddBegin(); 194 d->serverGui->aboutToAddBegin();
195 for (int i = 0; i < 3; i++ ) { 195 for (int i = 0; i < 3; i++ ) {
196 const DocLnk *lnk = d->iterate(); 196 const DocLnk *lnk = d->iterate();
197 if ( lnk ) { 197 if ( lnk ) {
198 add( *lnk ); 198 add( *lnk );
199 } else { 199 } else {
200 // stop when done 200 // stop when done
201 pause(); 201 pause();
202 if ( d->serverGui ) 202 if ( d->serverGui )
203 d->serverGui->documentScanningProgress( 100 ); 203 d->serverGui->documentScanningProgress( 100 );
204 if ( d->needToSendAllDocLinks ) 204 if ( d->needToSendAllDocLinks )
205 sendAllDocLinks(); 205 sendAllDocLinks();
206 break; 206 break;
207 } 207 }
208 } 208 }
209 if ( d->serverGui ) 209 if ( d->serverGui )
210 d->serverGui->aboutToAddEnd(); 210 d->serverGui->aboutToAddEnd();
211 } 211 }
212} 212}
213 213
214 214
215void DocumentList::reloadAppLnks() 215void DocumentList::reloadAppLnks()
216{ 216{
217 if ( d->sendAppLnks && d->serverGui ) { 217 if ( d->sendAppLnks && d->serverGui ) {
218 d->serverGui->applicationScanningProgress( 0 ); 218 d->serverGui->applicationScanningProgress( 0 );
219 d->serverGui->allApplicationsRemoved(); 219 d->serverGui->allApplicationsRemoved();
220 } 220 }
221 221
222 delete appLnkSet; 222 delete appLnkSet;
223 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 223 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
224 224
225 if ( d->sendAppLnks && d->serverGui ) { 225 if ( d->sendAppLnks && d->serverGui ) {
226 static QStringList prevTypeList; 226 static QStringList prevTypeList;
227 QStringList types = appLnkSet->types(); 227 QStringList types = appLnkSet->types();
228 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 228 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
229 if ( !(*ittypes).isEmpty() ) { 229 if ( !(*ittypes).isEmpty() ) {
230 if ( !prevTypeList.contains(*ittypes) ) { 230 if ( !prevTypeList.contains(*ittypes) ) {
231 QString name = appLnkSet->typeName(*ittypes); 231 QString name = appLnkSet->typeName(*ittypes);
232 QPixmap pm = appLnkSet->typePixmap(*ittypes); 232 QPixmap pm = appLnkSet->typePixmap(*ittypes);
233 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); 233 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes);
234 234
235 if (pm.isNull()) { 235 if (pm.isNull()) {
236 QImage img( Resource::loadImage( "UnknownDocument" ) ); 236 QImage img( Resource::loadImage( "UnknownDocument" ) );
237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
238 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 238 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
239 } 239 }
240 240
241 //odebug << "adding type " << (*ittypes) << "" << oendl; 241 //odebug << "adding type " << (*ittypes) << "" << oendl;
242 242
243 // ### our current launcher expects docs tab to be last 243 // ### our current launcher expects docs tab to be last
244 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 244 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
245 } 245 }
246 prevTypeList.remove(*ittypes); 246 prevTypeList.remove(*ittypes);
247 } 247 }
248 } 248 }
249 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 249 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
250 //odebug << "removing type " << (*ittypes) << "" << oendl; 250 //odebug << "removing type " << (*ittypes) << "" << oendl;
251 d->serverGui->typeRemoved(*ittypes); 251 d->serverGui->typeRemoved(*ittypes);
252 } 252 }
253 prevTypeList = types; 253 prevTypeList = types;
254 } 254 }
255 255
256 QListIterator<AppLnk> itapp( appLnkSet->children() ); 256 QListIterator<AppLnk> itapp( appLnkSet->children() );
257 AppLnk* l; 257 AppLnk* l;
258 while ( (l=itapp.current()) ) { 258 while ( (l=itapp.current()) ) {
259 ++itapp; 259 ++itapp;
260 if ( d->sendAppLnks && d->serverGui ) 260 if ( d->sendAppLnks && d->serverGui )
261 d->serverGui->applicationAdded( l->type(), *l ); 261 d->serverGui->applicationAdded( l->type(), *l );
262 } 262 }
263 263
264 if ( d->sendAppLnks && d->serverGui ) 264 if ( d->sendAppLnks && d->serverGui )
265 d->serverGui->applicationScanningProgress( 100 ); 265 d->serverGui->applicationScanningProgress( 100 );
266} 266}
267 267
268void DocumentList::reloadDocLnks() 268void DocumentList::reloadDocLnks()
269{ 269{
270 if ( !d->scanDocs ) 270 if ( !d->scanDocs )
271 return; 271 return;
272 272
273 if ( d->sendDocLnks && d->serverGui ) { 273 if ( d->sendDocLnks && d->serverGui ) {
274 d->serverGui->documentScanningProgress( 0 ); 274 d->serverGui->documentScanningProgress( 0 );
275 d->serverGui->allDocumentsRemoved(); 275 d->serverGui->allDocumentsRemoved();
276 } 276 }
277 277
278 rescan(); 278 rescan();
279} 279}
280 280
281void DocumentList::reforceDocuments()
282{
283 Config cfg( "Launcher" );
284 cfg.setGroup( "DocTab" );
285 d->scanDocs = cfg.readBoolEntry( "Enable", true );
286 reloadDocLnks();
287}
288
281void DocumentList::linkChanged( QString arg ) 289void DocumentList::linkChanged( QString arg )
282{ 290{
283 //odebug << "linkchanged( " << arg << " )" << oendl; 291 odebug << "linkchanged( " << arg << " )" << oendl;
284 292
285 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { 293 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
286 reloadAppLnks(); 294 reloadAppLnks();
287 } else { 295 } else {
288 296
289 const QList<DocLnk> &list = d->dls.children(); 297 const QList<DocLnk> &list = d->dls.children();
290 QListIterator<DocLnk> it( list ); 298 QListIterator<DocLnk> it( list );
291 while ( it.current() ) { 299 while ( it.current() ) {
292 DocLnk *doc = it.current(); 300 DocLnk *doc = it.current();
293 ++it; 301 ++it;
294 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 302 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
295 || ( doc->fileKnown() && doc->file() == arg ) ) { 303 || ( doc->fileKnown() && doc->file() == arg ) ) {
296 //odebug << "found old link" << oendl; 304 //odebug << "found old link" << oendl;
297 DocLnk* dl = new DocLnk( arg ); 305 DocLnk* dl = new DocLnk( arg );
298 // add new one if it exists and matches the mimetype 306 // add new one if it exists and matches the mimetype
299 if ( d->store( dl ) ) { 307 if ( d->store( dl ) ) {
300 // Existing link has been changed, send old link ref and a ref 308 // Existing link has been changed, send old link ref and a ref
301 // to the new link 309 // to the new link
302 //odebug << "change case" << oendl; 310 //odebug << "change case" << oendl;
303 if ( d->serverGui ) 311 if ( d->serverGui )
304 d->serverGui->documentChanged( *doc, *dl ); 312 d->serverGui->documentChanged( *doc, *dl );
305 313
306 } else { 314 } else {
307 // Link has been removed or doesn't match the mimetypes any more 315 // Link has been removed or doesn't match the mimetypes any more
308 // so we aren't interested in it, so take it away from the list 316 // so we aren't interested in it, so take it away from the list
309 //odebug << "removal case" << oendl; 317 //odebug << "removal case" << oendl;
310 if ( d->serverGui ) 318 if ( d->serverGui )
311 d->serverGui->documentRemoved( *doc ); 319 d->serverGui->documentRemoved( *doc );
312 320
313 } 321 }
314 d->dls.remove( doc ); // remove old link from docLnkSet 322 d->dls.remove( doc ); // remove old link from docLnkSet
315 delete doc; 323 delete doc;
316 return; 324 return;
317 } 325 }
318 } 326 }
319 // Didn't find existing link, must be new 327 // Didn't find existing link, must be new
320 DocLnk* dl = new DocLnk( arg ); 328 DocLnk* dl = new DocLnk( arg );
321 if ( d->store( dl ) ) { 329 if ( d->store( dl ) ) {
322 // Add if it's a link we are interested in 330 // Add if it's a link we are interested in
323 //odebug << "add case" << oendl; 331 //odebug << "add case" << oendl;
324 add( *dl ); 332 add( *dl );
325 } 333 }
326 334
327 } 335 }
328} 336}
329 337
330void DocumentList::restoreDone() 338void DocumentList::restoreDone()
331{ 339{
332 reloadAppLnks(); 340 reloadAppLnks();
333 reloadDocLnks(); 341 reloadDocLnks();
334} 342}
335 343
336void DocumentList::DiffAppLnks() 344void DocumentList::DiffAppLnks()
337{ 345{
338 static AppLnkSet *appLnkSet2; 346 static AppLnkSet *appLnkSet2;
339 347
340 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); 348 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() );
341 349
342 if ( d->sendAppLnks && d->serverGui ) { 350 if ( d->sendAppLnks && d->serverGui ) {
343 static QStringList prevTypeList = appLnkSet->types(); 351 static QStringList prevTypeList = appLnkSet->types();
344 QStringList types = appLnkSet2->types(); 352 QStringList types = appLnkSet2->types();
345 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 353 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
346 if ( !(*ittypes).isEmpty() ) { 354 if ( !(*ittypes).isEmpty() ) {
347 if ( !prevTypeList.contains(*ittypes) ) { 355 if ( !prevTypeList.contains(*ittypes) ) {
348 QString name = appLnkSet2->typeName(*ittypes); 356 QString name = appLnkSet2->typeName(*ittypes);
349 QPixmap pm = appLnkSet2->typePixmap(*ittypes); 357 QPixmap pm = appLnkSet2->typePixmap(*ittypes);
350 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); 358 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes);
351 359
352 if (pm.isNull()) { 360 if (pm.isNull()) {
353 QImage img( Resource::loadImage( "UnknownDocument" ) ); 361 QImage img( Resource::loadImage( "UnknownDocument" ) );
354 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 362 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
355 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 363 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
356 } 364 }
357 365
358 odebug << "adding type " << (*ittypes) << "" << oendl; 366 odebug << "adding type " << (*ittypes) << "" << oendl;
359 367
360 // ### our current launcher expects docs tab to be last 368 // ### our current launcher expects docs tab to be last
361 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 369 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
362 } 370 }
363 prevTypeList.remove(*ittypes); 371 prevTypeList.remove(*ittypes);
364 } 372 }
365 } 373 }
366 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 374 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
367 odebug << "removing type " << (*ittypes) << "" << oendl; 375 odebug << "removing type " << (*ittypes) << "" << oendl;
368 d->serverGui->typeRemoved(*ittypes); 376 d->serverGui->typeRemoved(*ittypes);
369 } 377 }
370 prevTypeList = types; 378 prevTypeList = types;
371 } 379 }
372 380
373 381
374 QListIterator<AppLnk> it1( appLnkSet->children() ); 382 QListIterator<AppLnk> it1( appLnkSet->children() );
375 QListIterator<AppLnk> it2( appLnkSet2->children() ); 383 QListIterator<AppLnk> it2( appLnkSet2->children() );
376 384
377 AppLnk *i; 385 AppLnk *i;
378 AppLnk *j; 386 AppLnk *j;
379 bool found; 387 bool found;
380 388
381 while ( (j=it2.current()) ) { 389 while ( (j=it2.current()) ) {
382 it1 = appLnkSet->children(); 390 it1 = appLnkSet->children();
383 found = false; 391 found = false;
384 while ( (i=it1.current()) ){ 392 while ( (i=it1.current()) ){
385 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 393 if (strcmp(i->name().ascii(),j->name().ascii()) == 0)
386 found = true; 394 found = true;
387 ++it1; 395 ++it1;
388 } 396 }
389 if (!found) { 397 if (!found) {
390 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; 398 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl;
391 d->serverGui->applicationAdded( j->type(), *j ); 399 d->serverGui->applicationAdded( j->type(), *j );
392 } 400 }
393 ++it2; 401 ++it2;
394 } 402 }
395 403
396 it1 = appLnkSet->children(); 404 it1 = appLnkSet->children();
397 while ( (i=it1.current()) ) { 405 while ( (i=it1.current()) ) {
398 it2 = appLnkSet2->children(); 406 it2 = appLnkSet2->children();
399 found = false; 407 found = false;
400 while ( (j=it2.current()) ){ 408 while ( (j=it2.current()) ){
401 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 409 if (strcmp(i->name().ascii(),j->name().ascii()) == 0)
402 found = true; 410 found = true;
403 ++it2; 411 ++it2;
404 } 412 }
405 if (!found) { 413 if (!found) {
406 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; 414 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl;
407 d->serverGui->applicationRemoved( i->type(), *i ); 415 d->serverGui->applicationRemoved( i->type(), *i );
408 } 416 }
409 417
410 ++it1; 418 ++it1;
411 } 419 }
412 420
413 delete appLnkSet; 421 delete appLnkSet;
414 appLnkSet = appLnkSet2; 422 appLnkSet = appLnkSet2;
415 423
416} 424}
417void DocumentList::storageChanged() 425void DocumentList::storageChanged()
418{ 426{
419 QTime t; 427 QTime t;
420 // ### can implement better 428 // ### can implement better
421 429
422 t.start(); 430 t.start();
423 DiffAppLnks(); 431 DiffAppLnks();
424// reloadAppLnks(); 432// reloadAppLnks();
425 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; 433 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl;
426 reloadDocLnks(); 434 reloadDocLnks();
427// odebug << "Reload links took " << t.elapsed() << " ms " << oendl; 435// odebug << "Reload links took " << t.elapsed() << " ms " << oendl;
428 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; 436 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl;
429// ### Optimization opportunity 437// ### Optimization opportunity
430 // Could be a bit more intelligent and somehow work out which 438 // Could be a bit more intelligent and somehow work out which
431 // mtab entry has changed and then only scan that and add and remove 439 // mtab entry has changed and then only scan that and add and remove
432 // links appropriately. 440 // links appropriately.
433// rescan(); 441// rescan();
434} 442}
435 443
436void DocumentList::sendAllDocLinks() 444void DocumentList::sendAllDocLinks()
437{ 445{
438 if ( d->tid != 0 ) { 446 if ( d->tid != 0 ) {
439 // We are in the middle of scanning, set a flag so 447 // We are in the middle of scanning, set a flag so
440 // we do this when we finish our scanning 448 // we do this when we finish our scanning
441 d->needToSendAllDocLinks = true; 449 d->needToSendAllDocLinks = true;
442 return; 450 return;
443 } 451 }
444 452
445 QString contents; 453 QString contents;
446 Categories cats; 454 Categories cats;
447 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { 455 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) {
448 DocLnk *doc = it.current(); 456 DocLnk *doc = it.current();
449 QFileInfo fi( doc->file() ); 457 QFileInfo fi( doc->file() );
450 if ( !fi.exists() ) 458 if ( !fi.exists() )
451 continue; 459 continue;
452 460
453 bool fake = !doc->linkFileKnown(); 461 bool fake = !doc->linkFileKnown();
454 if ( !fake ) { 462 if ( !fake ) {
455 QFile f( doc->linkFile() ); 463 QFile f( doc->linkFile() );
456 if ( f.open( IO_ReadOnly ) ) { 464 if ( f.open( IO_ReadOnly ) ) {
457 QTextStream ts( &f ); 465 QTextStream ts( &f );
458 ts.setEncoding( QTextStream::UnicodeUTF8 ); 466 ts.setEncoding( QTextStream::UnicodeUTF8 );
459 QString docLnk = ts.read(); 467 QString docLnk = ts.read();
460 // Strip out the (stale) LinkFile entry 468 // Strip out the (stale) LinkFile entry
461 int start = docLnk.find( "\nLinkFile = " ) + 1; 469 int start = docLnk.find( "\nLinkFile = " ) + 1;
462 if ( start > 0 ) { 470 if ( start > 0 ) {
463 int end = docLnk.find( "\n", start + 1 ) + 1; 471 int end = docLnk.find( "\n", start + 1 ) + 1;
464 contents += docLnk.left(start); 472 contents += docLnk.left(start);
465 contents += docLnk.mid(end); 473 contents += docLnk.mid(end);
466 } else { 474 } else {
467 contents += docLnk; 475 contents += docLnk;
468 } 476 }
469 contents += "LinkFile = " + doc->linkFile() + "\n"; 477 contents += "LinkFile = " + doc->linkFile() + "\n";
470 478
471 f.close(); 479 f.close();
472 } else 480 } else
473 fake = TRUE; 481 fake = TRUE;
474 } 482 }
475 if (fake) { 483 if (fake) {
476 contents += "[Desktop Entry]\n"; // No tr 484 contents += "[Desktop Entry]\n"; // No tr
477 contents += "Categories = " + // No tr 485 contents += "Categories = " + // No tr
478 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 486 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
479 contents += "Name = "+doc->name()+"\n"; // No tr 487 contents += "Name = "+doc->name()+"\n"; // No tr
480 contents += "Type = "+doc->type()+"\n"; // No tr 488 contents += "Type = "+doc->type()+"\n"; // No tr
481 } 489 }
482 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 490 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
483 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 491 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
484 } 492 }
485 493
486 //odebug << "sending length " << contents.length() << "" << oendl; 494 //odebug << "sending length " << contents.length() << "" << oendl;
487#ifndef QT_NO_COP 495#ifndef QT_NO_COP
488 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 496 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
489 e << contents; 497 e << contents;
490#endif 498#endif
491 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; 499 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;
492 500
493 d->needToSendAllDocLinks = false; 501 d->needToSendAllDocLinks = false;
494} 502}
495 503
496 504
497 505
498 506
499 507
500 508
501 509
502 510
503 511
504 512
505 513
506 514
507 515
508 516
509 517
510 518
511 519
512 520
513 521
514 522
515 523
516 524
517 525
518 526
519DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) 527DocumentListPrivate::DocumentListPrivate( ServerInterface *gui )
520{ 528{
521 storage = new StorageInfo( this ); 529 storage = new StorageInfo( this );
522 serverGui = gui; 530 serverGui = gui;
523 if ( serverGui ) { 531 if ( serverGui ) {
524 sendAppLnks = serverGui->requiresApplications(); 532 sendAppLnks = serverGui->requiresApplications();
525 sendDocLnks = serverGui->requiresDocuments(); 533 sendDocLnks = serverGui->requiresDocuments();
526 } else { 534 } else {
527 sendAppLnks = false; 535 sendAppLnks = false;
528 sendDocLnks = false; 536 sendDocLnks = false;
529 } 537 }
530 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { 538 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) {
531 listDirs[i] = 0; 539 listDirs[i] = 0;
532 lists[i] = 0; 540 lists[i] = 0;
533 listPositions[i] = 0; 541 listPositions[i] = 0;
534 } 542 }
535 initialize(); 543 initialize();
536 tid = 0; 544 tid = 0;
537} 545}
538 546
539void DocumentListPrivate::appendDocpath(FileSystem*fs) 547void DocumentListPrivate::appendDocpath(FileSystem*fs)
540{ 548{
541 QDir defPath(fs->path()+"/Documents"); 549 QDir defPath(fs->path()+"/Documents");
542 QFileInfo f(fs->path()+"/.opiestorage.cf"); 550 QFileInfo f(fs->path()+"/.opiestorage.cf");
543 if (!f.exists()) { 551 if (!f.exists()) {
544 Mediadlg dlg(fs); 552 Mediadlg dlg(fs);
545 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { 553 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) {
546 return; 554 return;
547 } 555 }
548 } 556 }
549 Config conf(f.filePath(), Config::File ); 557 Config conf(f.filePath(), Config::File );
550 conf.setGroup("main"); 558 conf.setGroup("main");
551 if (!conf.readBoolEntry("check",false)) { 559 if (!conf.readBoolEntry("check",false)) {
552 return; 560 return;
553 } 561 }
554 conf.setGroup("subdirs"); 562 conf.setGroup("subdirs");
555 bool read_all = conf.readBoolEntry("wholemedia",true); 563 bool read_all = conf.readBoolEntry("wholemedia",true);
556 if (read_all) { 564 if (read_all) {
557 docPaths+=fs->path(); 565 docPaths+=fs->path();
558 return; 566 return;
559 } 567 }
560 QStringList subDirs = conf.readListEntry("subdirs",':'); 568 QStringList subDirs = conf.readListEntry("subdirs",':');
561 if (subDirs.isEmpty()) { 569 if (subDirs.isEmpty()) {
562 if (defPath.exists()) { 570 if (defPath.exists()) {
563 docPaths+=defPath.path(); 571 docPaths+=defPath.path();
564 } 572 }
565 return; 573 return;
566 } 574 }
567 for (unsigned c = 0; c < subDirs.count();++c) { 575 for (unsigned c = 0; c < subDirs.count();++c) {
568 QDir docDir(QString(fs->path()+"/"+subDirs[c])); 576 QDir docDir(QString(fs->path()+"/"+subDirs[c]));
569 if (docDir.exists()) { 577 if (docDir.exists()) {
570 docPaths+=docDir.path(); 578 docPaths+=docDir.path();
571 } 579 }
572 } 580 }
573} 581}
574 582
575void DocumentListPrivate::initialize() 583void DocumentListPrivate::initialize()
576{ 584{
577 // Reset 585 // Reset
578 dls.clear(); 586 dls.clear();
579 docPaths.clear(); 587 docPaths.clear();
580 reference.clear(); 588 reference.clear();
581 589
582 QDir docDir( QPEApplication::documentDir() ); 590 QDir docDir( QPEApplication::documentDir() );
583 if ( docDir.exists() ) 591 if ( docDir.exists() )
584 docPaths += QPEApplication::documentDir(); 592 docPaths += QPEApplication::documentDir();
585 int i = 1; 593 int i = 1;
586 const QList<FileSystem> &fs = storage->fileSystems(); 594 const QList<FileSystem> &fs = storage->fileSystems();
587 QListIterator<FileSystem> it( fs ); 595 QListIterator<FileSystem> it( fs );
588 for ( ; it.current(); ++it ) { 596 for ( ; it.current(); ++it ) {
589 if ( (*it)->isRemovable() ) { 597 if ( (*it)->isRemovable() ) {
590 appendDocpath((*it)); 598 appendDocpath((*it));
591 ++i; 599 ++i;
592 } 600 }
593 } 601 }
594 602
595 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { 603 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) {
596 if ( listDirs[i] ) { 604 if ( listDirs[i] ) {
597 delete listDirs[i]; 605 delete listDirs[i];
598 listDirs[i] = 0; 606 listDirs[i] = 0;
599 } 607 }
600 lists[i] = 0; 608 lists[i] = 0;
601 listPositions[i] = 0; 609 listPositions[i] = 0;
602 } 610 }
603 611
604 docPathsSearched = 0; 612 docPathsSearched = 0;
605 searchDepth = -1; 613 searchDepth = -1;
606 state = Find; 614 state = Find;
607 dit = 0; 615 dit = 0;
608} 616}
609 617
610 618
611DocumentListPrivate::~DocumentListPrivate() 619DocumentListPrivate::~DocumentListPrivate()
612{ 620{
613 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) 621 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ )
614 if ( listDirs[i] ) 622 if ( listDirs[i] )
615 delete listDirs[i]; 623 delete listDirs[i];
616 delete dit; 624 delete dit;
617} 625}
618 626
619 627
620void DocumentListPrivate::estimatedPercentScanned() 628void DocumentListPrivate::estimatedPercentScanned()
621{ 629{
622 double overallProgress = 0.0; 630 double overallProgress = 0.0;
623 double levelWeight = 75.0; 631 double levelWeight = 75.0;
624 632
625 int topCount = docPaths.count(); 633 int topCount = docPaths.count();
626 if ( topCount > 1 ) { 634 if ( topCount > 1 ) {
627 levelWeight = levelWeight / topCount; 635 levelWeight = levelWeight / topCount;
628 overallProgress += (docPathsSearched - 1) * levelWeight; 636 overallProgress += (docPathsSearched - 1) * levelWeight;
629 } 637 }
630 638
631 for ( int d = 0; d <= searchDepth; d++ ) { 639 for ( int d = 0; d <= searchDepth; d++ ) {
632 if ( listDirs[d] ) { 640 if ( listDirs[d] ) {
633 int items = lists[d]->count(); 641 int items = lists[d]->count();
634 if ( items > 1 ) { 642 if ( items > 1 ) {
635 levelWeight = levelWeight / items; 643 levelWeight = levelWeight / items;
636 // Take in to account "." and ".." 644 // Take in to account "." and ".."
637 overallProgress += (listPositions[d] - 3) * levelWeight; 645 overallProgress += (listPositions[d] - 3) * levelWeight;
638 } 646 }
639 } else { 647 } else {
640 break; 648 break;
641 } 649 }
642 } 650 }
643 651
644 // odebug << "overallProgress: " << overallProgress << "" << oendl; 652 // odebug << "overallProgress: " << overallProgress << "" << oendl;
645 653
646 if ( serverGui ) 654 if ( serverGui )
647 serverGui->documentScanningProgress( (int)overallProgress ); 655 serverGui->documentScanningProgress( (int)overallProgress );
648} 656}
649 657
650 658
651const QString DocumentListPrivate::nextFile() 659const QString DocumentListPrivate::nextFile()
652{ 660{
653 while ( TRUE ) { 661 while ( TRUE ) {
654 while ( searchDepth < 0 ) { 662 while ( searchDepth < 0 ) {
655 // go to next base path 663 // go to next base path
656 if ( docPathsSearched >= docPaths.count() ) { 664 if ( docPathsSearched >= docPaths.count() ) {
657 // end of base paths 665 // end of base paths
658 return QString::null; 666 return QString::null;
659 } else { 667 } else {
660 QDir dir( docPaths[docPathsSearched] ); 668 QDir dir( docPaths[docPathsSearched] );
661 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl; 669 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl;
662 docPathsSearched++; 670 docPathsSearched++;
663 if ( !dir.exists( ".Qtopia-ignore" ) ) { 671 if ( !dir.exists( ".Qtopia-ignore" ) ) {
664 listDirs[0] = new QDir( dir ); 672 listDirs[0] = new QDir( dir );
665 lists[0] = listDirs[0]->entryInfoList(); 673 lists[0] = listDirs[0]->entryInfoList();
666 listPositions[0] = 0; 674 listPositions[0] = 0;
667 searchDepth = 0; 675 searchDepth = 0;
668 } 676 }
669 } 677 }
670 } 678 }
671 679
672 const QFileInfoList *fil = lists[searchDepth]; 680 const QFileInfoList *fil = lists[searchDepth];
673 if (!fil) { 681 if (!fil) {
674 return QString::null; 682 return QString::null;
675 } 683 }
676 QFileInfoList *fl = (QFileInfoList *)fil; 684 QFileInfoList *fl = (QFileInfoList *)fil;
677 unsigned int pos = listPositions[searchDepth]; 685 unsigned int pos = listPositions[searchDepth];
678 686
679 if ( pos >= fl->count() ) { 687 if ( pos >= fl->count() ) {
680 // go up a depth 688 // go up a depth
681 delete listDirs[searchDepth]; 689 delete listDirs[searchDepth];
682 listDirs[searchDepth] = 0; 690 listDirs[searchDepth] = 0;
683 lists[searchDepth] = 0; 691 lists[searchDepth] = 0;
684 listPositions[searchDepth] = 0; 692 listPositions[searchDepth] = 0;
685 searchDepth--; 693 searchDepth--;
686 } else { 694 } else {
687 const QFileInfo *fi = fl->at(pos); 695 const QFileInfo *fi = fl->at(pos);
688 listPositions[searchDepth]++; 696 listPositions[searchDepth]++;
689 QString bn = fi->fileName(); 697 QString bn = fi->fileName();
690 if ( bn[0] != '.' ) { 698 if ( bn[0] != '.' ) {
691 if ( fi->isDir() ) { 699 if ( fi->isDir() ) {
692 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { 700 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) {
693 // go down a depth 701 // go down a depth
694 QDir dir( fi->filePath() ); 702 QDir dir( fi->filePath() );
695 // odebug << "now going in to path: " << bn << "" << oendl; 703 // odebug << "now going in to path: " << bn << "" << oendl;
696 if ( !dir.exists( ".Qtopia-ignore" ) ) { 704 if ( !dir.exists( ".Qtopia-ignore" ) ) {
697 if ( searchDepth < MAX_SEARCH_DEPTH - 1) { 705 if ( searchDepth < MAX_SEARCH_DEPTH - 1) {
698 searchDepth++; 706 searchDepth++;
699 listDirs[searchDepth] = new QDir( dir ); 707 listDirs[searchDepth] = new QDir( dir );
700 lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); 708 lists[searchDepth] = listDirs[searchDepth]->entryInfoList();
701 listPositions[searchDepth] = 0; 709 listPositions[searchDepth] = 0;
702 } 710 }
703 } 711 }
704 } 712 }
705 } else { 713 } else {
706 estimatedPercentScanned(); 714 estimatedPercentScanned();
707 return fl->at(pos)->filePath(); 715 return fl->at(pos)->filePath();
708 } 716 }
709 } 717 }
710 } 718 }
711 } 719 }
712 720
713 return QString::null; 721 return QString::null;
714} 722}
715 723
716 724
717bool DocumentListPrivate::store( DocLnk* dl ) 725bool DocumentListPrivate::store( DocLnk* dl )
718{ 726{
719 // if ( dl->fileKnown() && !dl->file().isEmpty() ) { 727 // if ( dl->fileKnown() && !dl->file().isEmpty() ) {
720 if ( dl && dl->fileKnown() ) { 728 if ( dl && dl->fileKnown() ) {
721 dls.add( dl ); // store 729 dls.add( dl ); // store
722 return TRUE; 730 return TRUE;
723 } 731 }
724 732
725 // don't store - delete 733 // don't store - delete
726 delete dl; 734 delete dl;
727 return FALSE; 735 return FALSE;
728} 736}
729 737
730 738
731 #define MAGIC_NUMBER((void*)2) 739#define MAGIC_NUMBER ((void*)2)
732 740
733const DocLnk *DocumentListPrivate::iterate() 741const DocLnk *DocumentListPrivate::iterate()
734{ 742{
735 if ( state == Find ) { 743 if ( state == Find ) {
736 //odebug << "state Find" << oendl; 744 //odebug << "state Find" << oendl;
737 QString file = nextFile(); 745 QString file = nextFile();
738 while ( !file.isNull() ) { 746 while ( !file.isNull() ) {
739 if ( file.right(8) == ".desktop" ) { // No tr 747 if ( file.right(8) == ".desktop" ) { // No tr
740 DocLnk* dl = new DocLnk( file ); 748 DocLnk* dl = new DocLnk( file );
741 if ( store(dl) ) 749 if ( store(dl) )
742 return dl; 750 return dl;
743 } else { 751 } else {
744 reference.insert( file, MAGIC_NUMBER ); 752 reference.insert( file, MAGIC_NUMBER );
745 } 753 }
746 file = nextFile(); 754 file = nextFile();
747 } 755 }
748 state = RemoveKnownFiles; 756 state = RemoveKnownFiles;
749 757
750 if ( serverGui ) 758 if ( serverGui )
751 serverGui->documentScanningProgress( 75 ); 759 serverGui->documentScanningProgress( 75 );
752 } 760 }
753 761
754 static int iterationI; 762 static int iterationI;
755 static int iterationCount; 763 static int iterationCount;
756 764
757 if ( state == RemoveKnownFiles ) { 765 if ( state == RemoveKnownFiles ) {
758 //odebug << "state RemoveKnownFiles" << oendl; 766 //odebug << "state RemoveKnownFiles" << oendl;
759 const QList<DocLnk> &list = dls.children(); 767 const QList<DocLnk> &list = dls.children();
760 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { 768 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) {
761 reference.remove( (*it)->file() ); 769 reference.remove( (*it)->file() );
762 // ### does this need to be deleted? 770 // ### does this need to be deleted?
763 } 771 }
764 dit = new QDictIterator<void>(reference); 772 dit = new QDictIterator<void>(reference);
765 state = MakeUnknownFiles; 773 state = MakeUnknownFiles;
766 774
767 iterationI = 0; 775 iterationI = 0;
768 iterationCount = dit->count(); 776 iterationCount = dit->count();
769 } 777 }
770 778
771 if ( state == MakeUnknownFiles ) { 779 if ( state == MakeUnknownFiles ) {
772 //odebug << "state MakeUnknownFiles" << oendl; 780 //odebug << "state MakeUnknownFiles" << oendl;
773 for (void* c; (c=dit->current()); ++(*dit) ) { 781 for (void* c; (c=dit->current()); ++(*dit) ) {
774 if ( c == MAGIC_NUMBER ) { 782 if ( c == MAGIC_NUMBER ) {
775 DocLnk* dl = new DocLnk; 783 DocLnk* dl = new DocLnk;
776 QFileInfo fi( dit->currentKey() ); 784 QFileInfo fi( dit->currentKey() );
777 dl->setFile( fi.filePath() ); 785 dl->setFile( fi.filePath() );
778 dl->setName( fi.baseName() ); 786 dl->setName( fi.baseName() );
779 if ( store(dl) ) { 787 if ( store(dl) ) {
780 ++*dit; 788 ++*dit;
781 iterationI++; 789 iterationI++;
782 if ( serverGui ) 790 if ( serverGui )
783 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); 791 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount );
784 return dl; 792 return dl;
785 } 793 }
786 } 794 }
787 iterationI++; 795 iterationI++;
788 } 796 }
789 797
790 delete dit; 798 delete dit;
791 dit = 0; 799 dit = 0;
792 state = Done; 800 state = Done;
793 } 801 }
794 802
795 //odebug << "state Done" << oendl; 803 //odebug << "state Done" << oendl;
796 return NULL; 804 return NULL;
797} 805}
798 806
799 807
800#include "documentlist.moc" 808#include "documentlist.moc"
801 809
802 810
803 811
diff --git a/core/launcher/documentlist.h b/core/launcher/documentlist.h
index 232bb6a..8b69e95 100644
--- a/core/launcher/documentlist.h
+++ b/core/launcher/documentlist.h
@@ -1,78 +1,79 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef DOCUMENT_LIST_H 20#ifndef DOCUMENT_LIST_H
21#define DOCUMENT_LIST_H 21#define DOCUMENT_LIST_H
22 22
23 23
24#include <qobject.h> 24#include <qobject.h>
25#include <qtopia/applnk.h> 25#include <qtopia/applnk.h>
26 26
27 27
28class DocumentListPrivate; 28class DocumentListPrivate;
29class ServerInterface; 29class ServerInterface;
30 30
31class DocumentList : public QObject { 31class DocumentList : public QObject {
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 DocumentList( ServerInterface *serverGui, bool scanDocs = TRUE, 34 DocumentList( ServerInterface *serverGui, bool scanDocs = TRUE,
35 QObject *parent = 0, const char *name = 0 ); 35 QObject *parent = 0, const char *name = 0 );
36 ~DocumentList(); 36 ~DocumentList();
37 37
38 void linkChanged( QString link ); 38 void linkChanged( QString link );
39 void restoreDone(); 39 void restoreDone();
40 void storageChanged(); 40 void storageChanged();
41 void sendAllDocLinks(); 41 void sendAllDocLinks();
42 42
43 void reloadAppLnks(); 43 void reloadAppLnks();
44 void reloadDocLnks(); 44 void reloadDocLnks();
45 void reforceDocuments();
45 void DiffAppLnks(); 46 void DiffAppLnks();
46 47
47// Orig DocList stuff 48// Orig DocList stuff
48 void start(); 49 void start();
49 void pause(); 50 void pause();
50 void resume(); 51 void resume();
51 void rescan(); 52 void rescan();
52 53
53 static AppLnkSet *appLnkSet; 54 static AppLnkSet *appLnkSet;
54 55
55/* 56/*
56 void resend(); 57 void resend();
57signals: 58signals:
58 void added( const DocLnk& doc ); 59 void added( const DocLnk& doc );
59 void removed( const DocLnk& doc ); 60 void removed( const DocLnk& doc );
60 void changed( const DocLnk& oldDoc, const DocLnk& newDoc ); 61 void changed( const DocLnk& oldDoc, const DocLnk& newDoc );
61 void allRemoved(); 62 void allRemoved();
62 void doneForNow(); 63 void doneForNow();
63private slots: 64private slots:
64 void resendWorker(); 65 void resendWorker();
65*/ 66*/
66private slots: 67private slots:
67 void startInitialScan(); 68 void startInitialScan();
68protected: 69protected:
69 void timerEvent( QTimerEvent *te ); 70 void timerEvent( QTimerEvent *te );
70private: 71private:
71 void add( const DocLnk& doc ); 72 void add( const DocLnk& doc );
72 DocumentListPrivate *d; 73 DocumentListPrivate *d;
73 74
74}; 75};
75 76
76 77
77#endif 78#endif
78 79
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index ccc2114..970b8cb 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -7,784 +7,805 @@
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "startmenu.h" 21#include "startmenu.h"
22#include "taskbar.h" 22#include "taskbar.h"
23#include "serverinterface.h" 23#include "serverinterface.h"
24#include "launcherview.h" 24#include "launcherview.h"
25#include "launcher.h" 25#include "launcher.h"
26#include "server.h" 26#include "server.h"
27 27
28/* OPIE */ 28/* OPIE */
29#include <opie2/odebug.h> 29#include <opie2/odebug.h>
30#include <qtopia/global.h> 30#include <qtopia/global.h>
31#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
32#include <qtopia/qcopenvelope_qws.h> 32#include <qtopia/qcopenvelope_qws.h>
33#endif 33#endif
34#include <qtopia/resource.h> 34#include <qtopia/resource.h>
35#include <qtopia/applnk.h> 35#include <qtopia/applnk.h>
36#include <qtopia/config.h> 36#include <qtopia/config.h>
37#include <qtopia/qpeapplication.h> 37#include <qtopia/qpeapplication.h>
38#include <qtopia/mimetype.h> 38#include <qtopia/mimetype.h>
39#include <qtopia/private/categories.h> 39#include <qtopia/private/categories.h>
40#define QTOPIA_INTERNAL_FSLP 40#define QTOPIA_INTERNAL_FSLP
41#include <qtopia/lnkproperties.h> 41#include <qtopia/lnkproperties.h>
42 42
43/* QT */ 43/* QT */
44#include <qdir.h> 44#include <qdir.h>
45#ifdef Q_WS_QWS 45#ifdef Q_WS_QWS
46#include <qkeyboard_qws.h> 46#include <qkeyboard_qws.h>
47#include <qwindowsystem_qws.h> 47#include <qwindowsystem_qws.h>
48#endif 48#endif
49#include <qtimer.h> 49#include <qtimer.h>
50#include <qcombobox.h> 50#include <qcombobox.h>
51#include <qvbox.h> 51#include <qvbox.h>
52#include <qlayout.h> 52#include <qlayout.h>
53#include <qstyle.h> 53#include <qstyle.h>
54#include <qpushbutton.h> 54#include <qpushbutton.h>
55#include <qtabbar.h> 55#include <qtabbar.h>
56#include <qwidgetstack.h> 56#include <qwidgetstack.h>
57#include <qregexp.h> 57#include <qregexp.h>
58#include <qmessagebox.h> 58#include <qmessagebox.h>
59#include <qframe.h> 59#include <qframe.h>
60#include <qpainter.h> 60#include <qpainter.h>
61#include <qlabel.h> 61#include <qlabel.h>
62#include <qtextstream.h> 62#include <qtextstream.h>
63#include <qpopupmenu.h> 63#include <qpopupmenu.h>
64 64
65/* STD */ 65/* STD */
66#include <stdlib.h> 66#include <stdlib.h>
67#include <assert.h> 67#include <assert.h>
68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
69#include <unistd.h> 69#include <unistd.h>
70#include <stdio.h> 70#include <stdio.h>
71#include <sys/vfs.h> 71#include <sys/vfs.h>
72#include <mntent.h> 72#include <mntent.h>
73#endif 73#endif
74 74
75 75
76static bool isVisibleWindow( int ); 76static bool isVisibleWindow( int );
77//=========================================================================== 77//===========================================================================
78 78
79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : 79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
80 QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0) 80 QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0)
81{ 81{
82 docLoadingWidgetEnabled = false; 82 docLoadingWidgetEnabled = false;
83 docLoadingWidget = 0; 83 docLoadingWidget = 0;
84 docLoadingWidgetProgress = 0; 84 docLoadingWidgetProgress = 0;
85 launcher = parent; 85 launcher = parent;
86 categoryBar = new LauncherTabBar( this ); 86 categoryBar = new LauncherTabBar( this );
87 QPalette pal = categoryBar->palette(); 87 QPalette pal = categoryBar->palette();
88 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 88 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
89 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 89 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
90 categoryBar->setPalette( pal ); 90 categoryBar->setPalette( pal );
91 stack = new QWidgetStack(this); 91 stack = new QWidgetStack(this);
92 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); 92 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
93 categoryBar->show(); 93 categoryBar->show();
94 stack->show(); 94 stack->show();
95 95
96#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 96#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
97 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 97 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); 99 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) );
100 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 100 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
101 this, SLOT(appMessage(const QCString&,const QByteArray&))); 101 this, SLOT(appMessage(const QCString&,const QByteArray&)));
102#endif 102#endif
103 103
104 createDocLoadingWidget(); 104 createDocLoadingWidget();
105} 105}
106 106
107void LauncherTabWidget::createDocLoadingWidget() 107void LauncherTabWidget::createDocLoadingWidget()
108{ 108{
109 // Construct the 'doc loading widget' shown when finding documents 109 // Construct the 'doc loading widget' shown when finding documents
110 110
111 // ### LauncherView class needs changing to be more generic so 111 // ### LauncherView class needs changing to be more generic so
112 // this widget can change its background similar to the iconviews 112 // this widget can change its background similar to the iconviews
113 // so the background for this matches 113 // so the background for this matches
114 docLoadingWidget = new LauncherView( stack ); 114 docLoadingWidget = new LauncherView( stack );
115 docLoadingWidget->hideIcons(); 115 docLoadingWidget->hideIcons();
116 QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); 116 QVBox *docLoadingVBox = new QVBox( docLoadingWidget );
117 117
118 docLoadingVBox->setSpacing( 20 ); 118 docLoadingVBox->setSpacing( 20 );
119 docLoadingVBox->setMargin( 10 ); 119 docLoadingVBox->setMargin( 10 );
120 120
121 QWidget *space1 = new QWidget( docLoadingVBox ); 121 QWidget *space1 = new QWidget( docLoadingVBox );
122 docLoadingVBox->setStretchFactor( space1, 1 ); 122 docLoadingVBox->setStretchFactor( space1, 1 );
123 123
124 QLabel *waitPixmap = new QLabel( docLoadingVBox ); 124 QLabel *waitPixmap = new QLabel( docLoadingVBox );
125 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); 125 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) );
126 waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); 126 waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) );
127 waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); 127 waitPixmap->setAlignment( int( QLabel::AlignCenter ) );
128 128
129 Config cfg( "Launcher" ); 129 Config cfg( "Launcher" );
130 cfg.setGroup( "DocTab" ); 130 cfg.setGroup( "DocTab" );
131 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 131 docTabEnabled = cfg.readBoolEntry( "Enable", true );
132 132
133 QLabel *textLabel = new QLabel( docLoadingVBox ); 133 QLabel *textLabel = new QLabel( docLoadingVBox );
134 textLabel->setAlignment( int( QLabel::AlignCenter ) ); 134 textLabel->setAlignment( int( QLabel::AlignCenter ) );
135 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); 135 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
136 docLoadingWidgetProgress->setProgress( 0 ); 136 docLoadingWidgetProgress->setProgress( 0 );
137 docLoadingWidgetProgress->setCenterIndicator( TRUE ); 137 docLoadingWidgetProgress->setCenterIndicator( TRUE );
138 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker 138 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker
139 setProgressStyle(); 139 setProgressStyle();
140 140
141 if ( docTabEnabled ) 141 if ( docTabEnabled )
142 { 142 {
143 textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); 143 textLabel->setText( tr( "<b>Finding Documents...</b>" ) );
144 } 144 }
145 else 145 else
146 { 146 {
147 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" 147 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>"
148 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); 148 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) );
149 docLoadingWidgetProgress->hide(); 149 docLoadingWidgetProgress->hide();
150 docLoadingWidgetEnabled = true; 150 docLoadingWidgetEnabled = true;
151 } 151 }
152 152
153 QWidget *space2 = new QWidget( docLoadingVBox ); 153 QWidget *space2 = new QWidget( docLoadingVBox );
154 docLoadingVBox->setStretchFactor( space2, 1 ); 154 docLoadingVBox->setStretchFactor( space2, 1 );
155 155
156 cfg.setGroup( "Tab Documents" ); // No tr 156 cfg.setGroup( "Tab Documents" ); // No tr
157 setTabViewAppearance( docLoadingWidget, cfg ); 157 setTabViewAppearance( docLoadingWidget, cfg );
158 158
159 stack->addWidget( docLoadingWidget, 0 ); 159 stack->addWidget( docLoadingWidget, 0 );
160} 160}
161 161
162void LauncherTabWidget::initLayout() 162void LauncherTabWidget::initLayout()
163{ 163{
164 layout()->activate(); 164 layout()->activate();
165 docView()->setFocus(); 165 docView()->setFocus();
166 categoryBar->showTab("Documents"); 166 categoryBar->showTab("Documents");
167} 167}
168 168
169void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) 169void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
170{ 170{
171 if ( message == "nextView()" ) 171 if ( message == "nextView()" )
172 categoryBar->nextTab(); 172 categoryBar->nextTab();
173} 173}
174 174
175void LauncherTabWidget::raiseTabWidget() 175void LauncherTabWidget::raiseTabWidget()
176{ 176{
177 if ( categoryBar->currentView() == docView() 177 if ( categoryBar->currentView() == docView()
178 && docLoadingWidgetEnabled ) { 178 && docLoadingWidgetEnabled ) {
179 stack->raiseWidget( docLoadingWidget ); 179 stack->raiseWidget( docLoadingWidget );
180 docLoadingWidget->updateGeometry(); 180 docLoadingWidget->updateGeometry();
181 } else { 181 } else {
182 stack->raiseWidget( categoryBar->currentView() ); 182 stack->raiseWidget( categoryBar->currentView() );
183 } 183 }
184} 184}
185 185
186void LauncherTabWidget::tabProperties() 186void LauncherTabWidget::tabProperties()
187{ 187{
188 LauncherView *view = categoryBar->currentView(); 188 LauncherView *view = categoryBar->currentView();
189 QPopupMenu *m = new QPopupMenu( this ); 189 QPopupMenu *m = new QPopupMenu( this );
190 m->insertItem( tr("Icon View"), LauncherView::Icon ); 190 m->insertItem( tr("Icon View"), LauncherView::Icon );
191 m->insertItem( tr("List View"), LauncherView::List ); 191 m->insertItem( tr("List View"), LauncherView::List );
192 m->setItemChecked( (int)view->viewMode(), TRUE ); 192 m->setItemChecked( (int)view->viewMode(), TRUE );
193 int rv = m->exec( QCursor::pos() ); 193 int rv = m->exec( QCursor::pos() );
194 if ( rv >= 0 && rv != view->viewMode() ) { 194 if ( rv >= 0 && rv != view->viewMode() ) {
195 view->setViewMode( (LauncherView::ViewMode)rv ); 195 view->setViewMode( (LauncherView::ViewMode)rv );
196 } 196 }
197 197
198 delete m; 198 delete m;
199} 199}
200 200
201void LauncherTabWidget::deleteView( const QString& id ) 201void LauncherTabWidget::deleteView( const QString& id )
202{ 202{
203 LauncherTab *t = categoryBar->launcherTab(id); 203 LauncherTab *t = categoryBar->launcherTab(id);
204 if ( t ) { 204 if ( t ) {
205 stack->removeWidget( t->view ); 205 stack->removeWidget( t->view );
206 delete t->view; 206 delete t->view;
207 categoryBar->removeTab( t ); 207 categoryBar->removeTab( t );
208 } 208 }
209} 209}
210 210
211LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 211LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
212{ 212{
213 LauncherView* view = new LauncherView( stack ); 213 LauncherView* view = new LauncherView( stack );
214 connect( view, SIGNAL(clicked(const AppLnk*)), 214 connect( view, SIGNAL(clicked(const AppLnk*)),
215 this, SIGNAL(clicked(const AppLnk*))); 215 this, SIGNAL(clicked(const AppLnk*)));
216 connect( view, SIGNAL(rightPressed(AppLnk*)), 216 connect( view, SIGNAL(rightPressed(AppLnk*)),
217 this, SIGNAL(rightPressed(AppLnk*))); 217 this, SIGNAL(rightPressed(AppLnk*)));
218 218
219 219
220 int n = categoryBar->count(); 220 int n = categoryBar->count();
221 221
222 stack->addWidget( view, n ); 222 stack->addWidget( view, n );
223 223
224 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 224 LauncherTab *tab = new LauncherTab( id, view, pm, label );
225 categoryBar->insertTab( tab, n-1 ); 225 categoryBar->insertTab( tab, n-1 );
226 if ( id == "Documents" ) { 226 if ( id == "Documents" ) {
227 docview = view; 227 docview = view;
228 m_DocumentTabId = n; 228 m_DocumentTabId = n;
229 } 229 }
230 230
231 odebug << "inserting " << id << " at " << n-1 << "" << oendl; 231 odebug << "inserting " << id << " at " << n-1 << "" << oendl;
232 232
233 Config cfg("Launcher"); 233 Config cfg("Launcher");
234 setTabAppearance( tab, cfg ); 234 setTabAppearance( tab, cfg );
235 235
236 cfg.setGroup( "GUI" ); 236 cfg.setGroup( "GUI" );
237 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 237 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
238 238
239 return view; 239 return view;
240} 240}
241 241
242LauncherView *LauncherTabWidget::view( const QString &id ) 242LauncherView *LauncherTabWidget::view( const QString &id )
243{ 243{
244 LauncherTab *t = categoryBar->launcherTab(id); 244 LauncherTab *t = categoryBar->launcherTab(id);
245 if ( !t ) 245 if ( !t )
246 return 0; 246 return 0;
247 return t->view; 247 return t->view;
248} 248}
249 249
250LauncherView *LauncherTabWidget::docView() 250LauncherView *LauncherTabWidget::docView()
251{ 251{
252 return docview; 252 return docview;
253} 253}
254 254
255void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 255void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
256{ 256{
257 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { 257 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
258 docLoadingWidgetEnabled = v; 258 docLoadingWidgetEnabled = v;
259 raiseTabWidget(); 259 raiseTabWidget();
260 } 260 }
261} 261}
262 262
263void LauncherTabWidget::setLoadingProgress( int percent ) 263void LauncherTabWidget::setLoadingProgress( int percent )
264{ 264{
265 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); 265 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
266} 266}
267 267
268// ### this function could more to LauncherView 268// ### this function could more to LauncherView
269void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) 269void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
270{ 270{
271 // View 271 // View
272 QString view = cfg.readEntry( "View", "Icon" ); 272 QString view = cfg.readEntry( "View", "Icon" );
273 if ( view == "List" ) // No tr 273 if ( view == "List" ) // No tr
274 v->setViewMode( LauncherView::List ); 274 v->setViewMode( LauncherView::List );
275 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 275 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
276 if ( bgType == "Image" ) { // No tr 276 if ( bgType == "Image" ) { // No tr
277 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 277 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
278 v->setBackgroundType( LauncherView::Image, pm ); 278 v->setBackgroundType( LauncherView::Image, pm );
279 } else if ( bgType == "SolidColor" ) { 279 } else if ( bgType == "SolidColor" ) {
280 QString c = cfg.readEntry( "BackgroundColor" ); 280 QString c = cfg.readEntry( "BackgroundColor" );
281 v->setBackgroundType( LauncherView::SolidColor, c ); 281 v->setBackgroundType( LauncherView::SolidColor, c );
282 } else { 282 } else {
283 v->setBackgroundType( LauncherView::Ruled, QString::null ); 283 v->setBackgroundType( LauncherView::Ruled, QString::null );
284 } 284 }
285 QString textCol = cfg.readEntry( "TextColor" ); 285 QString textCol = cfg.readEntry( "TextColor" );
286 if ( textCol.isEmpty() ) 286 if ( textCol.isEmpty() )
287 v->setTextColor( QColor() ); 287 v->setTextColor( QColor() );
288 else 288 else
289 v->setTextColor( QColor(textCol) ); 289 v->setTextColor( QColor(textCol) );
290// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); 290// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE );
291 291
292 292
293 QStringList font = cfg.readListEntry( "Font", ',' ); 293 QStringList font = cfg.readListEntry( "Font", ',' );
294 if ( font.count() == 4 ) 294 if ( font.count() == 4 )
295 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 295 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
296 296
297 // ### FIXME TabColor TabTextColor 297 // ### FIXME TabColor TabTextColor
298 298
299} 299}
300 300
301// ### Could move to LauncherTab 301// ### Could move to LauncherTab
302void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) 302void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
303{ 303{
304 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr 304 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr
305 305
306 setTabViewAppearance( tab->view, cfg ); 306 setTabViewAppearance( tab->view, cfg );
307 307
308 // Tabs 308 // Tabs
309 QString tabCol = cfg.readEntry( "TabColor" ); 309 QString tabCol = cfg.readEntry( "TabColor" );
310 if ( tabCol.isEmpty() ) 310 if ( tabCol.isEmpty() )
311 tab->bgColor = QColor(); 311 tab->bgColor = QColor();
312 else 312 else
313 tab->bgColor = QColor(tabCol); 313 tab->bgColor = QColor(tabCol);
314 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 314 QString tabTextCol = cfg.readEntry( "TabTextColor" );
315 if ( tabTextCol.isEmpty() ) 315 if ( tabTextCol.isEmpty() )
316 tab->fgColor = QColor(); 316 tab->fgColor = QColor();
317 else 317 else
318 tab->fgColor = QColor(tabTextCol); 318 tab->fgColor = QColor(tabTextCol);
319} 319}
320 320
321void LauncherTabWidget::paletteChange( const QPalette &p ) 321void LauncherTabWidget::paletteChange( const QPalette &p )
322{ 322{
323 QVBox::paletteChange( p ); 323 QVBox::paletteChange( p );
324 QPalette pal = palette(); 324 QPalette pal = palette();
325 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 325 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
326 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 326 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
327 categoryBar->setPalette( pal ); 327 categoryBar->setPalette( pal );
328 categoryBar->update(); 328 categoryBar->update();
329} 329}
330 330
331void LauncherTabWidget::styleChange( QStyle & ) 331void LauncherTabWidget::styleChange( QStyle & )
332{ 332{
333 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); 333 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
334} 334}
335 335
336void LauncherTabWidget::setProgressStyle() 336void LauncherTabWidget::setProgressStyle()
337{ 337{
338 if (docLoadingWidgetProgress) { 338 if (docLoadingWidgetProgress) {
339 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); 339 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
340 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); 340 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
341 docLoadingWidgetProgress->setMargin( 1 ); 341 docLoadingWidgetProgress->setMargin( 1 );
342 docLoadingWidgetProgress->setLineWidth( 1 ); 342 docLoadingWidgetProgress->setLineWidth( 1 );
343 } 343 }
344} 344}
345 345
346/* 346/*
347 * FIXME 347 * FIXME
348 * The following NULL check is triggered by inserting, then removing a tab on the fly 348 * The following NULL check is triggered by inserting, then removing a tab on the fly
349 * as you would if you had removable media (which I do). Without this check 349 * as you would if you had removable media (which I do). Without this check
350 * the first app launched after a tab removal causes qpe to Segfault. 350 * the first app launched after a tab removal causes qpe to Segfault.
351 * This obviously has a more sinister cause, but this works around it with no 351 * This obviously has a more sinister cause, but this works around it with no
352 * obvious adverse effects. Please FIXME 352 * obvious adverse effects. Please FIXME
353 * bkc - 17/6/2004 353 * bkc - 17/6/2004
354 * 354 *
355 */ 355 */
356 356
357void LauncherTabWidget::setBusy(bool on) 357void LauncherTabWidget::setBusy(bool on)
358{ 358{
359 if ( on ) 359 if ( on )
360 currentView()->setBusy(TRUE); 360 currentView()->setBusy(TRUE);
361 else { 361 else {
362 for ( int i = 0; i < categoryBar->count(); i++ ) { 362 for ( int i = 0; i < categoryBar->count(); i++ ) {
363 if (categoryBar->tab(i)) { 363 if (categoryBar->tab(i)) {
364 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; 364 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
365 view->setBusy( FALSE ); 365 view->setBusy( FALSE );
366 } else { 366 } else {
367 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; 367 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl;
368 } 368 }
369 } 369 }
370 } 370 }
371} 371}
372 372
373void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 373void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
374 for (int i = 0; i < categoryBar->count(); i++ ) { 374 for (int i = 0; i < categoryBar->count(); i++ ) {
375 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 375 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
376 view->setBusyIndicatorType( str ); 376 view->setBusyIndicatorType( str );
377 } 377 }
378} 378}
379 379
380LauncherView *LauncherTabWidget::currentView(void) 380LauncherView *LauncherTabWidget::currentView(void)
381{ 381{
382 return (LauncherView*)stack->visibleWidget(); 382 return (LauncherView*)stack->visibleWidget();
383} 383}
384 384
385 385
386 386
387void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 387void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
388{ 388{
389 QDataStream stream( data, IO_ReadOnly ); 389 QDataStream stream( data, IO_ReadOnly );
390 if ( msg == "setTabView(QString,int)" ) { 390 if ( msg == "setTabView(QString,int)" ) {
391 QString id; 391 QString id;
392 stream >> id; 392 stream >> id;
393 int mode; 393 int mode;
394 stream >> mode; 394 stream >> mode;
395 if ( view(id) ) 395 if ( view(id) )
396 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 396 view(id)->setViewMode( (LauncherView::ViewMode)mode );
397 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 397 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
398 QString id; 398 QString id;
399 stream >> id; 399 stream >> id;
400 int mode; 400 int mode;
401 stream >> mode; 401 stream >> mode;
402 QString pixmapOrColor; 402 QString pixmapOrColor;
403 stream >> pixmapOrColor; 403 stream >> pixmapOrColor;
404 if ( view(id) ) 404 if ( view(id) )
405 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 405 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
406 if ( id == "Documents" ) 406 if ( id == "Documents" )
407 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 407 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
408 } else if ( msg == "setTextColor(QString,QString)" ) { 408 } else if ( msg == "setTextColor(QString,QString)" ) {
409 QString id; 409 QString id;
410 stream >> id; 410 stream >> id;
411 QString color; 411 QString color;
412 stream >> color; 412 stream >> color;
413 if ( view(id) ) 413 if ( view(id) )
414 view(id)->setTextColor( QColor(color) ); 414 view(id)->setTextColor( QColor(color) );
415 if ( id == "Documents" ) 415 if ( id == "Documents" )
416 docLoadingWidget->setTextColor( QColor(color) ); 416 docLoadingWidget->setTextColor( QColor(color) );
417 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 417 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
418 QString id; 418 QString id;
419 stream >> id; 419 stream >> id;
420 QString fam; 420 QString fam;
421 stream >> fam; 421 stream >> fam;
422 int size; 422 int size;
423 stream >> size; 423 stream >> size;
424 int weight; 424 int weight;
425 stream >> weight; 425 stream >> weight;
426 int italic; 426 int italic;
427 stream >> italic; 427 stream >> italic;
428 if ( view(id) ) { 428 if ( view(id) ) {
429 if ( !fam.isEmpty() ) { 429 if ( !fam.isEmpty() ) {
430 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 430 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
431 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; 431 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
432 } else { 432 } else {
433 view(id)->clearViewFont(); 433 view(id)->clearViewFont();
434 }
434 } 435 }
435 }
436 }else if ( msg == "setBusyIndicatorType(QString)" ) { 436 }else if ( msg == "setBusyIndicatorType(QString)" ) {
437 QString type; 437 QString type;
438 stream >> type; 438 stream >> type;
439 setBusyIndicatorType( type ); 439 setBusyIndicatorType( type );
440 }else if ( msg == "home()" ) { 440 }else if ( msg == "home()" ) {
441 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 441 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
442 if (categoryBar) 442 if (categoryBar)
443 categoryBar->nextTab(); 443 categoryBar->nextTab();
444 }else 444 }else {
445 static_cast<QWidget*>(parent())->raise(); 445 static_cast<QWidget*>(parent())->raise();
446 }
447 } else if (msg=="doctabEnabled(int)") {
448 int id; stream >> id;
449 odebug << "Doctab enabled " << id << oendl;
450 reCheckDoctab(id);
446 } 451 }
447} 452}
448 453
449 454void LauncherTabWidget::reCheckDoctab(int how)
455{
456 if ((bool)how == docTabEnabled) {
457 /* nothing to do */
458 return;
459 }
460 if (docLoadingWidget) {
461 stack->removeWidget(docLoadingWidget);
462 delete docLoadingWidget;
463 docLoadingWidget = 0;
464 }
465 createDocLoadingWidget();
466 {
467 QCopEnvelope( "QPE/System", "reforceDocuments()" );
468 odebug << "Sending doc rescan" << oendl;
469 }
470}
450 471
451//--------------------------------------------------------------------------- 472//---------------------------------------------------------------------------
452 473
453Launcher::Launcher() 474Launcher::Launcher()
454 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 475 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
455{ 476{
456 tabs = 0; 477 tabs = 0;
457 tb = 0; 478 tb = 0;
458 Config cfg( "Launcher" ); 479 Config cfg( "Launcher" );
459 cfg.setGroup( "DocTab" ); 480 cfg.setGroup( "DocTab" );
460 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 481 docTabEnabled = cfg.readBoolEntry( "Enable", true );
461} 482}
462 483
463void Launcher::createGUI() 484void Launcher::createGUI()
464{ 485{
465 setCaption( tr("Launcher") ); 486 setCaption( tr("Launcher") );
466 487
467 // we have a pretty good idea how big we'll be 488 // we have a pretty good idea how big we'll be
468 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 489 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
469 490
470 tb = new TaskBar; 491 tb = new TaskBar;
471 tabs = new LauncherTabWidget( this ); 492 tabs = new LauncherTabWidget( this );
472 setCentralWidget( tabs ); 493 setCentralWidget( tabs );
473 494
474 ServerInterface::dockWidget( tb, ServerInterface::Bottom ); 495 ServerInterface::dockWidget( tb, ServerInterface::Bottom );
475 tb->show(); 496 tb->show();
476 497
477 qApp->installEventFilter( this ); 498 qApp->installEventFilter( this );
478 499
479 connect( tb, SIGNAL(tabSelected(const QString&)), 500 connect( tb, SIGNAL(tabSelected(const QString&)),
480 this, SLOT(showTab(const QString&)) ); 501 this, SLOT(showTab(const QString&)) );
481 connect( tabs, SIGNAL(selected(const QString&)), 502 connect( tabs, SIGNAL(selected(const QString&)),
482 this, SLOT(viewSelected(const QString&)) ); 503 this, SLOT(viewSelected(const QString&)) );
483 connect( tabs, SIGNAL(clicked(const AppLnk*)), 504 connect( tabs, SIGNAL(clicked(const AppLnk*)),
484 this, SLOT(select(const AppLnk*))); 505 this, SLOT(select(const AppLnk*)));
485 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 506 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
486 this, SLOT(properties(AppLnk*))); 507 this, SLOT(properties(AppLnk*)));
487 508
488#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 509#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
489 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 510 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
490 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), 511 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
491 this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); 512 this, SLOT(systemMessage(const QCString&,const QByteArray&)) );
492#endif 513#endif
493 514
494 // all documents 515 // all documents
495 QImage img( Resource::loadImage( "DocsIcon" ) ); 516 QImage img( Resource::loadImage( "DocsIcon" ) );
496 QPixmap pm; 517 QPixmap pm;
497 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 518 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
498 // It could add this itself if it handles docs 519 // It could add this itself if it handles docs
499 520
500 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); 521 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
501 522
502 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); 523 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
503 qApp->setMainWidget( this ); 524 qApp->setMainWidget( this );
504 QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); 525 QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
505} 526}
506 527
507Launcher::~Launcher() 528Launcher::~Launcher()
508{ 529{
509 if ( tb ) 530 if ( tb )
510 destroyGUI(); 531 destroyGUI();
511} 532}
512 533
513 bool Launcher::requiresDocuments() const 534 bool Launcher::requiresDocuments() const
514 { 535 {
515 Config cfg( "Launcher" ); 536 Config cfg( "Launcher" );
516 cfg.setGroup( "DocTab" ); 537 cfg.setGroup( "DocTab" );
517 return cfg.readBoolEntry( "Enable", true ); 538 return cfg.readBoolEntry( "Enable", true );
518} 539}
519 540
520void Launcher::makeVisible() 541void Launcher::makeVisible()
521{ 542{
522 showMaximized(); 543 showMaximized();
523} 544}
524 545
525void Launcher::destroyGUI() 546void Launcher::destroyGUI()
526{ 547{
527 delete tb; 548 delete tb;
528 tb = 0; 549 tb = 0;
529 delete tabs; 550 delete tabs;
530 tabs =0; 551 tabs =0;
531} 552}
532 553
533bool Launcher::eventFilter( QObject*, QEvent *ev ) 554bool Launcher::eventFilter( QObject*, QEvent *ev )
534{ 555{
535#ifdef QT_QWS_CUSTOM 556#ifdef QT_QWS_CUSTOM
536 if ( ev->type() == QEvent::KeyPress ) { 557 if ( ev->type() == QEvent::KeyPress ) {
537 QKeyEvent *ke = (QKeyEvent *)ev; 558 QKeyEvent *ke = (QKeyEvent *)ev;
538 if ( ke->key() == Qt::Key_F11 ) { // menu key 559 if ( ke->key() == Qt::Key_F11 ) { // menu key
539 QWidget *active = qApp->activeWindow(); 560 QWidget *active = qApp->activeWindow();
540 if ( active && active->isPopup() ) 561 if ( active && active->isPopup() )
541 active->close(); 562 active->close();
542 else { 563 else {
543 Global::terminateBuiltin("calibrate"); // No tr 564 Global::terminateBuiltin("calibrate"); // No tr
544 tb->launchStartMenu(); 565 tb->launchStartMenu();
545 } 566 }
546 return TRUE; 567 return TRUE;
547 } 568 }
548 } 569 }
549#else 570#else
550 Q_UNUSED(ev); 571 Q_UNUSED(ev);
551#endif 572#endif
552 return FALSE; 573 return FALSE;
553} 574}
554 575
555static bool isVisibleWindow(int wid) 576static bool isVisibleWindow(int wid)
556{ 577{
557#ifdef Q_WS_QWS 578#ifdef Q_WS_QWS
558 const QList<QWSWindow> &list = qwsServer->clientWindows(); 579 const QList<QWSWindow> &list = qwsServer->clientWindows();
559 QWSWindow* w; 580 QWSWindow* w;
560 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 581 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
561 if ( w->winId() == wid ) 582 if ( w->winId() == wid )
562 return !w->isFullyObscured(); 583 return !w->isFullyObscured();
563 } 584 }
564#endif 585#endif
565 return FALSE; 586 return FALSE;
566} 587}
567 588
568void Launcher::viewSelected(const QString& s) 589void Launcher::viewSelected(const QString& s)
569{ 590{
570 setCaption( s + tr(" - Launcher") ); 591 setCaption( s + tr(" - Launcher") );
571} 592}
572 593
573void Launcher::showTab(const QString& id) 594void Launcher::showTab(const QString& id)
574{ 595{
575 tabs->categoryBar->showTab(id); 596 tabs->categoryBar->showTab(id);
576 raise(); 597 raise();
577} 598}
578 599
579void Launcher::select( const AppLnk *appLnk ) 600void Launcher::select( const AppLnk *appLnk )
580{ 601{
581 if ( appLnk->type() == "Folder" ) { // No tr 602 if ( appLnk->type() == "Folder" ) { // No tr
582 // Not supported: flat is simpler for the user 603 // Not supported: flat is simpler for the user
583 } else { 604 } else {
584 if ( appLnk->exec().isNull() ) { 605 if ( appLnk->exec().isNull() ) {
585 int i = QMessageBox::information(this,tr("No application"), 606 int i = QMessageBox::information(this,tr("No application"),
586 tr("<p>No application is defined for this document." 607 tr("<p>No application is defined for this document."
587 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); 608 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
588 609
589 /* ### Fixme */ 610 /* ### Fixme */
590 if ( i == 1 ) 611 if ( i == 1 )
591 Global::execute("textedit",appLnk->file()); 612 Global::execute("textedit",appLnk->file());
592 613
593 return; 614 return;
594 } 615 }
595 tabs->setBusy(TRUE); 616 tabs->setBusy(TRUE);
596 emit executing( appLnk ); 617 emit executing( appLnk );
597 appLnk->execute(); 618 appLnk->execute();
598 } 619 }
599} 620}
600 621
601void Launcher::properties( AppLnk *appLnk ) 622void Launcher::properties( AppLnk *appLnk )
602{ 623{
603 if ( appLnk->type() == "Folder" ) { // No tr 624 if ( appLnk->type() == "Folder" ) { // No tr
604 // Not supported: flat is simpler for the user 625 // Not supported: flat is simpler for the user
605 } else { 626 } else {
606/* ### libqtopia FIXME also moving docLnks... */ 627/* ### libqtopia FIXME also moving docLnks... */
607 LnkProperties prop(appLnk,0 ); 628 LnkProperties prop(appLnk,0 );
608 629
609 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) { 630 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) {
610 } 631 }
611 } 632 }
612} 633}
613 634
614void Launcher::storageChanged( const QList<FileSystem> & ) 635void Launcher::storageChanged( const QList<FileSystem> & )
615{ 636{
616 // ### update combo boxes if we had a combo box for the storage type 637 // ### update combo boxes if we had a combo box for the storage type
617} 638}
618 639
619void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 640void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
620{ 641{
621 QDataStream stream( data, IO_ReadOnly ); 642 QDataStream stream( data, IO_ReadOnly );
622 if ( msg == "busy()" ) { 643 if ( msg == "busy()" ) {
623 tb->startWait(); 644 tb->startWait();
624 } else if ( msg == "notBusy(QString)" ) { 645 } else if ( msg == "notBusy(QString)" ) {
625 QString app; 646 QString app;
626 stream >> app; 647 stream >> app;
627 tabs->setBusy(FALSE); 648 tabs->setBusy(FALSE);
628 tb->stopWait(app); 649 tb->stopWait(app);
629 } else if (msg == "applyStyle()") { 650 } else if (msg == "applyStyle()") {
630 tabs->currentView()->relayout(); 651 tabs->currentView()->relayout();
631 } 652 }
632} 653}
633 654
634// These are the update functions from the server 655// These are the update functions from the server
635void Launcher::typeAdded( const QString& type, const QString& name, 656void Launcher::typeAdded( const QString& type, const QString& name,
636 const QPixmap& pixmap, const QPixmap& ) 657 const QPixmap& pixmap, const QPixmap& )
637{ 658{
638 tabs->newView( type, pixmap, name ); 659 tabs->newView( type, pixmap, name );
639 ids.append( type ); 660 ids.append( type );
640 /* this will be called in applicationScanningProgress with value 100! */ 661 /* this will be called in applicationScanningProgress with value 100! */
641// tb->refreshStartMenu(); 662// tb->refreshStartMenu();
642 663
643 static bool first = TRUE; 664 static bool first = TRUE;
644 if ( first ) { 665 if ( first ) {
645 first = FALSE; 666 first = FALSE;
646 tabs->categoryBar->showTab(type); 667 tabs->categoryBar->showTab(type);
647 } 668 }
648 669
649 tabs->view( type )->setUpdatesEnabled( FALSE ); 670 tabs->view( type )->setUpdatesEnabled( FALSE );
650 tabs->view( type )->setSortEnabled( FALSE ); 671 tabs->view( type )->setSortEnabled( FALSE );
651} 672}
652 673
653void Launcher::typeRemoved( const QString& type ) 674void Launcher::typeRemoved( const QString& type )
654{ 675{
655 tabs->view( type )->removeAllItems(); 676 tabs->view( type )->removeAllItems();
656 tabs->deleteView( type ); 677 tabs->deleteView( type );
657 ids.remove( type ); 678 ids.remove( type );
658 /* this will be called in applicationScanningProgress with value 100! */ 679 /* this will be called in applicationScanningProgress with value 100! */
659// tb->refreshStartMenu(); 680// tb->refreshStartMenu();
660} 681}
661 682
662void Launcher::applicationAdded( const QString& type, const AppLnk& app ) 683void Launcher::applicationAdded( const QString& type, const AppLnk& app )
663{ 684{
664 if ( app.type() == "Separator" ) // No tr 685 if ( app.type() == "Separator" ) // No tr
665 return; 686 return;
666 687
667 LauncherView *view = tabs->view( type ); 688 LauncherView *view = tabs->view( type );
668 if ( view ) 689 if ( view )
669 view->addItem( new AppLnk( app ), FALSE ); 690 view->addItem( new AppLnk( app ), FALSE );
670 else 691 else
671 owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app " 692 owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app "
672 << app.name().latin1() << "!", 693 << app.name().latin1() << "!",
673 694
674 MimeType::registerApp( app ); 695 MimeType::registerApp( app );
675} 696}
676 697
677void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) 698void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
678{ 699{
679 LauncherView *view = tabs->view( type ); 700 LauncherView *view = tabs->view( type );
680 if ( view ) 701 if ( view )
681 view->removeLink( app.linkFile() ); 702 view->removeLink( app.linkFile() );
682 else 703 else
683 owarn << "removeAppLnk: No view for " << type << "!" << oendl; 704 owarn << "removeAppLnk: No view for " << type << "!" << oendl;
684} 705}
685 706
686void Launcher::allApplicationsRemoved() 707void Launcher::allApplicationsRemoved()
687{ 708{
688 MimeType::clear(); 709 MimeType::clear();
689 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) 710 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
690 tabs->view( (*it) )->removeAllItems(); 711 tabs->view( (*it) )->removeAllItems();
691} 712}
692 713
693void Launcher::documentAdded( const DocLnk& doc ) 714void Launcher::documentAdded( const DocLnk& doc )
694{ 715{
695 tabs->docView()->addItem( new DocLnk( doc ), FALSE ); 716 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
696} 717}
697 718
698void Launcher::aboutToAddBegin() 719void Launcher::aboutToAddBegin()
699{ 720{
700 tabs->docView()->setUpdatesEnabled( false ); 721 tabs->docView()->setUpdatesEnabled( false );
701} 722}
702 723
703void Launcher::aboutToAddEnd() 724void Launcher::aboutToAddEnd()
704{ 725{
705 tabs->docView()->setUpdatesEnabled( true ); 726 tabs->docView()->setUpdatesEnabled( true );
706} 727}
707 728
708void Launcher::showLoadingDocs() 729void Launcher::showLoadingDocs()
709{ 730{
710 tabs->docView()->hide(); 731 tabs->docView()->hide();
711} 732}
712 733
713void Launcher::showDocTab() 734void Launcher::showDocTab()
714{ 735{
715 if ( tabs->categoryBar->currentView() == tabs->docView() ) 736 if ( tabs->categoryBar->currentView() == tabs->docView() )
716 tabs->docView()->show(); 737 tabs->docView()->show();
717} 738}
718 739
719void Launcher::documentRemoved( const DocLnk& doc ) 740void Launcher::documentRemoved( const DocLnk& doc )
720{ 741{
721 tabs->docView()->removeLink( doc.linkFile() ); 742 tabs->docView()->removeLink( doc.linkFile() );
722} 743}
723 744
724void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) 745void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
725{ 746{
726#if 0 747#if 0
727 documentRemoved( oldDoc ); 748 documentRemoved( oldDoc );
728 documentAdded( newDoc ); 749 documentAdded( newDoc );
729// tabs->docView()->updateTools(); 750// tabs->docView()->updateTools();
730#else 751#else
731 tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc)); 752 tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc));
732#endif 753#endif
733} 754}
734 755
735void Launcher::allDocumentsRemoved() 756void Launcher::allDocumentsRemoved()
736{ 757{
737 tabs->docView()->removeAllItems(); 758 tabs->docView()->removeAllItems();
738} 759}
739 760
740void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) 761void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
741{ 762{
742 tb->setApplicationState( name, state ); 763 tb->setApplicationState( name, state );
743} 764}
744 765
745void Launcher::applicationScanningProgress( int percent ) 766void Launcher::applicationScanningProgress( int percent )
746{ 767{
747 switch ( percent ) { 768 switch ( percent ) {
748 case 0: { 769 case 0: {
749 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 770 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
750 tabs->view( (*it) )->setUpdatesEnabled( FALSE ); 771 tabs->view( (*it) )->setUpdatesEnabled( FALSE );
751 tabs->view( (*it) )->setSortEnabled( FALSE ); 772 tabs->view( (*it) )->setSortEnabled( FALSE );
752 } 773 }
753 break; 774 break;
754 } 775 }
755 case 100: { 776 case 100: {
756 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 777 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
757 tabs->view( (*it) )->setUpdatesEnabled( TRUE ); 778 tabs->view( (*it) )->setUpdatesEnabled( TRUE );
758 tabs->view( (*it) )->setSortEnabled( TRUE ); 779 tabs->view( (*it) )->setSortEnabled( TRUE );
759 } 780 }
760 tb->refreshStartMenu(); 781 tb->refreshStartMenu();
761 break; 782 break;
762 } 783 }
763 default: 784 default:
764 break; 785 break;
765 } 786 }
766} 787}
767 788
768void Launcher::documentScanningProgress( int percent ) 789void Launcher::documentScanningProgress( int percent )
769{ 790{
770 switch ( percent ) { 791 switch ( percent ) {
771 case 0: { 792 case 0: {
772 tabs->setLoadingProgress( 0 ); 793 tabs->setLoadingProgress( 0 );
773 tabs->setLoadingWidgetEnabled( TRUE ); 794 tabs->setLoadingWidgetEnabled( TRUE );
774 tabs->docView()->setUpdatesEnabled( FALSE ); 795 tabs->docView()->setUpdatesEnabled( FALSE );
775 tabs->docView()->setSortEnabled( FALSE ); 796 tabs->docView()->setSortEnabled( FALSE );
776 break; 797 break;
777 } 798 }
778 case 100: { 799 case 100: {
779 tabs->docView()->updateTools(); 800 tabs->docView()->updateTools();
780 tabs->docView()->setSortEnabled( TRUE ); 801 tabs->docView()->setSortEnabled( TRUE );
781 tabs->docView()->setUpdatesEnabled( TRUE ); 802 tabs->docView()->setUpdatesEnabled( TRUE );
782 tabs->setLoadingWidgetEnabled( FALSE ); 803 tabs->setLoadingWidgetEnabled( FALSE );
783 break; 804 break;
784 } 805 }
785 default: 806 default:
786 tabs->setLoadingProgress( percent ); 807 tabs->setLoadingProgress( percent );
787 break; 808 break;
788 } 809 }
789} 810}
790 811
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h
index db6ac54..b741064 100644
--- a/core/launcher/launcher.h
+++ b/core/launcher/launcher.h
@@ -1,158 +1,159 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LAUNCHER_H 20#ifndef LAUNCHER_H
21#define LAUNCHER_H 21#define LAUNCHER_H
22 22
23#include <qtopia/config.h> 23#include <qtopia/config.h>
24#include <qtopia/storage.h> 24#include <qtopia/storage.h>
25#include <qtopia/applnk.h> 25#include <qtopia/applnk.h>
26#include <qmainwindow.h> 26#include <qmainwindow.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qprogressbar.h> 28#include <qprogressbar.h>
29#include <qvbox.h> 29#include <qvbox.h>
30#include <qlist.h> 30#include <qlist.h>
31#include <qdict.h> 31#include <qdict.h>
32#include "launcherview.h" 32#include "launcherview.h"
33#include "launchertab.h" 33#include "launchertab.h"
34#include "serverinterface.h" 34#include "serverinterface.h"
35 35
36class QWidgetStack; 36class QWidgetStack;
37class TaskBar; 37class TaskBar;
38class Launcher; 38class Launcher;
39 39
40class LauncherTabWidget : public QVBox { 40class LauncherTabWidget : public QVBox {
41 // can't use a QTabWidget, since it won't let us set the frame style. 41 // can't use a QTabWidget, since it won't let us set the frame style.
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 LauncherTabWidget( Launcher* parent ); 44 LauncherTabWidget( Launcher* parent );
45 45
46 void updateDocs(AppLnkSet* docFolder); 46 void updateDocs(AppLnkSet* docFolder);
47 void setBusy(bool on); 47 void setBusy(bool on);
48 LauncherView *currentView(void); 48 LauncherView *currentView(void);
49 49
50 LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); 50 LauncherView* newView( const QString&, const QPixmap& pm, const QString& label );
51 void deleteView( const QString& ); 51 void deleteView( const QString& );
52 void setTabViewAppearance( LauncherView *v, Config &cfg ); 52 void setTabViewAppearance( LauncherView *v, Config &cfg );
53 void setTabAppearance( LauncherTab *, Config &cfg ); 53 void setTabAppearance( LauncherTab *, Config &cfg );
54 54
55 LauncherView *view( const QString & ); 55 LauncherView *view( const QString & );
56 LauncherView *docView(); 56 LauncherView *docView();
57 57
58 void createDocLoadingWidget(); 58 void createDocLoadingWidget();
59 void setLoadingWidgetEnabled( bool v ); 59 void setLoadingWidgetEnabled( bool v );
60 void setLoadingProgress( int percent ); 60 void setLoadingProgress( int percent );
61 61
62 LauncherTabBar* categoryBar; 62 LauncherTabBar* categoryBar;
63 63
64 void setBusyIndicatorType( const QString& type ); 64 void setBusyIndicatorType( const QString& type );
65 65
66signals: 66signals:
67 void selected(const QString&); 67 void selected(const QString&);
68 void clicked(const AppLnk*); 68 void clicked(const AppLnk*);
69 void rightPressed(AppLnk*); 69 void rightPressed(AppLnk*);
70 70
71protected slots: 71protected slots:
72 void raiseTabWidget(); 72 void raiseTabWidget();
73 void tabProperties(); 73 void tabProperties();
74 void initLayout(); 74 void initLayout();
75 75
76private slots: 76private slots:
77 void launcherMessage( const QCString &, const QByteArray &); 77 void launcherMessage( const QCString &, const QByteArray &);
78 void appMessage( const QCString &, const QByteArray &); 78 void appMessage( const QCString &, const QByteArray &);
79 void setProgressStyle(); 79 void setProgressStyle();
80 80
81protected: 81protected:
82 void paletteChange( const QPalette &p ); 82 void paletteChange( const QPalette &p );
83 void styleChange( QStyle & ); 83 void styleChange( QStyle & );
84 void reCheckDoctab(int how);
84 85
85private: 86private:
86 Launcher *launcher; 87 Launcher *launcher;
87 LauncherView *docview; 88 LauncherView *docview;
88 89
89 QWidgetStack *stack; 90 QWidgetStack *stack;
90 LauncherView *docLoadingWidget; 91 LauncherView *docLoadingWidget;
91 QProgressBar *docLoadingWidgetProgress; 92 QProgressBar *docLoadingWidgetProgress;
92 bool docLoadingWidgetEnabled; 93 bool docLoadingWidgetEnabled;
93 bool docTabEnabled; 94 bool docTabEnabled;
94 int m_DocumentTabId; 95 int m_DocumentTabId;
95}; 96};
96 97
97class Launcher : public QMainWindow, public ServerInterface 98class Launcher : public QMainWindow, public ServerInterface
98{ 99{
99 Q_OBJECT 100 Q_OBJECT
100public: 101public:
101 Launcher(); 102 Launcher();
102 ~Launcher(); 103 ~Launcher();
103 104
104 // implementing ServerInterface 105 // implementing ServerInterface
105 void createGUI(); 106 void createGUI();
106 void destroyGUI(); 107 void destroyGUI();
107 void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap ); 108 void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap );
108 void typeRemoved( const QString& type ); 109 void typeRemoved( const QString& type );
109 void applicationAdded( const QString& type, const AppLnk& doc ); 110 void applicationAdded( const QString& type, const AppLnk& doc );
110 void applicationRemoved( const QString& type, const AppLnk& doc ); 111 void applicationRemoved( const QString& type, const AppLnk& doc );
111 void allApplicationsRemoved(); 112 void allApplicationsRemoved();
112 void applicationStateChanged( const QString& name, ApplicationState state ); 113 void applicationStateChanged( const QString& name, ApplicationState state );
113 void documentAdded( const DocLnk& doc ); 114 void documentAdded( const DocLnk& doc );
114 void documentRemoved( const DocLnk& doc ); 115 void documentRemoved( const DocLnk& doc );
115 void aboutToAddBegin(); 116 void aboutToAddBegin();
116 void aboutToAddEnd(); 117 void aboutToAddEnd();
117 void allDocumentsRemoved(); 118 void allDocumentsRemoved();
118 void documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ); 119 void documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc );
119 void storageChanged( const QList<FileSystem> & ); 120 void storageChanged( const QList<FileSystem> & );
120 void applicationScanningProgress( int percent ); 121 void applicationScanningProgress( int percent );
121 void documentScanningProgress( int percent ); 122 void documentScanningProgress( int percent );
122 bool requiresApplications() const { return TRUE; } 123 bool requiresApplications() const { return TRUE; }
123 bool requiresDocuments() const; 124 bool requiresDocuments() const;
124 void showLoadingDocs(); 125 void showLoadingDocs();
125 void showDocTab(); 126 void showDocTab();
126 127
127 QStringList idList() const { return ids; } 128 QStringList idList() const { return ids; }
128 129
129public slots: 130public slots:
130 void viewSelected(const QString&); 131 void viewSelected(const QString&);
131 void showTab(const QString&); 132 void showTab(const QString&);
132 void select( const AppLnk * ); 133 void select( const AppLnk * );
133 void properties( AppLnk * ); 134 void properties( AppLnk * );
134 void makeVisible(); 135 void makeVisible();
135 136
136signals: 137signals:
137 void executing( const AppLnk * ); 138 void executing( const AppLnk * );
138 139
139private slots: 140private slots:
140 void systemMessage( const QCString &, const QByteArray &); 141 void systemMessage( const QCString &, const QByteArray &);
141 142
142protected: 143protected:
143 bool eventFilter( QObject *o, QEvent *ev ); 144 bool eventFilter( QObject *o, QEvent *ev );
144 145
145private: 146private:
146 void updateApps(); 147 void updateApps();
147 void loadDocs(); 148 void loadDocs();
148 void updateDocs(); 149 void updateDocs();
149 void updateTabs(); 150 void updateTabs();
150 151
151 LauncherTabWidget *tabs; 152 LauncherTabWidget *tabs;
152 QStringList ids; 153 QStringList ids;
153 TaskBar *tb; 154 TaskBar *tb;
154 155
155 bool docTabEnabled; 156 bool docTabEnabled;
156}; 157};
157 158
158#endif // LAUNCHERVIEW_H 159#endif // LAUNCHERVIEW_H
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index c9efacb..2783423 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,1223 +1,1221 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "launcherview.h" 21#include "launcherview.h"
22 22
23/* OPIE */ 23/* OPIE */
24#include <opie2/odebug.h> 24#include <opie2/odebug.h>
25#include <qtopia/qpeapplication.h> 25#include <qtopia/qpeapplication.h>
26#include <qtopia/private/categories.h> 26#include <qtopia/private/categories.h>
27#include <qtopia/categoryselect.h> 27#include <qtopia/categoryselect.h>
28#include <qtopia/mimetype.h> 28#include <qtopia/mimetype.h>
29#include <qtopia/resource.h> 29#include <qtopia/resource.h>
30using namespace Opie::Core; 30using namespace Opie::Core;
31 31
32#include <qpe/qcopenvelope_qws.h> 32#include <qpe/qcopenvelope_qws.h>
33 33
34/* QT */ 34/* QT */
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qfileinfo.h> 36#include <qfileinfo.h>
37#include <qiconview.h> 37#include <qiconview.h>
38#include <qobjectlist.h> 38#include <qobjectlist.h>
39 39
40 40
41// These define how the busy icon is animated and highlighted 41// These define how the busy icon is animated and highlighted
42#define BRIGHTEN_BUSY_ICON 42#define BRIGHTEN_BUSY_ICON
43//#define ALPHA_FADE_BUSY_ICON 43//#define ALPHA_FADE_BUSY_ICON
44//#define USE_ANIMATED_BUSY_ICON_OVERLAY 44//#define USE_ANIMATED_BUSY_ICON_OVERLAY
45#define BOUNCE_BUSY_ICON 45#define BOUNCE_BUSY_ICON
46 46
47typedef QMap<QString,QPixmap>::Iterator pixiter; 47typedef QMap<QString,QPixmap>::Iterator pixiter;
48 48
49class BgPixmap 49class BgPixmap
50{ 50{
51public: 51public:
52 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 52 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
53 QPixmap pm; 53 QPixmap pm;
54 int ref; 54 int ref;
55}; 55};
56 56
57 57
58static QMap<QString,BgPixmap*> *bgCache = 0; 58static QMap<QString,BgPixmap*> *bgCache = 0;
59 59
60static void cleanup_cache() 60static void cleanup_cache()
61{ 61{
62 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 62 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
63 while ( it != bgCache->end() ) { 63 while ( it != bgCache->end() ) {
64 QMap<QString,BgPixmap*>::Iterator curr = it; 64 QMap<QString,BgPixmap*>::Iterator curr = it;
65 ++it; 65 ++it;
66 delete (*curr); 66 delete (*curr);
67 bgCache->remove( curr ); 67 bgCache->remove( curr );
68 } 68 }
69 delete bgCache; 69 delete bgCache;
70 bgCache = 0; 70 bgCache = 0;
71} 71}
72 72
73 73
74class LauncherItem : public QIconViewItem 74class LauncherItem : public QIconViewItem
75{ 75{
76public: 76public:
77 enum iconstate_t { 77 enum iconstate_t {
78 BASE_ICON, 78 BASE_ICON,
79 WAITING_ICON, 79 WAITING_ICON,
80 EYE_ICON 80 EYE_ICON
81 }; 81 };
82 82
83 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 83 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
84 ~LauncherItem(); 84 ~LauncherItem();
85 85
86 AppLnk *appLnk() const { return app; } 86 AppLnk *appLnk() const { return app; }
87 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } 87 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
88 88
89 void animateIcon(); 89 void animateIcon();
90 void resetIcon(); 90 void resetIcon();
91 bool isEyeImage()const{return m_EyeImage;} 91 bool isEyeImage()const{return m_EyeImage;}
92 92
93 virtual int compare ( QIconViewItem * i ) const; 93 virtual int compare ( QIconViewItem * i ) const;
94 void paintItem( QPainter *p, const QColorGroup &cg ); 94 void paintItem( QPainter *p, const QColorGroup &cg );
95 95
96 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 96 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
97 void setEyePixmap(const QPixmap&aIcon); 97 void setEyePixmap(const QPixmap&aIcon);
98 virtual QPixmap*pixmap()const; 98 virtual QPixmap*pixmap()const;
99 99
100protected: 100protected:
101 bool isBigIcon; 101 bool isBigIcon;
102 int iteration; 102 int iteration;
103 AppLnk* app; 103 AppLnk* app;
104 104
105private: 105private:
106 void paintAnimatedIcon( QPainter *p ); 106 void paintAnimatedIcon( QPainter *p );
107 BusyIndicatorType busyType; 107 BusyIndicatorType busyType;
108 int psize; 108 int psize;
109 bool m_EyeImage; 109 bool m_EyeImage;
110 iconstate_t m_EyeImageSet; 110 iconstate_t m_EyeImageSet;
111}; 111};
112 112
113LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 113LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
114 : QIconViewItem( parent, applnk->name(), 114 : QIconViewItem( parent, applnk->name(),
115 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 115 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
116 isBigIcon( bigIcon ), 116 isBigIcon( bigIcon ),
117 iteration(0), 117 iteration(0),
118 app(applnk), // Takes ownership 118 app(applnk), // Takes ownership
119 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), 119 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
120 m_EyeImage(false), 120 m_EyeImage(false),
121 m_EyeImageSet(BASE_ICON) 121 m_EyeImageSet(BASE_ICON)
122{ 122{
123 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { 123 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
124 m_EyeImage = true; 124 m_EyeImage = true;
125 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); 125 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file());
126 if (it != LauncherIconView::sm_EyeCache->end()) { 126 if (it != LauncherIconView::sm_EyeCache->end()) {
127 m_EyeImageSet = EYE_ICON; 127 m_EyeImageSet = EYE_ICON;
128 setPixmap(*it); 128 setPixmap(*it);
129 } 129 }
130 } 130 }
131} 131}
132 132
133LauncherItem::~LauncherItem() 133LauncherItem::~LauncherItem()
134{ 134{
135 LauncherIconView* liv = (LauncherIconView*)iconView(); 135 LauncherIconView* liv = (LauncherIconView*)iconView();
136 if ( liv->busyItem() == this ) 136 if ( liv->busyItem() == this )
137 liv->setBusy(FALSE); 137 liv->setBusy(FALSE);
138 delete app; 138 delete app;
139} 139}
140 140
141QPixmap*LauncherItem::pixmap()const 141QPixmap*LauncherItem::pixmap()const
142{ 142{
143 if (m_EyeImage && m_EyeImageSet == BASE_ICON) { 143 if (m_EyeImage && m_EyeImageSet == BASE_ICON) {
144 LauncherIconView* liv = (LauncherIconView*)iconView(); 144 LauncherIconView* liv = (LauncherIconView*)iconView();
145 liv->requestEyePix(this); 145 liv->requestEyePix(this);
146 } 146 }
147 return QIconViewItem::pixmap(); 147 return QIconViewItem::pixmap();
148} 148}
149 149
150int LauncherItem::compare ( QIconViewItem * i ) const 150int LauncherItem::compare ( QIconViewItem * i ) const
151{ 151{
152 LauncherIconView* view = (LauncherIconView*)iconView(); 152 LauncherIconView* view = (LauncherIconView*)iconView();
153 return view->compare(app,((LauncherItem *)i)->appLnk()); 153 return view->compare(app,((LauncherItem *)i)->appLnk());
154} 154}
155 155
156void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 156void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
157{ 157{
158 LauncherIconView* liv = (LauncherIconView*)iconView(); 158 LauncherIconView* liv = (LauncherIconView*)iconView();
159 QBrush oldBrush( liv->itemTextBackground() ); 159 QBrush oldBrush( liv->itemTextBackground() );
160 QColorGroup mycg( cg ); 160 QColorGroup mycg( cg );
161 if ( liv->currentItem() == this ) { 161 if ( liv->currentItem() == this ) {
162 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 162 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
163 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 163 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
164 } 164 }
165 165
166 QIconViewItem::paintItem(p,mycg); 166 QIconViewItem::paintItem(p,mycg);
167 167
168 // Paint animation overlay 168 // Paint animation overlay
169 if ( liv->busyItem() == this ) 169 if ( liv->busyItem() == this )
170 paintAnimatedIcon(p); 170 paintAnimatedIcon(p);
171 171
172 if ( liv->currentItem() == this ) 172 if ( liv->currentItem() == this )
173 liv->setItemTextBackground( oldBrush ); 173 liv->setItemTextBackground( oldBrush );
174} 174}
175 175
176void LauncherItem::paintAnimatedIcon( QPainter *p ) 176void LauncherItem::paintAnimatedIcon( QPainter *p )
177{ 177{
178 LauncherIconView* liv = (LauncherIconView*)iconView(); 178 LauncherIconView* liv = (LauncherIconView*)iconView();
179 int pic = iteration % 16; 179 int pic = iteration % 16;
180 int w = pixmap()->width(), h = pixmap()->height(); 180 int w = pixmap()->width(), h = pixmap()->height();
181 QPixmap dblBuf( w, h + 4 ); 181 QPixmap dblBuf( w, h + 4 );
182 QPainter p2( &dblBuf ); 182 QPainter p2( &dblBuf );
183 int x1, y1; 183 int x1, y1;
184 if ( liv->itemTextPos() == QIconView::Bottom ) { 184 if ( liv->itemTextPos() == QIconView::Bottom ) {
185 x1 = x() + (width() - w) / 2 - liv->contentsX(); 185 x1 = x() + (width() - w) / 2 - liv->contentsX();
186 y1 = y() - liv->contentsY(); 186 y1 = y() - liv->contentsY();
187 } else { 187 } else {
188 x1 = x() - liv->contentsX(); 188 x1 = x() - liv->contentsX();
189 y1 = y() + (height() - h) / 2 - liv->contentsY(); 189 y1 = y() + (height() - h) / 2 - liv->contentsY();
190 } 190 }
191 y1 -= 2; 191 y1 -= 2;
192 p2.translate(-x1,-y1); 192 p2.translate(-x1,-y1);
193 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); 193 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
194 int bounceY = 2; 194 int bounceY = 2;
195#ifdef BOUNCE_BUSY_ICON 195#ifdef BOUNCE_BUSY_ICON
196 if ( busyType == BIT_Animated ) { 196 if ( busyType == BIT_Animated ) {
197 bounceY = 4 - ((iteration+2)%8); 197 bounceY = 4 - ((iteration+2)%8);
198 bounceY = bounceY < 0 ? -bounceY : bounceY; 198 bounceY = bounceY < 0 ? -bounceY : bounceY;
199 } 199 }
200#endif 200#endif
201 p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); 201 p2.drawPixmap( x1, y1 + bounceY, *pixmap() );
202#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 202#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
203 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); 203 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h );
204#else 204#else
205 Q_UNUSED( pic ) 205 Q_UNUSED( pic )
206#endif 206#endif
207 p->drawPixmap( x1, y1, dblBuf ); 207 p->drawPixmap( x1, y1, dblBuf );
208} 208}
209 209
210void LauncherItem::animateIcon() 210void LauncherItem::animateIcon()
211{ 211{
212 LauncherIconView* liv = (LauncherIconView*)iconView(); 212 LauncherIconView* liv = (LauncherIconView*)iconView();
213 213
214 if ( liv->busyItem() != this || !app ) 214 if ( liv->busyItem() != this || !app )
215 return; 215 return;
216 216
217 // Highlight the icon 217 // Highlight the icon
218 if ( iteration == 0 ) { 218 if ( iteration == 0 ) {
219 QPixmap src; 219 QPixmap src;
220 pixiter it; 220 pixiter it;
221 if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) { 221 if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) {
222 src = (*it); 222 src = (*it);
223 } else { 223 } else {
224 src = ((isBigIcon ? app->bigPixmap() : app->pixmap())); 224 src = ((isBigIcon ? app->bigPixmap() : app->pixmap()));
225 } 225 }
226 QImage img = src.convertToImage(); 226 QImage img = src.convertToImage();
227 QRgb *rgb; 227 QRgb *rgb;
228 int count; 228 int count;
229 if ( img.depth() == 32 ) { 229 if ( img.depth() == 32 ) {
230 rgb = (QRgb*)img.bits(); 230 rgb = (QRgb*)img.bits();
231 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 231 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
232 } else { 232 } else {
233 rgb = img.colorTable(); 233 rgb = img.colorTable();
234 count = img.numColors(); 234 count = img.numColors();
235 } 235 }
236 for ( int r = 0; r < count; r++, rgb++ ) { 236 for ( int r = 0; r < count; r++, rgb++ ) {
237#if defined(BRIGHTEN_BUSY_ICON) 237#if defined(BRIGHTEN_BUSY_ICON)
238 QColor c(*rgb); 238 QColor c(*rgb);
239 int h, s, v; 239 int h, s, v;
240 c.hsv(&h,&s,&v); 240 c.hsv(&h,&s,&v);
241 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 241 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
242 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 242 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
243#elif defined(ALPHA_FADE_BUSY_ICON) 243#elif defined(ALPHA_FADE_BUSY_ICON)
244 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 244 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
245#endif 245#endif
246 } 246 }
247 src.convertFromImage( img ); 247 src.convertFromImage( img );
248 setPixmap( src ); 248 setPixmap( src );
249 } 249 }
250 250
251 iteration++; 251 iteration++;
252 252
253 // Paint animation overlay 253 // Paint animation overlay
254 QPainter p( liv->viewport() ); 254 QPainter p( liv->viewport() );
255 paintAnimatedIcon( &p ); 255 paintAnimatedIcon( &p );
256} 256}
257 257
258void LauncherItem::resetIcon() 258void LauncherItem::resetIcon()
259{ 259{
260 iteration = 0; 260 iteration = 0;
261 if (isEyeImage()) { 261 if (isEyeImage()) {
262 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); 262 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file());
263 if (it != LauncherIconView::sm_EyeCache->end()) { 263 if (it != LauncherIconView::sm_EyeCache->end()) {
264 setPixmap(*it); 264 setPixmap(*it);
265 return; 265 return;
266 } 266 }
267 } 267 }
268 setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); 268 setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap());
269} 269}
270 270
271void LauncherItem::setEyePixmap(const QPixmap&aIcon) 271void LauncherItem::setEyePixmap(const QPixmap&aIcon)
272{ 272{
273 if (!isEyeImage()) return; 273 if (!isEyeImage()) return;
274 setPixmap(aIcon); 274 setPixmap(aIcon);
275 m_EyeImageSet = EYE_ICON; 275 m_EyeImageSet = EYE_ICON;
276} 276}
277 277
278//=========================================================================== 278//===========================================================================
279// Implemantation of LauncherIconview start 279// Implemantation of LauncherIconview start
280//=========================================================================== 280//===========================================================================
281 281
282QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; 282QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0;
283 283
284LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 284LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
285 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) 285 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white)
286{ 286{
287 m_EyeCallBack = 0; 287 m_EyeCallBack = 0;
288 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); 288 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>();
289 sortmeth = Name; 289 sortmeth = Name;
290 hidden.setAutoDelete(TRUE); 290 hidden.setAutoDelete(TRUE);
291 ike = FALSE; 291 ike = FALSE;
292 calculateGrid( Bottom ); 292 calculateGrid( Bottom );
293 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); 293 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
294} 294}
295 295
296LauncherIconView::~LauncherIconView() 296LauncherIconView::~LauncherIconView()
297{ 297{
298 odebug << "LauncherIconView::~LauncherIconView()" << oendl; 298 odebug << "LauncherIconView::~LauncherIconView()" << oendl;
299#if 0 // debuggery 299#if 0 // debuggery
300 QListIterator<AppLnk> it(hidden); 300 QListIterator<AppLnk> it(hidden);
301 AppLnk* l; 301 AppLnk* l;
302 while ((l=it.current())) { 302 while ((l=it.current())) {
303 ++it; 303 ++it;
304 //odebug << "" << l << ": hidden (should remove)" << oendl; 304 //odebug << "" << l << ": hidden (should remove)" << oendl;
305 } 305 }
306#endif 306#endif
307} 307}
308 308
309int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 309int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
310{ 310{
311 switch (sortmeth) { 311 switch (sortmeth) {
312 case Name: 312 case Name:
313 return a->name().lower().compare(b->name().lower()); 313 return a->name().lower().compare(b->name().lower());
314 case Date: { 314 case Date: {
315 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 315 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
316 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 316 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
317 return fa.lastModified().secsTo(fb.lastModified()); 317 return fa.lastModified().secsTo(fb.lastModified());
318 } 318 }
319 case Type: 319 case Type:
320 return a->type().compare(b->type()); 320 return a->type().compare(b->type());
321 } 321 }
322 return 0; 322 return 0;
323} 323}
324 324
325void LauncherIconView::setSortMethod( SortMethod m ) 325void LauncherIconView::setSortMethod( SortMethod m )
326{ 326{
327 if ( sortmeth != m ) { 327 if ( sortmeth != m ) {
328 sortmeth = m; 328 sortmeth = m;
329 sort(); 329 sort();
330 } 330 }
331} 331}
332 332
333void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 333void LauncherIconView::setCategoryFilter( int catfilter, bool resort )
334{ 334{
335 Categories cat;
336 cat.load( categoryFileName() );
337 QString str;
338 if ( catfilter == -2 ) 335 if ( catfilter == -2 )
339 cf = 0; 336 cf = 0;
340 else 337 else
341 cf = catfilter; 338 cf = catfilter;
342 hideOrShowItems(resort); 339 hideOrShowItems(resort);
343} 340}
344 341
345void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 342void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
346{ 343{
347 tf = QRegExp(typefilter,FALSE,TRUE); 344 tf = QRegExp(typefilter,FALSE,TRUE);
348 hideOrShowItems(resort); 345 hideOrShowItems(resort);
349} 346}
350 347
351void LauncherIconView::setItemTextPos( ItemTextPos pos ) 348void LauncherIconView::setItemTextPos( ItemTextPos pos )
352{ 349{
353 calculateGrid( pos ); 350 calculateGrid( pos );
354 QIconView::setItemTextPos( pos ); 351 QIconView::setItemTextPos( pos );
355} 352}
356 353
357void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) 354void LauncherIconView::drawBackground( QPainter *p, const QRect &r )
358{ 355{
359 if ( !bgPixmap.isNull() ) { 356 if ( !bgPixmap.isNull() ) {
360 p->drawTiledPixmap( r, bgPixmap, 357 p->drawTiledPixmap( r, bgPixmap,
361 QPoint( (r.x() + contentsX()) % bgPixmap.width(), 358 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
362 (r.y() + contentsY()) % bgPixmap.height() ) ); 359 (r.y() + contentsY()) % bgPixmap.height() ) );
363 } else { 360 } else {
364 p->fillRect( r, bgColor ); 361 p->fillRect( r, bgColor );
365 } 362 }
366} 363}
367 364
368void LauncherIconView::addCatsAndMimes(AppLnk* app) 365void LauncherIconView::addCatsAndMimes(AppLnk* app)
369 { 366 {
370 // QStringList c = app->categories(); 367 // QStringList c = app->categories();
371 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 368 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
372 // cats.replace(*cit,(void*)1); 369 // cats.replace(*cit,(void*)1);
373 // } 370 // }
374 QString maj=app->type(); 371 QString maj=app->type();
375 int sl=maj.find('/'); 372 int sl=maj.find('/');
376 if (sl>=0) { 373 if (sl>=0) {
377 QString k; 374 QString k;
378 k = maj.left(12) == "application/" ? maj : maj.left(sl); 375 k = maj.left(12) == "application/" ? maj : maj.left(sl);
379 mimes.replace(k,(void*)1); 376 mimes.replace(k,(void*)1);
380 } 377 }
381} 378}
382 379
383void LauncherIconView::setBusy(bool on) 380void LauncherIconView::setBusy(bool on)
384{ 381{
385#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 382#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
386 if ( busyPix.isNull() ) { 383 if ( busyPix.isNull() ) {
387 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 384 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
388 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); 385 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
389 } 386 }
390#endif 387#endif
391 388
392 if ( on ) { 389 if ( on ) {
393 busyTimer = startTimer( 100 ); 390 busyTimer = startTimer( 100 );
394 } else { 391 } else {
395 if ( busyTimer ) { 392 if ( busyTimer ) {
396 killTimer( busyTimer ); 393 killTimer( busyTimer );
397 busyTimer = 0; 394 busyTimer = 0;
398 } 395 }
399 } 396 }
400 397
401 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; 398 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
402 399
403 if ( bsy != c ) { 400 if ( bsy != c ) {
404 LauncherItem *oldBusy = bsy; 401 LauncherItem *oldBusy = bsy;
405 bsy = c; 402 bsy = c;
406 if ( oldBusy ) { 403 if ( oldBusy ) {
407 oldBusy->resetIcon(); 404 oldBusy->resetIcon();
408 } 405 }
409 if ( bsy ) { 406 if ( bsy ) {
410 bsy->setBusyIndicatorType( busyType ) ; 407 bsy->setBusyIndicatorType( busyType ) ;
411 bsy->animateIcon(); 408 bsy->animateIcon();
412 } 409 }
413 } 410 }
414} 411}
415 412
416void LauncherIconView::clear() 413void LauncherIconView::clear()
417{ 414{
418 mimes.clear(); 415 mimes.clear();
419 cats.clear(); 416 cats.clear();
420 QIconView::clear(); 417 QIconView::clear();
421 hidden.clear(); 418 hidden.clear();
422} 419}
423 420
424QStringList LauncherIconView::mimeTypes() const 421QStringList LauncherIconView::mimeTypes() const
425{ 422{
426 QStringList r; 423 QStringList r;
427 QDictIterator<void> it(mimes); 424 QDictIterator<void> it(mimes);
428 while (it.current()) { 425 while (it.current()) {
429 r.append(it.currentKey()); 426 r.append(it.currentKey());
430 ++it; 427 ++it;
431 } 428 }
432 r.sort(); 429 r.sort();
433 return r; 430 return r;
434} 431}
435 432
436LauncherItem*LauncherIconView::findDocItem(const QString&fname) 433LauncherItem*LauncherIconView::findDocItem(const QString&fname)
437{ 434{
438 LauncherItem* item = (LauncherItem*)firstItem(); 435 LauncherItem* item = (LauncherItem*)firstItem();
439 while (item) { 436 while (item) {
440 if (item->appLnk()->file()==fname) { 437 if (item->appLnk()->file()==fname) {
441 break; 438 break;
442 } 439 }
443 item = (LauncherItem*)item->nextItem(); 440 item = (LauncherItem*)item->nextItem();
444 } 441 }
445 return item; 442 return item;
446} 443}
447 444
448void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) 445void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
449{ 446{
450 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 447 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
451 if (s!=width) return; 448 if (s!=width) return;
452 LauncherItem*item = findDocItem(aFile); 449 LauncherItem*item = findDocItem(aFile);
453 if (!item||!item->isEyeImage()) return; 450 if (!item||!item->isEyeImage()) return;
454 (*sm_EyeCache)[aFile]=aPixmap; 451 (*sm_EyeCache)[aFile]=aPixmap;
455 item->setEyePixmap(aPixmap); 452 item->setEyePixmap(aPixmap);
456} 453}
457 454
458void LauncherIconView::checkCallback() 455void LauncherIconView::checkCallback()
459{ 456{
460 if (!m_EyeCallBack) { 457 if (!m_EyeCallBack) {
461 m_EyeCallBack = new LauncherThumbReceiver(); 458 m_EyeCallBack = new LauncherThumbReceiver();
462 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 459 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
463 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 460 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
464 } 461 }
465 m_eyeTimer.changeInterval(600000); 462 m_eyeTimer.changeInterval(600000);
466} 463}
467 464
468void LauncherIconView::addCheckItem(AppLnk* app) 465void LauncherIconView::addCheckItem(AppLnk* app)
469{ 466{
470 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 467 LauncherItem*item = new LauncherItem( this, app, bigIcns );
471 if (item->isEyeImage()) { 468 if (item->isEyeImage()) {
472 checkCallback(); 469 checkCallback();
473 } 470 }
474} 471}
475 472
476void LauncherIconView::requestEyePix(const LauncherItem*item) 473void LauncherIconView::requestEyePix(const LauncherItem*item)
477{ 474{
478 if (!item) return; 475 if (!item) return;
479 if (item->isEyeImage()) { 476 if (item->isEyeImage()) {
480 checkCallback(); 477 checkCallback();
481 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 478 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
482 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); 479 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
483 } 480 }
484} 481}
485 482
486void LauncherIconView::stopEyeTimer() 483void LauncherIconView::stopEyeTimer()
487{ 484{
488 if (m_EyeCallBack) { 485 if (m_EyeCallBack) {
489 disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 486 disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
490 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 487 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
491 delete m_EyeCallBack; 488 delete m_EyeCallBack;
492 m_EyeCallBack=0; 489 m_EyeCallBack=0;
493 } 490 }
494 m_eyeTimer.stop(); 491 m_eyeTimer.stop();
495} 492}
496 493
497void LauncherIconView::updateCategoriesAndMimeTypes() 494void LauncherIconView::updateCategoriesAndMimeTypes()
498{ 495{
499 mimes.clear(); 496 mimes.clear();
500 cats.clear(); 497 cats.clear();
501 LauncherItem* item = (LauncherItem*)firstItem(); 498 LauncherItem* item = (LauncherItem*)firstItem();
502 while (item) { 499 while (item) {
503 addCatsAndMimes(item->appLnk()); 500 addCatsAndMimes(item->appLnk());
504 item = (LauncherItem*)item->nextItem(); 501 item = (LauncherItem*)item->nextItem();
505 } 502 }
506 QListIterator<AppLnk> it(hidden); 503 QListIterator<AppLnk> it(hidden);
507 AppLnk* l; 504 AppLnk* l;
508 while ((l=it.current())) { 505 while ((l=it.current())) {
509 addCatsAndMimes(l); 506 addCatsAndMimes(l);
510 ++it; 507 ++it;
511 } 508 }
512} 509}
513 510
514void LauncherIconView::hideOrShowItems(bool resort) 511void LauncherIconView::hideOrShowItems(bool resort)
515{ 512{
516 viewport()->setUpdatesEnabled( FALSE ); 513 viewport()->setUpdatesEnabled( FALSE );
517 hidden.setAutoDelete(FALSE); 514 hidden.setAutoDelete(FALSE);
518 QList<AppLnk> links=hidden; 515 QList<AppLnk> links=hidden;
519 hidden.clear(); 516 hidden.clear();
520 hidden.setAutoDelete(TRUE); 517 hidden.setAutoDelete(TRUE);
521 LauncherItem* item = (LauncherItem*)firstItem(); 518 LauncherItem* item = (LauncherItem*)firstItem();
522 while (item) { 519 while (item) {
523 links.append(item->takeAppLnk()); 520 links.append(item->takeAppLnk());
524 item = (LauncherItem*)item->nextItem(); 521 item = (LauncherItem*)item->nextItem();
525 } 522 }
526 clear(); 523 clear();
527 QListIterator<AppLnk> it(links); 524 QListIterator<AppLnk> it(links);
528 AppLnk* l; 525 AppLnk* l;
529 while ((l=it.current())) { 526 while ((l=it.current())) {
530 addItem(l,FALSE); 527 addItem(l,FALSE);
531 ++it; 528 ++it;
532 } 529 }
533 if ( resort && !autoArrange() ) 530 if ( resort && !autoArrange() )
534 sort(); 531 sort();
535 viewport()->setUpdatesEnabled( TRUE ); 532 viewport()->setUpdatesEnabled( TRUE );
536} 533}
537 534
538bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache) 535bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache)
539{ 536{
540 LauncherItem* item = (LauncherItem*)firstItem(); 537 LauncherItem* item = (LauncherItem*)firstItem();
541 AppLnk* l; 538 AppLnk* l;
542 bool did = FALSE; 539 bool did = FALSE;
543 DocLnk dl(linkfile); 540 DocLnk dl(linkfile);
544 while (item) { 541 while (item) {
545 l = item->appLnk(); 542 l = item->appLnk();
546 LauncherItem *nextItem = (LauncherItem *)item->nextItem(); 543 LauncherItem *nextItem = (LauncherItem *)item->nextItem();
547 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && 544 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() &&
548 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { 545 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) {
549 if (removeCache) sm_EyeCache->remove(l->file()); 546 if (removeCache) sm_EyeCache->remove(l->file());
550 delete item; 547 delete item;
551 did = TRUE; 548 did = TRUE;
552 } 549 }
553 item = nextItem; 550 item = nextItem;
554 } 551 }
555 QListIterator<AppLnk> it(hidden); 552 QListIterator<AppLnk> it(hidden);
556 while ((l=it.current())) { 553 while ((l=it.current())) {
557 ++it; 554 ++it;
558 if ( l->linkFileKnown() && l->linkFile() == linkfile 555 if ( l->linkFileKnown() && l->linkFile() == linkfile
559 || l->file() == linkfile 556 || l->file() == linkfile
560 || dl.isValid() && dl.file() == l->file() ) { 557 || dl.isValid() && dl.file() == l->file() ) {
561 hidden.removeRef(l); 558 hidden.removeRef(l);
562 did = TRUE; 559 did = TRUE;
563 } 560 }
564 } 561 }
565 return did; 562 return did;
566} 563}
567 564
568void LauncherIconView::addItem(AppLnk* app, bool resort) 565void LauncherIconView::addItem(AppLnk* app, bool resort)
569{ 566{
570 addCatsAndMimes(app); 567 addCatsAndMimes(app);
571 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 568 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
572 && (cf == 0 || app->categories().contains(cf) 569 && (cf == 0 || app->categories().contains(cf)
573 || cf == -1 && app->categories().count() == 0 ) ) { 570 || cf == -1 && app->categories().count() == 0 ) ) {
574 addCheckItem(app); 571 addCheckItem(app);
575 } else { 572 } else {
576 hidden.append(app); 573 hidden.append(app);
577 } 574 }
578 if ( resort ){ 575 if ( resort ){
579 sort(); 576 sort();
580 } 577 }
581} 578}
582 579
583void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink) 580void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink)
584{ 581{
585 QString oldfile = old.file(); 582 QString oldfile = old.file();
586 QString newfile = nlink->file(); 583 QString newfile = nlink->file();
587 584
588 if (newfile != oldfile) { 585 if (newfile != oldfile) {
589 QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile); 586 QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile);
590 if (it != sm_EyeCache->end()) { 587 if (it != sm_EyeCache->end()) {
591 (*sm_EyeCache)[newfile]=(*it); 588 (*sm_EyeCache)[newfile]=(*it);
592 } 589 }
593 removeLink(old.linkFile()); 590 removeLink(old.linkFile());
594 } else { 591 } else {
595 removeLink(old.linkFile(),false); 592 removeLink(old.linkFile(),false);
596 } 593 }
597 addItem(nlink,false); 594 addItem(nlink,false);
598} 595}
599 596
600void LauncherIconView::timerEvent( QTimerEvent *te ) 597void LauncherIconView::timerEvent( QTimerEvent *te )
601{ 598{
602 if ( te->timerId() == busyTimer ) { 599 if ( te->timerId() == busyTimer ) {
603 if ( bsy ) 600 if ( bsy )
604 bsy->animateIcon(); 601 bsy->animateIcon();
605 } else { 602 } else {
606 QIconView::timerEvent( te ); 603 QIconView::timerEvent( te );
607 } 604 }
608} 605}
609 606
610void LauncherIconView::setBigIcons( bool bi ) 607void LauncherIconView::setBigIcons( bool bi )
611{ 608{
612 sm_EyeCache->clear(); 609 sm_EyeCache->clear();
613 bigIcns = bi; 610 bigIcns = bi;
614#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 611#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
615 busyPix.resize(0,0); 612 busyPix.resize(0,0);
616#endif 613#endif
617} 614}
618 615
619QIconViewItem* LauncherIconView::busyItem() const 616QIconViewItem* LauncherIconView::busyItem() const
620{ 617{
621 return bsy; 618 return bsy;
622} 619}
623 620
624void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 621void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
625 622
626void LauncherIconView::calculateGrid( ItemTextPos pos ) 623void LauncherIconView::calculateGrid( ItemTextPos pos )
627{ 624{
628 int dw = QApplication::desktop()->width(); 625 int dw = QApplication::desktop()->width();
629 int viewerWidth = dw-style().scrollBarExtent().width(); 626 int viewerWidth = dw-style().scrollBarExtent().width();
630 if ( pos == Bottom ) { 627 if ( pos == Bottom ) {
631 int cols = 3; 628 int cols = 3;
632 if ( viewerWidth <= 200 ) 629 if ( viewerWidth <= 200 )
633 cols = 2; 630 cols = 2;
634 else if ( viewerWidth >= 400 ) 631 else if ( viewerWidth >= 400 )
635 cols = viewerWidth/96; 632 cols = viewerWidth/96;
636 setSpacing( 4 ); 633 setSpacing( 4 );
637 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 634 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
638 setGridY( fontMetrics().height()*2+24 ); 635 setGridY( fontMetrics().height()*2+24 );
639 } else { 636 } else {
640 int cols = 2; 637 int cols = 2;
641 if ( viewerWidth < 150 ) 638 if ( viewerWidth < 150 )
642 cols = 1; 639 cols = 1;
643 else if ( viewerWidth >= 400 ) 640 else if ( viewerWidth >= 400 )
644 cols = viewerWidth/150; 641 cols = viewerWidth/150;
645 setSpacing( 2 ); 642 setSpacing( 2 );
646 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 643 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
647 setGridY( fontMetrics().height()+2 ); 644 setGridY( fontMetrics().height()+2 );
648 } 645 }
649} 646}
650 647
651void LauncherIconView::styleChange( QStyle &old ) 648void LauncherIconView::styleChange( QStyle &old )
652{ 649{
653 QIconView::styleChange( old ); 650 QIconView::styleChange( old );
654 calculateGrid( itemTextPos() ); 651 calculateGrid( itemTextPos() );
655} 652}
656 653
657void LauncherIconView::keyPressEvent(QKeyEvent* e) 654void LauncherIconView::keyPressEvent(QKeyEvent* e)
658{ 655{
659 ike = TRUE; 656 ike = TRUE;
660 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { 657 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) {
661 if ( (e->state() & ShiftButton) ) 658 if ( (e->state() & ShiftButton) )
662 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); 659 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() );
663 else 660 else
664 returnPressed(currentItem()); 661 returnPressed(currentItem());
665 } 662 }
666 663
667 QIconView::keyPressEvent(e); 664 QIconView::keyPressEvent(e);
668 ike = FALSE; 665 ike = FALSE;
669} 666}
670 667
671//=========================================================================== 668//===========================================================================
672// Implemantation of LauncherIconview end 669// Implemantation of LauncherIconview end
673//=========================================================================== 670//===========================================================================
674 671
675 672
676//=========================================================================== 673//===========================================================================
677LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 674LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
678 : QVBox( parent, name, fl ) 675 : QVBox( parent, name, fl )
679{ 676{
680 catmb = 0; 677 catmb = 0;
681 icons = new LauncherIconView( this ); 678 icons = new LauncherIconView( this );
682 setFocusProxy(icons); 679 setFocusProxy(icons);
683 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 680 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
684 681
685 icons->setItemsMovable( FALSE ); 682 icons->setItemsMovable( FALSE );
686 icons->setAutoArrange( TRUE ); 683 icons->setAutoArrange( TRUE );
687 icons->setSorting( TRUE ); 684 icons->setSorting( TRUE );
688 icons->setFrameStyle( QFrame::NoFrame ); 685 icons->setFrameStyle( QFrame::NoFrame );
689 icons->setMargin( 0 ); 686 icons->setMargin( 0 );
690 icons->setSelectionMode( QIconView::NoSelection ); 687 icons->setSelectionMode( QIconView::NoSelection );
691 icons->setBackgroundMode( PaletteBase ); 688 icons->setBackgroundMode( PaletteBase );
692 icons->setResizeMode( QIconView::Fixed ); 689 icons->setResizeMode( QIconView::Fixed );
693 vmode = (ViewMode)-1; 690 vmode = (ViewMode)-1;
694 setViewMode( Icon ); 691 setViewMode( Icon );
695 692
696 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 693 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
697 SLOT(itemClicked(int,QIconViewItem*)) ); 694 SLOT(itemClicked(int,QIconViewItem*)) );
698 connect( icons, SIGNAL(selectionChanged()), 695 connect( icons, SIGNAL(selectionChanged()),
699 SLOT(selectionChanged()) ); 696 SLOT(selectionChanged()) );
700 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 697 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
701 SLOT(returnPressed(QIconViewItem*)) ); 698 SLOT(returnPressed(QIconViewItem*)) );
702 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 699 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
703 SLOT(itemPressed(int,QIconViewItem*)) ); 700 SLOT(itemPressed(int,QIconViewItem*)) );
704 701
705 tools = 0; 702 tools = 0;
706 setBackgroundType( Ruled, QString::null ); 703 setBackgroundType( Ruled, QString::null );
707} 704}
708 705
709LauncherView::~LauncherView() 706LauncherView::~LauncherView()
710{ 707{
711 if ( bgCache && bgCache->contains( bgName ) ) 708 if ( bgCache && bgCache->contains( bgName ) )
712 (*bgCache)[bgName]->ref--; 709 (*bgCache)[bgName]->ref--;
713} 710}
714 711
715 712
716bool LauncherView::bsy=FALSE; 713bool LauncherView::bsy=FALSE;
717 714
718void LauncherView::setBusy(bool on) 715void LauncherView::setBusy(bool on)
719{ 716{
720 icons->setBusy(on); 717 icons->setBusy(on);
721} 718}
722 719
723void LauncherView::setBusyIndicatorType( const QString& type ) { 720void LauncherView::setBusyIndicatorType( const QString& type ) {
724 if ( type. lower ( ) == "animated" ) 721 if ( type. lower ( ) == "animated" )
725 icons->setBusyIndicatorType( BIT_Animated ) ; 722 icons->setBusyIndicatorType( BIT_Animated ) ;
726 else 723 else
727 icons->setBusyIndicatorType( BIT_Normal ) ; 724 icons->setBusyIndicatorType( BIT_Normal ) ;
728} 725}
729 726
730void LauncherView::hideIcons() 727void LauncherView::hideIcons()
731{ 728{
732 icons->hide(); 729 icons->hide();
733} 730}
734 731
735void LauncherView::setToolsEnabled(bool y) 732void LauncherView::setToolsEnabled(bool y)
736{ 733{
737 if ( !y != !tools ) { 734 if ( !y != !tools ) {
738 if ( y ) { 735 if ( y ) {
739 tools = new QHBox(this); 736 tools = new QHBox(this);
740 // Type filter 737 // Type filter
741 typemb = new QComboBox(tools); 738 typemb = new QComboBox(tools);
742 QSizePolicy p = typemb->sizePolicy(); 739 QSizePolicy p = typemb->sizePolicy();
743 p.setHorData(QSizePolicy::Expanding); 740 p.setHorData(QSizePolicy::Expanding);
744 typemb->setSizePolicy(p); 741 typemb->setSizePolicy(p);
745 // Category filter 742 // Category filter
746 updateTools(); 743 updateTools();
747 tools->show(); 744 tools->show();
748 } else { 745 } else {
749 delete tools; 746 delete tools;
750 tools = 0; 747 tools = 0;
751 } 748 }
752 } 749 }
753} 750}
754 751
755void LauncherView::updateTools() 752void LauncherView::updateTools()
756{ 753{
757 disconnect( typemb, SIGNAL(activated(int)), 754 disconnect( typemb, SIGNAL(activated(int)),
758 this, SLOT(showType(int)) ); 755 this, SLOT(showType(int)) );
759 if ( catmb ) { 756 if ( catmb ) {
760 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int))); 757 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int)));
761 } 758 }
762 759
763 // ### I want to remove this 760 // ### I want to remove this
764 icons->updateCategoriesAndMimeTypes(); 761 icons->updateCategoriesAndMimeTypes();
765 762
766 QString prev; 763 QString prev;
767 764
768 // Type filter 765 // Type filter
769 QStringList types; 766 QStringList types;
770 typelist = icons->mimeTypes(); 767 typelist = icons->mimeTypes();
771 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 768 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
772 QString t = *it; 769 QString t = *it;
773 if ( t.left(12) == "application/" ) { 770 if ( t.left(12) == "application/" ) {
774 MimeType mt(t); 771 MimeType mt(t);
775 const AppLnk* app = mt.application(); 772 const AppLnk* app = mt.application();
776 if ( app ) 773 if ( app )
777 t = app->name(); 774 t = app->name();
778 else 775 else
779 t = t.mid(12); 776 t = t.mid(12);
780 } else { 777 } else {
781 t[0] = t[0].upper(); 778 t[0] = t[0].upper();
782 } 779 }
783 types += t; 780 types += t;
784 } 781 }
785 types << tr("All types"); 782 types << tr("All types");
786 prev = typemb->currentText(); 783 prev = typemb->currentText();
787 typemb->clear(); 784 typemb->clear();
788 typemb->insertStringList(types); 785 typemb->insertStringList(types);
789 for (int i=0; i<typemb->count(); i++) { 786 for (int i=0; i<typemb->count(); i++) {
790 if ( typemb->text(i) == prev ) { 787 if ( typemb->text(i) == prev ) {
791 typemb->setCurrentItem(i); 788 typemb->setCurrentItem(i);
792 break; 789 break;
793 } 790 }
794 } 791 }
795 if ( prev.isNull() ) { 792 if ( prev.isNull() ) {
796 typemb->setCurrentItem(typemb->count()-1); 793 typemb->setCurrentItem(typemb->count()-1);
797 } 794 }
798 795
799 int pcat = catmb ? catmb->currentCategory() : -2; 796 int pcat = catmb ? catmb->currentCategory() : -2;
800 if ( !catmb ) { 797 if ( !catmb ) {
801 catmb = new CategorySelect(tools); 798 catmb = new CategorySelect(tools);
802 } else if (pcat!=-2) { 799 } else if (pcat!=-2) {
803 800
804 } 801 }
805 Categories cats( 0 ); 802 Categories cats( 0 );
806 cats.load( categoryFileName() ); 803 cats.load( categoryFileName() );
807 QArray<int> vl( 0 ); 804 QArray<int> vl( 0 );
808 catmb->setCategories( vl, "Document View", // No tr 805 catmb->setCategories( vl, "Document View", // No tr
809 tr("Document View") ); 806 tr("Document View") );
810 catmb->setRemoveCategoryEdit( TRUE ); 807 catmb->setRemoveCategoryEdit( TRUE );
811 catmb->setAllCategories( TRUE ); 808 catmb->setAllCategories( TRUE );
812 catmb->setCurrentCategory(pcat); 809 catmb->setCurrentCategory(pcat);
813 810
814 // if type has changed we need to redisplay 811 // if type has changed we need to redisplay
815 if ( typemb->currentText() != prev ) 812 if ( typemb->currentText() != prev )
816 showType( typemb->currentItem() ); 813 showType( typemb->currentItem() );
817 814
818 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 815 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
819 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 816 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
820} 817}
821 818
822void LauncherView::sortBy(int s) 819void LauncherView::sortBy(int s)
823{ 820{
824 icons->setSortMethod((LauncherIconView::SortMethod)s); 821 icons->setSortMethod((LauncherIconView::SortMethod)s);
825} 822}
826 823
827void LauncherView::showType(int t) 824void LauncherView::showType(int t)
828{ 825{
829 if ( t >= (int)typelist.count() ) { 826 if ( t >= (int)typelist.count() ) {
830 icons->setTypeFilter("",TRUE); 827 icons->setTypeFilter("",TRUE);
831 } else { 828 } else {
832 QString ty = typelist[t]; 829 QString ty = typelist[t];
833 if ( !ty.contains('/') ) 830 if ( !ty.contains('/') )
834 ty += "/*"; 831 ty += "/*";
835 icons->setTypeFilter(ty,TRUE); 832 icons->setTypeFilter(ty,TRUE);
836 } 833 }
837} 834}
838 835
839void LauncherView::showCategory( int c ) 836void LauncherView::showCategory( int c )
840{ 837{
841 icons->setCategoryFilter( c, TRUE ); 838 icons->setCategoryFilter( c, TRUE );
842} 839}
843 840
844void LauncherView::setViewMode( ViewMode m ) 841void LauncherView::setViewMode( ViewMode m )
845{ 842{
846 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl; 843 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl;
847 if ( vmode != m ) { 844 if ( vmode != m ) {
848 bool bigIcons = m == Icon; 845 bool bigIcons = m == Icon;
849 icons->viewport()->setUpdatesEnabled( FALSE ); 846 icons->viewport()->setUpdatesEnabled( FALSE );
850 icons->setBigIcons( bigIcons ); 847 icons->setBigIcons( bigIcons );
851 switch ( m ) { 848 switch ( m ) {
852 case List: 849 case List:
853 icons->setItemTextPos( QIconView::Right ); 850 icons->setItemTextPos( QIconView::Right );
854 break; 851 break;
855 case Icon: 852 case Icon:
856 icons->setItemTextPos( QIconView::Bottom ); 853 icons->setItemTextPos( QIconView::Bottom );
857 break; 854 break;
858 } 855 }
859 icons->hideOrShowItems( FALSE ); 856 icons->hideOrShowItems( FALSE );
860 icons->viewport()->setUpdatesEnabled( TRUE ); 857 icons->viewport()->setUpdatesEnabled( TRUE );
861 vmode = m; 858 vmode = m;
862 } 859 }
863} 860}
864 861
865// 862//
866// User images may require scaling. 863// User images may require scaling.
867// 864//
868QImage LauncherView::loadBackgroundImage(QString &bgName) 865QImage LauncherView::loadBackgroundImage(QString &bgName)
869{ 866{
870 QImageIO imgio; 867 QImageIO imgio;
871 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop 868 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop
872 bool further_scaling = TRUE; 869 bool further_scaling = TRUE;
873 870
874 imgio.setFileName( bgName ); 871 imgio.setFileName( bgName );
875 imgio.setParameters("GetHeaderInformation"); 872 imgio.setParameters("GetHeaderInformation");
876 873
877 if (imgio.read() == FALSE) { 874 if (imgio.read() == FALSE) {
878 return imgio.image(); 875 return imgio.image();
879 } 876 }
880 877
881 if (imgio.image().width() < ds.width() && 878 if (imgio.image().width() < ds.width() &&
882 imgio.image().height() < ds.height()) { 879 imgio.image().height() < ds.height()) {
883 further_scaling = FALSE; 880 further_scaling = FALSE;
884 } 881 }
885 882
886 if (!imgio.image().bits()) { 883 if (!imgio.image().bits()) {
887 // 884 //
888 // Scale and load. Note we don't scale up. 885 // Scale and load. Note we don't scale up.
889 // 886 //
890 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 887 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
891 imgio.setParameters(further_scaling ? 888 imgio.setParameters(further_scaling ?
892 param.arg(ds.width()).arg(ds.height()).latin1() : 889 param.arg(ds.width()).arg(ds.height()).latin1() :
893 ""); 890 "");
894 imgio.read(); 891 imgio.read();
895 } else { 892 } else {
896 if (further_scaling) { 893 if (further_scaling) {
897 int t1 = imgio.image().width() * ds.height(); 894 int t1 = imgio.image().width() * ds.height();
898 int t2 = imgio.image().height() * ds.width(); 895 int t2 = imgio.image().height() * ds.width();
899 int dsth = ds.height(); 896 int dsth = ds.height();
900 int dstw = ds.width(); 897 int dstw = ds.width();
901 898
902 if (t1 > t2) { 899 if (t1 > t2) {
903 dsth = t2 / imgio.image().width(); 900 dsth = t2 / imgio.image().width();
904 } else { 901 } else {
905 dstw = t1 / imgio.image().height(); 902 dstw = t1 / imgio.image().height();
906 } 903 }
907 904
908 // 905 //
909 // Loader didn't scale for us. Do it manually. 906 // Loader didn't scale for us. Do it manually.
910 // 907 //
911 return imgio.image().smoothScale(dstw, dsth); 908 return imgio.image().smoothScale(dstw, dsth);
912 } 909 }
913 } 910 }
914 911
915 return imgio.image(); 912 return imgio.image();
916} 913}
917 914
918void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 915void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
919{ 916{
920 if ( !bgCache ) { 917 if ( !bgCache ) {
921 bgCache = new QMap<QString,BgPixmap*>; 918 bgCache = new QMap<QString,BgPixmap*>;
922 qAddPostRoutine( cleanup_cache ); 919 qAddPostRoutine( cleanup_cache );
923 } 920 }
924 921
925 if ( bgCache->contains( bgName ) ) 922 if ( bgCache->contains( bgName ) )
926 (*bgCache)[bgName]->ref--; 923 (*bgCache)[bgName]->ref--;
927 bgName = ""; 924 bgName = "";
928 925
929 QPixmap bg; 926 QPixmap bg;
930 927
931 switch ( t ) { 928 switch ( t ) {
932 case Ruled: { 929 case Ruled: {
933 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 930 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
934 if ( bgCache->contains( bgName ) ) { 931 if ( bgCache->contains( bgName ) ) {
935 (*bgCache)[bgName]->ref++; 932 (*bgCache)[bgName]->ref++;
936 bg = (*bgCache)[bgName]->pm; 933 bg = (*bgCache)[bgName]->pm;
937 } else { 934 } else {
938 bg.resize( width(), 9 ); 935 bg.resize( width(), 9 );
939 QPainter painter( &bg ); 936 QPainter painter( &bg );
940 for ( int i = 0; i < 3; i++ ) { 937 for ( int i = 0; i < 3; i++ ) {
941 painter.setPen( white ); 938 painter.setPen( white );
942 painter.drawLine( 0, i*3, width()-1, i*3 ); 939 painter.drawLine( 0, i*3, width()-1, i*3 );
943 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 940 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
944 painter.setPen( colorGroup().background().light(105) ); 941 painter.setPen( colorGroup().background().light(105) );
945 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 942 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
946 } 943 }
947 painter.end(); 944 painter.end();
948 bgCache->insert( bgName, new BgPixmap(bg) ); 945 bgCache->insert( bgName, new BgPixmap(bg) );
949 } 946 }
950 break; 947 break;
951 } 948 }
952 949
953 case Image: 950 case Image:
954 if (!val.isEmpty()) { 951 if (!val.isEmpty()) {
955 bgName = val; 952 bgName = val;
956 if ( bgCache->contains( bgName ) ) { 953 if ( bgCache->contains( bgName ) ) {
957 (*bgCache)[bgName]->ref++; 954 (*bgCache)[bgName]->ref++;
958 bg = (*bgCache)[bgName]->pm; 955 bg = (*bgCache)[bgName]->pm;
959 } else { 956 } else {
960 QString imgFile = bgName; 957 QString imgFile = bgName;
961 bool tile = FALSE; 958 bool tile = FALSE;
962 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { 959 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) {
963 imgFile = Resource::findPixmap( imgFile ); 960 imgFile = Resource::findPixmap( imgFile );
964 tile = TRUE; 961 tile = TRUE;
965 } 962 }
966 QImage img = loadBackgroundImage(imgFile); 963 QImage img = loadBackgroundImage(imgFile);
967 964
968 965
969 if ( img.depth() == 1 ) 966 if ( img.depth() == 1 )
970 img = img.convertDepth(8); 967 img = img.convertDepth(8);
971 img.setAlphaBuffer(FALSE); 968 img.setAlphaBuffer(FALSE);
972 bg.convertFromImage(img); 969 bg.convertFromImage(img);
973 bgCache->insert( bgName, new BgPixmap(bg) ); 970 bgCache->insert( bgName, new BgPixmap(bg) );
974 } 971 }
975 } 972 }
976 break; 973 break;
977 974
978 case SolidColor: 975 case SolidColor:
979 default: 976 default:
980 break; 977 break;
981 } 978 }
982 979
983 const QObjectList *list = queryList( "QWidget", 0, FALSE ); 980 const QObjectList *list = queryList( "QWidget", 0, FALSE );
984 QObject *obj; 981 QObject *obj;
985 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { 982 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) {
986 if ( obj->isWidgetType() ) { 983 if ( obj->isWidgetType() ) {
987 QWidget *w = (QWidget*)obj; 984 QWidget *w = (QWidget*)obj;
988 w->setBackgroundPixmap( bg ); 985 w->setBackgroundPixmap( bg );
989 if ( bgName.isEmpty() ) { 986 if ( bgName.isEmpty() ) {
990 // Solid Color 987 // Solid Color
991 if ( val.isEmpty() ) 988 if ( val.isEmpty() )
992 w->setBackgroundColor( colorGroup().base() ); 989 w->setBackgroundColor( colorGroup().base() );
993 else 990 else
994 w->setBackgroundColor( val ); 991 w->setBackgroundColor( val );
995 } else { 992 } else {
996 // Ruled or Image pixmap 993 // Ruled or Image pixmap
997 w->setBackgroundOrigin( ParentOrigin ); 994 w->setBackgroundOrigin( ParentOrigin );
998 } 995 }
999 } 996 }
1000 } 997 }
1001 delete list; 998 delete list;
1002 999
1003 bgType = t; 1000 bgType = t;
1004 icons->viewport()->update(); 1001 icons->viewport()->update();
1005 1002
1006 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); 1003 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) );
1007} 1004}
1008 1005
1009void LauncherView::setTextColor( const QColor &tc ) 1006void LauncherView::setTextColor( const QColor &tc )
1010{ 1007{
1011 textCol = tc; 1008 textCol = tc;
1012 QColorGroup cg = icons->colorGroup(); 1009 QColorGroup cg = icons->colorGroup();
1013 cg.setColor( QColorGroup::Text, tc ); 1010 cg.setColor( QColorGroup::Text, tc );
1014 icons->setPalette( QPalette(cg,cg,cg) ); 1011 icons->setPalette( QPalette(cg,cg,cg) );
1015 icons->viewport()->update(); 1012 icons->viewport()->update();
1016} 1013}
1017 1014
1018void LauncherView::setViewFont( const QFont &f ) 1015void LauncherView::setViewFont( const QFont &f )
1019{ 1016{
1020 icons->setFont( f ); 1017 icons->setFont( f );
1021 icons->hideOrShowItems( FALSE ); 1018 icons->hideOrShowItems( FALSE );
1022} 1019}
1023 1020
1024void LauncherView::clearViewFont() 1021void LauncherView::clearViewFont()
1025{ 1022{
1026 icons->unsetFont(); 1023 icons->unsetFont();
1027 icons->hideOrShowItems( FALSE ); 1024 icons->hideOrShowItems( FALSE );
1028} 1025}
1029 1026
1030void LauncherView::resizeEvent(QResizeEvent *e) 1027void LauncherView::resizeEvent(QResizeEvent *e)
1031{ 1028{
1032// qDebug("LauncherView resize event"); 1029// qDebug("LauncherView resize event");
1033 QVBox::resizeEvent( e ); 1030 QVBox::resizeEvent( e );
1034// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... 1031// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere...
1035// if ( e->size().width() != e->oldSize().width() ) 1032// if ( e->size().width() != e->oldSize().width() )
1036 sort(); 1033 sort();
1037} 1034}
1038 1035
1039void LauncherView::selectionChanged() 1036void LauncherView::selectionChanged()
1040{ 1037{
1041 QIconViewItem* item = icons->currentItem(); 1038 QIconViewItem* item = icons->currentItem();
1042 if ( item && item->isSelected() ) { 1039 if ( item && item->isSelected() ) {
1043 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1040 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1044 if ( icons->inKeyEvent() ) // not for mouse press 1041 if ( icons->inKeyEvent() ) // not for mouse press
1045 emit clicked( appLnk ); 1042 emit clicked( appLnk );
1046 item->setSelected(FALSE); 1043 item->setSelected(FALSE);
1047 } 1044 }
1048} 1045}
1049 1046
1050void LauncherView::returnPressed( QIconViewItem *item ) 1047void LauncherView::returnPressed( QIconViewItem *item )
1051{ 1048{
1052 if ( item ) { 1049 if ( item ) {
1053 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1050 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1054 emit clicked( appLnk ); 1051 emit clicked( appLnk );
1055 } 1052 }
1056} 1053}
1057 1054
1058void LauncherView::itemClicked( int btn, QIconViewItem *item ) 1055void LauncherView::itemClicked( int btn, QIconViewItem *item )
1059{ 1056{
1060 if ( item ) { 1057 if ( item ) {
1061 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1058 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1062 if ( btn == LeftButton ) { 1059 if ( btn == LeftButton ) {
1063 // Make sure it's the item we execute that gets highlighted 1060 // Make sure it's the item we execute that gets highlighted
1064 icons->setCurrentItem( item ); 1061 icons->setCurrentItem( item );
1065 emit clicked( appLnk ); 1062 emit clicked( appLnk );
1066 } 1063 }
1067 item->setSelected(FALSE); 1064 item->setSelected(FALSE);
1068 } 1065 }
1069} 1066}
1070 1067
1071void LauncherView::itemPressed( int btn, QIconViewItem *item ) 1068void LauncherView::itemPressed( int btn, QIconViewItem *item )
1072{ 1069{
1073 if ( item ) { 1070 if ( item ) {
1074 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1071 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1075 if ( btn == RightButton ) 1072 if ( btn == RightButton )
1076 emit rightPressed( appLnk ); 1073 emit rightPressed( appLnk );
1077 else if ( btn == ShiftButton ) 1074 else if ( btn == ShiftButton )
1078 emit rightPressed( appLnk ); 1075 emit rightPressed( appLnk );
1079 item->setSelected(FALSE); 1076 item->setSelected(FALSE);
1080 } 1077 }
1081} 1078}
1082 1079
1083void LauncherView::removeAllItems() 1080void LauncherView::removeAllItems()
1084{ 1081{
1085 odebug << "LauncherView::removeAllItems()" << oendl; 1082 odebug << "LauncherView::removeAllItems()" << oendl;
1083 if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear();
1086 icons->clear(); 1084 icons->clear();
1087} 1085}
1088 1086
1089bool LauncherView::removeLink(const QString& linkfile) 1087bool LauncherView::removeLink(const QString& linkfile)
1090{ 1088{
1091 return icons->removeLink(linkfile); 1089 return icons->removeLink(linkfile);
1092} 1090}
1093 1091
1094void LauncherView::addItem(AppLnk* app, bool resort) 1092void LauncherView::addItem(AppLnk* app, bool resort)
1095{ 1093{
1096 icons->addItem(app,resort); 1094 icons->addItem(app,resort);
1097} 1095}
1098 1096
1099void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) 1097void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink)
1100{ 1098{
1101 icons->changeItem(old,nlink); 1099 icons->changeItem(old,nlink);
1102} 1100}
1103 1101
1104void LauncherView::setSortEnabled( bool v ) 1102void LauncherView::setSortEnabled( bool v )
1105{ 1103{
1106 icons->setSorting( v ); 1104 icons->setSorting( v );
1107 if ( v ) 1105 if ( v )
1108 sort(); 1106 sort();
1109} 1107}
1110 1108
1111void LauncherView::setUpdatesEnabled( bool u ) 1109void LauncherView::setUpdatesEnabled( bool u )
1112{ 1110{
1113 icons->setUpdatesEnabled( u ); 1111 icons->setUpdatesEnabled( u );
1114} 1112}
1115 1113
1116void LauncherView::sort() 1114void LauncherView::sort()
1117{ 1115{
1118 icons->sort(); 1116 icons->sort();
1119} 1117}
1120 1118
1121void LauncherView::paletteChange( const QPalette &p ) 1119void LauncherView::paletteChange( const QPalette &p )
1122{ 1120{
1123 icons->unsetPalette(); 1121 icons->unsetPalette();
1124 QVBox::paletteChange( p ); 1122 QVBox::paletteChange( p );
1125 if ( bgType == Ruled ) 1123 if ( bgType == Ruled )
1126 setBackgroundType( Ruled, QString::null ); 1124 setBackgroundType( Ruled, QString::null );
1127 QColorGroup cg = icons->colorGroup(); 1125 QColorGroup cg = icons->colorGroup();
1128 cg.setColor( QColorGroup::Text, textCol ); 1126 cg.setColor( QColorGroup::Text, textCol );
1129 icons->setPalette( QPalette(cg,cg,cg) ); 1127 icons->setPalette( QPalette(cg,cg,cg) );
1130} 1128}
1131 1129
1132void LauncherView::fontChanged(const QFont&) 1130void LauncherView::fontChanged(const QFont&)
1133{ 1131{
1134 odebug << "LauncherView::fontChanged()" << oendl; 1132 odebug << "LauncherView::fontChanged()" << oendl;
1135 icons->hideOrShowItems( FALSE ); 1133 icons->hideOrShowItems( FALSE );
1136} 1134}
1137 1135
1138void LauncherView::relayout(void) 1136void LauncherView::relayout(void)
1139{ 1137{
1140 icons->hideOrShowItems(FALSE); 1138 icons->hideOrShowItems(FALSE);
1141} 1139}
1142 1140
1143void LauncherView::flushBgCache() 1141void LauncherView::flushBgCache()
1144{ 1142{
1145 if ( !bgCache ) 1143 if ( !bgCache )
1146 return; 1144 return;
1147 // remove unreferenced backgrounds. 1145 // remove unreferenced backgrounds.
1148 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1146 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1149 while ( it != bgCache->end() ) { 1147 while ( it != bgCache->end() ) {
1150 QMap<QString,BgPixmap*>::Iterator curr = it; 1148 QMap<QString,BgPixmap*>::Iterator curr = it;
1151 ++it; 1149 ++it;
1152 if ( (*curr)->ref == 0 ) { 1150 if ( (*curr)->ref == 0 ) {
1153 delete (*curr); 1151 delete (*curr);
1154 bgCache->remove( curr ); 1152 bgCache->remove( curr );
1155 } 1153 }
1156 } 1154 }
1157} 1155}
1158 1156
1159/* 1157/*
1160 * Launcherthumbnail handling for image files 1158 * Launcherthumbnail handling for image files
1161 */ 1159 */
1162 1160
1163/* special image handling - based on opie eye */ 1161/* special image handling - based on opie eye */
1164QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 1162QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1165 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 1163 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1166 return s; 1164 return s;
1167} 1165}
1168 1166
1169QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 1167QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1170 return s << inf.file << inf.width << inf.height; 1168 return s << inf.file << inf.width << inf.height;
1171} 1169}
1172 1170
1173LauncherThumbReceiver::LauncherThumbReceiver() 1171LauncherThumbReceiver::LauncherThumbReceiver()
1174 :QObject() 1172 :QObject()
1175{ 1173{
1176 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); 1174 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1177 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 1175 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1178 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 1176 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1179 1177
1180 { 1178 {
1181 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 1179 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1182 } 1180 }
1183} 1181}
1184 1182
1185LauncherThumbReceiver::~LauncherThumbReceiver() 1183LauncherThumbReceiver::~LauncherThumbReceiver()
1186{ 1184{
1187 { 1185 {
1188 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 1186 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1189 } 1187 }
1190} 1188}
1191 1189
1192void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) 1190void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1193{ 1191{
1194 PixmapInfos pixinfos; 1192 PixmapInfos pixinfos;
1195 QDataStream stream( at, IO_ReadOnly ); 1193 QDataStream stream( at, IO_ReadOnly );
1196 1194
1197 /* we are just interested in thumbmails */ 1195 /* we are just interested in thumbmails */
1198 if ( str == "pixmapsHandled(PixmapList)" ) 1196 if ( str == "pixmapsHandled(PixmapList)" )
1199 stream >> pixinfos; 1197 stream >> pixinfos;
1200 1198
1201 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { 1199 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1202 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); 1200 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
1203 } 1201 }
1204} 1202}
1205 1203
1206void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) 1204void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1207{ 1205{
1208 PixmapInfo rItem; 1206 PixmapInfo rItem;
1209 rItem.file = file; 1207 rItem.file = file;
1210 rItem.width = width; 1208 rItem.width = width;
1211 rItem.height = height; 1209 rItem.height = height;
1212 m_inThumbNail.append(rItem); 1210 m_inThumbNail.append(rItem);
1213 QTimer::singleShot(2, this, SLOT(sendRequest())); 1211 QTimer::singleShot(2, this, SLOT(sendRequest()));
1214} 1212}
1215 1213
1216void LauncherThumbReceiver::sendRequest() 1214void LauncherThumbReceiver::sendRequest()
1217{ 1215{
1218 if (m_inThumbNail.count()>0) { 1216 if (m_inThumbNail.count()>0) {
1219 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); 1217 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1220 env << m_inThumbNail; 1218 env << m_inThumbNail;
1221 m_inThumbNail.clear(); 1219 m_inThumbNail.clear();
1222 } 1220 }
1223} 1221}
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 42186d3..15cd686 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -1,984 +1,986 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "server.h" 21#include "server.h"
22#include "serverapp.h" 22#include "serverapp.h"
23#include "startmenu.h" 23#include "startmenu.h"
24#include "launcher.h" 24#include "launcher.h"
25#include "transferserver.h" 25#include "transferserver.h"
26#include "qcopbridge.h" 26#include "qcopbridge.h"
27#include "irserver.h" 27#include "irserver.h"
28#include "packageslave.h" 28#include "packageslave.h"
29#include "calibrate.h" 29#include "calibrate.h"
30#include "qrsync.h" 30#include "qrsync.h"
31#include "syncdialog.h" 31#include "syncdialog.h"
32#include "shutdownimpl.h" 32#include "shutdownimpl.h"
33#include "applauncher.h" 33#include "applauncher.h"
34#if 0 34#if 0
35#include "suspendmonitor.h" 35#include "suspendmonitor.h"
36#endif 36#endif
37#include "documentlist.h" 37#include "documentlist.h"
38#include "qrr.h" 38#include "qrr.h"
39 39
40/* OPIE */ 40/* OPIE */
41#include <opie2/odebug.h> 41#include <opie2/odebug.h>
42#include <opie2/odevicebutton.h> 42#include <opie2/odevicebutton.h>
43#include <opie2/odevice.h> 43#include <opie2/odevice.h>
44#include <qtopia/applnk.h> 44#include <qtopia/applnk.h>
45#include <qtopia/private/categories.h> 45#include <qtopia/private/categories.h>
46#include <qtopia/mimetype.h> 46#include <qtopia/mimetype.h>
47#include <qtopia/config.h> 47#include <qtopia/config.h>
48#include <qtopia/resource.h> 48#include <qtopia/resource.h>
49#include <qtopia/version.h> 49#include <qtopia/version.h>
50#include <qtopia/storage.h> 50#include <qtopia/storage.h>
51#include <qtopia/qcopenvelope_qws.h> 51#include <qtopia/qcopenvelope_qws.h>
52#include <qtopia/global.h> 52#include <qtopia/global.h>
53using namespace Opie::Core; 53using namespace Opie::Core;
54 54
55/* QT */ 55/* QT */
56#include <qmainwindow.h> 56#include <qmainwindow.h>
57#include <qmessagebox.h> 57#include <qmessagebox.h>
58#include <qtimer.h> 58#include <qtimer.h>
59#include <qtextstream.h> 59#include <qtextstream.h>
60#include <qwindowsystem_qws.h> 60#include <qwindowsystem_qws.h>
61#include <qgfx_qws.h> 61#include <qgfx_qws.h>
62 62
63/* STD */ 63/* STD */
64#include <unistd.h> 64#include <unistd.h>
65#include <stdlib.h> 65#include <stdlib.h>
66 66
67extern QRect qt_maxWindowRect; 67extern QRect qt_maxWindowRect;
68 68
69static QWidget *calibrate(bool) 69static QWidget *calibrate(bool)
70{ 70{
71#ifdef Q_WS_QWS 71#ifdef Q_WS_QWS
72 Calibrate *c = new Calibrate; 72 Calibrate *c = new Calibrate;
73 c->show(); 73 c->show();
74 return c; 74 return c;
75#else 75#else
76 return 0; 76 return 0;
77#endif 77#endif
78} 78}
79 79
80#define FACTORY(T) \ 80#define FACTORY(T) \
81 static QWidget *new##T( bool maximized ) { \ 81 static QWidget *new##T( bool maximized ) { \
82 QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ 82 QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
83 if ( maximized ) { \ 83 if ( maximized ) { \
84 if ( qApp->desktop()->width() <= 350 ) { \ 84 if ( qApp->desktop()->width() <= 350 ) { \
85 w->showMaximized(); \ 85 w->showMaximized(); \
86 } else { \ 86 } else { \
87 w->resize( QSize( 300, 300 ) ); \ 87 w->resize( QSize( 300, 300 ) ); \
88 } \ 88 } \
89 } \ 89 } \
90 w->show(); \ 90 w->show(); \
91 return w; \ 91 return w; \
92 } 92 }
93 93
94 94
95#ifdef SINGLE_APP 95#ifdef SINGLE_APP
96#define APP(a,b,c,d) FACTORY(b) 96#define APP(a,b,c,d) FACTORY(b)
97#include "apps.h" 97#include "apps.h"
98#undef APP 98#undef APP
99#endif // SINGLE_APP 99#endif // SINGLE_APP
100 100
101static Global::Command builtins[] = { 101static Global::Command builtins[] = {
102 102
103#ifdef SINGLE_APP 103#ifdef SINGLE_APP
104#define APP(a,b,c,d) { a, new##b, c, d }, 104#define APP(a,b,c,d) { a, new##b, c, d },
105#include "apps.h" 105#include "apps.h"
106#undef APP 106#undef APP
107#endif 107#endif
108 108
109 /* FIXME defines need to be defined*/ 109 /* FIXME defines need to be defined*/
110#if !defined(OPIE_NO_BUILTIN_CALIBRATE) 110#if !defined(OPIE_NO_BUILTIN_CALIBRATE)
111 { "calibrate", calibrate, 1, 0 }, // No tr 111 { "calibrate", calibrate, 1, 0 }, // No tr
112#endif 112#endif
113#if !defined(OPIE_NO_BUILTIN_SHUTDOWN) 113#if !defined(OPIE_NO_BUILTIN_SHUTDOWN)
114 { "shutdown", Global::shutdown, 1, 0 }, // No tr 114 { "shutdown", Global::shutdown, 1, 0 }, // No tr
115// { "run", run, 1, 0 }, // No tr 115// { "run", run, 1, 0 }, // No tr
116#endif 116#endif
117 117
118 { 0, calibrate, 0, 0 }, 118 { 0, calibrate, 0, 0 },
119}; 119};
120 120
121#ifdef QPE_HAVE_DIRECT_ACCESS 121#ifdef QPE_HAVE_DIRECT_ACCESS
122extern void readyDirectAccess(QString cardInfo, QString installLocations); 122extern void readyDirectAccess(QString cardInfo, QString installLocations);
123extern const char *directAccessQueueFile(); 123extern const char *directAccessQueueFile();
124#endif 124#endif
125 125
126//--------------------------------------------------------------------------- 126//---------------------------------------------------------------------------
127 127
128 128
129//=========================================================================== 129//===========================================================================
130 130
131Server::Server() : 131Server::Server() :
132 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 132 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
133 qcopBridge( 0 ), 133 qcopBridge( 0 ),
134 transferServer( 0 ), 134 transferServer( 0 ),
135 packageHandler( 0 ), 135 packageHandler( 0 ),
136 syncDialog( 0 ) 136 syncDialog( 0 )
137{ 137{
138 Global::setBuiltinCommands(builtins); 138 Global::setBuiltinCommands(builtins);
139 139
140 tid_xfer = 0; 140 tid_xfer = 0;
141 /* ### FIXME ### */ 141 /* ### FIXME ### */
142/* tid_today = startTimer(3600*2*1000);*/ 142/* tid_today = startTimer(3600*2*1000);*/
143 last_today_show = QDate::currentDate(); 143 last_today_show = QDate::currentDate();
144 144
145#warning FIXME support TempScreenSaverMode 145#warning FIXME support TempScreenSaverMode
146#if 0 146#if 0
147 tsmMonitor = new TempScreenSaverMode(); 147 tsmMonitor = new TempScreenSaverMode();
148 connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); 148 connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) );
149#endif 149#endif
150 150
151 serverGui = new Launcher; 151 serverGui = new Launcher;
152 serverGui->createGUI(); 152 serverGui->createGUI();
153 153
154 docList = new DocumentList( serverGui ); 154 docList = new DocumentList( serverGui );
155 appLauncher = new AppLauncher(this); 155 appLauncher = new AppLauncher(this);
156 connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); 156 connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) );
157 connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); 157 connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) );
158 connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); 158 connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) );
159 159
160 storage = new StorageInfo( this ); 160 storage = new StorageInfo( this );
161 connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); 161 connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) );
162 162
163 163
164#ifdef QPE_HAVE_DIRECT_ACCESS 164#ifdef QPE_HAVE_DIRECT_ACCESS
165 QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this ); 165 QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this );
166 connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )), 166 connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )),
167 this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); 167 this, SLOT(desktopMessage( const QCString &, const QByteArray & )) );
168#endif 168#endif
169 169
170 // start services 170 // start services
171 startTransferServer(); 171 startTransferServer();
172 (void) new IrServer( this ); 172 (void) new IrServer( this );
173 173
174 packageHandler = new PackageHandler( this ); 174 packageHandler = new PackageHandler( this );
175 connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), 175 connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)),
176 this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); 176 this,SLOT(activate(const Opie::Core::ODeviceButton*,bool)));
177 177
178 setGeometry( -10, -10, 9, 9 ); 178 setGeometry( -10, -10, 9, 9 );
179 179
180 QCopChannel *channel = new QCopChannel("QPE/System", this); 180 QCopChannel *channel = new QCopChannel("QPE/System", this);
181 connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), 181 connect(channel, SIGNAL(received(const QCString&,const QByteArray&)),
182 this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); 182 this, SLOT(systemMsg(const QCString&,const QByteArray&)) );
183 183
184 QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); 184 QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this );
185 connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), 185 connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)),
186 this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); 186 this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) );
187 187
188 connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); 188 connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) );
189 connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); 189 connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) );
190 190
191 preloadApps(); 191 preloadApps();
192} 192}
193 193
194void Server::show() 194void Server::show()
195{ 195{
196 ServerApplication::login(TRUE); 196 ServerApplication::login(TRUE);
197 QWidget::show(); 197 QWidget::show();
198} 198}
199 199
200Server::~Server() 200Server::~Server()
201{ 201{
202 serverGui->destroyGUI(); 202 serverGui->destroyGUI();
203 delete docList; 203 delete docList;
204 delete qcopBridge; 204 delete qcopBridge;
205 delete transferServer; 205 delete transferServer;
206 delete serverGui; 206 delete serverGui;
207#if 0 207#if 0
208 delete tsmMonitor; 208 delete tsmMonitor;
209#endif 209#endif
210} 210}
211 211
212 212
213static bool hasVisibleWindow(const QString& clientname, bool partial) 213static bool hasVisibleWindow(const QString& clientname, bool partial)
214{ 214{
215#ifdef QWS 215#ifdef QWS
216 const QList<QWSWindow> &list = qwsServer->clientWindows(); 216 const QList<QWSWindow> &list = qwsServer->clientWindows();
217 QWSWindow* w; 217 QWSWindow* w;
218 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 218 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
219 if ( w->client()->identity() == clientname ) { 219 if ( w->client()->identity() == clientname ) {
220 if ( partial && !w->isFullyObscured() ) 220 if ( partial && !w->isFullyObscured() )
221 return TRUE; 221 return TRUE;
222 if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { 222 if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) {
223# if QT_VERSION < 0x030000 223# if QT_VERSION < 0x030000
224 QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, 224 QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect,
225 QSize(qt_screen->width(),qt_screen->height()) ); 225 QSize(qt_screen->width(),qt_screen->height()) );
226# else 226# else
227 QRect mwr = qt_maxWindowRect; 227 QRect mwr = qt_maxWindowRect;
228# endif 228# endif
229 if ( mwr.contains(w->requested().boundingRect()) ) 229 if ( mwr.contains(w->requested().boundingRect()) )
230 return TRUE; 230 return TRUE;
231 } 231 }
232 } 232 }
233 } 233 }
234#endif 234#endif
235 return FALSE; 235 return FALSE;
236} 236}
237 237
238void Server::activate(const ODeviceButton* button, bool held) 238void Server::activate(const ODeviceButton* button, bool held)
239{ 239{
240 Global::terminateBuiltin("calibrate"); // No tr 240 Global::terminateBuiltin("calibrate"); // No tr
241 OQCopMessage om; 241 OQCopMessage om;
242 if ( held ) { 242 if ( held ) {
243 om = button->heldAction(); 243 om = button->heldAction();
244 } else { 244 } else {
245 om = button->pressedAction(); 245 om = button->pressedAction();
246 } 246 }
247 247
248 if ( om.channel() != "ignore" ) 248 if ( om.channel() != "ignore" )
249 om.send(); 249 om.send();
250 250
251 // A button with no action defined, will return a null ServiceRequest. Don't attempt 251 // A button with no action defined, will return a null ServiceRequest. Don't attempt
252 // to send/do anything with this as it will crash 252 // to send/do anything with this as it will crash
253 /* ### FIXME */ 253 /* ### FIXME */
254#if 0 254#if 0
255 if ( !sr.isNull() ) { 255 if ( !sr.isNull() ) {
256 QString app = sr.app(); 256 QString app = sr.app();
257 bool vis = hasVisibleWindow(app, app != "qpe"); 257 bool vis = hasVisibleWindow(app, app != "qpe");
258 if ( sr.message() == "raise()" && vis ) { 258 if ( sr.message() == "raise()" && vis ) {
259 sr.setMessage("nextView()"); 259 sr.setMessage("nextView()");
260 } else { 260 } else {
261 // "back door" 261 // "back door"
262 sr << (int)vis; 262 sr << (int)vis;
263 } 263 }
264 264
265 sr.send(); 265 sr.send();
266 } 266 }
267#endif 267#endif
268} 268}
269 269
270 270
271#ifdef Q_WS_QWS 271#ifdef Q_WS_QWS
272 272
273typedef struct KeyOverride { 273typedef struct KeyOverride {
274 ushort scan_code; 274 ushort scan_code;
275 QWSServer::KeyMap map; 275 QWSServer::KeyMap map;
276}; 276};
277 277
278 278
279static const KeyOverride jp109keys[] = { 279static const KeyOverride jp109keys[] = {
280 { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, 280 { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } },
281 { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, 281 { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } },
282 { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, 282 { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } },
283 { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, 283 { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } },
284 { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, 284 { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } },
285 { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } }, 285 { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } },
286 { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, 286 { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } },
287 { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } }, 287 { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } },
288 { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, 288 { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } },
289 { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } }, 289 { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } },
290 { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, 290 { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } },
291 { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, 291 { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } },
292 { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } }, 292 { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } },
293 { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, 293 { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } },
294 { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } }, 294 { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } },
295 { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, 295 { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } },
296 { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } }, 296 { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } },
297 { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } }, 297 { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } },
298 { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } }, 298 { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } },
299 { 0x00, { 0, 0xffff, 0xffff, 0xffff } } 299 { 0x00, { 0, 0xffff, 0xffff, 0xffff } }
300}; 300};
301 301
302bool Server::setKeyboardLayout( const QString &kb ) 302bool Server::setKeyboardLayout( const QString &kb )
303{ 303{
304 //quick demo version that can be extended 304 //quick demo version that can be extended
305 305
306 QIntDict<QWSServer::KeyMap> *om = 0; 306 QIntDict<QWSServer::KeyMap> *om = 0;
307 if ( kb == "us101" ) { // No tr 307 if ( kb == "us101" ) { // No tr
308 om = 0; 308 om = 0;
309 } else if ( kb == "jp109" ) { 309 } else if ( kb == "jp109" ) {
310 om = new QIntDict<QWSServer::KeyMap>(37); 310 om = new QIntDict<QWSServer::KeyMap>(37);
311 const KeyOverride *k = jp109keys; 311 const KeyOverride *k = jp109keys;
312 while ( k->scan_code ) { 312 while ( k->scan_code ) {
313 om->insert( k->scan_code, &k->map ); 313 om->insert( k->scan_code, &k->map );
314 k++; 314 k++;
315 } 315 }
316 } 316 }
317 QWSServer::setOverrideKeys( om ); 317 QWSServer::setOverrideKeys( om );
318 318
319 return TRUE; 319 return TRUE;
320} 320}
321#endif 321#endif
322 322
323void Server::systemMsg(const QCString &msg, const QByteArray &data) 323void Server::systemMsg(const QCString &msg, const QByteArray &data)
324{ 324{
325 QDataStream stream( data, IO_ReadOnly ); 325 QDataStream stream( data, IO_ReadOnly );
326 326
327 if ( msg == "securityChanged()" ) { 327 if ( msg == "securityChanged()" ) {
328 if ( transferServer ) 328 if ( transferServer )
329 transferServer->authorizeConnections(); 329 transferServer->authorizeConnections();
330 330
331 if ( qcopBridge ) 331 if ( qcopBridge )
332 qcopBridge->authorizeConnections(); 332 qcopBridge->authorizeConnections();
333#warning FIXME support TempScreenSaverMode 333#warning FIXME support TempScreenSaverMode
334#if 0 334#if 0
335 } else if ( msg == "setTempScreenSaverMode(int,int)" ) { 335 } else if ( msg == "setTempScreenSaverMode(int,int)" ) {
336 int mode, pid; 336 int mode, pid;
337 stream >> mode >> pid; 337 stream >> mode >> pid;
338 tsmMonitor->setTempMode(mode, pid); 338 tsmMonitor->setTempMode(mode, pid);
339#endif 339#endif
340 } else if ( msg == "linkChanged(QString)" ) { 340 } else if ( msg == "linkChanged(QString)" ) {
341 QString link; 341 QString link;
342 stream >> link; 342 stream >> link;
343 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; 343 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl;
344 docList->linkChanged(link); 344 docList->linkChanged(link);
345 } else if (msg =="reforceDocuments()") {
346 docList->reforceDocuments();
345 } else if ( msg == "serviceChanged(QString)" ) { 347 } else if ( msg == "serviceChanged(QString)" ) {
346 MimeType::updateApplications(); 348 MimeType::updateApplications();
347 } else if ( msg == "mkdir(QString)" ) { 349 } else if ( msg == "mkdir(QString)" ) {
348 QString dir; 350 QString dir;
349 stream >> dir; 351 stream >> dir;
350 if ( !dir.isEmpty() ) 352 if ( !dir.isEmpty() )
351 mkdir( dir ); 353 mkdir( dir );
352 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 354 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
353 QString baseFile, sigFile; 355 QString baseFile, sigFile;
354 stream >> baseFile >> sigFile; 356 stream >> baseFile >> sigFile;
355 QRsync::generateSignature( baseFile, sigFile ); 357 QRsync::generateSignature( baseFile, sigFile );
356 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 358 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
357 QString baseFile, sigFile, deltaFile; 359 QString baseFile, sigFile, deltaFile;
358 stream >> baseFile >> sigFile >> deltaFile; 360 stream >> baseFile >> sigFile >> deltaFile;
359 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 361 QRsync::generateDiff( baseFile, sigFile, deltaFile );
360 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 362 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
361 QString baseFile, deltaFile; 363 QString baseFile, deltaFile;
362 stream >> baseFile >> deltaFile; 364 stream >> baseFile >> deltaFile;
363 if ( !QFile::exists( baseFile ) ) { 365 if ( !QFile::exists( baseFile ) ) {
364 QFile f( baseFile ); 366 QFile f( baseFile );
365 f.open( IO_WriteOnly ); 367 f.open( IO_WriteOnly );
366 f.close(); 368 f.close();
367 } 369 }
368 QRsync::applyDiff( baseFile, deltaFile ); 370 QRsync::applyDiff( baseFile, deltaFile );
369#ifndef QT_NO_COP 371#ifndef QT_NO_COP
370 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 372 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
371 e << baseFile; 373 e << baseFile;
372#endif 374#endif
373 } else if ( msg == "rdiffCleanup()" ) { 375 } else if ( msg == "rdiffCleanup()" ) {
374 mkdir( "/tmp/rdiff" ); 376 mkdir( "/tmp/rdiff" );
375 QDir dir; 377 QDir dir;
376 dir.setPath( "/tmp/rdiff" ); 378 dir.setPath( "/tmp/rdiff" );
377 QStringList entries = dir.entryList(); 379 QStringList entries = dir.entryList();
378 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 380 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
379 dir.remove( *it ); 381 dir.remove( *it );
380 } else if ( msg == "sendHandshakeInfo()" ) { 382 } else if ( msg == "sendHandshakeInfo()" ) {
381 QString home = getenv( "HOME" ); 383 QString home = getenv( "HOME" );
382#ifndef QT_NO_COP 384#ifndef QT_NO_COP
383 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 385 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
384 e << home; 386 e << home;
385 int locked = (int) ServerApplication::screenLocked(); 387 int locked = (int) ServerApplication::screenLocked();
386 e << locked; 388 e << locked;
387#endif 389#endif
388 } else if ( msg == "sendVersionInfo()" ) { 390 } else if ( msg == "sendVersionInfo()" ) {
389 /* 391 /*
390 * @&$*! Qtopiadesktop relies on the major number 392 * @&$*! Qtopiadesktop relies on the major number
391 * to start with 1. (or 2 as the case of version 2.1 will be) 393 * to start with 1. (or 2 as the case of version 2.1 will be)
392 * we need to fake 1.7 to be able 394 * we need to fake 1.7 to be able
393 * to sync with Qtopiadesktop 1.7. 395 * to sync with Qtopiadesktop 1.7.
394 * We'll send it Opie's version in the platform string for now, 396 * We'll send it Opie's version in the platform string for now,
395 * until such time when QD gets rewritten correctly. 397 * until such time when QD gets rewritten correctly.
396 */ 398 */
397 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); 399 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" );
398 400
399 QString opiename = "Opie "+QString(QPE_VERSION); 401 QString opiename = "Opie "+QString(QPE_VERSION);
400 QString QDVersion="1.7"; 402 QString QDVersion="1.7";
401 e << QDVersion << opiename; 403 e << QDVersion << opiename;
402 404
403 } else if ( msg == "sendCardInfo()" ) { 405 } else if ( msg == "sendCardInfo()" ) {
404#ifndef QT_NO_COP 406#ifndef QT_NO_COP
405 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 407 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
406#endif 408#endif
407 storage->update(); 409 storage->update();
408 const QList<FileSystem> &fs = storage->fileSystems(); 410 const QList<FileSystem> &fs = storage->fileSystems();
409 QListIterator<FileSystem> it ( fs ); 411 QListIterator<FileSystem> it ( fs );
410 QString s; 412 QString s;
411 QString homeDir = getenv("HOME"); 413 QString homeDir = getenv("HOME");
412 QString homeFs, homeFsPath; 414 QString homeFs, homeFsPath;
413 for ( ; it.current(); ++it ) { 415 for ( ; it.current(); ++it ) {
414 int k4 = (*it)->blockSize()/256; 416 int k4 = (*it)->blockSize()/256;
415 if ( (*it)->isRemovable() ) { 417 if ( (*it)->isRemovable() ) {
416 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr 418 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr
417 + QString::number( (*it)->availBlocks() * k4/4 ) 419 + QString::number( (*it)->availBlocks() * k4/4 )
418 + "K " + (*it)->options() + ";"; 420 + "K " + (*it)->options() + ";";
419 } else if ( homeDir.contains( (*it)->path() ) && 421 } else if ( homeDir.contains( (*it)->path() ) &&
420 (*it)->path().length() > homeFsPath.length() ) { 422 (*it)->path().length() > homeFsPath.length() ) {
421 homeFsPath = (*it)->path(); 423 homeFsPath = (*it)->path();
422 homeFs = 424 homeFs =
423 (*it)->name() + "=" + homeDir + "/Documents " // No tr 425 (*it)->name() + "=" + homeDir + "/Documents " // No tr
424 + QString::number( (*it)->availBlocks() * k4/4 ) 426 + QString::number( (*it)->availBlocks() * k4/4 )
425 + "K " + (*it)->options() + ";"; 427 + "K " + (*it)->options() + ";";
426 } 428 }
427 } 429 }
428 if ( !homeFs.isEmpty() ) 430 if ( !homeFs.isEmpty() )
429 s += homeFs; 431 s += homeFs;
430#ifndef QT_NO_COP 432#ifndef QT_NO_COP
431 e << s; 433 e << s;
432#endif 434#endif
433 } else if ( msg == "sendInstallLocations()" ) { 435 } else if ( msg == "sendInstallLocations()" ) {
434#ifndef QT_NO_COP 436#ifndef QT_NO_COP
435 QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); 437 QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" );
436 e << installLocationsString(); 438 e << installLocationsString();
437#endif 439#endif
438 } else if ( msg == "sendSyncDate(QString)" ) { 440 } else if ( msg == "sendSyncDate(QString)" ) {
439 QString app; 441 QString app;
440 stream >> app; 442 stream >> app;
441 Config cfg( "qpe" ); 443 Config cfg( "qpe" );
442 cfg.setGroup("SyncDate"); 444 cfg.setGroup("SyncDate");
443#ifndef QT_NO_COP 445#ifndef QT_NO_COP
444 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 446 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
445 e << app << cfg.readEntry( app ); 447 e << app << cfg.readEntry( app );
446#endif 448#endif
447 //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " 449 //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response "
448 // << cfg.readEntry( app ).latin1() << oendl; 450 // << cfg.readEntry( app ).latin1() << oendl;
449 } else if ( msg == "setSyncDate(QString,QString)" ) { 451 } else if ( msg == "setSyncDate(QString,QString)" ) {
450 QString app, date; 452 QString app, date;
451 stream >> app >> date; 453 stream >> app >> date;
452 Config cfg( "qpe" ); 454 Config cfg( "qpe" );
453 cfg.setGroup("SyncDate"); 455 cfg.setGroup("SyncDate");
454 cfg.writeEntry( app, date ); 456 cfg.writeEntry( app, date );
455 //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; 457 //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl;
456 } else if ( msg == "startSync(QString)" ) { 458 } else if ( msg == "startSync(QString)" ) {
457 QString what; 459 QString what;
458 stream >> what; 460 stream >> what;
459 delete syncDialog; 461 delete syncDialog;
460 syncDialog = new SyncDialog( this, what ); 462 syncDialog = new SyncDialog( this, what );
461 syncDialog->show(); 463 syncDialog->show();
462 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); 464 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) );
463 } else if ( msg == "stopSync()") { 465 } else if ( msg == "stopSync()") {
464 delete syncDialog; 466 delete syncDialog;
465 syncDialog = 0; 467 syncDialog = 0;
466 } else if (msg == "restoreDone(QString)") { 468 } else if (msg == "restoreDone(QString)") {
467 docList->restoreDone(); 469 docList->restoreDone();
468 } else if ( msg == "getAllDocLinks()" ) { 470 } else if ( msg == "getAllDocLinks()" ) {
469 docList->sendAllDocLinks(); 471 docList->sendAllDocLinks();
470 } 472 }
471#ifdef QPE_HAVE_DIRECT_ACCESS 473#ifdef QPE_HAVE_DIRECT_ACCESS
472 else if ( msg == "prepareDirectAccess()" ) { 474 else if ( msg == "prepareDirectAccess()" ) {
473 prepareDirectAccess(); 475 prepareDirectAccess();
474 } else if ( msg == "postDirectAccess()" ) { 476 } else if ( msg == "postDirectAccess()" ) {
475 postDirectAccess(); 477 postDirectAccess();
476 } 478 }
477#endif 479#endif
478#ifdef Q_WS_QWS 480#ifdef Q_WS_QWS
479 481
480 else if ( msg == "setMouseProto(QString)" ) { 482 else if ( msg == "setMouseProto(QString)" ) {
481 QString mice; 483 QString mice;
482 stream >> mice; 484 stream >> mice;
483 setenv("QWS_MOUSE_PROTO",mice.latin1(),1); 485 setenv("QWS_MOUSE_PROTO",mice.latin1(),1);
484 qwsServer->openMouse(); 486 qwsServer->openMouse();
485 } else if ( msg == "setKeyboard(QString)" ) { 487 } else if ( msg == "setKeyboard(QString)" ) {
486 QString kb; 488 QString kb;
487 stream >> kb; 489 stream >> kb;
488 setenv("QWS_KEYBOARD",kb.latin1(),1); 490 setenv("QWS_KEYBOARD",kb.latin1(),1);
489 qwsServer->openKeyboard(); 491 qwsServer->openKeyboard();
490 } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { 492 } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) {
491 int delay, period; 493 int delay, period;
492 stream >> delay >> period; 494 stream >> delay >> period;
493 qwsSetKeyboardAutoRepeat( delay, period ); 495 qwsSetKeyboardAutoRepeat( delay, period );
494 Config cfg( "qpe" ); 496 Config cfg( "qpe" );
495 cfg.setGroup("Keyboard"); 497 cfg.setGroup("Keyboard");
496 cfg.writeEntry( "RepeatDelay", delay ); 498 cfg.writeEntry( "RepeatDelay", delay );
497 cfg.writeEntry( "RepeatPeriod", period ); 499 cfg.writeEntry( "RepeatPeriod", period );
498 } else if ( msg == "setKeyboardLayout(QString)" ) { 500 } else if ( msg == "setKeyboardLayout(QString)" ) {
499 QString kb; 501 QString kb;
500 stream >> kb; 502 stream >> kb;
501 setKeyboardLayout( kb ); 503 setKeyboardLayout( kb );
502 Config cfg( "qpe" ); 504 Config cfg( "qpe" );
503 cfg.setGroup("Keyboard"); 505 cfg.setGroup("Keyboard");
504 cfg.writeEntry( "Layout", kb ); 506 cfg.writeEntry( "Layout", kb );
505 } else if ( msg == "autoStart(QString)" ) { 507 } else if ( msg == "autoStart(QString)" ) {
506 QString appName; 508 QString appName;
507 stream >> appName; 509 stream >> appName;
508 Config cfg( "autostart" ); 510 Config cfg( "autostart" );
509 cfg.setGroup( "AutoStart" ); 511 cfg.setGroup( "AutoStart" );
510 if ( appName.compare("clear") == 0){ 512 if ( appName.compare("clear") == 0){
511 cfg.writeEntry("Apps", ""); 513 cfg.writeEntry("Apps", "");
512 } 514 }
513 } else if ( msg == "autoStart(QString,QString)" ) { 515 } else if ( msg == "autoStart(QString,QString)" ) {
514 QString modifier, appName; 516 QString modifier, appName;
515 stream >> modifier >> appName; 517 stream >> modifier >> appName;
516 Config cfg( "autostart" ); 518 Config cfg( "autostart" );
517 cfg.setGroup( "AutoStart" ); 519 cfg.setGroup( "AutoStart" );
518 if ( modifier.compare("add") == 0 ){ 520 if ( modifier.compare("add") == 0 ){
519 // only add if appname is entered 521 // only add if appname is entered
520 if (!appName.isEmpty()) { 522 if (!appName.isEmpty()) {
521 cfg.writeEntry("Apps", appName); 523 cfg.writeEntry("Apps", appName);
522 } 524 }
523 } else if (modifier.compare("remove") == 0 ) { 525 } else if (modifier.compare("remove") == 0 ) {
524 // need to change for multiple entries 526 // need to change for multiple entries
525 // actually remove is right now simular to clear, but in future there 527 // actually remove is right now simular to clear, but in future there
526 // should be multiple apps in autostart possible. 528 // should be multiple apps in autostart possible.
527 QString checkName; 529 QString checkName;
528 checkName = cfg.readEntry("Apps", ""); 530 checkName = cfg.readEntry("Apps", "");
529 if (checkName == appName) { 531 if (checkName == appName) {
530 cfg.writeEntry("Apps", ""); 532 cfg.writeEntry("Apps", "");
531 } 533 }
532 } 534 }
533 // case the autostart feature should be delayed 535 // case the autostart feature should be delayed
534 } else if ( msg == "autoStart(QString,QString,QString)") { 536 } else if ( msg == "autoStart(QString,QString,QString)") {
535 QString modifier, appName, delay; 537 QString modifier, appName, delay;
536 stream >> modifier >> appName >> delay; 538 stream >> modifier >> appName >> delay;
537 Config cfg( "autostart" ); 539 Config cfg( "autostart" );
538 540
539 cfg.setGroup( "AutoStart" ); 541 cfg.setGroup( "AutoStart" );
540 if ( modifier.compare("add") == 0 ){ 542 if ( modifier.compare("add") == 0 ){
541 // only add it appname is entered 543 // only add it appname is entered
542 if (!appName.isEmpty()) { 544 if (!appName.isEmpty()) {
543 cfg.writeEntry("Apps", appName); 545 cfg.writeEntry("Apps", appName);
544 cfg.writeEntry("Delay", delay); 546 cfg.writeEntry("Delay", delay);
545 } 547 }
546 } 548 }
547 } 549 }
548#endif 550#endif
549} 551}
550 552
551QString Server::cardInfoString() 553QString Server::cardInfoString()
552{ 554{
553 storage->update(); 555 storage->update();
554 const QList<FileSystem> &fs = storage->fileSystems(); 556 const QList<FileSystem> &fs = storage->fileSystems();
555 QListIterator<FileSystem> it ( fs ); 557 QListIterator<FileSystem> it ( fs );
556 QString s; 558 QString s;
557 QString homeDir = getenv("HOME"); 559 QString homeDir = getenv("HOME");
558 QString homeFs, homeFsPath; 560 QString homeFs, homeFsPath;
559 for ( ; it.current(); ++it ) { 561 for ( ; it.current(); ++it ) {
560 int k4 = (*it)->blockSize()/256; 562 int k4 = (*it)->blockSize()/256;
561 if ( (*it)->isRemovable() ) { 563 if ( (*it)->isRemovable() ) {
562 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr 564 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr
563 + QString::number( (*it)->availBlocks() * k4/4 ) 565 + QString::number( (*it)->availBlocks() * k4/4 )
564 + "K " + (*it)->options() + ";"; 566 + "K " + (*it)->options() + ";";
565 } else if ( homeDir.contains( (*it)->path() ) && 567 } else if ( homeDir.contains( (*it)->path() ) &&
566 (*it)->path().length() > homeFsPath.length() ) { 568 (*it)->path().length() > homeFsPath.length() ) {
567 homeFsPath = (*it)->path(); 569 homeFsPath = (*it)->path();
568 homeFs = 570 homeFs =
569 (*it)->name() + "=" + homeDir + "/Documents " // No tr 571 (*it)->name() + "=" + homeDir + "/Documents " // No tr
570 + QString::number( (*it)->availBlocks() * k4/4 ) 572 + QString::number( (*it)->availBlocks() * k4/4 )
571 + "K " + (*it)->options() + ";"; 573 + "K " + (*it)->options() + ";";
572 } 574 }
573 } 575 }
574 if ( !homeFs.isEmpty() ) 576 if ( !homeFs.isEmpty() )
575 s += homeFs; 577 s += homeFs;
576 return s; 578 return s;
577} 579}
578 580
579QString Server::installLocationsString() 581QString Server::installLocationsString()
580{ 582{
581 storage->update(); 583 storage->update();
582 const QList<FileSystem> &fs = storage->fileSystems(); 584 const QList<FileSystem> &fs = storage->fileSystems();
583 QListIterator<FileSystem> it ( fs ); 585 QListIterator<FileSystem> it ( fs );
584 QString s; 586 QString s;
585 QString homeDir = getenv("HOME"); 587 QString homeDir = getenv("HOME");
586 QString homeFs, homeFsPath; 588 QString homeFs, homeFsPath;
587 for ( ; it.current(); ++it ) { 589 for ( ; it.current(); ++it ) {
588 int k4 = (*it)->blockSize()/256; 590 int k4 = (*it)->blockSize()/256;
589 if ( (*it)->isRemovable() ) { 591 if ( (*it)->isRemovable() ) {
590 s += (*it)->name() + "=" + (*it)->path() + " " // No tr 592 s += (*it)->name() + "=" + (*it)->path() + " " // No tr
591 + QString::number( (*it)->availBlocks() * k4/4 ) 593 + QString::number( (*it)->availBlocks() * k4/4 )
592 + "K " + (*it)->options() + ";"; 594 + "K " + (*it)->options() + ";";
593 } else if ( homeDir.contains( (*it)->path() ) && 595 } else if ( homeDir.contains( (*it)->path() ) &&
594 (*it)->path().length() > homeFsPath.length() ) { 596 (*it)->path().length() > homeFsPath.length() ) {
595 homeFsPath = (*it)->path(); 597 homeFsPath = (*it)->path();
596 homeFs = 598 homeFs =
597 (*it)->name() + "=" + homeDir + " " // No tr 599 (*it)->name() + "=" + homeDir + " " // No tr
598 + QString::number( (*it)->availBlocks() * k4/4 ) 600 + QString::number( (*it)->availBlocks() * k4/4 )
599 + "K " + (*it)->options() + ";"; 601 + "K " + (*it)->options() + ";";
600 } 602 }
601 } 603 }
602 if ( !homeFs.isEmpty() ) 604 if ( !homeFs.isEmpty() )
603 s = homeFs + s; 605 s = homeFs + s;
604 return s; 606 return s;
605} 607}
606 608
607void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) 609void Server::receiveTaskBar(const QCString &msg, const QByteArray &data)
608{ 610{
609 QDataStream stream( data, IO_ReadOnly ); 611 QDataStream stream( data, IO_ReadOnly );
610 612
611 if ( msg == "reloadApps()" ) { 613 if ( msg == "reloadApps()" ) {
612 docList->reloadAppLnks(); 614 docList->reloadAppLnks();
613 } else if ( msg == "soundAlarm()" ) { 615 } else if ( msg == "soundAlarm()" ) {
614 ServerApplication::soundAlarm(); 616 ServerApplication::soundAlarm();
615 } else if ( msg == "setLed(int,bool)" ) { 617 } else if ( msg == "setLed(int,bool)" ) {
616 int led, status; 618 int led, status;
617 stream >> led >> status; 619 stream >> led >> status;
618 620
619 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); 621 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( );
620 if ( ll. count ( )) { 622 if ( ll. count ( )) {
621 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; 623 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0];
622 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); 624 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow );
623 625
624 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); 626 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off );
625 } 627 }
626 } 628 }
627} 629}
628 630
629void Server::cancelSync() 631void Server::cancelSync()
630{ 632{
631#ifndef QT_NO_COP 633#ifndef QT_NO_COP
632 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 634 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
633#endif 635#endif
634 delete syncDialog; 636 delete syncDialog;
635 syncDialog = 0; 637 syncDialog = 0;
636} 638}
637 639
638bool Server::mkdir(const QString &localPath) 640bool Server::mkdir(const QString &localPath)
639{ 641{
640 QDir fullDir(localPath); 642 QDir fullDir(localPath);
641 if (fullDir.exists()) 643 if (fullDir.exists())
642 return true; 644 return true;
643 645
644 // at this point the directory doesn't exist 646 // at this point the directory doesn't exist
645 // go through the directory tree and start creating the direcotories 647 // go through the directory tree and start creating the direcotories
646 // that don't exist; if we can't create the directories, return false 648 // that don't exist; if we can't create the directories, return false
647 649
648 QString dirSeps = "/"; 650 QString dirSeps = "/";
649 int dirIndex = localPath.find(dirSeps); 651 int dirIndex = localPath.find(dirSeps);
650 QString checkedPath; 652 QString checkedPath;
651 653
652 // didn't find any seps; weird, use the cur dir instead 654 // didn't find any seps; weird, use the cur dir instead
653 if (dirIndex == -1) { 655 if (dirIndex == -1) {
654 //odebug << "No seperators found in path " << localPath << "" << oendl; 656 //odebug << "No seperators found in path " << localPath << "" << oendl;
655 checkedPath = QDir::currentDirPath(); 657 checkedPath = QDir::currentDirPath();
656 } 658 }
657 659
658 while (checkedPath != localPath) { 660 while (checkedPath != localPath) {
659 // no more seperators found, use the local path 661 // no more seperators found, use the local path
660 if (dirIndex == -1) { 662 if (dirIndex == -1) {
661 checkedPath = localPath; 663 checkedPath = localPath;
662 } else { 664 } else {
663 // the next directory to check 665 // the next directory to check
664 checkedPath = localPath.left(dirIndex) + "/"; 666 checkedPath = localPath.left(dirIndex) + "/";
665 // advance the iterator; the next dir seperator 667 // advance the iterator; the next dir seperator
666 dirIndex = localPath.find(dirSeps, dirIndex+1); 668 dirIndex = localPath.find(dirSeps, dirIndex+1);
667 } 669 }
668 670
669 QDir checkDir(checkedPath); 671 QDir checkDir(checkedPath);
670 if (!checkDir.exists()) { 672 if (!checkDir.exists()) {
671 //odebug << "mkdir making dir " << checkedPath << "" << oendl; 673 //odebug << "mkdir making dir " << checkedPath << "" << oendl;
672 674
673 if (!checkDir.mkdir(checkedPath)) { 675 if (!checkDir.mkdir(checkedPath)) {
674 odebug << "Unable to make directory " << checkedPath << "" << oendl; 676 odebug << "Unable to make directory " << checkedPath << "" << oendl;
675 return FALSE; 677 return FALSE;
676 } 678 }
677 } 679 }
678 680
679 } 681 }
680 return TRUE; 682 return TRUE;
681} 683}
682 684
683void Server::styleChange( QStyle &s ) 685void Server::styleChange( QStyle &s )
684{ 686{
685 QWidget::styleChange( s ); 687 QWidget::styleChange( s );
686} 688}
687 689
688void Server::startTransferServer() 690void Server::startTransferServer()
689{ 691{
690 if ( !qcopBridge ) { 692 if ( !qcopBridge ) {
691 // start qcop bridge server 693 // start qcop bridge server
692 qcopBridge = new QCopBridge( 4243 ); 694 qcopBridge = new QCopBridge( 4243 );
693 if ( qcopBridge->ok() ) { 695 if ( qcopBridge->ok() ) {
694 // ... OK 696 // ... OK
695 connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), 697 connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)),
696 this, SLOT(syncConnectionClosed(const QHostAddress&)) ); 698 this, SLOT(syncConnectionClosed(const QHostAddress&)) );
697 } else { 699 } else {
698 delete qcopBridge; 700 delete qcopBridge;
699 qcopBridge = 0; 701 qcopBridge = 0;
700 } 702 }
701 } 703 }
702 704
703 if ( !transferServer ) { 705 if ( !transferServer ) {
704 // start transfer server 706 // start transfer server
705 transferServer = new TransferServer( 4242 ); 707 transferServer = new TransferServer( 4242 );
706 if ( transferServer->ok() ) { 708 if ( transferServer->ok() ) {
707 // ... OK 709 // ... OK
708 } else { 710 } else {
709 delete transferServer; 711 delete transferServer;
710 transferServer = 0; 712 transferServer = 0;
711 } 713 }
712 714
713 if ( !qcopBridge ) 715 if ( !qcopBridge )
714 tid_xfer = startTimer( 2000 ); 716 tid_xfer = startTimer( 2000 );
715 } 717 }
716} 718}
717 719
718void Server::timerEvent( QTimerEvent *e ) 720void Server::timerEvent( QTimerEvent *e )
719{ 721{
720 if ( e->timerId() == tid_xfer ) { 722 if ( e->timerId() == tid_xfer ) {
721 killTimer( tid_xfer ); 723 killTimer( tid_xfer );
722 tid_xfer = 0; 724 tid_xfer = 0;
723 startTransferServer(); 725 startTransferServer();
724 } 726 }
725#if 0 727#if 0
726 /* ### FIXME today startin */ 728 /* ### FIXME today startin */
727 else if ( e->timerId() == tid_today ) { 729 else if ( e->timerId() == tid_today ) {
728 QDate today = QDate::currentDate(); 730 QDate today = QDate::currentDate();
729 if ( today != last_today_show ) { 731 if ( today != last_today_show ) {
730 last_today_show = today; 732 last_today_show = today;
731 Config cfg("today"); 733 Config cfg("today");
732 cfg.setGroup("Start"); 734 cfg.setGroup("Start");
733#ifndef QPE_DEFAULT_TODAY_MODE 735#ifndef QPE_DEFAULT_TODAY_MODE
734#define QPE_DEFAULT_TODAY_MODE "Never" 736#define QPE_DEFAULT_TODAY_MODE "Never"
735#endif 737#endif
736 if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { 738 if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) {
737 QCopEnvelope env(Service::channel("today"),"raise()"); 739 QCopEnvelope env(Service::channel("today"),"raise()");
738 } 740 }
739 } 741 }
740 } 742 }
741#endif 743#endif
742} 744}
743 745
744void Server::terminateServers() 746void Server::terminateServers()
745{ 747{
746 delete transferServer; 748 delete transferServer;
747 delete qcopBridge; 749 delete qcopBridge;
748 transferServer = 0; 750 transferServer = 0;
749 qcopBridge = 0; 751 qcopBridge = 0;
750} 752}
751 753
752void Server::syncConnectionClosed( const QHostAddress & ) 754void Server::syncConnectionClosed( const QHostAddress & )
753{ 755{
754 odebug << "Lost sync connection" << oendl; 756 odebug << "Lost sync connection" << oendl;
755 delete syncDialog; 757 delete syncDialog;
756 syncDialog = 0; 758 syncDialog = 0;
757} 759}
758 760
759void Server::pokeTimeMonitors() 761void Server::pokeTimeMonitors()
760{ 762{
761#if 0 763#if 0
762 // inform all TimeMonitors 764 // inform all TimeMonitors
763 QStrList tms = Service::channels("TimeMonitor"); 765 QStrList tms = Service::channels("TimeMonitor");
764 for (const char* ch = tms.first(); ch; ch=tms.next()) { 766 for (const char* ch = tms.first(); ch; ch=tms.next()) {
765 QString t = getenv("TZ"); 767 QString t = getenv("TZ");
766 QCopEnvelope e(ch, "timeChange(QString)"); 768 QCopEnvelope e(ch, "timeChange(QString)");
767 e << t; 769 e << t;
768 } 770 }
769#endif 771#endif
770} 772}
771 773
772void Server::applicationLaunched(int, const QString &app) 774void Server::applicationLaunched(int, const QString &app)
773{ 775{
774 serverGui->applicationStateChanged( app, ServerInterface::Launching ); 776 serverGui->applicationStateChanged( app, ServerInterface::Launching );
775} 777}
776 778
777void Server::applicationTerminated(int pid, const QString &app) 779void Server::applicationTerminated(int pid, const QString &app)
778{ 780{
779 serverGui->applicationStateChanged( app, ServerInterface::Terminated ); 781 serverGui->applicationStateChanged( app, ServerInterface::Terminated );
780#if 0 782#if 0
781 tsmMonitor->applicationTerminated( pid ); 783 tsmMonitor->applicationTerminated( pid );
782#else 784#else
783 Q_UNUSED( pid ) 785 Q_UNUSED( pid )
784#endif 786#endif
785} 787}
786 788
787void Server::applicationConnected(const QString &app) 789void Server::applicationConnected(const QString &app)
788{ 790{
789 serverGui->applicationStateChanged( app, ServerInterface::Running ); 791 serverGui->applicationStateChanged( app, ServerInterface::Running );
790} 792}
791 793
792void Server::storageChanged() 794void Server::storageChanged()
793{ 795{
794 system( "opie-update-symlinks" ); 796 system( "opie-update-symlinks" );
795 serverGui->storageChanged( storage->fileSystems() ); 797 serverGui->storageChanged( storage->fileSystems() );
796 docList->storageChanged(); 798 docList->storageChanged();
797} 799}
798 800
799 801
800 802
801void Server::preloadApps() 803void Server::preloadApps()
802{ 804{
803 Config cfg("Launcher"); 805 Config cfg("Launcher");
804 cfg.setGroup("Preload"); 806 cfg.setGroup("Preload");
805 QStringList apps = cfg.readListEntry("Apps",','); 807 QStringList apps = cfg.readListEntry("Apps",',');
806 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 808 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
807#ifndef QT_NO_COP 809#ifndef QT_NO_COP
808 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 810 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
809#endif 811#endif
810 } 812 }
811} 813}
812 814
813// This is only called if QPE_HAVE_DIRECT_ACCESS is defined 815// This is only called if QPE_HAVE_DIRECT_ACCESS is defined
814void Server::prepareDirectAccess() 816void Server::prepareDirectAccess()
815{ 817{
816 qDebug( "Server::prepareDirectAccess()" ); 818 qDebug( "Server::prepareDirectAccess()" );
817 // Put up a pretty dialog 819 // Put up a pretty dialog
818 syncDialog = new SyncDialog( this, tr("USB Lock") ); 820 syncDialog = new SyncDialog( this, tr("USB Lock") );
819 syncDialog->show(); 821 syncDialog->show();
820 822
821 // Prevent the PDA from acting as a PDA 823 // Prevent the PDA from acting as a PDA
822 terminateServers(); 824 terminateServers();
823 825
824 // suspend the mtab monitor 826 // suspend the mtab monitor
825#ifndef QT_NO_COP 827#ifndef QT_NO_COP
826 { 828 {
827 QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); 829 QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" );
828 } 830 }
829#endif 831#endif
830 832
831 // send out a flush message 833 // send out a flush message
832 // once flushes are done call runDirectAccess() 834 // once flushes are done call runDirectAccess()
833 // We just count the number of apps and set a timer. 835 // We just count the number of apps and set a timer.
834 // Either the timer expires or the correct number of apps responds. 836 // Either the timer expires or the correct number of apps responds.
835 // Note: quicklauncher isn't in the runningApps list but it responds 837 // Note: quicklauncher isn't in the runningApps list but it responds
836 // to the flush so we start the counter at 1 838 // to the flush so we start the counter at 1
837 pendingFlushes = 1; 839 pendingFlushes = 1;
838 directAccessRun = FALSE; 840 directAccessRun = FALSE;
839 for ( QMap<int,QString>::ConstIterator it = 841 for ( QMap<int,QString>::ConstIterator it =
840 appLauncher->runningApplications().begin(); 842 appLauncher->runningApplications().begin();
841 it != appLauncher->runningApplications().end(); 843 it != appLauncher->runningApplications().end();
842 ++it ) { 844 ++it ) {
843 pendingFlushes++; 845 pendingFlushes++;
844 } 846 }
845#ifndef QT_NO_COP 847#ifndef QT_NO_COP
846 QCopEnvelope e1( "QPE/System", "flush()" ); 848 QCopEnvelope e1( "QPE/System", "flush()" );
847#endif 849#endif
848 QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) ); 850 QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) );
849#warning FIXME support TempScreenSaverMode 851#warning FIXME support TempScreenSaverMode
850#if 0 852#if 0
851 QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend); 853 QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend);
852#endif 854#endif
853} 855}
854 856
855// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined 857// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined
856// It fakes the presence of Qtopia Desktop 858// It fakes the presence of Qtopia Desktop
857void Server::desktopMessage( const QCString &message, const QByteArray &data ) 859void Server::desktopMessage( const QCString &message, const QByteArray &data )
858{ 860{
859 QDataStream stream( data, IO_ReadOnly ); 861 QDataStream stream( data, IO_ReadOnly );
860 if ( message == "flushDone(QString)" ) { 862 if ( message == "flushDone(QString)" ) {
861 QString app; 863 QString app;
862 stream >> app; 864 stream >> app;
863 qDebug( "flushDone from %s", app.latin1() ); 865 qDebug( "flushDone from %s", app.latin1() );
864 if ( --pendingFlushes == 0 ) { 866 if ( --pendingFlushes == 0 ) {
865 qDebug( "pendingFlushes == 0, all the apps responded" ); 867 qDebug( "pendingFlushes == 0, all the apps responded" );
866 runDirectAccess(); 868 runDirectAccess();
867 } 869 }
868 } else if ( message == "installStarted(QString)" ) { 870 } else if ( message == "installStarted(QString)" ) {
869 QString package; 871 QString package;
870 stream >> package; 872 stream >> package;
871 qDebug( "\tInstall Started for package %s", package.latin1() ); 873 qDebug( "\tInstall Started for package %s", package.latin1() );
872 } else if ( message == "installStep(QString)" ) { 874 } else if ( message == "installStep(QString)" ) {
873 QString step; 875 QString step;
874 stream >> step; 876 stream >> step;
875 qDebug( "\tInstall Step %s", step.latin1() ); 877 qDebug( "\tInstall Step %s", step.latin1() );
876 } else if ( message == "installDone(QString)" ) { 878 } else if ( message == "installDone(QString)" ) {
877 QString package; 879 QString package;
878 stream >> package; 880 stream >> package;
879 qDebug( "\tInstall Finished for package %s", package.latin1() ); 881 qDebug( "\tInstall Finished for package %s", package.latin1() );
880 } else if ( message == "installFailed(QString,int,QString)" ) { 882 } else if ( message == "installFailed(QString,int,QString)" ) {
881 QString package, error; 883 QString package, error;
882 int status; 884 int status;
883 stream >> package >> status >> error; 885 stream >> package >> status >> error;
884 qDebug( "\tInstall Failed for package %s with error code %d and error message %s", 886 qDebug( "\tInstall Failed for package %s with error code %d and error message %s",
885 package.latin1(), status, error.latin1() ); 887 package.latin1(), status, error.latin1() );
886 } else if ( message == "removeStarted(QString)" ) { 888 } else if ( message == "removeStarted(QString)" ) {
887 QString package; 889 QString package;
888 stream >> package; 890 stream >> package;
889 qDebug( "\tRemove Started for package %s", package.latin1() ); 891 qDebug( "\tRemove Started for package %s", package.latin1() );
890 } else if ( message == "removeDone(QString)" ) { 892 } else if ( message == "removeDone(QString)" ) {
891 QString package; 893 QString package;
892 stream >> package; 894 stream >> package;
893 qDebug( "\tRemove Finished for package %s", package.latin1() ); 895 qDebug( "\tRemove Finished for package %s", package.latin1() );
894 } else if ( message == "removeFailed(QString)" ) { 896 } else if ( message == "removeFailed(QString)" ) {
895 QString package; 897 QString package;
896 stream >> package; 898 stream >> package;
897 qDebug( "\tRemove Failed for package %s", package.latin1() ); 899 qDebug( "\tRemove Failed for package %s", package.latin1() );
898 } 900 }
899 901
900 if ( qrr && qrr->waitingForMessages ) 902 if ( qrr && qrr->waitingForMessages )
901 qrr->desktopMessage( message, data ); 903 qrr->desktopMessage( message, data );
902} 904}
903 905
904 906
905// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined 907// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined
906void Server::runDirectAccess() 908void Server::runDirectAccess()
907{ 909{
908#ifdef QPE_HAVE_DIRECT_ACCESS 910#ifdef QPE_HAVE_DIRECT_ACCESS
909 // The timer must have fired after all the apps responded 911 // The timer must have fired after all the apps responded
910 // with flushDone(). Just ignore it. 912 // with flushDone(). Just ignore it.
911 if ( directAccessRun ) 913 if ( directAccessRun )
912 return; 914 return;
913 915
914 directAccessRun = TRUE; 916 directAccessRun = TRUE;
915 ::readyDirectAccess(cardInfoString(), installLocationsString()); 917 ::readyDirectAccess(cardInfoString(), installLocationsString());
916#endif 918#endif
917} 919}
918 920
919// This is only called if QPE_HAVE_DIRECT_ACCESS is defined 921// This is only called if QPE_HAVE_DIRECT_ACCESS is defined
920void Server::postDirectAccess() 922void Server::postDirectAccess()
921{ 923{
922#ifdef QPE_HAVE_DIRECT_ACCESS 924#ifdef QPE_HAVE_DIRECT_ACCESS
923 qDebug( "Server::postDirectAccess()" ); 925 qDebug( "Server::postDirectAccess()" );
924 926
925 // Categories may have changed 927 // Categories may have changed
926 QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); 928 QCopEnvelope e1( "QPE/System", "categoriesChanged()" );
927 // Apps need to reload their data 929 // Apps need to reload their data
928 QCopEnvelope e2( "QPE/System", "reload()" ); 930 QCopEnvelope e2( "QPE/System", "reload()" );
929 // Reload DocLinks 931 // Reload DocLinks
930 docList->storageChanged(); 932 docList->storageChanged();
931 // Restart the PDA server stuff 933 // Restart the PDA server stuff
932 startTransferServer(); 934 startTransferServer();
933 935
934 // restart the mtab monitor 936 // restart the mtab monitor
935#ifndef QT_NO_COP 937#ifndef QT_NO_COP
936 { 938 {
937 QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); 939 QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" );
938 } 940 }
939#endif 941#endif
940 942
941 // Process queued requests 943 // Process queued requests
942 const char *queueFile = ::directAccessQueueFile(); 944 const char *queueFile = ::directAccessQueueFile();
943 QFile *file = new QFile( queueFile ); 945 QFile *file = new QFile( queueFile );
944 if ( !file->exists() ) { 946 if ( !file->exists() ) {
945 delete file; 947 delete file;
946 // Get rid of the dialog 948 // Get rid of the dialog
947 if ( syncDialog ) { 949 if ( syncDialog ) {
948 delete syncDialog; 950 delete syncDialog;
949 syncDialog = 0; 951 syncDialog = 0;
950 } 952 }
951#warning FIXME support TempScreenSaverMode 953#warning FIXME support TempScreenSaverMode
952#if 0 954#if 0
953 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); 955 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable);
954#endif 956#endif
955 } else { 957 } else {
956 qrr = new QueuedRequestRunner( file, syncDialog ); 958 qrr = new QueuedRequestRunner( file, syncDialog );
957 connect( qrr, SIGNAL(finished()), 959 connect( qrr, SIGNAL(finished()),
958 this, SLOT(finishedQueuedRequests()) ); 960 this, SLOT(finishedQueuedRequests()) );
959 QTimer::singleShot( 100, qrr, SLOT(process()) ); 961 QTimer::singleShot( 100, qrr, SLOT(process()) );
960 // qrr will remove the sync dialog later 962 // qrr will remove the sync dialog later
961 } 963 }
962#endif 964#endif
963} 965}
964 966
965void Server::finishedQueuedRequests() 967void Server::finishedQueuedRequests()
966{ 968{
967 if ( qrr->readyToDelete ) { 969 if ( qrr->readyToDelete ) {
968 delete qrr; 970 delete qrr;
969 qrr = 0; 971 qrr = 0;
970 // Get rid of the dialog 972 // Get rid of the dialog
971 if ( syncDialog ) { 973 if ( syncDialog ) {
972 delete syncDialog; 974 delete syncDialog;
973 syncDialog = 0; 975 syncDialog = 0;
974 } 976 }
975#warning FIXME support TempScreenSaverMode 977#warning FIXME support TempScreenSaverMode
976#if 0 978#if 0
977 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); 979 QPEApplication::setTempScreenSaverMode(QPEApplication::Enable);
978#endif 980#endif
979 } else { 981 } else {
980 qrr->readyToDelete = TRUE; 982 qrr->readyToDelete = TRUE;
981 QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); 983 QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) );
982 } 984 }
983} 985}
984 986