Diffstat (limited to 'core/launcher/launcherview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/launcherview.cpp | 596 |
1 files changed, 280 insertions, 316 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 1317bda..673e53c 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -101,267 +101,2 @@ private: | |||
101 | bool m_EyeImage; | 101 | bool m_EyeImage; |
102 | LauncherThumbReceiver*m_EyeCallback; | ||
103 | }; | ||
104 | |||
105 | |||
106 | class LauncherIconView : public QIconView { | ||
107 | public: | ||
108 | LauncherIconView( QWidget* parent, const char* name=0 ) : | ||
109 | QIconView(parent,name), | ||
110 | tf(""), | ||
111 | cf(0), | ||
112 | bsy(0), | ||
113 | busyTimer(0), | ||
114 | bigIcns(TRUE), | ||
115 | bgColor(white) | ||
116 | { | ||
117 | sortmeth = Name; | ||
118 | hidden.setAutoDelete(TRUE); | ||
119 | ike = FALSE; | ||
120 | calculateGrid( Bottom ); | ||
121 | } | ||
122 | |||
123 | ~LauncherIconView() | ||
124 | { | ||
125 | #if 0 // debuggery | ||
126 | QListIterator<AppLnk> it(hidden); | ||
127 | AppLnk* l; | ||
128 | while ((l=it.current())) { | ||
129 | ++it; | ||
130 | //odebug << "" << l << ": hidden (should remove)" << oendl; | ||
131 | } | ||
132 | #endif | ||
133 | } | ||
134 | |||
135 | QIconViewItem* busyItem() const { return bsy; } | ||
136 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | ||
137 | QPixmap busyPixmap() const { return busyPix; } | ||
138 | #endif | ||
139 | void setBigIcons( bool bi ) { | ||
140 | bigIcns = bi; | ||
141 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | ||
142 | busyPix.resize(0,0); | ||
143 | #endif | ||
144 | } | ||
145 | |||
146 | void updateCategoriesAndMimeTypes(); | ||
147 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | ||
148 | void doAutoScroll() | ||
149 | { | ||
150 | // We don't want rubberbanding (yet) | ||
151 | } | ||
152 | |||
153 | void setBusy(bool on) | ||
154 | { | ||
155 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | ||
156 | if ( busyPix.isNull() ) { | ||
157 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | ||
158 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); | ||
159 | } | ||
160 | #endif | ||
161 | |||
162 | if ( on ) { | ||
163 | busyTimer = startTimer( 100 ); | ||
164 | } else { | ||
165 | if ( busyTimer ) { | ||
166 | killTimer( busyTimer ); | ||
167 | busyTimer = 0; | ||
168 | } | ||
169 | } | ||
170 | |||
171 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; | ||
172 | |||
173 | if ( bsy != c ) { | ||
174 | LauncherItem *oldBusy = bsy; | ||
175 | bsy = c; | ||
176 | if ( oldBusy ) { | ||
177 | oldBusy->resetIcon(); | ||
178 | } | ||
179 | if ( bsy ) { | ||
180 | bsy->setBusyIndicatorType( busyType ) ; | ||
181 | bsy->animateIcon(); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | |||
186 | bool inKeyEvent() const { return ike; } | ||
187 | void keyPressEvent(QKeyEvent* e) | ||
188 | { | ||
189 | ike = TRUE; | ||
190 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { | ||
191 | if ( (e->state() & ShiftButton) ) | ||
192 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); | ||
193 | else | ||
194 | returnPressed(currentItem()); | ||
195 | } | ||
196 | |||
197 | QIconView::keyPressEvent(e); | ||
198 | ike = FALSE; | ||
199 | } | ||
200 | |||
201 | void addItem(AppLnk* app, bool resort=TRUE); | ||
202 | bool removeLink(const QString& linkfile); | ||
203 | |||
204 | QStringList mimeTypes() const; | ||
205 | QStringList categories() const; | ||
206 | |||
207 | void clear() | ||
208 | { | ||
209 | mimes.clear(); | ||
210 | cats.clear(); | ||
211 | QIconView::clear(); | ||
212 | hidden.clear(); | ||
213 | } | ||
214 | |||
215 | void addCatsAndMimes(AppLnk* app) | ||
216 | { | ||
217 | // QStringList c = app->categories(); | ||
218 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | ||
219 | // cats.replace(*cit,(void*)1); | ||
220 | // } | ||
221 | QString maj=app->type(); | ||
222 | int sl=maj.find('/'); | ||
223 | if (sl>=0) { | ||
224 | QString k; | ||
225 | k = maj.left(12) == "application/" ? maj : maj.left(sl); | ||
226 | mimes.replace(k,(void*)1); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | void setBackgroundOrigin( QWidget::BackgroundOrigin ) { | ||
231 | } | ||
232 | |||
233 | void setBackgroundPixmap( const QPixmap &pm ) { | ||
234 | bgPixmap = pm; | ||
235 | } | ||
236 | |||
237 | void setBackgroundColor( const QColor &c ) { | ||
238 | bgColor = c; | ||
239 | } | ||
240 | |||
241 | void drawBackground( QPainter *p, const QRect &r ) | ||
242 | { | ||
243 | if ( !bgPixmap.isNull() ) { | ||
244 | p->drawTiledPixmap( r, bgPixmap, | ||
245 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), | ||
246 | (r.y() + contentsY()) % bgPixmap.height() ) ); | ||
247 | } else { | ||
248 | p->fillRect( r, bgColor ); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | void setItemTextPos( ItemTextPos pos ) | ||
253 | { | ||
254 | calculateGrid( pos ); | ||
255 | QIconView::setItemTextPos( pos ); | ||
256 | } | ||
257 | |||
258 | void hideOrShowItems(bool resort); | ||
259 | |||
260 | void setTypeFilter(const QString& typefilter, bool resort) | ||
261 | { | ||
262 | tf = QRegExp(typefilter,FALSE,TRUE); | ||
263 | hideOrShowItems(resort); | ||
264 | } | ||
265 | |||
266 | void setCategoryFilter( int catfilter, bool resort ) | ||
267 | { | ||
268 | Categories cat; | ||
269 | cat.load( categoryFileName() ); | ||
270 | QString str; | ||
271 | if ( catfilter == -2 ) | ||
272 | cf = 0; | ||
273 | else | ||
274 | cf = catfilter; | ||
275 | hideOrShowItems(resort); | ||
276 | } | ||
277 | |||
278 | enum SortMethod { Name, Date, Type }; | ||
279 | |||
280 | void setSortMethod( SortMethod m ) | ||
281 | { | ||
282 | if ( sortmeth != m ) { | ||
283 | sortmeth = m; | ||
284 | sort(); | ||
285 | } | ||
286 | } | ||
287 | |||
288 | int compare(const AppLnk* a, const AppLnk* b) | ||
289 | { | ||
290 | switch (sortmeth) { | ||
291 | case Name: | ||
292 | return a->name().lower().compare(b->name().lower()); | ||
293 | case Date: { | ||
294 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | ||
295 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | ||
296 | return fa.lastModified().secsTo(fb.lastModified()); | ||
297 | } | ||
298 | case Type: | ||
299 | return a->type().compare(b->type()); | ||
300 | } | ||
301 | return 0; | ||
302 | } | ||
303 | |||
304 | protected: | ||
305 | |||
306 | void timerEvent( QTimerEvent *te ) | ||
307 | { | ||
308 | if ( te->timerId() == busyTimer ) { | ||
309 | if ( bsy ) | ||
310 | bsy->animateIcon(); | ||
311 | } else { | ||
312 | QIconView::timerEvent( te ); | ||
313 | } | ||
314 | } | ||
315 | |||
316 | void styleChange( QStyle &old ) | ||
317 | { | ||
318 | QIconView::styleChange( old ); | ||
319 | calculateGrid( itemTextPos() ); | ||
320 | } | ||
321 | |||
322 | void calculateGrid( ItemTextPos pos ) | ||
323 | { | ||
324 | int dw = QApplication::desktop()->width(); | ||
325 | int viewerWidth = dw-style().scrollBarExtent().width(); | ||
326 | if ( pos == Bottom ) { | ||
327 | int cols = 3; | ||
328 | if ( viewerWidth <= 200 ) | ||
329 | cols = 2; | ||
330 | else if ( viewerWidth >= 400 ) | ||
331 | cols = viewerWidth/96; | ||
332 | setSpacing( 4 ); | ||
333 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | ||
334 | setGridY( fontMetrics().height()*2+24 ); | ||
335 | } else { | ||
336 | int cols = 2; | ||
337 | if ( viewerWidth < 150 ) | ||
338 | cols = 1; | ||
339 | else if ( viewerWidth >= 400 ) | ||
340 | cols = viewerWidth/150; | ||
341 | setSpacing( 2 ); | ||
342 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | ||
343 | setGridY( fontMetrics().height()+2 ); | ||
344 | } | ||
345 | } | ||
346 | |||
347 | void focusInEvent( QFocusEvent * ) {} | ||
348 | void focusOutEvent( QFocusEvent * ) {} | ||
349 | |||
350 | private: | ||
351 | QList<AppLnk> hidden; | ||
352 | QDict<void> mimes; | ||
353 | QDict<void> cats; | ||
354 | SortMethod sortmeth; | ||
355 | QRegExp tf; | ||
356 | int cf; | ||
357 | LauncherItem* bsy; | ||
358 | int busyTimer; | ||
359 | bool ike; | ||
360 | bool bigIcns; | ||
361 | QPixmap bgPixmap; | ||
362 | QColor bgColor; | ||
363 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | ||
364 | QPixmap busyPix; | ||
365 | #endif | ||
366 | BusyIndicatorType busyType; | ||
367 | }; | 102 | }; |
@@ -393,3 +128,2 @@ LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | |||
393 | { | 128 | { |
394 | m_EyeCallback = new LauncherThumbReceiver(this); | ||
395 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { | 129 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { |
@@ -397,3 +131,2 @@ LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | |||
397 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); | 131 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); |
398 | m_EyeCallback->requestThumb(applnk->file(),m_iPixmap.width(),m_iPixmap.height()); | ||
399 | } | 132 | } |
@@ -407,3 +140,2 @@ LauncherItem::~LauncherItem() | |||
407 | delete app; | 140 | delete app; |
408 | if (m_EyeCallback) delete m_EyeCallback; | ||
409 | } | 141 | } |
@@ -528,2 +260,140 @@ void LauncherItem::setEyePixmap(const QPixmap&aIcon) | |||
528 | //=========================================================================== | 260 | //=========================================================================== |
261 | // Implemantation of LauncherIconview start | ||
262 | //=========================================================================== | ||
263 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) | ||
264 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) | ||
265 | { | ||
266 | m_EyeCallBack = 0; | ||
267 | sortmeth = Name; | ||
268 | hidden.setAutoDelete(TRUE); | ||
269 | ike = FALSE; | ||
270 | calculateGrid( Bottom ); | ||
271 | } | ||
272 | |||
273 | LauncherIconView::~LauncherIconView() | ||
274 | { | ||
275 | #if 0 // debuggery | ||
276 | QListIterator<AppLnk> it(hidden); | ||
277 | AppLnk* l; | ||
278 | while ((l=it.current())) { | ||
279 | ++it; | ||
280 | //odebug << "" << l << ": hidden (should remove)" << oendl; | ||
281 | } | ||
282 | #endif | ||
283 | } | ||
284 | |||
285 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) | ||
286 | { | ||
287 | switch (sortmeth) { | ||
288 | case Name: | ||
289 | return a->name().lower().compare(b->name().lower()); | ||
290 | case Date: { | ||
291 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | ||
292 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | ||
293 | return fa.lastModified().secsTo(fb.lastModified()); | ||
294 | } | ||
295 | case Type: | ||
296 | return a->type().compare(b->type()); | ||
297 | } | ||
298 | return 0; | ||
299 | } | ||
300 | |||
301 | void LauncherIconView::setSortMethod( SortMethod m ) | ||
302 | { | ||
303 | if ( sortmeth != m ) { | ||
304 | sortmeth = m; | ||
305 | sort(); | ||
306 | } | ||
307 | } | ||
308 | |||
309 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) | ||
310 | { | ||
311 | Categories cat; | ||
312 | cat.load( categoryFileName() ); | ||
313 | QString str; | ||
314 | if ( catfilter == -2 ) | ||
315 | cf = 0; | ||
316 | else | ||
317 | cf = catfilter; | ||
318 | hideOrShowItems(resort); | ||
319 | } | ||
320 | |||
321 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) | ||
322 | { | ||
323 | tf = QRegExp(typefilter,FALSE,TRUE); | ||
324 | hideOrShowItems(resort); | ||
325 | } | ||
326 | |||
327 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) | ||
328 | { | ||
329 | calculateGrid( pos ); | ||
330 | QIconView::setItemTextPos( pos ); | ||
331 | } | ||
332 | |||
333 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) | ||
334 | { | ||
335 | if ( !bgPixmap.isNull() ) { | ||
336 | p->drawTiledPixmap( r, bgPixmap, | ||
337 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), | ||
338 | (r.y() + contentsY()) % bgPixmap.height() ) ); | ||
339 | } else { | ||
340 | p->fillRect( r, bgColor ); | ||
341 | } | ||
342 | } | ||
343 | |||
344 | void LauncherIconView::addCatsAndMimes(AppLnk* app) | ||
345 | { | ||
346 | // QStringList c = app->categories(); | ||
347 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | ||
348 | // cats.replace(*cit,(void*)1); | ||
349 | // } | ||
350 | QString maj=app->type(); | ||
351 | int sl=maj.find('/'); | ||
352 | if (sl>=0) { | ||
353 | QString k; | ||
354 | k = maj.left(12) == "application/" ? maj : maj.left(sl); | ||
355 | mimes.replace(k,(void*)1); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | void LauncherIconView::setBusy(bool on) | ||
360 | { | ||
361 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | ||
362 | if ( busyPix.isNull() ) { | ||
363 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | ||
364 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); | ||
365 | } | ||
366 | #endif | ||
367 | |||
368 | if ( on ) { | ||
369 | busyTimer = startTimer( 100 ); | ||
370 | } else { | ||
371 | if ( busyTimer ) { | ||
372 | killTimer( busyTimer ); | ||
373 | busyTimer = 0; | ||
374 | } | ||
375 | } | ||
376 | |||
377 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; | ||
378 | |||
379 | if ( bsy != c ) { | ||
380 | LauncherItem *oldBusy = bsy; | ||
381 | bsy = c; | ||
382 | if ( oldBusy ) { | ||
383 | oldBusy->resetIcon(); | ||
384 | } | ||
385 | if ( bsy ) { | ||
386 | bsy->setBusyIndicatorType( busyType ) ; | ||
387 | bsy->animateIcon(); | ||
388 | } | ||
389 | } | ||
390 | } | ||
391 | |||
392 | void LauncherIconView::clear() | ||
393 | { | ||
394 | mimes.clear(); | ||
395 | cats.clear(); | ||
396 | QIconView::clear(); | ||
397 | hidden.clear(); | ||
398 | } | ||
529 | 399 | ||
@@ -534,4 +404,4 @@ QStringList LauncherIconView::mimeTypes() const | |||
534 | while (it.current()) { | 404 | while (it.current()) { |
535 | r.append(it.currentKey()); | 405 | r.append(it.currentKey()); |
536 | ++it; | 406 | ++it; |
537 | } | 407 | } |
@@ -541,2 +411,42 @@ QStringList LauncherIconView::mimeTypes() const | |||
541 | 411 | ||
412 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) | ||
413 | { | ||
414 | LauncherItem* item = (LauncherItem*)firstItem(); | ||
415 | while (item) { | ||
416 | if (item->appLnk()->file()==fname) { | ||
417 | break; | ||
418 | } | ||
419 | item = (LauncherItem*)item->nextItem(); | ||
420 | } | ||
421 | return item; | ||
422 | } | ||
423 | |||
424 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile) | ||
425 | { | ||
426 | LauncherItem*item = findDocItem(aFile); | ||
427 | if (!item||!item->isEyeImage()) return; | ||
428 | |||
429 | item->setEyePixmap(aPixmap); | ||
430 | } | ||
431 | |||
432 | void LauncherIconView::checkCallback() | ||
433 | { | ||
434 | if (m_EyeCallBack) { | ||
435 | return; | ||
436 | } | ||
437 | m_EyeCallBack = new LauncherThumbReceiver(); | ||
438 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&)), | ||
439 | this,SLOT(setEyePixmap(const QPixmap&,const QString&))); | ||
440 | } | ||
441 | |||
442 | void LauncherIconView::addCheckItem(AppLnk* app) | ||
443 | { | ||
444 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); | ||
445 | if (item->isEyeImage()) { | ||
446 | checkCallback(); | ||
447 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | ||
448 | m_EyeCallBack->requestThumb(app->file(),s,s); | ||
449 | } | ||
450 | } | ||
451 | |||
542 | void LauncherIconView::addItem(AppLnk* app, bool resort) | 452 | void LauncherIconView::addItem(AppLnk* app, bool resort) |
@@ -544,11 +454,12 @@ void LauncherIconView::addItem(AppLnk* app, bool resort) | |||
544 | addCatsAndMimes(app); | 454 | addCatsAndMimes(app); |
545 | |||
546 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 455 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
547 | && (cf == 0 || app->categories().contains(cf) | 456 | && (cf == 0 || app->categories().contains(cf) |
548 | || cf == -1 && app->categories().count() == 0 ) ) | 457 | || cf == -1 && app->categories().count() == 0 ) ) { |
549 | (void) new LauncherItem( this, app, bigIcns ); | 458 | addCheckItem(app); |
550 | else | 459 | } else { |
551 | hidden.append(app); | 460 | hidden.append(app); |
552 | if ( resort ) | 461 | } |
553 | sort(); | 462 | if ( resort ){ |
463 | sort(); | ||
464 | } | ||
554 | } | 465 | } |
@@ -561,4 +472,4 @@ void LauncherIconView::updateCategoriesAndMimeTypes() | |||
561 | while (item) { | 472 | while (item) { |
562 | addCatsAndMimes(item->appLnk()); | 473 | addCatsAndMimes(item->appLnk()); |
563 | item = (LauncherItem*)item->nextItem(); | 474 | item = (LauncherItem*)item->nextItem(); |
564 | } | 475 | } |
@@ -567,4 +478,4 @@ void LauncherIconView::updateCategoriesAndMimeTypes() | |||
567 | while ((l=it.current())) { | 478 | while ((l=it.current())) { |
568 | addCatsAndMimes(l); | 479 | addCatsAndMimes(l); |
569 | ++it; | 480 | ++it; |
570 | } | 481 | } |
@@ -588,4 +499,4 @@ void LauncherIconView::hideOrShowItems(bool resort) | |||
588 | while ((l=it.current())) { | 499 | while ((l=it.current())) { |
589 | addItem(l,FALSE); | 500 | addItem(l,FALSE); |
590 | ++it; | 501 | ++it; |
591 | } | 502 | } |
@@ -603,12 +514,10 @@ bool LauncherIconView::removeLink(const QString& linkfile) | |||
603 | while (item) { | 514 | while (item) { |
604 | l = item->appLnk(); | 515 | l = item->appLnk(); |
605 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); | 516 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); |
606 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 517 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && |
607 | || l->fileKnown() && ( | 518 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { |
608 | l->file() == linkfile | 519 | delete item; |
609 | || dl.isValid() && dl.file() == l->file() ) ) { | 520 | did = TRUE; |
610 | delete item; | 521 | } |
611 | did = TRUE; | 522 | item = nextItem; |
612 | } | ||
613 | item = nextItem; | ||
614 | } | 523 | } |
@@ -616,9 +525,9 @@ bool LauncherIconView::removeLink(const QString& linkfile) | |||
616 | while ((l=it.current())) { | 525 | while ((l=it.current())) { |
617 | ++it; | 526 | ++it; |
618 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 527 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
619 | || l->file() == linkfile | 528 | || l->file() == linkfile |
620 | || dl.isValid() && dl.file() == l->file() ) { | 529 | || dl.isValid() && dl.file() == l->file() ) { |
621 | hidden.removeRef(l); | 530 | hidden.removeRef(l); |
622 | did = TRUE; | 531 | did = TRUE; |
623 | } | 532 | } |
624 | } | 533 | } |
@@ -627,4 +536,63 @@ bool LauncherIconView::removeLink(const QString& linkfile) | |||
627 | 536 | ||
537 | void LauncherIconView::timerEvent( QTimerEvent *te ) | ||
538 | { | ||
539 | if ( te->timerId() == busyTimer ) { | ||
540 | if ( bsy ) | ||
541 | bsy->animateIcon(); | ||
542 | } else { | ||
543 | QIconView::timerEvent( te ); | ||
544 | } | ||
545 | } | ||
546 | |||
547 | void LauncherIconView::setBigIcons( bool bi ) | ||
548 | { | ||
549 | bigIcns = bi; | ||
550 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | ||
551 | busyPix.resize(0,0); | ||
552 | #endif | ||
553 | } | ||
554 | |||
555 | QIconViewItem* LauncherIconView::busyItem() const | ||
556 | { | ||
557 | return bsy; | ||
558 | } | ||
559 | |||
560 | void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | ||
561 | |||
562 | void LauncherIconView::calculateGrid( ItemTextPos pos ) | ||
563 | { | ||
564 | int dw = QApplication::desktop()->width(); | ||
565 | int viewerWidth = dw-style().scrollBarExtent().width(); | ||
566 | if ( pos == Bottom ) { | ||
567 | int cols = 3; | ||
568 | if ( viewerWidth <= 200 ) | ||
569 | cols = 2; | ||
570 | else if ( viewerWidth >= 400 ) | ||
571 | cols = viewerWidth/96; | ||
572 | setSpacing( 4 ); | ||
573 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | ||
574 | setGridY( fontMetrics().height()*2+24 ); | ||
575 | } else { | ||
576 | int cols = 2; | ||
577 | if ( viewerWidth < 150 ) | ||
578 | cols = 1; | ||
579 | else if ( viewerWidth >= 400 ) | ||
580 | cols = viewerWidth/150; | ||
581 | setSpacing( 2 ); | ||
582 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | ||
583 | setGridY( fontMetrics().height()+2 ); | ||
584 | } | ||
585 | } | ||
586 | |||
587 | void LauncherIconView::styleChange( QStyle &old ) | ||
588 | { | ||
589 | QIconView::styleChange( old ); | ||
590 | calculateGrid( itemTextPos() ); | ||
591 | } | ||
592 | //=========================================================================== | ||
593 | // Implemantation of LauncherIconview end | ||
628 | //=========================================================================== | 594 | //=========================================================================== |
629 | 595 | ||
596 | |||
597 | //=========================================================================== | ||
630 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | 598 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) |
@@ -1097,6 +1065,5 @@ QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | |||
1097 | 1065 | ||
1098 | LauncherThumbReceiver::LauncherThumbReceiver(LauncherItem*parent) | 1066 | LauncherThumbReceiver::LauncherThumbReceiver() |
1099 | :QObject() | 1067 | :QObject() |
1100 | { | 1068 | { |
1101 | m_parent = parent; | ||
1102 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); | 1069 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); |
@@ -1108,3 +1075,2 @@ LauncherThumbReceiver::LauncherThumbReceiver(LauncherItem*parent) | |||
1108 | } | 1075 | } |
1109 | m_waiting = false; | ||
1110 | } | 1076 | } |
@@ -1122,3 +1088,3 @@ void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | |||
1122 | QDataStream stream( at, IO_ReadOnly ); | 1088 | QDataStream stream( at, IO_ReadOnly ); |
1123 | if (!m_parent || !m_waiting) return; | 1089 | |
1124 | /* we are just interested in thumbmails */ | 1090 | /* we are just interested in thumbmails */ |
@@ -1128,7 +1094,4 @@ void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | |||
1128 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { | 1094 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { |
1129 | if ((*it).file==m_reqFile) { | 1095 | odebug << "Pixinfos: " << (*it).file << " - " << (*it).width << oendl; |
1130 | m_parent->setEyePixmap((*it).pixmap); | 1096 | emit sig_Thumbnail((*it).pixmap,(*it).file); |
1131 | m_waiting = false; | ||
1132 | break; | ||
1133 | } | ||
1134 | } | 1097 | } |
@@ -1138,3 +1101,3 @@ void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height | |||
1138 | { | 1101 | { |
1139 | m_reqFile = file; | 1102 | PixmapInfo rItem; |
1140 | rItem.file = file; | 1103 | rItem.file = file; |
@@ -1142,3 +1105,4 @@ void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height | |||
1142 | rItem.height = height; | 1105 | rItem.height = height; |
1143 | QTimer::singleShot(1, this, SLOT(sendRequest())); | 1106 | m_inThumbNail.append(rItem); |
1107 | QTimer::singleShot(2, this, SLOT(sendRequest())); | ||
1144 | } | 1108 | } |
@@ -1147,7 +1111,7 @@ void LauncherThumbReceiver::sendRequest() | |||
1147 | { | 1111 | { |
1148 | PixmapInfos m_inThumbNail; | 1112 | if (m_inThumbNail.count()>0) { |
1149 | m_inThumbNail.append(rItem); | 1113 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); |
1150 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); | 1114 | env << m_inThumbNail; |
1151 | env << m_inThumbNail; | 1115 | } |
1152 | m_waiting = true; | 1116 | m_inThumbNail.clear(); |
1153 | } | 1117 | } |