KDE3Support
kfiletreebranch.h
Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef kfile_tree_branch_h 00023 #define kfile_tree_branch_h 00024 00025 class QColorGroup; 00026 00027 #include <Qt3Support/Q3ListView> 00028 00029 #include <kfileitem.h> 00030 #include <kio/global.h> 00031 #include <kdirlister.h> 00032 #include <kio/job.h> 00033 #include <k3filetreeviewitem.h> 00034 00035 class KUrl; 00036 class K3FileTreeView; 00037 00038 00049 class KDE3SUPPORT_EXPORT KFileTreeBranch : public KDirLister 00050 { 00051 Q_OBJECT 00052 public: 00063 KFileTreeBranch( K3FileTreeView*, const KUrl& url, const QString& name, 00064 const QPixmap& pix, bool showHidden = false, 00065 K3FileTreeViewItem *branchRoot = 0 ); 00066 00070 KUrl rootUrl() const; 00071 00078 virtual void setRoot( K3FileTreeViewItem *r ); 00079 00083 K3FileTreeViewItem *root( ); 00084 00088 QString name() const; 00089 00093 virtual void setName( const QString 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 QPixmap pixmap() const; 00101 00102 /* 00103 * returns the current root item pixmap set by 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 K3FileTreeView::showFolderOpenPximap weather 00108 * open pixmap are displayed or not. 00109 */ 00110 QPixmap openPixmap() const; 00111 00116 bool showExtensions( ) const; 00117 00121 void setOpen( bool setopen = true ); 00122 00131 void setChildRecurse( bool t=true ); 00132 00137 bool childRecurse(); 00138 00139 public Q_SLOTS: 00146 virtual bool populate( const KUrl &url, K3FileTreeViewItem* currItem ); 00147 00154 virtual void setShowExtensions( bool visible = true ); 00155 00156 void setOpenPixmap( const QPixmap& pix ); 00157 00158 protected: 00163 virtual K3FileTreeViewItem *createTreeViewItem( K3FileTreeViewItem *parent, 00164 const KFileItem &fileItem ); 00165 00166 public: 00170 virtual K3FileTreeViewItem *findTVIByUrl( const KUrl& ); 00171 00172 Q_SIGNALS: 00176 void populateFinished( K3FileTreeViewItem * ); 00177 00183 void newTreeViewItems( KFileTreeBranch*, const K3FileTreeViewItemList& ); 00184 00188 void directoryChildCount( K3FileTreeViewItem* item, int count ); 00189 00190 private Q_SLOTS: 00191 void slotRefreshItems( const QList<QPair<KFileItem, KFileItem> >& ); 00192 void addItems( const KFileItemList& ); 00193 void slCompleted( const KUrl& ); 00194 void slotCanceled( const KUrl& ); 00195 void slotListerStarted( const KUrl& ); 00196 void slotDeleteItem( const KFileItem& ); 00197 void slotDirlisterClear(); 00198 void slotDirlisterClearUrl( const KUrl& url ); 00199 void slotRedirect( const KUrl& oldUrl, const KUrl&newUrl ); 00200 00201 private: 00202 K3FileTreeViewItem *parentKFTVItem( const KFileItem &item ); 00203 static void deleteChildrenOf( Q3ListViewItem *parent ); 00204 K3FileTreeViewItem* treeItemForFileItem(const KFileItem &it); 00205 00206 K3FileTreeViewItem *m_root; 00207 KUrl m_startURL; 00208 QString m_name; 00209 QPixmap m_rootIcon; 00210 QPixmap m_openRootIcon; 00211 00212 /* this list holds the url's which children are opened. */ 00213 KUrl::List m_openChildrenURLs; 00214 00215 00216 /* The next two members are used for caching purposes in findTVIByURL. */ 00217 KUrl m_lastFoundURL; 00218 K3FileTreeViewItem *m_lastFoundItem; 00219 00220 bool m_recurseChildren :1; 00221 bool m_showExtensions :1; 00222 00223 private: 00224 class KFileTreeBranchPrivate; 00225 KFileTreeBranchPrivate *d; 00226 }; 00227 00228 00232 typedef Q3PtrList<KFileTreeBranch> KFileTreeBranchList; 00233 00237 typedef Q3PtrListIterator<KFileTreeBranch> KFileTreeBranchIterator; 00238 00239 #endif 00240
KDE 4.6 API Reference