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

libkonq

  • libkonq
konq_dirpart.cpp
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 <tdeio/paste.h>
26#include <tdeapplication.h>
27#include <tdeaction.h>
28#include <kdatastream.h>
29#include <kdebug.h>
30#include <kdirlister.h>
31#include <kiconloader.h>
32#include <tdelocale.h>
33#include <tdemessagebox.h>
34#include <konq_drag.h>
35#include <tdeparts/browserextension.h>
36#include <kurldrag.h>
37#include <kuserprofile.h>
38#include <kurifilter.h>
39#include <tdeglobalsettings.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
48class KonqDirPart::KonqDirPartPrivate
49{
50public:
51 KonqDirPartPrivate() : dirLister( 0 ) {}
52 TQStringList mimeFilters;
53 TDEToggleAction *aEnormousIcons;
54 TDEToggleAction *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
65void KonqDirPart::KonqDirPartPrivate::findAvailableIconSizes(void)
66{
67 TDEIconTheme *root = TDEGlobal::instance()->iconLoader()->theme();
68 iconSize.resize(1);
69 if (root) {
70 TQValueList<int> avSizes = root->querySizes(TDEIcon::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(TDEIcon::SizeSmall); // 16
99 iconSize.append(TDEIcon::SizeMedium); // 32
100 iconSize.append(TDEIcon::SizeLarge); // 48
101 iconSize.append(TDEIcon::SizeHuge); // 64
102 }
103 kdDebug(1203) << "Using " << iconSize.count() << " icon sizes." << endl;
104}
105
106int KonqDirPart::KonqDirPartPrivate::findNearestIconSize(int preferred)
107{
108 int s1 = iconSize[1];
109 if (preferred == 0) return TDEGlobal::iconLoader()->currentSize(TDEIcon::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
122int KonqDirPart::KonqDirPartPrivate::nearestIconSizeError(int size)
123{
124 return TQABS(size - findNearestIconSize(size));
125}
126
127KonqDirPart::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(), TQ_SIGNAL(dataChanged()), this, TQ_SLOT(slotClipboardDataChanged()) );
137
138 actionCollection()->setHighlightingEnabled( true );
139
140 m_paIncIconSize = new TDEAction( i18n( "Enlarge Icons" ), "zoom-in", 0, this, TQ_SLOT( slotIncIconSize() ), actionCollection(), "incIconSize" );
141 m_paDecIconSize = new TDEAction( i18n( "Shrink Icons" ), "zoom-out", 0, this, TQ_SLOT( slotDecIconSize() ), actionCollection(), "decIconSize" );
142
143 m_paDefaultIcons = new TDERadioAction( i18n( "&Default Size" ), 0, actionCollection(), "modedefault" );
144 d->aEnormousIcons = new TDERadioAction( i18n( "&Huge" ), 0,
145 actionCollection(), "modeenormous" );
146 m_paHugeIcons = new TDERadioAction( i18n( "&Very Large" ), 0, actionCollection(), "modehuge" );
147 m_paLargeIcons = new TDERadioAction( i18n( "&Large" ), 0, actionCollection(), "modelarge" );
148 m_paMediumIcons = new TDERadioAction( i18n( "&Medium" ), 0, actionCollection(), "modemedium" );
149 d->aSmallMediumIcons = new TDERadioAction( i18n( "&Small" ), 0,
150 actionCollection(), "modesmallmedium" );
151 m_paSmallIcons = new TDERadioAction( 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, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotIconSizeToggled( bool ) ) );
162 connect( d->aEnormousIcons, TQ_SIGNAL( toggled( bool ) ),
163 this, TQ_SLOT( slotIconSizeToggled( bool ) ) );
164 connect( m_paHugeIcons, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotIconSizeToggled( bool ) ) );
165 connect( m_paLargeIcons, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotIconSizeToggled( bool ) ) );
166 connect( m_paMediumIcons, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotIconSizeToggled( bool ) ) );
167 connect( d->aSmallMediumIcons, TQ_SIGNAL( toggled( bool ) ),
168 this, TQ_SLOT( slotIconSizeToggled( bool ) ) );
169 connect( m_paSmallIcons, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotIconSizeToggled( bool ) ) );
170
171 connect( tdeApp, TQ_SIGNAL(iconChanged(int)), TQ_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] = TDEIcon::SizeSmall; // 16
179 d->iconSize[2] = TDEIcon::SizeSmallMedium; // 22
180 d->iconSize[3] = TDEIcon::SizeMedium; // 32
181 d->iconSize[4] = TDEIcon::SizeLarge; // 48
182 d->iconSize[5] = TDEIcon::SizeHuge; // 64
183 d->iconSize[6] = TDEIcon::SizeEnormous; // 128
184 d->iconSize[7] = 192;
185 d->iconSize[8] = 256;
186 TDEIconTheme *root = TDEGlobal::instance()->iconLoader()->theme();
187 if (root)
188 {
189 TQValueList<int> avSizes = root->querySizes(TDEIcon::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] = TDEIcon::SizeSmall;
217 m_iIconSize[2] = TDEIcon::SizeMedium;
218 m_iIconSize[3] = TDEIcon::SizeLarge;
219 m_iIconSize[4] = TDEIcon::SizeHuge;
220 // ... up to here
221
222 TDEAction *a = new TDEAction( i18n( "Configure Background..." ), "background", 0, this, TQ_SLOT( slotBackgroundSettings() ),
223 actionCollection(), "bgsettings" );
224
225 a->setToolTip( i18n( "Allows choosing of background settings for this view" ) );
226}
227
228KonqDirPart::~KonqDirPart()
229{
230 // Close the find part with us
231 delete m_findPart;
232 delete d;
233 d = 0;
234}
235
236void 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
257void 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
270TQStringList KonqDirPart::mimeFilter() const
271{
272 return d->mimeFilters;
273}
274
275TQScrollView * KonqDirPart::scrollWidget()
276{
277 return static_cast<TQScrollView *>(widget());
278}
279
280void KonqDirPart::slotBackgroundSettings()
281{
282 TQColor bgndColor = m_pProps->bgColor( widget() );
283 TQColor defaultColor = TDEGlobalSettings::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
310void 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
349void 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
372void KonqDirPart::saveState( TQDataStream& stream )
373{
374 stream << m_nameFilter;
375}
376
377void KonqDirPart::restoreState( TQDataStream& stream )
378{
379 stream >> m_nameFilter;
380}
381
382void 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
400void 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
416void 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-tde-cutselection" ) && data->provides( "text/uri-list" ) ) {
423 if ( KonqDrag::decodeIsCutSelection( data ) ) {
424 (void) KURLDrag::decode( data, lst );
425 }
426 }
427
428 disableIcons( lst );
429
430 updatePasteAction();
431}
432
433void KonqDirPart::updatePasteAction() // KDE4: merge into method above
434{
435 TQString actionText = TDEIO::pasteActionText();
436 bool paste = !actionText.isEmpty();
437 if ( paste ) {
438 emit m_extension->setActionText( "paste", actionText );
439 }
440 emit m_extension->enableAction( "paste", paste );
441}
442
443void KonqDirPart::newItems(const KFileItemList &entries)
444{
445 d->dirSizeDirty = true;
446 if ( m_findPart ) {
447 emitTotalCount();
448 }
449
450 emit itemsAdded(entries);
451}
452
453void KonqDirPart::deleteItem(KFileItem * fileItem)
454{
455 d->dirSizeDirty = true;
456 emit itemRemoved(fileItem);
457}
458
459void KonqDirPart::refreshItems(const KFileItemList &entries)
460{
461 emit itemsRefresh(entries);
462}
463
464void KonqDirPart::emitTotalCount()
465{
466 if ( !d->dirLister || d->dirLister->url().isEmpty() ) {
467 return;
468 }
469 if ( d->dirSizeDirty ) {
470 m_lDirSize = 0;
471 m_lFileCount = 0;
472 m_lDirCount = 0;
473 KFileItemList entries = d->dirLister->items();
474 for (KFileItemListIterator it(entries); it.current(); ++it)
475 {
476 if ( !it.current()->isDir() )
477 {
478 if (!it.current()->isLink()) { // symlinks don't contribute to the size
479 m_lDirSize += it.current()->size();
480 }
481 m_lFileCount++;
482 }
483 else {
484 m_lDirCount++;
485 }
486 }
487 d->dirSizeDirty = false;
488 }
489
490 TQString summary =
491 TDEIO::itemsSummaryString(m_lFileCount + m_lDirCount,
492 m_lFileCount,
493 m_lDirCount,
494 m_lDirSize,
495 true);
496 bool bShowsResult = false;
497 if (m_findPart)
498 {
499 TQVariant prop = m_findPart->property( "showsResult" );
500 bShowsResult = prop.isValid() && prop.toBool();
501 }
502 //kdDebug(1203) << "KonqDirPart::emitTotalCount bShowsResult=" << bShowsResult << endl;
503 emit setStatusBarText( bShowsResult ? i18n("Search result: %1").arg(summary) : summary );
504}
505
506void KonqDirPart::emitCounts( const KFileItemList & lst )
507{
508 if ( lst.count() == 1 )
509 emit setStatusBarText( ((KFileItemList)lst).first()->getStatusBarInfo() );
510 else
511 {
512 long long fileSizeSum = 0;
513 uint fileCount = 0;
514 uint dirCount = 0;
515
516 for ( KFileItemListIterator it( lst ); it.current(); ++it )
517 {
518 if ( it.current()->isDir() )
519 dirCount++;
520 else
521 {
522 if ( !it.current()->isLink() ) // ignore symlinks
523 fileSizeSum += it.current()->size();
524 fileCount++;
525 }
526 }
527
528 emit setStatusBarText( TDEIO::itemsSummaryString( fileCount + dirCount,
529 fileCount, dirCount,
530 fileSizeSum, true ) );
531 }
532}
533
534void KonqDirPart::emitCounts( const KFileItemList & lst, bool selectionChanged )
535{
536 if ( lst.count() == 0 ) {
537 emitTotalCount();
538 }
539 else {
540 emitCounts( lst );
541 }
542
543 // Yes, the caller could do that too :)
544 // But this bool could also be used to cache the TQString for the last
545 // selection, as long as selectionChanged is false.
546 // Not sure it's worth it though.
547 // MiB: no, I don't think it's worth it. Especially regarding the
548 // loss of readability of the code. Thus, this will be removed in
549 // KDE 4.0.
550 if ( selectionChanged ) {
551 emit m_extension->selectionInfo( lst );
552 }
553}
554
555void KonqDirPart::emitMouseOver( const KFileItem* item )
556{
557 emit m_extension->mouseOverInfo( item );
558}
559
560void KonqDirPart::slotIconSizeToggled( bool toggleOn )
561{
562 //kdDebug(1203) << "KonqDirPart::slotIconSizeToggled" << endl;
563
564 // This slot is called when an iconsize action is checked or by calling
565 // action->setChecked(false) (previously true). So we must filter out
566 // the 'untoggled' case to prevent odd results here (repaints/loops!)
567 if ( !toggleOn )
568 return;
569
570 if ( m_paDefaultIcons->isChecked() )
571 setIconSize(0);
572 else if ( d->aEnormousIcons->isChecked() )
573 setIconSize(d->findNearestIconSize(TDEIcon::SizeEnormous));
574 else if ( m_paHugeIcons->isChecked() )
575 setIconSize(d->findNearestIconSize(TDEIcon::SizeHuge));
576 else if ( m_paLargeIcons->isChecked() )
577 setIconSize(d->findNearestIconSize(TDEIcon::SizeLarge));
578 else if ( m_paMediumIcons->isChecked() )
579 setIconSize(d->findNearestIconSize(TDEIcon::SizeMedium));
580 else if ( d->aSmallMediumIcons->isChecked() )
581 setIconSize(d->findNearestIconSize(TDEIcon::SizeSmallMedium));
582 else if ( m_paSmallIcons->isChecked() )
583 setIconSize(d->findNearestIconSize(TDEIcon::SizeSmall));
584}
585
586void KonqDirPart::slotIncIconSize()
587{
588 int s = m_pProps->iconSize();
589 s = s ? s : TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop );
590 uint sizeIndex = 0;
591 for ( uint idx = 1; idx < d->iconSize.count() ; ++idx )
592 if (s == d->iconSize[idx]) {
593 sizeIndex = idx;
594 break;
595 }
596 if ( sizeIndex > 0 && sizeIndex < d->iconSize.count() - 1 )
597 {
598 setIconSize( d->iconSize[sizeIndex + 1] );
599 }
600}
601
602void KonqDirPart::slotDecIconSize()
603{
604 int s = m_pProps->iconSize();
605 s = s ? s : TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop );
606 uint sizeIndex = 0;
607 for ( uint idx = 1; idx < d->iconSize.count() ; ++idx )
608 if (s == d->iconSize[idx]) {
609 sizeIndex = idx;
610 break;
611 }
612 if ( sizeIndex > 1 )
613 {
614 setIconSize( d->iconSize[sizeIndex - 1] );
615 }
616}
617
618// Only updates Actions, a GUI update is done in the views by reimplementing this
619void KonqDirPart::newIconSize( int size /*0=default, or 16,32,48....*/ )
620{
621 int realSize = (size==0) ? TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop ) : size;
622 m_paDecIconSize->setEnabled(realSize > d->iconSize[1]);
623 m_paIncIconSize->setEnabled(realSize < d->iconSize.back());
624
625 m_paDefaultIcons->setChecked(size == 0);
626 d->aEnormousIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeEnormous));
627 m_paHugeIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeHuge));
628 m_paLargeIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeLarge));
629 m_paMediumIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeMedium));
630 d->aSmallMediumIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeSmallMedium));
631 m_paSmallIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeSmall));
632}
633
634// Stores the new icon size and updates the GUI
635void KonqDirPart::setIconSize( int size )
636{
637 //kdDebug(1203) << "KonqDirPart::setIconSize " << size << " -> updating props and GUI" << endl;
638 m_pProps->setIconSize( size );
639 newIconSize( size );
640}
641
642bool KonqDirPart::closeURL()
643{
644 // Tell all the childern objects to clean themselves up for dinner :)
645 return doCloseURL();
646}
647
648bool KonqDirPart::openURL(const KURL& url)
649{
650 if ( m_findPart )
651 {
652 kdDebug(1203) << "KonqDirPart::openURL -> emit findClosed " << this << endl;
653 delete m_findPart;
654 m_findPart = 0L;
655 emit findClosed( this );
656 }
657
658 m_url = url;
659 emit aboutToOpenURL ();
660
661 return doOpenURL(url);
662}
663
664void KonqDirPart::setFindPart( KParts::ReadOnlyPart * part )
665{
666 assert(part);
667 m_findPart = part;
668 connect( m_findPart, TQ_SIGNAL( started() ),
669 this, TQ_SLOT( slotStarted() ) );
670 connect( m_findPart, TQ_SIGNAL( started() ),
671 this, TQ_SLOT( slotStartAnimationSearching() ) );
672 connect( m_findPart, TQ_SIGNAL( clear() ),
673 this, TQ_SLOT( slotClear() ) );
674 connect( m_findPart, TQ_SIGNAL( newItems( const KFileItemList & ) ),
675 this, TQ_SLOT( slotNewItems( const KFileItemList & ) ) );
676 connect( m_findPart, TQ_SIGNAL( finished() ), // can't name it completed, it conflicts with a KROP signal
677 this, TQ_SLOT( slotCompleted() ) );
678 connect( m_findPart, TQ_SIGNAL( finished() ),
679 this, TQ_SLOT( slotStopAnimationSearching() ) );
680 connect( m_findPart, TQ_SIGNAL( canceled() ),
681 this, TQ_SLOT( slotCanceled() ) );
682 connect( m_findPart, TQ_SIGNAL( canceled() ),
683 this, TQ_SLOT( slotStopAnimationSearching() ) );
684
685 connect( m_findPart, TQ_SIGNAL( findClosed() ),
686 this, TQ_SLOT( slotFindClosed() ) );
687
688 emit findOpened( this );
689
690 // set the initial URL in the find part
691 m_findPart->openURL( url() );
692}
693
694void KonqDirPart::slotFindClosed()
695{
696 kdDebug(1203) << "KonqDirPart::slotFindClosed -> emit findClosed " << this << endl;
697 delete m_findPart;
698 m_findPart = 0L;
699 emit findClosed( this );
700 // reload where we were before
701 openURL( url() );
702}
703
704void KonqDirPart::slotIconChanged( int group )
705{
706 if (group != TDEIcon::Desktop) return;
707 adjustIconSizes();
708}
709
710void KonqDirPart::slotStartAnimationSearching()
711{
712 started(0);
713}
714
715void KonqDirPart::slotStopAnimationSearching()
716{
717 completed();
718}
719
720void KonqDirPartBrowserExtension::saveState( TQDataStream &stream )
721{
722 m_dirPart->saveState( stream );
723 bool hasFindPart = m_dirPart->findPart();
724 stream << hasFindPart;
725 assert( ! ( hasFindPart && !strcmp(m_dirPart->className(), "KFindPart") ) );
726 if ( !hasFindPart )
727 KParts::BrowserExtension::saveState( stream );
728 else {
729 m_dirPart->saveFindState( stream );
730 }
731}
732
733void KonqDirPartBrowserExtension::restoreState( TQDataStream &stream )
734{
735 m_dirPart->restoreState( stream );
736 bool hasFindPart;
737 stream >> hasFindPart;
738 assert( ! ( hasFindPart && !strcmp(m_dirPart->className(), "KFindPart") ) );
739 if ( !hasFindPart )
740 // This calls openURL, that's why we don't want to call it in case of a find part
741 KParts::BrowserExtension::restoreState( stream );
742 else {
743 m_dirPart->restoreFindState( stream );
744 }
745}
746
747
748void KonqDirPart::resetCount()
749{
750 m_lDirSize = 0;
751 m_lFileCount = 0;
752 m_lDirCount = 0;
753 d->dirSizeDirty = true;
754}
755
756void KonqDirPart::setDirLister( KDirLister* lister )
757{
758 d->dirLister = lister;
759}
760
761#include "konq_dirpart.moc"
KonqBgndDialog
Dialog for configuring the background Currently it defines and shows the pixmaps under the tiles reso...
Definition: konq_bgnddlg.h:39
KonqFMSettings::settings
static KonqFMSettings * settings()
The static instance of KonqFMSettings.
Definition: konq_settings.cpp:47

libkonq

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

libkonq

Skip menu "libkonq"
  • kate
  • libkonq
  • twin
  •   lib
Generated for libkonq by doxygen 1.9.4
This website is maintained by Timothy Pearson.