当前位置: 首页>>代码示例>>C++>>正文


C++ KFileItem::extraData方法代码示例

本文整理汇总了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 );
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:30,代码来源:tdefiletreebranch.cpp

示例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 );
    }
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:11,代码来源:tdefiletreebranch.cpp

示例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 );
}
开发者ID:Fat-Zer,项目名称:tdelibs,代码行数:85,代码来源:tdefiletreebranch.cpp


注:本文中的KFileItem::extraData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。