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

libkonq

  • libkonq
konq_dirpart.cc
1 /* This file is part of the KDE projects
2  Copyright (C) 2000 David Faure <faure@kde.org>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; see the file COPYING. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "konq_dirpart.h"
21 #include "konq_bgnddlg.h"
22 #include "konq_propsview.h"
23 #include "konq_settings.h"
24 
25 #include <kio/paste.h>
26 #include <kapplication.h>
27 #include <kaction.h>
28 #include <kdatastream.h>
29 #include <kdebug.h>
30 #include <kdirlister.h>
31 #include <kiconloader.h>
32 #include <klocale.h>
33 #include <kmessagebox.h>
34 #include <konq_drag.h>
35 #include <kparts/browserextension.h>
36 #include <kurldrag.h>
37 #include <kuserprofile.h>
38 #include <kurifilter.h>
39 #include <kglobalsettings.h>
40 
41 #include <tqapplication.h>
42 #include <tqclipboard.h>
43 #include <tqfile.h>
44 #include <tqguardedptr.h>
45 #include <assert.h>
46 #include <tqvaluevector.h>
47 
48 class KonqDirPart::KonqDirPartPrivate
49 {
50 public:
51  KonqDirPartPrivate() : dirLister( 0 ) {}
52  TQStringList mimeFilters;
53  KToggleAction *aEnormousIcons;
54  KToggleAction *aSmallMediumIcons;
55  TQValueVector<int> iconSize;
56 
57  KDirLister* dirLister;
58  bool dirSizeDirty;
59 
60  void findAvailableIconSizes(void);
61  int findNearestIconSize(int size);
62  int nearestIconSizeError(int size);
63 };
64 
65 void KonqDirPart::KonqDirPartPrivate::findAvailableIconSizes(void)
66 {
67  KIconTheme *root = KGlobal::instance()->iconLoader()->theme();
68  iconSize.resize(1);
69  if (root) {
70  TQValueList<int> avSizes = root->querySizes(KIcon::Desktop);
71  kdDebug(1203) << "The icon theme handles the sizes:" << avSizes << endl;
72  qHeapSort(avSizes);
73  int oldSize = -1;
74  if (avSizes.count() < 10) {
75  // Fixed or threshold type icons
76  TQValueListConstIterator<int> i;
77  for (i = avSizes.begin(); i != avSizes.end(); i++) {
78  // Skip duplicated values (sanity check)
79  if (*i != oldSize) iconSize.append(*i);
80  oldSize = *i;
81  }
82  } else {
83  // Scalable icons.
84  const int progression[] = {16, 22, 32, 48, 64, 96, 128, 192, 256};
85 
86  TQValueListConstIterator<int> j = avSizes.begin();
87  for (uint i = 0; i < 9; i++) {
88  while (j++ != avSizes.end()) {
89  if (*j >= progression[i]) {
90  iconSize.append(*j);
91  kdDebug(1203) << "appending " << *j << " size." << endl;
92  break;
93  }
94  }
95  }
96  }
97  } else {
98  iconSize.append(KIcon::SizeSmall); // 16
99  iconSize.append(KIcon::SizeMedium); // 32
100  iconSize.append(KIcon::SizeLarge); // 48
101  iconSize.append(KIcon::SizeHuge); // 64
102  }
103  kdDebug(1203) << "Using " << iconSize.count() << " icon sizes." << endl;
104 }
105 
106 int KonqDirPart::KonqDirPartPrivate::findNearestIconSize(int preferred)
107 {
108  int s1 = iconSize[1];
109  if (preferred == 0) return KGlobal::iconLoader()->currentSize(KIcon::Desktop);
110  if (preferred <= s1) return s1;
111  for (uint i = 2; i <= iconSize.count(); i++) {
112  if (preferred <= iconSize[i]) {
113  if (preferred - s1 < iconSize[i] - preferred) return s1;
114  else return iconSize[i];
115  } else {
116  s1 = iconSize[i];
117  }
118  }
119  return s1;
120 }
121 
122 int KonqDirPart::KonqDirPartPrivate::nearestIconSizeError(int size)
123 {
124  return QABS(size - findNearestIconSize(size));
125 }
126 
127 KonqDirPart::KonqDirPart( TQObject *parent, const char *name )
128  :KParts::ReadOnlyPart( parent, name ),
129  m_pProps( 0L ),
130  m_findPart( 0L )
131 {
132  d = new KonqDirPartPrivate;
133  resetCount();
134  //m_bMultipleItemsSelected = false;
135 
136  connect( TQApplication::clipboard(), TQT_SIGNAL(dataChanged()), this, TQT_SLOT(slotClipboardDataChanged()) );
137 
138  actionCollection()->setHighlightingEnabled( true );
139 
140  m_paIncIconSize = new KAction( i18n( "Enlarge Icons" ), "viewmag+", 0, this, TQT_SLOT( slotIncIconSize() ), actionCollection(), "incIconSize" );
141  m_paDecIconSize = new KAction( i18n( "Shrink Icons" ), "viewmag-", 0, this, TQT_SLOT( slotDecIconSize() ), actionCollection(), "decIconSize" );
142 
143  m_paDefaultIcons = new KRadioAction( i18n( "&Default Size" ), 0, actionCollection(), "modedefault" );
144  d->aEnormousIcons = new KRadioAction( i18n( "&Huge" ), 0,
145  actionCollection(), "modeenormous" );
146  m_paHugeIcons = new KRadioAction( i18n( "&Very Large" ), 0, actionCollection(), "modehuge" );
147  m_paLargeIcons = new KRadioAction( i18n( "&Large" ), 0, actionCollection(), "modelarge" );
148  m_paMediumIcons = new KRadioAction( i18n( "&Medium" ), 0, actionCollection(), "modemedium" );
149  d->aSmallMediumIcons = new KRadioAction( i18n( "&Small" ), 0,
150  actionCollection(), "modesmallmedium" );
151  m_paSmallIcons = new KRadioAction( i18n( "&Tiny" ), 0, actionCollection(), "modesmall" );
152 
153  m_paDefaultIcons->setExclusiveGroup( "ViewMode" );
154  d->aEnormousIcons->setExclusiveGroup( "ViewMode" );
155  m_paHugeIcons->setExclusiveGroup( "ViewMode" );
156  m_paLargeIcons->setExclusiveGroup( "ViewMode" );
157  m_paMediumIcons->setExclusiveGroup( "ViewMode" );
158  d->aSmallMediumIcons->setExclusiveGroup( "ViewMode" );
159  m_paSmallIcons->setExclusiveGroup( "ViewMode" );
160 
161  connect( m_paDefaultIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
162  connect( d->aEnormousIcons, TQT_SIGNAL( toggled( bool ) ),
163  this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
164  connect( m_paHugeIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
165  connect( m_paLargeIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
166  connect( m_paMediumIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
167  connect( d->aSmallMediumIcons, TQT_SIGNAL( toggled( bool ) ),
168  this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
169  connect( m_paSmallIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
170 
171  connect( kapp, TQT_SIGNAL(iconChanged(int)), TQT_SLOT(slotIconChanged(int)) );
172 #if 0
173  // Extract 6 icon sizes from the icon theme.
174  // Use 16,22,32,48,64,128 as default.
175  // Use these also if the icon theme is scalable.
176  int i;
177  d->iconSize[0] = 0; // Default value
178  d->iconSize[1] = KIcon::SizeSmall; // 16
179  d->iconSize[2] = KIcon::SizeSmallMedium; // 22
180  d->iconSize[3] = KIcon::SizeMedium; // 32
181  d->iconSize[4] = KIcon::SizeLarge; // 48
182  d->iconSize[5] = KIcon::SizeHuge; // 64
183  d->iconSize[6] = KIcon::SizeEnormous; // 128
184  d->iconSize[7] = 192;
185  d->iconSize[8] = 256;
186  KIconTheme *root = KGlobal::instance()->iconLoader()->theme();
187  if (root)
188  {
189  TQValueList<int> avSizes = root->querySizes(KIcon::Desktop);
190  kdDebug(1203) << "the icon theme handles the following sizes:" << avSizes << endl;
191  if (avSizes.count() < 10) {
192  // Use the icon sizes supplied by the theme.
193  // If avSizes contains more than 10 entries, assume a scalable
194  // icon theme.
195  TQValueList<int>::Iterator it;
196  for (i=1, it=avSizes.begin(); (it!=avSizes.end()) && (i<7); it++, i++)
197  {
198  d->iconSize[i] = *it;
199  kdDebug(1203) << "m_iIconSize[" << i << "] = " << *it << endl;
200  }
201  // Generate missing sizes
202  for (; i < 7; i++) {
203  d->iconSize[i] = d->iconSize[i - 1] + d->iconSize[i - 1] / 2 ;
204  kdDebug(1203) << "m_iIconSize[" << i << "] = " << d->iconSize[i] << endl;
205  }
206  }
207  }
208 #else
209  d->iconSize.reserve(10);
210  d->iconSize.append(0); // Default value
211  adjustIconSizes();
212 #endif
213 
214  // Remove in KDE4 ...
215  // These are here in the event subclasses access them.
216  m_iIconSize[1] = KIcon::SizeSmall;
217  m_iIconSize[2] = KIcon::SizeMedium;
218  m_iIconSize[3] = KIcon::SizeLarge;
219  m_iIconSize[4] = KIcon::SizeHuge;
220  // ... up to here
221 
222  KAction *a = new KAction( i18n( "Configure Background..." ), "background", 0, this, TQT_SLOT( slotBackgroundSettings() ),
223  actionCollection(), "bgsettings" );
224 
225  a->setToolTip( i18n( "Allows choosing of background settings for this view" ) );
226 }
227 
228 KonqDirPart::~KonqDirPart()
229 {
230  // Close the find part with us
231  delete m_findPart;
232  delete d;
233  d = 0;
234 }
235 
236 void KonqDirPart::adjustIconSizes()
237 {
238  d->findAvailableIconSizes();
239  m_paSmallIcons->setEnabled(d->findNearestIconSize(16) < 20);
240  d->aSmallMediumIcons->setEnabled(d->nearestIconSizeError(22) < 2);
241  m_paMediumIcons->setEnabled(d->nearestIconSizeError(32) < 6);
242  m_paLargeIcons->setEnabled(d->nearestIconSizeError(48) < 8);
243  m_paHugeIcons->setEnabled(d->nearestIconSizeError(64) < 12);
244  d->aEnormousIcons->setEnabled(d->findNearestIconSize(128) > 110);
245 
246  if (m_pProps) {
247  int size = m_pProps->iconSize();
248  int nearSize = d->findNearestIconSize(size);
249 
250  if (size != nearSize) {
251  m_pProps->setIconSize(nearSize);
252  }
253  newIconSize(nearSize);
254  }
255 }
256 
257 void KonqDirPart::setMimeFilter (const TQStringList& mime)
258 {
259  TQString u = url().url();
260 
261  if ( u.isEmpty () )
262  return;
263 
264  if ( mime.isEmpty() )
265  d->mimeFilters.clear();
266  else
267  d->mimeFilters = mime;
268 }
269 
270 TQStringList KonqDirPart::mimeFilter() const
271 {
272  return d->mimeFilters;
273 }
274 
275 TQScrollView * KonqDirPart::scrollWidget()
276 {
277  return static_cast<TQScrollView *>(widget());
278 }
279 
280 void KonqDirPart::slotBackgroundSettings()
281 {
282  TQColor bgndColor = m_pProps->bgColor( widget() );
283  TQColor defaultColor = KGlobalSettings::baseColor();
284  // dlg must be created on the heap as widget() can get deleted while dlg.exec(),
285  // trying to delete dlg as its child then (#124210) - Frank Osterfeld
286  TQGuardedPtr<KonqBgndDialog> dlg = new KonqBgndDialog( widget(),
287  m_pProps->bgPixmapFile(),
288  bgndColor,
289  defaultColor );
290 
291  if ( dlg->exec() == KonqBgndDialog::Accepted )
292  {
293  if ( dlg->color().isValid() )
294  {
295  m_pProps->setBgColor( dlg->color() );
296  m_pProps->setBgPixmapFile( "" );
297  }
298  else
299  {
300  m_pProps->setBgColor( defaultColor );
301  m_pProps->setBgPixmapFile( dlg->pixmapFile() );
302  }
303  m_pProps->applyColors( scrollWidget()->viewport() );
304  scrollWidget()->viewport()->repaint();
305  }
306 
307  delete dlg;
308 }
309 
310 void KonqDirPart::lmbClicked( KFileItem * fileItem )
311 {
312  KURL url = fileItem->url();
313  if ( !fileItem->isReadable() )
314  {
315  // No permissions or local file that doesn't exist - need to find out which
316  if ( ( !fileItem->isLocalFile() ) || TQFile::exists( url.path() ) )
317  {
318  KMessageBox::error( widget(), i18n("<p>You do not have enough permissions to read <b>%1</b></p>").arg(url.prettyURL()) );
319  return;
320  }
321  KMessageBox::error( widget(), i18n("<p><b>%1</b> does not seem to exist anymore</p>").arg(url.prettyURL()) );
322  return;
323  }
324 
325  KParts::URLArgs args;
326  fileItem->determineMimeType();
327  if ( fileItem->isMimeTypeKnown() )
328  args.serviceType = fileItem->mimetype();
329  args.trustedSource = true;
330 
331  if (KonqFMSettings::settings()->alwaysNewWin() && fileItem->isDir()) {
332  //args.frameName = "_blank"; // open new window
333  // We tried the other option, passing the path as framename so that
334  // an existing window for that dir is reused (like MSWindows does when
335  // the similar option is activated and the sidebar is hidden (!)).
336  // But this requires some work, including changing the framename
337  // when navigating, etc. Not very much requested yet, in addition.
338  KParts::WindowArgs wargs;
339  KParts::ReadOnlyPart* dummy;
340  emit m_extension->createNewWindow( url, args, wargs, dummy );
341  }
342  else
343  {
344  kdDebug() << "emit m_extension->openURLRequest( " << url.url() << "," << args.serviceType << ")" << endl;
345  emit m_extension->openURLRequest( url, args );
346  }
347 }
348 
349 void KonqDirPart::mmbClicked( KFileItem * fileItem )
350 {
351  if ( fileItem )
352  {
353  // Optimisation to avoid KRun to call kfmclient that then tells us
354  // to open a window :-)
355  KService::Ptr offer = KServiceTypeProfile::preferredService(fileItem->mimetype(), "Application");
356  //if (offer) kdDebug(1203) << "KonqDirPart::mmbClicked: got service " << offer->desktopEntryName() << endl;
357  if ( offer && offer->desktopEntryName().startsWith("kfmclient") )
358  {
359  KParts::URLArgs args;
360  args.serviceType = fileItem->mimetype();
361  emit m_extension->createNewWindow( fileItem->url(), args );
362  }
363  else
364  fileItem->run();
365  }
366  else
367  {
368  m_extension->pasteRequest();
369  }
370 }
371 
372 void KonqDirPart::saveState( TQDataStream& stream )
373 {
374  stream << m_nameFilter;
375 }
376 
377 void KonqDirPart::restoreState( TQDataStream& stream )
378 {
379  stream >> m_nameFilter;
380 }
381 
382 void KonqDirPart::saveFindState( TQDataStream& stream )
383 {
384  // assert only doable in KDE4.
385  //assert( m_findPart ); // test done by caller.
386  if ( !m_findPart )
387  return;
388 
389  // When we have a find part, our own URL wasn't saved (see KonqDirPartBrowserExtension)
390  // So let's do it here
391  stream << m_url;
392 
393  KParts::BrowserExtension* ext = KParts::BrowserExtension::childObject( m_findPart );
394  if( !ext )
395  return;
396 
397  ext->saveState( stream );
398 }
399 
400 void KonqDirPart::restoreFindState( TQDataStream& stream )
401 {
402  // Restore our own URL
403  stream >> m_url;
404 
405  emit findOpen( this );
406 
407  KParts::BrowserExtension* ext = KParts::BrowserExtension::childObject( m_findPart );
408  slotClear();
409 
410  if( !ext )
411  return;
412 
413  ext->restoreState( stream );
414 }
415 
416 void KonqDirPart::slotClipboardDataChanged()
417 {
418  // This is very related to KDIconView::slotClipboardDataChanged
419 
420  KURL::List lst;
421  TQMimeSource *data = TQApplication::clipboard()->data();
422  if ( data->provides( "application/x-kde-cutselection" ) && data->provides( "text/uri-list" ) )
423  if ( KonqDrag::decodeIsCutSelection( data ) )
424  (void) KURLDrag::decode( data, lst );
425 
426  disableIcons( lst );
427 
428  updatePasteAction();
429 }
430 
431 void KonqDirPart::updatePasteAction() // KDE4: merge into method above
432 {
433  TQString actionText = KIO::pasteActionText();
434  bool paste = !actionText.isEmpty();
435  if ( paste )
436  emit m_extension->setActionText( "paste", actionText );
437  emit m_extension->enableAction( "paste", paste );
438 }
439 
440 void KonqDirPart::newItems( const KFileItemList & entries )
441 {
442  d->dirSizeDirty = true;
443  if ( m_findPart )
444  emitTotalCount();
445 
446  emit itemsAdded( entries );
447 }
448 
449 void KonqDirPart::deleteItem( KFileItem * fileItem )
450 {
451  d->dirSizeDirty = true;
452  emit itemRemoved( fileItem );
453 }
454 
455 void KonqDirPart::emitTotalCount()
456 {
457  if ( !d->dirLister || d->dirLister->url().isEmpty() )
458  return;
459  if ( d->dirSizeDirty ) {
460  m_lDirSize = 0;
461  m_lFileCount = 0;
462  m_lDirCount = 0;
463  KFileItemList entries = d->dirLister->items();
464  for (KFileItemListIterator it(entries); it.current(); ++it)
465  {
466  if ( !it.current()->isDir() )
467  {
468  if (!it.current()->isLink()) // symlinks don't contribute to the size
469  m_lDirSize += it.current()->size();
470  m_lFileCount++;
471  }
472  else
473  m_lDirCount++;
474  }
475  d->dirSizeDirty = false;
476  }
477 
478  TQString summary =
479  KIO::itemsSummaryString(m_lFileCount + m_lDirCount,
480  m_lFileCount,
481  m_lDirCount,
482  m_lDirSize,
483  true);
484  bool bShowsResult = false;
485  if (m_findPart)
486  {
487  TQVariant prop = m_findPart->property( "showsResult" );
488  bShowsResult = prop.isValid() && prop.toBool();
489  }
490  //kdDebug(1203) << "KonqDirPart::emitTotalCount bShowsResult=" << bShowsResult << endl;
491  emit setStatusBarText( bShowsResult ? i18n("Search result: %1").arg(summary) : summary );
492 }
493 
494 void KonqDirPart::emitCounts( const KFileItemList & lst )
495 {
496  if ( lst.count() == 1 )
497  emit setStatusBarText( ((KFileItemList)lst).first()->getStatusBarInfo() );
498  else
499  {
500  long long fileSizeSum = 0;
501  uint fileCount = 0;
502  uint dirCount = 0;
503 
504  for ( KFileItemListIterator it( lst ); it.current(); ++it )
505  {
506  if ( it.current()->isDir() )
507  dirCount++;
508  else
509  {
510  if ( !it.current()->isLink() ) // ignore symlinks
511  fileSizeSum += it.current()->size();
512  fileCount++;
513  }
514  }
515 
516  emit setStatusBarText( KIO::itemsSummaryString( fileCount + dirCount,
517  fileCount, dirCount,
518  fileSizeSum, true ) );
519  }
520 }
521 
522 void KonqDirPart::emitCounts( const KFileItemList & lst, bool selectionChanged )
523 {
524  if ( lst.count() == 0 )
525  emitTotalCount();
526  else
527  emitCounts( lst );
528 
529  // Yes, the caller could do that too :)
530  // But this bool could also be used to cache the TQString for the last
531  // selection, as long as selectionChanged is false.
532  // Not sure it's worth it though.
533  // MiB: no, I don't think it's worth it. Especially regarding the
534  // loss of readability of the code. Thus, this will be removed in
535  // KDE 4.0.
536  if ( selectionChanged )
537  emit m_extension->selectionInfo( lst );
538 }
539 
540 void KonqDirPart::emitMouseOver( const KFileItem* item )
541 {
542  emit m_extension->mouseOverInfo( item );
543 }
544 
545 void KonqDirPart::slotIconSizeToggled( bool toggleOn )
546 {
547  //kdDebug(1203) << "KonqDirPart::slotIconSizeToggled" << endl;
548 
549  // This slot is called when an iconsize action is checked or by calling
550  // action->setChecked(false) (previously true). So we must filter out
551  // the 'untoggled' case to prevent odd results here (repaints/loops!)
552  if ( !toggleOn )
553  return;
554 
555  if ( m_paDefaultIcons->isChecked() )
556  setIconSize(0);
557  else if ( d->aEnormousIcons->isChecked() )
558  setIconSize(d->findNearestIconSize(KIcon::SizeEnormous));
559  else if ( m_paHugeIcons->isChecked() )
560  setIconSize(d->findNearestIconSize(KIcon::SizeHuge));
561  else if ( m_paLargeIcons->isChecked() )
562  setIconSize(d->findNearestIconSize(KIcon::SizeLarge));
563  else if ( m_paMediumIcons->isChecked() )
564  setIconSize(d->findNearestIconSize(KIcon::SizeMedium));
565  else if ( d->aSmallMediumIcons->isChecked() )
566  setIconSize(d->findNearestIconSize(KIcon::SizeSmallMedium));
567  else if ( m_paSmallIcons->isChecked() )
568  setIconSize(d->findNearestIconSize(KIcon::SizeSmall));
569 }
570 
571 void KonqDirPart::slotIncIconSize()
572 {
573  int s = m_pProps->iconSize();
574  s = s ? s : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
575  uint sizeIndex = 0;
576  for ( uint idx = 1; idx < d->iconSize.count() ; ++idx )
577  if (s == d->iconSize[idx]) {
578  sizeIndex = idx;
579  break;
580  }
581  if ( sizeIndex > 0 && sizeIndex < d->iconSize.count() - 1 )
582  {
583  setIconSize( d->iconSize[sizeIndex + 1] );
584  }
585 }
586 
587 void KonqDirPart::slotDecIconSize()
588 {
589  int s = m_pProps->iconSize();
590  s = s ? s : KGlobal::iconLoader()->currentSize( KIcon::Desktop );
591  uint sizeIndex = 0;
592  for ( uint idx = 1; idx < d->iconSize.count() ; ++idx )
593  if (s == d->iconSize[idx]) {
594  sizeIndex = idx;
595  break;
596  }
597  if ( sizeIndex > 1 )
598  {
599  setIconSize( d->iconSize[sizeIndex - 1] );
600  }
601 }
602 
603 // Only updates Actions, a GUI update is done in the views by reimplementing this
604 void KonqDirPart::newIconSize( int size /*0=default, or 16,32,48....*/ )
605 {
606  int realSize = (size==0) ? KGlobal::iconLoader()->currentSize( KIcon::Desktop ) : size;
607  m_paDecIconSize->setEnabled(realSize > d->iconSize[1]);
608  m_paIncIconSize->setEnabled(realSize < d->iconSize.back());
609 
610  m_paDefaultIcons->setChecked(size == 0);
611  d->aEnormousIcons->setChecked(size == d->findNearestIconSize(KIcon::SizeEnormous));
612  m_paHugeIcons->setChecked(size == d->findNearestIconSize(KIcon::SizeHuge));
613  m_paLargeIcons->setChecked(size == d->findNearestIconSize(KIcon::SizeLarge));
614  m_paMediumIcons->setChecked(size == d->findNearestIconSize(KIcon::SizeMedium));
615  d->aSmallMediumIcons->setChecked(size == d->findNearestIconSize(KIcon::SizeSmallMedium));
616  m_paSmallIcons->setChecked(size == d->findNearestIconSize(KIcon::SizeSmall));
617 }
618 
619 // Stores the new icon size and updates the GUI
620 void KonqDirPart::setIconSize( int size )
621 {
622  //kdDebug(1203) << "KonqDirPart::setIconSize " << size << " -> updating props and GUI" << endl;
623  m_pProps->setIconSize( size );
624  newIconSize( size );
625 }
626 
627 bool KonqDirPart::closeURL()
628 {
629  // Tell all the childern objects to clean themselves up for dinner :)
630  return doCloseURL();
631 }
632 
633 bool KonqDirPart::openURL(const KURL& url)
634 {
635  if ( m_findPart )
636  {
637  kdDebug(1203) << "KonqDirPart::openURL -> emit findClosed " << this << endl;
638  delete m_findPart;
639  m_findPart = 0L;
640  emit findClosed( this );
641  }
642 
643  m_url = url;
644  emit aboutToOpenURL ();
645 
646  return doOpenURL(url);
647 }
648 
649 void KonqDirPart::setFindPart( KParts::ReadOnlyPart * part )
650 {
651  assert(part);
652  m_findPart = part;
653  connect( m_findPart, TQT_SIGNAL( started() ),
654  this, TQT_SLOT( slotStarted() ) );
655  connect( m_findPart, TQT_SIGNAL( started() ),
656  this, TQT_SLOT( slotStartAnimationSearching() ) );
657  connect( m_findPart, TQT_SIGNAL( clear() ),
658  this, TQT_SLOT( slotClear() ) );
659  connect( m_findPart, TQT_SIGNAL( newItems( const KFileItemList & ) ),
660  this, TQT_SLOT( slotNewItems( const KFileItemList & ) ) );
661  connect( m_findPart, TQT_SIGNAL( finished() ), // can't name it completed, it conflicts with a KROP signal
662  this, TQT_SLOT( slotCompleted() ) );
663  connect( m_findPart, TQT_SIGNAL( finished() ),
664  this, TQT_SLOT( slotStopAnimationSearching() ) );
665  connect( m_findPart, TQT_SIGNAL( canceled() ),
666  this, TQT_SLOT( slotCanceled() ) );
667  connect( m_findPart, TQT_SIGNAL( canceled() ),
668  this, TQT_SLOT( slotStopAnimationSearching() ) );
669 
670  connect( m_findPart, TQT_SIGNAL( findClosed() ),
671  this, TQT_SLOT( slotFindClosed() ) );
672 
673  emit findOpened( this );
674 
675  // set the initial URL in the find part
676  m_findPart->openURL( url() );
677 }
678 
679 void KonqDirPart::slotFindClosed()
680 {
681  kdDebug(1203) << "KonqDirPart::slotFindClosed -> emit findClosed " << this << endl;
682  delete m_findPart;
683  m_findPart = 0L;
684  emit findClosed( this );
685  // reload where we were before
686  openURL( url() );
687 }
688 
689 void KonqDirPart::slotIconChanged( int group )
690 {
691  if (group != KIcon::Desktop) return;
692  adjustIconSizes();
693 }
694 
695 void KonqDirPart::slotStartAnimationSearching()
696 {
697  started(0);
698 }
699 
700 void KonqDirPart::slotStopAnimationSearching()
701 {
702  completed();
703 }
704 
705 void KonqDirPartBrowserExtension::saveState( TQDataStream &stream )
706 {
707  m_dirPart->saveState( stream );
708  bool hasFindPart = m_dirPart->findPart();
709  stream << hasFindPart;
710  assert( ! ( hasFindPart && !strcmp(m_dirPart->className(), "KFindPart") ) );
711  if ( !hasFindPart )
712  KParts::BrowserExtension::saveState( stream );
713  else {
714  m_dirPart->saveFindState( stream );
715  }
716 }
717 
718 void KonqDirPartBrowserExtension::restoreState( TQDataStream &stream )
719 {
720  m_dirPart->restoreState( stream );
721  bool hasFindPart;
722  stream >> hasFindPart;
723  assert( ! ( hasFindPart && !strcmp(m_dirPart->className(), "KFindPart") ) );
724  if ( !hasFindPart )
725  // This calls openURL, that's why we don't want to call it in case of a find part
726  KParts::BrowserExtension::restoreState( stream );
727  else {
728  m_dirPart->restoreFindState( stream );
729  }
730 }
731 
732 
733 void KonqDirPart::resetCount()
734 {
735  m_lDirSize = 0;
736  m_lFileCount = 0;
737  m_lDirCount = 0;
738  d->dirSizeDirty = true;
739 }
740 
741 void KonqDirPart::setDirLister( KDirLister* lister )
742 {
743  d->dirLister = lister;
744 }
745 
746 #include "konq_dirpart.moc"

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.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |