KDE3Support
k3filetreeview.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2000 David Faure <faure@kde.org> 00003 2000 Carsten Pfeiffer <pfeiffer@kde.org> 00004 2002 Klaas Freitag <freitag@suse.de> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef kfile_tree_view_h 00022 #define kfile_tree_view_h 00023 00024 #include <QtCore/QMap> 00025 #include <QtCore/QPoint> 00026 #include <QtGui/QPixmap> 00027 00028 00029 00030 #include <k3listview.h> 00031 #include <kdirnotify.h> 00032 #include <kio/job.h> 00033 #include <k3filetreeviewitem.h> 00034 #include <kfiletreebranch.h> 00035 00036 class QTimer; 00037 00038 00039 00053 class KDE3SUPPORT_EXPORT K3FileTreeView : public K3ListView 00054 { 00055 Q_OBJECT 00056 public: 00057 K3FileTreeView( QWidget *parent ); 00058 virtual ~K3FileTreeView(); 00059 00063 K3FileTreeViewItem * currentKFileTreeViewItem() const; 00064 00068 KUrl currentUrl() const; 00069 00083 KFileTreeBranch* addBranch( const KUrl &path, const QString& name, bool showHidden = false ); 00084 00088 virtual KFileTreeBranch* addBranch( const KUrl &path, const QString& name , 00089 const QPixmap& pix, bool showHidden = false ); 00090 00094 virtual KFileTreeBranch* addBranch( KFileTreeBranch * ); 00095 00101 virtual bool removeBranch( KFileTreeBranch *branch ); 00102 00107 KFileTreeBranch *branch( const QString& searchName ); 00108 00109 00113 KFileTreeBranchList& branches(); 00114 00119 virtual void setDirOnlyMode( KFileTreeBranch *branch, bool ); 00120 00129 K3FileTreeViewItem *findItem( KFileTreeBranch* brnch, const QString& relUrl ); 00130 00134 K3FileTreeViewItem *findItem( const QString& branchName, const QString& relUrl ); 00135 00139 bool showFolderOpenPixmap() const; 00140 00141 public Q_SLOTS: 00142 00150 virtual void setShowFolderOpenPixmap( bool showIt = true ); 00151 00152 protected: 00157 virtual bool acceptDrag(QDropEvent* event) const; 00158 virtual Q3DragObject * dragObject(); 00159 00160 virtual void startAnimation( K3FileTreeViewItem* item, const char * iconBaseName = "kde", uint iconCount = 6 ); 00161 virtual void stopAnimation( K3FileTreeViewItem* item ); 00162 virtual void contentsDragEnterEvent( QDragEnterEvent *e ); 00163 virtual void contentsDragMoveEvent( QDragMoveEvent *e ); 00164 virtual void contentsDragLeaveEvent( QDragLeaveEvent *e ); 00165 virtual void contentsDropEvent( QDropEvent *ev ); 00166 00167 protected Q_SLOTS: 00168 virtual void slotNewTreeViewItems( KFileTreeBranch*, 00169 const K3FileTreeViewItemList& ); 00170 00171 virtual void slotSetNextUrlToSelect( const KUrl &url ); 00172 00173 virtual QPixmap itemIcon( K3FileTreeViewItem*, int gap = 0 ) const; 00174 00175 private Q_SLOTS: 00176 void slotExecuted( Q3ListViewItem * ); 00177 void slotExpanded( Q3ListViewItem * ); 00178 void slotCollapsed( Q3ListViewItem *item ); 00179 00180 void slotSelectionChanged(); 00181 00182 void slotAnimation(); 00183 00184 void slotAutoOpenFolder(); 00185 00186 void slotOnItem( Q3ListViewItem * ); 00187 void slotItemRenamed(Q3ListViewItem*, const QString &, int); 00188 00189 void slotPopulateFinished( K3FileTreeViewItem* ); 00190 00191 00192 Q_SIGNALS: 00193 00194 void onItem( const QString& ); 00195 /* New signals if you like it ? */ 00196 void dropped( QWidget*, QDropEvent* ); 00197 void dropped( QWidget*, QDropEvent*, KUrl::List& ); 00198 void dropped( KUrl::List&, KUrl& ); 00199 // The drop event allows to differentiate between move and copy 00200 void dropped( QWidget*, QDropEvent*, KUrl::List&, KUrl& ); 00201 00202 void dropped( QDropEvent *, Q3ListViewItem * ); 00203 void dropped(K3FileTreeView *, QDropEvent *, Q3ListViewItem *); 00204 void dropped(QDropEvent *, Q3ListViewItem *, Q3ListViewItem *); 00205 void dropped(K3FileTreeView *, QDropEvent *, Q3ListViewItem *, Q3ListViewItem *); 00206 00207 protected: 00208 KUrl m_nextUrlToSelect; 00209 00210 00211 private: 00212 // Returns whether item is still a valid item in the tree 00213 bool isValidItem( Q3ListViewItem *item); 00214 void clearTree(); 00215 00216 00217 /* List that holds the branches */ 00218 KFileTreeBranchList m_branches; 00219 00220 00221 struct AnimationInfo 00222 { 00223 AnimationInfo( const char * _iconBaseName, uint _iconCount, const QPixmap & _originalPixmap ) 00224 : iconBaseName(_iconBaseName), iconCount(_iconCount), iconNumber(1), originalPixmap(_originalPixmap) {} 00225 AnimationInfo() : iconCount(0) {} 00226 QByteArray iconBaseName; 00227 uint iconCount; 00228 uint iconNumber; 00229 QPixmap originalPixmap; 00230 }; 00231 typedef QMap<K3FileTreeViewItem *, AnimationInfo> MapCurrentOpeningFolders; 00232 MapCurrentOpeningFolders m_mapCurrentOpeningFolders; 00233 00234 00235 QTimer *m_animationTimer; 00236 00237 QPoint m_dragPos; 00238 bool m_bDrag; 00239 00240 bool m_wantOpenFolderPixmaps; // Flag weather the folder should have open-folder pixmaps 00241 00242 Q3ListViewItem *m_currentBeforeDropItem; // The item that was current before the drag-enter event happened 00243 Q3ListViewItem *m_dropItem; // The item we are moving the mouse over (during a drag) 00244 QPixmap m_openFolderPixmap; 00245 QTimer *m_autoOpenTimer; 00246 00247 private: 00248 class K3FileTreeViewPrivate; 00249 K3FileTreeViewPrivate *d; 00250 }; 00251 00252 #endif
KDE 4.6 API Reference