summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp2
-rw-r--r--core/launcher/mrulist.cpp42
2 files changed, 38 insertions, 6 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index cf1a3c8..17a30e6 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -83,856 +83,856 @@ namespace {
83 cfg->setGroup("mimetypes" ); 83 cfg->setGroup("mimetypes" );
84 tmpMime = cfg->readBoolEntry("all" ,false); 84 tmpMime = cfg->readBoolEntry("all" ,false);
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
538void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 538void Launcher::loadDocs() // ok here comes a hack belonging to Global::
539{ 539{
540 qWarning("loading Documents" ); 540 qWarning("loading Documents" );
541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); 541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() );
542 delete docsFolder; 542 delete docsFolder;
543 docsFolder = new DocLnkSet; 543 docsFolder = new DocLnkSet;
544 qWarning("new DocLnkSet" ); 544 qWarning("new DocLnkSet" );
545 DocLnkSet *tmp = 0; 545 DocLnkSet *tmp = 0;
546 QString home = QString(getenv("HOME")) + "/Documents"; 546 QString home = QString(getenv("HOME")) + "/Documents";
547 tmp = new DocLnkSet( home , QString::null); 547 tmp = new DocLnkSet( home , QString::null);
548 docsFolder->appendFrom( *tmp ); 548 docsFolder->appendFrom( *tmp );
549 delete tmp; 549 delete tmp;
550 // find out wich filesystems are new in this round 550 // find out wich filesystems are new in this round
551 // We will do this by having a timestamp inside each mountpoint 551 // 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 552 // if the current timestamp doesn't match this is a new file system and
553 // come up with our MediumMountGui :) let the hacking begin 553 // come up with our MediumMountGui :) let the hacking begin
554 int stamp = uidgen.generate(); 554 int stamp = uidgen.generate();
555 555
556 QString newStamp = QString::number( stamp ); // generates newtime Stamp 556 QString newStamp = QString::number( stamp ); // generates newtime Stamp
557 StorageInfo storage; 557 StorageInfo storage;
558 const QList<FileSystem> &fileSystems = storage.fileSystems(); 558 const QList<FileSystem> &fileSystems = storage.fileSystems();
559 QListIterator<FileSystem> it ( fileSystems ); 559 QListIterator<FileSystem> it ( fileSystems );
560 for ( ; it.current(); ++it ) { 560 for ( ; it.current(); ++it ) {
561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
562 qWarning("%s is removeable", (*it)->path().latin1() ); 562 qWarning("%s is removeable", (*it)->path().latin1() );
563 OConfig cfg( (*it)->path() + "/.opiestorage.cf"); 563 OConfig cfg( (*it)->path() + "/.opiestorage.cf");
564 cfg.setGroup("main"); 564 cfg.setGroup("main");
565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
566 if( stamp == m_timeStamp ){ // ok we know this card 566 if( stamp == m_timeStamp ){ // ok we know this card
567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
568 // we need to scan the list now. Hopefully the cache will be there 568 // we need to scan the list now. Hopefully the cache will be there
569 // read the mimetypes from the config and search for documents 569 // read the mimetypes from the config and search for documents
570 QStringList mimetypes = configToMime( &cfg); 570 QStringList mimetypes = configToMime( &cfg);
571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
572 docsFolder->appendFrom( *tmp ); 572 docsFolder->appendFrom( *tmp );
573 delete tmp; 573 delete tmp;
574 574
575 }else{ // come up with the gui cause this a new card 575 }else{ // come up with the gui cause this a new card
576 MediumMountGui medium((*it)->path() ); 576 MediumMountGui medium((*it)->path() );
577 if( medium.check() ){ // we did not ask before or ask again is off 577 if( medium.check() ){ // we did not ask before or ask again is off
578 if( medium.exec() ){ // he clicked yes so search it 578 if( medium.exec() ){ // he clicked yes so search it
579 // speicher 579 // speicher
580 cfg.read(); // cause of a race we need to reread 580 cfg.read(); // cause of a race we need to reread
581 cfg.writeEntry("timestamp", newStamp ); 581 cfg.writeEntry("timestamp", newStamp );
582 }// no else 582 }// no else
583 }else{ // we checked 583 }else{ // we checked
584 // do something different see what we need to do 584 // do something different see what we need to do
585 // let's see if we should check the device 585 // let's see if we should check the device
586 cfg.setGroup("main" ); 586 cfg.setGroup("main" );
587 bool check = cfg.readBoolEntry("autocheck", true ); 587 bool check = cfg.readBoolEntry("autocheck", true );
588 if( check ){ // find the documents 588 if( check ){ // find the documents
589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); 589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
590 docsFolder->appendFrom( *tmp ); 590 docsFolder->appendFrom( *tmp );
591 delete tmp; 591 delete tmp;
592 } 592 }
593 } 593 }
594 } 594 }
595 } 595 }
596 } 596 }
597 m_timeStamp = newStamp; 597 m_timeStamp = newStamp;
598} 598}
599 599
600void Launcher::updateTabs() 600void Launcher::updateTabs()
601{ 601{
602 MimeType::updateApplications(); // ### reads all applnks twice 602 MimeType::updateApplications(); // ### reads all applnks twice
603 603
604 delete rootFolder; 604 delete rootFolder;
605 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 605 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
606 606
607 loadDocs(); 607 loadDocs();
608 608
609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
610} 610}
611 611
612void Launcher::updateDocs() 612void Launcher::updateDocs()
613{ 613{
614 loadDocs(); 614 loadDocs();
615 tabs->updateDocs(docsFolder,storage->fileSystems()); 615 tabs->updateDocs(docsFolder,storage->fileSystems());
616} 616}
617 617
618void Launcher::viewSelected(const QString& s) 618void Launcher::viewSelected(const QString& s)
619{ 619{
620 setCaption( s + tr(" - Launcher") ); 620 setCaption( s + tr(" - Launcher") );
621} 621}
622 622
623void Launcher::nextView() 623void Launcher::nextView()
624{ 624{
625 tabs->nextTab(); 625 tabs->nextTab();
626} 626}
627 627
628 628
629void Launcher::select( const AppLnk *appLnk ) 629void Launcher::select( const AppLnk *appLnk )
630{ 630{
631 if ( appLnk->type() == "Folder" ) { 631 if ( appLnk->type() == "Folder" ) {
632 // Not supported: flat is simpler for the user 632 // Not supported: flat is simpler for the user
633 } else { 633 } else {
634 if ( appLnk->exec().isNull() ) { 634 if ( appLnk->exec().isNull() ) {
635 QMessageBox::information(this,tr("No application"), 635 QMessageBox::information(this,tr("No application"),
636 tr("<p>No application is defined for this document." 636 tr("<p>No application is defined for this document."
637 "<p>Type is %1.").arg(appLnk->type())); 637 "<p>Type is %1.").arg(appLnk->type()));
638 return; 638 return;
639 } 639 }
640 tabs->setBusy(TRUE); 640 tabs->setBusy(TRUE);
641 emit executing( appLnk ); 641 emit executing( appLnk );
642 appLnk->execute(); 642 appLnk->execute();
643 } 643 }
644} 644}
645 645
646void Launcher::externalSelected(const AppLnk *appLnk) 646void Launcher::externalSelected(const AppLnk *appLnk)
647{ 647{
648 tabs->setBusy(TRUE); 648 tabs->setBusy(TRUE);
649 emit executing( appLnk ); 649 emit executing( appLnk );
650} 650}
651 651
652void Launcher::properties( AppLnk *appLnk ) 652void Launcher::properties( AppLnk *appLnk )
653{ 653{
654 if ( appLnk->type() == "Folder" ) { 654 if ( appLnk->type() == "Folder" ) {
655 // Not supported: flat is simpler for the user 655 // Not supported: flat is simpler for the user
656 } else { 656 } else {
657 in_lnk_props = TRUE; 657 in_lnk_props = TRUE;
658 got_lnk_change = FALSE; 658 got_lnk_change = FALSE;
659 LnkProperties prop(appLnk); 659 LnkProperties prop(appLnk);
660 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 660 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
661 prop.showMaximized(); 661 prop.showMaximized();
662 prop.exec(); 662 prop.exec();
663 in_lnk_props = FALSE; 663 in_lnk_props = FALSE;
664 if ( got_lnk_change ) { 664 if ( got_lnk_change ) {
665 updateLink(lnk_change); 665 updateLink(lnk_change);
666 } 666 }
667 } 667 }
668} 668}
669 669
670void Launcher::updateLink(const QString& link) 670void Launcher::updateLink(const QString& link)
671{ 671{
672 if (link.isNull()) 672 if (link.isNull())
673 updateTabs(); 673 updateTabs();
674 else if (link.isEmpty()) 674 else if (link.isEmpty())
675 updateDocs(); 675 updateDocs();
676 else 676 else
677 tabs->updateLink(link); 677 tabs->updateLink(link);
678} 678}
679 679
680void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 680void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
681{ 681{
682 QDataStream stream( data, IO_ReadOnly ); 682 QDataStream stream( data, IO_ReadOnly );
683 if ( msg == "linkChanged(QString)" ) { 683 if ( msg == "linkChanged(QString)" ) {
684 QString link; 684 QString link;
685 stream >> link; 685 stream >> link;
686 if ( in_lnk_props ) { 686 if ( in_lnk_props ) {
687 got_lnk_change = TRUE; 687 got_lnk_change = TRUE;
688 lnk_change = link; 688 lnk_change = link;
689 } else { 689 } else {
690 updateLink(link); 690 updateLink(link);
691 } 691 }
692 } else if ( msg == "busy()" ) { 692 } else if ( msg == "busy()" ) {
693 emit busy(); 693 emit busy();
694 } else if ( msg == "notBusy(QString)" ) { 694 } else if ( msg == "notBusy(QString)" ) {
695 QString app; 695 QString app;
696 stream >> app; 696 stream >> app;
697 tabs->setBusy(FALSE); 697 tabs->setBusy(FALSE);
698 emit notBusy(app); 698 emit notBusy(app);
699 } else if ( msg == "mkdir(QString)" ) { 699 } else if ( msg == "mkdir(QString)" ) {
700 QString dir; 700 QString dir;
701 stream >> dir; 701 stream >> dir;
702 if ( !dir.isEmpty() ) 702 if ( !dir.isEmpty() )
703 mkdir( dir ); 703 mkdir( dir );
704 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 704 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
705 QString baseFile, sigFile; 705 QString baseFile, sigFile;
706 stream >> baseFile >> sigFile; 706 stream >> baseFile >> sigFile;
707 QRsync::generateSignature( baseFile, sigFile ); 707 QRsync::generateSignature( baseFile, sigFile );
708 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 708 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
709 QString baseFile, sigFile, deltaFile; 709 QString baseFile, sigFile, deltaFile;
710 stream >> baseFile >> sigFile >> deltaFile; 710 stream >> baseFile >> sigFile >> deltaFile;
711 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 711 QRsync::generateDiff( baseFile, sigFile, deltaFile );
712 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 712 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
713 QString baseFile, deltaFile; 713 QString baseFile, deltaFile;
714 stream >> baseFile >> deltaFile; 714 stream >> baseFile >> deltaFile;
715 if ( !QFile::exists( baseFile ) ) { 715 if ( !QFile::exists( baseFile ) ) {
716 QFile f( baseFile ); 716 QFile f( baseFile );
717 f.open( IO_WriteOnly ); 717 f.open( IO_WriteOnly );
718 f.close(); 718 f.close();
719 } 719 }
720 QRsync::applyDiff( baseFile, deltaFile ); 720 QRsync::applyDiff( baseFile, deltaFile );
721 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 721 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
722 e << baseFile; 722 e << baseFile;
723 } else if ( msg == "rdiffCleanup()" ) { 723 } else if ( msg == "rdiffCleanup()" ) {
724 mkdir( "/tmp/rdiff" ); 724 mkdir( "/tmp/rdiff" );
725 QDir dir; 725 QDir dir;
726 dir.setPath( "/tmp/rdiff" ); 726 dir.setPath( "/tmp/rdiff" );
727 QStringList entries = dir.entryList(); 727 QStringList entries = dir.entryList();
728 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 728 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
729 dir.remove( *it ); 729 dir.remove( *it );
730 } else if ( msg == "sendHandshakeInfo()" ) { 730 } else if ( msg == "sendHandshakeInfo()" ) {
731 QString home = getenv( "HOME" ); 731 QString home = getenv( "HOME" );
732 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 732 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
733 e << home; 733 e << home;
734 int locked = (int) Desktop::screenLocked(); 734 int locked = (int) Desktop::screenLocked();
735 e << locked; 735 e << locked;
736 // register an app for autostart 736 // register an app for autostart
737 // if clear is send the list is cleared. 737 // if clear is send the list is cleared.
738 } else if ( msg == "autoStart(QString)" ) { 738 } else if ( msg == "autoStart(QString)" ) {
739 QString appName; 739 QString appName;
740 stream >> appName; 740 stream >> appName;
741 Config cfg( "autostart" ); 741 Config cfg( "autostart" );
742 cfg.setGroup( "AutoStart" ); 742 cfg.setGroup( "AutoStart" );
743 if ( appName.compare("clear") == 0){ 743 if ( appName.compare("clear") == 0){
744 cfg.writeEntry("Apps", ""); 744 cfg.writeEntry("Apps", "");
745 } 745 }
746 } else if ( msg == "autoStart(QString,QString)" ) { 746 } else if ( msg == "autoStart(QString,QString)" ) {
747 QString modifier, appName; 747 QString modifier, appName;
748 stream >> modifier >> appName; 748 stream >> modifier >> appName;
749 Config cfg( "autostart" ); 749 Config cfg( "autostart" );
750 cfg.setGroup( "AutoStart" ); 750 cfg.setGroup( "AutoStart" );
751 if ( modifier.compare("add") == 0 ){ 751 if ( modifier.compare("add") == 0 ){
752 // only add it appname is entered 752 // only add it appname is entered
753 if (!appName.isEmpty()) { 753 if (!appName.isEmpty()) {
754 cfg.writeEntry("Apps", appName); 754 cfg.writeEntry("Apps", appName);
755 } 755 }
756 } else if (modifier.compare("remove") == 0 ) { 756 } else if (modifier.compare("remove") == 0 ) {
757 // need to change for multiple entries 757 // need to change for multiple entries
758 // actually remove is right now simular to clear, but in future there 758 // actually remove is right now simular to clear, but in future there
759 // should be multiple apps in autostart possible. 759 // should be multiple apps in autostart possible.
760 QString checkName; 760 QString checkName;
761 checkName = cfg.readEntry("Apps", ""); 761 checkName = cfg.readEntry("Apps", "");
762 if (checkName == appName) { 762 if (checkName == appName) {
763 cfg.writeEntry("Apps", ""); 763 cfg.writeEntry("Apps", "");
764 } 764 }
765 } 765 }
766 } else if ( msg == "sendCardInfo()" ) { 766 } else if ( msg == "sendCardInfo()" ) {
767 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 767 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
768 const QList<FileSystem> &fs = storage->fileSystems(); 768 const QList<FileSystem> &fs = storage->fileSystems();
769 QListIterator<FileSystem> it ( fs ); 769 QListIterator<FileSystem> it ( fs );
770 QString s; 770 QString s;
771 QString homeDir = getenv("HOME"); 771 QString homeDir = getenv("HOME");
772 QString hardDiskHome; 772 QString hardDiskHome;
773 for ( ; it.current(); ++it ) { 773 for ( ; it.current(); ++it ) {
774 if ( (*it)->isRemovable() ) 774 if ( (*it)->isRemovable() )
775 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 775 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
776 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 776 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
777 + " " + (*it)->options() + ";"; 777 + " " + (*it)->options() + ";";
778 else if ( (*it)->disk() == "/dev/mtdblock1" || 778 else if ( (*it)->disk() == "/dev/mtdblock1" ||
779 (*it)->disk() == "/dev/mtdblock/1" ) 779 (*it)->disk() == "/dev/mtdblock/1" )
780 s += (*it)->name() + "=" + homeDir + "/Documents " 780 s += (*it)->name() + "=" + homeDir + "/Documents "
781 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 781 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
782 + " " + (*it)->options() + ";"; 782 + " " + (*it)->options() + ";";
783 else if ( (*it)->name().contains( "Hard Disk") && 783 else if ( (*it)->name().contains( "Hard Disk") &&
784 homeDir.contains( (*it)->path() ) && 784 homeDir.contains( (*it)->path() ) &&
785 (*it)->path().length() > hardDiskHome.length() ) 785 (*it)->path().length() > hardDiskHome.length() )
786 hardDiskHome = 786 hardDiskHome =
787 (*it)->name() + "=" + homeDir + "/Documents " 787 (*it)->name() + "=" + homeDir + "/Documents "
788 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 788 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
789 + " " + (*it)->options() + ";"; 789 + " " + (*it)->options() + ";";
790 } 790 }
791 if ( !hardDiskHome.isEmpty() ) 791 if ( !hardDiskHome.isEmpty() )
792 s += hardDiskHome; 792 s += hardDiskHome;
793 793
794 e << s; 794 e << s;
795 } else if ( msg == "sendSyncDate(QString)" ) { 795 } else if ( msg == "sendSyncDate(QString)" ) {
796 QString app; 796 QString app;
797 stream >> app; 797 stream >> app;
798 Config cfg( "qpe" ); 798 Config cfg( "qpe" );
799 cfg.setGroup("SyncDate"); 799 cfg.setGroup("SyncDate");
800 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 800 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
801 e << app << cfg.readEntry( app ); 801 e << app << cfg.readEntry( app );
802 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 802 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
803 //cfg.readEntry( app ).latin1() ); 803 //cfg.readEntry( app ).latin1() );
804 } else if ( msg == "setSyncDate(QString,QString)" ) { 804 } else if ( msg == "setSyncDate(QString,QString)" ) {
805 QString app, date; 805 QString app, date;
806 stream >> app >> date; 806 stream >> app >> date;
807 Config cfg( "qpe" ); 807 Config cfg( "qpe" );
808 cfg.setGroup("SyncDate"); 808 cfg.setGroup("SyncDate");
809 cfg.writeEntry( app, date ); 809 cfg.writeEntry( app, date );
810 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 810 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
811 } else if ( msg == "startSync(QString)" ) { 811 } else if ( msg == "startSync(QString)" ) {
812 QString what; 812 QString what;
813 stream >> what; 813 stream >> what;
814 delete syncDialog; syncDialog = 0; 814 delete syncDialog; syncDialog = 0;
815 syncDialog = new SyncDialog( this, "syncProgress", FALSE, 815 syncDialog = new SyncDialog( this, "syncProgress", FALSE,
816 WStyle_Tool | WStyle_Customize | 816 WStyle_Tool | WStyle_Customize |
817 Qt::WStyle_StaysOnTop ); 817 Qt::WStyle_StaysOnTop );
818 syncDialog->showMaximized(); 818 syncDialog->showMaximized();
819 syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); 819 syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
820 connect( syncDialog->buttonCancel, SIGNAL( clicked() ), 820 connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
821 SLOT( cancelSync() ) ); 821 SLOT( cancelSync() ) );
822 } 822 }
823 else if ( msg == "stopSync()") { 823 else if ( msg == "stopSync()") {
824 delete syncDialog; syncDialog = 0; 824 delete syncDialog; syncDialog = 0;
825 } else if ( msg == "getAllDocLinks()" ) { 825 } else if ( msg == "getAllDocLinks()" ) {
826 loadDocs(); 826 loadDocs();
827 827
828 QString contents; 828 QString contents;
829 829
830 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { 830 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
831 DocLnk *doc = it.current(); 831 DocLnk *doc = it.current();
832 QFileInfo fi( doc->file() ); 832 QFileInfo fi( doc->file() );
833 if ( !fi.exists() ) 833 if ( !fi.exists() )
834 continue; 834 continue;
835 835
836 bool fake = !doc->linkFileKnown(); 836 bool fake = !doc->linkFileKnown();
837 if ( !fake ) { 837 if ( !fake ) {
838 QFile f( doc->linkFile() ); 838 QFile f( doc->linkFile() );
839 if ( f.open( IO_ReadOnly ) ) { 839 if ( f.open( IO_ReadOnly ) ) {
840 QTextStream ts( &f ); 840 QTextStream ts( &f );
841 ts.setEncoding( QTextStream::UnicodeUTF8 ); 841 ts.setEncoding( QTextStream::UnicodeUTF8 );
842 contents += ts.read(); 842 contents += ts.read();
843 f.close(); 843 f.close();
844 } else 844 } else
845 fake = TRUE; 845 fake = TRUE;
846 } 846 }
847 if (fake) { 847 if (fake) {
848 contents += "[Desktop Entry]\n"; 848 contents += "[Desktop Entry]\n";
849 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; 849 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n";
850 contents += "File = "+doc->file()+"\n"; 850 contents += "File = "+doc->file()+"\n";
851 contents += "Name = "+doc->name()+"\n"; 851 contents += "Name = "+doc->name()+"\n";
852 contents += "Type = "+doc->type()+"\n"; 852 contents += "Type = "+doc->type()+"\n";
853 } 853 }
854 contents += QString("Size = %1\n").arg( fi.size() ); 854 contents += QString("Size = %1\n").arg( fi.size() );
855 } 855 }
856 856
857 //qDebug( "sending length %d", contents.length() ); 857 //qDebug( "sending length %d", contents.length() );
858 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 858 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
859 e << contents; 859 e << contents;
860 860
861 qDebug( "================ \n\n%s\n\n===============", 861 qDebug( "================ \n\n%s\n\n===============",
862 contents.latin1() ); 862 contents.latin1() );
863 863
864 delete docsFolder; 864 delete docsFolder;
865 docsFolder = 0; 865 docsFolder = 0;
866 } 866 }
867} 867}
868 868
869void Launcher::cancelSync() 869void Launcher::cancelSync()
870{ 870{
871 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 871 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
872} 872}
873 873
874void Launcher::storageChanged() 874void Launcher::storageChanged()
875{ 875{
876 if ( in_lnk_props ) { 876 if ( in_lnk_props ) {
877 got_lnk_change = TRUE; 877 got_lnk_change = TRUE;
878 lnk_change = ""; 878 lnk_change = "";
879 } else { 879 } else {
880 updateDocs(); 880 updateDocs();
881 } 881 }
882} 882}
883 883
884 884
885bool Launcher::mkdir(const QString &localPath) 885bool Launcher::mkdir(const QString &localPath)
886{ 886{
887 QDir fullDir(localPath); 887 QDir fullDir(localPath);
888 if (fullDir.exists()) 888 if (fullDir.exists())
889 return true; 889 return true;
890 890
891 // at this point the directory doesn't exist 891 // at this point the directory doesn't exist
892 // go through the directory tree and start creating the direcotories 892 // go through the directory tree and start creating the direcotories
893 // that don't exist; if we can't create the directories, return false 893 // that don't exist; if we can't create the directories, return false
894 894
895 QString dirSeps = "/"; 895 QString dirSeps = "/";
896 int dirIndex = localPath.find(dirSeps); 896 int dirIndex = localPath.find(dirSeps);
897 QString checkedPath; 897 QString checkedPath;
898 898
899 // didn't find any seps; weird, use the cur dir instead 899 // didn't find any seps; weird, use the cur dir instead
900 if (dirIndex == -1) { 900 if (dirIndex == -1) {
901 //qDebug("No seperators found in path %s", localPath.latin1()); 901 //qDebug("No seperators found in path %s", localPath.latin1());
902 checkedPath = QDir::currentDirPath(); 902 checkedPath = QDir::currentDirPath();
903 } 903 }
904 904
905 while (checkedPath != localPath) { 905 while (checkedPath != localPath) {
906 // no more seperators found, use the local path 906 // no more seperators found, use the local path
907 if (dirIndex == -1) 907 if (dirIndex == -1)
908 checkedPath = localPath; 908 checkedPath = localPath;
909 else { 909 else {
910 // the next directory to check 910 // the next directory to check
911 checkedPath = localPath.left(dirIndex) + "/"; 911 checkedPath = localPath.left(dirIndex) + "/";
912 // advance the iterator; the next dir seperator 912 // advance the iterator; the next dir seperator
913 dirIndex = localPath.find(dirSeps, dirIndex+1); 913 dirIndex = localPath.find(dirSeps, dirIndex+1);
914 } 914 }
915 915
916 QDir checkDir(checkedPath); 916 QDir checkDir(checkedPath);
917 if (!checkDir.exists()) { 917 if (!checkDir.exists()) {
918 //qDebug("mkdir making dir %s", checkedPath.latin1()); 918 //qDebug("mkdir making dir %s", checkedPath.latin1());
919 919
920 if (!checkDir.mkdir(checkedPath)) { 920 if (!checkDir.mkdir(checkedPath)) {
921 qDebug("Unable to make directory %s", checkedPath.latin1()); 921 qDebug("Unable to make directory %s", checkedPath.latin1());
922 return FALSE; 922 return FALSE;
923 } 923 }
924 } 924 }
925 925
926 } 926 }
927 return TRUE; 927 return TRUE;
928} 928}
929 929
930void Launcher::preloadApps() 930void Launcher::preloadApps()
931{ 931{
932 Config cfg("Launcher"); 932 Config cfg("Launcher");
933 cfg.setGroup("Preload"); 933 cfg.setGroup("Preload");
934 QStringList apps = cfg.readListEntry("Apps",','); 934 QStringList apps = cfg.readListEntry("Apps",',');
935 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 935 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
936 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 936 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
937 } 937 }
938} 938}
diff --git a/core/launcher/mrulist.cpp b/core/launcher/mrulist.cpp
index 4daf7d2..6066dac 100644
--- a/core/launcher/mrulist.cpp
+++ b/core/launcher/mrulist.cpp
@@ -1,199 +1,231 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Holger 'zecke' Freyther
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 4**
4** This file is part of Qtopia Environment. 5** This file is part of Qtopia Environment.
5** 6**
6** 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
7** 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
8** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 10** packaging of this file.
10** 11**
11** 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
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 14**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 16**
16** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 18** not clear to you.
18** 19**
19**********************************************************************/ 20**********************************************************************/
20 21
21#include "mrulist.h" 22#include "mrulist.h"
22 23
23#include <qpe/global.h> 24#include <qpe/global.h>
24#include <qpe/applnk.h> 25#include <qpe/applnk.h>
25#include <qpe/resource.h> 26#include <qpe/resource.h>
26 27
27#include <qframe.h> 28#include <qframe.h>
28#include <qpushbutton.h> 29#include <qpushbutton.h>
29#include <qtoolbutton.h> 30#include <qtoolbutton.h>
30#include <qpopupmenu.h> 31#include <qpopupmenu.h>
31#include <qpainter.h> 32#include <qpainter.h>
32#include <qwindowsystem_qws.h> 33#include <qwindowsystem_qws.h>
33 34
34 35
35 QList<MRUList>*MRUList::MRUListWidgets = NULL; 36 QList<MRUList>*MRUList::MRUListWidgets = NULL;
36 QList<AppLnk>*MRUList::task = NULL; 37 QList<AppLnk>*MRUList::task = NULL;
37 38
38 39
39MRUList::MRUList( QWidget *parent ) 40MRUList::MRUList( QWidget *parent )
40 : QFrame( parent ), selected(-1), oldsel(-1) 41 : QFrame( parent ), selected(-1), oldsel(-1)
41{ 42{
42 setBackgroundMode( PaletteButton ); 43 setBackgroundMode( PaletteButton );
43 if (!MRUListWidgets) 44 if (!MRUListWidgets)
44 MRUListWidgets = new QList<MRUList>; 45 MRUListWidgets = new QList<MRUList>;
45 if (!task) 46 if (!task)
46 task = new QList<AppLnk>; 47 task = new QList<AppLnk>;
47 MRUListWidgets->append( this ); 48 MRUListWidgets->append( this );
48} 49}
49 50
50 51
51MRUList::~MRUList() 52MRUList::~MRUList()
52{ 53{
53 if (MRUListWidgets) 54 if (MRUListWidgets)
54 MRUListWidgets->remove( this ); 55 MRUListWidgets->remove( this );
55 if (task) 56 if (task)
56 task->setAutoDelete( TRUE ); 57 task->setAutoDelete( TRUE );
57} 58}
58 59
59 60
60QSize MRUList::sizeHint() const 61QSize MRUList::sizeHint() const
61{ 62{
62 return QSize( frameWidth(), 16 ); 63 return QSize( frameWidth(), 16 );
63} 64}
64 65
65 66
66void MRUList::addTask( const AppLnk *appLnk ) 67void MRUList::addTask( const AppLnk *appLnk )
67{ 68{
68 if ( !appLnk ) 69 if ( !appLnk )
69 return; 70 return;
70 unsigned int i = 0; 71 unsigned int i = 0;
71 72
72 if ( !task ) 73 if ( !task )
73 return; 74 return;
74 75 // ok we wan't to delete old icons from the taskbar
76 // get the window list and see which windows aren't there any more
77 QList<AppLnk> cleanUp;
78 cleanUp.setAutoDelete( TRUE );
79 const QList<QWSWindow> &list = qwsServer->clientWindows();
80 QWSWindow* w;
81 bool running = false; // to see what we should do
82 for ( ; i < task->count(); i++ ) {
83 AppLnk *t = task->at(i);
84 running = false;
85 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
86 QString app = w->client()->identity();
87 if( app == t->exec( ) ){
88 running = true;
89 break;
90 }
91 }
92 if(!running ) { // gues what we do now
93 cleanUp.append( t);
94 }
95 }
96 // no do a clean up of these old icons
97 AppLnk *lnk;
98 for( lnk = cleanUp.first(); lnk != 0; lnk = cleanUp.next() ){
99 task->remove( lnk );
100 }
101 cleanUp.clear(); // should be deleted too
102
103 i = 0;
75 for ( ; i < task->count(); i++ ) { 104 for ( ; i < task->count(); i++ ) {
76 AppLnk *t = task->at(i); 105 AppLnk *t = task->at(i);
77 if ( t->exec() == appLnk->exec() ) { 106 if ( t->exec() == appLnk->exec() ) {
78 if (i != 0) { 107 if (i != 0) {
79 task->remove(); 108 task->remove();
80 task->prepend( t ); 109 task->prepend( t );
81 } 110 }
82 for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) 111 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
83 MRUListWidgets->at(i)->update(); 112 MRUListWidgets->at(i)->update();
84 return; 113 return;
85 } 114 }
86 } 115 }
87 116 // check which tasks are running and delete them from the list
88 AppLnk *t = new AppLnk( *appLnk ); 117 AppLnk *t = new AppLnk( *appLnk );
89 // DocLnks have an overloaded virtual function exec() 118 // DocLnks have an overloaded virtual function exec()
90 t->setExec( appLnk->exec() ); 119 t->setExec( appLnk->exec() );
91 task->prepend( t ); 120 task->prepend( t );
92 121
93 if ( task->count() > 6 ) { 122 if ( task->count() > 6 ) {
94 t = task->last(); 123 t = task->last();
95 task->remove(); 124 task->remove();
96 Global::terminate(t); 125 Global::terminate(t);
97 delete t; 126 delete t;
98 } 127 }
99 128
100 for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) 129 for (unsigned i = 0; i < MRUListWidgets->count(); i++ )
101 MRUListWidgets->at(i)->update(); 130 MRUListWidgets->at(i)->update();
102} 131}
103 132
104bool MRUList::quitOldApps() 133bool MRUList::quitOldApps()
105{ 134{
106 QStringList appsstarted; 135 QStringList appsstarted;
107 QStringList appsrunning; 136 QStringList appsrunning;
108 for ( int i=task->count()-1; i>=0; --i ) { 137 for ( int i=task->count()-1; i>=0; --i ) {
109 AppLnk *t = task->at(i); 138 AppLnk *t = task->at(i);
110 appsstarted.append(t->exec()); 139 appsstarted.append(t->exec());
111 } 140 }
112 141
113 const QList<QWSWindow> &list = qwsServer->clientWindows(); 142 const QList<QWSWindow> &list = qwsServer->clientWindows();
114 QWSWindow* w; 143 QWSWindow* w;
115 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 144 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
116 QString app = w->client()->identity(); 145 QString app = w->client()->identity();
117 if ( appsstarted.contains(app) && !appsrunning.contains(app) ) 146 if ( appsstarted.contains(app) && !appsrunning.contains(app) )
118 appsrunning.append(app); 147 appsrunning.append(app);
119 } 148 }
120 149
121 if ( appsrunning.count() > 1 ) { 150 if ( appsrunning.count() > 1 ) {
122 QStringList::ConstIterator it = appsrunning.begin(); 151 QStringList::ConstIterator it = appsrunning.begin();
123 ++it; // top stays running! 152 ++it; // top stays running!
124 for (; it != appsrunning.end(); it++) { 153 for (; it != appsrunning.end(); it++) {
125 for ( int i=task->count()-1; i>=0; --i ) { 154 for ( int i=task->count()-1; i>=0; --i ) {
126 AppLnk *t = task->at(i); 155 AppLnk *t = task->at(i);
127 if ( t->exec() == *it ) 156 if ( t->exec() == *it ){
128 Global::terminate(t); 157 task->remove(i );
158 delete t;
159 Global::terminate(t);
160 }
129 } 161 }
130 } 162 }
131 return TRUE; 163 return TRUE;
132 } else { 164 } else {
133 return FALSE; 165 return FALSE;
134 } 166 }
135} 167}
136 168
137 169
138void MRUList::mousePressEvent(QMouseEvent *e) 170void MRUList::mousePressEvent(QMouseEvent *e)
139{ 171{
140 selected = 0; 172 selected = 0;
141 int x=0; 173 int x=0;
142 QListIterator<AppLnk> it( *task ); 174 QListIterator<AppLnk> it( *task );
143 for ( ; it.current(); ++it,++selected,x+=15 ) { 175 for ( ; it.current(); ++it,++selected,x+=15 ) {
144 if ( x + 15 <= width() ) { 176 if ( x + 15 <= width() ) {
145 if ( e->x() >= x && e->x() < x+15 ) { 177 if ( e->x() >= x && e->x() < x+15 ) {
146 if ( selected < (int)task->count() ) { 178 if ( selected < (int)task->count() ) {
147 repaint(FALSE); 179 repaint(FALSE);
148 return; 180 return;
149 } 181 }
150 } 182 }
151 } else { 183 } else {
152 break; 184 break;
153 } 185 }
154 } 186 }
155 selected = -1; 187 selected = -1;
156 repaint( FALSE ); 188 repaint( FALSE );
157} 189}
158 190
159 191
160void MRUList::mouseReleaseEvent(QMouseEvent *) 192void MRUList::mouseReleaseEvent(QMouseEvent *)
161{ 193{
162 if ( selected >= 0 ) { 194 if ( selected >= 0 ) {
163 if ( parentWidget() ) 195 if ( parentWidget() )
164 if ( parentWidget()->isA( "QPopupMenu" ) ) 196 if ( parentWidget()->isA( "QPopupMenu" ) )
165 parentWidget()->hide(); 197 parentWidget()->hide();
166 Global::execute( task->at(selected)->exec() ); 198 Global::execute( task->at(selected)->exec() );
167 selected = -1; 199 selected = -1;
168 oldsel = -1; 200 oldsel = -1;
169 update(); 201 update();
170 } 202 }
171} 203}
172 204
173 205
174void MRUList::paintEvent( QPaintEvent * ) 206void MRUList::paintEvent( QPaintEvent * )
175{ 207{
176 QPainter p( this ); 208 QPainter p( this );
177 AppLnk *t; 209 AppLnk *t;
178 int x = 0; 210 int x = 0;
179 int y = (height() - 14) / 2; 211 int y = (height() - 14) / 2;
180 int i = 0; 212 int i = 0;
181 213
182 p.fillRect( 0, 0, width(), height(), colorGroup().background() ); 214 p.fillRect( 0, 0, width(), height(), colorGroup().background() );
183 215
184 if ( task ) { 216 if ( task ) {
185 QListIterator<AppLnk> it( *task ); 217 QListIterator<AppLnk> it( *task );
186 for ( ; it.current(); i++, ++it ) { 218 for ( ; it.current(); i++, ++it ) {
187 if ( x + 15 <= width() ) { 219 if ( x + 15 <= width() ) {
188 t = it.current(); 220 t = it.current();
189 if ( (int)i == selected ) 221 if ( (int)i == selected )
190 p.fillRect( x, y, 15, t->pixmap().height()+1, colorGroup().highlight() ); 222 p.fillRect( x, y, 15, t->pixmap().height()+1, colorGroup().highlight() );
191 else if ( (int)i == oldsel ) 223 else if ( (int)i == oldsel )
192 p.eraseRect( x, y, 15, t->pixmap().height()+1 ); 224 p.eraseRect( x, y, 15, t->pixmap().height()+1 );
193 p.drawPixmap( x, y, t->pixmap() ); 225 p.drawPixmap( x, y, t->pixmap() );
194 x += 15; 226 x += 15;
195 } 227 }
196 } 228 }
197 } 229 }
198} 230}
199 231