kfiletreeview.h
/* This file is part of the KDE project
Copyright (C) 2000 David Faure <faure@kde.org>
2000 Carsten Pfeiffer <pfeiffer@kde.org>
2002 Klaas Freitag <freitag@suse.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef kfile_tree_view_h
#define kfile_tree_view_h
#include <qmap.h>
#include <qpoint.h>
#include <qpixmap.h>
#include <qstrlist.h>
#include <qtooltip.h>
#include <klistview.h>
#include <kdirnotify.h>
#include <kio/job.h>
#include <kfiletreeviewitem.h>
#include <kfiletreebranch.h>
class QTimer;
class KIO_EXPORT KFileTreeViewToolTip : public QToolTip
{
public:
KFileTreeViewToolTip( QListView *view ) : QToolTip( view ), m_view( view ) {}
protected:
virtual void maybeTip( const QPoint & );
private:
QListView *m_view;
};
class KIO_EXPORT KFileTreeView : public KListView
{
Q_OBJECT
public:
KFileTreeView( QWidget *parent, const char *name = 0 );
virtual ~KFileTreeView();
KFileTreeViewItem * currentKFileTreeViewItem() const;
KURL currentURL() const;
KFileTreeBranch* addBranch( const KURL &path, const QString& name, bool showHidden = false );
virtual KFileTreeBranch* addBranch( const KURL &path, const QString& name ,
const QPixmap& pix, bool showHidden = false );
virtual KFileTreeBranch* addBranch( KFileTreeBranch * );
virtual bool removeBranch( KFileTreeBranch *branch );
KFileTreeBranch *branch( const QString& searchName );
KFileTreeBranchList& branches();
virtual void setDirOnlyMode( KFileTreeBranch *branch, bool );
KFileTreeViewItem *findItem( KFileTreeBranch* brnch, const QString& relUrl );
KFileTreeViewItem *findItem( const QString& branchName, const QString& relUrl );
bool showFolderOpenPixmap() const { return m_wantOpenFolderPixmaps; };
public slots:
virtual void setShowFolderOpenPixmap( bool showIt = true )
{ m_wantOpenFolderPixmaps = showIt; }
protected:
virtual bool acceptDrag(QDropEvent* event) const;
virtual QDragObject * dragObject();
virtual void startAnimation( KFileTreeViewItem* item, const char * iconBaseName = "kde", uint iconCount = 6 );
virtual void stopAnimation( KFileTreeViewItem* item );
virtual void contentsDragEnterEvent( QDragEnterEvent *e );
virtual void contentsDragMoveEvent( QDragMoveEvent *e );
virtual void contentsDragLeaveEvent( QDragLeaveEvent *e );
virtual void contentsDropEvent( QDropEvent *ev );
protected slots:
virtual void slotNewTreeViewItems( KFileTreeBranch*,
const KFileTreeViewItemList& );
virtual void slotSetNextUrlToSelect( const KURL &url )
{ m_nextUrlToSelect = url; }
virtual QPixmap itemIcon( KFileTreeViewItem*, int gap = 0 ) const;
private slots:
void slotExecuted( QListViewItem * );
void slotExpanded( QListViewItem * );
void slotCollapsed( QListViewItem *item );
void slotSelectionChanged();
void slotAnimation();
void slotAutoOpenFolder();
void slotOnItem( QListViewItem * );
void slotItemRenamed(QListViewItem*, const QString &, int);
void slotPopulateFinished( KFileTreeViewItem* );
signals:
void onItem( const QString& );
/* New signals if you like it ? */
void dropped( QWidget*, QDropEvent* );
void dropped( QWidget*, QDropEvent*, KURL::List& );
void dropped( KURL::List&, KURL& );
// The drop event allows to differentiate between move and copy
void dropped( QWidget*, QDropEvent*, KURL::List&, KURL& );
void dropped( QDropEvent *e, QListViewItem * after);
void dropped(KFileTreeView *, QDropEvent *, QListViewItem *);
void dropped(QDropEvent *e, QListViewItem * parent, QListViewItem * after);
void dropped(KFileTreeView *, QDropEvent *, QListViewItem *, QListViewItem *);
protected:
KURL m_nextUrlToSelect;
private:
// Returns whether item is still a valid item in the tree
bool isValidItem( QListViewItem *item);
void clearTree();
/* List that holds the branches */
KFileTreeBranchList m_branches;
struct AnimationInfo
{
AnimationInfo( const char * _iconBaseName, uint _iconCount, const QPixmap & _originalPixmap )
: iconBaseName(_iconBaseName), iconCount(_iconCount), iconNumber(1), originalPixmap(_originalPixmap) {}
AnimationInfo() : iconCount(0) {}
QCString iconBaseName;
uint iconCount;
uint iconNumber;
QPixmap originalPixmap;
};
typedef QMap<KFileTreeViewItem *, AnimationInfo> MapCurrentOpeningFolders;
MapCurrentOpeningFolders m_mapCurrentOpeningFolders;
QTimer *m_animationTimer;
QPoint m_dragPos;
bool m_bDrag;
bool m_wantOpenFolderPixmaps; // Flag weather the folder should have open-folder pixmaps
QListViewItem *m_currentBeforeDropItem; // The item that was current before the drag-enter event happened
QListViewItem *m_dropItem; // The item we are moving the mouse over (during a drag)
QStrList m_lstDropFormats;
QPixmap m_openFolderPixmap;
QTimer *m_autoOpenTimer;
KFileTreeViewToolTip m_toolTip;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KFileTreeViewPrivate;
KFileTreeViewPrivate *d;
};
#endif
KFileTreeBranch
This is the branch class of the KFileTreeView, which represents one branch in the treeview...
Definition: kfiletreebranch.h:48
KFileTreeView
The filetreeview offers a treeview on the file system which behaves like a QTreeView showing files an...
Definition: kfiletreeview.h:66
KFileTreeViewItem
An item for a KFileTreeView that knows about its own KFileItem.
Definition: kfiletreeviewitem.h:40
KFileTreeView::showFolderOpenPixmap
bool showFolderOpenPixmap() const
Definition: kfiletreeview.h:152
KFileTreeView::setShowFolderOpenPixmap
virtual void setShowFolderOpenPixmap(bool showIt=true)
set the flag to show 'extended' folder icons on or off.
Definition: kfiletreeview.h:163

KDE Home | KDE Accessibility Home | Description of Access Keys