summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp8
-rw-r--r--core/launcher/launcher.cpp10
-rw-r--r--core/launcher/launcher.h2
-rw-r--r--core/launcher/serverinterface.h2
4 files changed, 20 insertions, 2 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index 59dd721..19ceb0f 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -1,788 +1,792 @@
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 )
194 d->serverGui->aboutToAddBegin();
193 for (int i = 0; i < 3; i++ ) { 195 for (int i = 0; i < 3; i++ ) {
194 const DocLnk *lnk = d->iterate(); 196 const DocLnk *lnk = d->iterate();
195 if ( lnk ) { 197 if ( lnk ) {
196 add( *lnk ); 198 add( *lnk );
197 } else { 199 } else {
198 // stop when done 200 // stop when done
199 pause(); 201 pause();
200 if ( d->serverGui ) 202 if ( d->serverGui )
201 d->serverGui->documentScanningProgress( 100 ); 203 d->serverGui->documentScanningProgress( 100 );
202 if ( d->needToSendAllDocLinks ) 204 if ( d->needToSendAllDocLinks )
203 sendAllDocLinks(); 205 sendAllDocLinks();
204 break; 206 break;
205 } 207 }
206 } 208 }
209 if ( d->serverGui )
210 d->serverGui->aboutToAddEnd();
207 } 211 }
208} 212}
209 213
210 214
211void DocumentList::reloadAppLnks() 215void DocumentList::reloadAppLnks()
212{ 216{
213 if ( d->sendAppLnks && d->serverGui ) { 217 if ( d->sendAppLnks && d->serverGui ) {
214 d->serverGui->applicationScanningProgress( 0 ); 218 d->serverGui->applicationScanningProgress( 0 );
215 d->serverGui->allApplicationsRemoved(); 219 d->serverGui->allApplicationsRemoved();
216 } 220 }
217 221
218 delete appLnkSet; 222 delete appLnkSet;
219 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 223 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
220 224
221 if ( d->sendAppLnks && d->serverGui ) { 225 if ( d->sendAppLnks && d->serverGui ) {
222 static QStringList prevTypeList; 226 static QStringList prevTypeList;
223 QStringList types = appLnkSet->types(); 227 QStringList types = appLnkSet->types();
224 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 228 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
225 if ( !(*ittypes).isEmpty() ) { 229 if ( !(*ittypes).isEmpty() ) {
226 if ( !prevTypeList.contains(*ittypes) ) { 230 if ( !prevTypeList.contains(*ittypes) ) {
227 QString name = appLnkSet->typeName(*ittypes); 231 QString name = appLnkSet->typeName(*ittypes);
228 QPixmap pm = appLnkSet->typePixmap(*ittypes); 232 QPixmap pm = appLnkSet->typePixmap(*ittypes);
229 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); 233 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes);
230 234
231 if (pm.isNull()) { 235 if (pm.isNull()) {
232 QImage img( Resource::loadImage( "UnknownDocument" ) ); 236 QImage img( Resource::loadImage( "UnknownDocument" ) );
233 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
234 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 238 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
235 } 239 }
236 240
237 //odebug << "adding type " << (*ittypes) << "" << oendl; 241 //odebug << "adding type " << (*ittypes) << "" << oendl;
238 242
239 // ### our current launcher expects docs tab to be last 243 // ### our current launcher expects docs tab to be last
240 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 244 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
241 } 245 }
242 prevTypeList.remove(*ittypes); 246 prevTypeList.remove(*ittypes);
243 } 247 }
244 } 248 }
245 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 249 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
246 //odebug << "removing type " << (*ittypes) << "" << oendl; 250 //odebug << "removing type " << (*ittypes) << "" << oendl;
247 d->serverGui->typeRemoved(*ittypes); 251 d->serverGui->typeRemoved(*ittypes);
248 } 252 }
249 prevTypeList = types; 253 prevTypeList = types;
250 } 254 }
251 255
252 QListIterator<AppLnk> itapp( appLnkSet->children() ); 256 QListIterator<AppLnk> itapp( appLnkSet->children() );
253 AppLnk* l; 257 AppLnk* l;
254 while ( (l=itapp.current()) ) { 258 while ( (l=itapp.current()) ) {
255 ++itapp; 259 ++itapp;
256 if ( d->sendAppLnks && d->serverGui ) 260 if ( d->sendAppLnks && d->serverGui )
257 d->serverGui->applicationAdded( l->type(), *l ); 261 d->serverGui->applicationAdded( l->type(), *l );
258 } 262 }
259 263
260 if ( d->sendAppLnks && d->serverGui ) 264 if ( d->sendAppLnks && d->serverGui )
261 d->serverGui->applicationScanningProgress( 100 ); 265 d->serverGui->applicationScanningProgress( 100 );
262} 266}
263 267
264void DocumentList::reloadDocLnks() 268void DocumentList::reloadDocLnks()
265{ 269{
266 if ( !d->scanDocs ) 270 if ( !d->scanDocs )
267 return; 271 return;
268 272
269 if ( d->sendDocLnks && d->serverGui ) { 273 if ( d->sendDocLnks && d->serverGui ) {
270 d->serverGui->documentScanningProgress( 0 ); 274 d->serverGui->documentScanningProgress( 0 );
271 d->serverGui->allDocumentsRemoved(); 275 d->serverGui->allDocumentsRemoved();
272 } 276 }
273 277
274 rescan(); 278 rescan();
275} 279}
276 280
277void DocumentList::linkChanged( QString arg ) 281void DocumentList::linkChanged( QString arg )
278{ 282{
279 //odebug << "linkchanged( " << arg << " )" << oendl; 283 //odebug << "linkchanged( " << arg << " )" << oendl;
280 284
281 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { 285 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
282 reloadAppLnks(); 286 reloadAppLnks();
283 } else { 287 } else {
284 288
285 const QList<DocLnk> &list = d->dls.children(); 289 const QList<DocLnk> &list = d->dls.children();
286 QListIterator<DocLnk> it( list ); 290 QListIterator<DocLnk> it( list );
287 while ( it.current() ) { 291 while ( it.current() ) {
288 DocLnk *doc = it.current(); 292 DocLnk *doc = it.current();
289 ++it; 293 ++it;
290 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 294 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
291 || ( doc->fileKnown() && doc->file() == arg ) ) { 295 || ( doc->fileKnown() && doc->file() == arg ) ) {
292 //odebug << "found old link" << oendl; 296 //odebug << "found old link" << oendl;
293 DocLnk* dl = new DocLnk( arg ); 297 DocLnk* dl = new DocLnk( arg );
294 // add new one if it exists and matches the mimetype 298 // add new one if it exists and matches the mimetype
295 if ( d->store( dl ) ) { 299 if ( d->store( dl ) ) {
296 // Existing link has been changed, send old link ref and a ref 300 // Existing link has been changed, send old link ref and a ref
297 // to the new link 301 // to the new link
298 //odebug << "change case" << oendl; 302 //odebug << "change case" << oendl;
299 if ( d->serverGui ) 303 if ( d->serverGui )
300 d->serverGui->documentChanged( *doc, *dl ); 304 d->serverGui->documentChanged( *doc, *dl );
301 305
302 } else { 306 } else {
303 // Link has been removed or doesn't match the mimetypes any more 307 // Link has been removed or doesn't match the mimetypes any more
304 // so we aren't interested in it, so take it away from the list 308 // so we aren't interested in it, so take it away from the list
305 //odebug << "removal case" << oendl; 309 //odebug << "removal case" << oendl;
306 if ( d->serverGui ) 310 if ( d->serverGui )
307 d->serverGui->documentRemoved( *doc ); 311 d->serverGui->documentRemoved( *doc );
308 312
309 } 313 }
310 d->dls.remove( doc ); // remove old link from docLnkSet 314 d->dls.remove( doc ); // remove old link from docLnkSet
311 delete doc; 315 delete doc;
312 return; 316 return;
313 } 317 }
314 } 318 }
315 // Didn't find existing link, must be new 319 // Didn't find existing link, must be new
316 DocLnk* dl = new DocLnk( arg ); 320 DocLnk* dl = new DocLnk( arg );
317 if ( d->store( dl ) ) { 321 if ( d->store( dl ) ) {
318 // Add if it's a link we are interested in 322 // Add if it's a link we are interested in
319 //odebug << "add case" << oendl; 323 //odebug << "add case" << oendl;
320 add( *dl ); 324 add( *dl );
321 } 325 }
322 326
323 } 327 }
324} 328}
325 329
326void DocumentList::restoreDone() 330void DocumentList::restoreDone()
327{ 331{
328 reloadAppLnks(); 332 reloadAppLnks();
329 reloadDocLnks(); 333 reloadDocLnks();
330} 334}
331 335
332void DocumentList::DiffAppLnks() 336void DocumentList::DiffAppLnks()
333{ 337{
334 static AppLnkSet *appLnkSet2; 338 static AppLnkSet *appLnkSet2;
335 339
336 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); 340 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() );
337 341
338 if ( d->sendAppLnks && d->serverGui ) { 342 if ( d->sendAppLnks && d->serverGui ) {
339 static QStringList prevTypeList = appLnkSet->types(); 343 static QStringList prevTypeList = appLnkSet->types();
340 QStringList types = appLnkSet2->types(); 344 QStringList types = appLnkSet2->types();
341 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 345 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
342 if ( !(*ittypes).isEmpty() ) { 346 if ( !(*ittypes).isEmpty() ) {
343 if ( !prevTypeList.contains(*ittypes) ) { 347 if ( !prevTypeList.contains(*ittypes) ) {
344 QString name = appLnkSet2->typeName(*ittypes); 348 QString name = appLnkSet2->typeName(*ittypes);
345 QPixmap pm = appLnkSet2->typePixmap(*ittypes); 349 QPixmap pm = appLnkSet2->typePixmap(*ittypes);
346 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); 350 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes);
347 351
348 if (pm.isNull()) { 352 if (pm.isNull()) {
349 QImage img( Resource::loadImage( "UnknownDocument" ) ); 353 QImage img( Resource::loadImage( "UnknownDocument" ) );
350 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 354 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
351 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 355 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
352 } 356 }
353 357
354 odebug << "adding type " << (*ittypes) << "" << oendl; 358 odebug << "adding type " << (*ittypes) << "" << oendl;
355 359
356 // ### our current launcher expects docs tab to be last 360 // ### our current launcher expects docs tab to be last
357 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 361 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
358 } 362 }
359 prevTypeList.remove(*ittypes); 363 prevTypeList.remove(*ittypes);
360 } 364 }
361 } 365 }
362 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 366 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
363 odebug << "removing type " << (*ittypes) << "" << oendl; 367 odebug << "removing type " << (*ittypes) << "" << oendl;
364 d->serverGui->typeRemoved(*ittypes); 368 d->serverGui->typeRemoved(*ittypes);
365 } 369 }
366 prevTypeList = types; 370 prevTypeList = types;
367 } 371 }
368 372
369 373
370 QListIterator<AppLnk> it1( appLnkSet->children() ); 374 QListIterator<AppLnk> it1( appLnkSet->children() );
371 QListIterator<AppLnk> it2( appLnkSet2->children() ); 375 QListIterator<AppLnk> it2( appLnkSet2->children() );
372 376
373 AppLnk *i; 377 AppLnk *i;
374 AppLnk *j; 378 AppLnk *j;
375 bool found; 379 bool found;
376 380
377 while ( (j=it2.current()) ) { 381 while ( (j=it2.current()) ) {
378 it1 = appLnkSet->children(); 382 it1 = appLnkSet->children();
379 found = false; 383 found = false;
380 while ( (i=it1.current()) ){ 384 while ( (i=it1.current()) ){
381 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 385 if (strcmp(i->name().ascii(),j->name().ascii()) == 0)
382 found = true; 386 found = true;
383 ++it1; 387 ++it1;
384 } 388 }
385 if (!found) { 389 if (!found) {
386 qDebug("Item %s needs to be added",j->name().ascii() ); 390 qDebug("Item %s needs to be added",j->name().ascii() );
387 d->serverGui->applicationAdded( j->type(), *j ); 391 d->serverGui->applicationAdded( j->type(), *j );
388 } 392 }
389 ++it2; 393 ++it2;
390 } 394 }
391 395
392 it1 = appLnkSet->children(); 396 it1 = appLnkSet->children();
393 while ( (i=it1.current()) ) { 397 while ( (i=it1.current()) ) {
394 it2 = appLnkSet2->children(); 398 it2 = appLnkSet2->children();
395 found = false; 399 found = false;
396 while ( (j=it2.current()) ){ 400 while ( (j=it2.current()) ){
397 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 401 if (strcmp(i->name().ascii(),j->name().ascii()) == 0)
398 found = true; 402 found = true;
399 ++it2; 403 ++it2;
400 } 404 }
401 if (!found) { 405 if (!found) {
402 qDebug("Item %s needs to be removed",i->name().ascii() ); 406 qDebug("Item %s needs to be removed",i->name().ascii() );
403 d->serverGui->applicationRemoved( i->type(), *i ); 407 d->serverGui->applicationRemoved( i->type(), *i );
404 } 408 }
405 409
406 ++it1; 410 ++it1;
407 } 411 }
408 412
409 delete appLnkSet; 413 delete appLnkSet;
410 appLnkSet = appLnkSet2; 414 appLnkSet = appLnkSet2;
411 415
412} 416}
413void DocumentList::storageChanged() 417void DocumentList::storageChanged()
414{ 418{
415 QTime t; 419 QTime t;
416 // ### can implement better 420 // ### can implement better
417 421
418 t.start(); 422 t.start();
419 DiffAppLnks(); 423 DiffAppLnks();
420// reloadAppLnks(); 424// reloadAppLnks();
421 qDebug("Reload App links took %i ms",t.elapsed() ); 425 qDebug("Reload App links took %i ms",t.elapsed() );
422 reloadDocLnks(); 426 reloadDocLnks();
423// odebug << "Reload links took " << t.elapsed() << " ms " << oendl; 427// odebug << "Reload links took " << t.elapsed() << " ms " << oendl;
424 qDebug("Reload All links took %i ms",t.elapsed() ); 428 qDebug("Reload All links took %i ms",t.elapsed() );
425// ### Optimization opportunity 429// ### Optimization opportunity
426 // Could be a bit more intelligent and somehow work out which 430 // Could be a bit more intelligent and somehow work out which
427 // mtab entry has changed and then only scan that and add and remove 431 // mtab entry has changed and then only scan that and add and remove
428 // links appropriately. 432 // links appropriately.
429// rescan(); 433// rescan();
430} 434}
431 435
432void DocumentList::sendAllDocLinks() 436void DocumentList::sendAllDocLinks()
433{ 437{
434 if ( d->tid != 0 ) { 438 if ( d->tid != 0 ) {
435 // We are in the middle of scanning, set a flag so 439 // We are in the middle of scanning, set a flag so
436 // we do this when we finish our scanning 440 // we do this when we finish our scanning
437 d->needToSendAllDocLinks = true; 441 d->needToSendAllDocLinks = true;
438 return; 442 return;
439 } 443 }
440 444
441 QString contents; 445 QString contents;
442 Categories cats; 446 Categories cats;
443 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { 447 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) {
444 DocLnk *doc = it.current(); 448 DocLnk *doc = it.current();
445 QFileInfo fi( doc->file() ); 449 QFileInfo fi( doc->file() );
446 if ( !fi.exists() ) 450 if ( !fi.exists() )
447 continue; 451 continue;
448 452
449 bool fake = !doc->linkFileKnown(); 453 bool fake = !doc->linkFileKnown();
450 if ( !fake ) { 454 if ( !fake ) {
451 QFile f( doc->linkFile() ); 455 QFile f( doc->linkFile() );
452 if ( f.open( IO_ReadOnly ) ) { 456 if ( f.open( IO_ReadOnly ) ) {
453 QTextStream ts( &f ); 457 QTextStream ts( &f );
454 ts.setEncoding( QTextStream::UnicodeUTF8 ); 458 ts.setEncoding( QTextStream::UnicodeUTF8 );
455 contents += ts.read(); 459 contents += ts.read();
456 f.close(); 460 f.close();
457 } else 461 } else
458 fake = TRUE; 462 fake = TRUE;
459 } 463 }
460 if (fake) { 464 if (fake) {
461 contents += "[Desktop Entry]\n"; // No tr 465 contents += "[Desktop Entry]\n"; // No tr
462 contents += "Categories = " + // No tr 466 contents += "Categories = " + // No tr
463 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 467 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
464 contents += "Name = "+doc->name()+"\n"; // No tr 468 contents += "Name = "+doc->name()+"\n"; // No tr
465 contents += "Type = "+doc->type()+"\n"; // No tr 469 contents += "Type = "+doc->type()+"\n"; // No tr
466 } 470 }
467 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 471 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
468 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 472 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
469 } 473 }
470 474
471 //odebug << "sending length " << contents.length() << "" << oendl; 475 //odebug << "sending length " << contents.length() << "" << oendl;
472#ifndef QT_NO_COP 476#ifndef QT_NO_COP
473 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 477 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
474 e << contents; 478 e << contents;
475#endif 479#endif
476 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; 480 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;
477 481
478 d->needToSendAllDocLinks = false; 482 d->needToSendAllDocLinks = false;
479} 483}
480 484
481 485
482 486
483 487
484 488
485 489
486 490
487 491
488 492
489 493
490 494
491 495
492 496
493 497
494 498
495 499
496 500
497 501
498 502
499 503
500 504
501 505
502 506
503 507
504DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) 508DocumentListPrivate::DocumentListPrivate( ServerInterface *gui )
505{ 509{
506 storage = new StorageInfo( this ); 510 storage = new StorageInfo( this );
507 serverGui = gui; 511 serverGui = gui;
508 if ( serverGui ) { 512 if ( serverGui ) {
509 sendAppLnks = serverGui->requiresApplications(); 513 sendAppLnks = serverGui->requiresApplications();
510 sendDocLnks = serverGui->requiresDocuments(); 514 sendDocLnks = serverGui->requiresDocuments();
511 } else { 515 } else {
512 sendAppLnks = false; 516 sendAppLnks = false;
513 sendDocLnks = false; 517 sendDocLnks = false;
514 } 518 }
515 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { 519 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) {
516 listDirs[i] = 0; 520 listDirs[i] = 0;
517 lists[i] = 0; 521 lists[i] = 0;
518 listPositions[i] = 0; 522 listPositions[i] = 0;
519 } 523 }
520 initialize(); 524 initialize();
521 tid = 0; 525 tid = 0;
522} 526}
523 527
524void DocumentListPrivate::appendDocpath(FileSystem*fs) 528void DocumentListPrivate::appendDocpath(FileSystem*fs)
525{ 529{
526 QDir defPath(fs->path()+"/Documents"); 530 QDir defPath(fs->path()+"/Documents");
527 QFileInfo f(fs->path()+"/.opiestorage.cf"); 531 QFileInfo f(fs->path()+"/.opiestorage.cf");
528 if (!f.exists()) { 532 if (!f.exists()) {
529 Mediadlg dlg(fs); 533 Mediadlg dlg(fs);
530 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { 534 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) {
531 return; 535 return;
532 } 536 }
533 } 537 }
534 Config conf(f.filePath(), Config::File ); 538 Config conf(f.filePath(), Config::File );
535 conf.setGroup("main"); 539 conf.setGroup("main");
536 if (!conf.readBoolEntry("check",false)) { 540 if (!conf.readBoolEntry("check",false)) {
537 return; 541 return;
538 } 542 }
539 conf.setGroup("subdirs"); 543 conf.setGroup("subdirs");
540 bool read_all = conf.readBoolEntry("wholemedia",true); 544 bool read_all = conf.readBoolEntry("wholemedia",true);
541 if (read_all) { 545 if (read_all) {
542 docPaths+=fs->path(); 546 docPaths+=fs->path();
543 return; 547 return;
544 } 548 }
545 QStringList subDirs = conf.readListEntry("subdirs",':'); 549 QStringList subDirs = conf.readListEntry("subdirs",':');
546 if (subDirs.isEmpty()) { 550 if (subDirs.isEmpty()) {
547 if (defPath.exists()) { 551 if (defPath.exists()) {
548 docPaths+=defPath.path(); 552 docPaths+=defPath.path();
549 } 553 }
550 return; 554 return;
551 } 555 }
552 for (unsigned c = 0; c < subDirs.count();++c) { 556 for (unsigned c = 0; c < subDirs.count();++c) {
553 QDir docDir(QString(fs->path()+"/"+subDirs[c])); 557 QDir docDir(QString(fs->path()+"/"+subDirs[c]));
554 if (docDir.exists()) { 558 if (docDir.exists()) {
555 docPaths+=docDir.path(); 559 docPaths+=docDir.path();
556 } 560 }
557 } 561 }
558} 562}
559 563
560void DocumentListPrivate::initialize() 564void DocumentListPrivate::initialize()
561{ 565{
562 // Reset 566 // Reset
563 dls.clear(); 567 dls.clear();
564 docPaths.clear(); 568 docPaths.clear();
565 reference.clear(); 569 reference.clear();
566 570
567 QDir docDir( QPEApplication::documentDir() ); 571 QDir docDir( QPEApplication::documentDir() );
568 if ( docDir.exists() ) 572 if ( docDir.exists() )
569 docPaths += QPEApplication::documentDir(); 573 docPaths += QPEApplication::documentDir();
570 int i = 1; 574 int i = 1;
571 const QList<FileSystem> &fs = storage->fileSystems(); 575 const QList<FileSystem> &fs = storage->fileSystems();
572 QListIterator<FileSystem> it( fs ); 576 QListIterator<FileSystem> it( fs );
573 for ( ; it.current(); ++it ) { 577 for ( ; it.current(); ++it ) {
574 if ( (*it)->isRemovable() ) { 578 if ( (*it)->isRemovable() ) {
575 appendDocpath((*it)); 579 appendDocpath((*it));
576 ++i; 580 ++i;
577 } 581 }
578 } 582 }
579 583
580 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { 584 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) {
581 if ( listDirs[i] ) { 585 if ( listDirs[i] ) {
582 delete listDirs[i]; 586 delete listDirs[i];
583 listDirs[i] = 0; 587 listDirs[i] = 0;
584 } 588 }
585 lists[i] = 0; 589 lists[i] = 0;
586 listPositions[i] = 0; 590 listPositions[i] = 0;
587 } 591 }
588 592
589 docPathsSearched = 0; 593 docPathsSearched = 0;
590 searchDepth = -1; 594 searchDepth = -1;
591 state = Find; 595 state = Find;
592 dit = 0; 596 dit = 0;
593} 597}
594 598
595 599
596DocumentListPrivate::~DocumentListPrivate() 600DocumentListPrivate::~DocumentListPrivate()
597{ 601{
598 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) 602 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ )
599 if ( listDirs[i] ) 603 if ( listDirs[i] )
600 delete listDirs[i]; 604 delete listDirs[i];
601 delete dit; 605 delete dit;
602} 606}
603 607
604 608
605void DocumentListPrivate::estimatedPercentScanned() 609void DocumentListPrivate::estimatedPercentScanned()
606{ 610{
607 double overallProgress = 0.0; 611 double overallProgress = 0.0;
608 double levelWeight = 75.0; 612 double levelWeight = 75.0;
609 613
610 int topCount = docPaths.count(); 614 int topCount = docPaths.count();
611 if ( topCount > 1 ) { 615 if ( topCount > 1 ) {
612 levelWeight = levelWeight / topCount; 616 levelWeight = levelWeight / topCount;
613 overallProgress += (docPathsSearched - 1) * levelWeight; 617 overallProgress += (docPathsSearched - 1) * levelWeight;
614 } 618 }
615 619
616 for ( int d = 0; d <= searchDepth; d++ ) { 620 for ( int d = 0; d <= searchDepth; d++ ) {
617 if ( listDirs[d] ) { 621 if ( listDirs[d] ) {
618 int items = lists[d]->count(); 622 int items = lists[d]->count();
619 if ( items > 1 ) { 623 if ( items > 1 ) {
620 levelWeight = levelWeight / items; 624 levelWeight = levelWeight / items;
621 // Take in to account "." and ".." 625 // Take in to account "." and ".."
622 overallProgress += (listPositions[d] - 3) * levelWeight; 626 overallProgress += (listPositions[d] - 3) * levelWeight;
623 } 627 }
624 } else { 628 } else {
625 break; 629 break;
626 } 630 }
627 } 631 }
628 632
629 // odebug << "overallProgress: " << overallProgress << "" << oendl; 633 // odebug << "overallProgress: " << overallProgress << "" << oendl;
630 634
631 if ( serverGui ) 635 if ( serverGui )
632 serverGui->documentScanningProgress( (int)overallProgress ); 636 serverGui->documentScanningProgress( (int)overallProgress );
633} 637}
634 638
635 639
636const QString DocumentListPrivate::nextFile() 640const QString DocumentListPrivate::nextFile()
637{ 641{
638 while ( TRUE ) { 642 while ( TRUE ) {
639 while ( searchDepth < 0 ) { 643 while ( searchDepth < 0 ) {
640 // go to next base path 644 // go to next base path
641 if ( docPathsSearched >= docPaths.count() ) { 645 if ( docPathsSearched >= docPaths.count() ) {
642 // end of base paths 646 // end of base paths
643 return QString::null; 647 return QString::null;
644 } else { 648 } else {
645 QDir dir( docPaths[docPathsSearched] ); 649 QDir dir( docPaths[docPathsSearched] );
646 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl; 650 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl;
647 docPathsSearched++; 651 docPathsSearched++;
648 if ( !dir.exists( ".Qtopia-ignore" ) ) { 652 if ( !dir.exists( ".Qtopia-ignore" ) ) {
649 listDirs[0] = new QDir( dir ); 653 listDirs[0] = new QDir( dir );
650 lists[0] = listDirs[0]->entryInfoList(); 654 lists[0] = listDirs[0]->entryInfoList();
651 listPositions[0] = 0; 655 listPositions[0] = 0;
652 searchDepth = 0; 656 searchDepth = 0;
653 } 657 }
654 } 658 }
655 } 659 }
656 660
657 const QFileInfoList *fil = lists[searchDepth]; 661 const QFileInfoList *fil = lists[searchDepth];
658 if (!fil) { 662 if (!fil) {
659 return QString::null; 663 return QString::null;
660 } 664 }
661 QFileInfoList *fl = (QFileInfoList *)fil; 665 QFileInfoList *fl = (QFileInfoList *)fil;
662 unsigned int pos = listPositions[searchDepth]; 666 unsigned int pos = listPositions[searchDepth];
663 667
664 if ( pos >= fl->count() ) { 668 if ( pos >= fl->count() ) {
665 // go up a depth 669 // go up a depth
666 delete listDirs[searchDepth]; 670 delete listDirs[searchDepth];
667 listDirs[searchDepth] = 0; 671 listDirs[searchDepth] = 0;
668 lists[searchDepth] = 0; 672 lists[searchDepth] = 0;
669 listPositions[searchDepth] = 0; 673 listPositions[searchDepth] = 0;
670 searchDepth--; 674 searchDepth--;
671 } else { 675 } else {
672 const QFileInfo *fi = fl->at(pos); 676 const QFileInfo *fi = fl->at(pos);
673 listPositions[searchDepth]++; 677 listPositions[searchDepth]++;
674 QString bn = fi->fileName(); 678 QString bn = fi->fileName();
675 if ( bn[0] != '.' ) { 679 if ( bn[0] != '.' ) {
676 if ( fi->isDir() ) { 680 if ( fi->isDir() ) {
677 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { 681 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) {
678 // go down a depth 682 // go down a depth
679 QDir dir( fi->filePath() ); 683 QDir dir( fi->filePath() );
680 // odebug << "now going in to path: " << bn << "" << oendl; 684 // odebug << "now going in to path: " << bn << "" << oendl;
681 if ( !dir.exists( ".Qtopia-ignore" ) ) { 685 if ( !dir.exists( ".Qtopia-ignore" ) ) {
682 if ( searchDepth < MAX_SEARCH_DEPTH - 1) { 686 if ( searchDepth < MAX_SEARCH_DEPTH - 1) {
683 searchDepth++; 687 searchDepth++;
684 listDirs[searchDepth] = new QDir( dir ); 688 listDirs[searchDepth] = new QDir( dir );
685 lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); 689 lists[searchDepth] = listDirs[searchDepth]->entryInfoList();
686 listPositions[searchDepth] = 0; 690 listPositions[searchDepth] = 0;
687 } 691 }
688 } 692 }
689 } 693 }
690 } else { 694 } else {
691 estimatedPercentScanned(); 695 estimatedPercentScanned();
692 return fl->at(pos)->filePath(); 696 return fl->at(pos)->filePath();
693 } 697 }
694 } 698 }
695 } 699 }
696 } 700 }
697 701
698 return QString::null; 702 return QString::null;
699} 703}
700 704
701 705
702bool DocumentListPrivate::store( DocLnk* dl ) 706bool DocumentListPrivate::store( DocLnk* dl )
703{ 707{
704 // if ( dl->fileKnown() && !dl->file().isEmpty() ) { 708 // if ( dl->fileKnown() && !dl->file().isEmpty() ) {
705 if ( dl && dl->fileKnown() ) { 709 if ( dl && dl->fileKnown() ) {
706 dls.add( dl ); // store 710 dls.add( dl ); // store
707 return TRUE; 711 return TRUE;
708 } 712 }
709 713
710 // don't store - delete 714 // don't store - delete
711 delete dl; 715 delete dl;
712 return FALSE; 716 return FALSE;
713} 717}
714 718
715 719
716 #define MAGIC_NUMBER((void*)2) 720 #define MAGIC_NUMBER((void*)2)
717 721
718const DocLnk *DocumentListPrivate::iterate() 722const DocLnk *DocumentListPrivate::iterate()
719{ 723{
720 if ( state == Find ) { 724 if ( state == Find ) {
721 //odebug << "state Find" << oendl; 725 //odebug << "state Find" << oendl;
722 QString file = nextFile(); 726 QString file = nextFile();
723 while ( !file.isNull() ) { 727 while ( !file.isNull() ) {
724 if ( file.right(8) == ".desktop" ) { // No tr 728 if ( file.right(8) == ".desktop" ) { // No tr
725 DocLnk* dl = new DocLnk( file ); 729 DocLnk* dl = new DocLnk( file );
726 if ( store(dl) ) 730 if ( store(dl) )
727 return dl; 731 return dl;
728 } else { 732 } else {
729 reference.insert( file, MAGIC_NUMBER ); 733 reference.insert( file, MAGIC_NUMBER );
730 } 734 }
731 file = nextFile(); 735 file = nextFile();
732 } 736 }
733 state = RemoveKnownFiles; 737 state = RemoveKnownFiles;
734 738
735 if ( serverGui ) 739 if ( serverGui )
736 serverGui->documentScanningProgress( 75 ); 740 serverGui->documentScanningProgress( 75 );
737 } 741 }
738 742
739 static int iterationI; 743 static int iterationI;
740 static int iterationCount; 744 static int iterationCount;
741 745
742 if ( state == RemoveKnownFiles ) { 746 if ( state == RemoveKnownFiles ) {
743 //odebug << "state RemoveKnownFiles" << oendl; 747 //odebug << "state RemoveKnownFiles" << oendl;
744 const QList<DocLnk> &list = dls.children(); 748 const QList<DocLnk> &list = dls.children();
745 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { 749 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) {
746 reference.remove( (*it)->file() ); 750 reference.remove( (*it)->file() );
747 // ### does this need to be deleted? 751 // ### does this need to be deleted?
748 } 752 }
749 dit = new QDictIterator<void>(reference); 753 dit = new QDictIterator<void>(reference);
750 state = MakeUnknownFiles; 754 state = MakeUnknownFiles;
751 755
752 iterationI = 0; 756 iterationI = 0;
753 iterationCount = dit->count(); 757 iterationCount = dit->count();
754 } 758 }
755 759
756 if ( state == MakeUnknownFiles ) { 760 if ( state == MakeUnknownFiles ) {
757 //odebug << "state MakeUnknownFiles" << oendl; 761 //odebug << "state MakeUnknownFiles" << oendl;
758 for (void* c; (c=dit->current()); ++(*dit) ) { 762 for (void* c; (c=dit->current()); ++(*dit) ) {
759 if ( c == MAGIC_NUMBER ) { 763 if ( c == MAGIC_NUMBER ) {
760 DocLnk* dl = new DocLnk; 764 DocLnk* dl = new DocLnk;
761 QFileInfo fi( dit->currentKey() ); 765 QFileInfo fi( dit->currentKey() );
762 dl->setFile( fi.filePath() ); 766 dl->setFile( fi.filePath() );
763 dl->setName( fi.baseName() ); 767 dl->setName( fi.baseName() );
764 if ( store(dl) ) { 768 if ( store(dl) ) {
765 ++*dit; 769 ++*dit;
766 iterationI++; 770 iterationI++;
767 if ( serverGui ) 771 if ( serverGui )
768 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); 772 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount );
769 return dl; 773 return dl;
770 } 774 }
771 } 775 }
772 iterationI++; 776 iterationI++;
773 } 777 }
774 778
775 delete dit; 779 delete dit;
776 dit = 0; 780 dit = 0;
777 state = Done; 781 state = Done;
778 } 782 }
779 783
780 //odebug << "state Done" << oendl; 784 //odebug << "state Done" << oendl;
781 return NULL; 785 return NULL;
782} 786}
783 787
784 788
785#include "documentlist.moc" 789#include "documentlist.moc"
786 790
787 791
788 792
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index bf2287d..6afbcd8 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,776 +1,786 @@
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 "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 ) 80 QVBox( parent ), docview( 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 bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); 131 bool 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 int n = categoryBar->count(); 219 int n = categoryBar->count();
220 stack->addWidget( view, n ); 220 stack->addWidget( view, n );
221 221
222 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 222 LauncherTab *tab = new LauncherTab( id, view, pm, label );
223 categoryBar->insertTab( tab, n-1 ); 223 categoryBar->insertTab( tab, n-1 );
224 224
225 if ( id == "Documents" ) 225 if ( id == "Documents" )
226 docview = view; 226 docview = view;
227 227
228 odebug << "inserting " << id << " at " << n-1 << "" << oendl; 228 odebug << "inserting " << id << " at " << n-1 << "" << oendl;
229 229
230 Config cfg("Launcher"); 230 Config cfg("Launcher");
231 setTabAppearance( tab, cfg ); 231 setTabAppearance( tab, cfg );
232 232
233 cfg.setGroup( "GUI" ); 233 cfg.setGroup( "GUI" );
234 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 234 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
235 235
236 return view; 236 return view;
237} 237}
238 238
239LauncherView *LauncherTabWidget::view( const QString &id ) 239LauncherView *LauncherTabWidget::view( const QString &id )
240{ 240{
241 LauncherTab *t = categoryBar->launcherTab(id); 241 LauncherTab *t = categoryBar->launcherTab(id);
242 if ( !t ) 242 if ( !t )
243 return 0; 243 return 0;
244 return t->view; 244 return t->view;
245} 245}
246 246
247LauncherView *LauncherTabWidget::docView() 247LauncherView *LauncherTabWidget::docView()
248{ 248{
249 return docview; 249 return docview;
250} 250}
251 251
252void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 252void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
253{ 253{
254 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { 254 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
255 docLoadingWidgetEnabled = v; 255 docLoadingWidgetEnabled = v;
256 raiseTabWidget(); 256 raiseTabWidget();
257 } 257 }
258} 258}
259 259
260void LauncherTabWidget::setLoadingProgress( int percent ) 260void LauncherTabWidget::setLoadingProgress( int percent )
261{ 261{
262 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); 262 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
263} 263}
264 264
265// ### this function could more to LauncherView 265// ### this function could more to LauncherView
266void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) 266void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
267{ 267{
268 // View 268 // View
269 QString view = cfg.readEntry( "View", "Icon" ); 269 QString view = cfg.readEntry( "View", "Icon" );
270 if ( view == "List" ) // No tr 270 if ( view == "List" ) // No tr
271 v->setViewMode( LauncherView::List ); 271 v->setViewMode( LauncherView::List );
272 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 272 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
273 if ( bgType == "Image" ) { // No tr 273 if ( bgType == "Image" ) { // No tr
274 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 274 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
275 v->setBackgroundType( LauncherView::Image, pm ); 275 v->setBackgroundType( LauncherView::Image, pm );
276 } else if ( bgType == "SolidColor" ) { 276 } else if ( bgType == "SolidColor" ) {
277 QString c = cfg.readEntry( "BackgroundColor" ); 277 QString c = cfg.readEntry( "BackgroundColor" );
278 v->setBackgroundType( LauncherView::SolidColor, c ); 278 v->setBackgroundType( LauncherView::SolidColor, c );
279 } else { 279 } else {
280 v->setBackgroundType( LauncherView::Ruled, QString::null ); 280 v->setBackgroundType( LauncherView::Ruled, QString::null );
281 } 281 }
282 QString textCol = cfg.readEntry( "TextColor" ); 282 QString textCol = cfg.readEntry( "TextColor" );
283 if ( textCol.isEmpty() ) 283 if ( textCol.isEmpty() )
284 v->setTextColor( QColor() ); 284 v->setTextColor( QColor() );
285 else 285 else
286 v->setTextColor( QColor(textCol) ); 286 v->setTextColor( QColor(textCol) );
287// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); 287// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE );
288 288
289 289
290 QStringList font = cfg.readListEntry( "Font", ',' ); 290 QStringList font = cfg.readListEntry( "Font", ',' );
291 if ( font.count() == 4 ) 291 if ( font.count() == 4 )
292 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 292 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
293 293
294 // ### FIXME TabColor TabTextColor 294 // ### FIXME TabColor TabTextColor
295 295
296} 296}
297 297
298// ### Could move to LauncherTab 298// ### Could move to LauncherTab
299void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) 299void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
300{ 300{
301 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr 301 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr
302 302
303 setTabViewAppearance( tab->view, cfg ); 303 setTabViewAppearance( tab->view, cfg );
304 304
305 // Tabs 305 // Tabs
306 QString tabCol = cfg.readEntry( "TabColor" ); 306 QString tabCol = cfg.readEntry( "TabColor" );
307 if ( tabCol.isEmpty() ) 307 if ( tabCol.isEmpty() )
308 tab->bgColor = QColor(); 308 tab->bgColor = QColor();
309 else 309 else
310 tab->bgColor = QColor(tabCol); 310 tab->bgColor = QColor(tabCol);
311 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 311 QString tabTextCol = cfg.readEntry( "TabTextColor" );
312 if ( tabTextCol.isEmpty() ) 312 if ( tabTextCol.isEmpty() )
313 tab->fgColor = QColor(); 313 tab->fgColor = QColor();
314 else 314 else
315 tab->fgColor = QColor(tabTextCol); 315 tab->fgColor = QColor(tabTextCol);
316} 316}
317 317
318void LauncherTabWidget::paletteChange( const QPalette &p ) 318void LauncherTabWidget::paletteChange( const QPalette &p )
319{ 319{
320 QVBox::paletteChange( p ); 320 QVBox::paletteChange( p );
321 QPalette pal = palette(); 321 QPalette pal = palette();
322 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 322 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
323 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 323 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
324 categoryBar->setPalette( pal ); 324 categoryBar->setPalette( pal );
325 categoryBar->update(); 325 categoryBar->update();
326} 326}
327 327
328void LauncherTabWidget::styleChange( QStyle & ) 328void LauncherTabWidget::styleChange( QStyle & )
329{ 329{
330 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); 330 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
331} 331}
332 332
333void LauncherTabWidget::setProgressStyle() 333void LauncherTabWidget::setProgressStyle()
334{ 334{
335 if (docLoadingWidgetProgress) { 335 if (docLoadingWidgetProgress) {
336 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); 336 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
337 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); 337 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
338 docLoadingWidgetProgress->setMargin( 1 ); 338 docLoadingWidgetProgress->setMargin( 1 );
339 docLoadingWidgetProgress->setLineWidth( 1 ); 339 docLoadingWidgetProgress->setLineWidth( 1 );
340 } 340 }
341} 341}
342 342
343void LauncherTabWidget::setBusy(bool on) 343void LauncherTabWidget::setBusy(bool on)
344{ 344{
345 if ( on ) 345 if ( on )
346 currentView()->setBusy(TRUE); 346 currentView()->setBusy(TRUE);
347 else { 347 else {
348 for ( int i = 0; i < categoryBar->count(); i++ ) { 348 for ( int i = 0; i < categoryBar->count(); i++ ) {
349 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; 349 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
350 view->setBusy( FALSE ); 350 view->setBusy( FALSE );
351 } 351 }
352 } 352 }
353} 353}
354 354
355void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 355void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
356 for (int i = 0; i < categoryBar->count(); i++ ) { 356 for (int i = 0; i < categoryBar->count(); i++ ) {
357 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 357 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
358 view->setBusyIndicatorType( str ); 358 view->setBusyIndicatorType( str );
359 } 359 }
360} 360}
361 361
362LauncherView *LauncherTabWidget::currentView(void) 362LauncherView *LauncherTabWidget::currentView(void)
363{ 363{
364 return (LauncherView*)stack->visibleWidget(); 364 return (LauncherView*)stack->visibleWidget();
365} 365}
366 366
367 367
368 368
369void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 369void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
370{ 370{
371 QDataStream stream( data, IO_ReadOnly ); 371 QDataStream stream( data, IO_ReadOnly );
372 if ( msg == "setTabView(QString,int)" ) { 372 if ( msg == "setTabView(QString,int)" ) {
373 QString id; 373 QString id;
374 stream >> id; 374 stream >> id;
375 int mode; 375 int mode;
376 stream >> mode; 376 stream >> mode;
377 if ( view(id) ) 377 if ( view(id) )
378 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 378 view(id)->setViewMode( (LauncherView::ViewMode)mode );
379 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 379 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
380 QString id; 380 QString id;
381 stream >> id; 381 stream >> id;
382 int mode; 382 int mode;
383 stream >> mode; 383 stream >> mode;
384 QString pixmapOrColor; 384 QString pixmapOrColor;
385 stream >> pixmapOrColor; 385 stream >> pixmapOrColor;
386 if ( view(id) ) 386 if ( view(id) )
387 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 387 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
388 if ( id == "Documents" ) 388 if ( id == "Documents" )
389 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 389 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
390 } else if ( msg == "setTextColor(QString,QString)" ) { 390 } else if ( msg == "setTextColor(QString,QString)" ) {
391 QString id; 391 QString id;
392 stream >> id; 392 stream >> id;
393 QString color; 393 QString color;
394 stream >> color; 394 stream >> color;
395 if ( view(id) ) 395 if ( view(id) )
396 view(id)->setTextColor( QColor(color) ); 396 view(id)->setTextColor( QColor(color) );
397 if ( id == "Documents" ) 397 if ( id == "Documents" )
398 docLoadingWidget->setTextColor( QColor(color) ); 398 docLoadingWidget->setTextColor( QColor(color) );
399 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 399 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
400 QString id; 400 QString id;
401 stream >> id; 401 stream >> id;
402 QString fam; 402 QString fam;
403 stream >> fam; 403 stream >> fam;
404 int size; 404 int size;
405 stream >> size; 405 stream >> size;
406 int weight; 406 int weight;
407 stream >> weight; 407 stream >> weight;
408 int italic; 408 int italic;
409 stream >> italic; 409 stream >> italic;
410 if ( view(id) ) { 410 if ( view(id) ) {
411 if ( !fam.isEmpty() ) { 411 if ( !fam.isEmpty() ) {
412 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 412 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
413 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; 413 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
414 } else { 414 } else {
415 view(id)->clearViewFont(); 415 view(id)->clearViewFont();
416 } 416 }
417 } 417 }
418 }else if ( msg == "setBusyIndicatorType(QString)" ) { 418 }else if ( msg == "setBusyIndicatorType(QString)" ) {
419 QString type; 419 QString type;
420 stream >> type; 420 stream >> type;
421 setBusyIndicatorType( type ); 421 setBusyIndicatorType( type );
422 }else if ( msg == "home()" ) { 422 }else if ( msg == "home()" ) {
423 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 423 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
424 if (categoryBar) 424 if (categoryBar)
425 categoryBar->nextTab(); 425 categoryBar->nextTab();
426 }else 426 }else
427 static_cast<QWidget*>(parent())->raise(); 427 static_cast<QWidget*>(parent())->raise();
428 } 428 }
429} 429}
430 430
431 431
432 432
433//--------------------------------------------------------------------------- 433//---------------------------------------------------------------------------
434 434
435Launcher::Launcher() 435Launcher::Launcher()
436 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 436 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
437{ 437{
438 tabs = 0; 438 tabs = 0;
439 tb = 0; 439 tb = 0;
440 Config cfg( "Launcher" ); 440 Config cfg( "Launcher" );
441 cfg.setGroup( "DocTab" ); 441 cfg.setGroup( "DocTab" );
442 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 442 docTabEnabled = cfg.readBoolEntry( "Enable", true );
443} 443}
444 444
445void Launcher::createGUI() 445void Launcher::createGUI()
446{ 446{
447 setCaption( tr("Launcher") ); 447 setCaption( tr("Launcher") );
448 448
449 // we have a pretty good idea how big we'll be 449 // we have a pretty good idea how big we'll be
450 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 450 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
451 451
452 tb = new TaskBar; 452 tb = new TaskBar;
453 tabs = new LauncherTabWidget( this ); 453 tabs = new LauncherTabWidget( this );
454 setCentralWidget( tabs ); 454 setCentralWidget( tabs );
455 455
456 ServerInterface::dockWidget( tb, ServerInterface::Bottom ); 456 ServerInterface::dockWidget( tb, ServerInterface::Bottom );
457 tb->show(); 457 tb->show();
458 458
459 qApp->installEventFilter( this ); 459 qApp->installEventFilter( this );
460 460
461 461
462 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); 462 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) );
463 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); 463 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) );
464 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); 464 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) );
465 465
466 connect( tb, SIGNAL(tabSelected(const QString&)), 466 connect( tb, SIGNAL(tabSelected(const QString&)),
467 this, SLOT(showTab(const QString&)) ); 467 this, SLOT(showTab(const QString&)) );
468 connect( tabs, SIGNAL(selected(const QString&)), 468 connect( tabs, SIGNAL(selected(const QString&)),
469 this, SLOT(viewSelected(const QString&)) ); 469 this, SLOT(viewSelected(const QString&)) );
470 connect( tabs, SIGNAL(clicked(const AppLnk*)), 470 connect( tabs, SIGNAL(clicked(const AppLnk*)),
471 this, SLOT(select(const AppLnk*))); 471 this, SLOT(select(const AppLnk*)));
472 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 472 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
473 this, SLOT(properties(AppLnk*))); 473 this, SLOT(properties(AppLnk*)));
474 474
475#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 475#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
477 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), 477 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
478 this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); 478 this, SLOT(systemMessage(const QCString&,const QByteArray&)) );
479#endif 479#endif
480 480
481 // all documents 481 // all documents
482 QImage img( Resource::loadImage( "DocsIcon" ) ); 482 QImage img( Resource::loadImage( "DocsIcon" ) );
483 QPixmap pm; 483 QPixmap pm;
484 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 484 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
485 // It could add this itself if it handles docs 485 // It could add this itself if it handles docs
486 486
487 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); 487 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
488 488
489 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); 489 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
490 qApp->setMainWidget( this ); 490 qApp->setMainWidget( this );
491 QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); 491 QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
492} 492}
493 493
494Launcher::~Launcher() 494Launcher::~Launcher()
495{ 495{
496 if ( tb ) 496 if ( tb )
497 destroyGUI(); 497 destroyGUI();
498} 498}
499 499
500 bool Launcher::requiresDocuments() const 500 bool Launcher::requiresDocuments() const
501 { 501 {
502 Config cfg( "Launcher" ); 502 Config cfg( "Launcher" );
503 cfg.setGroup( "DocTab" ); 503 cfg.setGroup( "DocTab" );
504 return cfg.readBoolEntry( "Enable", true ); 504 return cfg.readBoolEntry( "Enable", true );
505} 505}
506 506
507void Launcher::makeVisible() 507void Launcher::makeVisible()
508{ 508{
509 showMaximized(); 509 showMaximized();
510} 510}
511 511
512void Launcher::destroyGUI() 512void Launcher::destroyGUI()
513{ 513{
514 delete tb; 514 delete tb;
515 tb = 0; 515 tb = 0;
516 delete tabs; 516 delete tabs;
517 tabs =0; 517 tabs =0;
518} 518}
519 519
520bool Launcher::eventFilter( QObject*, QEvent *ev ) 520bool Launcher::eventFilter( QObject*, QEvent *ev )
521{ 521{
522#ifdef QT_QWS_CUSTOM 522#ifdef QT_QWS_CUSTOM
523 if ( ev->type() == QEvent::KeyPress ) { 523 if ( ev->type() == QEvent::KeyPress ) {
524 QKeyEvent *ke = (QKeyEvent *)ev; 524 QKeyEvent *ke = (QKeyEvent *)ev;
525 if ( ke->key() == Qt::Key_F11 ) { // menu key 525 if ( ke->key() == Qt::Key_F11 ) { // menu key
526 QWidget *active = qApp->activeWindow(); 526 QWidget *active = qApp->activeWindow();
527 if ( active && active->isPopup() ) 527 if ( active && active->isPopup() )
528 active->close(); 528 active->close();
529 else { 529 else {
530 Global::terminateBuiltin("calibrate"); // No tr 530 Global::terminateBuiltin("calibrate"); // No tr
531 tb->launchStartMenu(); 531 tb->launchStartMenu();
532 } 532 }
533 return TRUE; 533 return TRUE;
534 } 534 }
535 } 535 }
536#else 536#else
537 Q_UNUSED(ev); 537 Q_UNUSED(ev);
538#endif 538#endif
539 return FALSE; 539 return FALSE;
540} 540}
541 541
542void Launcher::toggleSymbolInput() 542void Launcher::toggleSymbolInput()
543{ 543{
544 tb->toggleSymbolInput(); 544 tb->toggleSymbolInput();
545} 545}
546 546
547void Launcher::toggleNumLockState() 547void Launcher::toggleNumLockState()
548{ 548{
549 tb->toggleNumLockState(); 549 tb->toggleNumLockState();
550} 550}
551 551
552void Launcher::toggleCapsLockState() 552void Launcher::toggleCapsLockState()
553{ 553{
554 tb->toggleCapsLockState(); 554 tb->toggleCapsLockState();
555} 555}
556 556
557static bool isVisibleWindow(int wid) 557static bool isVisibleWindow(int wid)
558{ 558{
559#ifdef Q_WS_QWS 559#ifdef Q_WS_QWS
560 const QList<QWSWindow> &list = qwsServer->clientWindows(); 560 const QList<QWSWindow> &list = qwsServer->clientWindows();
561 QWSWindow* w; 561 QWSWindow* w;
562 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 562 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
563 if ( w->winId() == wid ) 563 if ( w->winId() == wid )
564 return !w->isFullyObscured(); 564 return !w->isFullyObscured();
565 } 565 }
566#endif 566#endif
567 return FALSE; 567 return FALSE;
568} 568}
569 569
570void Launcher::viewSelected(const QString& s) 570void Launcher::viewSelected(const QString& s)
571{ 571{
572 setCaption( s + tr(" - Launcher") ); 572 setCaption( s + tr(" - Launcher") );
573} 573}
574 574
575void Launcher::showTab(const QString& id) 575void Launcher::showTab(const QString& id)
576{ 576{
577 tabs->categoryBar->showTab(id); 577 tabs->categoryBar->showTab(id);
578 raise(); 578 raise();
579} 579}
580 580
581void Launcher::select( const AppLnk *appLnk ) 581void Launcher::select( const AppLnk *appLnk )
582{ 582{
583 if ( appLnk->type() == "Folder" ) { // No tr 583 if ( appLnk->type() == "Folder" ) { // No tr
584 // Not supported: flat is simpler for the user 584 // Not supported: flat is simpler for the user
585 } else { 585 } else {
586 if ( appLnk->exec().isNull() ) { 586 if ( appLnk->exec().isNull() ) {
587 int i = QMessageBox::information(this,tr("No application"), 587 int i = QMessageBox::information(this,tr("No application"),
588 tr("<p>No application is defined for this document." 588 tr("<p>No application is defined for this document."
589 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); 589 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
590 590
591 /* ### Fixme */ 591 /* ### Fixme */
592 if ( i == 1 ) 592 if ( i == 1 )
593 Global::execute("textedit",appLnk->file()); 593 Global::execute("textedit",appLnk->file());
594 594
595 return; 595 return;
596 } 596 }
597 tabs->setBusy(TRUE); 597 tabs->setBusy(TRUE);
598 emit executing( appLnk ); 598 emit executing( appLnk );
599 appLnk->execute(); 599 appLnk->execute();
600 } 600 }
601} 601}
602 602
603void Launcher::properties( AppLnk *appLnk ) 603void Launcher::properties( AppLnk *appLnk )
604{ 604{
605 if ( appLnk->type() == "Folder" ) { // No tr 605 if ( appLnk->type() == "Folder" ) { // No tr
606 // Not supported: flat is simpler for the user 606 // Not supported: flat is simpler for the user
607 } else { 607 } else {
608/* ### libqtopia FIXME also moving docLnks... */ 608/* ### libqtopia FIXME also moving docLnks... */
609 LnkProperties prop(appLnk,0 ); 609 LnkProperties prop(appLnk,0 );
610 610
611 QPEApplication::execDialog( &prop ); 611 QPEApplication::execDialog( &prop );
612 } 612 }
613} 613}
614 614
615void Launcher::storageChanged( const QList<FileSystem> &fs ) 615void Launcher::storageChanged( const QList<FileSystem> &fs )
616{ 616{
617 // ### update combo boxes if we had a combo box for the storage type 617 // ### update combo boxes if we had a combo box for the storage type
618} 618}
619 619
620void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 620void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
621{ 621{
622 QDataStream stream( data, IO_ReadOnly ); 622 QDataStream stream( data, IO_ReadOnly );
623 if ( msg == "busy()" ) { 623 if ( msg == "busy()" ) {
624 tb->startWait(); 624 tb->startWait();
625 } else if ( msg == "notBusy(QString)" ) { 625 } else if ( msg == "notBusy(QString)" ) {
626 QString app; 626 QString app;
627 stream >> app; 627 stream >> app;
628 tabs->setBusy(FALSE); 628 tabs->setBusy(FALSE);
629 tb->stopWait(app); 629 tb->stopWait(app);
630 } else if (msg == "applyStyle()") { 630 } else if (msg == "applyStyle()") {
631 tabs->currentView()->relayout(); 631 tabs->currentView()->relayout();
632 } 632 }
633} 633}
634 634
635// These are the update functions from the server 635// These are the update functions from the server
636void Launcher::typeAdded( const QString& type, const QString& name, 636void Launcher::typeAdded( const QString& type, const QString& name,
637 const QPixmap& pixmap, const QPixmap& ) 637 const QPixmap& pixmap, const QPixmap& )
638{ 638{
639 tabs->newView( type, pixmap, name ); 639 tabs->newView( type, pixmap, name );
640 ids.append( type ); 640 ids.append( type );
641 /* this will be called in applicationScanningProgress with value 100! */ 641 /* this will be called in applicationScanningProgress with value 100! */
642// tb->refreshStartMenu(); 642// tb->refreshStartMenu();
643 643
644 static bool first = TRUE; 644 static bool first = TRUE;
645 if ( first ) { 645 if ( first ) {
646 first = FALSE; 646 first = FALSE;
647 tabs->categoryBar->showTab(type); 647 tabs->categoryBar->showTab(type);
648 } 648 }
649 649
650 tabs->view( type )->setUpdatesEnabled( FALSE ); 650 tabs->view( type )->setUpdatesEnabled( FALSE );
651 tabs->view( type )->setSortEnabled( FALSE ); 651 tabs->view( type )->setSortEnabled( FALSE );
652} 652}
653 653
654void Launcher::typeRemoved( const QString& type ) 654void Launcher::typeRemoved( const QString& type )
655{ 655{
656 tabs->view( type )->removeAllItems(); 656 tabs->view( type )->removeAllItems();
657 tabs->deleteView( type ); 657 tabs->deleteView( type );
658 ids.remove( type ); 658 ids.remove( type );
659 /* this will be called in applicationScanningProgress with value 100! */ 659 /* this will be called in applicationScanningProgress with value 100! */
660// tb->refreshStartMenu(); 660// tb->refreshStartMenu();
661} 661}
662 662
663void Launcher::applicationAdded( const QString& type, const AppLnk& app ) 663void Launcher::applicationAdded( const QString& type, const AppLnk& app )
664{ 664{
665 if ( app.type() == "Separator" ) // No tr 665 if ( app.type() == "Separator" ) // No tr
666 return; 666 return;
667 667
668 LauncherView *view = tabs->view( type ); 668 LauncherView *view = tabs->view( type );
669 if ( view ) 669 if ( view )
670 view->addItem( new AppLnk( app ), FALSE ); 670 view->addItem( new AppLnk( app ), FALSE );
671 else 671 else
672 qWarning("addAppLnk: No view for type %s. Can't add app %s!", 672 qWarning("addAppLnk: No view for type %s. Can't add app %s!",
673 type.latin1(),app.name().latin1() ); 673 type.latin1(),app.name().latin1() );
674 674
675 MimeType::registerApp( app ); 675 MimeType::registerApp( app );
676} 676}
677 677
678void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) 678void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
679{ 679{
680 LauncherView *view = tabs->view( type ); 680 LauncherView *view = tabs->view( type );
681 if ( view ) 681 if ( view )
682 view->removeLink( app.linkFile() ); 682 view->removeLink( app.linkFile() );
683 else 683 else
684 owarn << "removeAppLnk: No view for " << type << "!" << oendl; 684 owarn << "removeAppLnk: No view for " << type << "!" << oendl;
685} 685}
686 686
687void Launcher::allApplicationsRemoved() 687void Launcher::allApplicationsRemoved()
688{ 688{
689 MimeType::clear(); 689 MimeType::clear();
690 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) 690 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
691 tabs->view( (*it) )->removeAllItems(); 691 tabs->view( (*it) )->removeAllItems();
692} 692}
693 693
694void Launcher::documentAdded( const DocLnk& doc ) 694void Launcher::documentAdded( const DocLnk& doc )
695{ 695{
696 tabs->docView()->addItem( new DocLnk( doc ), FALSE ); 696 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
697} 697}
698 698
699void Launcher::aboutToAddBegin()
700{
701 tabs->docView()->setUpdatesEnabled( false );
702}
703
704void Launcher::aboutToAddEnd()
705{
706 tabs->docView()->setUpdatesEnabled( true );
707}
708
699void Launcher::showLoadingDocs() 709void Launcher::showLoadingDocs()
700{ 710{
701 tabs->docView()->hide(); 711 tabs->docView()->hide();
702} 712}
703 713
704void Launcher::showDocTab() 714void Launcher::showDocTab()
705{ 715{
706 if ( tabs->categoryBar->currentView() == tabs->docView() ) 716 if ( tabs->categoryBar->currentView() == tabs->docView() )
707 tabs->docView()->show(); 717 tabs->docView()->show();
708} 718}
709 719
710void Launcher::documentRemoved( const DocLnk& doc ) 720void Launcher::documentRemoved( const DocLnk& doc )
711{ 721{
712 tabs->docView()->removeLink( doc.linkFile() ); 722 tabs->docView()->removeLink( doc.linkFile() );
713} 723}
714 724
715void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) 725void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
716{ 726{
717 documentRemoved( oldDoc ); 727 documentRemoved( oldDoc );
718 documentAdded( newDoc ); 728 documentAdded( newDoc );
719} 729}
720 730
721void Launcher::allDocumentsRemoved() 731void Launcher::allDocumentsRemoved()
722{ 732{
723 tabs->docView()->removeAllItems(); 733 tabs->docView()->removeAllItems();
724} 734}
725 735
726void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) 736void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
727{ 737{
728 tb->setApplicationState( name, state ); 738 tb->setApplicationState( name, state );
729} 739}
730 740
731void Launcher::applicationScanningProgress( int percent ) 741void Launcher::applicationScanningProgress( int percent )
732{ 742{
733 switch ( percent ) { 743 switch ( percent ) {
734 case 0: { 744 case 0: {
735 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 745 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
736 tabs->view( (*it) )->setUpdatesEnabled( FALSE ); 746 tabs->view( (*it) )->setUpdatesEnabled( FALSE );
737 tabs->view( (*it) )->setSortEnabled( FALSE ); 747 tabs->view( (*it) )->setSortEnabled( FALSE );
738 } 748 }
739 break; 749 break;
740 } 750 }
741 case 100: { 751 case 100: {
742 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 752 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
743 tabs->view( (*it) )->setUpdatesEnabled( TRUE ); 753 tabs->view( (*it) )->setUpdatesEnabled( TRUE );
744 tabs->view( (*it) )->setSortEnabled( TRUE ); 754 tabs->view( (*it) )->setSortEnabled( TRUE );
745 } 755 }
746 tb->refreshStartMenu(); 756 tb->refreshStartMenu();
747 break; 757 break;
748 } 758 }
749 default: 759 default:
750 break; 760 break;
751 } 761 }
752} 762}
753 763
754void Launcher::documentScanningProgress( int percent ) 764void Launcher::documentScanningProgress( int percent )
755{ 765{
756 switch ( percent ) { 766 switch ( percent ) {
757 case 0: { 767 case 0: {
758 tabs->setLoadingProgress( 0 ); 768 tabs->setLoadingProgress( 0 );
759 tabs->setLoadingWidgetEnabled( TRUE ); 769 tabs->setLoadingWidgetEnabled( TRUE );
760 tabs->docView()->setUpdatesEnabled( FALSE ); 770 tabs->docView()->setUpdatesEnabled( FALSE );
761 tabs->docView()->setSortEnabled( FALSE ); 771 tabs->docView()->setSortEnabled( FALSE );
762 break; 772 break;
763 } 773 }
764 case 100: { 774 case 100: {
765 tabs->docView()->updateTools(); 775 tabs->docView()->updateTools();
766 tabs->docView()->setSortEnabled( TRUE ); 776 tabs->docView()->setSortEnabled( TRUE );
767 tabs->docView()->setUpdatesEnabled( TRUE ); 777 tabs->docView()->setUpdatesEnabled( TRUE );
768 tabs->setLoadingWidgetEnabled( FALSE ); 778 tabs->setLoadingWidgetEnabled( FALSE );
769 break; 779 break;
770 } 780 }
771 default: 781 default:
772 tabs->setLoadingProgress( percent ); 782 tabs->setLoadingProgress( percent );
773 break; 783 break;
774 } 784 }
775} 785}
776 786
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h
index 4f3ff8c..29bd7db 100644
--- a/core/launcher/launcher.h
+++ b/core/launcher/launcher.h
@@ -1,157 +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 84
85private: 85private:
86 Launcher *launcher; 86 Launcher *launcher;
87 LauncherView *docview; 87 LauncherView *docview;
88 88
89 QWidgetStack *stack; 89 QWidgetStack *stack;
90 LauncherView *docLoadingWidget; 90 LauncherView *docLoadingWidget;
91 QProgressBar *docLoadingWidgetProgress; 91 QProgressBar *docLoadingWidgetProgress;
92 bool docLoadingWidgetEnabled; 92 bool docLoadingWidgetEnabled;
93}; 93};
94 94
95class Launcher : public QMainWindow, public ServerInterface 95class Launcher : public QMainWindow, public ServerInterface
96{ 96{
97 Q_OBJECT 97 Q_OBJECT
98public: 98public:
99 Launcher(); 99 Launcher();
100 ~Launcher(); 100 ~Launcher();
101 101
102 // implementing ServerInterface 102 // implementing ServerInterface
103 void createGUI(); 103 void createGUI();
104 void destroyGUI(); 104 void destroyGUI();
105 void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap ); 105 void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap );
106 void typeRemoved( const QString& type ); 106 void typeRemoved( const QString& type );
107 void applicationAdded( const QString& type, const AppLnk& doc ); 107 void applicationAdded( const QString& type, const AppLnk& doc );
108 void applicationRemoved( const QString& type, const AppLnk& doc ); 108 void applicationRemoved( const QString& type, const AppLnk& doc );
109 void allApplicationsRemoved(); 109 void allApplicationsRemoved();
110 void applicationStateChanged( const QString& name, ApplicationState state ); 110 void applicationStateChanged( const QString& name, ApplicationState state );
111 void documentAdded( const DocLnk& doc ); 111 void documentAdded( const DocLnk& doc );
112 void documentRemoved( const DocLnk& doc ); 112 void documentRemoved( const DocLnk& doc );
113 void aboutToAddBegin();
114 void aboutToAddEnd();
113 void allDocumentsRemoved(); 115 void allDocumentsRemoved();
114 void documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ); 116 void documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc );
115 void storageChanged( const QList<FileSystem> & ); 117 void storageChanged( const QList<FileSystem> & );
116 void applicationScanningProgress( int percent ); 118 void applicationScanningProgress( int percent );
117 void documentScanningProgress( int percent ); 119 void documentScanningProgress( int percent );
118 bool requiresApplications() const { return TRUE; } 120 bool requiresApplications() const { return TRUE; }
119 bool requiresDocuments() const; 121 bool requiresDocuments() const;
120 void showLoadingDocs(); 122 void showLoadingDocs();
121 void showDocTab(); 123 void showDocTab();
122 124
123 QStringList idList() const { return ids; } 125 QStringList idList() const { return ids; }
124 126
125public slots: 127public slots:
126 void viewSelected(const QString&); 128 void viewSelected(const QString&);
127 void showTab(const QString&); 129 void showTab(const QString&);
128 void select( const AppLnk * ); 130 void select( const AppLnk * );
129 void properties( AppLnk * ); 131 void properties( AppLnk * );
130 void makeVisible(); 132 void makeVisible();
131 133
132signals: 134signals:
133 void executing( const AppLnk * ); 135 void executing( const AppLnk * );
134 136
135private slots: 137private slots:
136 void systemMessage( const QCString &, const QByteArray &); 138 void systemMessage( const QCString &, const QByteArray &);
137 void toggleSymbolInput(); 139 void toggleSymbolInput();
138 void toggleNumLockState(); 140 void toggleNumLockState();
139 void toggleCapsLockState(); 141 void toggleCapsLockState();
140 142
141protected: 143protected:
142 bool eventFilter( QObject *o, QEvent *ev ); 144 bool eventFilter( QObject *o, QEvent *ev );
143 145
144private: 146private:
145 void updateApps(); 147 void updateApps();
146 void loadDocs(); 148 void loadDocs();
147 void updateDocs(); 149 void updateDocs();
148 void updateTabs(); 150 void updateTabs();
149 151
150 LauncherTabWidget *tabs; 152 LauncherTabWidget *tabs;
151 QStringList ids; 153 QStringList ids;
152 TaskBar *tb; 154 TaskBar *tb;
153 155
154 bool docTabEnabled; 156 bool docTabEnabled;
155}; 157};
156 158
157#endif // LAUNCHERVIEW_H 159#endif // LAUNCHERVIEW_H
diff --git a/core/launcher/serverinterface.h b/core/launcher/serverinterface.h
index e57ea51..132766f 100644
--- a/core/launcher/serverinterface.h
+++ b/core/launcher/serverinterface.h
@@ -1,72 +1,74 @@
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 SERVER_INTERFACE_H 20#ifndef SERVER_INTERFACE_H
21#define SERVER_INTERFACE_H 21#define SERVER_INTERFACE_H
22 22
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qpixmap.h> 25#include <qpixmap.h>
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qtopia/applnk.h> 27#include <qtopia/applnk.h>
28#include <qtopia/storage.h> 28#include <qtopia/storage.h>
29 29
30 30
31class ServerInterface { 31class ServerInterface {
32public: 32public:
33 virtual ~ServerInterface(); 33 virtual ~ServerInterface();
34 34
35 virtual void createGUI() = 0; 35 virtual void createGUI() = 0;
36 virtual void destroyGUI() = 0; 36 virtual void destroyGUI() = 0;
37 37
38 // These notify of the application categories, like what is used in the current launcher tabs, 38 // These notify of the application categories, like what is used in the current launcher tabs,
39 // for example "Applications", "Games" etc. 39 // for example "Applications", "Games" etc.
40 virtual void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap ) = 0; 40 virtual void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap ) = 0;
41 virtual void typeRemoved( const QString& type ) = 0; 41 virtual void typeRemoved( const QString& type ) = 0;
42 42
43 // These functions notify when an application is added or removed and to which category it belongs 43 // These functions notify when an application is added or removed and to which category it belongs
44 virtual void applicationAdded( const QString& type, const AppLnk& doc ) = 0; 44 virtual void applicationAdded( const QString& type, const AppLnk& doc ) = 0;
45 virtual void applicationRemoved( const QString& type, const AppLnk& doc ) = 0; 45 virtual void applicationRemoved( const QString& type, const AppLnk& doc ) = 0;
46 virtual void allApplicationsRemoved() = 0; 46 virtual void allApplicationsRemoved() = 0;
47 // Useful for wait icons, or running application lists etc 47 // Useful for wait icons, or running application lists etc
48 enum ApplicationState { Launching, Running, Terminated }; 48 enum ApplicationState { Launching, Running, Terminated };
49 virtual void applicationStateChanged( const QString& name, ApplicationState state ) = 0; 49 virtual void applicationStateChanged( const QString& name, ApplicationState state ) = 0;
50 static const AppLnkSet& appLnks(); 50 static const AppLnkSet& appLnks();
51 51
52 // These functions notify of adding, removal and changes of document links used in the documents tab for example 52 // These functions notify of adding, removal and changes of document links used in the documents tab for example
53 virtual void aboutToAddBegin() {}
54 virtual void aboutToAddEnd() {}
53 virtual void documentAdded( const DocLnk& doc ) = 0; 55 virtual void documentAdded( const DocLnk& doc ) = 0;
54 virtual void documentRemoved( const DocLnk& doc ) = 0; 56 virtual void documentRemoved( const DocLnk& doc ) = 0;
55 virtual void allDocumentsRemoved() = 0; 57 virtual void allDocumentsRemoved() = 0;
56 virtual void documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) = 0; 58 virtual void documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) = 0;
57 59
58 virtual void storageChanged( const QList<FileSystem> & ) = 0; 60 virtual void storageChanged( const QList<FileSystem> & ) = 0;
59 61
60 virtual void applicationScanningProgress( int percent ) = 0; 62 virtual void applicationScanningProgress( int percent ) = 0;
61 virtual void documentScanningProgress( int percent ) = 0; 63 virtual void documentScanningProgress( int percent ) = 0;
62 64
63 // Tells the server if the GUI needs to be updated about documents or applnks 65 // Tells the server if the GUI needs to be updated about documents or applnks
64 virtual bool requiresApplications() const = 0; 66 virtual bool requiresApplications() const = 0;
65 virtual bool requiresDocuments() const = 0; 67 virtual bool requiresDocuments() const = 0;
66 68
67 enum DockArea { Top, Bottom, Left, Right }; 69 enum DockArea { Top, Bottom, Left, Right };
68 static void dockWidget( QWidget *w, DockArea placement ); 70 static void dockWidget( QWidget *w, DockArea placement );
69}; 71};
70 72
71 73
72#endif // SERVER_INTERFACE_H 74#endif // SERVER_INTERFACE_H