summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp53
1 files changed, 42 insertions, 11 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index f9c6c02..1a52f69 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,844 +1,875 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (c) 2002 Holger zecke Freyther 2** Copyright (c) 2002 Holger zecke Freyther
3** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 4**
5** This file is part of Qtopia Environment. 5** This file is part of Qtopia Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT 22// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
23// have this class. 23// have this class.
24#define QTOPIA_INTERNAL_FSLP 24#define QTOPIA_INTERNAL_FSLP
25 25
26#include <opie/oconfig.h> 26#include <opie/oconfig.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 <qdatetime.h> 37#include <qdatetime.h>
38#include <qdir.h> 38#include <qdir.h>
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#include <qtimer.h> 40#include <qtimer.h>
41#include <qcombobox.h> 41#include <qcombobox.h>
42#include <qvbox.h> 42#include <qvbox.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qstyle.h> 44#include <qstyle.h>
45#include <qpushbutton.h> 45#include <qpushbutton.h>
46#include <qtabbar.h> 46#include <qtabbar.h>
47#include <qwidgetstack.h> 47#include <qwidgetstack.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qregexp.h> 49#include <qregexp.h>
50#include <qmessagebox.h> 50#include <qmessagebox.h>
51#include <qframe.h> 51#include <qframe.h>
52#include <qpainter.h> 52#include <qpainter.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qtextstream.h> 54#include <qtextstream.h>
55 55
56#include "launcherview.h" 56#include "launcherview.h"
57#include "launcher.h" 57#include "launcher.h"
58#include "syncdialog.h" 58#include "syncdialog.h"
59#include "desktop.h" 59#include "desktop.h"
60#include <qpe/lnkproperties.h> 60#include <qpe/lnkproperties.h>
61#include "mrulist.h" 61#include "mrulist.h"
62#include "qrsync.h" 62#include "qrsync.h"
63#include <stdlib.h> 63#include <stdlib.h>
64#include <unistd.h> 64#include <unistd.h>
65 65
66#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 66#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
67#include <stdio.h> 67#include <stdio.h>
68#include <sys/vfs.h> 68#include <sys/vfs.h>
69#include <mntent.h> 69#include <mntent.h>
70#endif 70#endif
71 71
72#include <qpe/storage.h> 72#include <qpe/storage.h>
73#include "mediummountgui.h" 73#include "mediummountgui.h"
74//#define SHOW_ALL 74//#define SHOW_ALL
75 75
76// uidGen 76// uidGen
77 77
78// uidGen 78// uidGen
79namespace { 79namespace {
80 QStringList configToMime( Config *cfg ){ 80 QStringList configToMime( Config *cfg ){
81 QStringList mimes; 81 QStringList mimes;
82 bool tmpMime; 82 bool tmpMime = true;
83 cfg->setGroup("mimetypes" ); 83 cfg->setGroup("mimetypes" );
84 tmpMime = cfg->readBoolEntry("all" ,false); 84 tmpMime = cfg->readBoolEntry("all" ,true);
85 if( tmpMime ){ 85 if( tmpMime ){
86 mimes << QString::null; 86 mimes << QString::null;
87 return mimes; 87 return mimes;
88 }else{ 88 }else{
89 tmpMime = cfg->readBoolEntry("audio", true ); 89 tmpMime = cfg->readBoolEntry("audio", true );
90 if(tmpMime ) 90 if(tmpMime )
91 mimes.append("audio/*" ); 91 mimes.append("audio/*" );
92 92
93 tmpMime = cfg->readBoolEntry("image", true ); 93 tmpMime = cfg->readBoolEntry("image", true );
94 if(tmpMime ) 94 if(tmpMime )
95 mimes.append("image/*" ); 95 mimes.append("image/*" );
96 96
97 tmpMime = cfg->readBoolEntry("text", true ); 97 tmpMime = cfg->readBoolEntry("text", true );
98 if(tmpMime ) 98 if(tmpMime )
99 mimes.append("text/*"); 99 mimes.append("text/*");
100 100
101 tmpMime = cfg->readBoolEntry("video", true ); 101 tmpMime = cfg->readBoolEntry("video", true );
102 if(tmpMime ) 102 if(tmpMime )
103 mimes.append("video/*" ); 103 mimes.append("video/*" );
104 } 104 }
105 return mimes; 105 return mimes;
106 } 106 }
107 107
108} 108}
109 109
110 110
111CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 111CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
112 QVBox( parent ) 112 QVBox( parent )
113{ 113{
114 categoryBar = 0; 114 categoryBar = 0;
115 stack = 0; 115 stack = 0;
116} 116}
117 117
118void CategoryTabWidget::prevTab() 118void CategoryTabWidget::prevTab()
119{ 119{
120 if ( categoryBar ) { 120 if ( categoryBar ) {
121 int n = categoryBar->count(); 121 int n = categoryBar->count();
122 int tab = categoryBar->currentTab(); 122 int tab = categoryBar->currentTab();
123 if ( tab >= 0 ) 123 if ( tab >= 0 )
124 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 124 categoryBar->setCurrentTab( (tab - 1 + n)%n );
125 } 125 }
126} 126}
127 127
128void CategoryTabWidget::nextTab() 128void CategoryTabWidget::nextTab()
129{ 129{
130 if ( categoryBar ) { 130 if ( categoryBar ) {
131 int n = categoryBar->count(); 131 int n = categoryBar->count();
132 int tab = categoryBar->currentTab(); 132 int tab = categoryBar->currentTab();
133 categoryBar->setCurrentTab( (tab + 1)%n ); 133 categoryBar->setCurrentTab( (tab + 1)%n );
134 } 134 }
135} 135}
136 136
137void CategoryTabWidget::addItem( const QString& linkfile ) 137void CategoryTabWidget::addItem( const QString& linkfile )
138{ 138{
139 int i=0; 139 int i=0;
140 AppLnk *app = new AppLnk(linkfile); 140 AppLnk *app = new AppLnk(linkfile);
141 if ( !app->isValid() ) { 141 if ( !app->isValid() ) {
142 delete app; 142 delete app;
143 return; 143 return;
144 } 144 }
145 if ( !app->file().isEmpty() ) { 145 if ( !app->file().isEmpty() ) {
146 // A document 146 // A document
147 delete app; 147 delete app;
148 app = new DocLnk(linkfile); 148 app = new DocLnk(linkfile);
149 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 149 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
150 return; 150 return;
151 } 151 }
152 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 152 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
153 if ( !(*it).isEmpty() ) { 153 if ( !(*it).isEmpty() ) {
154 QRegExp tf(*it,FALSE,TRUE); 154 QRegExp tf(*it,FALSE,TRUE);
155 if ( tf.match(app->type()) >= 0 ) { 155 if ( tf.match(app->type()) >= 0 ) {
156 ((LauncherView*)stack->widget(i))->addItem(app); 156 ((LauncherView*)stack->widget(i))->addItem(app);
157 return; 157 return;
158 } 158 }
159 i++; 159 i++;
160 } 160 }
161 } 161 }
162} 162}
163 163
164void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, 164void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
165 AppLnkSet* docFolder, const QList<FileSystem> &fs) 165 AppLnkSet* docFolder, const QList<FileSystem> &fs)
166{ 166{
167 delete categoryBar; 167 delete categoryBar;
168 categoryBar = new CategoryTabBar( this ); 168 categoryBar = new CategoryTabBar( this );
169 QPalette pal = categoryBar->palette(); 169 QPalette pal = categoryBar->palette();
170 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 170 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
171 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 171 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
172 categoryBar->setPalette( pal ); 172 categoryBar->setPalette( pal );
173 173
174 delete stack; 174 delete stack;
175 stack = new QWidgetStack(this); 175 stack = new QWidgetStack(this);
176 tabs=0; 176 tabs=0;
177 177
178 ids.clear(); 178 ids.clear();
179 179
180 QStringList types = rootFolder->types(); 180 QStringList types = rootFolder->types();
181 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 181 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
182 if ( !(*it).isEmpty() ) { 182 if ( !(*it).isEmpty() ) {
183 newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); 183 newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it));
184 } 184 }
185 } 185 }
186 QListIterator<AppLnk> it( rootFolder->children() ); 186 QListIterator<AppLnk> it( rootFolder->children() );
187 AppLnk* l; 187 AppLnk* l;
188 while ( (l=it.current()) ) { 188 while ( (l=it.current()) ) {
189 if ( l->type() == "Separator" ) { 189 if ( l->type() == "Separator" ) {
190 rootFolder->remove(l); 190 rootFolder->remove(l);
191 delete l; 191 delete l;
192 } else { 192 } else {
193 int i=0; 193 int i=0;
194 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 194 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
195 if ( *it == l->type() ) 195 if ( *it == l->type() )
196 ((LauncherView*)stack->widget(i))->addItem(l,FALSE); 196 ((LauncherView*)stack->widget(i))->addItem(l,FALSE);
197 i++; 197 i++;
198 } 198 }
199 } 199 }
200 ++it; 200 ++it;
201 } 201 }
202 rootFolder->detachChildren(); 202 rootFolder->detachChildren();
203 for (int i=0; i<tabs; i++) 203 for (int i=0; i<tabs; i++)
204 ((LauncherView*)stack->widget(i))->sort(); 204 ((LauncherView*)stack->widget(i))->sort();
205 205
206 // all documents 206 // all documents
207 docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); 207 docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents"));
208 docview->populate( docFolder, QString::null ); 208 docview->populate( docFolder, QString::null );
209 docFolder->detachChildren(); 209 docFolder->detachChildren();
210 docview->setFileSystems(fs); 210 docview->setFileSystems(fs);
211 docview->setToolsEnabled(TRUE); 211 docview->setToolsEnabled(TRUE);
212 212
213 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); 213 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) );
214 214
215 ((LauncherView*)stack->widget(0))->setFocus(); 215 ((LauncherView*)stack->widget(0))->setFocus();
216 216
217 categoryBar->show(); 217 categoryBar->show();
218 stack->show(); 218 stack->show();
219} 219}
220 220
221void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) 221void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs)
222{ 222{
223 docview->populate( docFolder, QString::null ); 223 docview->populate( docFolder, QString::null );
224 docFolder->detachChildren(); 224 docFolder->detachChildren();
225 docview->setFileSystems(fs); 225 docview->setFileSystems(fs);
226 docview->updateTools(); 226 docview->updateTools();
227} 227}
228 228
229LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 229LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
230{ 230{
231 LauncherView* view = new LauncherView( stack ); 231 LauncherView* view = new LauncherView( stack );
232 connect( view, SIGNAL(clicked(const AppLnk*)), 232 connect( view, SIGNAL(clicked(const AppLnk*)),
233 this, SIGNAL(clicked(const AppLnk*))); 233 this, SIGNAL(clicked(const AppLnk*)));
234 connect( view, SIGNAL(rightPressed(AppLnk*)), 234 connect( view, SIGNAL(rightPressed(AppLnk*)),
235 this, SIGNAL(rightPressed(AppLnk*))); 235 this, SIGNAL(rightPressed(AppLnk*)));
236 ids.append(id); 236 ids.append(id);
237 categoryBar->addTab( new QTab( pm, label ) ); 237 categoryBar->addTab( new QTab( pm, label ) );
238 stack->addWidget( view, tabs++ ); 238 stack->addWidget( view, tabs++ );
239 return view; 239 return view;
240} 240}
241 241
242void CategoryTabWidget::updateLink(const QString& linkfile) 242void CategoryTabWidget::updateLink(const QString& linkfile)
243{ 243{
244 int i=0; 244 int i=0;
245 LauncherView* view; 245 LauncherView* view;
246 while ((view = (LauncherView*)stack->widget(i++))) { 246 while ((view = (LauncherView*)stack->widget(i++))) {
247 if ( view->removeLink(linkfile) ) 247 if ( view->removeLink(linkfile) )
248 break; 248 break;
249 } 249 }
250 addItem(linkfile); 250 addItem(linkfile);
251 docview->updateTools(); 251 docview->updateTools();
252} 252}
253 253
254void CategoryTabWidget::paletteChange( const QPalette &p ) 254void CategoryTabWidget::paletteChange( const QPalette &p )
255{ 255{
256 QVBox::paletteChange( p ); 256 QVBox::paletteChange( p );
257 QPalette pal = palette(); 257 QPalette pal = palette();
258 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 258 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
259 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 259 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
260 categoryBar->setPalette( pal ); 260 categoryBar->setPalette( pal );
261 categoryBar->update(); 261 categoryBar->update();
262} 262}
263 263
264void CategoryTabWidget::setBusy(bool on) 264void CategoryTabWidget::setBusy(bool on)
265{ 265{
266 if ( on ) 266 if ( on )
267 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); 267 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE);
268 else 268 else
269 for (int i=0; i<tabs; i++) 269 for (int i=0; i<tabs; i++)
270 ((LauncherView*)stack->widget(i))->setBusy(FALSE); 270 ((LauncherView*)stack->widget(i))->setBusy(FALSE);
271} 271}
272 272
273 273
274CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) 274CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name )
275 : QTabBar( parent, name ) 275 : QTabBar( parent, name )
276{ 276{
277 setFocusPolicy( NoFocus ); 277 setFocusPolicy( NoFocus );
278 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); 278 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) );
279} 279}
280 280
281CategoryTabBar::~CategoryTabBar() 281CategoryTabBar::~CategoryTabBar()
282{ 282{
283} 283}
284 284
285void CategoryTabBar::layoutTabs() 285void CategoryTabBar::layoutTabs()
286{ 286{
287 if ( !count() ) 287 if ( !count() )
288 return; 288 return;
289 289
290// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; 290// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 };
291 int hiddenTabWidth = -12; 291 int hiddenTabWidth = -12;
292 int middleTab = currentTab(); 292 int middleTab = currentTab();
293 int hframe, vframe, overlap; 293 int hframe, vframe, overlap;
294 style().tabbarMetrics( this, hframe, vframe, overlap ); 294 style().tabbarMetrics( this, hframe, vframe, overlap );
295 QFontMetrics fm = fontMetrics(); 295 QFontMetrics fm = fontMetrics();
296 int x = 0; 296 int x = 0;
297 QRect r; 297 QRect r;
298 QTab *t; 298 QTab *t;
299 int available = width()-1; 299 int available = width()-1;
300 int required = 0; 300 int required = 0;
301 for ( int i = 0; i < count(); i++ ) { 301 for ( int i = 0; i < count(); i++ ) {
302 t = tab(i); 302 t = tab(i);
303 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { 303 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) {
304 if ( i != middleTab ) { 304 if ( i != middleTab ) {
305 // required += hiddenTabWidth + hframe - overlap; 305 // required += hiddenTabWidth + hframe - overlap;
306 available -= hiddenTabWidth + hframe - overlap; 306 available -= hiddenTabWidth + hframe - overlap;
307 if ( t->iconSet() != 0 ) 307 if ( t->iconSet() != 0 )
308 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 308 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
309 } else { 309 } else {
310 required += fm.width( t->text() ) + hframe - overlap; 310 required += fm.width( t->text() ) + hframe - overlap;
311 if ( t->iconSet() != 0 ) 311 if ( t->iconSet() != 0 )
312 required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 312 required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
313 } 313 }
314 } 314 }
315 for ( int i = 0; i < count(); i++ ) { 315 for ( int i = 0; i < count(); i++ ) {
316 t = tab(i); 316 t = tab(i);
317 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { 317 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) {
318 if ( i != middleTab ) { 318 if ( i != middleTab ) {
319 int w = hiddenTabWidth; 319 int w = hiddenTabWidth;
320 int ih = 0; 320 int ih = 0;
321 if ( t->iconSet() != 0 ) { 321 if ( t->iconSet() != 0 ) {
322 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 322 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
323 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 323 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
324 } 324 }
325 int h = QMAX( fm.height(), ih ); 325 int h = QMAX( fm.height(), ih );
326 h = QMAX( h, QApplication::globalStrut().height() ); 326 h = QMAX( h, QApplication::globalStrut().height() );
327 327
328 h += vframe; 328 h += vframe;
329 w += hframe; 329 w += hframe;
330 330
331 t->setRect( QRect(x, 0, w, h) ); 331 t->setRect( QRect(x, 0, w, h) );
332 x += t->rect().width() - overlap; 332 x += t->rect().width() - overlap;
333 r = r.unite( t->rect() ); 333 r = r.unite( t->rect() );
334 } else { 334 } else {
335 int w = fm.width( t->text() ); 335 int w = fm.width( t->text() );
336 int ih = 0; 336 int ih = 0;
337 if ( t->iconSet() != 0 ) { 337 if ( t->iconSet() != 0 ) {
338 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 338 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
339 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 339 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
340 } 340 }
341 int h = QMAX( fm.height(), ih ); 341 int h = QMAX( fm.height(), ih );
342 h = QMAX( h, QApplication::globalStrut().height() ); 342 h = QMAX( h, QApplication::globalStrut().height() );
343 343
344 h += vframe; 344 h += vframe;
345 w += hframe; 345 w += hframe;
346 346
347 // t->setRect( QRect(x, 0, w * available/required, h) ); 347 // t->setRect( QRect(x, 0, w * available/required, h) );
348 t->setRect( QRect(x, 0, available, h) ); 348 t->setRect( QRect(x, 0, available, h) );
349 x += t->rect().width() - overlap; 349 x += t->rect().width() - overlap;
350 r = r.unite( t->rect() ); 350 r = r.unite( t->rect() );
351 } 351 }
352 } 352 }
353 353
354 QRect rr = tab(count()-1)->rect(); 354 QRect rr = tab(count()-1)->rect();
355 rr.setRight(width()-1); 355 rr.setRight(width()-1);
356 tab(count()-1)->setRect( rr ); 356 tab(count()-1)->setRect( rr );
357 357
358 for ( t = tabList()->first(); t; t = tabList()->next() ) { 358 for ( t = tabList()->first(); t; t = tabList()->next() ) {
359 QRect tr = t->rect(); 359 QRect tr = t->rect();
360 tr.setHeight( r.height() ); 360 tr.setHeight( r.height() );
361 t->setRect( tr ); 361 t->setRect( tr );
362 } 362 }
363 363
364 update(); 364 update();
365} 365}
366 366
367 367
368void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const 368void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
369{ 369{
370#if QT_VERSION >= 300 370#if QT_VERSION >= 300
371 QStyle::SFlags flags = QStyle::Style_Default; 371 QStyle::SFlags flags = QStyle::Style_Default;
372 if ( selected ) 372 if ( selected )
373 flags |= QStyle::Style_Selected; 373 flags |= QStyle::Style_Selected;
374 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 374 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
375 colorGroup(), flags, QStyleOption(t) ); 375 colorGroup(), flags, QStyleOption(t) );
376#else 376#else
377 style().drawTab( p, this, t, selected ); 377 style().drawTab( p, this, t, selected );
378#endif 378#endif
379 379
380 QRect r( t->rect() ); 380 QRect r( t->rect() );
381 QFont f( font() ); 381 QFont f( font() );
382 if ( selected ) 382 if ( selected )
383 f.setBold( TRUE ); 383 f.setBold( TRUE );
384 p->setFont( f ); 384 p->setFont( f );
385 385
386 int iw = 0; 386 int iw = 0;
387 int ih = 0; 387 int ih = 0;
388 if ( t->iconSet() != 0 ) { 388 if ( t->iconSet() != 0 ) {
389 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 389 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
390 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 390 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
391 } 391 }
392 int w = iw + p->fontMetrics().width( t->text() ) + 4; 392 int w = iw + p->fontMetrics().width( t->text() ) + 4;
393 int h = QMAX(p->fontMetrics().height() + 4, ih ); 393 int h = QMAX(p->fontMetrics().height() + 4, ih );
394 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 394 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
395 r.top() + (r.height()-h)/2, w, h ), t, 395 r.top() + (r.height()-h)/2, w, h ), t,
396#if QT_VERSION >= 300 396#if QT_VERSION >= 300
397 t->identifier() == keyboardFocusTab() 397 t->identifier() == keyboardFocusTab()
398#else 398#else
399 t->identitifer() == keyboardFocusTab() 399 t->identitifer() == keyboardFocusTab()
400#endif 400#endif
401 ); 401 );
402} 402}
403 403
404 404
405void CategoryTabBar::paintLabel( QPainter* p, const QRect&, 405void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
406 QTab* t, bool has_focus ) const 406 QTab* t, bool has_focus ) const
407{ 407{
408 QRect r = t->rect(); 408 QRect r = t->rect();
409 // if ( t->id != currentTab() ) 409 // if ( t->id != currentTab() )
410 //r.moveBy( 1, 1 ); 410 //r.moveBy( 1, 1 );
411 // 411 //
412 if ( t->iconSet() ) { 412 if ( t->iconSet() ) {
413 // the tab has an iconset, draw it in the right mode 413 // the tab has an iconset, draw it in the right mode
414 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 414 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
415 if ( mode == QIconSet::Normal && has_focus ) 415 if ( mode == QIconSet::Normal && has_focus )
416 mode = QIconSet::Active; 416 mode = QIconSet::Active;
417 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 417 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
418 int pixw = pixmap.width(); 418 int pixw = pixmap.width();
419 int pixh = pixmap.height(); 419 int pixh = pixmap.height();
420 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); 420 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
421 r.setLeft( r.left() + pixw + 5 ); 421 r.setLeft( r.left() + pixw + 5 );
422 } 422 }
423 423
424 QRect tr = r; 424 QRect tr = r;
425 425
426 if ( r.width() < 20 ) 426 if ( r.width() < 20 )
427 return; 427 return;
428 428
429 if ( t->isEnabled() && isEnabled() ) { 429 if ( t->isEnabled() && isEnabled() ) {
430#if defined(_WS_WIN32_) 430#if defined(_WS_WIN32_)
431 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 431 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
432 p->setPen( colorGroup().buttonText() ); 432 p->setPen( colorGroup().buttonText() );
433 else 433 else
434 p->setPen( colorGroup().foreground() ); 434 p->setPen( colorGroup().foreground() );
435#else 435#else
436 p->setPen( colorGroup().foreground() ); 436 p->setPen( colorGroup().foreground() );
437#endif 437#endif
438 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 438 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
439 } else { 439 } else {
440 p->setPen( palette().disabled().foreground() ); 440 p->setPen( palette().disabled().foreground() );
441 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 441 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
442 } 442 }
443} 443}
444 444
445//--------------------------------------------------------------------------- 445//---------------------------------------------------------------------------
446 446
447Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 447Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
448 : QMainWindow( parent, name, fl ) 448 : QMainWindow( parent, name, fl )
449{ 449{
450 setCaption( tr("Launcher") ); 450 setCaption( tr("Launcher") );
451 451
452 syncDialog = 0; 452 syncDialog = 0;
453 453
454 // we have a pretty good idea how big we'll be 454 // we have a pretty good idea how big we'll be
455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
456 456
457 tabs = 0; 457 tabs = 0;
458 rootFolder = 0; 458 rootFolder = 0;
459 docsFolder = 0; 459 docsFolder = 0;
460 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know 460 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
461 //uidgen.store( stamp ); 461 //uidgen.store( stamp );
462 m_timeStamp = QString::number( stamp ); 462 m_timeStamp = QString::number( stamp );
463 463
464 tabs = new CategoryTabWidget( this ); 464 tabs = new CategoryTabWidget( this );
465 tabs->setMaximumWidth( qApp->desktop()->width() ); 465 tabs->setMaximumWidth( qApp->desktop()->width() );
466 setCentralWidget( tabs ); 466 setCentralWidget( tabs );
467 467
468 connect( tabs, SIGNAL(selected(const QString&)), 468 connect( tabs, SIGNAL(selected(const QString&)),
469 this, SLOT(viewSelected(const QString&)) ); 469 this, SLOT(viewSelected(const QString&)) );
470 connect( tabs, SIGNAL(clicked(const AppLnk*)), 470 connect( tabs, SIGNAL(clicked(const AppLnk*)),
471 this, SLOT(select(const AppLnk*))); 471 this, SLOT(select(const AppLnk*)));
472 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 472 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
473 this, SLOT(properties(AppLnk*))); 473 this, SLOT(properties(AppLnk*)));
474 474
475#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 475#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
479#endif 479#endif
480 480
481 storage = new StorageInfo( this ); 481 storage = new StorageInfo( this );
482 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 482 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
483 483
484 updateTabs(); 484 updateTabs();
485 485
486 preloadApps(); 486 preloadApps();
487 487
488 in_lnk_props = FALSE; 488 in_lnk_props = FALSE;
489 got_lnk_change = FALSE; 489 got_lnk_change = FALSE;
490} 490}
491 491
492Launcher::~Launcher() 492Launcher::~Launcher()
493{ 493{
494} 494}
495 495
496static bool isVisibleWindow(int wid) 496static bool isVisibleWindow(int wid)
497{ 497{
498 const QList<QWSWindow> &list = qwsServer->clientWindows(); 498 const QList<QWSWindow> &list = qwsServer->clientWindows();
499 QWSWindow* w; 499 QWSWindow* w;
500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
501 if ( w->winId() == wid ) 501 if ( w->winId() == wid )
502 return !w->isFullyObscured(); 502 return !w->isFullyObscured();
503 } 503 }
504 return FALSE; 504 return FALSE;
505} 505}
506 506
507void Launcher::showMaximized() 507void Launcher::showMaximized()
508{ 508{
509 if ( isVisibleWindow( winId() ) ) 509 if ( isVisibleWindow( winId() ) )
510 doMaximize(); 510 doMaximize();
511 else 511 else
512 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 512 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
513} 513}
514 514
515void Launcher::doMaximize() 515void Launcher::doMaximize()
516{ 516{
517 QMainWindow::showMaximized(); 517 QMainWindow::showMaximized();
518} 518}
519 519
520void Launcher::updateMimeTypes() 520void Launcher::updateMimeTypes()
521{ 521{
522 MimeType::clear(); 522 MimeType::clear();
523 updateMimeTypes(rootFolder); 523 updateMimeTypes(rootFolder);
524} 524}
525 525
526void Launcher::updateMimeTypes(AppLnkSet* folder) 526void Launcher::updateMimeTypes(AppLnkSet* folder)
527{ 527{
528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
529 AppLnk *app = it.current(); 529 AppLnk *app = it.current();
530 if ( app->type() == "Folder" ) 530 if ( app->type() == "Folder" )
531 updateMimeTypes((AppLnkSet *)app); 531 updateMimeTypes((AppLnkSet *)app);
532 else { 532 else {
533 MimeType::registerApp(*app); 533 MimeType::registerApp(*app);
534 } 534 }
535 } 535 }
536} 536}
537 537/** This is a HACK....
538 * Reason: scanning huge mediums, microdirvers for examples
539 * consomes time. To avoid that we invented the MediumMountCheck
540 *
541 * a) the user globally disabled medium checking. We can ignore
542 * all removable medium
543 * b) the user enabled medium checking globally and we need to use this mimefilter
544 * c) the user enabled medium checking on a per medium bases
545 * c1) we already checked and its not ask again turns
546 * c2) we need to ask and then apply the mimefilter
547 */
538void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 548void Launcher::loadDocs() // ok here comes a hack belonging to Global::
539{ 549{
540 qWarning("loading Documents" );
541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() );
542 delete docsFolder; 550 delete docsFolder;
543 docsFolder = new DocLnkSet; 551 docsFolder = new DocLnkSet;
544 qWarning("new DocLnkSet" ); 552
545 DocLnkSet *tmp = 0; 553 DocLnkSet *tmp = 0;
546 QString home = QString(getenv("HOME")) + "/Documents"; 554 QString home = QString(getenv("HOME")) + "/Documents";
547 tmp = new DocLnkSet( home , QString::null); 555 tmp = new DocLnkSet( home , QString::null);
548 docsFolder->appendFrom( *tmp ); 556 docsFolder->appendFrom( *tmp );
549 delete tmp; 557 delete tmp;
558
559 Config mediumCfg( "medium");
560 mediumCfg.setGroup("main");
561 // a) -zecke we don't want to check
562 if(!mediumCfg.readBoolEntry("use", true ) )
563 return;
564
550 // find out wich filesystems are new in this round 565 // find out wich filesystems are new in this round
551 // We will do this by having a timestamp inside each mountpoint 566 // We will do this by having a timestamp inside each mountpoint
552 // if the current timestamp doesn't match this is a new file system and 567 // if the current timestamp doesn't match this is a new file system and
553 // come up with our MediumMountGui :) let the hacking begin 568 // come up with our MediumMountGui :) let the hacking begin
554 int stamp = uidgen.generate(); 569 int stamp = uidgen.generate();
555 570
556 QString newStamp = QString::number( stamp ); // generates newtime Stamp 571 QString newStamp = QString::number( stamp ); // generates newtime Stamp
557 StorageInfo storage; 572 StorageInfo storage;
558 const QList<FileSystem> &fileSystems = storage.fileSystems(); 573 const QList<FileSystem> &fileSystems = storage.fileSystems();
559 QListIterator<FileSystem> it ( fileSystems ); 574 QListIterator<FileSystem> it ( fileSystems );
560 575
561 576 // b)
577 if( mediumCfg.readBoolEntry("global", true ) ){
578 QString mime = configToMime(&mediumCfg).join(";");
579 for( ; it.current(); ++it ){
580 if( (*it)->isRemovable() ){
581 tmp = new DocLnkSet( (*it)->path(), mime );
582 docsFolder->appendFrom( *tmp );
583 delete tmp;
584 }
585 } // done
586 return; // save the else
587 }
588 // c) zecke
562 for ( ; it.current(); ++it ) { 589 for ( ; it.current(); ++it ) {
563 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 590 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
564 qWarning("%s is removeable", (*it)->path().latin1() ); 591 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File);
565 OConfig cfg( (*it)->path() + "/.opiestorage.cf");
566 cfg.setGroup("main"); 592 cfg.setGroup("main");
567 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 593 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
594 /** This medium is uptodate
595 */
568 if( stamp == m_timeStamp ){ // ok we know this card 596 if( stamp == m_timeStamp ){ // ok we know this card
569 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 597 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
570 // we need to scan the list now. Hopefully the cache will be there 598 // we need to scan the list now. Hopefully the cache will be there
571 // read the mimetypes from the config and search for documents 599 // read the mimetypes from the config and search for documents
572 QStringList mimetypes = configToMime( &cfg); 600 QStringList mimetypes = configToMime( &cfg);
573 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 601 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
574 docsFolder->appendFrom( *tmp ); 602 docsFolder->appendFrom( *tmp );
575 delete tmp; 603 delete tmp;
576 604
577 }else{ // come up with the gui cause this a new card 605 }else{ // come up with the gui cause this a new card
578 MediumMountGui medium(&cfg, (*it)->path() ); 606 MediumMountGui medium(&cfg, (*it)->path() );
579 if( medium.check() ){ // we did not ask before or ask again is off 607 if( medium.check() ){ // we did not ask before or ask again is off
608 /** c2) */
580 if( medium.exec() ){ // he clicked yes so search it 609 if( medium.exec() ){ // he clicked yes so search it
581 // speicher 610 // speicher
582 //cfg.read(); // cause of a race we need to reread - fixed 611 //cfg.read(); // cause of a race we need to reread - fixed
612 cfg.setGroup("main");
583 cfg.writeEntry("timestamp", newStamp ); 613 cfg.writeEntry("timestamp", newStamp );
584 cfg.write(); 614 cfg.write();
585 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); 615 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
586 docsFolder->appendFrom( *tmp ); 616 docsFolder->appendFrom( *tmp );
587 delete tmp; 617 delete tmp;
588 }// no else 618 }// no else
619 /** c1) */
589 }else{ // we checked 620 }else{ // we checked
590 // do something different see what we need to do 621 // do something different see what we need to do
591 // let's see if we should check the device 622 // let's see if we should check the device
592 cfg.setGroup("main" ); 623 cfg.setGroup("main" );
593 bool check = cfg.readBoolEntry("autocheck", true ); 624 bool check = cfg.readBoolEntry("autocheck", true );
594 if( check ){ // find the documents 625 if( check ){ // find the documents
595 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); 626 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
596 docsFolder->appendFrom( *tmp ); 627 docsFolder->appendFrom( *tmp );
597 delete tmp; 628 delete tmp;
598 } 629 }
599 } 630 }
600 } 631 }
601 } 632 }
602 } 633 }
603 m_timeStamp = newStamp; 634 m_timeStamp = newStamp;
604} 635}
605 636
606void Launcher::updateTabs() 637void Launcher::updateTabs()
607{ 638{
608 MimeType::updateApplications(); // ### reads all applnks twice 639 MimeType::updateApplications(); // ### reads all applnks twice
609 640
610 delete rootFolder; 641 delete rootFolder;
611 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 642 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
612 643
613 loadDocs(); 644 loadDocs();
614 645
615 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 646 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
616} 647}
617 648
618void Launcher::updateDocs() 649void Launcher::updateDocs()
619{ 650{
620 loadDocs(); 651 loadDocs();
621 tabs->updateDocs(docsFolder,storage->fileSystems()); 652 tabs->updateDocs(docsFolder,storage->fileSystems());
622} 653}
623 654
624void Launcher::viewSelected(const QString& s) 655void Launcher::viewSelected(const QString& s)
625{ 656{
626 setCaption( s + tr(" - Launcher") ); 657 setCaption( s + tr(" - Launcher") );
627} 658}
628 659
629void Launcher::nextView() 660void Launcher::nextView()
630{ 661{
631 tabs->nextTab(); 662 tabs->nextTab();
632} 663}
633 664
634 665
635void Launcher::select( const AppLnk *appLnk ) 666void Launcher::select( const AppLnk *appLnk )
636{ 667{
637 if ( appLnk->type() == "Folder" ) { 668 if ( appLnk->type() == "Folder" ) {
638 // Not supported: flat is simpler for the user 669 // Not supported: flat is simpler for the user
639 } else { 670 } else {
640 if ( appLnk->exec().isNull() ) { 671 if ( appLnk->exec().isNull() ) {
641 QMessageBox::information(this,tr("No application"), 672 QMessageBox::information(this,tr("No application"),
642 tr("<p>No application is defined for this document." 673 tr("<p>No application is defined for this document."
643 "<p>Type is %1.").arg(appLnk->type())); 674 "<p>Type is %1.").arg(appLnk->type()));
644 return; 675 return;
645 } 676 }
646 tabs->setBusy(TRUE); 677 tabs->setBusy(TRUE);
647 emit executing( appLnk ); 678 emit executing( appLnk );
648 appLnk->execute(); 679 appLnk->execute();
649 } 680 }
650} 681}
651 682
652void Launcher::externalSelected(const AppLnk *appLnk) 683void Launcher::externalSelected(const AppLnk *appLnk)
653{ 684{
654 tabs->setBusy(TRUE); 685 tabs->setBusy(TRUE);
655 emit executing( appLnk ); 686 emit executing( appLnk );
656} 687}
657 688
658void Launcher::properties( AppLnk *appLnk ) 689void Launcher::properties( AppLnk *appLnk )
659{ 690{
660 if ( appLnk->type() == "Folder" ) { 691 if ( appLnk->type() == "Folder" ) {
661 // Not supported: flat is simpler for the user 692 // Not supported: flat is simpler for the user
662 } else { 693 } else {
663 in_lnk_props = TRUE; 694 in_lnk_props = TRUE;
664 got_lnk_change = FALSE; 695 got_lnk_change = FALSE;
665 LnkProperties prop(appLnk); 696 LnkProperties prop(appLnk);
666 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 697 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
667 prop.showMaximized(); 698 prop.showMaximized();
668 prop.exec(); 699 prop.exec();
669 in_lnk_props = FALSE; 700 in_lnk_props = FALSE;
670 if ( got_lnk_change ) { 701 if ( got_lnk_change ) {
671 updateLink(lnk_change); 702 updateLink(lnk_change);
672 } 703 }
673 } 704 }
674} 705}
675 706
676void Launcher::updateLink(const QString& link) 707void Launcher::updateLink(const QString& link)
677{ 708{
678 if (link.isNull()) 709 if (link.isNull())
679 updateTabs(); 710 updateTabs();
680 else if (link.isEmpty()) 711 else if (link.isEmpty())
681 updateDocs(); 712 updateDocs();
682 else 713 else
683 tabs->updateLink(link); 714 tabs->updateLink(link);
684} 715}
685 716
686void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 717void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
687{ 718{
688 QDataStream stream( data, IO_ReadOnly ); 719 QDataStream stream( data, IO_ReadOnly );
689 if ( msg == "closing(QString)" ){ 720 if ( msg == "closing(QString)" ){
690 QString app; 721 QString app;
691 stream >> app; 722 stream >> app;
692 qWarning("app closed %s", app.latin1() ); 723 qWarning("app closed %s", app.latin1() );
693 MRUList::removeTask( app ); 724 MRUList::removeTask( app );
694 }else if ( msg == "linkChanged(QString)" ) { 725 }else if ( msg == "linkChanged(QString)" ) {
695 QString link; 726 QString link;
696 stream >> link; 727 stream >> link;
697 if ( in_lnk_props ) { 728 if ( in_lnk_props ) {
698 got_lnk_change = TRUE; 729 got_lnk_change = TRUE;
699 lnk_change = link; 730 lnk_change = link;
700 } else { 731 } else {
701 updateLink(link); 732 updateLink(link);
702 } 733 }
703 } else if ( msg == "busy()" ) { 734 } else if ( msg == "busy()" ) {
704 emit busy(); 735 emit busy();
705 } else if ( msg == "notBusy(QString)" ) { 736 } else if ( msg == "notBusy(QString)" ) {
706 QString app; 737 QString app;
707 stream >> app; 738 stream >> app;
708 tabs->setBusy(FALSE); 739 tabs->setBusy(FALSE);
709 emit notBusy(app); 740 emit notBusy(app);
710 } else if ( msg == "mkdir(QString)" ) { 741 } else if ( msg == "mkdir(QString)" ) {
711 QString dir; 742 QString dir;
712 stream >> dir; 743 stream >> dir;
713 if ( !dir.isEmpty() ) 744 if ( !dir.isEmpty() )
714 mkdir( dir ); 745 mkdir( dir );
715 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 746 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
716 QString baseFile, sigFile; 747 QString baseFile, sigFile;
717 stream >> baseFile >> sigFile; 748 stream >> baseFile >> sigFile;
718 QRsync::generateSignature( baseFile, sigFile ); 749 QRsync::generateSignature( baseFile, sigFile );
719 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 750 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
720 QString baseFile, sigFile, deltaFile; 751 QString baseFile, sigFile, deltaFile;
721 stream >> baseFile >> sigFile >> deltaFile; 752 stream >> baseFile >> sigFile >> deltaFile;
722 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 753 QRsync::generateDiff( baseFile, sigFile, deltaFile );
723 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 754 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
724 QString baseFile, deltaFile; 755 QString baseFile, deltaFile;
725 stream >> baseFile >> deltaFile; 756 stream >> baseFile >> deltaFile;
726 if ( !QFile::exists( baseFile ) ) { 757 if ( !QFile::exists( baseFile ) ) {
727 QFile f( baseFile ); 758 QFile f( baseFile );
728 f.open( IO_WriteOnly ); 759 f.open( IO_WriteOnly );
729 f.close(); 760 f.close();
730 } 761 }
731 QRsync::applyDiff( baseFile, deltaFile ); 762 QRsync::applyDiff( baseFile, deltaFile );
732 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 763 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
733 e << baseFile; 764 e << baseFile;
734 } else if ( msg == "rdiffCleanup()" ) { 765 } else if ( msg == "rdiffCleanup()" ) {
735 mkdir( "/tmp/rdiff" ); 766 mkdir( "/tmp/rdiff" );
736 QDir dir; 767 QDir dir;
737 dir.setPath( "/tmp/rdiff" ); 768 dir.setPath( "/tmp/rdiff" );
738 QStringList entries = dir.entryList(); 769 QStringList entries = dir.entryList();
739 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 770 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
740 dir.remove( *it ); 771 dir.remove( *it );
741 } else if ( msg == "sendHandshakeInfo()" ) { 772 } else if ( msg == "sendHandshakeInfo()" ) {
742 QString home = getenv( "HOME" ); 773 QString home = getenv( "HOME" );
743 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 774 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
744 e << home; 775 e << home;
745 int locked = (int) Desktop::screenLocked(); 776 int locked = (int) Desktop::screenLocked();
746 e << locked; 777 e << locked;
747 // register an app for autostart 778 // register an app for autostart
748 // if clear is send the list is cleared. 779 // if clear is send the list is cleared.
749 } else if ( msg == "autoStart(QString)" ) { 780 } else if ( msg == "autoStart(QString)" ) {
750 QString appName; 781 QString appName;
751 stream >> appName; 782 stream >> appName;
752 Config cfg( "autostart" ); 783 Config cfg( "autostart" );
753 cfg.setGroup( "AutoStart" ); 784 cfg.setGroup( "AutoStart" );
754 if ( appName.compare("clear") == 0){ 785 if ( appName.compare("clear") == 0){
755 cfg.writeEntry("Apps", ""); 786 cfg.writeEntry("Apps", "");
756 } 787 }
757 } else if ( msg == "autoStart(QString,QString)" ) { 788 } else if ( msg == "autoStart(QString,QString)" ) {
758 QString modifier, appName; 789 QString modifier, appName;
759 stream >> modifier >> appName; 790 stream >> modifier >> appName;
760 Config cfg( "autostart" ); 791 Config cfg( "autostart" );
761 cfg.setGroup( "AutoStart" ); 792 cfg.setGroup( "AutoStart" );
762 if ( modifier.compare("add") == 0 ){ 793 if ( modifier.compare("add") == 0 ){
763 // only add if appname is entered 794 // only add if appname is entered
764 if (!appName.isEmpty()) { 795 if (!appName.isEmpty()) {
765 cfg.writeEntry("Apps", appName); 796 cfg.writeEntry("Apps", appName);
766 } 797 }
767 } else if (modifier.compare("remove") == 0 ) { 798 } else if (modifier.compare("remove") == 0 ) {
768 // need to change for multiple entries 799 // need to change for multiple entries
769 // actually remove is right now simular to clear, but in future there 800 // actually remove is right now simular to clear, but in future there
770 // should be multiple apps in autostart possible. 801 // should be multiple apps in autostart possible.
771 QString checkName; 802 QString checkName;
772 checkName = cfg.readEntry("Apps", ""); 803 checkName = cfg.readEntry("Apps", "");
773 if (checkName == appName) { 804 if (checkName == appName) {
774 cfg.writeEntry("Apps", ""); 805 cfg.writeEntry("Apps", "");
775 } 806 }
776 } 807 }
777 // case the autostart feature should be delayed 808 // case the autostart feature should be delayed
778 } else if ( msg == "autoStart(QString, QString, QString)") { 809 } else if ( msg == "autoStart(QString, QString, QString)") {
779 QString modifier, appName, delay; 810 QString modifier, appName, delay;
780 stream >> modifier >> appName >> delay; 811 stream >> modifier >> appName >> delay;
781 Config cfg( "autostart" ); 812 Config cfg( "autostart" );
782 cfg.setGroup( "AutoStart" ); 813 cfg.setGroup( "AutoStart" );
783 if ( modifier.compare("add") == 0 ){ 814 if ( modifier.compare("add") == 0 ){
784 // only add it appname is entered 815 // only add it appname is entered
785 if (!appName.isEmpty()) { 816 if (!appName.isEmpty()) {
786 cfg.writeEntry("Apps", appName); 817 cfg.writeEntry("Apps", appName);
787 cfg.writeEntry("Delay", delay); 818 cfg.writeEntry("Delay", delay);
788 } 819 }
789 } else { 820 } else {
790 } 821 }
791 } else if ( msg == "sendCardInfo()" ) { 822 } else if ( msg == "sendCardInfo()" ) {
792 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 823 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
793 const QList<FileSystem> &fs = storage->fileSystems(); 824 const QList<FileSystem> &fs = storage->fileSystems();
794 QListIterator<FileSystem> it ( fs ); 825 QListIterator<FileSystem> it ( fs );
795 QString s; 826 QString s;
796 QString homeDir = getenv("HOME"); 827 QString homeDir = getenv("HOME");
797 QString hardDiskHome; 828 QString hardDiskHome;
798 for ( ; it.current(); ++it ) { 829 for ( ; it.current(); ++it ) {
799 if ( (*it)->isRemovable() ) 830 if ( (*it)->isRemovable() )
800 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 831 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
801 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 832 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
802 + " " + (*it)->options() + ";"; 833 + " " + (*it)->options() + ";";
803 else if ( (*it)->disk() == "/dev/mtdblock1" || 834 else if ( (*it)->disk() == "/dev/mtdblock1" ||
804 (*it)->disk() == "/dev/mtdblock/1" ) 835 (*it)->disk() == "/dev/mtdblock/1" )
805 s += (*it)->name() + "=" + homeDir + "/Documents " 836 s += (*it)->name() + "=" + homeDir + "/Documents "
806 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 837 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
807 + " " + (*it)->options() + ";"; 838 + " " + (*it)->options() + ";";
808 else if ( (*it)->name().contains( "Hard Disk") && 839 else if ( (*it)->name().contains( "Hard Disk") &&
809 homeDir.contains( (*it)->path() ) && 840 homeDir.contains( (*it)->path() ) &&
810 (*it)->path().length() > hardDiskHome.length() ) 841 (*it)->path().length() > hardDiskHome.length() )
811 hardDiskHome = 842 hardDiskHome =
812 (*it)->name() + "=" + homeDir + "/Documents " 843 (*it)->name() + "=" + homeDir + "/Documents "
813 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 844 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
814 + " " + (*it)->options() + ";"; 845 + " " + (*it)->options() + ";";
815 } 846 }
816 if ( !hardDiskHome.isEmpty() ) 847 if ( !hardDiskHome.isEmpty() )
817 s += hardDiskHome; 848 s += hardDiskHome;
818 849
819 e << s; 850 e << s;
820 } else if ( msg == "sendSyncDate(QString)" ) { 851 } else if ( msg == "sendSyncDate(QString)" ) {
821 QString app; 852 QString app;
822 stream >> app; 853 stream >> app;
823 Config cfg( "qpe" ); 854 Config cfg( "qpe" );
824 cfg.setGroup("SyncDate"); 855 cfg.setGroup("SyncDate");
825 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 856 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
826 e << app << cfg.readEntry( app ); 857 e << app << cfg.readEntry( app );
827 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 858 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
828 //cfg.readEntry( app ).latin1() ); 859 //cfg.readEntry( app ).latin1() );
829 } else if ( msg == "setSyncDate(QString,QString)" ) { 860 } else if ( msg == "setSyncDate(QString,QString)" ) {
830 QString app, date; 861 QString app, date;
831 stream >> app >> date; 862 stream >> app >> date;
832 Config cfg( "qpe" ); 863 Config cfg( "qpe" );
833 cfg.setGroup("SyncDate"); 864 cfg.setGroup("SyncDate");
834 cfg.writeEntry( app, date ); 865 cfg.writeEntry( app, date );
835 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 866 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
836 } else if ( msg == "startSync(QString)" ) { 867 } else if ( msg == "startSync(QString)" ) {
837 QString what; 868 QString what;
838 stream >> what; 869 stream >> what;
839 delete syncDialog; syncDialog = 0; 870 delete syncDialog; syncDialog = 0;
840 syncDialog = new SyncDialog( this, "syncProgress", FALSE, 871 syncDialog = new SyncDialog( this, "syncProgress", FALSE,
841 WStyle_Tool | WStyle_Customize | 872 WStyle_Tool | WStyle_Customize |
842 Qt::WStyle_StaysOnTop ); 873 Qt::WStyle_StaysOnTop );
843 syncDialog->showMaximized(); 874 syncDialog->showMaximized();
844 syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); 875 syncDialog->whatLabel->setText( "<b>" + what + "</b>" );