kio Library API Documentation

kfiletreebranch.h

00001 
00002 /* This file is part of the KDE project
00003    Copyright (C) 2000 David Faure <faure@kde.org>
00004                  2000 Carsten Pfeiffer <pfeiffer@kde.org>
00005                  2001 Klaas Freitag <freitag@suse.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License version 2 as published by the Free Software Foundation.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 
00022 #ifndef kfile_tree_branch_h
00023 #define kfile_tree_branch_h
00024 
00025 #include <qdict.h>
00026 #include <qlistview.h>
00027 
00028 #include <kfileitem.h>
00029 #include <kio/global.h>
00030 #include <kdirlister.h>
00031 #include <kio/job.h>
00032 #include <kfiletreeviewitem.h>
00033 
00034 class KURL;
00035 class KURL::List;
00036 class KFileTreeView;
00037 
00038 
00049 class KFileTreeBranch : public KDirLister
00050 {
00051    Q_OBJECT
00052 public:
00063    KFileTreeBranch( KFileTreeView*, const KURL& url, const QString& name,
00064                     const QPixmap& pix, bool showHidden = false,
00065             KFileTreeViewItem *branchRoot = 0 );
00066 
00070    KURL     rootUrl() const { return( m_startURL ); }
00071 
00078    virtual void     setRoot( KFileTreeViewItem *r ){ m_root = r; };
00079 
00083    KFileTreeViewItem *root( ) { return( m_root );}
00084 
00088    QString      name() const { return( m_name ); }
00089 
00093    virtual void         setName( const QString n ) { m_name = n; };
00094 
00095    /*
00096     * returns the current root item pixmap set in the constructor. The root
00097     * item pixmap defaults to the icon for directories.
00098     * @see openPixmap()
00099     */
00100    const QPixmap& pixmap(){ return(m_rootIcon); }
00101 
00102    /*
00103     * returns the current root item pixmap set by @ref setOpenPixmap()
00104     * which is displayed if the branch is expanded.
00105     * The root item pixmap defaults to the icon for directories.
00106     * @see pixmap()
00107     * Note that it depends on @ref KFileTreeView::showFolderOpenPximap weather
00108     * open pixmap are displayed or not.
00109     */
00110    const QPixmap& openPixmap() { return(m_openRootIcon); }
00111 
00116    bool showExtensions( ) const;
00117 
00121    void setOpen( bool setopen = true )
00122       { if( root() ) root()->setOpen( setopen ); }
00123 
00132    void setChildRecurse( bool t=true );
00133 
00138    bool childRecurse()
00139       { return m_recurseChildren; }
00140 
00141 public slots:
00148    virtual bool populate( const KURL &url, KFileTreeViewItem* currItem );
00149 
00156    virtual void setShowExtensions( bool visible = true );
00157 
00158    void setOpenPixmap( const QPixmap& pix );
00159 
00160 protected:
00165    virtual KFileTreeViewItem *createTreeViewItem( KFileTreeViewItem *parent,
00166                           KFileItem *fileItem );
00167 
00168 public:
00172    virtual KFileTreeViewItem *findTVIByURL( const KURL& );
00173 
00174 signals:
00178    void populateFinished( KFileTreeViewItem * );
00179 
00185    void newTreeViewItems( KFileTreeBranch*, const KFileTreeViewItemList& );
00186 
00190    void directoryChildCount( KFileTreeViewItem* item, int count );
00191 
00192 private slots:
00193    void addItems( const KFileItemList& );
00194    void slCompleted( const KURL& );
00195    void slotCanceled( const KURL& );
00196    void slotListerStarted( const KURL& );
00197    void slotDeleteItem( KFileItem* );
00198    void slotDirlisterClear();
00199    void slotDirlisterClearURL( const KURL& url );
00200    void slotRedirect( const KURL& oldUrl, const KURL&newUrl );
00201 
00202 private:
00203    KFileTreeViewItem    *parentKFTVItem( KFileItem *item );
00204 
00205    KFileTreeViewItem    *m_root;
00206    KURL         m_startURL;
00207    QString      m_name;
00208    QPixmap      m_rootIcon;
00209    QPixmap              m_openRootIcon;
00210 
00211    /* this list holds the url's which children are opened. */
00212    KURL::List           m_openChildrenURLs;
00213 
00214 
00215    /* The next two members are used for caching purposes in findTVIByURL. */
00216    KURL                 m_lastFoundURL;
00217    KFileTreeViewItem   *m_lastFoundItem;
00218 
00219    bool                 m_recurseChildren :1;
00220    bool                 m_showExtensions  :1;
00221 
00222 protected:
00223    virtual void virtual_hook( int id, void* data );
00224 private:
00225    class KFileTreeBranchPrivate;
00226    KFileTreeBranchPrivate *d;
00227 };
00228 
00229 
00233 typedef QPtrList<KFileTreeBranch> KFileTreeBranchList;
00234 
00238 typedef QPtrListIterator<KFileTreeBranch> KFileTreeBranchIterator;
00239 
00240 #endif
00241 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:30 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001