• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libkonq
 

libkonq

  • libkonq
konq_iconviewwidget.cc
1 /* This file is part of the KDE projects
2  Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3  Copyright (C) 2000 - 2005 David Faure <faure@kde.org>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 #include "konq_iconviewwidget.h"
21 #include "konq_operations.h"
22 #include "konq_undo.h"
23 #include "konq_sound.h"
24 #include "konq_filetip.h"
25 
26 #include <tqclipboard.h>
27 #include <tqlayout.h>
28 #include <tqtimer.h>
29 #include <tqpainter.h>
30 #include <tqtooltip.h>
31 #include <tqlabel.h>
32 #include <tqmovie.h>
33 #include <tqregexp.h>
34 #include <tqcursor.h>
35 
36 #include <kapplication.h>
37 #include <kdebug.h>
38 #include <kio/previewjob.h>
39 #include <kfileivi.h>
40 #include <konq_settings.h>
41 #include <konq_drag.h>
42 #include <kglobalsettings.h>
43 #include <kpropertiesdialog.h>
44 #include <kipc.h>
45 #include <kicontheme.h>
46 #include <kiconeffect.h>
47 #include <kurldrag.h>
48 #include <kstandarddirs.h>
49 #include <kprotocolinfo.h>
50 #include <ktrader.h>
51 
52 #include <assert.h>
53 #include <unistd.h>
54 #include <klocale.h>
55 
56 
57 struct KonqIconViewWidgetPrivate
58 {
59  KonqIconViewWidgetPrivate() {
60  pActiveItem = 0;
61  bSoundPreviews = false;
62  pSoundItem = 0;
63  bSoundItemClicked = false;
64  pSoundPlayer = 0;
65  pSoundTimer = 0;
66  pPreviewJob = 0;
67  bAllowSetWallpaper = false;
68 
69  doAnimations = true;
70  m_movie = 0L;
71  m_movieBlocked = 0;
72  pFileTip = 0;
73  pActivateDoubleClick = 0L;
74  bCaseInsensitive = true;
75  pPreviewMimeTypes = 0L;
76  bProgramsURLdrag = false;
77  }
78  ~KonqIconViewWidgetPrivate() {
79  delete pSoundPlayer;
80  delete pSoundTimer;
81  delete m_movie;
82  delete pFileTip;
83  delete pActivateDoubleClick;
84  delete pPreviewMimeTypes;
85  //delete pPreviewJob; done by stopImagePreview
86  }
87  KFileIVI *pActiveItem;
88  // Sound preview
89  KFileIVI *pSoundItem;
90  KonqSoundPlayer *pSoundPlayer;
91  TQTimer *pSoundTimer;
92  bool bSoundPreviews;
93  bool bSoundItemClicked;
94  bool bAllowSetWallpaper;
95  bool bCaseInsensitive;
96  bool bBoostPreview;
97 
98  // Animated icons support
99  bool doAnimations;
100  TQMovie* m_movie;
101  int m_movieBlocked;
102  TQString movieFileName;
103 
104  KIO::PreviewJob *pPreviewJob;
105  KonqFileTip* pFileTip;
106  TQStringList previewSettings;
107  bool renameItem;
108  bool firstClick;
109  bool releaseMouseEvent;
110  TQPoint mousePos;
111  int mouseState;
112  TQTimer *pActivateDoubleClick;
113  TQStringList* pPreviewMimeTypes;
114  bool bProgramsURLdrag;
115 };
116 
117 KonqIconViewWidget::KonqIconViewWidget( TQWidget * parent, const char * name, WFlags f, bool kdesktop )
118  : KIconView( parent, name, f ),
119  m_rootItem( 0L ), m_size( 0 ) /* default is DesktopIcon size */,
120  m_bDesktop( kdesktop ),
121  m_bSetGridX( !kdesktop ) /* No line breaking on the desktop */
122 {
123  d = new KonqIconViewWidgetPrivate;
124  connect( this, TQT_SIGNAL( dropped( TQDropEvent *, const TQValueList<TQIconDragItem> & ) ),
125  this, TQT_SLOT( slotDropped( TQDropEvent*, const TQValueList<TQIconDragItem> & ) ) );
126 
127  connect( this, TQT_SIGNAL( selectionChanged() ),
128  this, TQT_SLOT( slotSelectionChanged() ) );
129 
130  kapp->addKipcEventMask( KIPC::IconChanged );
131  connect( kapp, TQT_SIGNAL(iconChanged(int)), TQT_SLOT(slotIconChanged(int)) );
132  connect( this, TQT_SIGNAL(onItem(TQIconViewItem *)), TQT_SLOT(slotOnItem(TQIconViewItem *)) );
133  connect( this, TQT_SIGNAL(onViewport()), TQT_SLOT(slotOnViewport()) );
134  connect( this, TQT_SIGNAL(itemRenamed(TQIconViewItem *, const TQString &)), TQT_SLOT(slotItemRenamed(TQIconViewItem *, const TQString &)) );
135 
136  m_pSettings = KonqFMSettings::settings(); // already needed in setItemTextPos(), calculateGridX()
137  d->bBoostPreview = boostPreview();
138 
139  // hardcoded settings
140  setSelectionMode( TQIconView::Extended );
141  setItemTextPos( TQIconView::Bottom );
142  d->releaseMouseEvent = false;
143  d->pFileTip = new KonqFileTip(this);
144  d->firstClick = false;
145  calculateGridX();
146  setAutoArrange( true );
147  setSorting( true, sortDirection() );
148  readAnimatedIconsConfig();
149  m_bSortDirsFirst = true;
150  m_bMousePressed = false;
151  m_LineupMode = LineupBoth;
152  // emit our signals
153  slotSelectionChanged();
154  m_iconPositionGroupPrefix = TQString::fromLatin1( "IconPosition::" );
155  KonqUndoManager::incRef();
156 }
157 
158 KonqIconViewWidget::~KonqIconViewWidget()
159 {
160  stopImagePreview();
161  KonqUndoManager::decRef();
162  delete d;
163 }
164 
165 bool KonqIconViewWidget::maySetWallpaper()
166 {
167  return d->bAllowSetWallpaper;
168 }
169 
170 void KonqIconViewWidget::setMaySetWallpaper(bool b)
171 {
172  d->bAllowSetWallpaper = b;
173 }
174 
175 void KonqIconViewWidget::focusOutEvent( TQFocusEvent * ev )
176 {
177  // We can't possibly have the mouse pressed and still lose focus.
178  // Well, we can, but when we regain focus we should assume the mouse is
179  // not down anymore or the slotOnItem code will break with highlighting!
180  m_bMousePressed = false;
181 
182  // This will ensure that tooltips don't pop up and the mouseover icon
183  // effect will go away if the mouse goes out of the view without
184  // first moving into an empty portion of the view
185  // Fixes part of #86968, and #85204
186  // Matt Newell 2004-09-24
187  slotOnViewport();
188 
189  KIconView::focusOutEvent( ev );
190 }
191 
192 void KonqIconViewWidget::slotItemRenamed(TQIconViewItem *item, const TQString &name)
193 {
194  kdDebug(1203) << "KonqIconViewWidget::slotItemRenamed" << endl;
195  KFileIVI *viewItem = static_cast<KFileIVI *>(item);
196  KFileItem *fileItem = viewItem->item();
197 
198  // The correct behavior is to show the old name until the rename has successfully
199  // completed. Unfortunately, KIconView forces us to allow the text to be changed
200  // before we try the rename, so set it back to the pre-rename state.
201  viewItem->setText( fileItem->text() );
202  kdDebug(1203)<<" fileItem->text() ;"<<fileItem->text()<<endl;
203  // Don't do anything if the user renamed to a blank name.
204  if( !name.isEmpty() )
205  {
206  // Actually attempt the rename. If it succeeds, KDirLister will update the name.
207  KURL oldurl( fileItem->url() );
208  KURL newurl( oldurl );
209  newurl.setPath( newurl.directory(false) + KIO::encodeFileName( name ) );
210  kdDebug(1203)<<" newurl :"<<newurl<<endl;
211  // We use url()+name so that it also works if the name is a relative path (#51176)
212  KonqOperations::rename( this, oldurl, newurl );
213  }
214 }
215 
216 void KonqIconViewWidget::slotIconChanged( int group )
217 {
218  if (group != KIcon::Desktop)
219  return;
220 
221  int size = m_size;
222  if ( m_size == 0 )
223  m_size = -1; // little trick to force grid change in setIcons
224  setIcons( size ); // force re-determining all icons
225  readAnimatedIconsConfig();
226 }
227 
228 void KonqIconViewWidget::readAnimatedIconsConfig()
229 {
230  KConfigGroup cfgGroup( KGlobal::config(), "DesktopIcons" );
231  d->doAnimations = cfgGroup.readBoolEntry( "Animated", true /*default*/ );
232 }
233 
234 void KonqIconViewWidget::slotOnItem( TQIconViewItem *_item )
235 {
236  KFileIVI* item = static_cast<KFileIVI *>( _item );
237  // Reset icon of previous item
238  if( d->pActiveItem != 0L && d->pActiveItem != item )
239  {
240  if ( d->m_movie && d->pActiveItem->isAnimated() )
241  {
242  d->m_movie->pause(); // we'll see below what we do with it
243  d->pActiveItem->setAnimated( false );
244  d->pActiveItem->refreshIcon( true );
245  }
246  else {
247  d->pActiveItem->setActive( false );
248  }
249  d->pActiveItem = 0L;
250  d->pFileTip->setItem( 0L );
251  }
252 
253  // Stop sound
254  if (d->pSoundPlayer != 0 && item != d->pSoundItem)
255  {
256  d->pSoundPlayer->stop();
257 
258  d->pSoundItem = 0;
259  if (d->pSoundTimer && d->pSoundTimer->isActive())
260  d->pSoundTimer->stop();
261  }
262 
263  if ( !m_bMousePressed )
264  {
265  if( item != d->pActiveItem )
266  {
267  d->pActiveItem = item;
268  d->pFileTip->setItem( d->pActiveItem->item(),
269  item->rect(),
270  item->pixmap() );
271 
272  if ( d->doAnimations && d->pActiveItem && d->pActiveItem->hasAnimation() )
273  {
274  //kdDebug(1203) << "Playing animation for: " << d->pActiveItem->mouseOverAnimation() << endl;
275  // Check if cached movie can be used
276 #if 0 // Qt-mng bug, reusing the movie doesn't work currently.
277  if ( d->m_movie && d->movieFileName == d->pActiveItem->mouseOverAnimation() )
278  {
279  d->pActiveItem->setAnimated( true );
280  if (d->m_movieBlocked) {
281  kdDebug(1203) << "onitem, but blocked" << endl;
282  d->m_movie->pause();
283  }
284  else {
285  kdDebug(1203) << "we go ahead.." << endl;
286  d->m_movieBlocked++;
287  TQTimer::singleShot(300, this, TQT_SLOT(slotReenableAnimation()));
288  d->m_movie->restart();
289  d->m_movie->unpause();
290  }
291  }
292  else
293 #endif
294  {
295  TQMovie movie = KGlobal::iconLoader()->loadMovie( d->pActiveItem->mouseOverAnimation(), KIcon::Desktop, d->pActiveItem->iconSize() );
296  if ( !movie.isNull() )
297  {
298  delete d->m_movie;
299  d->m_movie = new TQMovie( movie ); // shallow copy, don't worry
300  // Fix alpha-channel - currently only if no background pixmap,
301  // the bg pixmap case requires to uncomment the code at qmovie.cpp:404
302  const TQPixmap* pm = backgroundPixmap();
303  bool hasPixmap = pm && !pm->isNull();
304  if ( !hasPixmap ) {
305  pm = viewport()->backgroundPixmap();
306  hasPixmap = pm && !pm->isNull();
307  }
308  if (!hasPixmap && backgroundMode() != NoBackground)
309  d->m_movie->setBackgroundColor( viewport()->backgroundColor() );
310  d->m_movie->connectUpdate( this, TQT_SLOT( slotMovieUpdate(const TQRect &) ) );
311  d->m_movie->connectStatus( TQT_TQOBJECT(this), TQT_SLOT( slotMovieStatus(int) ) );
312  d->movieFileName = d->pActiveItem->mouseOverAnimation();
313  d->pActiveItem->setAnimated( true );
314  }
315  else
316  {
317  d->pActiveItem->setAnimated( false );
318  if (d->m_movie)
319  d->m_movie->pause();
320  // No movie available, remember it
321  d->pActiveItem->setMouseOverAnimation( TQString::null );
322  }
323  }
324  } // animations
325  // Only do the normal "mouseover" effect if no animation is in use
326  if (d->pActiveItem && !d->pActiveItem->isAnimated())
327  {
328  d->pActiveItem->setActive( true );
329  }
330  }
331  else // No change in current item
332  {
333  // No effect. If we want to underline on hover, we should
334  // force the IVI to repaint here, though!
335  d->pActiveItem = 0L;
336  d->pFileTip->setItem( 0L );
337  }
338  } // bMousePressed
339  else
340  {
341  // All features disabled during mouse clicking, e.g. rectangular
342  // selection
343  d->pActiveItem = 0L;
344  d->pFileTip->setItem( 0L );
345  }
346 
347  // ## shouldn't this be disabled during rectangular selection too ?
348  if (d->bSoundPreviews && d->pSoundPlayer &&
349  d->pSoundPlayer->mimeTypes().contains(
350  item->item()->mimetype())
351  && KGlobalSettings::showFilePreview(item->item()->url())
352  && topLevelWidget() == kapp->activeWindow())
353  {
354  d->pSoundItem = item;
355  d->bSoundItemClicked = false;
356  if (!d->pSoundTimer)
357  {
358  d->pSoundTimer = new TQTimer(this);
359  connect(d->pSoundTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotStartSoundPreview()));
360  }
361  if (d->pSoundTimer->isActive())
362  d->pSoundTimer->stop();
363  d->pSoundTimer->start(500, true);
364  }
365  else
366  {
367  if (d->pSoundPlayer)
368  d->pSoundPlayer->stop();
369  d->pSoundItem = 0;
370  if (d->pSoundTimer && d->pSoundTimer->isActive())
371  d->pSoundTimer->stop();
372  }
373 }
374 
375 void KonqIconViewWidget::slotOnViewport()
376 {
377  d->pFileTip->setItem( 0L );
378 
379  if (d->pSoundPlayer)
380  d->pSoundPlayer->stop();
381  d->pSoundItem = 0;
382  if (d->pSoundTimer && d->pSoundTimer->isActive())
383  d->pSoundTimer->stop();
384 
385  if (d->pActiveItem == 0L)
386  return;
387 
388  if ( d->doAnimations && d->m_movie && d->pActiveItem->isAnimated() )
389  {
390  d->pActiveItem->setAnimated( false );
391 #if 0
392  // Aborting before the end of the animation ?
393  if (d->m_movie->running()) {
394  d->m_movie->pause();
395  d->m_movieBlocked++;
396  kdDebug(1203) << "on viewport, blocking" << endl;
397  TQTimer::singleShot(300, this, TQT_SLOT(slotReenableAnimation()));
398  }
399 #endif
400  d->pActiveItem->refreshIcon( true );
401  Q_ASSERT( d->pActiveItem->state() == KIcon::DefaultState );
402  //delete d->m_movie;
403  //d->m_movie = 0L;
404  // TODO a timer to delete the movie after some time if unused?
405  }
406  else
407  {
408  d->pActiveItem->setActive( false );
409  }
410  d->pActiveItem = 0L;
411 }
412 
413 void KonqIconViewWidget::slotStartSoundPreview()
414 {
415  if (!d->pSoundItem || d->bSoundItemClicked)
416  return;
417 
418  d->pSoundPlayer->play(d->pSoundItem->item()->url().url());
419 }
420 
421 
422 void KonqIconViewWidget::slotPreview(const KFileItem *item, const TQPixmap &pix)
423 {
424  // ### slow. Idea: move KonqKfmIconView's m_itemDict into this class
425  for (TQIconViewItem *it = firstItem(); it; it = it->nextItem())
426  {
427  KFileIVI* current = static_cast<KFileIVI *>(it);
428  if (current->item() == item)
429  {
430  if (item->overlays() & KIcon::HiddenOverlay) {
431  TQPixmap p(pix);
432 
433  KIconEffect::semiTransparent(p);
434  current->setThumbnailPixmap(p);
435  } else {
436  current->setThumbnailPixmap(pix);
437  }
438  break;
439  }
440  }
441 }
442 
443 void KonqIconViewWidget::slotPreviewResult()
444 {
445  d->pPreviewJob = 0;
446  emit imagePreviewFinished();
447 }
448 
449 void KonqIconViewWidget::slotToolTipPreview(const KFileItem* , const TQPixmap &)
450 {
451 // unused - remove for KDE4
452 }
453 
454 void KonqIconViewWidget::slotToolTipPreviewResult()
455 {
456 // unused - remove for KDE4
457 }
458 
459 void KonqIconViewWidget::slotMovieUpdate( const TQRect& rect )
460 {
461  //kdDebug(1203) << "KonqIconViewWidget::slotMovieUpdate " << rect.x() << "," << rect.y() << " " << rect.width() << "x" << rect.height() << endl;
462  Q_ASSERT( d );
463  Q_ASSERT( d->m_movie );
464  // seems stopAnimation triggers one last update
465  if ( d->pActiveItem && d->m_movie && d->pActiveItem->isAnimated() ) {
466  const TQPixmap &frame = d->m_movie->framePixmap();
467  // This can happen if the icon was scaled to the desired size, so KIconLoader
468  // will happily return a movie with different dimensions than the icon
469  int iconSize=d->pActiveItem->iconSize();
470  if (iconSize==0) iconSize = KGlobal::iconLoader()->currentSize( KIcon::Desktop );
471  if ( frame.width() != iconSize || frame.height() != iconSize ) {
472  d->pActiveItem->setAnimated( false );
473  d->m_movie->pause();
474  // No movie available, remember it
475  d->pActiveItem->setMouseOverAnimation( TQString::null );
476  d->pActiveItem->setActive( true );
477  return;
478  }
479  d->pActiveItem->setPixmapDirect( frame, false, false /*no redraw*/ );
480  TQRect pixRect = d->pActiveItem->pixmapRect(false);
481  repaintContents( pixRect.x() + rect.x(), pixRect.y() + rect.y(), rect.width(), rect.height(), false );
482  }
483 }
484 
485 void KonqIconViewWidget::slotMovieStatus( int status )
486 {
487  if ( status < 0 ) {
488  // Error playing the MNG -> forget about it and do normal iconeffect
489  if ( d->pActiveItem && d->pActiveItem->isAnimated() ) {
490  d->pActiveItem->setAnimated( false );
491  d->pActiveItem->setMouseOverAnimation( TQString::null );
492  d->pActiveItem->setActive( true );
493  }
494  }
495 }
496 
497 void KonqIconViewWidget::slotReenableAnimation()
498 {
499  if (!--d->m_movieBlocked) {
500  if ( d->pActiveItem && d->m_movie && d->m_movie->paused()) {
501  kdDebug(1203) << "reenabled animation" << endl;
502  d->m_movie->restart();
503  d->m_movie->unpause();
504  }
505  }
506 }
507 
508 void KonqIconViewWidget::clear()
509 {
510  d->pFileTip->setItem( 0L );
511  stopImagePreview(); // Just in case
512  KIconView::clear();
513  d->pActiveItem = 0L;
514 }
515 
516 void KonqIconViewWidget::takeItem( TQIconViewItem *item )
517 {
518  if ( d->pActiveItem == static_cast<KFileIVI *>(item) )
519  {
520  d->pFileTip->setItem( 0L );
521  d->pActiveItem = 0L;
522  }
523 
524  if ( d->pPreviewJob )
525  d->pPreviewJob->removeItem( static_cast<KFileIVI *>(item)->item() );
526 
527  KIconView::takeItem( item );
528 }
529 
530 // Currently unused - remove in KDE 4.0
531 void KonqIconViewWidget::setThumbnailPixmap( KFileIVI * item, const TQPixmap & pixmap )
532 {
533  if ( item )
534  {
535  if ( d->pActiveItem == item )
536  {
537  d->pFileTip->setItem( 0L );
538  d->pActiveItem = 0L;
539  }
540  item->setThumbnailPixmap( pixmap );
541  if ( m_bSetGridX && item->width() > gridX() )
542  {
543  setGridX( item->width() );
544  if (autoArrange())
545  arrangeItemsInGrid();
546  }
547  }
548 }
549 
550 bool KonqIconViewWidget::initConfig( bool bInit )
551 {
552  bool fontChanged = false;
553 
554  // Color settings
555  TQColor normalTextColor = m_pSettings->normalTextColor();
556  setItemColor( normalTextColor );
557 
558  if (m_bDesktop)
559  {
560  TQColor itemTextBg = m_pSettings->itemTextBackground();
561  if ( itemTextBg.isValid() )
562  setItemTextBackground( itemTextBg );
563  else
564  setItemTextBackground( Qt::NoBrush );
565  }
566 
567  bool on = m_pSettings->showFileTips() && TQToolTip::isGloballyEnabled();
568  d->pFileTip->setOptions(on,
569  m_pSettings->showPreviewsInFileTips(),
570  m_pSettings->numFileTips());
571 
572  // if the user wants our own tooltip, don't show the one from Qts ListView
573  setShowToolTips(!on);
574 
575  // Font settings
576  TQFont font( m_pSettings->standardFont() );
577  if (!m_bDesktop)
578  font.setUnderline( m_pSettings->underlineLink() );
579 
580  if ( font != KonqIconViewWidget::font() )
581  {
582  setFont( font );
583  if (!bInit)
584  {
585  // TQIconView doesn't do it by default... but if the font is made much
586  // bigger, we really need to give more space between the icons
587  fontChanged = true;
588  }
589  }
590 
591  setIconTextHeight( m_pSettings->iconTextHeight() );
592 
593  if ( (itemTextPos() == TQIconView::Right) && (maxItemWidth() != gridXValue()) )
594  {
595  int size = m_size;
596  m_size = -1; // little trick to force grid change in setIcons
597  setIcons( size ); // force re-determining all icons
598  }
599  else if ( d->bBoostPreview != boostPreview() ) // Update icons if settings for preview icon size have changed
600  setIcons(m_size);
601  else if (!bInit)
602  updateContents();
603  return fontChanged;
604 }
605 
606 bool KonqIconViewWidget::boostPreview() const
607 {
608  if ( m_bDesktop ) return false;
609 
610  KConfigGroup group( KGlobal::config(), "PreviewSettings" );
611  return group.readBoolEntry( "BoostSize", false );
612 }
613 
614 void KonqIconViewWidget::disableSoundPreviews()
615 {
616  d->bSoundPreviews = false;
617 
618  if (d->pSoundPlayer)
619  d->pSoundPlayer->stop();
620  d->pSoundItem = 0;
621  if (d->pSoundTimer && d->pSoundTimer->isActive())
622  d->pSoundTimer->stop();
623 }
624 
625 void KonqIconViewWidget::setIcons( int size, const TQStringList& stopImagePreviewFor )
626 {
627  // size has changed?
628  bool sizeChanged = (m_size != size);
629  int oldGridX = gridX();
630  m_size = size;
631 
632  // boost preview option has changed?
633  bool boost = boostPreview();
634  bool previewSizeChanged = ( d->bBoostPreview != boost );
635  d->bBoostPreview = boost;
636 
637  if ( sizeChanged || previewSizeChanged )
638  {
639  int realSize = size ? size : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
640  // choose spacing depending on font, but min 5 (due to KFileIVI move limit)
641  setSpacing( ( m_bDesktop || ( realSize > KIcon::SizeSmall ) ) ?
642  QMAX( 5, TQFontMetrics(font()).width('n') ) : 0 );
643  }
644 
645  if ( sizeChanged || previewSizeChanged || !stopImagePreviewFor.isEmpty() )
646  {
647  calculateGridX();
648  }
649  bool stopAll = !stopImagePreviewFor.isEmpty() && stopImagePreviewFor.first() == "*";
650 
651  // Disable repaints that can be triggered by ivi->setIcon(). Since icons are
652  // resized in-place, if the icon size is increasing it can happens that the right
653  // or bottom icons exceed the size of the viewport.. here we prevent the repaint
654  // event that will be triggered in that case.
655  bool prevUpdatesState = viewport()->isUpdatesEnabled();
656  viewport()->setUpdatesEnabled( false );
657 
658  // Do this even if size didn't change, since this is used by refreshMimeTypes...
659  for ( TQIconViewItem *it = firstItem(); it; it = it->nextItem() ) {
660  KFileIVI * ivi = static_cast<KFileIVI *>( it );
661  // Set a normal icon for files that are not thumbnails, and for files
662  // that are thumbnails but for which it should be stopped
663  if ( !ivi->isThumbnail() ||
664  sizeChanged ||
665  previewSizeChanged ||
666  stopAll ||
667  mimeTypeMatch( ivi->item()->mimetype(), stopImagePreviewFor ) )
668  {
669  ivi->setIcon( size, ivi->state(), true, false );
670  }
671  else
672  ivi->invalidateThumb( ivi->state(), true );
673  }
674 
675  // Restore viewport update to previous state
676  viewport()->setUpdatesEnabled( prevUpdatesState );
677 
678  if ( ( sizeChanged || previewSizeChanged || oldGridX != gridX() ||
679  !stopImagePreviewFor.isEmpty() ) && autoArrange() )
680  arrangeItemsInGrid( true ); // take new grid into account and repaint
681  else
682  viewport()->update(); //Repaint later..
683 }
684 
685 bool KonqIconViewWidget::mimeTypeMatch( const TQString& mimeType, const TQStringList& mimeList ) const
686 {
687  // Code duplication from KIO::PreviewJob
688  KMimeType::Ptr mime = KMimeType::mimeType( mimeType );
689  for (TQStringList::ConstIterator mt = mimeList.begin(); mt != mimeList.end(); ++mt)
690  {
691  if ( mime->is( *mt ) )
692  return true;
693  // Support for *mt == "image/*"
694  TQString tmp( mimeType );
695  if ( (*mt).endsWith("*") && tmp.replace(TQRegExp("/.*"), "/*") == (*mt) )
696  return true;
697  if ( (*mt) == "text/plain" )
698  {
699  TQVariant textProperty = mime->property( "X-KDE-text" );
700  if ( textProperty.type() == TQVariant::Bool && textProperty.toBool() )
701  return true;
702  }
703  }
704  return false;
705 }
706 
707 void KonqIconViewWidget::setItemTextPos( ItemTextPos pos )
708 {
709  // can't call gridXValue() because this already would need the new itemTextPos()
710  int sz = m_size ? m_size : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
711 
712  if ( m_bSetGridX )
713  if ( pos == TQIconView::Bottom )
714  setGridX( QMAX( sz + 50, previewIconSize( sz ) + 13 ) );
715  else
716  {
717  setMaxItemWidth( QMAX( sz, previewIconSize( sz ) ) + m_pSettings->iconTextWidth() );
718  setGridX( -1 );
719  }
720 
721  KIconView::setItemTextPos( pos );
722 }
723 
724 void KonqIconViewWidget::gridValues( int* x, int* y, int* dx, int* dy,
725  int* nx, int* ny )
726 {
727  int previewSize = previewIconSize( m_size );
728  int iconSize = m_size ? m_size : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
729 
730  // Grid size
731  // as KFileIVI limits to move an icon to x >= 5, y >= 5, we define a grid cell as:
732  // spacing() must be >= 5 (currently set to 5 in setIcons())
733  // horizontal: left spacing() + <width>
734  // vertical : top spacing(), <height>, bottom spacing()
735  // The doubled space in y-direction gives a better visual separation and makes it clearer
736  // to which item the text belongs
737  *dx = spacing() + QMAX( QMAX( iconSize, previewSize ), m_pSettings->iconTextWidth() );
738  int textHeight = iconTextHeight() * fontMetrics().height();
739  *dy = spacing() + QMAX( iconSize, previewSize ) + 2 + textHeight + spacing();
740 
741  // Icon Area
742  int w, h;
743  if ( m_IconRect.isValid() ) { // w and h must be != 0, otherwise we would get a div by zero
744  *x = m_IconRect.left(); w = m_IconRect.width();
745  *y = m_IconRect.top(); h = m_IconRect.height();
746  }
747  else {
748  *x = 0; w = viewport()->width();
749  *y = 0; h = viewport()->height();
750  }
751 
752  // bug:110775 avoid div by zero (happens e.g. when iconTextHeight or iconTextWidth are very large)
753  if ( *dx > w )
754  *dx = w;
755 
756  if ( *dy > h )
757  *dy = h;
758 
759  *nx = w / *dx;
760  *ny = h / *dy;
761  // TODO: Check that items->count() <= nx * ny
762 
763  // Let have exactly nx columns and ny rows
764  if(*nx && *ny) {
765  *dx = w / *nx;
766  *dy = h / *ny;
767  }
768  kdDebug(1203) << "x=" << *x << " y=" << *y << " spacing=" << spacing() << " iconSize=" << iconSize
769  << " w=" << w << " h=" << h
770  << " nx=" << *nx << " ny=" << *ny
771  << " dx=" << *dx << " dy=" << *dy << endl;
772 }
773 
774 void KonqIconViewWidget::calculateGridX()
775 {
776  if ( m_bSetGridX )
777  if ( itemTextPos() == TQIconView::Bottom )
778  setGridX( gridXValue() );
779  else
780  {
781  setMaxItemWidth( gridXValue() );
782  setGridX( -1 );
783  }
784 }
785 
786 int KonqIconViewWidget::gridXValue() const
787 {
788  // this method is only used in konqi as filemanager (not desktop)
789  int sz = m_size ? m_size : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
790  int newGridX;
791 
792  if ( itemTextPos() == TQIconView::Bottom )
793  newGridX = QMAX( sz + 50, previewIconSize( sz ) + 13 );
794  else
795  newGridX = QMAX( sz, previewIconSize( sz ) ) + m_pSettings->iconTextWidth();
796 
797  //kdDebug(1203) << "gridXValue: " << newGridX << " sz=" << sz << endl;
798  return newGridX;
799 }
800 
801 void KonqIconViewWidget::refreshMimeTypes()
802 {
803  updatePreviewMimeTypes();
804  for ( TQIconViewItem *it = firstItem(); it; it = it->nextItem() )
805  (static_cast<KFileIVI *>( it ))->item()->refreshMimeType();
806  setIcons( m_size );
807 }
808 
809 void KonqIconViewWidget::setURL( const KURL &kurl )
810 {
811  stopImagePreview();
812  m_url = kurl;
813 
814  d->pFileTip->setPreview( KGlobalSettings::showFilePreview(m_url) );
815 
816  if ( m_url.isLocalFile() )
817  m_dotDirectoryPath = m_url.path(1).append( ".directory" );
818  else
819  m_dotDirectoryPath = TQString::null;
820 }
821 
822 void KonqIconViewWidget::startImagePreview( const TQStringList &, bool force )
823 {
824  stopImagePreview(); // just in case
825 
826  // Check config
827  if ( !KGlobalSettings::showFilePreview( url() ) ) {
828  kdDebug(1203) << "Previews disabled for protocol " << url().protocol() << endl;
829  emit imagePreviewFinished();
830  return;
831  }
832 
833  if ((d->bSoundPreviews = d->previewSettings.contains( "audio/" )) &&
834  !d->pSoundPlayer)
835  {
836  KLibFactory *factory = KLibLoader::self()->factory("konq_sound");
837  if (factory)
838  d->pSoundPlayer = static_cast<KonqSoundPlayer *>(
839  factory->create(TQT_TQOBJECT(this), 0, "KonqSoundPlayer"));
840  d->bSoundPreviews = (d->pSoundPlayer != 0L);
841  }
842 
843  KFileItemList items;
844  for ( TQIconViewItem *it = firstItem(); it; it = it->nextItem() )
845  if ( force || !static_cast<KFileIVI *>( it )->hasValidThumbnail() )
846  items.append( static_cast<KFileIVI *>( it )->item() );
847 
848  bool onlyAudio = true;
849  for ( TQStringList::ConstIterator it = d->previewSettings.begin(); it != d->previewSettings.end(); ++it ) {
850  if ( (*it).startsWith( "audio/" ) )
851  d->bSoundPreviews = true;
852  else
853  onlyAudio = false;
854  }
855 
856  if ( items.isEmpty() || onlyAudio ) {
857  emit imagePreviewFinished();
858  return; // don't start the preview job if not really necessary
859  }
860 
861  int iconSize = m_size ? m_size : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
862  int size;
863 
864  d->bBoostPreview = boostPreview();
865  size = previewIconSize( iconSize );
866 
867  if ( !d->bBoostPreview )
868  iconSize /= 2;
869 
870  d->pPreviewJob = KIO::filePreview( items, size, size, iconSize,
871  m_pSettings->textPreviewIconTransparency(), true /* scale */,
872  true /* save */, &(d->previewSettings) );
873  connect( d->pPreviewJob, TQT_SIGNAL( gotPreview( const KFileItem *, const TQPixmap & ) ),
874  this, TQT_SLOT( slotPreview( const KFileItem *, const TQPixmap & ) ) );
875  connect( d->pPreviewJob, TQT_SIGNAL( result( KIO::Job * ) ),
876  this, TQT_SLOT( slotPreviewResult() ) );
877 }
878 
879 void KonqIconViewWidget::stopImagePreview()
880 {
881  if (d->pPreviewJob)
882  {
883  d->pPreviewJob->kill();
884  d->pPreviewJob = 0;
885  // Now that previews are updated in-place, calling
886  // arrangeItemsInGrid() here is not needed anymore
887  }
888 }
889 
890 bool KonqIconViewWidget::isPreviewRunning() const
891 {
892  return d->pPreviewJob;
893 }
894 
895 KFileItemList KonqIconViewWidget::selectedFileItems()
896 {
897  KFileItemList lstItems;
898 
899  TQIconViewItem *it = firstItem();
900  for (; it; it = it->nextItem() )
901  if ( it->isSelected() ) {
902  KFileItem *fItem = (static_cast<KFileIVI *>(it))->item();
903  lstItems.append( fItem );
904  }
905  return lstItems;
906 }
907 
908 void KonqIconViewWidget::slotDropped( TQDropEvent *ev, const TQValueList<TQIconDragItem> & )
909 {
910  // Drop on background
911  KURL dirURL = url();
912  if ( m_rootItem ) {
913  bool dummy;
914  dirURL = m_rootItem->mostLocalURL(dummy);
915  }
916  KonqOperations::doDrop( m_rootItem /* may be 0L */, dirURL, ev, this );
917 }
918 
919 void KonqIconViewWidget::slotAboutToCreate(const TQPoint &, const TQValueList<KIO::CopyInfo> &)
920 {
921  // Do nothing :-)
922 }
923 
924 void KonqIconViewWidget::drawBackground( TQPainter *p, const TQRect &r )
925 {
926  drawBackground(p, r, r.topLeft());
927 }
928 
929 void KonqIconViewWidget::drawBackground( TQPainter *p, const TQRect &r , const TQPoint &pt)
930 {
931  const TQPixmap *pm = backgroundPixmap();
932  bool hasPixmap = pm && !pm->isNull();
933  if ( !hasPixmap ) {
934  pm = viewport()->backgroundPixmap();
935  hasPixmap = pm && !pm->isNull();
936  }
937 
938  TQRect rtgt(r);
939  rtgt.moveTopLeft(pt);
940  if (!hasPixmap && backgroundMode() != NoBackground) {
941  p->fillRect(rtgt, viewport()->backgroundColor());
942  return;
943  }
944 
945  if (hasPixmap) {
946  int ax = (r.x() + contentsX() + leftMargin()) % pm->width();
947  int ay = (r.y() + contentsY() + topMargin()) % pm->height();
948  p->drawTiledPixmap(rtgt, *pm, TQPoint(ax, ay));
949  }
950 }
951 
952 TQDragObject * KonqIconViewWidget::dragObject()
953 {
954  if ( !currentItem() )
955  return 0;
956 
957  return konqDragObject( viewport() );
958 }
959 
960 KonqIconDrag * KonqIconViewWidget::konqDragObject( TQWidget * dragSource )
961 {
962  //kdDebug(1203) << "KonqIconViewWidget::konqDragObject" << endl;
963 
964  KonqIconDrag2 * drag = new KonqIconDrag2( dragSource );
965  TQIconViewItem *primaryItem = currentItem();
966  // Append all items to the drag object
967  for ( TQIconViewItem *it = firstItem(); it; it = it->nextItem() ) {
968  if ( it->isSelected() ) {
969  if (!primaryItem)
970  primaryItem = it;
971  KFileItem* fileItem = (static_cast<KFileIVI *>(it))->item();
972  KURL url = fileItem->url();
973  bool dummy;
974  KURL mostLocalURL = fileItem->mostLocalURL(dummy);
975  TQString itemURL = KURLDrag::urlToString(url);
976  kdDebug(1203) << "itemURL=" << itemURL << endl;
977  TQIconDragItem id;
978  id.setData( TQCString(itemURL.latin1()) );
979  drag->append( id,
980  TQRect( it->pixmapRect(false).topLeft() - m_mousePos,
981  it->pixmapRect().size() ),
982  TQRect( it->textRect(false).topLeft() - m_mousePos,
983  it->textRect().size() ),
984  itemURL, mostLocalURL );
985  }
986  }
987 
988  if (primaryItem)
989  drag->setPixmap( *primaryItem->pixmap(), m_mousePos - primaryItem->pixmapRect(false).topLeft() );
990 
991  return drag;
992 }
993 
994 void KonqIconViewWidget::contentsDragEnterEvent( TQDragEnterEvent *e )
995 {
996  if ( e->provides( "text/uri-list" ) )
997  {
998  TQByteArray payload = e->encodedData( "text/uri-list" );
999  if ( !payload.size() )
1000  kdError() << "Empty data !" << endl;
1001  // Cache the URLs, since we need them every time we move over a file
1002  // (see KFileIVI)
1003  bool ok = KURLDrag::decode( e, m_lstDragURLs );
1004  if( !ok )
1005  kdError() << "Couldn't decode urls dragged !" << endl;
1006  }
1007 
1008  KURL::List uriList;
1009  if ( KURLDrag::decode(e, uriList) )
1010  {
1011  if ( uriList.first().protocol() == "programs" )
1012  {
1013  e->ignore();
1014  emit dragEntered( false );
1015  d->bProgramsURLdrag = true;
1016  return;
1017  }
1018  }
1019 
1020  KIconView::contentsDragEnterEvent( e );
1021  emit dragEntered( true /*accepted*/ );
1022 }
1023 
1024 void KonqIconViewWidget::contentsDragMoveEvent( TQDragMoveEvent *e )
1025 {
1026  if ( d->bProgramsURLdrag ) {
1027  emit dragMove( false );
1028  e->ignore();
1029  cancelPendingHeldSignal();
1030  return;
1031  }
1032 
1033  TQIconViewItem *item = findItem( e->pos() );
1034  if ( e->source() != viewport() &&
1035  !item && m_rootItem && !m_rootItem->isWritable() ) {
1036  emit dragMove( false );
1037  e->ignore();
1038  cancelPendingHeldSignal();
1039  return;
1040  }
1041  emit dragMove( true );
1042  KIconView::contentsDragMoveEvent( e );
1043 }
1044 
1045 void KonqIconViewWidget::contentsDragLeaveEvent( TQDragLeaveEvent *e )
1046 {
1047  d->bProgramsURLdrag = false;
1048  KIconView::contentsDragLeaveEvent(e);
1049  emit dragLeft();
1050 }
1051 
1052 
1053 void KonqIconViewWidget::setItemColor( const TQColor &c )
1054 {
1055  iColor = c;
1056 }
1057 
1058 TQColor KonqIconViewWidget::itemColor() const
1059 {
1060  return iColor;
1061 }
1062 
1063 void KonqIconViewWidget::disableIcons( const KURL::List & lst )
1064 {
1065  for ( TQIconViewItem *kit = firstItem(); kit; kit = kit->nextItem() )
1066  {
1067  bool bFound = false;
1068  // Wow. This is ugly. Matching two lists together....
1069  // Some sorting to optimise this would be a good idea ?
1070  for (KURL::List::ConstIterator it = lst.begin(); !bFound && it != lst.end(); ++it)
1071  {
1072  if ( static_cast<KFileIVI *>( kit )->item()->url() == *it )
1073  {
1074  bFound = true;
1075  // maybe remove "it" from lst here ?
1076  }
1077  }
1078  static_cast<KFileIVI *>( kit )->setDisabled( bFound );
1079  }
1080 }
1081 
1082 void KonqIconViewWidget::slotSelectionChanged()
1083 {
1084  // This code is very related to ListViewBrowserExtension::updateActions
1085  int canCopy = 0;
1086  int canDel = 0;
1087  int canTrash = 0;
1088  bool bInTrash = false;
1089  int iCount = 0;
1090 
1091  for ( TQIconViewItem *it = firstItem(); it; it = it->nextItem() )
1092  {
1093  if ( it->isSelected() )
1094  {
1095  iCount++;
1096  canCopy++;
1097 
1098  KFileItem *item = ( static_cast<KFileIVI *>( it ) )->item();
1099  KURL url = item->url();
1100  TQString local_path = item->localPath();
1101 
1102  if ( url.directory(false) == KGlobalSettings::trashPath() )
1103  bInTrash = true;
1104  if ( KProtocolInfo::supportsDeleting( url ) )
1105  canDel++;
1106  if ( !local_path.isEmpty() )
1107  canTrash++;
1108  }
1109  }
1110 
1111  emit enableAction( "cut", canDel > 0 );
1112  emit enableAction( "copy", canCopy > 0 );
1113  emit enableAction( "trash", canDel > 0 && !bInTrash && canTrash==canDel );
1114  emit enableAction( "del", canDel > 0 );
1115  emit enableAction( "properties", iCount > 0 && KPropertiesDialog::canDisplay( selectedFileItems() ) );
1116  emit enableAction( "editMimeType", ( iCount == 1 ) );
1117  emit enableAction( "rename", ( iCount == 1) && !bInTrash );
1118 }
1119 
1120 void KonqIconViewWidget::renameCurrentItem()
1121 {
1122  if ( currentItem() )
1123  currentItem()->rename();
1124 }
1125 
1126 void KonqIconViewWidget::renameSelectedItem()
1127 {
1128  kdDebug(1203) << " -- KonqIconViewWidget::renameSelectedItem() -- " << endl;
1129  TQIconViewItem * item = 0L;
1130  TQIconViewItem *it = firstItem();
1131  for (; it; it = it->nextItem() )
1132  if ( it->isSelected() && !item )
1133  {
1134  item = it;
1135  break;
1136  }
1137  if (!item)
1138  {
1139  Q_ASSERT(item);
1140  return;
1141  }
1142  item->rename();
1143 }
1144 
1145 void KonqIconViewWidget::cutSelection()
1146 {
1147  kdDebug(1203) << " -- KonqIconViewWidget::cutSelection() -- " << endl;
1148  KonqIconDrag * obj = konqDragObject( /* no parent ! */ );
1149  obj->setMoveSelection( true );
1150  TQApplication::clipboard()->setData( obj );
1151 }
1152 
1153 void KonqIconViewWidget::copySelection()
1154 {
1155  kdDebug(1203) << " -- KonqIconViewWidget::copySelection() -- " << endl;
1156  KonqIconDrag * obj = konqDragObject( /* no parent ! */ );
1157  TQApplication::clipboard()->setData( obj );
1158 }
1159 
1160 void KonqIconViewWidget::pasteSelection()
1161 {
1162  paste( url() );
1163 }
1164 
1165 void KonqIconViewWidget::paste( const KURL &url )
1166 {
1167  KonqOperations::doPaste( this, url );
1168 }
1169 
1170 KURL::List KonqIconViewWidget::selectedUrls()
1171 {
1172  return selectedUrls( UserVisibleUrls );
1173 }
1174 
1175 KURL::List KonqIconViewWidget::selectedUrls( UrlFlags flags ) const
1176 {
1177  KURL::List lstURLs;
1178  bool dummy;
1179  for ( TQIconViewItem *it = firstItem(); it; it = it->nextItem() )
1180  if ( it->isSelected() ) {
1181  KFileItem* item = (static_cast<KFileIVI *>( it ))->item();
1182  lstURLs.append( flags == MostLocalUrls ? item->mostLocalURL( dummy ) : item->url() );
1183  }
1184  return lstURLs;
1185 }
1186 
1187 TQRect KonqIconViewWidget::iconArea() const
1188 {
1189  return m_IconRect;
1190 }
1191 
1192 void KonqIconViewWidget::setIconArea(const TQRect &rect)
1193 {
1194  m_IconRect = rect;
1195 }
1196 
1197 int KonqIconViewWidget::lineupMode() const
1198 {
1199  return m_LineupMode;
1200 }
1201 
1202 void KonqIconViewWidget::setLineupMode(int mode)
1203 {
1204  m_LineupMode = mode;
1205 }
1206 
1207 bool KonqIconViewWidget::sortDirectoriesFirst() const
1208 {
1209  return m_bSortDirsFirst;
1210 }
1211 
1212 void KonqIconViewWidget::setSortDirectoriesFirst( bool b )
1213 {
1214  m_bSortDirsFirst = b;
1215 }
1216 
1217 void KonqIconViewWidget::contentsMouseMoveEvent( TQMouseEvent *e )
1218 {
1219  if ( (d->pSoundPlayer && d->pSoundPlayer->isPlaying()) || (d->pSoundTimer && d->pSoundTimer->isActive()))
1220  {
1221  // The following call is SO expensive (the ::widgetAt call eats up to 80%
1222  // of the mouse move cpucycles!), so it's mandatory to place that function
1223  // under strict checks, such as d->pSoundPlayer->isPlaying()
1224  if ( TQApplication::widgetAt( TQCursor::pos() ) != topLevelWidget() )
1225  {
1226  if (d->pSoundPlayer)
1227  d->pSoundPlayer->stop();
1228  d->pSoundItem = 0;
1229  if (d->pSoundTimer && d->pSoundTimer->isActive())
1230  d->pSoundTimer->stop();
1231  }
1232  }
1233  d->renameItem= false;
1234  KIconView::contentsMouseMoveEvent( e );
1235 }
1236 
1237 void KonqIconViewWidget::contentsDropEvent( TQDropEvent * ev )
1238 {
1239  TQIconViewItem *i = findItem( ev->pos() );
1240  KURL::List uriList;
1241 
1242  if ( ev->source() != viewport() &&
1243  !i && m_rootItem && !m_rootItem->isWritable() ) {
1244  ev->accept( false );
1245  return;
1246  }
1247 
1248  // Short-circuit TQIconView if Ctrl is pressed, so that it's possible
1249  // to drop a file into its own parent widget to copy it.
1250  if ( !i && (ev->action() == TQDropEvent::Copy || ev->action() == TQDropEvent::Link)
1251  && ev->source() && ev->source() == viewport()
1252  && KURLDrag::decode(ev, uriList) && !uriList.isEmpty()
1253  && uriList.first().upURL().url(1) == url().url(1))
1254  {
1255  // First we need to call TQIconView though, to clear the drag shape
1256  bool bMovable = itemsMovable();
1257  setItemsMovable(false); // hack ? call it what you want :-)
1258  KIconView::contentsDropEvent( ev );
1259  setItemsMovable(bMovable);
1260 
1261  TQValueList<TQIconDragItem> lst;
1262  slotDropped(ev, lst);
1263  }
1264  else
1265  {
1266  KIconView::contentsDropEvent( ev );
1267  emit dropped(); // What is this for ? (David) KDE4: remove
1268  }
1269  // Don't do this here, it's too early !
1270  // slotSaveIconPositions();
1271  // If we want to save after the new file gets listed, though,
1272  // we could reimplement contentsDropEvent in KDIconView and set m_bNeedSave. Bah.
1273 
1274  // This signal is sent last because we need to ensure it is
1275  // taken in account when all the slots triggered by the dropped() signal
1276  // are executed. This way we know that the Drag and Drop is truely finished
1277  emit dragFinished();
1278 }
1279 
1280 void KonqIconViewWidget::doubleClickTimeout()
1281 {
1282  d->renameItem= true;
1283  mousePressChangeValue();
1284  if ( d->releaseMouseEvent )
1285  {
1286  TQMouseEvent e( TQEvent::MouseButtonPress,d->mousePos , 1, d->mouseState);
1287  TQIconViewItem* item = findItem( e.pos() );
1288  KURL url;
1289  if ( item )
1290  {
1291  url= ( static_cast<KFileIVI *>( item ) )->item()->url();
1292  bool brenameTrash =false;
1293  if ( url.isLocalFile() && (url.directory(false) == KGlobalSettings::trashPath() || url.path(1).startsWith(KGlobalSettings::trashPath())))
1294  brenameTrash = true;
1295 
1296  if ( url.isLocalFile() && !brenameTrash && d->renameItem && m_pSettings->renameIconDirectly() && e.button() == Qt::LeftButton && item->textRect( false ).contains(e.pos()))
1297  {
1298  if( d->pActivateDoubleClick->isActive () )
1299  d->pActivateDoubleClick->stop();
1300  item->rename();
1301  m_bMousePressed = false;
1302  }
1303  }
1304  }
1305  else
1306  {
1307  TQMouseEvent e( TQEvent::MouseMove,d->mousePos , 1, d->mouseState);
1308  KIconView::contentsMousePressEvent( &e );
1309  }
1310  if( d->pActivateDoubleClick->isActive() )
1311  d->pActivateDoubleClick->stop();
1312 
1313  d->releaseMouseEvent = false;
1314  d->renameItem= false;
1315 }
1316 
1317 void KonqIconViewWidget::wheelEvent(TQWheelEvent* e)
1318 {
1319  // when scrolling with mousewheel, stop possible pending filetip
1320  d->pFileTip->setItem( 0 );
1321 
1322  if (e->state() == ControlButton)
1323  {
1324  if (e->delta() >= 0)
1325  {
1326  emit incIconSize();
1327  }
1328  else
1329  {
1330  emit decIconSize();
1331  }
1332  e->accept();
1333  return;
1334  }
1335 
1336  KIconView::wheelEvent(e);
1337 }
1338 
1339 void KonqIconViewWidget::leaveEvent( TQEvent *e )
1340 {
1341  // when leaving the widget, stop possible pending filetip and icon effect
1342  slotOnViewport();
1343 
1344  KIconView::leaveEvent(e);
1345 }
1346 
1347 void KonqIconViewWidget::mousePressChangeValue()
1348 {
1349  //kdDebug(1203) << "KonqIconViewWidget::contentsMousePressEvent" << endl;
1350  m_bMousePressed = true;
1351  if (d->pSoundPlayer)
1352  d->pSoundPlayer->stop();
1353  d->bSoundItemClicked = true;
1354  d->firstClick = false;
1355 
1356  // Once we click on the item, we don't want a tooltip
1357  // Fixes part of #86968
1358  d->pFileTip->setItem( 0 );
1359 }
1360 
1361 void KonqIconViewWidget::contentsMousePressEvent( TQMouseEvent *e )
1362 {
1363  if(d->pActivateDoubleClick && d->pActivateDoubleClick->isActive ())
1364  d->pActivateDoubleClick->stop();
1365  TQIconViewItem* item = findItem( e->pos() );
1366  m_mousePos = e->pos();
1367  KURL url;
1368  if ( item )
1369  {
1370  url = ( static_cast<KFileIVI *>( item ) )->item()->url();
1371  bool brenameTrash =false;
1372  if ( url.isLocalFile() && (url.directory(false) == KGlobalSettings::trashPath() || url.path(1).startsWith(KGlobalSettings::trashPath())))
1373  brenameTrash = true;
1374  if ( !brenameTrash && !KGlobalSettings::singleClick() && m_pSettings->renameIconDirectly() && e->button() == Qt::LeftButton && item->textRect( false ).contains(e->pos())&& !d->firstClick && url.isLocalFile() && (!url.protocol().find("device", 0, false)==0))
1375  {
1376  d->firstClick = true;
1377  d->mousePos = e->pos();
1378  d->mouseState = e->state();
1379  if (!d->pActivateDoubleClick)
1380  {
1381  d->pActivateDoubleClick = new TQTimer(this);
1382  connect(d->pActivateDoubleClick, TQT_SIGNAL(timeout()), this, TQT_SLOT(doubleClickTimeout()));
1383  }
1384  if( d->pActivateDoubleClick->isActive () )
1385  d->pActivateDoubleClick->stop();
1386  else
1387  d->pActivateDoubleClick->start(TQApplication::doubleClickInterval());
1388  d->releaseMouseEvent = false;
1389  return;
1390  }
1391  else
1392  d->renameItem= false;
1393  }
1394  else
1395  d->renameItem= false;
1396  mousePressChangeValue();
1397  if(d->pActivateDoubleClick && d->pActivateDoubleClick->isActive())
1398  d->pActivateDoubleClick->stop();
1399  KIconView::contentsMousePressEvent( e );
1400 
1401 }
1402 
1403 void KonqIconViewWidget::contentsMouseReleaseEvent( TQMouseEvent *e )
1404 {
1405  KIconView::contentsMouseReleaseEvent( e );
1406  if(d->releaseMouseEvent && d->pActivateDoubleClick && d->pActivateDoubleClick->isActive ())
1407  d->pActivateDoubleClick->stop();
1408  slotSelectionChanged();
1409  d->releaseMouseEvent = true;
1410  m_bMousePressed = false;
1411 }
1412 
1413 void KonqIconViewWidget::slotSaveIconPositions()
1414 {
1415  // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
1416  // This code is currently not used but left in for compatibility reasons.
1417  // It can be removed in KDE 4.0
1418  // Saving of desktop icon positions is now done in KDIconView::saveIconPositions()
1419  // in kdebase/kdesktop/kdiconview.cc
1420  // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
1421 
1422  if ( m_dotDirectoryPath.isEmpty() )
1423  return;
1424  if ( !m_bDesktop )
1425  return; // Currently not available in Konqueror
1426  kdDebug(1214) << "KonqIconViewWidget::slotSaveIconPositions" << endl;
1427  KSimpleConfig dotDirectory( m_dotDirectoryPath );
1428  TQIconViewItem *it = firstItem();
1429  if ( !it )
1430  return; // No more icons. Maybe we're closing and they've been removed already
1431  while ( it )
1432  {
1433  KFileIVI *ivi = static_cast<KFileIVI *>( it );
1434  KFileItem *item = ivi->item();
1435 
1436  dotDirectory.setGroup( TQString( m_iconPositionGroupPrefix ).append( item->url().fileName() ) );
1437  kdDebug(1214) << "KonqIconViewWidget::slotSaveIconPositions " << item->url().fileName() << " " << it->x() << " " << it->y() << endl;
1438  dotDirectory.writeEntry( TQString( "X %1" ).arg( width() ), it->x() );
1439  dotDirectory.writeEntry( TQString( "Y %1" ).arg( height() ), it->y() );
1440  dotDirectory.writeEntry( "Exists", true );
1441 
1442  it = it->nextItem();
1443  }
1444 
1445  TQStringList groups = dotDirectory.groupList();
1446  TQStringList::ConstIterator gIt = groups.begin();
1447  TQStringList::ConstIterator gEnd = groups.end();
1448  for (; gIt != gEnd; ++gIt )
1449  if ( (*gIt).left( m_iconPositionGroupPrefix.length() ) == m_iconPositionGroupPrefix )
1450  {
1451  dotDirectory.setGroup( *gIt );
1452  if ( dotDirectory.hasKey( "Exists" ) )
1453  dotDirectory.deleteEntry( "Exists", false );
1454  else
1455  {
1456  kdDebug(1214) << "KonqIconViewWidget::slotSaveIconPositions deleting group " << *gIt << endl;
1457  dotDirectory.deleteGroup( *gIt );
1458  }
1459  }
1460 
1461  dotDirectory.sync();
1462 
1463  // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
1464  // This code is currently not used but left in for compatibility reasons.
1465  // It can be removed in KDE 4.0
1466  // Saving of desktop icon positions is now done in KDIconView::saveIconPositions()
1467  // in kdebase/kdesktop/kdiconview.cc
1468  // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
1469 }
1470 
1471 // Adapted version of TQIconView::insertInGrid, that works relative to
1472 // m_IconRect, instead of the entire viewport.
1473 
1474 void KonqIconViewWidget::insertInGrid(TQIconViewItem *item)
1475 {
1476  if (0L == item)
1477  return;
1478 
1479  if (!m_IconRect.isValid())
1480  {
1481  KIconView::insertInGrid(item);
1482  return;
1483  }
1484 
1485  TQRegion r(m_IconRect);
1486  TQIconViewItem *i = firstItem();
1487  int y = -1;
1488  for (; i; i = i->nextItem() )
1489  {
1490  r = r.subtract(i->rect());
1491  y = QMAX(y, i->y() + i->height());
1492  }
1493 
1494  TQMemArray<TQRect> rects = r.rects();
1495  TQMemArray<TQRect>::Iterator it = rects.begin();
1496  bool foundPlace = FALSE;
1497  for (; it != rects.end(); ++it)
1498  {
1499  TQRect rect = *it;
1500  if (rect.width() >= item->width() && rect.height() >= item->height())
1501  {
1502  int sx = 0, sy = 0;
1503  if (rect.width() >= item->width() + spacing())
1504  sx = spacing();
1505  if (rect.height() >= item->height() + spacing())
1506  sy = spacing();
1507  item->move(rect.x() + sx, rect.y() + sy);
1508  foundPlace = true;
1509  break;
1510  }
1511  }
1512 
1513  if (!foundPlace)
1514  item->move(m_IconRect.topLeft());
1515 
1516  //item->dirty = false;
1517  return;
1518 }
1519 
1520 
1521 /*
1522  * The algorithm used for lineing up the icons could be called
1523  * "beating flat the icon field". Imagine the icon field to be some height
1524  * field on a regular grid, with the height being the number of icons in
1525  * each grid element. Now imagine slamming on the field with a shovel or
1526  * some other flat surface. The high peaks will be flattened and spread out
1527  * over their adjacent areas. This is basically what the algorithm tries to
1528  * simulate.
1529  *
1530  * First, the icons are binned to a grid of the desired size. If all bins
1531  * are containing at most one icon, we're done, of course. We just have to
1532  * move all icons to the center of each grid element.
1533  * For each bin which has more than one icon in it, we calculate 4
1534  * "friction coefficients", one for each cardinal direction. The friction
1535  * coefficient of a direction is the number of icons adjacent in that
1536  * direction. The idea is that this number is somewhat a measure in which
1537  * direction the icons should flow: icons flow in the direction of lowest
1538  * friction coefficient. We move a maximum of one icon per bin and loop over
1539  * all bins. This procedure is repeated some maximum number of times or until
1540  * no icons are moved anymore.
1541  *
1542  * I don't know if this algorithm is good or bad, I don't even know if it will
1543  * work all the time. It seems a correct thing to do, however, and it seems to
1544  * work particularly well. In any case, the number of runs is limited so there
1545  * can be no races.
1546  */
1547 
1548 void KonqIconViewWidget::lineupIcons()
1549 {
1550  // even if there are no items yet, calculate the maxItemWidth to have the correct
1551  // item rect when we insert new items
1552 
1553  // Create a grid of (ny x nx) bins.
1554  int x0, y0, dx, dy, nx, ny;
1555  gridValues( &x0, &y0, &dx, &dy, &nx, &ny );
1556 
1557  int itemWidth = dx - spacing();
1558  bool newItemWidth = false;
1559  if ( maxItemWidth() != itemWidth ) {
1560  newItemWidth = true;
1561  setMaxItemWidth( itemWidth );
1562  setFont( font() ); // Force calcRect()
1563  }
1564 
1565  if ( !firstItem() ) {
1566  kdDebug(1203) << "No icons at all ?\n";
1567  return;
1568  }
1569 
1570  int iconSize = m_size ? m_size : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
1571 
1572  typedef TQValueList<TQIconViewItem*> Bin;
1573  Bin*** bins = new Bin**[nx];
1574  int i;
1575  int j;
1576  for ( i = 0; i < nx ; i++ ) {
1577  bins[i] = new Bin*[ny];
1578  for ( j = 0; j < ny; j++ )
1579  bins[i][j] = 0L;
1580  }
1581 
1582  // Insert items into grid
1583  int textHeight = iconTextHeight() * fontMetrics().height();
1584 
1585  for ( TQIconViewItem* item = firstItem(); item; item = item->nextItem() ) {
1586  int x = item->x() + item->width() / 2 - x0;
1587  int y = item->pixmapRect( false ).bottom() - iconSize / 2
1588  - ( dy - ( iconSize + textHeight ) ) / 2 - y0;
1589  int posX = QMIN( nx-1, QMAX( 0, x / dx ) );
1590  int posY = QMIN( ny-1, QMAX( 0, y / dy ) );
1591 
1592  if ( !bins[posX][posY] )
1593  bins[posX][posY] = new Bin;
1594  bins[posX][posY]->prepend( item );
1595  }
1596 
1597  // The shuffle code
1598  int n, k;
1599  const int infinity = 10000;
1600  int nmoves = 1;
1601  for ( n = 0; n < 30 && nmoves > 0; n++ ) {
1602  nmoves = 0;
1603  for ( i = 0; i < nx; i++ ) {
1604  for ( j = 0; j < ny; j++ ) {
1605  if ( !bins[i][j] || ( bins[i][j]->count() <= 1 ) )
1606  continue;
1607 
1608  // Calculate the 4 "friction coefficients".
1609  int tf = 0, bf = 0, lf = 0, rf = 0;
1610  for ( k = j-1; k >= 0 && bins[i][k] && bins[i][k]->count(); k-- )
1611  tf += bins[i][k]->count();
1612  if ( k == -1 )
1613  tf += infinity;
1614 
1615  for ( k = j+1; k < ny && bins[i][k] && bins[i][k]->count(); k++ )
1616  bf += bins[i][k]->count();
1617  if ( k == ny )
1618  bf += infinity;
1619 
1620  for ( k = i-1; k >= 0 && bins[k][j] && bins[k][j]->count(); k-- )
1621  lf += bins[k][j]->count();
1622  if ( k == -1 )
1623  lf += infinity;
1624 
1625  for ( k = i+1; k < nx && bins[k][j] && bins[k][j]->count(); k++ )
1626  rf += bins[k][j]->count();
1627  if ( k == nx )
1628  rf += infinity;
1629 
1630  // If we are stuck between walls, continue
1631  if ( tf >= infinity && bf >= infinity &&
1632  lf >= infinity && rf >= infinity )
1633  continue;
1634 
1635  // Is there a preferred lineup direction?
1636  if ( m_LineupMode == LineupHorizontal ) {
1637  tf += infinity;
1638  bf += infinity;
1639  }
1640  else if ( m_LineupMode == LineupVertical ) {
1641  lf += infinity;
1642  rf += infinity;
1643  }
1644 
1645  // Move one item in the direction of the least friction
1646  TQIconViewItem* movedItem;
1647  Bin* items = bins[i][j];
1648 
1649  int mini = QMIN( QMIN( tf, bf ), QMIN( lf, rf ) );
1650  if ( tf == mini ) {
1651  // move top item in (i,j) to (i,j-1)
1652  Bin::iterator it = items->begin();
1653  movedItem = *it;
1654  for ( ++it; it != items->end(); ++it ) {
1655  if ( (*it)->y() < movedItem->y() )
1656  movedItem = *it;
1657  }
1658  items->remove( movedItem );
1659  if ( !bins[i][j-1] )
1660  bins[i][j-1] = new Bin;
1661  bins[i][j-1]->prepend( movedItem );
1662  }
1663  else if ( bf ==mini ) {
1664  // move bottom item in (i,j) to (i,j+1)
1665  Bin::iterator it = items->begin();
1666  movedItem = *it;
1667  for ( ++it; it != items->end(); ++it ) {
1668  if ( (*it)->y() > movedItem->y() )
1669  movedItem = *it;
1670  }
1671  items->remove( movedItem );
1672  if ( !bins[i][j+1] )
1673  bins[i][j+1] = new Bin;
1674  bins[i][j+1]->prepend( movedItem );
1675  }
1676  else if ( lf == mini )
1677  {
1678  // move left item in (i,j) to (i-1,j)
1679  Bin::iterator it = items->begin();
1680  movedItem = *it;
1681  for ( ++it; it != items->end(); ++it ) {
1682  if ( (*it)->x() < movedItem->x() )
1683  movedItem = *it;
1684  }
1685  items->remove( movedItem );
1686  if ( !bins[i-1][j] )
1687  bins[i-1][j] = new Bin;
1688  bins[i-1][j]->prepend( movedItem );
1689  }
1690  else {
1691  // move right item in (i,j) to (i+1,j)
1692  Bin::iterator it = items->begin();
1693  movedItem = *it;
1694  for ( ++it; it != items->end(); ++it ) {
1695  if ( (*it)->x() > movedItem->x() )
1696  movedItem = *it;
1697  }
1698  items->remove( movedItem );
1699  if ( !bins[i+1][j] )
1700  bins[i+1][j] = new Bin;
1701  bins[i+1][j]->prepend( movedItem );
1702  }
1703  nmoves++;
1704  }
1705  }
1706  }
1707 
1708  // Perform the actual moving
1709  TQRegion repaintRegion;
1710  TQValueList<TQIconViewItem*> movedItems;
1711 
1712  for ( i = 0; i < nx; i++ ) {
1713  for ( j = 0; j < ny; j++ ) {
1714  Bin* bin = bins[i][j];
1715  if ( !bin )
1716  continue;
1717  if ( !bin->isEmpty() ) {
1718  TQIconViewItem* item = bin->first();
1719  int newX = x0 + i*dx + spacing() +
1720  QMAX(0, ( (dx-spacing()) - item->width() ) / 2); // pixmap can be larger as iconsize
1721  // align all icons vertically to their text
1722  int newY = y0 + j*dy + dy - spacing() - ( item->pixmapRect().bottom() + 2 + textHeight );
1723  if ( item->x() != newX || item->y() != newY ) {
1724  TQRect oldRect = item->rect();
1725  movedItems.prepend( item );
1726  item->move( newX, newY );
1727  if ( item->rect() != oldRect )
1728  repaintRegion = repaintRegion.unite( oldRect );
1729  }
1730  }
1731  delete bin;
1732  bins[i][j] = 0L;
1733  }
1734  }
1735 
1736  // repaint
1737  if ( newItemWidth )
1738  updateContents();
1739  else {
1740  // Repaint only repaintRegion...
1741  TQMemArray<TQRect> rects = repaintRegion.rects();
1742  for ( uint l = 0; l < rects.count(); l++ ) {
1743  kdDebug( 1203 ) << "Repainting (" << rects[l].x() << ","
1744  << rects[l].y() << ")\n";
1745  repaintContents( rects[l], false );
1746  }
1747  // Repaint icons that were moved
1748  while ( !movedItems.isEmpty() ) {
1749  repaintItem( movedItems.first() );
1750  movedItems.remove( movedItems.first() );
1751  }
1752  }
1753 
1754  for ( i = 0; i < nx ; i++ ) {
1755  delete [] bins[i];
1756  }
1757  delete [] bins;
1758 }
1759 
1760 void KonqIconViewWidget::lineupIcons( TQIconView::Arrangement arrangement )
1761 {
1762  int x0, y0, dx, dy, nxmax, nymax;
1763  gridValues( &x0, &y0, &dx, &dy, &nxmax, &nymax );
1764  int textHeight = iconTextHeight() * fontMetrics().height();
1765 
1766  TQRegion repaintRegion;
1767  TQValueList<TQIconViewItem*> movedItems;
1768  int nx = 0, ny = 0;
1769 
1770  TQIconViewItem* item;
1771  for ( item = firstItem(); item; item = item->nextItem() ) {
1772  int newX = x0 + nx*dx + spacing() +
1773  QMAX(0, ( (dx-spacing()) - item->width() ) / 2); // icon can be larger as defined
1774  // align all icons vertically to their text
1775  int newY = y0 + ny*dy + dy - spacing() - ( item->pixmapRect().bottom() + 2 + textHeight );
1776  if ( item->x() != newX || item->y() != newY ) {
1777  TQRect oldRect = item->rect();
1778  movedItems.prepend( item );
1779  item->move( newX, newY );
1780  if ( item->rect() != oldRect )
1781  repaintRegion = repaintRegion.unite( oldRect );
1782  }
1783  if ( arrangement == TQIconView::LeftToRight ) {
1784  nx++;
1785  if ( nx >= nxmax ) {
1786  ny++;
1787  nx = 0;
1788  }
1789  }
1790  else {
1791  ny++;
1792  if ( ny >= nymax ) {
1793  nx++;
1794  ny = 0;
1795  }
1796  }
1797  }
1798 
1799  // Repaint only repaintRegion...
1800  TQMemArray<TQRect> rects = repaintRegion.rects();
1801  for ( uint l = 0; l < rects.count(); l++ ) {
1802  kdDebug( 1203 ) << "Repainting (" << rects[l].x() << ","
1803  << rects[l].y() << ")\n";
1804  repaintContents( rects[l], false );
1805  }
1806  // Repaint icons that were moved
1807  while ( !movedItems.isEmpty() ) {
1808  repaintItem( movedItems.first() );
1809  movedItems.remove( movedItems.first() );
1810  }
1811 }
1812 
1813 int KonqIconViewWidget::largestPreviewIconSize( int size ) const
1814 {
1815  int iconSize = size ? size : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
1816 
1817  if (iconSize < 28)
1818  return 48;
1819  if (iconSize < 40)
1820  return 64;
1821  if (iconSize < 60)
1822  return 96;
1823  if (iconSize < 120)
1824  return 128;
1825 
1826  return 192;
1827 }
1828 
1829 int KonqIconViewWidget::previewIconSize( int size ) const
1830 {
1831  int iconSize = size ? size : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
1832 
1833  if (!d->bBoostPreview)
1834  return iconSize;
1835 
1836  return largestPreviewIconSize( iconSize );
1837 }
1838 
1839 void KonqIconViewWidget::visualActivate(TQIconViewItem * item)
1840 {
1841  // Rect of the TQIconViewItem.
1842  TQRect irect = item->rect();
1843 
1844  // Rect of the QIconViewItem's pixmap area.
1845  TQRect rect = item->pixmapRect();
1846 
1847  // Adjust to correct position. If this isn't done, the fact that the
1848  // text may be wider than the pixmap puts us off-centre.
1849  rect.moveBy(irect.x(), irect.y());
1850 
1851  // Adjust for scrolling (David)
1852  rect.moveBy( -contentsX(), -contentsY() );
1853 
1854  if (KGlobalSettings::showKonqIconActivationEffect() == true) {
1855  KIconEffect::visualActivate(viewport(), rect, item->pixmap());
1856  }
1857 }
1858 
1859 void KonqIconViewWidget::backgroundPixmapChange( const TQPixmap & )
1860 {
1861  viewport()->update();
1862 }
1863 
1864 void KonqIconViewWidget::setPreviewSettings( const TQStringList& settings )
1865 {
1866  d->previewSettings = settings;
1867  updatePreviewMimeTypes();
1868 
1869  int size = m_size;
1870  m_size = -1; // little trick to force grid change in setIcons
1871  setIcons( size ); // force re-determining all icons
1872 }
1873 
1874 const TQStringList& KonqIconViewWidget::previewSettings()
1875 {
1876  return d->previewSettings;
1877 }
1878 
1879 void KonqIconViewWidget::setNewURL( const TQString& url )
1880 {
1881  KURL u;
1882  if ( url.startsWith( "/" ) )
1883  u.setPath( url );
1884  else
1885  u = url;
1886  setURL( u );
1887 }
1888 
1889 void KonqIconViewWidget::setCaseInsensitiveSort( bool b )
1890 {
1891  d->bCaseInsensitive = b;
1892 }
1893 
1894 bool KonqIconViewWidget::caseInsensitiveSort() const
1895 {
1896  return d->bCaseInsensitive;
1897 }
1898 
1899 bool KonqIconViewWidget::canPreview( KFileItem* item )
1900 {
1901  if ( !KGlobalSettings::showFilePreview( url() ) )
1902  return false;
1903 
1904  if ( d->pPreviewMimeTypes == 0L )
1905  updatePreviewMimeTypes();
1906 
1907  return mimeTypeMatch( item->mimetype(), *( d->pPreviewMimeTypes ) );
1908 }
1909 
1910 void KonqIconViewWidget::updatePreviewMimeTypes()
1911 {
1912  if ( d->pPreviewMimeTypes == 0L )
1913  d->pPreviewMimeTypes = new TQStringList;
1914  else
1915  d->pPreviewMimeTypes->clear();
1916 
1917  // Load the list of plugins to determine which mimetypes are supported
1918  KTrader::OfferList plugins = KTrader::self()->query("ThumbCreator");
1919  KTrader::OfferList::ConstIterator it;
1920 
1921  for ( it = plugins.begin(); it != plugins.end(); ++it ) {
1922  if ( d->previewSettings.contains((*it)->desktopEntryName()) ) {
1923  TQStringList mimeTypes = (*it)->property("MimeTypes").toStringList();
1924  for (TQStringList::ConstIterator mt = mimeTypes.begin(); mt != mimeTypes.end(); ++mt)
1925  d->pPreviewMimeTypes->append(*mt);
1926  }
1927  }
1928 }
1929 
1930 #include "konq_iconviewwidget.moc"
1931 
1932 /* vim: set et sw=4 ts=8 softtabstop=4: */

libkonq

Skip menu "libkonq"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libkonq

Skip menu "libkonq"
  • kate
  • kwin
  •   lib
  • libkonq
Generated for libkonq by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |