summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-07-14 18:49:16 (UTC)
committer llornkcor <llornkcor>2003-07-14 18:49:16 (UTC)
commitab28f35bc3c9c184862ac19462322eed2be0f541 (patch) (unidiff)
tree99bff20a6ca5c4b19d972d72ca2ec9abbaaa0e9d
parenta62dda249a0b823e1aa006bbc502f72e9af7da95 (diff)
downloadopie-ab28f35bc3c9c184862ac19462322eed2be0f541.zip
opie-ab28f35bc3c9c184862ac19462322eed2be0f541.tar.gz
opie-ab28f35bc3c9c184862ac19462322eed2be0f541.tar.bz2
try to fix crash when insert drive. please test.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index d9fc8e4..5f050aa 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,951 +1,951 @@
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// 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> 25//#include <opie/ofiledialog.h>
26#include <opie/ofileselector.h> 26#include <opie/ofileselector.h>
27#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include <qpe/applnk.h> 29#include <qpe/applnk.h>
30#include <qpe/config.h> 30#include <qpe/config.h>
31#include <qpe/global.h> 31#include <qpe/global.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/mimetype.h> 33#include <qpe/mimetype.h>
34#include <qpe/storage.h> 34#include <qpe/storage.h>
35#include <qpe/palmtoprecord.h> 35#include <qpe/palmtoprecord.h>
36 36
37#include <qpe/version.h> 37#include <qpe/version.h>
38 38
39#include <qdir.h> 39#include <qdir.h>
40#ifdef QWS 40#ifdef QWS
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42#endif 42#endif
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qcombobox.h> 44#include <qcombobox.h>
45#include <qvbox.h> 45#include <qvbox.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qstyle.h> 47#include <qstyle.h>
48#include <qpushbutton.h> 48#include <qpushbutton.h>
49#include <qtabbar.h> 49#include <qtabbar.h>
50#include <qwidgetstack.h> 50#include <qwidgetstack.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qframe.h> 54#include <qframe.h>
55#include <qpainter.h> 55#include <qpainter.h>
56#include <qlabel.h> 56#include <qlabel.h>
57#include <qtextstream.h> 57#include <qtextstream.h>
58#include <qpopupmenu.h> 58#include <qpopupmenu.h>
59 59
60#include <opie/owait.h> 60#include <opie/owait.h>
61 61
62 62
63#include "launcherview.h" 63#include "launcherview.h"
64#include "launcher.h" 64#include "launcher.h"
65#include "syncdialog.h" 65#include "syncdialog.h"
66#include "desktop.h" 66#include "desktop.h"
67#include <qpe/lnkproperties.h> 67#include <qpe/lnkproperties.h>
68//#include "mrulist.h" 68//#include "mrulist.h"
69#include "qrsync.h" 69#include "qrsync.h"
70#include <stdlib.h> 70#include <stdlib.h>
71#include <unistd.h> 71#include <unistd.h>
72 72
73#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 73#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
74#include <stdio.h> 74#include <stdio.h>
75#include <sys/vfs.h> 75#include <sys/vfs.h>
76#include <mntent.h> 76#include <mntent.h>
77#endif 77#endif
78 78
79#include <qpe/storage.h> 79#include <qpe/storage.h>
80#include "mediummountgui.h" 80#include "mediummountgui.h"
81 81
82namespace { 82namespace {
83 QStringList configToMime( Config *cfg ){ 83 QStringList configToMime( Config *cfg ){
84 QStringList mimes; 84 QStringList mimes;
85 bool tmpMime = true; 85 bool tmpMime = true;
86 cfg->setGroup("mimetypes" ); 86 cfg->setGroup("mimetypes" );
87 tmpMime = cfg->readBoolEntry("all" ,true); 87 tmpMime = cfg->readBoolEntry("all" ,true);
88 if( tmpMime ){ 88 if( tmpMime ){
89 mimes << QString::null; 89 mimes << QString::null;
90 return mimes; 90 return mimes;
91 }else{ 91 }else{
92 tmpMime = cfg->readBoolEntry("audio", true ); 92 tmpMime = cfg->readBoolEntry("audio", true );
93 if(tmpMime ) 93 if(tmpMime )
94 mimes.append("audio/*" ); 94 mimes.append("audio/*" );
95 95
96 tmpMime = cfg->readBoolEntry("image", true ); 96 tmpMime = cfg->readBoolEntry("image", true );
97 if(tmpMime ) 97 if(tmpMime )
98 mimes.append("image/*" ); 98 mimes.append("image/*" );
99 99
100 tmpMime = cfg->readBoolEntry("text", true ); 100 tmpMime = cfg->readBoolEntry("text", true );
101 if(tmpMime ) 101 if(tmpMime )
102 mimes.append("text/*"); 102 mimes.append("text/*");
103 103
104 tmpMime = cfg->readBoolEntry("video", true ); 104 tmpMime = cfg->readBoolEntry("video", true );
105 if(tmpMime ) 105 if(tmpMime )
106 mimes.append("video/*" ); 106 mimes.append("video/*" );
107 } 107 }
108 return mimes; 108 return mimes;
109 } 109 }
110 110
111} 111}
112 112
113 113
114 114
115//#define SHOW_ALL 115//#define SHOW_ALL
116 116
117class CategoryTab : public QTab 117class CategoryTab : public QTab
118{ 118{
119public: 119public:
120 CategoryTab( const QIconSet &icon, const QString &text=QString::null ) 120 CategoryTab( const QIconSet &icon, const QString &text=QString::null )
121 : QTab( icon, text ) 121 : QTab( icon, text )
122 { 122 {
123 } 123 }
124 124
125 QColor bgColor; 125 QColor bgColor;
126 QColor fgColor; 126 QColor fgColor;
127}; 127};
128 128
129//=========================================================================== 129//===========================================================================
130 130
131CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 131CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
132 QVBox( parent ) 132 QVBox( parent )
133{ 133{
134 categoryBar = 0; 134 categoryBar = 0;
135 stack = 0; 135 stack = 0;
136} 136}
137 137
138void CategoryTabWidget::prevTab() 138void CategoryTabWidget::prevTab()
139{ 139{
140 if ( categoryBar ) { 140 if ( categoryBar ) {
141 int n = categoryBar->count(); 141 int n = categoryBar->count();
142 int tab = categoryBar->currentTab(); 142 int tab = categoryBar->currentTab();
143 if ( tab >= 0 ) 143 if ( tab >= 0 )
144 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 144 categoryBar->setCurrentTab( (tab - 1 + n)%n );
145 } 145 }
146} 146}
147 147
148void CategoryTabWidget::nextTab() 148void CategoryTabWidget::nextTab()
149{ 149{
150 if ( categoryBar ) { 150 if ( categoryBar ) {
151 int n = categoryBar->count(); 151 int n = categoryBar->count();
152 int tab = categoryBar->currentTab(); 152 int tab = categoryBar->currentTab();
153 categoryBar->setCurrentTab( (tab + 1)%n ); 153 categoryBar->setCurrentTab( (tab + 1)%n );
154 } 154 }
155} 155}
156 156
157 157
158void CategoryTabWidget::showTab(const QString& id) 158void CategoryTabWidget::showTab(const QString& id)
159{ 159{
160 if ( categoryBar ) { 160 if ( categoryBar ) {
161 int idx = ids.findIndex( id ); 161 int idx = ids.findIndex( id );
162 categoryBar->setCurrentTab( idx ); 162 categoryBar->setCurrentTab( idx );
163 } 163 }
164} 164}
165 165
166void CategoryTabWidget::addItem( const QString& linkfile ) 166void CategoryTabWidget::addItem( const QString& linkfile )
167{ 167{
168 int i=0; 168 int i=0;
169 AppLnk *app = new AppLnk(linkfile); 169 AppLnk *app = new AppLnk(linkfile);
170 if ( !app->isValid() ) { 170 if ( !app->isValid() ) {
171 delete app; 171 delete app;
172 app=0; 172 app=0;
173 } 173 }
174 if ( !app || !app->file().isEmpty() ) { 174 if ( !app || !app->file().isEmpty() ) {
175 // A document 175 // A document
176 delete app; 176// delete app;
177 app = new DocLnk(linkfile); 177// app = new DocLnk(linkfile);
178 if ( app->fileKnown() ) { 178// if ( app->fileKnown() ) {
179 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 179// ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
180 } else { 180// } else {
181 ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); 181// ((LauncherView*)(stack->widget(ids.count()-1)))->sort();
182 delete app; 182// delete app;
183 } 183// }
184 return; 184 return;
185 } 185 }
186 // An application 186 // An application
187 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 187 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
188 if ( !(*it).isEmpty() ) { 188 if ( !(*it).isEmpty() ) {
189 QRegExp tf(*it,FALSE,TRUE); 189 QRegExp tf(*it,FALSE,TRUE);
190 if ( tf.match(app->type()) >= 0 ) { 190 if ( tf.match(app->type()) >= 0 ) {
191 ((LauncherView*)stack->widget(i))->addItem(app); 191 ((LauncherView*)stack->widget(i))->addItem(app);
192 return; 192 return;
193 } 193 }
194 i++; 194 i++;
195 } 195 }
196 } 196 }
197 197
198 QCopEnvelope e("QPE/TaskBar","reloadApps()"); 198 QCopEnvelope e("QPE/TaskBar","reloadApps()");
199} 199}
200 200
201void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, 201void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
202 AppLnkSet* /*docFolder*/, const QList<FileSystem> & /*fs*/) 202 AppLnkSet* /*docFolder*/, const QList<FileSystem> & /*fs*/)
203{ 203{
204 QString current; 204 QString current;
205 if ( categoryBar ) { 205 if ( categoryBar ) {
206 int c = categoryBar->currentTab(); 206 int c = categoryBar->currentTab();
207 if ( c >= 0 ) current = ids[c]; 207 if ( c >= 0 ) current = ids[c];
208 } 208 }
209 209
210 delete categoryBar; 210 delete categoryBar;
211 categoryBar = new CategoryTabBar( this ); 211 categoryBar = new CategoryTabBar( this );
212 QPalette pal = categoryBar->palette(); 212 QPalette pal = categoryBar->palette();
213 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 213 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
214 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 214 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
215 categoryBar->setPalette( pal ); 215 categoryBar->setPalette( pal );
216 216
217 delete stack; 217 delete stack;
218 stack = new QWidgetStack(this); 218 stack = new QWidgetStack(this);
219 tabs=0; 219 tabs=0;
220 220
221 ids.clear(); 221 ids.clear();
222 222
223 Config cfg("Launcher"); 223 Config cfg("Launcher");
224 224
225 QStringList types = rootFolder->types(); 225 QStringList types = rootFolder->types();
226 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 226 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
227 if ( !(*it).isEmpty() ) { 227 if ( !(*it).isEmpty() ) {
228 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); 228 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it));
229 setTabAppearance( *it, cfg ); 229 setTabAppearance( *it, cfg );
230 } 230 }
231 } 231 }
232 QListIterator<AppLnk> it( rootFolder->children() ); 232 QListIterator<AppLnk> it( rootFolder->children() );
233 AppLnk* l; 233 AppLnk* l;
234 while ( (l=it.current()) ) { 234 while ( (l=it.current()) ) {
235 if ( l->type() == "Separator" ) { // No tr 235 if ( l->type() == "Separator" ) { // No tr
236 rootFolder->remove(l); 236 rootFolder->remove(l);
237 delete l; 237 delete l;
238 } else { 238 } else {
239 int i=0; 239 int i=0;
240 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 240 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
241 if ( *it == l->type() ) 241 if ( *it == l->type() )
242 ((LauncherView*)stack->widget(i))->addItem(l,FALSE); 242 ((LauncherView*)stack->widget(i))->addItem(l,FALSE);
243 i++; 243 i++;
244 } 244 }
245 } 245 }
246 ++it; 246 ++it;
247 } 247 }
248 rootFolder->detachChildren(); 248 rootFolder->detachChildren();
249 for (int i=0; i<tabs; i++) 249 for (int i=0; i<tabs; i++)
250 ((LauncherView*)stack->widget(i))->sort(); 250 ((LauncherView*)stack->widget(i))->sort();
251 251
252 // all documents 252 // all documents
253 QImage img( Resource::loadImage( "DocsIcon" ) ); 253 QImage img( Resource::loadImage( "DocsIcon" ) );
254 QPixmap pm; 254 QPixmap pm;
255 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 255 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
256 256
257 //ljpotter 257 //ljpotter
258 CategoryTab *catTab ; 258 CategoryTab *catTab ;
259 catTab = new CategoryTab( pm, "Documents" ); 259 catTab = new CategoryTab( pm, "Documents" );
260 260
261 categoryBar->addTab( catTab ); 261 categoryBar->addTab( catTab );
262 262
263 fileSel = new DocumentTab( stack, 4, 0, "/",""); 263 fileSel = new DocumentTab( stack, 4, 0, "/","");
264 stack->addWidget( fileSel, tabs++ ); 264 stack->addWidget( fileSel, tabs++ );
265 265
266 // fileSel->hide(); 266 // fileSel->hide();
267 267
268 connect( fileSel, SIGNAL( fileSelected( const DocLnk & )), 268 connect( fileSel, SIGNAL( fileSelected( const DocLnk & )),
269 this, SLOT(clickie(const DocLnk&)) ); 269 this, SLOT(clickie(const DocLnk&)) );
270 270
271// connect( fileSel, SIGNAL( fileSelected( const QString & )), 271// connect( fileSel, SIGNAL( fileSelected( const QString & )),
272// this, SLOT(clickie(const QString&)) ); 272// this, SLOT(clickie(const QString&)) );
273 273
274 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); 274 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) );
275 275
276 ((LauncherView*)stack->widget(0))->setFocus(); 276 ((LauncherView*)stack->widget(0))->setFocus();
277 277
278 cfg. setGroup ( "GUI" ); 278 cfg. setGroup ( "GUI" );
279 setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null )); 279 setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null ));
280 280
281 if ( !current.isNull() ) { 281 if ( !current.isNull() ) {
282 showTab(current); 282 showTab(current);
283 } 283 }
284 284
285 categoryBar->show(); 285 categoryBar->show();
286 stack->show(); 286 stack->show();
287 287
288 288
289 QCopEnvelope e("QPE/TaskBar","reloadApps()"); 289 QCopEnvelope e("QPE/TaskBar","reloadApps()");
290} 290}
291 291
292void CategoryTabWidget::clickie(const DocLnk &lnk) { 292void CategoryTabWidget::clickie(const DocLnk &lnk) {
293 lnk.execute(); 293 lnk.execute();
294 // fileSel->reparse(); 294 // fileSel->reparse();
295} 295}
296 296
297void CategoryTabWidget::clickie(const QString &appStr) { 297void CategoryTabWidget::clickie(const QString &appStr) {
298// DocLnk lnk(appStr); 298// DocLnk lnk(appStr);
299// lnk.execute(); 299// lnk.execute();
300} 300}
301 301
302void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) 302void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg )
303{ 303{
304 QString grp( "Tab %1" ); // No tr 304 QString grp( "Tab %1" ); // No tr
305 cfg.setGroup( grp.arg(id) ); 305 cfg.setGroup( grp.arg(id) );
306 LauncherView *v = view( id ); 306 LauncherView *v = view( id );
307 int idx = ids.findIndex( id ); 307 int idx = ids.findIndex( id );
308 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); 308 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx );
309 309
310 // View 310 // View
311 QString view = cfg.readEntry( "View", "Icon" ); 311 QString view = cfg.readEntry( "View", "Icon" );
312 if ( view == "List" ) // No tr 312 if ( view == "List" ) // No tr
313 v->setViewMode( LauncherView::List ); 313 v->setViewMode( LauncherView::List );
314 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 314 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
315 if ( bgType == "Image" ) { // No tr 315 if ( bgType == "Image" ) { // No tr
316 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 316 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
317 v->setBackgroundType( LauncherView::Image, pm ); 317 v->setBackgroundType( LauncherView::Image, pm );
318 } else if ( bgType == "SolidColor" ) { 318 } else if ( bgType == "SolidColor" ) {
319 QString c = cfg.readEntry( "BackgroundColor" ); 319 QString c = cfg.readEntry( "BackgroundColor" );
320 v->setBackgroundType( LauncherView::SolidColor, c ); 320 v->setBackgroundType( LauncherView::SolidColor, c );
321 } 321 }
322 QString textCol = cfg.readEntry( "TextColor" ); 322 QString textCol = cfg.readEntry( "TextColor" );
323 if ( textCol.isEmpty() ) 323 if ( textCol.isEmpty() )
324 v->setTextColor( QColor() ); 324 v->setTextColor( QColor() );
325 else 325 else
326 v->setTextColor( QColor(textCol) ); 326 v->setTextColor( QColor(textCol) );
327 QStringList font = cfg.readListEntry( "Font", ',' ); 327 QStringList font = cfg.readListEntry( "Font", ',' );
328 if ( font.count() == 4 ) 328 if ( font.count() == 4 )
329 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) );
330 330
331 // Tabs 331 // Tabs
332 QString tabCol = cfg.readEntry( "TabColor" ); 332 QString tabCol = cfg.readEntry( "TabColor" );
333 if ( tabCol.isEmpty() ) 333 if ( tabCol.isEmpty() )
334 tab->bgColor = QColor(); 334 tab->bgColor = QColor();
335 else 335 else
336 tab->bgColor = QColor(tabCol); 336 tab->bgColor = QColor(tabCol);
337 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 337 QString tabTextCol = cfg.readEntry( "TabTextColor" );
338 if ( tabTextCol.isEmpty() ) 338 if ( tabTextCol.isEmpty() )
339 tab->fgColor = QColor(); 339 tab->fgColor = QColor();
340 else 340 else
341 tab->fgColor = QColor(tabTextCol); 341 tab->fgColor = QColor(tabTextCol);
342} 342}
343 343
344//void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> & /*fs*/) 344//void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> & /*fs*/)
345//{ 345//{
346 // docFolder->detachChildren(); 346 // docFolder->detachChildren();
347//} 347//}
348 348
349void CategoryTabWidget::tabProperties() 349void CategoryTabWidget::tabProperties()
350{ 350{
351 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); 351 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() );
352 QPopupMenu *m = new QPopupMenu( this ); 352 QPopupMenu *m = new QPopupMenu( this );
353 m->insertItem( tr("Icon View"), LauncherView::Icon ); 353 m->insertItem( tr("Icon View"), LauncherView::Icon );
354 m->insertItem( tr("List View"), LauncherView::List ); 354 m->insertItem( tr("List View"), LauncherView::List );
355 m->setItemChecked( (int)view->viewMode(), TRUE ); 355 m->setItemChecked( (int)view->viewMode(), TRUE );
356 int rv = m->exec( QCursor::pos() ); 356 int rv = m->exec( QCursor::pos() );
357 if ( rv >= 0 && rv != view->viewMode() ) { 357 if ( rv >= 0 && rv != view->viewMode() ) {
358 view->setViewMode( (LauncherView::ViewMode)rv ); 358 view->setViewMode( (LauncherView::ViewMode)rv );
359 } 359 }
360 360
361 delete m; 361 delete m;
362} 362}
363 363
364QString CategoryTabWidget::getAllDocLinkInfo() const 364QString CategoryTabWidget::getAllDocLinkInfo() const
365{ 365{
366 return ""; 366 return "";
367} 367}
368 368
369LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 369LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
370{ 370{
371 LauncherView* view = new LauncherView( stack ); 371 LauncherView* view = new LauncherView( stack );
372 connect( view, SIGNAL(clicked(const AppLnk*)), 372 connect( view, SIGNAL(clicked(const AppLnk*)),
373 this, SIGNAL(clicked(const AppLnk*))); 373 this, SIGNAL(clicked(const AppLnk*)));
374 connect( view, SIGNAL(rightPressed(AppLnk*)), 374 connect( view, SIGNAL(rightPressed(AppLnk*)),
375 this, SIGNAL(rightPressed(AppLnk*))); 375 this, SIGNAL(rightPressed(AppLnk*)));
376 ids.append(id); 376 ids.append(id);
377 categoryBar->addTab( new CategoryTab( pm, label ) ); 377 categoryBar->addTab( new CategoryTab( pm, label ) );
378 stack->addWidget( view, tabs++ ); 378 stack->addWidget( view, tabs++ );
379 return view; 379 return view;
380} 380}
381 381
382void CategoryTabWidget::updateLink(const QString& linkfile) 382void CategoryTabWidget::updateLink(const QString& linkfile)
383{ 383{
384 // LauncherView* view; 384 // LauncherView* view;
385 qApp->processEvents(); 385 qApp->processEvents();
386// while ((view = (LauncherView*)stack->widget(i++))) { 386// while ((view = (LauncherView*)stack->widget(i++))) {
387// if ( view->removeLink(linkfile) ) 387// if ( view->removeLink(linkfile) )
388// break; 388// break;
389// } 389// }
390 // addItem(linkfile); 390 // addItem(linkfile);
391 fileSel->reparse(); 391 fileSel->reparse();
392} 392}
393 393
394void CategoryTabWidget::paletteChange( const QPalette &p ) 394void CategoryTabWidget::paletteChange( const QPalette &p )
395{ 395{
396 QVBox::paletteChange( p ); 396 QVBox::paletteChange( p );
397 QPalette pal = palette(); 397 QPalette pal = palette();
398 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 398 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
399 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 399 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
400 categoryBar->setPalette( pal ); 400 categoryBar->setPalette( pal );
401 categoryBar->update(); 401 categoryBar->update();
402} 402}
403 403
404void CategoryTabWidget::setBusy(bool on) 404void CategoryTabWidget::setBusy(bool on)
405{ 405{
406 if ( on ) 406 if ( on )
407 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); 407 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE);
408 else 408 else
409 for (int i=0; i<tabs-1; i++) 409 for (int i=0; i<tabs-1; i++)
410 ((LauncherView*)stack->widget(i))->setBusy(FALSE); 410 ((LauncherView*)stack->widget(i))->setBusy(FALSE);
411} 411}
412 412
413LauncherView *CategoryTabWidget::view( const QString &id ) 413LauncherView *CategoryTabWidget::view( const QString &id )
414{ 414{
415 int idx = ids.findIndex( id ); 415 int idx = ids.findIndex( id );
416 return (LauncherView *)stack->widget(idx); 416 return (LauncherView *)stack->widget(idx);
417} 417}
418 418
419void CategoryTabWidget::setBusyIndicatorType ( const QString &type ) 419void CategoryTabWidget::setBusyIndicatorType ( const QString &type )
420{ 420{
421 for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it ) 421 for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it )
422 view ( *it )-> setBusyIndicatorType ( type ); 422 view ( *it )-> setBusyIndicatorType ( type );
423} 423}
424 424
425//=========================================================================== 425//===========================================================================
426 426
427CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) 427CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name )
428 : QTabBar( parent, name ) 428 : QTabBar( parent, name )
429{ 429{
430 setFocusPolicy( NoFocus ); 430 setFocusPolicy( NoFocus );
431 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); 431 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) );
432} 432}
433 433
434CategoryTabBar::~CategoryTabBar() 434CategoryTabBar::~CategoryTabBar()
435{ 435{
436} 436}
437 437
438void CategoryTabBar::layoutTabs() 438void CategoryTabBar::layoutTabs()
439{ 439{
440 if ( !count() ) 440 if ( !count() )
441 return; 441 return;
442 442
443// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; 443// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 };
444 int available = width()-1; 444 int available = width()-1;
445 QFontMetrics fm = fontMetrics(); 445 QFontMetrics fm = fontMetrics();
446 int hiddenTabWidth = -7; 446 int hiddenTabWidth = -7;
447 int middleTab = currentTab(); 447 int middleTab = currentTab();
448 int hframe, vframe, overlap; 448 int hframe, vframe, overlap;
449 style().tabbarMetrics( this, hframe, vframe, overlap ); 449 style().tabbarMetrics( this, hframe, vframe, overlap );
450 int x = 0; 450 int x = 0;
451 QRect r; 451 QRect r;
452 QTab *t; 452 QTab *t;
453 int required = 0; 453 int required = 0;
454 int eventabwidth = (width()-1)/count(); 454 int eventabwidth = (width()-1)/count();
455 enum Mode { HideBackText, Pack, Even } mode=Even; 455 enum Mode { HideBackText, Pack, Even } mode=Even;
456 for ( int i = 0; i < count(); i++ ) { 456 for ( int i = 0; i < count(); i++ ) {
457 t = tab(i); 457 t = tab(i);
458 int iw = fm.width( t->text() ) + hframe - overlap; 458 int iw = fm.width( t->text() ) + hframe - overlap;
459 if ( i != middleTab ) { 459 if ( i != middleTab ) {
460 available -= hiddenTabWidth + hframe - overlap; 460 available -= hiddenTabWidth + hframe - overlap;
461 if ( t->iconSet() != 0 ) 461 if ( t->iconSet() != 0 )
462 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 462 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
463 } 463 }
464 if ( t->iconSet() != 0 ) 464 if ( t->iconSet() != 0 )
465 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 465 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
466 required += iw; 466 required += iw;
467 // 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.
468 if ( iw >= eventabwidth-10 ) 468 if ( iw >= eventabwidth-10 )
469 mode = Pack; 469 mode = Pack;
470 } 470 }
471 if ( mode == Pack && required > width()-1 ) 471 if ( mode == Pack && required > width()-1 )
472 mode = HideBackText; 472 mode = HideBackText;
473 for ( int i = 0; i < count(); i++ ) { 473 for ( int i = 0; i < count(); i++ ) {
474 t = tab(i); 474 t = tab(i);
475 if ( mode != HideBackText ) { 475 if ( mode != HideBackText ) {
476 int w = fm.width( t->text() ); 476 int w = fm.width( t->text() );
477 int ih = 0; 477 int ih = 0;
478 if ( t->iconSet() != 0 ) { 478 if ( t->iconSet() != 0 ) {
479 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 479 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
480 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 480 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
481 } 481 }
482 int h = QMAX( fm.height(), ih ); 482 int h = QMAX( fm.height(), ih );
483 h = QMAX( h, QApplication::globalStrut().height() ); 483 h = QMAX( h, QApplication::globalStrut().height() );
484 484
485 h += vframe; 485 h += vframe;
486 w += hframe; 486 w += hframe;
487 487
488 QRect tr(x, 0, 488 QRect tr(x, 0,
489 mode == Even ? eventabwidth : w * (width()-1)/required, h); 489 mode == Even ? eventabwidth : w * (width()-1)/required, h);
490 t->setRect(tr); 490 t->setRect(tr);
491 x += tr.width() - overlap; 491 x += tr.width() - overlap;
492 r = r.unite(tr); 492 r = r.unite(tr);
493 } else if ( i != middleTab ) { 493 } else if ( i != middleTab ) {
494 int w = hiddenTabWidth; 494 int w = hiddenTabWidth;
495 int ih = 0; 495 int ih = 0;
496 if ( t->iconSet() != 0 ) { 496 if ( t->iconSet() != 0 ) {
497 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 497 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
498 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 498 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
499 } 499 }
500 int h = QMAX( fm.height(), ih ); 500 int h = QMAX( fm.height(), ih );
501 h = QMAX( h, QApplication::globalStrut().height() ); 501 h = QMAX( h, QApplication::globalStrut().height() );
502 502
503 h += vframe; 503 h += vframe;
504 w += hframe; 504 w += hframe;
505 505
506 t->setRect( QRect(x, 0, w, h) ); 506 t->setRect( QRect(x, 0, w, h) );
507 x += t->rect().width() - overlap; 507 x += t->rect().width() - overlap;
508 r = r.unite( t->rect() ); 508 r = r.unite( t->rect() );
509 } else { 509 } else {
510 int ih = 0; 510 int ih = 0;
511 if ( t->iconSet() != 0 ) { 511 if ( t->iconSet() != 0 ) {
512 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 512 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
513 } 513 }
514 int h = QMAX( fm.height(), ih ); 514 int h = QMAX( fm.height(), ih );
515 h = QMAX( h, QApplication::globalStrut().height() ); 515 h = QMAX( h, QApplication::globalStrut().height() );
516 516
517 h += vframe; 517 h += vframe;
518 518
519 t->setRect( QRect(x, 0, available, h) ); 519 t->setRect( QRect(x, 0, available, h) );
520 x += t->rect().width() - overlap; 520 x += t->rect().width() - overlap;
521 r = r.unite( t->rect() ); 521 r = r.unite( t->rect() );
522 } 522 }
523 } 523 }
524 524
525 QRect rr = tab(count()-1)->rect(); 525 QRect rr = tab(count()-1)->rect();
526 rr.setRight(width()-1); 526 rr.setRight(width()-1);
527 tab(count()-1)->setRect( rr ); 527 tab(count()-1)->setRect( rr );
528 528
529 for ( t = tabList()->first(); t; t = tabList()->next() ) { 529 for ( t = tabList()->first(); t; t = tabList()->next() ) {
530 QRect tr = t->rect(); 530 QRect tr = t->rect();
531 tr.setHeight( r.height() ); 531 tr.setHeight( r.height() );
532 t->setRect( tr ); 532 t->setRect( tr );
533 } 533 }
534 534
535 update(); 535 update();
536} 536}
537 537
538 538
539void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const 539void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
540{ 540{
541 CategoryTabBar *that = (CategoryTabBar *) this; 541 CategoryTabBar *that = (CategoryTabBar *) this;
542 CategoryTab *ct = (CategoryTab *)t; 542 CategoryTab *ct = (CategoryTab *)t;
543 QPalette pal = palette(); 543 QPalette pal = palette();
544 bool setPal = FALSE; 544 bool setPal = FALSE;
545 if ( ct->bgColor.isValid() ) { 545 if ( ct->bgColor.isValid() ) {
546 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); 546 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor );
547 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); 547 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor );
548 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); 548 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor );
549 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); 549 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor );
550 that->setUpdatesEnabled( FALSE ); 550 that->setUpdatesEnabled( FALSE );
551 that->setPalette( pal ); 551 that->setPalette( pal );
552 setPal = TRUE; 552 setPal = TRUE;
553 } 553 }
554#if QT_VERSION >= 300 554#if QT_VERSION >= 300
555 QStyle::SFlags flags = QStyle::Style_Default; 555 QStyle::SFlags flags = QStyle::Style_Default;
556 if ( selected ) 556 if ( selected )
557 flags |= QStyle::Style_Selected; 557 flags |= QStyle::Style_Selected;
558 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 558 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
559 colorGroup(), flags, QStyleOption(t) ); 559 colorGroup(), flags, QStyleOption(t) );
560#else 560#else
561 style().drawTab( p, this, t, selected ); 561 style().drawTab( p, this, t, selected );
562#endif 562#endif
563 563
564 QRect r( t->rect() ); 564 QRect r( t->rect() );
565 QFont f( font() ); 565 QFont f( font() );
566 if ( selected ) 566 if ( selected )
567 f.setBold( TRUE ); 567 f.setBold( TRUE );
568 p->setFont( f ); 568 p->setFont( f );
569 569
570 if ( ct->fgColor.isValid() ) { 570 if ( ct->fgColor.isValid() ) {
571 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); 571 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor );
572 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); 572 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor );
573 that->setUpdatesEnabled( FALSE ); 573 that->setUpdatesEnabled( FALSE );
574 that->setPalette( pal ); 574 that->setPalette( pal );
575 setPal = TRUE; 575 setPal = TRUE;
576 } 576 }
577 int iw = 0; 577 int iw = 0;
578 int ih = 0; 578 int ih = 0;
579 if ( t->iconSet() != 0 ) { 579 if ( t->iconSet() != 0 ) {
580 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 580 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
581 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 581 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
582 } 582 }
583 int w = iw + p->fontMetrics().width( t->text() ) + 4; 583 int w = iw + p->fontMetrics().width( t->text() ) + 4;
584 int h = QMAX(p->fontMetrics().height() + 4, ih ); 584 int h = QMAX(p->fontMetrics().height() + 4, ih );
585 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 585 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
586 r.top() + (r.height()-h)/2, w, h ), t, 586 r.top() + (r.height()-h)/2, w, h ), t,
587#if QT_VERSION >= 300 587#if QT_VERSION >= 300
588 t->identifier() == keyboardFocusTab() 588 t->identifier() == keyboardFocusTab()
589#else 589#else
590 t->identitifer() == keyboardFocusTab() 590 t->identitifer() == keyboardFocusTab()
591#endif 591#endif
592 ); 592 );
593 if ( setPal ) { 593 if ( setPal ) {
594 that->unsetPalette(); 594 that->unsetPalette();
595 that->setUpdatesEnabled( TRUE ); 595 that->setUpdatesEnabled( TRUE );
596 } 596 }
597} 597}
598 598
599 599
600void CategoryTabBar::paintLabel( QPainter* p, const QRect&, 600void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
601 QTab* t, bool has_focus ) const 601 QTab* t, bool has_focus ) const
602{ 602{
603 QRect r = t->rect(); 603 QRect r = t->rect();
604 // if ( t->id != currentTab() ) 604 // if ( t->id != currentTab() )
605 //r.moveBy( 1, 1 ); 605 //r.moveBy( 1, 1 );
606 // 606 //
607 if ( t->iconSet() ) { 607 if ( t->iconSet() ) {
608 // the tab has an iconset, draw it in the right mode 608 // the tab has an iconset, draw it in the right mode
609 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 609 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
610 if ( mode == QIconSet::Normal && has_focus ) 610 if ( mode == QIconSet::Normal && has_focus )
611 mode = QIconSet::Active; 611 mode = QIconSet::Active;
612 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 612 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
613 int pixw = pixmap.width(); 613 int pixw = pixmap.width();
614 int pixh = pixmap.height(); 614 int pixh = pixmap.height();
615 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 );
616 r.setLeft( r.left() + pixw + 5 ); 616 r.setLeft( r.left() + pixw + 5 );
617 } 617 }
618 618
619 QRect tr = r; 619 QRect tr = r;
620 620
621 if ( r.width() < 20 ) 621 if ( r.width() < 20 )
622 return; 622 return;
623 623
624 if ( t->isEnabled() && isEnabled() ) { 624 if ( t->isEnabled() && isEnabled() ) {
625#if defined(_WS_WIN32_) 625#if defined(_WS_WIN32_)
626 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 626 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
627 p->setPen( colorGroup().buttonText() ); 627 p->setPen( colorGroup().buttonText() );
628 else 628 else
629 p->setPen( colorGroup().foreground() ); 629 p->setPen( colorGroup().foreground() );
630#else 630#else
631 p->setPen( colorGroup().foreground() ); 631 p->setPen( colorGroup().foreground() );
632#endif 632#endif
633 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 633 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
634 } else { 634 } else {
635 p->setPen( palette().disabled().foreground() ); 635 p->setPen( palette().disabled().foreground() );
636 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 636 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
637 } 637 }
638} 638}
639 639
640//--------------------------------------------------------------------------- 640//---------------------------------------------------------------------------
641 641
642Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 642Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
643 : QMainWindow( parent, name, fl ) 643 : QMainWindow( parent, name, fl )
644{ 644{
645 setCaption( tr("Launcher") ); 645 setCaption( tr("Launcher") );
646 646
647 syncDialog = 0; 647 syncDialog = 0;
648 648
649 // we have a pretty good idea how big we'll be 649 // we have a pretty good idea how big we'll be
650 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 650 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
651 651
652 tabs = 0; 652 tabs = 0;
653 rootFolder = 0; 653 rootFolder = 0;
654 docsFolder = 0; 654 docsFolder = 0;
655 655
656 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
657 //uidgen.store( stamp ); 657 //uidgen.store( stamp );
658 m_timeStamp = QString::number( stamp ); 658 m_timeStamp = QString::number( stamp );
659 659
660 tabs = new CategoryTabWidget( this ); 660 tabs = new CategoryTabWidget( this );
661 setCentralWidget( tabs ); 661 setCentralWidget( tabs );
662 662
663 connect( tabs, SIGNAL(selected(const QString&)), 663 connect( tabs, SIGNAL(selected(const QString&)),
664 this, SLOT(viewSelected(const QString&)) ); 664 this, SLOT(viewSelected(const QString&)) );
665 connect( tabs, SIGNAL(clicked(const AppLnk*)), 665 connect( tabs, SIGNAL(clicked(const AppLnk*)),
666 this, SLOT(select(const AppLnk*))); 666 this, SLOT(select(const AppLnk*)));
667 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 667 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
668 this, SLOT(properties(AppLnk*))); 668 this, SLOT(properties(AppLnk*)));
669 669
670 670
671#if !defined(QT_NO_COP) 671#if !defined(QT_NO_COP)
672 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 672 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
673 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 673 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
674 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 674 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
675 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 675 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
676 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 676 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
677 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); 677 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) );
678#endif 678#endif
679 679
680 storage = new StorageInfo( this ); 680 storage = new StorageInfo( this );
681 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 681 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
682 682
683 updateTabs(); 683 updateTabs();
684 684
685 preloadApps(); 685 preloadApps();
686 686
687 in_lnk_props = FALSE; 687 in_lnk_props = FALSE;
688 got_lnk_change = FALSE; 688 got_lnk_change = FALSE;
689} 689}
690 690
691Launcher::~Launcher() 691Launcher::~Launcher()
692{ 692{
693 delete rootFolder; 693 delete rootFolder;
694 delete docsFolder; 694 delete docsFolder;
695} 695}
696 696
697static bool isVisibleWindow(int wid) 697static bool isVisibleWindow(int wid)
698{ 698{
699#ifdef QWS 699#ifdef QWS
700 const QList<QWSWindow> &list = qwsServer->clientWindows(); 700 const QList<QWSWindow> &list = qwsServer->clientWindows();
701 QWSWindow* w; 701 QWSWindow* w;
702 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 702 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
703 if ( w->winId() == wid ) 703 if ( w->winId() == wid )
704 return !w->isFullyObscured(); 704 return !w->isFullyObscured();
705 } 705 }
706#endif 706#endif
707 return FALSE; 707 return FALSE;
708} 708}
709 709
710void Launcher::showMaximized() 710void Launcher::showMaximized()
711{ 711{
712 if ( isVisibleWindow( winId() ) ) 712 if ( isVisibleWindow( winId() ) )
713 doMaximize(); 713 doMaximize();
714 else 714 else
715 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 715 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
716} 716}
717 717
718void Launcher::doMaximize() 718void Launcher::doMaximize()
719{ 719{
720 QMainWindow::showMaximized(); 720 QMainWindow::showMaximized();
721 tabs->setMaximumWidth( qApp->desktop()->width() ); 721 tabs->setMaximumWidth( qApp->desktop()->width() );
722} 722}
723 723
724void Launcher::updateMimeTypes() 724void Launcher::updateMimeTypes()
725{ 725{
726 MimeType::clear(); 726 MimeType::clear();
727 updateMimeTypes(rootFolder); 727 updateMimeTypes(rootFolder);
728} 728}
729 729
730void Launcher::updateMimeTypes(AppLnkSet* folder) 730void Launcher::updateMimeTypes(AppLnkSet* folder)
731{ 731{
732 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 732 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
733 AppLnk *app = it.current(); 733 AppLnk *app = it.current();
734 if ( app->type() == "Folder" ) // No tr 734 if ( app->type() == "Folder" ) // No tr
735 updateMimeTypes((AppLnkSet *)app); 735 updateMimeTypes((AppLnkSet *)app);
736 else { 736 else {
737 MimeType::registerApp(*app); 737 MimeType::registerApp(*app);
738 } 738 }
739 } 739 }
740} 740}
741 741
742/** This is a HACK.... 742/** This is a HACK....
743 * Reason: scanning huge mediums, microdirvers for examples 743 * Reason: scanning huge mediums, microdirvers for examples
744 * consomes time. To avoid that we invented the MediumMountCheck 744 * consomes time. To avoid that we invented the MediumMountCheck
745 * 745 *
746 * a) the user globally disabled medium checking. We can ignore 746 * a) the user globally disabled medium checking. We can ignore
747 * all removable medium 747 * all removable medium
748 * 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
749 * c) the user enabled medium checking on a per medium bases 749 * c) the user enabled medium checking on a per medium bases
750 * c1) we already checked and its not ask again turns 750 * c1) we already checked and its not ask again turns
751 * c2) we need to ask and then apply the mimefilter 751 * c2) we need to ask and then apply the mimefilter
752 */ 752 */
753void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 753void Launcher::loadDocs() // ok here comes a hack belonging to Global::
754{ 754{
755 OWait *owait = new OWait(); 755 OWait *owait = new OWait();
756 Global::statusMessage( tr( "Finding documents" ) ); 756 Global::statusMessage( tr( "Finding documents" ) );
757 757
758 owait->show(); 758 owait->show();
759 qApp->processEvents(); 759 qApp->processEvents();
760 if(docsFolder) delete docsFolder; 760 if(docsFolder) delete docsFolder;
761 docsFolder = new DocLnkSet; 761 docsFolder = new DocLnkSet;
762 DocLnkSet *tmp = 0; 762 DocLnkSet *tmp = 0;
763 QString home = QString(getenv("HOME")) + "/Documents"; 763 QString home = QString(getenv("HOME")) + "/Documents";
764 tmp = new DocLnkSet( home , QString::null); 764 tmp = new DocLnkSet( home , QString::null);
765 docsFolder->appendFrom( *tmp ); 765 docsFolder->appendFrom( *tmp );
766 delete tmp; 766 delete tmp;
767 767
768 // RAM documents 768 // RAM documents
769 StorageInfo storage; 769 StorageInfo storage;
770 const QList<FileSystem> &fileSystems = storage.fileSystems(); 770 const QList<FileSystem> &fileSystems = storage.fileSystems();
771 QListIterator<FileSystem> it ( fileSystems ); 771 QListIterator<FileSystem> it ( fileSystems );
772 772
773 for ( ; it.current(); ++it ) { 773 for ( ; it.current(); ++it ) {
774 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { 774 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
775 tmp = new DocLnkSet( (*it)->path(), QString::null ); 775 tmp = new DocLnkSet( (*it)->path(), QString::null );
776 docsFolder->appendFrom( *tmp ); 776 docsFolder->appendFrom( *tmp );
777 delete tmp; 777 delete tmp;
778 } 778 }
779 } 779 }
780 780
781 Config mediumCfg( "medium"); 781 Config mediumCfg( "medium");
782 mediumCfg.setGroup("main"); 782 mediumCfg.setGroup("main");
783 // a) -zecke we don't want to check 783 // a) -zecke we don't want to check
784 if(!mediumCfg.readBoolEntry("use", true ) ) { 784 if(!mediumCfg.readBoolEntry("use", true ) ) {
785 owait->hide(); 785 owait->hide();
786 delete owait; 786 delete owait;
787 return; 787 return;
788 } 788 }
789 // find out wich filesystems are new in this round 789 // find out wich filesystems are new in this round
790 // We will do this by having a timestamp inside each mountpoint 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 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 792 // come up with our MediumMountGui :) let the hacking begin
793 int stamp = uidgen.generate(); 793 int stamp = uidgen.generate();
794 794
795 QString newStamp = QString::number( stamp ); // generates newtime Stamp 795 QString newStamp = QString::number( stamp ); // generates newtime Stamp
796 796
797 // b) 797 // b)
798 if( mediumCfg.readBoolEntry("global", true ) ){ 798 if( mediumCfg.readBoolEntry("global", true ) ){
799 QString mime = configToMime(&mediumCfg).join(";"); 799 QString mime = configToMime(&mediumCfg).join(";");
800 for( it.toFirst(); it.current(); ++it ){ 800 for( it.toFirst(); it.current(); ++it ){
801 if( (*it)->isRemovable() ){ 801 if( (*it)->isRemovable() ){
802 tmp = new DocLnkSet( (*it)->path(), mime ); 802 tmp = new DocLnkSet( (*it)->path(), mime );
803 docsFolder->appendFrom( *tmp ); 803 docsFolder->appendFrom( *tmp );
804 delete tmp; 804 delete tmp;
805 } 805 }
806 } // done 806 } // done
807 owait->hide(); 807 owait->hide();
808 delete owait; 808 delete owait;
809 return; // save the else 809 return; // save the else
810 } 810 }
811 // c) zecke 811 // c) zecke
812 for ( it.toFirst(); it.current(); ++it ) { 812 for ( it.toFirst(); it.current(); ++it ) {
813 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
814 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); 814 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File);
815 cfg.setGroup("main"); 815 cfg.setGroup("main");
816 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 816 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
817 /** This medium is uptodate 817 /** This medium is uptodate
818 */ 818 */
819 if( stamp == m_timeStamp ){ // ok we know this card 819 if( stamp == m_timeStamp ){ // ok we know this card
820 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 820 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
821 // 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
822 // read the mimetypes from the config and search for documents 822 // read the mimetypes from the config and search for documents
823 QStringList mimetypes = configToMime( &cfg); 823 QStringList mimetypes = configToMime( &cfg);
824 //qApp->processEvents(); 824 //qApp->processEvents();
825 Global::statusMessage( tr( "Searching documents" ) ); 825 Global::statusMessage( tr( "Searching documents" ) );
826 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 826 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
827 docsFolder->appendFrom( *tmp ); 827 docsFolder->appendFrom( *tmp );
828 delete tmp; 828 delete tmp;
829 829
830 } else { // come up with the gui cause this a new card 830 } else { // come up with the gui cause this a new card
831 MediumMountGui medium(&cfg, (*it)->path() ); 831 MediumMountGui medium(&cfg, (*it)->path() );
832 if( medium.check() ){ // we did not ask before or ask again is off 832 if( medium.check() ){ // we did not ask before or ask again is off
833 /** c2) */ 833 /** c2) */
834 if( medium.exec() ){ // he clicked yes so search it 834 if( medium.exec() ){ // he clicked yes so search it
835 // speicher 835 // speicher
836 //cfg.read(); // cause of a race we need to reread - fixed 836 //cfg.read(); // cause of a race we need to reread - fixed
837 cfg.setGroup("main"); 837 cfg.setGroup("main");
838 cfg.writeEntry("timestamp", newStamp ); 838 cfg.writeEntry("timestamp", newStamp );
839 cfg.write(); 839 cfg.write();
840 840
841 //qApp->processEvents(); 841 //qApp->processEvents();
842 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); 842 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
843 docsFolder->appendFrom( *tmp ); 843 docsFolder->appendFrom( *tmp );
844 delete tmp; 844 delete tmp;
845 }// no else 845 }// no else
846 /** c1) */ 846 /** c1) */
847 } else { // we checked 847 } else { // we checked
848 // do something different see what we need to do 848 // do something different see what we need to do
849 // let's see if we should check the device 849 // let's see if we should check the device
850 cfg.setGroup("main" ); 850 cfg.setGroup("main" );
851 bool check = cfg.readBoolEntry("autocheck", true ); 851 bool check = cfg.readBoolEntry("autocheck", true );
852 if( check ){ // find the documents 852 if( check ){ // find the documents
853 853
854 //qApp->processEvents(); 854 //qApp->processEvents();
855 Global::statusMessage( tr( "Searching documents" ) ); 855 Global::statusMessage( tr( "Searching documents" ) );
856 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); 856 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
857 docsFolder->appendFrom( *tmp ); 857 docsFolder->appendFrom( *tmp );
858 delete tmp; 858 delete tmp;
859 } 859 }
860 } 860 }
861 } 861 }
862 } 862 }
863 } 863 }
864 m_timeStamp = newStamp; 864 m_timeStamp = newStamp;
865 owait->hide(); 865 owait->hide();
866 delete owait; 866 delete owait;
867} 867}
868 868
869void Launcher::updateTabs() 869void Launcher::updateTabs()
870{ 870{
871 MimeType::updateApplications(); // ### reads all applnks twice 871 MimeType::updateApplications(); // ### reads all applnks twice
872 delete rootFolder; 872 delete rootFolder;
873 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 873 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
874 874
875 loadDocs(); 875 loadDocs();
876 876
877 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 877 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
878} 878}
879 879
880void Launcher::updateDocs() 880void Launcher::updateDocs()
881{ 881{
882 loadDocs(); 882 loadDocs();
883 // tabs->updateDocs(docsFolder,storage->fileSystems()); 883 // tabs->updateDocs(docsFolder,storage->fileSystems());
884} 884}
885 885
886void Launcher::viewSelected(const QString& s) 886void Launcher::viewSelected(const QString& s)
887{ 887{
888 setCaption( s + tr(" - Launcher") ); 888 setCaption( s + tr(" - Launcher") );
889} 889}
890 890
891void Launcher::nextView() 891void Launcher::nextView()
892{ 892{
893 tabs->nextTab(); 893 tabs->nextTab();
894} 894}
895 895
896void Launcher::showTab(const QString& id) 896void Launcher::showTab(const QString& id)
897{ 897{
898 tabs->showTab(id); 898 tabs->showTab(id);
899 raise(); 899 raise();
900} 900}
901 901
902void Launcher::select( const AppLnk *appLnk ) 902void Launcher::select( const AppLnk *appLnk )
903{ 903{
904 if ( appLnk->type() == "Folder" ) { // No tr 904 if ( appLnk->type() == "Folder" ) { // No tr
905 // Not supported: flat is simpler for the user 905 // Not supported: flat is simpler for the user
906 } else { 906 } else {
907 if ( appLnk->exec().isNull() ) { 907 if ( appLnk->exec().isNull() ) {
908 QMessageBox::information(this,tr("No application"), 908 QMessageBox::information(this,tr("No application"),
909 tr("<p>No application is defined for this document." 909 tr("<p>No application is defined for this document."
910 "<p>Type is %1.").arg(appLnk->type())); 910 "<p>Type is %1.").arg(appLnk->type()));
911 return; 911 return;
912 } 912 }
913 tabs->setBusy(TRUE); 913 tabs->setBusy(TRUE);
914 emit executing( appLnk ); 914 emit executing( appLnk );
915 appLnk->execute(); 915 appLnk->execute();
916 } 916 }
917} 917}
918 918
919void Launcher::externalSelected(const AppLnk *appLnk) 919void Launcher::externalSelected(const AppLnk *appLnk)
920{ 920{
921 tabs->setBusy(TRUE); 921 tabs->setBusy(TRUE);
922 emit executing( appLnk ); 922 emit executing( appLnk );
923} 923}
924 924
925void Launcher::properties( AppLnk *appLnk ) 925void Launcher::properties( AppLnk *appLnk )
926{ 926{
927 if ( appLnk->type() == "Folder" ) { // No tr 927 if ( appLnk->type() == "Folder" ) { // No tr
928 // Not supported: flat is simpler for the user 928 // Not supported: flat is simpler for the user
929 } else { 929 } else {
930 in_lnk_props = TRUE; 930 in_lnk_props = TRUE;
931 got_lnk_change = FALSE; 931 got_lnk_change = FALSE;
932 LnkProperties prop(appLnk); 932 LnkProperties prop(appLnk);
933 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 933 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
934 prop.showMaximized(); 934 prop.showMaximized();
935 prop.exec(); 935 prop.exec();
936 in_lnk_props = FALSE; 936 in_lnk_props = FALSE;
937 if ( got_lnk_change ) { 937 if ( got_lnk_change ) {
938 updateLink(lnk_change); 938 updateLink(lnk_change);
939 } 939 }
940 } 940 }
941} 941}
942 942
943void Launcher::updateLink(const QString& link) 943void Launcher::updateLink(const QString& link)
944{ 944{
945 bool notify_sm = false; 945 bool notify_sm = false;
946 946
947 if (link.isNull()) { 947 if (link.isNull()) {
948 updateTabs(); 948 updateTabs();
949 notify_sm = true; 949 notify_sm = true;
950 } 950 }
951 else if (link.isEmpty()) { 951 else if (link.isEmpty()) {