00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "konq_dirpart.h"
00021 #include "konq_bgnddlg.h"
00022 #include "konq_propsview.h"
00023 #include "konq_settings.h"
00024
00025 #include <tdeio/paste.h>
00026 #include <tdeapplication.h>
00027 #include <tdeaction.h>
00028 #include <kdatastream.h>
00029 #include <kdebug.h>
00030 #include <kdirlister.h>
00031 #include <kiconloader.h>
00032 #include <tdelocale.h>
00033 #include <tdemessagebox.h>
00034 #include <konq_drag.h>
00035 #include <tdeparts/browserextension.h>
00036 #include <kurldrag.h>
00037 #include <kuserprofile.h>
00038 #include <kurifilter.h>
00039 #include <tdeglobalsettings.h>
00040
00041 #include <tqapplication.h>
00042 #include <tqclipboard.h>
00043 #include <tqfile.h>
00044 #include <tqguardedptr.h>
00045 #include <assert.h>
00046 #include <tqvaluevector.h>
00047
00048 class KonqDirPart::KonqDirPartPrivate
00049 {
00050 public:
00051 KonqDirPartPrivate() : dirLister( 0 ) {}
00052 TQStringList mimeFilters;
00053 TDEToggleAction *aEnormousIcons;
00054 TDEToggleAction *aSmallMediumIcons;
00055 TQValueVector<int> iconSize;
00056
00057 KDirLister* dirLister;
00058 bool dirSizeDirty;
00059
00060 void findAvailableIconSizes(void);
00061 int findNearestIconSize(int size);
00062 int nearestIconSizeError(int size);
00063 };
00064
00065 void KonqDirPart::KonqDirPartPrivate::findAvailableIconSizes(void)
00066 {
00067 TDEIconTheme *root = TDEGlobal::instance()->iconLoader()->theme();
00068 iconSize.resize(1);
00069 if (root) {
00070 TQValueList<int> avSizes = root->querySizes(TDEIcon::Desktop);
00071 kdDebug(1203) << "The icon theme handles the sizes:" << avSizes << endl;
00072 qHeapSort(avSizes);
00073 int oldSize = -1;
00074 if (avSizes.count() < 10) {
00075
00076 TQValueListConstIterator<int> i;
00077 for (i = avSizes.begin(); i != avSizes.end(); i++) {
00078
00079 if (*i != oldSize) iconSize.append(*i);
00080 oldSize = *i;
00081 }
00082 } else {
00083
00084 const int progression[] = {16, 22, 32, 48, 64, 96, 128, 192, 256};
00085
00086 TQValueListConstIterator<int> j = avSizes.begin();
00087 for (uint i = 0; i < 9; i++) {
00088 while (j++ != avSizes.end()) {
00089 if (*j >= progression[i]) {
00090 iconSize.append(*j);
00091 kdDebug(1203) << "appending " << *j << " size." << endl;
00092 break;
00093 }
00094 }
00095 }
00096 }
00097 } else {
00098 iconSize.append(TDEIcon::SizeSmall);
00099 iconSize.append(TDEIcon::SizeMedium);
00100 iconSize.append(TDEIcon::SizeLarge);
00101 iconSize.append(TDEIcon::SizeHuge);
00102 }
00103 kdDebug(1203) << "Using " << iconSize.count() << " icon sizes." << endl;
00104 }
00105
00106 int KonqDirPart::KonqDirPartPrivate::findNearestIconSize(int preferred)
00107 {
00108 int s1 = iconSize[1];
00109 if (preferred == 0) return TDEGlobal::iconLoader()->currentSize(TDEIcon::Desktop);
00110 if (preferred <= s1) return s1;
00111 for (uint i = 2; i <= iconSize.count(); i++) {
00112 if (preferred <= iconSize[i]) {
00113 if (preferred - s1 < iconSize[i] - preferred) return s1;
00114 else return iconSize[i];
00115 } else {
00116 s1 = iconSize[i];
00117 }
00118 }
00119 return s1;
00120 }
00121
00122 int KonqDirPart::KonqDirPartPrivate::nearestIconSizeError(int size)
00123 {
00124 return QABS(size - findNearestIconSize(size));
00125 }
00126
00127 KonqDirPart::KonqDirPart( TQObject *parent, const char *name )
00128 :KParts::ReadOnlyPart( parent, name ),
00129 m_pProps( 0L ),
00130 m_findPart( 0L )
00131 {
00132 d = new KonqDirPartPrivate;
00133 resetCount();
00134
00135
00136 connect( TQApplication::clipboard(), TQT_SIGNAL(dataChanged()), this, TQT_SLOT(slotClipboardDataChanged()) );
00137
00138 actionCollection()->setHighlightingEnabled( true );
00139
00140 m_paIncIconSize = new TDEAction( i18n( "Enlarge Icons" ), "zoom-in", 0, this, TQT_SLOT( slotIncIconSize() ), actionCollection(), "incIconSize" );
00141 m_paDecIconSize = new TDEAction( i18n( "Shrink Icons" ), "zoom-out", 0, this, TQT_SLOT( slotDecIconSize() ), actionCollection(), "decIconSize" );
00142
00143 m_paDefaultIcons = new TDERadioAction( i18n( "&Default Size" ), 0, actionCollection(), "modedefault" );
00144 d->aEnormousIcons = new TDERadioAction( i18n( "&Huge" ), 0,
00145 actionCollection(), "modeenormous" );
00146 m_paHugeIcons = new TDERadioAction( i18n( "&Very Large" ), 0, actionCollection(), "modehuge" );
00147 m_paLargeIcons = new TDERadioAction( i18n( "&Large" ), 0, actionCollection(), "modelarge" );
00148 m_paMediumIcons = new TDERadioAction( i18n( "&Medium" ), 0, actionCollection(), "modemedium" );
00149 d->aSmallMediumIcons = new TDERadioAction( i18n( "&Small" ), 0,
00150 actionCollection(), "modesmallmedium" );
00151 m_paSmallIcons = new TDERadioAction( i18n( "&Tiny" ), 0, actionCollection(), "modesmall" );
00152
00153 m_paDefaultIcons->setExclusiveGroup( "ViewMode" );
00154 d->aEnormousIcons->setExclusiveGroup( "ViewMode" );
00155 m_paHugeIcons->setExclusiveGroup( "ViewMode" );
00156 m_paLargeIcons->setExclusiveGroup( "ViewMode" );
00157 m_paMediumIcons->setExclusiveGroup( "ViewMode" );
00158 d->aSmallMediumIcons->setExclusiveGroup( "ViewMode" );
00159 m_paSmallIcons->setExclusiveGroup( "ViewMode" );
00160
00161 connect( m_paDefaultIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
00162 connect( d->aEnormousIcons, TQT_SIGNAL( toggled( bool ) ),
00163 this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
00164 connect( m_paHugeIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
00165 connect( m_paLargeIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
00166 connect( m_paMediumIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
00167 connect( d->aSmallMediumIcons, TQT_SIGNAL( toggled( bool ) ),
00168 this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
00169 connect( m_paSmallIcons, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotIconSizeToggled( bool ) ) );
00170
00171 connect( kapp, TQT_SIGNAL(iconChanged(int)), TQT_SLOT(slotIconChanged(int)) );
00172 #if 0
00173
00174
00175
00176 int i;
00177 d->iconSize[0] = 0;
00178 d->iconSize[1] = TDEIcon::SizeSmall;
00179 d->iconSize[2] = TDEIcon::SizeSmallMedium;
00180 d->iconSize[3] = TDEIcon::SizeMedium;
00181 d->iconSize[4] = TDEIcon::SizeLarge;
00182 d->iconSize[5] = TDEIcon::SizeHuge;
00183 d->iconSize[6] = TDEIcon::SizeEnormous;
00184 d->iconSize[7] = 192;
00185 d->iconSize[8] = 256;
00186 TDEIconTheme *root = TDEGlobal::instance()->iconLoader()->theme();
00187 if (root)
00188 {
00189 TQValueList<int> avSizes = root->querySizes(TDEIcon::Desktop);
00190 kdDebug(1203) << "the icon theme handles the following sizes:" << avSizes << endl;
00191 if (avSizes.count() < 10) {
00192
00193
00194
00195 TQValueList<int>::Iterator it;
00196 for (i=1, it=avSizes.begin(); (it!=avSizes.end()) && (i<7); it++, i++)
00197 {
00198 d->iconSize[i] = *it;
00199 kdDebug(1203) << "m_iIconSize[" << i << "] = " << *it << endl;
00200 }
00201
00202 for (; i < 7; i++) {
00203 d->iconSize[i] = d->iconSize[i - 1] + d->iconSize[i - 1] / 2 ;
00204 kdDebug(1203) << "m_iIconSize[" << i << "] = " << d->iconSize[i] << endl;
00205 }
00206 }
00207 }
00208 #else
00209 d->iconSize.reserve(10);
00210 d->iconSize.append(0);
00211 adjustIconSizes();
00212 #endif
00213
00214
00215
00216 m_iIconSize[1] = TDEIcon::SizeSmall;
00217 m_iIconSize[2] = TDEIcon::SizeMedium;
00218 m_iIconSize[3] = TDEIcon::SizeLarge;
00219 m_iIconSize[4] = TDEIcon::SizeHuge;
00220
00221
00222 TDEAction *a = new TDEAction( i18n( "Configure Background..." ), "background", 0, this, TQT_SLOT( slotBackgroundSettings() ),
00223 actionCollection(), "bgsettings" );
00224
00225 a->setToolTip( i18n( "Allows choosing of background settings for this view" ) );
00226 }
00227
00228 KonqDirPart::~KonqDirPart()
00229 {
00230
00231 delete m_findPart;
00232 delete d;
00233 d = 0;
00234 }
00235
00236 void KonqDirPart::adjustIconSizes()
00237 {
00238 d->findAvailableIconSizes();
00239 m_paSmallIcons->setEnabled(d->findNearestIconSize(16) < 20);
00240 d->aSmallMediumIcons->setEnabled(d->nearestIconSizeError(22) < 2);
00241 m_paMediumIcons->setEnabled(d->nearestIconSizeError(32) < 6);
00242 m_paLargeIcons->setEnabled(d->nearestIconSizeError(48) < 8);
00243 m_paHugeIcons->setEnabled(d->nearestIconSizeError(64) < 12);
00244 d->aEnormousIcons->setEnabled(d->findNearestIconSize(128) > 110);
00245
00246 if (m_pProps) {
00247 int size = m_pProps->iconSize();
00248 int nearSize = d->findNearestIconSize(size);
00249
00250 if (size != nearSize) {
00251 m_pProps->setIconSize(nearSize);
00252 }
00253 newIconSize(nearSize);
00254 }
00255 }
00256
00257 void KonqDirPart::setMimeFilter (const TQStringList& mime)
00258 {
00259 TQString u = url().url();
00260
00261 if ( u.isEmpty () )
00262 return;
00263
00264 if ( mime.isEmpty() )
00265 d->mimeFilters.clear();
00266 else
00267 d->mimeFilters = mime;
00268 }
00269
00270 TQStringList KonqDirPart::mimeFilter() const
00271 {
00272 return d->mimeFilters;
00273 }
00274
00275 TQScrollView * KonqDirPart::scrollWidget()
00276 {
00277 return static_cast<TQScrollView *>(widget());
00278 }
00279
00280 void KonqDirPart::slotBackgroundSettings()
00281 {
00282 TQColor bgndColor = m_pProps->bgColor( widget() );
00283 TQColor defaultColor = TDEGlobalSettings::baseColor();
00284
00285
00286 TQGuardedPtr<KonqBgndDialog> dlg = new KonqBgndDialog( widget(),
00287 m_pProps->bgPixmapFile(),
00288 bgndColor,
00289 defaultColor );
00290
00291 if ( dlg->exec() == KonqBgndDialog::Accepted )
00292 {
00293 if ( dlg->color().isValid() )
00294 {
00295 m_pProps->setBgColor( dlg->color() );
00296 m_pProps->setBgPixmapFile( "" );
00297 }
00298 else
00299 {
00300 m_pProps->setBgColor( defaultColor );
00301 m_pProps->setBgPixmapFile( dlg->pixmapFile() );
00302 }
00303 m_pProps->applyColors( scrollWidget()->viewport() );
00304 scrollWidget()->viewport()->repaint();
00305 }
00306
00307 delete dlg;
00308 }
00309
00310 void KonqDirPart::lmbClicked( KFileItem * fileItem )
00311 {
00312 KURL url = fileItem->url();
00313 if ( !fileItem->isReadable() )
00314 {
00315
00316 if ( ( !fileItem->isLocalFile() ) || TQFile::exists( url.path() ) )
00317 {
00318 KMessageBox::error( widget(), i18n("<p>You do not have enough permissions to read <b>%1</b></p>").arg(url.prettyURL()) );
00319 return;
00320 }
00321 KMessageBox::error( widget(), i18n("<p><b>%1</b> does not seem to exist anymore</p>").arg(url.prettyURL()) );
00322 return;
00323 }
00324
00325 KParts::URLArgs args;
00326 fileItem->determineMimeType();
00327 if ( fileItem->isMimeTypeKnown() )
00328 args.serviceType = fileItem->mimetype();
00329 args.trustedSource = true;
00330
00331 if (KonqFMSettings::settings()->alwaysNewWin() && fileItem->isDir()) {
00332
00333
00334
00335
00336
00337
00338 KParts::WindowArgs wargs;
00339 KParts::ReadOnlyPart* dummy;
00340 emit m_extension->createNewWindow( url, args, wargs, dummy );
00341 }
00342 else
00343 {
00344 kdDebug() << "emit m_extension->openURLRequest( " << url.url() << "," << args.serviceType << ")" << endl;
00345 emit m_extension->openURLRequest( url, args );
00346 }
00347 }
00348
00349 void KonqDirPart::mmbClicked( KFileItem * fileItem )
00350 {
00351 if ( fileItem )
00352 {
00353
00354
00355 KService::Ptr offer = KServiceTypeProfile::preferredService(fileItem->mimetype(), "Application");
00356
00357 if ( offer && offer->desktopEntryName().startsWith("kfmclient") )
00358 {
00359 KParts::URLArgs args;
00360 args.serviceType = fileItem->mimetype();
00361 emit m_extension->createNewWindow( fileItem->url(), args );
00362 }
00363 else
00364 fileItem->run();
00365 }
00366 else
00367 {
00368 m_extension->pasteRequest();
00369 }
00370 }
00371
00372 void KonqDirPart::saveState( TQDataStream& stream )
00373 {
00374 stream << m_nameFilter;
00375 }
00376
00377 void KonqDirPart::restoreState( TQDataStream& stream )
00378 {
00379 stream >> m_nameFilter;
00380 }
00381
00382 void KonqDirPart::saveFindState( TQDataStream& stream )
00383 {
00384
00385
00386 if ( !m_findPart )
00387 return;
00388
00389
00390
00391 stream << m_url;
00392
00393 KParts::BrowserExtension* ext = KParts::BrowserExtension::childObject( m_findPart );
00394 if( !ext )
00395 return;
00396
00397 ext->saveState( stream );
00398 }
00399
00400 void KonqDirPart::restoreFindState( TQDataStream& stream )
00401 {
00402
00403 stream >> m_url;
00404
00405 emit findOpen( this );
00406
00407 KParts::BrowserExtension* ext = KParts::BrowserExtension::childObject( m_findPart );
00408 slotClear();
00409
00410 if( !ext )
00411 return;
00412
00413 ext->restoreState( stream );
00414 }
00415
00416 void KonqDirPart::slotClipboardDataChanged()
00417 {
00418
00419
00420 KURL::List lst;
00421 TQMimeSource *data = TQApplication::clipboard()->data();
00422 if ( data->provides( "application/x-tde-cutselection" ) && data->provides( "text/uri-list" ) ) {
00423 if ( KonqDrag::decodeIsCutSelection( data ) ) {
00424 (void) KURLDrag::decode( data, lst );
00425 }
00426 }
00427
00428 disableIcons( lst );
00429
00430 updatePasteAction();
00431 }
00432
00433 void KonqDirPart::updatePasteAction()
00434 {
00435 TQString actionText = TDEIO::pasteActionText();
00436 bool paste = !actionText.isEmpty();
00437 if ( paste ) {
00438 emit m_extension->setActionText( "paste", actionText );
00439 }
00440 emit m_extension->enableAction( "paste", paste );
00441 }
00442
00443 void KonqDirPart::newItems(const KFileItemList &entries)
00444 {
00445 d->dirSizeDirty = true;
00446 if ( m_findPart ) {
00447 emitTotalCount();
00448 }
00449
00450 emit itemsAdded(entries);
00451 }
00452
00453 void KonqDirPart::deleteItem(KFileItem * fileItem)
00454 {
00455 d->dirSizeDirty = true;
00456 emit itemRemoved(fileItem);
00457 }
00458
00459 void KonqDirPart::refreshItems(const KFileItemList &entries)
00460 {
00461 emit itemsRefresh(entries);
00462 }
00463
00464 void KonqDirPart::emitTotalCount()
00465 {
00466 if ( !d->dirLister || d->dirLister->url().isEmpty() ) {
00467 return;
00468 }
00469 if ( d->dirSizeDirty ) {
00470 m_lDirSize = 0;
00471 m_lFileCount = 0;
00472 m_lDirCount = 0;
00473 KFileItemList entries = d->dirLister->items();
00474 for (KFileItemListIterator it(entries); it.current(); ++it)
00475 {
00476 if ( !it.current()->isDir() )
00477 {
00478 if (!it.current()->isLink()) {
00479 m_lDirSize += it.current()->size();
00480 }
00481 m_lFileCount++;
00482 }
00483 else {
00484 m_lDirCount++;
00485 }
00486 }
00487 d->dirSizeDirty = false;
00488 }
00489
00490 TQString summary =
00491 TDEIO::itemsSummaryString(m_lFileCount + m_lDirCount,
00492 m_lFileCount,
00493 m_lDirCount,
00494 m_lDirSize,
00495 true);
00496 bool bShowsResult = false;
00497 if (m_findPart)
00498 {
00499 TQVariant prop = m_findPart->property( "showsResult" );
00500 bShowsResult = prop.isValid() && prop.toBool();
00501 }
00502
00503 emit setStatusBarText( bShowsResult ? i18n("Search result: %1").arg(summary) : summary );
00504 }
00505
00506 void KonqDirPart::emitCounts( const KFileItemList & lst )
00507 {
00508 if ( lst.count() == 1 )
00509 emit setStatusBarText( ((KFileItemList)lst).first()->getStatusBarInfo() );
00510 else
00511 {
00512 long long fileSizeSum = 0;
00513 uint fileCount = 0;
00514 uint dirCount = 0;
00515
00516 for ( KFileItemListIterator it( lst ); it.current(); ++it )
00517 {
00518 if ( it.current()->isDir() )
00519 dirCount++;
00520 else
00521 {
00522 if ( !it.current()->isLink() )
00523 fileSizeSum += it.current()->size();
00524 fileCount++;
00525 }
00526 }
00527
00528 emit setStatusBarText( TDEIO::itemsSummaryString( fileCount + dirCount,
00529 fileCount, dirCount,
00530 fileSizeSum, true ) );
00531 }
00532 }
00533
00534 void KonqDirPart::emitCounts( const KFileItemList & lst, bool selectionChanged )
00535 {
00536 if ( lst.count() == 0 ) {
00537 emitTotalCount();
00538 }
00539 else {
00540 emitCounts( lst );
00541 }
00542
00543
00544
00545
00546
00547
00548
00549
00550 if ( selectionChanged ) {
00551 emit m_extension->selectionInfo( lst );
00552 }
00553 }
00554
00555 void KonqDirPart::emitMouseOver( const KFileItem* item )
00556 {
00557 emit m_extension->mouseOverInfo( item );
00558 }
00559
00560 void KonqDirPart::slotIconSizeToggled( bool toggleOn )
00561 {
00562
00563
00564
00565
00566
00567 if ( !toggleOn )
00568 return;
00569
00570 if ( m_paDefaultIcons->isChecked() )
00571 setIconSize(0);
00572 else if ( d->aEnormousIcons->isChecked() )
00573 setIconSize(d->findNearestIconSize(TDEIcon::SizeEnormous));
00574 else if ( m_paHugeIcons->isChecked() )
00575 setIconSize(d->findNearestIconSize(TDEIcon::SizeHuge));
00576 else if ( m_paLargeIcons->isChecked() )
00577 setIconSize(d->findNearestIconSize(TDEIcon::SizeLarge));
00578 else if ( m_paMediumIcons->isChecked() )
00579 setIconSize(d->findNearestIconSize(TDEIcon::SizeMedium));
00580 else if ( d->aSmallMediumIcons->isChecked() )
00581 setIconSize(d->findNearestIconSize(TDEIcon::SizeSmallMedium));
00582 else if ( m_paSmallIcons->isChecked() )
00583 setIconSize(d->findNearestIconSize(TDEIcon::SizeSmall));
00584 }
00585
00586 void KonqDirPart::slotIncIconSize()
00587 {
00588 int s = m_pProps->iconSize();
00589 s = s ? s : TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop );
00590 uint sizeIndex = 0;
00591 for ( uint idx = 1; idx < d->iconSize.count() ; ++idx )
00592 if (s == d->iconSize[idx]) {
00593 sizeIndex = idx;
00594 break;
00595 }
00596 if ( sizeIndex > 0 && sizeIndex < d->iconSize.count() - 1 )
00597 {
00598 setIconSize( d->iconSize[sizeIndex + 1] );
00599 }
00600 }
00601
00602 void KonqDirPart::slotDecIconSize()
00603 {
00604 int s = m_pProps->iconSize();
00605 s = s ? s : TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop );
00606 uint sizeIndex = 0;
00607 for ( uint idx = 1; idx < d->iconSize.count() ; ++idx )
00608 if (s == d->iconSize[idx]) {
00609 sizeIndex = idx;
00610 break;
00611 }
00612 if ( sizeIndex > 1 )
00613 {
00614 setIconSize( d->iconSize[sizeIndex - 1] );
00615 }
00616 }
00617
00618
00619 void KonqDirPart::newIconSize( int size )
00620 {
00621 int realSize = (size==0) ? TDEGlobal::iconLoader()->currentSize( TDEIcon::Desktop ) : size;
00622 m_paDecIconSize->setEnabled(realSize > d->iconSize[1]);
00623 m_paIncIconSize->setEnabled(realSize < d->iconSize.back());
00624
00625 m_paDefaultIcons->setChecked(size == 0);
00626 d->aEnormousIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeEnormous));
00627 m_paHugeIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeHuge));
00628 m_paLargeIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeLarge));
00629 m_paMediumIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeMedium));
00630 d->aSmallMediumIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeSmallMedium));
00631 m_paSmallIcons->setChecked(size == d->findNearestIconSize(TDEIcon::SizeSmall));
00632 }
00633
00634
00635 void KonqDirPart::setIconSize( int size )
00636 {
00637
00638 m_pProps->setIconSize( size );
00639 newIconSize( size );
00640 }
00641
00642 bool KonqDirPart::closeURL()
00643 {
00644
00645 return doCloseURL();
00646 }
00647
00648 bool KonqDirPart::openURL(const KURL& url)
00649 {
00650 if ( m_findPart )
00651 {
00652 kdDebug(1203) << "KonqDirPart::openURL -> emit findClosed " << this << endl;
00653 delete m_findPart;
00654 m_findPart = 0L;
00655 emit findClosed( this );
00656 }
00657
00658 m_url = url;
00659 emit aboutToOpenURL ();
00660
00661 return doOpenURL(url);
00662 }
00663
00664 void KonqDirPart::setFindPart( KParts::ReadOnlyPart * part )
00665 {
00666 assert(part);
00667 m_findPart = part;
00668 connect( m_findPart, TQT_SIGNAL( started() ),
00669 this, TQT_SLOT( slotStarted() ) );
00670 connect( m_findPart, TQT_SIGNAL( started() ),
00671 this, TQT_SLOT( slotStartAnimationSearching() ) );
00672 connect( m_findPart, TQT_SIGNAL( clear() ),
00673 this, TQT_SLOT( slotClear() ) );
00674 connect( m_findPart, TQT_SIGNAL( newItems( const KFileItemList & ) ),
00675 this, TQT_SLOT( slotNewItems( const KFileItemList & ) ) );
00676 connect( m_findPart, TQT_SIGNAL( finished() ),
00677 this, TQT_SLOT( slotCompleted() ) );
00678 connect( m_findPart, TQT_SIGNAL( finished() ),
00679 this, TQT_SLOT( slotStopAnimationSearching() ) );
00680 connect( m_findPart, TQT_SIGNAL( canceled() ),
00681 this, TQT_SLOT( slotCanceled() ) );
00682 connect( m_findPart, TQT_SIGNAL( canceled() ),
00683 this, TQT_SLOT( slotStopAnimationSearching() ) );
00684
00685 connect( m_findPart, TQT_SIGNAL( findClosed() ),
00686 this, TQT_SLOT( slotFindClosed() ) );
00687
00688 emit findOpened( this );
00689
00690
00691 m_findPart->openURL( url() );
00692 }
00693
00694 void KonqDirPart::slotFindClosed()
00695 {
00696 kdDebug(1203) << "KonqDirPart::slotFindClosed -> emit findClosed " << this << endl;
00697 delete m_findPart;
00698 m_findPart = 0L;
00699 emit findClosed( this );
00700
00701 openURL( url() );
00702 }
00703
00704 void KonqDirPart::slotIconChanged( int group )
00705 {
00706 if (group != TDEIcon::Desktop) return;
00707 adjustIconSizes();
00708 }
00709
00710 void KonqDirPart::slotStartAnimationSearching()
00711 {
00712 started(0);
00713 }
00714
00715 void KonqDirPart::slotStopAnimationSearching()
00716 {
00717 completed();
00718 }
00719
00720 void KonqDirPartBrowserExtension::saveState( TQDataStream &stream )
00721 {
00722 m_dirPart->saveState( stream );
00723 bool hasFindPart = m_dirPart->findPart();
00724 stream << hasFindPart;
00725 assert( ! ( hasFindPart && !strcmp(m_dirPart->className(), "KFindPart") ) );
00726 if ( !hasFindPart )
00727 KParts::BrowserExtension::saveState( stream );
00728 else {
00729 m_dirPart->saveFindState( stream );
00730 }
00731 }
00732
00733 void KonqDirPartBrowserExtension::restoreState( TQDataStream &stream )
00734 {
00735 m_dirPart->restoreState( stream );
00736 bool hasFindPart;
00737 stream >> hasFindPart;
00738 assert( ! ( hasFindPart && !strcmp(m_dirPart->className(), "KFindPart") ) );
00739 if ( !hasFindPart )
00740
00741 KParts::BrowserExtension::restoreState( stream );
00742 else {
00743 m_dirPart->restoreFindState( stream );
00744 }
00745 }
00746
00747
00748 void KonqDirPart::resetCount()
00749 {
00750 m_lDirSize = 0;
00751 m_lFileCount = 0;
00752 m_lDirCount = 0;
00753 d->dirSizeDirty = true;
00754 }
00755
00756 void KonqDirPart::setDirLister( KDirLister* lister )
00757 {
00758 d->dirLister = lister;
00759 }
00760
00761 #include "konq_dirpart.moc"