23 #include <QtCore/QFile>
29 #include <sys/types.h>
36 const QPixmap& pix,
bool showHidden,
44 m_openRootIcon( pix ),
45 m_recurseChildren(true),
46 m_showExtensions(true)
59 m_root->setExpandable(
true );
60 m_root->setPixmap( 0, pix );
61 m_root->setText( 0, name );
72 this, SLOT(slCompleted(
KUrl)));
75 this, SLOT(slotListerStarted(
KUrl)));
81 this, SLOT(slotCanceled(
KUrl)));
83 connect(
this, SIGNAL(
clear()),
84 this, SLOT(slotDirlisterClear()));
87 this, SLOT(slotDirlisterClearUrl(
KUrl)));
90 this, SLOT(slotRedirect(
KUrl,
KUrl)));
92 m_openChildrenURLs.append( url );
127 return m_openRootIcon;
133 root()->setOpen( setopen );
139 m_openRootIcon = pix;
141 if(
root()->isOpen())
143 root()->setPixmap( 0, pix );
147 void KFileTreeBranch::slotListerStarted(
const KUrl &url )
165 if( item.
isNull() )
return 0;
173 dirUrl.setFileName(
QString() );
184 kDebug(250) <<
"Refreshing " <<
list.count() <<
" items !";
186 for (
int i = 0; i <
list.count(); ++i )
200 kDebug(250) <<
"Adding " << list.count() <<
" items !";
204 KFileItemList::const_iterator kit = list.begin();
205 const KFileItemList::const_iterator kend = list.end();
206 for ( ; kit != kend; ++kit )
209 parentItem = parentKFTVItem( currItem );
225 if( !m_showExtensions && !currItem.
isDir() )
228 int mPoint = name.lastIndexOf(
'.' );
230 name = name.left( mPoint );
231 newKFTVI->setText( 0, name );
245 kDebug(250) <<
"Doing stat on " << filename;
246 KDE_struct_stat statBuf;
247 if(
KDE::stat( filename , &statBuf ) == 0 )
249 int hardLinks = statBuf.st_nlink;
250 kDebug(250) <<
"stat succeeded, hardlinks: " << hardLinks;
257 newKFTVI->setExpandable(
true);
261 newKFTVI->setExpandable(
false);
271 kDebug(250) <<
"stat of " << filename <<
" failed !";
274 treeViewItList.append( newKFTVI );
284 if( parent && !fileItem.
isNull() )
292 kDebug(250) <<
"createTreeViewItem: Have no parent";
299 m_recurseChildren = t;
301 m_openChildrenURLs.clear();
306 return m_recurseChildren;
312 m_showExtensions = visible;
317 return( m_showExtensions );
325 void KFileTreeBranch::slotDeleteItem(
const KFileItem &it )
334 kDebug( 250 ) <<
"Child count: " << kfti->childCount();
335 if( kfti->childCount() > 0 )
341 kDebug(250) <<
"Calling child to be deleted !";
348 kDebug(250) <<
"Found corresponding K3FileTreeViewItem";
351 m_lastFoundURL =
KUrl();
352 m_lastFoundItem = 0L;
358 kDebug(250) <<
"Error: kfiletreeviewitem: "<< kfti;
363 void KFileTreeBranch::slotCanceled(
const KUrl& url )
367 m_openChildrenURLs.removeAll( url);
375 void KFileTreeBranch::slotDirlisterClear()
377 kDebug(250)<<
"*** Clear all !";
380 deleteChildrenOf( m_root );
383 void KFileTreeBranch::slotDirlisterClearUrl(
const KUrl& url )
390 deleteChildrenOf( ftvi );
401 while ( parent->firstChild() )
402 delete parent->firstChild();
405 void KFileTreeBranch::slotRedirect(
const KUrl& oldUrl,
const KUrl&newUrl )
419 kDebug(250) <<
"findByURL: Returning root as a parent !";
424 kDebug(250) <<
"findByURL: Returning from lastFoundURL!";
425 resultItem = m_lastFoundItem;
429 kDebug(250) <<
"findByURL: searching by dirlister: " << url.
url();
435 resultItem = treeItemForFileItem(it);
436 m_lastFoundItem = resultItem;
437 m_lastFoundURL =
url;
441 return( resultItem );
445 void KFileTreeBranch::slCompleted(
const KUrl& url )
449 if( ! currParent )
return;
451 kDebug(250) <<
"current parent " << currParent <<
" is already listed: "
467 kDebug(250) <<
"recurseChildren: " << m_recurseChildren;
474 bool wantRecurseUrl =
false;
476 for ( KUrl::List::Iterator it = m_openChildrenURLs.begin();
477 it != m_openChildrenURLs.end(); ++it )
481 wantRecurseUrl =
true;
485 kDebug(250) <<
"Recursing " << url.
prettyUrl() <<
"? " << wantRecurseUrl;
487 if( wantRecurseUrl && currParent )
499 kDebug( 250 ) <<
"No children to recuse";
505 m_openChildrenURLs.removeAll(url);
535 kDebug(250) <<
"skipping to recurse in complete-slot";
549 if( m_recurseChildren )
551 m_openChildrenURLs.append( url );
562 kDebug(250) <<
"Children already existing in treeview!";
569 #include "kfiletreebranch.moc"