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
00228
bool isValidItem(
QListViewItem *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 QPixmap & _originalPixmap )
00239 : iconBaseName(_iconBaseName), iconCount(_iconCount), iconNumber(1), originalPixmap(_originalPixmap) {}
00240 AnimationInfo() : iconCount(0) {}
00241
QCString iconBaseName;
00242 uint iconCount;
00243 uint iconNumber;
00244
QPixmap originalPixmap;
00245 };
00246
typedef QMap<KFileTreeViewItem *, AnimationInfo> MapCurrentOpeningFolders;
00247 MapCurrentOpeningFolders m_mapCurrentOpeningFolders;
00248
00249
00250
QTimer *m_animationTimer;
00251
00252
QPoint m_dragPos;
00253
bool m_bDrag;
00254
00255
bool m_wantOpenFolderPixmaps;
00256
00257
QListViewItem *m_currentBeforeDropItem;
00258
QListViewItem *m_dropItem;
00259
QStrList m_lstDropFormats;
00260
QPixmap m_openFolderPixmap;
00261
QTimer *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