kfiletreeview.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef kfile_tree_view_h
00022 #define kfile_tree_view_h
00023
00024 #include <qmap.h>
00025 #include <qpoint.h>
00026 #include <qpixmap.h>
00027 #include <qstrlist.h>
00028 #include <qtooltip.h>
00029
00030 #include <klistview.h>
00031 #include <kdirnotify.h>
00032 #include <kio/job.h>
00033 #include <kfiletreeviewitem.h>
00034 #include <kfiletreebranch.h>
00035
00036 class QTimer;
00037
00038
00039
00040 class KFileTreeViewToolTip : public QToolTip
00041 {
00042 public:
00043 KFileTreeViewToolTip( QListView *view ) : QToolTip( view ), m_view( view ) {}
00044
00045 protected:
00046 virtual void maybeTip( const QPoint & );
00047
00048 private:
00049 QListView *m_view;
00050 };
00051
00052
00066 class KFileTreeView : public KListView
00067 {
00068 Q_OBJECT
00069 public:
00070 KFileTreeView( QWidget *parent, const char *name = 0 );
00071 virtual ~KFileTreeView();
00072
00076 KFileTreeViewItem * currentKFileTreeViewItem() const;
00077
00081 KURL currentURL() const;
00082
00096 KFileTreeBranch* addBranch( const KURL &path, const QString& name, bool showHidden = false );
00097
00101 virtual KFileTreeBranch* addBranch( const KURL &path, const QString& name ,
00102 const QPixmap& pix, bool showHidden = false );
00103
00107 virtual KFileTreeBranch* addBranch( KFileTreeBranch * );
00108
00114 virtual bool removeBranch( KFileTreeBranch *branch );
00115
00120 KFileTreeBranch *branch( const QString& searchName );
00121
00122
00126 KFileTreeBranchList& branches();
00127
00132 virtual void setDirOnlyMode( KFileTreeBranch *branch, bool );
00133
00142 KFileTreeViewItem *findItem( KFileTreeBranch* brnch, const QString& relUrl );
00143
00147 KFileTreeViewItem *findItem( const QString& branchName, const QString& relUrl );
00148
00152 bool showFolderOpenPixmap() const { return m_wantOpenFolderPixmaps; };
00153
00154 public slots:
00155
00163 virtual void setShowFolderOpenPixmap( bool showIt = true )
00164 { m_wantOpenFolderPixmaps = showIt; }
00165
00166 protected:
00171 virtual bool acceptDrag(QDropEvent* event) const;
00172 virtual QDragObject * dragObject();
00173
00174 virtual void startAnimation( KFileTreeViewItem* item, const char * iconBaseName = "kde", uint iconCount = 6 );
00175 virtual void stopAnimation( KFileTreeViewItem* item );
00176 virtual void contentsDragEnterEvent( QDragEnterEvent *e );
00177 virtual void contentsDragMoveEvent( QDragMoveEvent *e );
00178 virtual void contentsDragLeaveEvent( QDragLeaveEvent *e );
00179 virtual void contentsDropEvent( QDropEvent *ev );
00180
00181 protected slots:
00182 virtual void slotNewTreeViewItems( KFileTreeBranch*,
00183 const KFileTreeViewItemList& );
00184
00185 virtual void slotSetNextUrlToSelect( const KURL &url )
00186 { m_nextUrlToSelect = url; }
00187
00188 virtual QPixmap itemIcon( KFileTreeViewItem*, int gap = 0 ) const;
00189
00190 private slots:
00191 void slotExecuted( QListViewItem * );
00192 void slotExpanded( QListViewItem * );
00193 void slotCollapsed( QListViewItem *item );
00194
00195 void slotSelectionChanged();
00196
00197 void slotAnimation();
00198
00199 void slotAutoOpenFolder();
00200
00201 void slotOnItem( QListViewItem * );
00202 void slotItemRenamed(QListViewItem*, const QString &, int);
00203
00204 void slotPopulateFinished( KFileTreeViewItem* );
00205
00206
00207 signals:
00208
00209 void onItem( const QString& );
00210
00211 void dropped( QWidget*, QDropEvent* );
00212 void dropped( QWidget*, QDropEvent*, KURL::List& );
00213 void dropped( KURL::List&, KURL& );
00214
00215 void dropped( QWidget*, QDropEvent*, KURL::List&, KURL& );
00216
00217 void dropped( QDropEvent *, QListViewItem * );
00218 void dropped(KFileTreeView *, QDropEvent *, QListViewItem *);
00219 void dropped(QDropEvent *, QListViewItem *, QListViewItem *);
00220 void dropped(KFileTreeView *, QDropEvent *, QListViewItem *, QListViewItem *);
00221
00222 protected:
00223 KURL m_nextUrlToSelect;
00224
00225
00226 private:
00227 void clearTree();
00228
00229
00230
00231 KFileTreeBranchList m_branches;
00232
00233
00234 struct AnimationInfo
00235 {
00236 AnimationInfo( const char * _iconBaseName, uint _iconCount, const QPixmap & _originalPixmap )
00237 : iconBaseName(_iconBaseName), iconCount(_iconCount), iconNumber(1), originalPixmap(_originalPixmap) {}
00238 AnimationInfo() : iconCount(0) {}
00239 QCString iconBaseName;
00240 uint iconCount;
00241 uint iconNumber;
00242 QPixmap originalPixmap;
00243 };
00244 typedef QMap<KFileTreeViewItem *, AnimationInfo> MapCurrentOpeningFolders;
00245 MapCurrentOpeningFolders m_mapCurrentOpeningFolders;
00246
00247
00248 QTimer *m_animationTimer;
00249
00250 QPoint m_dragPos;
00251 bool m_bDrag;
00252
00253 bool m_wantOpenFolderPixmaps;
00254
00255 QListViewItem *m_currentBeforeDropItem;
00256 QListViewItem *m_dropItem;
00257 QStrList m_lstDropFormats;
00258 QPixmap m_openFolderPixmap;
00259 QTimer *m_autoOpenTimer;
00260
00261 KFileTreeViewToolTip m_toolTip;
00262
00263
00264 protected:
00265 virtual void virtual_hook( int id, void* data );
00266 private:
00267 class KFileTreeViewPrivate;
00268 KFileTreeViewPrivate *d;
00269 };
00270
00271 #endif
This file is part of the documentation for kio Library Version 3.2.3.