本文整理汇总了C++中KFileItem::extraData方法的典型用法代码示例。如果您正苦于以下问题:C++ KFileItem::extraData方法的具体用法?C++ KFileItem::extraData怎么用?C++ KFileItem::extraData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFileItem
的用法示例。
在下文中一共展示了KFileItem::extraData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findTVIByURL
KFileTreeViewItem* KFileTreeBranch::findTVIByURL( const KURL& url )
{
KFileTreeViewItem *resultItem = 0;
if( m_startURL.equals(url, true) )
{
kdDebug(250) << "findByURL: Returning root as a parent !" << endl;
resultItem = m_root;
}
else if( m_lastFoundURL.equals( url, true ))
{
kdDebug(250) << "findByURL: Returning from lastFoundURL!" << endl;
resultItem = m_lastFoundItem;
}
else
{
kdDebug(250) << "findByURL: searching by dirlister: " << url.url() << endl;
KFileItem *it = findByURL( url );
if( it )
{
resultItem = static_cast<KFileTreeViewItem*>(it->extraData(this));
m_lastFoundItem = resultItem;
m_lastFoundURL = url;
}
}
return( resultItem );
}
示例2: slotDirlisterClearURL
void KFileTreeBranch::slotDirlisterClearURL( const KURL& url )
{
kdDebug(250)<< "*** Clear for URL !" << url.prettyURL() << endl;
KFileItem *item = findByURL( url );
if( item )
{
KFileTreeViewItem *ftvi =
static_cast<KFileTreeViewItem *>(item->extraData( this ));
deleteChildrenOf( ftvi );
}
}
示例3: addItems
void KFileTreeBranch::addItems( const KFileItemList& list )
{
KFileItemListIterator it( list );
kdDebug(250) << "Adding " << list.count() << " items !" << endl;
KFileItem *currItem;
KFileTreeViewItemList treeViewItList;
KFileTreeViewItem *parentItem = 0;
while ( (currItem = it.current()) != 0 )
{
parentItem = parentKFTVItem( currItem );
/* Only create a new KFileTreeViewItem if it does not yet exist */
KFileTreeViewItem *newKFTVI =
static_cast<KFileTreeViewItem *>(currItem->extraData( this ));
if( ! newKFTVI )
{
newKFTVI = createTreeViewItem( parentItem, currItem );
if (!newKFTVI)
{
// TODO: Don't fail if parentItem == 0
++it;
continue;
}
currItem->setExtraData( this, newKFTVI );
/* Cut off the file extension in case it is not a directory */
if( !m_showExtensions && !currItem->isDir() ) /* Need to cut the extension */
{
TQString name = currItem->text();
int mPoint = name.findRev( '.' );
if( mPoint > 0 )
name = name.left( mPoint );
newKFTVI->setText( 0, name );
}
}
/* Now try to find out if there are children for dirs in the treeview */
/* This stats a directory on the local file system and checks the */
/* hardlink entry in the stat-buf. This works only for local directories. */
if( dirOnlyMode() && !m_recurseChildren && currItem->isLocalFile( ) && currItem->isDir() )
{
KURL url = currItem->url();
TQString filename = url.directory( false, true ) + url.fileName();
/* do the stat trick of Carsten. The problem is, that the hardlink
* count only contains directory links. Thus, this method only seem
* to work in dir-only mode */
kdDebug(250) << "Doing stat on " << filename << endl;
KDE_struct_stat statBuf;
if( KDE_stat( TQFile::encodeName( filename ), &statBuf ) == 0 )
{
int hardLinks = statBuf.st_nlink; /* Count of dirs */
kdDebug(250) << "stat succeeded, hardlinks: " << hardLinks << endl;
// If the link count is > 2, the directory likely has subdirs. If it's < 2
// it's something weird like a mounted SMB share. In that case we don't know
// if there are subdirs, thus show it as expandable.
if( hardLinks != 2 )
{
newKFTVI->setExpandable(true);
}
else
{
newKFTVI->setExpandable(false);
}
if( hardLinks >= 2 ) // "Normal" directory with subdirs
{
kdDebug(250) << "Emitting for " << url.prettyURL() << endl;
emit( directoryChildCount( newKFTVI, hardLinks-2)); // parentItem, hardLinks-1 ));
}
}
else
{
kdDebug(250) << "stat of " << filename << " failed !" << endl;
}
}
++it;
treeViewItList.append( newKFTVI );
}
emit newTreeViewItems( this, treeViewItList );
}