summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp1188
-rw-r--r--core/launcher/launcher.h31
2 files changed, 637 insertions, 582 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index bcc2495..d9fc8e4 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -17,16 +17,18 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT 21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class. 22// have this class.
23#define QTOPIA_INTERNAL_FSLP 23#define QTOPIA_INTERNAL_FSLP
24 24
25//#include <opie/ofiledialog.h>
26#include <opie/ofileselector.h>
25#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
26#include <qpe/resource.h> 28#include <qpe/resource.h>
27#include <qpe/applnk.h> 29#include <qpe/applnk.h>
28#include <qpe/config.h> 30#include <qpe/config.h>
29#include <qpe/global.h> 31#include <qpe/global.h>
30#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
31#include <qpe/mimetype.h> 33#include <qpe/mimetype.h>
32#include <qpe/storage.h> 34#include <qpe/storage.h>
@@ -84,44 +86,44 @@ namespace {
84 cfg->setGroup("mimetypes" ); 86 cfg->setGroup("mimetypes" );
85 tmpMime = cfg->readBoolEntry("all" ,true); 87 tmpMime = cfg->readBoolEntry("all" ,true);
86 if( tmpMime ){ 88 if( tmpMime ){
87 mimes << QString::null; 89 mimes << QString::null;
88 return mimes; 90 return mimes;
89 }else{ 91 }else{
90 tmpMime = cfg->readBoolEntry("audio", true ); 92 tmpMime = cfg->readBoolEntry("audio", true );
91 if(tmpMime ) 93 if(tmpMime )
92 mimes.append("audio/*" ); 94 mimes.append("audio/*" );
93 95
94 tmpMime = cfg->readBoolEntry("image", true ); 96 tmpMime = cfg->readBoolEntry("image", true );
95 if(tmpMime ) 97 if(tmpMime )
96 mimes.append("image/*" ); 98 mimes.append("image/*" );
97 99
98 tmpMime = cfg->readBoolEntry("text", true ); 100 tmpMime = cfg->readBoolEntry("text", true );
99 if(tmpMime ) 101 if(tmpMime )
100 mimes.append("text/*"); 102 mimes.append("text/*");
101 103
102 tmpMime = cfg->readBoolEntry("video", true ); 104 tmpMime = cfg->readBoolEntry("video", true );
103 if(tmpMime ) 105 if(tmpMime )
104 mimes.append("video/*" ); 106 mimes.append("video/*" );
105 } 107 }
106 return mimes; 108 return mimes;
107 } 109 }
108 110
109} 111}
110 112
111 113
112 114
113//#define SHOW_ALL 115//#define SHOW_ALL
114 116
115class CategoryTab : public QTab 117class CategoryTab : public QTab
116{ 118{
117public: 119public:
118 CategoryTab( const QIconSet &icon, const QString &text=QString::null ) 120 CategoryTab( const QIconSet &icon, const QString &text=QString::null )
119 : QTab( icon, text ) 121 : QTab( icon, text )
120 { 122 {
121 } 123 }
122 124
123 QColor bgColor; 125 QColor bgColor;
124 QColor fgColor; 126 QColor fgColor;
125}; 127};
126 128
127//=========================================================================== 129//===========================================================================
@@ -131,80 +133,80 @@ CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
131{ 133{
132 categoryBar = 0; 134 categoryBar = 0;
133 stack = 0; 135 stack = 0;
134} 136}
135 137
136void CategoryTabWidget::prevTab() 138void CategoryTabWidget::prevTab()
137{ 139{
138 if ( categoryBar ) { 140 if ( categoryBar ) {
139 int n = categoryBar->count(); 141 int n = categoryBar->count();
140 int tab = categoryBar->currentTab(); 142 int tab = categoryBar->currentTab();
141 if ( tab >= 0 ) 143 if ( tab >= 0 )
142 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 144 categoryBar->setCurrentTab( (tab - 1 + n)%n );
143 } 145 }
144} 146}
145 147
146void CategoryTabWidget::nextTab() 148void CategoryTabWidget::nextTab()
147{ 149{
148 if ( categoryBar ) { 150 if ( categoryBar ) {
149 int n = categoryBar->count(); 151 int n = categoryBar->count();
150 int tab = categoryBar->currentTab(); 152 int tab = categoryBar->currentTab();
151 categoryBar->setCurrentTab( (tab + 1)%n ); 153 categoryBar->setCurrentTab( (tab + 1)%n );
152 } 154 }
153} 155}
154 156
155 157
156void CategoryTabWidget::showTab(const QString& id) 158void CategoryTabWidget::showTab(const QString& id)
157{ 159{
158 if ( categoryBar ) { 160 if ( categoryBar ) {
159 int idx = ids.findIndex( id ); 161 int idx = ids.findIndex( id );
160 categoryBar->setCurrentTab( idx ); 162 categoryBar->setCurrentTab( idx );
161 } 163 }
162} 164}
163 165
164void CategoryTabWidget::addItem( const QString& linkfile ) 166void CategoryTabWidget::addItem( const QString& linkfile )
165{ 167{
166 int i=0; 168 int i=0;
167 AppLnk *app = new AppLnk(linkfile); 169 AppLnk *app = new AppLnk(linkfile);
168 if ( !app->isValid() ) { 170 if ( !app->isValid() ) {
169 delete app; 171 delete app;
170 app=0; 172 app=0;
171 } 173 }
172 if ( !app || !app->file().isEmpty() ) { 174 if ( !app || !app->file().isEmpty() ) {
173 // A document 175 // A document
174 delete app; 176 delete app;
175 app = new DocLnk(linkfile); 177 app = new DocLnk(linkfile);
176 if ( app->fileKnown() ) { 178 if ( app->fileKnown() ) {
177 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 179 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
178 } else { 180 } else {
179 ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); 181 ((LauncherView*)(stack->widget(ids.count()-1)))->sort();
180 delete app; 182 delete app;
181 } 183 }
182 return; 184 return;
183 } 185 }
184 // An application 186 // An application
185 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 187 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
186 if ( !(*it).isEmpty() ) { 188 if ( !(*it).isEmpty() ) {
187 QRegExp tf(*it,FALSE,TRUE); 189 QRegExp tf(*it,FALSE,TRUE);
188 if ( tf.match(app->type()) >= 0 ) { 190 if ( tf.match(app->type()) >= 0 ) {
189 ((LauncherView*)stack->widget(i))->addItem(app); 191 ((LauncherView*)stack->widget(i))->addItem(app);
190 return; 192 return;
191 } 193 }
192 i++; 194 i++;
193 } 195 }
194 } 196 }
195 197
196 QCopEnvelope e("QPE/TaskBar","reloadApps()"); 198 QCopEnvelope e("QPE/TaskBar","reloadApps()");
197} 199}
198 200
199void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, 201void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
200 AppLnkSet* docFolder, const QList<FileSystem> &fs) 202 AppLnkSet* /*docFolder*/, const QList<FileSystem> & /*fs*/)
201{ 203{
202 QString current; 204 QString current;
203 if ( categoryBar ) { 205 if ( categoryBar ) {
204 int c = categoryBar->currentTab(); 206 int c = categoryBar->currentTab();
205 if ( c >= 0 ) current = ids[c]; 207 if ( c >= 0 ) current = ids[c];
206 } 208 }
207 209
208 delete categoryBar; 210 delete categoryBar;
209 categoryBar = new CategoryTabBar( this ); 211 categoryBar = new CategoryTabBar( this );
210 QPalette pal = categoryBar->palette(); 212 QPalette pal = categoryBar->palette();
@@ -217,195 +219,212 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
217 tabs=0; 219 tabs=0;
218 220
219 ids.clear(); 221 ids.clear();
220 222
221 Config cfg("Launcher"); 223 Config cfg("Launcher");
222 224
223 QStringList types = rootFolder->types(); 225 QStringList types = rootFolder->types();
224 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 226 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
225 if ( !(*it).isEmpty() ) { 227 if ( !(*it).isEmpty() ) {
226 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); 228 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it));
227 setTabAppearance( *it, cfg ); 229 setTabAppearance( *it, cfg );
228 } 230 }
229 } 231 }
230 QListIterator<AppLnk> it( rootFolder->children() ); 232 QListIterator<AppLnk> it( rootFolder->children() );
231 AppLnk* l; 233 AppLnk* l;
232 while ( (l=it.current()) ) { 234 while ( (l=it.current()) ) {
233 if ( l->type() == "Separator" ) { // No tr 235 if ( l->type() == "Separator" ) { // No tr
234 rootFolder->remove(l); 236 rootFolder->remove(l);
235 delete l; 237 delete l;
236 } else { 238 } else {
237 int i=0; 239 int i=0;
238 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 240 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
239 if ( *it == l->type() ) 241 if ( *it == l->type() )
240 ((LauncherView*)stack->widget(i))->addItem(l,FALSE); 242 ((LauncherView*)stack->widget(i))->addItem(l,FALSE);
241 i++; 243 i++;
242 } 244 }
243 } 245 }
244 ++it; 246 ++it;
245 } 247 }
246 rootFolder->detachChildren(); 248 rootFolder->detachChildren();
247 for (int i=0; i<tabs; i++) 249 for (int i=0; i<tabs; i++)
248 ((LauncherView*)stack->widget(i))->sort(); 250 ((LauncherView*)stack->widget(i))->sort();
249 251
250 // all documents 252 // all documents
251 QImage img( Resource::loadImage( "DocsIcon" ) ); 253 QImage img( Resource::loadImage( "DocsIcon" ) );
252 QPixmap pm; 254 QPixmap pm;
253 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 255 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
254 docview = newView( "Documents", // No tr
255 pm, tr("Documents"));
256 docview->populate( docFolder, QString::null );
257 docFolder->detachChildren();
258 docview->setFileSystems(fs);
259 docview->setToolsEnabled(TRUE);
260 setTabAppearance( "Documents", cfg ); // No tr
261 256
262 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); 257 //ljpotter
258 CategoryTab *catTab ;
259 catTab = new CategoryTab( pm, "Documents" );
260
261 categoryBar->addTab( catTab );
262
263 fileSel = new DocumentTab( stack, 4, 0, "/","");
264 stack->addWidget( fileSel, tabs++ );
265
266 // fileSel->hide();
267
268 connect( fileSel, SIGNAL( fileSelected( const DocLnk & )),
269 this, SLOT(clickie(const DocLnk&)) );
270
271// connect( fileSel, SIGNAL( fileSelected( const QString & )),
272// this, SLOT(clickie(const QString&)) );
273
274 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) );
263 275
264 ((LauncherView*)stack->widget(0))->setFocus(); 276 ((LauncherView*)stack->widget(0))->setFocus();
265 277
266 cfg. setGroup ( "GUI" ); 278 cfg. setGroup ( "GUI" );
267 setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null )); 279 setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null ));
268 280
269 if ( !current.isNull() ) { 281 if ( !current.isNull() ) {
270 showTab(current); 282 showTab(current);
271 } 283 }
272 284
273 categoryBar->show(); 285 categoryBar->show();
274 stack->show(); 286 stack->show();
275 287
288
276 QCopEnvelope e("QPE/TaskBar","reloadApps()"); 289 QCopEnvelope e("QPE/TaskBar","reloadApps()");
277} 290}
278 291
292void CategoryTabWidget::clickie(const DocLnk &lnk) {
293 lnk.execute();
294 // fileSel->reparse();
295}
296
297void CategoryTabWidget::clickie(const QString &appStr) {
298// DocLnk lnk(appStr);
299// lnk.execute();
300}
301
279void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) 302void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg )
280{ 303{
281 QString grp( "Tab %1" ); // No tr 304 QString grp( "Tab %1" ); // No tr
282 cfg.setGroup( grp.arg(id) ); 305 cfg.setGroup( grp.arg(id) );
283 LauncherView *v = view( id ); 306 LauncherView *v = view( id );
284 int idx = ids.findIndex( id ); 307 int idx = ids.findIndex( id );
285 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); 308 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx );
286 309
287 // View 310 // View
288 QString view = cfg.readEntry( "View", "Icon" ); 311 QString view = cfg.readEntry( "View", "Icon" );
289 if ( view == "List" ) // No tr 312 if ( view == "List" ) // No tr
290 v->setViewMode( LauncherView::List ); 313 v->setViewMode( LauncherView::List );
291 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 314 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
292 if ( bgType == "Image" ) { // No tr 315 if ( bgType == "Image" ) { // No tr
293 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 316 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
294 v->setBackgroundType( LauncherView::Image, pm ); 317 v->setBackgroundType( LauncherView::Image, pm );
295 } else if ( bgType == "SolidColor" ) { 318 } else if ( bgType == "SolidColor" ) {
296 QString c = cfg.readEntry( "BackgroundColor" ); 319 QString c = cfg.readEntry( "BackgroundColor" );
297 v->setBackgroundType( LauncherView::SolidColor, c ); 320 v->setBackgroundType( LauncherView::SolidColor, c );
298 } 321 }
299 QString textCol = cfg.readEntry( "TextColor" ); 322 QString textCol = cfg.readEntry( "TextColor" );
300 if ( textCol.isEmpty() ) 323 if ( textCol.isEmpty() )
301 v->setTextColor( QColor() ); 324 v->setTextColor( QColor() );
302 else 325 else
303 v->setTextColor( QColor(textCol) ); 326 v->setTextColor( QColor(textCol) );
304 QStringList font = cfg.readListEntry( "Font", ',' ); 327 QStringList font = cfg.readListEntry( "Font", ',' );
305 if ( font.count() == 4 ) 328 if ( font.count() == 4 )
306 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 329 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
307 330
308 // Tabs 331 // Tabs
309 QString tabCol = cfg.readEntry( "TabColor" ); 332 QString tabCol = cfg.readEntry( "TabColor" );
310 if ( tabCol.isEmpty() ) 333 if ( tabCol.isEmpty() )
311 tab->bgColor = QColor(); 334 tab->bgColor = QColor();
312 else 335 else
313 tab->bgColor = QColor(tabCol); 336 tab->bgColor = QColor(tabCol);
314 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 337 QString tabTextCol = cfg.readEntry( "TabTextColor" );
315 if ( tabTextCol.isEmpty() ) 338 if ( tabTextCol.isEmpty() )
316 tab->fgColor = QColor(); 339 tab->fgColor = QColor();
317 else 340 else
318 tab->fgColor = QColor(tabTextCol); 341 tab->fgColor = QColor(tabTextCol);
319} 342}
320 343
321void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) 344//void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> & /*fs*/)
322{ 345//{
323 docview->populate( docFolder, QString::null ); 346 // docFolder->detachChildren();
324 docFolder->detachChildren(); 347//}
325 docview->setFileSystems(fs);
326 docview->updateTools();
327}
328 348
329void CategoryTabWidget::tabProperties() 349void CategoryTabWidget::tabProperties()
330{ 350{
331 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); 351 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() );
332 QPopupMenu *m = new QPopupMenu( this ); 352 QPopupMenu *m = new QPopupMenu( this );
333 m->insertItem( tr("Icon View"), LauncherView::Icon ); 353 m->insertItem( tr("Icon View"), LauncherView::Icon );
334 m->insertItem( tr("List View"), LauncherView::List ); 354 m->insertItem( tr("List View"), LauncherView::List );
335 m->setItemChecked( (int)view->viewMode(), TRUE ); 355 m->setItemChecked( (int)view->viewMode(), TRUE );
336 int rv = m->exec( QCursor::pos() ); 356 int rv = m->exec( QCursor::pos() );
337 if ( rv >= 0 && rv != view->viewMode() ) { 357 if ( rv >= 0 && rv != view->viewMode() ) {
338 view->setViewMode( (LauncherView::ViewMode)rv ); 358 view->setViewMode( (LauncherView::ViewMode)rv );
339 } 359 }
340 360
341 delete m; 361 delete m;
342} 362}
343 363
344QString CategoryTabWidget::getAllDocLinkInfo() const 364QString CategoryTabWidget::getAllDocLinkInfo() const
345{ 365{
346 return docview->getAllDocLinkInfo(); 366 return "";
347} 367}
348 368
349LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 369LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
350{ 370{
351 LauncherView* view = new LauncherView( stack ); 371 LauncherView* view = new LauncherView( stack );
352 connect( view, SIGNAL(clicked(const AppLnk*)), 372 connect( view, SIGNAL(clicked(const AppLnk*)),
353 this, SIGNAL(clicked(const AppLnk*))); 373 this, SIGNAL(clicked(const AppLnk*)));
354 connect( view, SIGNAL(rightPressed(AppLnk*)), 374 connect( view, SIGNAL(rightPressed(AppLnk*)),
355 this, SIGNAL(rightPressed(AppLnk*))); 375 this, SIGNAL(rightPressed(AppLnk*)));
356 ids.append(id); 376 ids.append(id);
357 categoryBar->addTab( new CategoryTab( pm, label ) ); 377 categoryBar->addTab( new CategoryTab( pm, label ) );
358 stack->addWidget( view, tabs++ ); 378 stack->addWidget( view, tabs++ );
359 return view; 379 return view;
360} 380}
361 381
362void CategoryTabWidget::updateLink(const QString& linkfile) 382void CategoryTabWidget::updateLink(const QString& linkfile)
363{ 383{
364 int i=0; 384 // LauncherView* view;
365 LauncherView* view; 385 qApp->processEvents();
366 qApp->processEvents(); 386// while ((view = (LauncherView*)stack->widget(i++))) {
367 while ((view = (LauncherView*)stack->widget(i++))) { 387// if ( view->removeLink(linkfile) )
368 if ( view->removeLink(linkfile) ) 388// break;
369 break; 389// }
370 } 390 // addItem(linkfile);
371 addItem(linkfile); 391 fileSel->reparse();
372 docview->updateTools();
373} 392}
374 393
375void CategoryTabWidget::paletteChange( const QPalette &p ) 394void CategoryTabWidget::paletteChange( const QPalette &p )
376{ 395{
377 QVBox::paletteChange( p ); 396 QVBox::paletteChange( p );
378 QPalette pal = palette(); 397 QPalette pal = palette();
379 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 398 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
380 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 399 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
381 categoryBar->setPalette( pal ); 400 categoryBar->setPalette( pal );
382 categoryBar->update(); 401 categoryBar->update();
383} 402}
384 403
385void CategoryTabWidget::setBusy(bool on) 404void CategoryTabWidget::setBusy(bool on)
386{ 405{
387 if ( on ) 406 if ( on )
388 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); 407 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE);
389 else 408 else
390 for (int i=0; i<tabs; i++) 409 for (int i=0; i<tabs-1; i++)
391 ((LauncherView*)stack->widget(i))->setBusy(FALSE); 410 ((LauncherView*)stack->widget(i))->setBusy(FALSE);
392} 411}
393 412
394LauncherView *CategoryTabWidget::view( const QString &id ) 413LauncherView *CategoryTabWidget::view( const QString &id )
395{ 414{
396 int idx = ids.findIndex( id ); 415 int idx = ids.findIndex( id );
397 return (LauncherView *)stack->widget(idx); 416 return (LauncherView *)stack->widget(idx);
398} 417}
399 418
400void CategoryTabWidget::setBusyIndicatorType ( const QString &type ) 419void CategoryTabWidget::setBusyIndicatorType ( const QString &type )
401{ 420{
402 for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it ) 421 for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it )
403 view ( *it )-> setBusyIndicatorType ( type ); 422 view ( *it )-> setBusyIndicatorType ( type );
404} 423}
405 424
406//=========================================================================== 425//===========================================================================
407 426
408CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) 427CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name )
409 : QTabBar( parent, name ) 428 : QTabBar( parent, name )
410{ 429{
411 setFocusPolicy( NoFocus ); 430 setFocusPolicy( NoFocus );
@@ -414,98 +433,98 @@ CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name )
414 433
415CategoryTabBar::~CategoryTabBar() 434CategoryTabBar::~CategoryTabBar()
416{ 435{
417} 436}
418 437
419void CategoryTabBar::layoutTabs() 438void CategoryTabBar::layoutTabs()
420{ 439{
421 if ( !count() ) 440 if ( !count() )
422 return; 441 return;
423 442
424// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; 443// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 };
425 int available = width()-1; 444 int available = width()-1;
426 QFontMetrics fm = fontMetrics(); 445 QFontMetrics fm = fontMetrics();
427 int hiddenTabWidth = -7; 446 int hiddenTabWidth = -7;
428 int middleTab = currentTab(); 447 int middleTab = currentTab();
429 int hframe, vframe, overlap; 448 int hframe, vframe, overlap;
430 style().tabbarMetrics( this, hframe, vframe, overlap ); 449 style().tabbarMetrics( this, hframe, vframe, overlap );
431 int x = 0; 450 int x = 0;
432 QRect r; 451 QRect r;
433 QTab *t; 452 QTab *t;
434 int required = 0; 453 int required = 0;
435 int eventabwidth = (width()-1)/count(); 454 int eventabwidth = (width()-1)/count();
436 enum Mode { HideBackText, Pack, Even } mode=Even; 455 enum Mode { HideBackText, Pack, Even } mode=Even;
437 for ( int i = 0; i < count(); i++ ) { 456 for ( int i = 0; i < count(); i++ ) {
438 t = tab(i); 457 t = tab(i);
439 int iw = fm.width( t->text() ) + hframe - overlap; 458 int iw = fm.width( t->text() ) + hframe - overlap;
440 if ( i != middleTab ) { 459 if ( i != middleTab ) {
441 available -= hiddenTabWidth + hframe - overlap; 460 available -= hiddenTabWidth + hframe - overlap;
442 if ( t->iconSet() != 0 ) 461 if ( t->iconSet() != 0 )
443 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 462 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
444 } 463 }
445 if ( t->iconSet() != 0 ) 464 if ( t->iconSet() != 0 )
446 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 465 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
447 required += iw; 466 required += iw;
448 // As space gets tight, packed looks better than even. "10" must be at least 0. 467 // As space gets tight, packed looks better than even. "10" must be at least 0.
449 if ( iw >= eventabwidth-10 ) 468 if ( iw >= eventabwidth-10 )
450 mode = Pack; 469 mode = Pack;
451 } 470 }
452 if ( mode == Pack && required > width()-1 ) 471 if ( mode == Pack && required > width()-1 )
453 mode = HideBackText; 472 mode = HideBackText;
454 for ( int i = 0; i < count(); i++ ) { 473 for ( int i = 0; i < count(); i++ ) {
455 t = tab(i); 474 t = tab(i);
456 if ( mode != HideBackText ) { 475 if ( mode != HideBackText ) {
457 int w = fm.width( t->text() ); 476 int w = fm.width( t->text() );
458 int ih = 0; 477 int ih = 0;
459 if ( t->iconSet() != 0 ) { 478 if ( t->iconSet() != 0 ) {
460 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 479 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
461 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 480 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
462 } 481 }
463 int h = QMAX( fm.height(), ih ); 482 int h = QMAX( fm.height(), ih );
464 h = QMAX( h, QApplication::globalStrut().height() ); 483 h = QMAX( h, QApplication::globalStrut().height() );
465 484
466 h += vframe; 485 h += vframe;
467 w += hframe; 486 w += hframe;
468 487
469 QRect tr(x, 0, 488 QRect tr(x, 0,
470 mode == Even ? eventabwidth : w * (width()-1)/required, h); 489 mode == Even ? eventabwidth : w * (width()-1)/required, h);
471 t->setRect(tr); 490 t->setRect(tr);
472 x += tr.width() - overlap; 491 x += tr.width() - overlap;
473 r = r.unite(tr); 492 r = r.unite(tr);
474 } else if ( i != middleTab ) { 493 } else if ( i != middleTab ) {
475 int w = hiddenTabWidth; 494 int w = hiddenTabWidth;
476 int ih = 0; 495 int ih = 0;
477 if ( t->iconSet() != 0 ) { 496 if ( t->iconSet() != 0 ) {
478 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 497 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
479 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 498 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
480 } 499 }
481 int h = QMAX( fm.height(), ih ); 500 int h = QMAX( fm.height(), ih );
482 h = QMAX( h, QApplication::globalStrut().height() ); 501 h = QMAX( h, QApplication::globalStrut().height() );
483 502
484 h += vframe; 503 h += vframe;
485 w += hframe; 504 w += hframe;
486 505
487 t->setRect( QRect(x, 0, w, h) ); 506 t->setRect( QRect(x, 0, w, h) );
488 x += t->rect().width() - overlap; 507 x += t->rect().width() - overlap;
489 r = r.unite( t->rect() ); 508 r = r.unite( t->rect() );
490 } else { 509 } else {
491 int ih = 0; 510 int ih = 0;
492 if ( t->iconSet() != 0 ) { 511 if ( t->iconSet() != 0 ) {
493 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 512 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
494 } 513 }
495 int h = QMAX( fm.height(), ih ); 514 int h = QMAX( fm.height(), ih );
496 h = QMAX( h, QApplication::globalStrut().height() ); 515 h = QMAX( h, QApplication::globalStrut().height() );
497 516
498 h += vframe; 517 h += vframe;
499 518
500 t->setRect( QRect(x, 0, available, h) ); 519 t->setRect( QRect(x, 0, available, h) );
501 x += t->rect().width() - overlap; 520 x += t->rect().width() - overlap;
502 r = r.unite( t->rect() ); 521 r = r.unite( t->rect() );
503 } 522 }
504 } 523 }
505 524
506 QRect rr = tab(count()-1)->rect(); 525 QRect rr = tab(count()-1)->rect();
507 rr.setRight(width()-1); 526 rr.setRight(width()-1);
508 tab(count()-1)->setRect( rr ); 527 tab(count()-1)->setRect( rr );
509 528
510 for ( t = tabList()->first(); t; t = tabList()->next() ) { 529 for ( t = tabList()->first(); t; t = tabList()->next() ) {
511 QRect tr = t->rect(); 530 QRect tr = t->rect();
@@ -519,107 +538,107 @@ void CategoryTabBar::layoutTabs()
519 538
520void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const 539void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
521{ 540{
522 CategoryTabBar *that = (CategoryTabBar *) this; 541 CategoryTabBar *that = (CategoryTabBar *) this;
523 CategoryTab *ct = (CategoryTab *)t; 542 CategoryTab *ct = (CategoryTab *)t;
524 QPalette pal = palette(); 543 QPalette pal = palette();
525 bool setPal = FALSE; 544 bool setPal = FALSE;
526 if ( ct->bgColor.isValid() ) { 545 if ( ct->bgColor.isValid() ) {
527 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); 546 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor );
528 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); 547 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor );
529 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); 548 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor );
530 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); 549 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor );
531 that->setUpdatesEnabled( FALSE ); 550 that->setUpdatesEnabled( FALSE );
532 that->setPalette( pal ); 551 that->setPalette( pal );
533 setPal = TRUE; 552 setPal = TRUE;
534 } 553 }
535#if QT_VERSION >= 300 554#if QT_VERSION >= 300
536 QStyle::SFlags flags = QStyle::Style_Default; 555 QStyle::SFlags flags = QStyle::Style_Default;
537 if ( selected ) 556 if ( selected )
538 flags |= QStyle::Style_Selected; 557 flags |= QStyle::Style_Selected;
539 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 558 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
540 colorGroup(), flags, QStyleOption(t) ); 559 colorGroup(), flags, QStyleOption(t) );
541#else 560#else
542 style().drawTab( p, this, t, selected ); 561 style().drawTab( p, this, t, selected );
543#endif 562#endif
544 563
545 QRect r( t->rect() ); 564 QRect r( t->rect() );
546 QFont f( font() ); 565 QFont f( font() );
547 if ( selected ) 566 if ( selected )
548 f.setBold( TRUE ); 567 f.setBold( TRUE );
549 p->setFont( f ); 568 p->setFont( f );
550 569
551 if ( ct->fgColor.isValid() ) { 570 if ( ct->fgColor.isValid() ) {
552 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); 571 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor );
553 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); 572 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor );
554 that->setUpdatesEnabled( FALSE ); 573 that->setUpdatesEnabled( FALSE );
555 that->setPalette( pal ); 574 that->setPalette( pal );
556 setPal = TRUE; 575 setPal = TRUE;
557 } 576 }
558 int iw = 0; 577 int iw = 0;
559 int ih = 0; 578 int ih = 0;
560 if ( t->iconSet() != 0 ) { 579 if ( t->iconSet() != 0 ) {
561 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 580 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
562 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 581 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
563 } 582 }
564 int w = iw + p->fontMetrics().width( t->text() ) + 4; 583 int w = iw + p->fontMetrics().width( t->text() ) + 4;
565 int h = QMAX(p->fontMetrics().height() + 4, ih ); 584 int h = QMAX(p->fontMetrics().height() + 4, ih );
566 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 585 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
567 r.top() + (r.height()-h)/2, w, h ), t, 586 r.top() + (r.height()-h)/2, w, h ), t,
568#if QT_VERSION >= 300 587#if QT_VERSION >= 300
569 t->identifier() == keyboardFocusTab() 588 t->identifier() == keyboardFocusTab()
570#else 589#else
571 t->identitifer() == keyboardFocusTab() 590 t->identitifer() == keyboardFocusTab()
572#endif 591#endif
573 ); 592 );
574 if ( setPal ) { 593 if ( setPal ) {
575 that->unsetPalette(); 594 that->unsetPalette();
576 that->setUpdatesEnabled( TRUE ); 595 that->setUpdatesEnabled( TRUE );
577 } 596 }
578} 597}
579 598
580 599
581void CategoryTabBar::paintLabel( QPainter* p, const QRect&, 600void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
582 QTab* t, bool has_focus ) const 601 QTab* t, bool has_focus ) const
583{ 602{
584 QRect r = t->rect(); 603 QRect r = t->rect();
585 // if ( t->id != currentTab() ) 604 // if ( t->id != currentTab() )
586 //r.moveBy( 1, 1 ); 605 //r.moveBy( 1, 1 );
587 // 606 //
588 if ( t->iconSet() ) { 607 if ( t->iconSet() ) {
589 // the tab has an iconset, draw it in the right mode 608 // the tab has an iconset, draw it in the right mode
590 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 609 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
591 if ( mode == QIconSet::Normal && has_focus ) 610 if ( mode == QIconSet::Normal && has_focus )
592 mode = QIconSet::Active; 611 mode = QIconSet::Active;
593 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 612 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
594 int pixw = pixmap.width(); 613 int pixw = pixmap.width();
595 int pixh = pixmap.height(); 614 int pixh = pixmap.height();
596 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); 615 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
597 r.setLeft( r.left() + pixw + 5 ); 616 r.setLeft( r.left() + pixw + 5 );
598 } 617 }
599 618
600 QRect tr = r; 619 QRect tr = r;
601 620
602 if ( r.width() < 20 ) 621 if ( r.width() < 20 )
603 return; 622 return;
604 623
605 if ( t->isEnabled() && isEnabled() ) { 624 if ( t->isEnabled() && isEnabled() ) {
606#if defined(_WS_WIN32_) 625#if defined(_WS_WIN32_)
607 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 626 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
608 p->setPen( colorGroup().buttonText() ); 627 p->setPen( colorGroup().buttonText() );
609 else 628 else
610 p->setPen( colorGroup().foreground() ); 629 p->setPen( colorGroup().foreground() );
611#else 630#else
612 p->setPen( colorGroup().foreground() ); 631 p->setPen( colorGroup().foreground() );
613#endif 632#endif
614 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 633 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
615 } else { 634 } else {
616 p->setPen( palette().disabled().foreground() ); 635 p->setPen( palette().disabled().foreground() );
617 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 636 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
618 } 637 }
619} 638}
620 639
621//--------------------------------------------------------------------------- 640//---------------------------------------------------------------------------
622 641
623Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 642Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
624 : QMainWindow( parent, name, fl ) 643 : QMainWindow( parent, name, fl )
625{ 644{
@@ -637,21 +656,22 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
637 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know 656 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
638 //uidgen.store( stamp ); 657 //uidgen.store( stamp );
639 m_timeStamp = QString::number( stamp ); 658 m_timeStamp = QString::number( stamp );
640 659
641 tabs = new CategoryTabWidget( this ); 660 tabs = new CategoryTabWidget( this );
642 setCentralWidget( tabs ); 661 setCentralWidget( tabs );
643 662
644 connect( tabs, SIGNAL(selected(const QString&)), 663 connect( tabs, SIGNAL(selected(const QString&)),
645 this, SLOT(viewSelected(const QString&)) ); 664 this, SLOT(viewSelected(const QString&)) );
646 connect( tabs, SIGNAL(clicked(const AppLnk*)), 665 connect( tabs, SIGNAL(clicked(const AppLnk*)),
647 this, SLOT(select(const AppLnk*))); 666 this, SLOT(select(const AppLnk*)));
648 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 667 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
649 this, SLOT(properties(AppLnk*))); 668 this, SLOT(properties(AppLnk*)));
669
650 670
651#if !defined(QT_NO_COP) 671#if !defined(QT_NO_COP)
652 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 672 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
653 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 673 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
654 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 674 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
655 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 675 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
656 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 676 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
657 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); 677 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) );
@@ -675,29 +695,29 @@ Launcher::~Launcher()
675} 695}
676 696
677static bool isVisibleWindow(int wid) 697static bool isVisibleWindow(int wid)
678{ 698{
679#ifdef QWS 699#ifdef QWS
680 const QList<QWSWindow> &list = qwsServer->clientWindows(); 700 const QList<QWSWindow> &list = qwsServer->clientWindows();
681 QWSWindow* w; 701 QWSWindow* w;
682 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 702 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
683 if ( w->winId() == wid ) 703 if ( w->winId() == wid )
684 return !w->isFullyObscured(); 704 return !w->isFullyObscured();
685 } 705 }
686#endif 706#endif
687 return FALSE; 707 return FALSE;
688} 708}
689 709
690void Launcher::showMaximized() 710void Launcher::showMaximized()
691{ 711{
692 if ( isVisibleWindow( winId() ) ) 712 if ( isVisibleWindow( winId() ) )
693 doMaximize(); 713 doMaximize();
694 else 714 else
695 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 715 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
696} 716}
697 717
698void Launcher::doMaximize() 718void Launcher::doMaximize()
699{ 719{
700 QMainWindow::showMaximized(); 720 QMainWindow::showMaximized();
701 tabs->setMaximumWidth( qApp->desktop()->width() ); 721 tabs->setMaximumWidth( qApp->desktop()->width() );
702} 722}
703 723
@@ -705,167 +725,167 @@ void Launcher::updateMimeTypes()
705{ 725{
706 MimeType::clear(); 726 MimeType::clear();
707 updateMimeTypes(rootFolder); 727 updateMimeTypes(rootFolder);
708} 728}
709 729
710void Launcher::updateMimeTypes(AppLnkSet* folder) 730void Launcher::updateMimeTypes(AppLnkSet* folder)
711{ 731{
712 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 732 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
713 AppLnk *app = it.current(); 733 AppLnk *app = it.current();
714 if ( app->type() == "Folder" ) // No tr 734 if ( app->type() == "Folder" ) // No tr
715 updateMimeTypes((AppLnkSet *)app); 735 updateMimeTypes((AppLnkSet *)app);
716 else { 736 else {
717 MimeType::registerApp(*app); 737 MimeType::registerApp(*app);
718 } 738 }
719 } 739 }
720} 740}
721 741
722/** This is a HACK.... 742/** This is a HACK....
723 * Reason: scanning huge mediums, microdirvers for examples 743 * Reason: scanning huge mediums, microdirvers for examples
724 * consomes time. To avoid that we invented the MediumMountCheck 744 * consomes time. To avoid that we invented the MediumMountCheck
725 * 745 *
726 * a) the user globally disabled medium checking. We can ignore 746 * a) the user globally disabled medium checking. We can ignore
727 * all removable medium 747 * all removable medium
728 * b) the user enabled medium checking globally and we need to use this mimefilter 748 * b) the user enabled medium checking globally and we need to use this mimefilter
729 * c) the user enabled medium checking on a per medium bases 749 * c) the user enabled medium checking on a per medium bases
730 * c1) we already checked and its not ask again turns 750 * c1) we already checked and its not ask again turns
731 * c2) we need to ask and then apply the mimefilter 751 * c2) we need to ask and then apply the mimefilter
732 */ 752 */
733void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 753void Launcher::loadDocs() // ok here comes a hack belonging to Global::
734{ 754{
735 755 OWait *owait = new OWait();
736 OWait *owait = new OWait(); 756 Global::statusMessage( tr( "Finding documents" ) );
737 Global::statusMessage( tr( "Finding documents" ) ); 757
738 758 owait->show();
739 owait->show(); 759 qApp->processEvents();
740 qApp->processEvents(); 760 if(docsFolder) delete docsFolder;
741 761 docsFolder = new DocLnkSet;
742 delete docsFolder; 762 DocLnkSet *tmp = 0;
743 docsFolder = new DocLnkSet; 763 QString home = QString(getenv("HOME")) + "/Documents";
744 764 tmp = new DocLnkSet( home , QString::null);
745 DocLnkSet *tmp = 0; 765 docsFolder->appendFrom( *tmp );
746 QString home = QString(getenv("HOME")) + "/Documents"; 766 delete tmp;
747 tmp = new DocLnkSet( home , QString::null); 767
748 docsFolder->appendFrom( *tmp ); 768 // RAM documents
749 delete tmp; 769 StorageInfo storage;
750 770 const QList<FileSystem> &fileSystems = storage.fileSystems();
751 // RAM documents 771 QListIterator<FileSystem> it ( fileSystems );
752 StorageInfo storage; 772
753 const QList<FileSystem> &fileSystems = storage.fileSystems(); 773 for ( ; it.current(); ++it ) {
754 QListIterator<FileSystem> it ( fileSystems ); 774 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
755 775 tmp = new DocLnkSet( (*it)->path(), QString::null );
756 for ( ; it.current(); ++it ) { 776 docsFolder->appendFrom( *tmp );
757 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { 777 delete tmp;
758 tmp = new DocLnkSet( (*it)->path(), QString::null ); 778 }
759 docsFolder->appendFrom( *tmp ); 779 }
760 delete tmp; 780
761 } 781 Config mediumCfg( "medium");
762 } 782 mediumCfg.setGroup("main");
763 783 // a) -zecke we don't want to check
764 Config mediumCfg( "medium"); 784 if(!mediumCfg.readBoolEntry("use", true ) ) {
765 mediumCfg.setGroup("main"); 785 owait->hide();
766 // a) -zecke we don't want to check 786 delete owait;
767 if(!mediumCfg.readBoolEntry("use", true ) )
768 return; 787 return;
788 }
789 // find out wich filesystems are new in this round
790 // We will do this by having a timestamp inside each mountpoint
791 // if the current timestamp doesn't match this is a new file system and
792 // come up with our MediumMountGui :) let the hacking begin
793 int stamp = uidgen.generate();
769 794
770 // find out wich filesystems are new in this round 795 QString newStamp = QString::number( stamp ); // generates newtime Stamp
771 // We will do this by having a timestamp inside each mountpoint
772 // if the current timestamp doesn't match this is a new file system and
773 // come up with our MediumMountGui :) let the hacking begin
774 int stamp = uidgen.generate();
775 796
776 QString newStamp = QString::number( stamp ); // generates newtime Stamp 797 // b)
777 798 if( mediumCfg.readBoolEntry("global", true ) ){
778 // b)
779 if( mediumCfg.readBoolEntry("global", true ) ){
780 QString mime = configToMime(&mediumCfg).join(";"); 799 QString mime = configToMime(&mediumCfg).join(";");
781 for( it.toFirst(); it.current(); ++it ){ 800 for( it.toFirst(); it.current(); ++it ){
782 if( (*it)->isRemovable() ){ 801 if( (*it)->isRemovable() ){
783 tmp = new DocLnkSet( (*it)->path(), mime ); 802 tmp = new DocLnkSet( (*it)->path(), mime );
784 docsFolder->appendFrom( *tmp ); 803 docsFolder->appendFrom( *tmp );
785 delete tmp; 804 delete tmp;
786 } 805 }
787 } // done 806 } // done
807 owait->hide();
808 delete owait;
788 return; // save the else 809 return; // save the else
789 } 810 }
790 // c) zecke 811 // c) zecke
791 for ( it.toFirst(); it.current(); ++it ) { 812 for ( it.toFirst(); it.current(); ++it ) {
792 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 813 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
793 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); 814 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File);
794 cfg.setGroup("main"); 815 cfg.setGroup("main");
795 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 816 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
796 /** This medium is uptodate 817 /** This medium is uptodate
797 */ 818 */
798 if( stamp == m_timeStamp ){ // ok we know this card 819 if( stamp == m_timeStamp ){ // ok we know this card
799 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 820 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
800 // we need to scan the list now. Hopefully the cache will be there 821 // we need to scan the list now. Hopefully the cache will be there
801 // read the mimetypes from the config and search for documents 822 // read the mimetypes from the config and search for documents
802 QStringList mimetypes = configToMime( &cfg); 823 QStringList mimetypes = configToMime( &cfg);
803 //qApp->processEvents(); 824 //qApp->processEvents();
825 Global::statusMessage( tr( "Searching documents" ) );
826 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
827 docsFolder->appendFrom( *tmp );
828 delete tmp;
829
830 } else { // come up with the gui cause this a new card
831 MediumMountGui medium(&cfg, (*it)->path() );
832 if( medium.check() ){ // we did not ask before or ask again is off
833 /** c2) */
834 if( medium.exec() ){ // he clicked yes so search it
835 // speicher
836 //cfg.read(); // cause of a race we need to reread - fixed
837 cfg.setGroup("main");
838 cfg.writeEntry("timestamp", newStamp );
839 cfg.write();
840
841 //qApp->processEvents();
842 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
843 docsFolder->appendFrom( *tmp );
844 delete tmp;
845 }// no else
846 /** c1) */
847 } else { // we checked
848 // do something different see what we need to do
849 // let's see if we should check the device
850 cfg.setGroup("main" );
851 bool check = cfg.readBoolEntry("autocheck", true );
852 if( check ){ // find the documents
853
854 //qApp->processEvents();
804 Global::statusMessage( tr( "Searching documents" ) ); 855 Global::statusMessage( tr( "Searching documents" ) );
805 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 856 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
806 docsFolder->appendFrom( *tmp ); 857 docsFolder->appendFrom( *tmp );
807 delete tmp; 858 delete tmp;
808 859 }
809 }else{ // come up with the gui cause this a new card 860 }
810 MediumMountGui medium(&cfg, (*it)->path() ); 861 }
811 if( medium.check() ){ // we did not ask before or ask again is off 862 }
812 /** c2) */ 863 }
813 if( medium.exec() ){ // he clicked yes so search it 864 m_timeStamp = newStamp;
814 // speicher 865 owait->hide();
815 //cfg.read(); // cause of a race we need to reread - fixed 866 delete owait;
816 cfg.setGroup("main");
817 cfg.writeEntry("timestamp", newStamp );
818 cfg.write();
819
820 //qApp->processEvents();
821 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
822 docsFolder->appendFrom( *tmp );
823 delete tmp;
824 }// no else
825 /** c1) */
826 }else{ // we checked
827 // do something different see what we need to do
828 // let's see if we should check the device
829 cfg.setGroup("main" );
830 bool check = cfg.readBoolEntry("autocheck", true );
831 if( check ){ // find the documents
832
833 //qApp->processEvents();
834 Global::statusMessage( tr( "Searching documents" ) );
835 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
836 docsFolder->appendFrom( *tmp );
837 delete tmp;
838 }
839 }
840 }
841 }
842 }
843 m_timeStamp = newStamp;
844 owait->hide();
845 delete owait;
846} 867}
847 868
848void Launcher::updateTabs() 869void Launcher::updateTabs()
849{ 870{
850 MimeType::updateApplications(); // ### reads all applnks twice 871 MimeType::updateApplications(); // ### reads all applnks twice
851
852 delete rootFolder; 872 delete rootFolder;
853 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 873 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
854 874
855 loadDocs(); 875 loadDocs();
856 876
857 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 877 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
858} 878}
859 879
860void Launcher::updateDocs() 880void Launcher::updateDocs()
861{ 881{
862 loadDocs(); 882 loadDocs();
863 tabs->updateDocs(docsFolder,storage->fileSystems()); 883 // tabs->updateDocs(docsFolder,storage->fileSystems());
864} 884}
865 885
866void Launcher::viewSelected(const QString& s) 886void Launcher::viewSelected(const QString& s)
867{ 887{
868 setCaption( s + tr(" - Launcher") ); 888 setCaption( s + tr(" - Launcher") );
869} 889}
870 890
871void Launcher::nextView() 891void Launcher::nextView()
@@ -877,133 +897,133 @@ void Launcher::showTab(const QString& id)
877{ 897{
878 tabs->showTab(id); 898 tabs->showTab(id);
879 raise(); 899 raise();
880} 900}
881 901
882void Launcher::select( const AppLnk *appLnk ) 902void Launcher::select( const AppLnk *appLnk )
883{ 903{
884 if ( appLnk->type() == "Folder" ) { // No tr 904 if ( appLnk->type() == "Folder" ) { // No tr
885 // Not supported: flat is simpler for the user 905 // Not supported: flat is simpler for the user
886 } else { 906 } else {
887 if ( appLnk->exec().isNull() ) { 907 if ( appLnk->exec().isNull() ) {
888 QMessageBox::information(this,tr("No application"), 908 QMessageBox::information(this,tr("No application"),
889 tr("<p>No application is defined for this document." 909 tr("<p>No application is defined for this document."
890 "<p>Type is %1.").arg(appLnk->type())); 910 "<p>Type is %1.").arg(appLnk->type()));
891 return; 911 return;
892 } 912 }
893 tabs->setBusy(TRUE); 913 tabs->setBusy(TRUE);
894 emit executing( appLnk ); 914 emit executing( appLnk );
895 appLnk->execute(); 915 appLnk->execute();
896 } 916 }
897} 917}
898 918
899void Launcher::externalSelected(const AppLnk *appLnk) 919void Launcher::externalSelected(const AppLnk *appLnk)
900{ 920{
901 tabs->setBusy(TRUE); 921 tabs->setBusy(TRUE);
902 emit executing( appLnk ); 922 emit executing( appLnk );
903} 923}
904 924
905void Launcher::properties( AppLnk *appLnk ) 925void Launcher::properties( AppLnk *appLnk )
906{ 926{
907 if ( appLnk->type() == "Folder" ) { // No tr 927 if ( appLnk->type() == "Folder" ) { // No tr
908 // Not supported: flat is simpler for the user 928 // Not supported: flat is simpler for the user
909 } else { 929 } else {
910 in_lnk_props = TRUE; 930 in_lnk_props = TRUE;
911 got_lnk_change = FALSE; 931 got_lnk_change = FALSE;
912 LnkProperties prop(appLnk); 932 LnkProperties prop(appLnk);
913 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 933 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
914 prop.showMaximized(); 934 prop.showMaximized();
915 prop.exec(); 935 prop.exec();
916 in_lnk_props = FALSE; 936 in_lnk_props = FALSE;
917 if ( got_lnk_change ) { 937 if ( got_lnk_change ) {
918 updateLink(lnk_change); 938 updateLink(lnk_change);
919 } 939 }
920 } 940 }
921} 941}
922 942
923void Launcher::updateLink(const QString& link) 943void Launcher::updateLink(const QString& link)
924{ 944{
925 bool notify_sm = false; 945 bool notify_sm = false;
926 946
927 if (link.isNull()) { 947 if (link.isNull()) {
928 updateTabs(); 948 updateTabs();
929 notify_sm = true; 949 notify_sm = true;
930 } 950 }
931 else if (link.isEmpty()) { 951 else if (link.isEmpty()) {
932 updateDocs(); 952 updateDocs();
933 } 953 }
934 else { 954 else {
935 tabs->updateLink(link); 955 tabs->updateLink(link);
936 notify_sm = true; 956 notify_sm = true;
937 } 957 }
938 958
939 if ( notify_sm ) 959 if ( notify_sm )
940 QCopEnvelope e ( "QPE/TaskBar", "reloadApps()" ); 960 QCopEnvelope e ( "QPE/TaskBar", "reloadApps()" );
941} 961}
942 962
943void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 963void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
944{ 964{
945 QDataStream stream( data, IO_ReadOnly ); 965 QDataStream stream( data, IO_ReadOnly );
946 if ( msg == "linkChanged(QString)" ) { 966 if ( msg == "linkChanged(QString)" ) {
947 QString link; 967 QString link;
948 stream >> link; 968 stream >> link;
949 if ( in_lnk_props ) { 969 if ( in_lnk_props ) {
950 got_lnk_change = TRUE; 970 got_lnk_change = TRUE;
951 lnk_change = link; 971 lnk_change = link;
952 } else { 972 } else {
953 updateLink(link); 973 updateLink(link);
954 } 974 }
955 } else if ( msg == "busy()" ) { 975 } else if ( msg == "busy()" ) {
956 emit busy(); 976 emit busy();
957 } else if ( msg == "notBusy(QString)" ) { 977 } else if ( msg == "notBusy(QString)" ) {
958 QString app; 978 QString app;
959 stream >> app; 979 stream >> app;
960 tabs->setBusy(FALSE); 980 tabs->setBusy(FALSE);
961 emit notBusy(app); 981 emit notBusy(app);
962 } else if ( msg == "mkdir(QString)" ) { 982 } else if ( msg == "mkdir(QString)" ) {
963 QString dir; 983 QString dir;
964 stream >> dir; 984 stream >> dir;
965 if ( !dir.isEmpty() ) 985 if ( !dir.isEmpty() )
966 mkdir( dir ); 986 mkdir( dir );
967 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 987 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
968 QString baseFile, sigFile; 988 QString baseFile, sigFile;
969 stream >> baseFile >> sigFile; 989 stream >> baseFile >> sigFile;
970 QRsync::generateSignature( baseFile, sigFile ); 990 QRsync::generateSignature( baseFile, sigFile );
971 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 991 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
972 QString baseFile, sigFile, deltaFile; 992 QString baseFile, sigFile, deltaFile;
973 stream >> baseFile >> sigFile >> deltaFile; 993 stream >> baseFile >> sigFile >> deltaFile;
974 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 994 QRsync::generateDiff( baseFile, sigFile, deltaFile );
975 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 995 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
976 QString baseFile, deltaFile; 996 QString baseFile, deltaFile;
977 stream >> baseFile >> deltaFile; 997 stream >> baseFile >> deltaFile;
978 if ( !QFile::exists( baseFile ) ) { 998 if ( !QFile::exists( baseFile ) ) {
979 QFile f( baseFile ); 999 QFile f( baseFile );
980 f.open( IO_WriteOnly ); 1000 f.open( IO_WriteOnly );
981 f.close(); 1001 f.close();
982 } 1002 }
983 QRsync::applyDiff( baseFile, deltaFile ); 1003 QRsync::applyDiff( baseFile, deltaFile );
984#ifndef QT_NO_COP 1004#ifndef QT_NO_COP
985 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 1005 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
986 e << baseFile; 1006 e << baseFile;
987#endif 1007#endif
988 } else if ( msg == "rdiffCleanup()" ) { 1008 } else if ( msg == "rdiffCleanup()" ) {
989 mkdir( "/tmp/rdiff" ); 1009 mkdir( "/tmp/rdiff" );
990 QDir dir; 1010 QDir dir;
991 dir.setPath( "/tmp/rdiff" ); 1011 dir.setPath( "/tmp/rdiff" );
992 QStringList entries = dir.entryList(); 1012 QStringList entries = dir.entryList();
993 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 1013 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
994 dir.remove( *it ); 1014 dir.remove( *it );
995 } else if ( msg == "sendHandshakeInfo()" ) { 1015 } else if ( msg == "sendHandshakeInfo()" ) {
996 QString home = getenv( "HOME" ); 1016 QString home = getenv( "HOME" );
997#ifndef QT_NO_COP 1017#ifndef QT_NO_COP
998 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 1018 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
999 e << home; 1019 e << home;
1000 int locked = (int) Desktop::screenLocked(); 1020 int locked = (int) Desktop::screenLocked();
1001 e << locked; 1021 e << locked;
1002#endif 1022#endif
1003 } else if ( msg == "autoStart(QString)" ) { 1023 } else if ( msg == "autoStart(QString)" ) {
1004 QString appName; 1024 QString appName;
1005 stream >> appName; 1025 stream >> appName;
1006 Config cfg( "autostart" ); 1026 Config cfg( "autostart" );
1007 cfg.setGroup( "AutoStart" ); 1027 cfg.setGroup( "AutoStart" );
1008 if ( appName.compare("clear") == 0){ 1028 if ( appName.compare("clear") == 0){
1009 cfg.writeEntry("Apps", ""); 1029 cfg.writeEntry("Apps", "");
@@ -1045,275 +1065,291 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
1045 } 1065 }
1046 /* 1066 /*
1047 * QtopiaDesktop relies on the major number 1067 * QtopiaDesktop relies on the major number
1048 * to start with 1. We're at 0.9 1068 * to start with 1. We're at 0.9
1049 * so wee need to fake at least 1.4 to be able 1069 * so wee need to fake at least 1.4 to be able
1050 * to sync with QtopiaDesktop1.6 1070 * to sync with QtopiaDesktop1.6
1051 */ 1071 */
1052 else if ( msg == "sendVersionInfo()" ) { 1072 else if ( msg == "sendVersionInfo()" ) {
1053 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); 1073 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" );
1054 QString v2 = QString::fromLatin1("1.4"); 1074 QString v2 = QString::fromLatin1("1.4");
1055 e << v2; 1075 e << v2;
1056 //qDebug("version %s\n", line.latin1()); 1076 //qDebug("version %s\n", line.latin1());
1057 } else if ( msg == "sendCardInfo()" ) { 1077 } else if ( msg == "sendCardInfo()" ) {
1058#ifndef QT_NO_COP 1078#ifndef QT_NO_COP
1059 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 1079 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
1060#endif 1080#endif
1061 const QList<FileSystem> &fs = storage->fileSystems(); 1081 const QList<FileSystem> &fs = storage->fileSystems();
1062 QListIterator<FileSystem> it ( fs ); 1082 QListIterator<FileSystem> it ( fs );
1063 QString s; 1083 QString s;
1064 QString homeDir = getenv("HOME"); 1084 QString homeDir = getenv("HOME");
1065 QString hardDiskHome, hardDiskHomePath; 1085 QString hardDiskHome, hardDiskHomePath;
1066 for ( ; it.current(); ++it ) { 1086 for ( ; it.current(); ++it ) {
1067 int k4 = (*it)->blockSize()/256; 1087 int k4 = (*it)->blockSize()/256;
1068 if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { 1088 if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") {
1069 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 1089 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
1070 + QString::number( (*it)->availBlocks() * k4/4 ) 1090 + QString::number( (*it)->availBlocks() * k4/4 )
1071 + "K " + (*it)->options() + ";"; 1091 + "K " + (*it)->options() + ";";
1072 } else if ( (*it)->disk() == "/dev/mtdblock1" || 1092 } else if ( (*it)->disk() == "/dev/mtdblock1" ||
1073 (*it)->disk() == "/dev/mtdblock/1" ) { 1093 (*it)->disk() == "/dev/mtdblock/1" ) {
1074 s += (*it)->name() + "=" + homeDir + "/Documents " 1094 s += (*it)->name() + "=" + homeDir + "/Documents "
1075 + QString::number( (*it)->availBlocks() * k4/4 ) 1095 + QString::number( (*it)->availBlocks() * k4/4 )
1076 + "K " + (*it)->options() + ";"; 1096 + "K " + (*it)->options() + ";";
1077 } else if ( (*it)->name().contains( "Hard Disk") && 1097 } else if ( (*it)->name().contains( "Hard Disk") &&
1078 homeDir.contains( (*it)->path() ) && 1098 homeDir.contains( (*it)->path() ) &&
1079 (*it)->path().length() > hardDiskHomePath.length() ) { 1099 (*it)->path().length() > hardDiskHomePath.length() ) {
1080 hardDiskHomePath = (*it)->path(); 1100 hardDiskHomePath = (*it)->path();
1081 hardDiskHome = 1101 hardDiskHome =
1082 (*it)->name() + "=" + homeDir + "/Documents " 1102 (*it)->name() + "=" + homeDir + "/Documents "
1083 + QString::number( (*it)->availBlocks() * k4/4 ) 1103 + QString::number( (*it)->availBlocks() * k4/4 )
1084 + "K " + (*it)->options() + ";"; 1104 + "K " + (*it)->options() + ";";
1085 } 1105 }
1086 } 1106 }
1087 if ( !hardDiskHome.isEmpty() ) 1107 if ( !hardDiskHome.isEmpty() )
1088 s += hardDiskHome; 1108 s += hardDiskHome;
1089 1109
1090#ifndef QT_NO_COP 1110#ifndef QT_NO_COP
1091 e << s; 1111 e << s;
1092#endif 1112#endif
1093 } else if ( msg == "sendSyncDate(QString)" ) { 1113 } else if ( msg == "sendSyncDate(QString)" ) {
1094 QString app; 1114 QString app;
1095 stream >> app; 1115 stream >> app;
1096 Config cfg( "qpe" ); 1116 Config cfg( "qpe" );
1097 cfg.setGroup("SyncDate"); 1117 cfg.setGroup("SyncDate");
1098#ifndef QT_NO_COP 1118#ifndef QT_NO_COP
1099 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 1119 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
1100 e << app << cfg.readEntry( app ); 1120 e << app << cfg.readEntry( app );
1101#endif 1121#endif
1102 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 1122 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
1103 //cfg.readEntry( app ).latin1() ); 1123 //cfg.readEntry( app ).latin1() );
1104 } else if ( msg == "setSyncDate(QString,QString)" ) { 1124 } else if ( msg == "setSyncDate(QString,QString)" ) {
1105 QString app, date; 1125 QString app, date;
1106 stream >> app >> date; 1126 stream >> app >> date;
1107 Config cfg( "qpe" ); 1127 Config cfg( "qpe" );
1108 cfg.setGroup("SyncDate"); 1128 cfg.setGroup("SyncDate");
1109 cfg.writeEntry( app, date ); 1129 cfg.writeEntry( app, date );
1110 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 1130 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
1111 } else if ( msg == "startSync(QString)" ) { 1131 } else if ( msg == "startSync(QString)" ) {
1112 QString what; 1132 QString what;
1113 stream >> what; 1133 stream >> what;
1114 delete syncDialog; syncDialog = 0; 1134 delete syncDialog; syncDialog = 0;
1115 syncDialog = new SyncDialog( this, "syncProgress", FALSE, 1135 syncDialog = new SyncDialog( this, "syncProgress", FALSE,
1116 WStyle_Tool | WStyle_Customize | 1136 WStyle_Tool | WStyle_Customize |
1117 Qt::WStyle_StaysOnTop ); 1137 Qt::WStyle_StaysOnTop );
1118 syncDialog->showMaximized(); 1138 syncDialog->showMaximized();
1119 syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); 1139 syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
1120 connect( syncDialog->buttonCancel, SIGNAL( clicked() ), 1140 connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
1121 SLOT( cancelSync() ) ); 1141 SLOT( cancelSync() ) );
1122 } else if ( msg == "stopSync()") { 1142 } else if ( msg == "stopSync()") {
1123 delete syncDialog; syncDialog = 0; 1143 delete syncDialog; syncDialog = 0;
1124 } else if ( msg == "getAllDocLinks()" ) { 1144 } else if ( msg == "getAllDocLinks()" ) {
1125 loadDocs(); 1145 loadDocs();
1126 1146
1127 // directly show updated docs in document tab 1147 // directly show updated docs in document tab
1128 updateDocs(); 1148 updateDocs();
1129 1149
1130 QString contents; 1150 QString contents;
1131 1151
1132 //Categories cats; 1152// Categories cats;
1133 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { 1153 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
1134 DocLnk *doc = it.current(); 1154 DocLnk *doc = it.current();
1135 QFileInfo fi( doc->file() ); 1155 QFileInfo fi( doc->file() );
1136 if ( !fi.exists() ) 1156 if ( !fi.exists() )
1137 continue; 1157 continue;
1138 1158
1139 bool fake = !doc->linkFileKnown(); 1159 bool fake = !doc->linkFileKnown();
1140 if ( !fake ) { 1160 if ( !fake ) {
1141 QFile f( doc->linkFile() ); 1161 QFile f( doc->linkFile() );
1142 if ( f.open( IO_ReadOnly ) ) { 1162 if ( f.open( IO_ReadOnly ) ) {
1143 QTextStream ts( &f ); 1163 QTextStream ts( &f );
1144 ts.setEncoding( QTextStream::UnicodeUTF8 ); 1164 ts.setEncoding( QTextStream::UnicodeUTF8 );
1145 contents += ts.read(); 1165 contents += ts.read();
1146 f.close(); 1166 f.close();
1147 } else 1167 } else
1148 fake = TRUE; 1168 fake = TRUE;
1149 } 1169 }
1150 if (fake) { 1170 if (fake) {
1151 contents += "[Desktop Entry]\n"; 1171 contents += "[Desktop Entry]\n";
1152 contents += "Categories = " + // No tr 1172 contents += "Categories = " + // No tr
1153 // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 1173// cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
1154 Qtopia::Record::idsToString( doc->categories() ) + "\n"; 1174 Qtopia::Record::idsToString( doc->categories() ) + "\n";
1155 contents += "Name = "+doc->name()+"\n"; // No tr 1175 contents += "Name = "+doc->name()+"\n"; // No tr
1156 contents += "Type = "+doc->type()+"\n"; // No tr 1176 contents += "Type = "+doc->type()+"\n"; // No tr
1157 } 1177 }
1158 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 1178 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
1159 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 1179 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
1160 } 1180 }
1161 1181
1162 //qDebug( "sending length %d", contents.length() ); 1182 //qDebug( "sending length %d", contents.length() );
1163#ifndef QT_NO_COP 1183#ifndef QT_NO_COP
1164 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 1184 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
1165 e << contents; 1185 e << contents;
1166#endif 1186#endif
1167 1187
1168 //qDebug( "================ \n\n%s\n\n===============", 1188 //qDebug( "================ \n\n%s\n\n===============",
1169 //contents.latin1() ); 1189 //contents.latin1() );
1170 1190
1171 delete docsFolder; 1191 delete docsFolder;
1172 docsFolder = 0; 1192 docsFolder = 0;
1173#ifdef QWS 1193#ifdef QWS
1174 } else if ( msg == "setMouseProto(QString)" ) { 1194 } else if ( msg == "setMouseProto(QString)" ) {
1175 QString mice; 1195 QString mice;
1176 stream >> mice; 1196 stream >> mice;
1177 setenv("QWS_MOUSE_PROTO",mice.latin1(),1); 1197 setenv("QWS_MOUSE_PROTO",mice.latin1(),1);
1178 qwsServer->openMouse(); 1198 qwsServer->openMouse();
1179 } else if ( msg == "setKeyboard(QString)" ) { 1199 } else if ( msg == "setKeyboard(QString)" ) {
1180 QString kb; 1200 QString kb;
1181 stream >> kb; 1201 stream >> kb;
1182 setenv("QWS_KEYBOARD",kb.latin1(),1); 1202 setenv("QWS_KEYBOARD",kb.latin1(),1);
1183 qwsServer->openKeyboard(); 1203 qwsServer->openKeyboard();
1184#endif 1204#endif
1185 } 1205 }
1186} 1206}
1187 1207
1188void Launcher::cancelSync() 1208void Launcher::cancelSync()
1189{ 1209{
1190#ifndef QT_NO_COP 1210#ifndef QT_NO_COP
1191 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 1211 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
1192#endif 1212#endif
1193} 1213}
1194 1214
1195void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) 1215void Launcher::launcherMessage( const QCString &msg, const QByteArray &data)
1196{ 1216{
1197 QDataStream stream( data, IO_ReadOnly ); 1217 QDataStream stream( data, IO_ReadOnly );
1198 if ( msg == "setTabView(QString,int)" ) { 1218 if ( msg == "setTabView(QString,int)" ) {
1199 QString id; 1219 QString id;
1200 stream >> id; 1220 stream >> id;
1201 int mode; 1221 int mode;
1202 stream >> mode; 1222 stream >> mode;
1203 if ( tabs->view(id) ) 1223 if ( tabs->view(id) )
1204 tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); 1224 tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode );
1205 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 1225 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
1206 QString id; 1226 QString id;
1207 stream >> id; 1227 stream >> id;
1208 int mode; 1228 int mode;
1209 stream >> mode; 1229 stream >> mode;
1210 QString pixmapOrColor; 1230 QString pixmapOrColor;
1211 stream >> pixmapOrColor; 1231 stream >> pixmapOrColor;
1212 if ( tabs->view(id) ) 1232 if ( tabs->view(id) )
1213 tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 1233 tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
1214 } else if ( msg == "setTextColor(QString,QString)" ) { 1234 } else if ( msg == "setTextColor(QString,QString)" ) {
1215 QString id; 1235 QString id;
1216 stream >> id; 1236 stream >> id;
1217 QString color; 1237 QString color;
1218 stream >> color; 1238 stream >> color;
1219 if ( tabs->view(id) ) 1239 if ( tabs->view(id) )
1220 tabs->view(id)->setTextColor( QColor(color) ); 1240 tabs->view(id)->setTextColor( QColor(color) );
1221 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 1241 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
1222 QString id; 1242 QString id;
1223 stream >> id; 1243 stream >> id;
1224 QString fam; 1244 QString fam;
1225 stream >> fam; 1245 stream >> fam;
1226 int size; 1246 int size;
1227 stream >> size; 1247 stream >> size;
1228 int weight; 1248 int weight;
1229 stream >> weight; 1249 stream >> weight;
1230 int italic; 1250 int italic;
1231 stream >> italic; 1251 stream >> italic;
1232 if ( tabs->view(id) ) 1252 if ( tabs->view(id) )
1233 if ( !fam. isEmpty ( )) 1253 if ( !fam. isEmpty ( ))
1234 tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 1254 tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
1235 else 1255 else
1236 tabs->view(id)->unsetViewFont(); 1256 tabs->view(id)->unsetViewFont();
1237 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); 1257 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic );
1238 } 1258 }
1239 else if ( msg == "setBusyIndicatorType(QString)" ) { 1259 else if ( msg == "setBusyIndicatorType(QString)" ) {
1240 QString type; 1260 QString type;
1241 stream >> type; 1261 stream >> type;
1242 tabs->setBusyIndicatorType(type); 1262 tabs->setBusyIndicatorType(type);
1243 } 1263 }
1244 else if ( msg == "home()" ) { 1264 else if ( msg == "home()" ) {
1245 if ( isVisibleWindow( winId ( ))) 1265 if ( isVisibleWindow( winId ( )))
1246 nextView ( ); 1266 nextView ( );
1247 else 1267 else
1248 raise ( ); 1268 raise ( );
1249 1269
1250 } 1270 }
1251} 1271}
1252 1272
1253void Launcher::storageChanged() 1273void Launcher::storageChanged()
1254{ 1274{
1255 if ( in_lnk_props ) { 1275 if ( in_lnk_props ) {
1256 got_lnk_change = TRUE; 1276 got_lnk_change = TRUE;
1257 lnk_change = QString::null; 1277 lnk_change = QString::null;
1258 } else { 1278 } else {
1259 updateLink( QString::null ); 1279 updateLink( QString::null );
1260 } 1280 }
1261} 1281}
1262 1282
1263 1283
1264bool Launcher::mkdir(const QString &localPath) 1284bool Launcher::mkdir(const QString &localPath)
1265{ 1285{
1266 QDir fullDir(localPath); 1286 QDir fullDir(localPath);
1267 if (fullDir.exists()) 1287 if (fullDir.exists())
1268 return true; 1288 return true;
1269 1289
1270 // at this point the directory doesn't exist 1290 // at this point the directory doesn't exist
1271 // go through the directory tree and start creating the direcotories 1291 // go through the directory tree and start creating the direcotories
1272 // that don't exist; if we can't create the directories, return false 1292 // that don't exist; if we can't create the directories, return false
1273 1293
1274 QString dirSeps = "/"; 1294 QString dirSeps = "/";
1275 int dirIndex = localPath.find(dirSeps); 1295 int dirIndex = localPath.find(dirSeps);
1276 QString checkedPath; 1296 QString checkedPath;
1277 1297
1278 // didn't find any seps; weird, use the cur dir instead 1298 // didn't find any seps; weird, use the cur dir instead
1279 if (dirIndex == -1) { 1299 if (dirIndex == -1) {
1280 //qDebug("No seperators found in path %s", localPath.latin1()); 1300 //qDebug("No seperators found in path %s", localPath.latin1());
1281 checkedPath = QDir::currentDirPath(); 1301 checkedPath = QDir::currentDirPath();
1282 } 1302 }
1283 1303
1284 while (checkedPath != localPath) { 1304 while (checkedPath != localPath) {
1285 // no more seperators found, use the local path 1305 // no more seperators found, use the local path
1286 if (dirIndex == -1) 1306 if (dirIndex == -1)
1287 checkedPath = localPath; 1307 checkedPath = localPath;
1288 else { 1308 else {
1289 // the next directory to check 1309 // the next directory to check
1290 checkedPath = localPath.left(dirIndex) + "/"; 1310 checkedPath = localPath.left(dirIndex) + "/";
1291 // advance the iterator; the next dir seperator 1311 // advance the iterator; the next dir seperator
1292 dirIndex = localPath.find(dirSeps, dirIndex+1); 1312 dirIndex = localPath.find(dirSeps, dirIndex+1);
1293 } 1313 }
1294 1314
1295 QDir checkDir(checkedPath); 1315 QDir checkDir(checkedPath);
1296 if (!checkDir.exists()) { 1316 if (!checkDir.exists()) {
1297 //qDebug("mkdir making dir %s", checkedPath.latin1()); 1317 //qDebug("mkdir making dir %s", checkedPath.latin1());
1298 1318
1299 if (!checkDir.mkdir(checkedPath)) { 1319 if (!checkDir.mkdir(checkedPath)) {
1300 qDebug("Unable to make directory %s", checkedPath.latin1()); 1320 qDebug("Unable to make directory %s", checkedPath.latin1());
1301 return FALSE; 1321 return FALSE;
1302 } 1322 }
1303 } 1323 }
1304 1324
1305 } 1325 }
1306 return TRUE; 1326 return TRUE;
1307} 1327}
1308 1328
1309void Launcher::preloadApps() 1329void Launcher::preloadApps()
1310{ 1330{
1311 Config cfg("Launcher"); 1331 Config cfg("Launcher");
1312 cfg.setGroup("Preload"); 1332 cfg.setGroup("Preload");
1313 QStringList apps = cfg.readListEntry("Apps",','); 1333 QStringList apps = cfg.readListEntry("Apps",',');
1314 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 1334 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
1315#ifndef QT_NO_COP 1335#ifndef QT_NO_COP
1316 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 1336 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
1317#endif 1337#endif
1318 } 1338 }
1319} 1339}
1340
1341DocumentTab::DocumentTab( QWidget *parent, int mode, int selector, const QString &dirName, const QString &fileName)
1342 : OFileSelector(parent,mode,selector,dirName,fileName)
1343{
1344 setYesCancelVisible(false);
1345 setToolbarVisible(true);
1346 setPermissionBarVisible(false);
1347 setLineEditVisible(false) ;
1348 //setChooserVisible( bool chooser );
1349
1350}
1351
1352DocumentTab::~DocumentTab() {
1353
1354}
1355
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h
index c92ef5d..0616734 100644
--- a/core/launcher/launcher.h
+++ b/core/launcher/launcher.h
@@ -1,13 +1,12 @@
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**
6** This file may be distributed and/or modified under the terms of the 5** 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 6** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 8** packaging of this file.
10** 9**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** 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. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 12**
@@ -16,69 +15,89 @@
16** Contact info@trolltech.com if any conditions of this licensing are 15** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 16** not clear to you.
18** 17**
19**********************************************************************/ 18**********************************************************************/
20#ifndef LAUNCHER_H 19#ifndef LAUNCHER_H
21#define LAUNCHER_H 20#define LAUNCHER_H
22 21
23#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/applnk.h>
24
25#include <opie/ofileselector.h>
26
24#include <qmainwindow.h> 27#include <qmainwindow.h>
25#include <qtabbar.h> 28#include <qtabbar.h>
26#include <qstringlist.h> 29#include <qstringlist.h>
27#include <qvbox.h> 30#include <qvbox.h>
28#include <qlist.h> 31#include <qlist.h>
29#include <qpe/palmtopuidgen.h> 32#include <qpe/palmtopuidgen.h>
30#include "launcherview.h" 33#include "launcherview.h"
31 34
32class AppLnk; 35class AppLnk;
33class AppLnkSet; 36class AppLnkSet;
34class DocLnkSet; 37class DocLnkSet;
35class QWidgetStack; 38class QWidgetStack;
36class StorageInfo; 39class StorageInfo;
37class SyncDialog; 40class SyncDialog;
38 41
42
43class DocumentTab : public OFileSelector
44{
45 Q_OBJECT
46public:
47 DocumentTab( QWidget *parent, int mode, int selector, const QString &dirName, const QString &fileName);//, 4,0, "/","");
48~DocumentTab();
49private:
50
51};
52
39class CategoryTabBar : public QTabBar 53class CategoryTabBar : public QTabBar
40{ 54{
41 Q_OBJECT 55 Q_OBJECT
42public: 56public:
43 CategoryTabBar( QWidget *parent=0, const char *name=0 ); 57 CategoryTabBar( QWidget *parent=0, const char *name=0 );
44 ~CategoryTabBar(); 58 ~CategoryTabBar();
45 59
60signals:
61
46protected slots: 62protected slots:
47 virtual void layoutTabs(); 63 virtual void layoutTabs();
48 64
49protected: 65protected:
50 void paint ( QPainter *p, QTab *t, bool f ) const; 66 void paint ( QPainter *p, QTab *t, bool f ) const;
51 void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; 67 void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const;
68
52}; 69};
53 70
54class CategoryTabWidget : public QVBox { 71class CategoryTabWidget : public QVBox {
55 // can't use a QTabWidget, since it won't let us set the frame style. 72 // can't use a QTabWidget, since it won't let us set the frame style.
56 Q_OBJECT 73 Q_OBJECT
57public: 74public:
58 CategoryTabWidget( QWidget* parent ); 75 CategoryTabWidget( QWidget* parent );
59 void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, 76 void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder,
60 const QList<FileSystem> &); 77 const QList<FileSystem> &);
61 void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); 78// void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs);
62 void updateLink(const QString& linkfile); 79 void updateLink(const QString& linkfile);
63 void setBusy(bool on); 80 void setBusy(bool on);
64 QString getAllDocLinkInfo() const; 81 QString getAllDocLinkInfo() const;
65 LauncherView *view( const QString &id ); 82 LauncherView *view( const QString &id );
66 void setBusyIndicatorType ( const QString &type ); 83 void setBusyIndicatorType ( const QString &type );
84 DocumentTab *fileSel;
67signals: 85signals:
68 void selected(const QString&); 86 void selected(const QString&);
69 void clicked(const AppLnk*); 87 void clicked(const AppLnk*);
70 void rightPressed(AppLnk*); 88 void rightPressed(AppLnk*);
71 89 void ofileSel(const DocLnk &);
72public slots: 90public slots:
73 void nextTab(); 91 void nextTab();
74 void prevTab(); 92 void prevTab();
75 void showTab(const QString&); 93 void showTab(const QString&);
76 94 void clickie(const DocLnk&);
95 void clickie(const QString &);
77protected slots: 96protected slots:
78 void tabProperties(); 97 void tabProperties();
79 98
80protected: 99protected:
81 void setTabAppearance( const QString &id, Config &cfg ); 100 void setTabAppearance( const QString &id, Config &cfg );
82 void paletteChange( const QPalette &p ); 101 void paletteChange( const QPalette &p );
83 102
84private: 103private: