tdeio/tdefile
tdefiletreeview.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef TDEFILE_TREE_VIEW_H
00022 #define TDEFILE_TREE_VIEW_H
00023
00024 #include <tqmap.h>
00025 #include <tqpoint.h>
00026 #include <tqpixmap.h>
00027 #include <tqstrlist.h>
00028 #include <tqtooltip.h>
00029
00030 #include <tdelistview.h>
00031 #include <kdirnotify.h>
00032 #include <tdeio/job.h>
00033 #include <tdefiletreeviewitem.h>
00034 #include <tdefiletreebranch.h>
00035
00036 class TQTimer;
00037
00038
00039
00040 class TDEIO_EXPORT KFileTreeViewToolTip : public TQToolTip
00041 {
00042 public:
00043 KFileTreeViewToolTip( TQListView *view ) : TQToolTip( view ), m_view( view ) {}
00044
00045 protected:
00046 virtual void maybeTip( const TQPoint & );
00047
00048 private:
00049 TQListView *m_view;
00050 };
00051
00052
00066 class TDEIO_EXPORT KFileTreeView : public TDEListView
00067 {
00068 Q_OBJECT
00069 public:
00070 KFileTreeView( TQWidget *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 TQString& name, bool showHidden = false );
00097
00101 virtual KFileTreeBranch* addBranch( const KURL &path, const TQString& name ,
00102 const TQPixmap& pix, bool showHidden = false );
00103
00107 virtual KFileTreeBranch* addBranch( KFileTreeBranch * );
00108
00114 virtual bool removeBranch( KFileTreeBranch *branch );
00115
00120 KFileTreeBranch *branch( const TQString& searchName );
00121
00122
00126 KFileTreeBranchList& branches();
00127
00132 virtual void setDirOnlyMode( KFileTreeBranch *branch, bool );
00133
00142 KFileTreeViewItem *findItem( KFileTreeBranch* brnch, const TQString& relUrl );
00143
00147 KFileTreeViewItem *findItem( const TQString& branchName, const TQString& 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(TQDropEvent* event) const;
00172 virtual TQDragObject * 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( TQDragEnterEvent *e );
00177 virtual void contentsDragMoveEvent( TQDragMoveEvent *e );
00178 virtual void contentsDragLeaveEvent( TQDragLeaveEvent *e );
00179 virtual void contentsDropEvent( TQDropEvent *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 TQPixmap itemIcon( KFileTreeViewItem*, int gap = 0 ) const;
00189
00190 private slots:
00191 void slotExecuted( TQListViewItem * );
00192 void slotExpanded( TQListViewItem * );
00193 void slotCollapsed( TQListViewItem *item );
00194
00195 void slotSelectionChanged();
00196
00197 void slotAnimation();
00198
00199 void slotAutoOpenFolder();
00200
00201 void slotOnItem( TQListViewItem * );
00202 void slotItemRenamed(TQListViewItem*, const TQString &, int);
00203
00204 void slotPopulateFinished( KFileTreeViewItem* );
00205
00206
00207 signals:
00208
00209 void onItem( const TQString& );
00210
00211 void dropped( TQWidget*, TQDropEvent* );
00212 void dropped( TQWidget*, TQDropEvent*, KURL::List& );
00213 void dropped( KURL::List&, KURL& );
00214
00215 void dropped( TQWidget*, TQDropEvent*, KURL::List&, KURL& );
00216
00217 void dropped( TQDropEvent *e, TQListViewItem * after);
00218 void dropped(KFileTreeView *, TQDropEvent *, TQListViewItem *);
00219 void dropped(TQDropEvent *e, TQListViewItem * parent, TQListViewItem * after);
00220 void dropped(KFileTreeView *, TQDropEvent *, TQListViewItem *, TQListViewItem *);
00221
00222 protected:
00223 KURL m_nextUrlToSelect;
00224
00225
00226 private:
00227
00228 bool isValidItem( TQListViewItem *item);
00229 void clearTree();
00230
00231
00232
00233 KFileTreeBranchList m_branches;
00234
00235
00236 struct AnimationInfo
00237 {
00238 AnimationInfo( const char * _iconBaseName, uint _iconCount, const TQPixmap & _originalPixmap )
00239 : iconBaseName(_iconBaseName), iconCount(_iconCount), iconNumber(1), originalPixmap(_originalPixmap) {}
00240 AnimationInfo() : iconCount(0) {}
00241 TQCString iconBaseName;
00242 uint iconCount;
00243 uint iconNumber;
00244 TQPixmap originalPixmap;
00245 };
00246 typedef TQMap<KFileTreeViewItem *, AnimationInfo> MapCurrentOpeningFolders;
00247 MapCurrentOpeningFolders m_mapCurrentOpeningFolders;
00248
00249
00250 TQTimer *m_animationTimer;
00251
00252 TQPoint m_dragPos;
00253 bool m_bDrag;
00254
00255 bool m_wantOpenFolderPixmaps;
00256
00257 TQListViewItem *m_currentBeforeDropItem;
00258 TQListViewItem *m_dropItem;
00259 TQStrList m_lstDropFormats;
00260 TQPixmap m_openFolderPixmap;
00261 TQTimer *m_autoOpenTimer;
00262
00263 KFileTreeViewToolTip m_toolTip;
00264
00265
00266 protected:
00267 virtual void virtual_hook( int id, void* data );
00268 private:
00269 class KFileTreeViewPrivate;
00270 KFileTreeViewPrivate *d;
00271 };
00272
00273 #endif