kfiletreeview.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kfiletreeview.h

    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., 59 Temple Place - Suite 330,
    00018    Boston, MA 02111-1307, USA.
    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 *brnch, 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    /* New signals if you like it ? */
    00211    void dropped( QWidget*, QDropEvent* );
    00212    void dropped( QWidget*, QDropEvent*, KURL::List& );
    00213    void dropped( KURL::List&, KURL& );
    00214
    00215    void dropped( QDropEvent *, QListViewItem * );
    00216    void dropped (KFileTreeView *, QDropEvent *, QListViewItem *);
    00217    void dropped (QDropEvent *, QListViewItem *, QListViewItem *);
    00218    void dropped (KFileTreeView *, QDropEvent *, QListViewItem *, QListViewItem *);
    00219
    00220 protected:
    00221    KURL m_nextUrlToSelect;
    00222
    00223
    00224 private:
    00225     void clearTree();
    00226
    00227
    00228    /* List that holds the branches */
    00229     KFileTreeBranchList m_branches;
    00230
    00231
    00232     struct AnimationInfo
    00233     {
    00234         AnimationInfo( const char * _iconBaseName, uint _iconCount, const QPixmap & _originalPixmap )
    00235             : iconBaseName(_iconBaseName), iconCount(_iconCount), iconNumber(1), originalPixmap(_originalPixmap) {}
    00236         AnimationInfo() : iconCount(0) {}
    00237         QCString iconBaseName;
    00238         uint iconCount;
    00239         uint iconNumber;
    00240         QPixmap originalPixmap;
    00241     };
    00242     typedef QMap<KFileTreeViewItem *, AnimationInfo> MapCurrentOpeningFolders;
    00243     MapCurrentOpeningFolders m_mapCurrentOpeningFolders;
    00244
    00245
    00246     QTimer *m_animationTimer;
    00247
    00248     QPoint m_dragPos;
    00249     bool m_bDrag;
    00250
    00251    bool m_wantOpenFolderPixmaps; // Flag weather the folder should have open-folder pixmaps
    00252
    00253     QListViewItem *m_currentBeforeDropItem; // The item that was current before the drag-enter event happened
    00254     QListViewItem *m_dropItem; // The item we are moving the mouse over (during a drag)
    00255     QStrList m_lstDropFormats;
    00256    QPixmap  m_openFolderPixmap;
    00257     QTimer *m_autoOpenTimer;
    00258
    00259     KFileTreeViewToolTip m_toolTip;
    00260
    00261
    00262 protected:
    00263    virtual void virtual_hook( int id, void* data );
    00264 private:
    00265    class KFileTreeViewPrivate;
    00266    KFileTreeViewPrivate *d;
    00267 };
    00268
    00269 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:13:35 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001