kfileview.h
// -*- c++ -*-
/* This file is part of the KDE libraries
Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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 KFILEVIEW_H
#define KFILEVIEW_H
class QPoint;
class KActionCollection;
#include <qwidget.h>
#include "kfileitem.h"
#include "kfile.h"
class KIO_EXPORT KFileViewSignaler : public QObject
{
Q_OBJECT
public:
void activate( const KFileItem *item ) {
if ( item->isDir() )
emit dirActivated( item );
else
emit fileSelected( item );
}
void highlightFile(const KFileItem *i) { emit fileHighlighted(i); }
void activateMenu( const KFileItem *i, const QPoint& pos ) {
emit activatedMenu( i, pos );
}
void changeSorting( QDir::SortSpec sorting ) {
emit sortingChanged( sorting );
}
void dropURLs(const KFileItem *i, QDropEvent*e, const KURL::List&urls) {
emit dropped(i, e, urls);
}
signals:
void dirActivated(const KFileItem*);
void sortingChanged( QDir::SortSpec );
void fileHighlighted(const KFileItem*);
void fileSelected(const KFileItem*);
void activatedMenu( const KFileItem *i, const QPoint& );
void dropped(const KFileItem *, QDropEvent*, const KURL::List&);
};
class KIO_EXPORT KFileView {
public:
KFileView();
virtual ~KFileView();
void addItemList(const KFileItemList &list);
virtual QWidget *widget() = 0;
QWidget *widget() const { return const_cast<KFileView*>(this)->widget(); }
void setCurrentItem( const QString &filename );
virtual void setCurrentItem( const KFileItem *item ) = 0;
virtual KFileItem *currentFileItem() const = 0;
virtual void clear();
virtual void updateView(bool f = true);
virtual void updateView(const KFileItem*);
virtual void removeItem(const KFileItem *item);
virtual void listingCompleted();
QDir::SortSpec sorting() const { return m_sorting; }
virtual void setSorting(QDir::SortSpec sort);
bool isReversed() const { return (m_sorting & QDir::Reversed); }
void sortReversed();
uint count() const { return filesNumber + dirsNumber; }
uint numFiles() const { return filesNumber; }
uint numDirs() const { return dirsNumber; }
virtual void setSelectionMode( KFile::SelectionMode sm );
virtual KFile::SelectionMode selectionMode() const;
enum ViewMode {
Files = 1,
Directories = 2,
All = Files | Directories
};
virtual void setViewMode( ViewMode vm );
virtual ViewMode viewMode() const { return view_mode; }
QString viewName() const { return m_viewName; }
void setViewName( const QString& name ) { m_viewName = name; }
virtual void setParentView(KFileView *parent);
virtual void insertItem( KFileItem *i);
virtual void clearView() = 0;
virtual void ensureItemVisible( const KFileItem *i ) = 0;
virtual void clearSelection() = 0;
virtual void selectAll();
virtual void invertSelection();
virtual void setSelected(const KFileItem *, bool enable) = 0;
virtual bool isSelected( const KFileItem * ) const = 0;
const KFileItemList * selectedItems() const;
const KFileItemList * items() const;
virtual KFileItem * firstFileItem() const = 0;
virtual KFileItem * nextItem( const KFileItem * ) const = 0;
virtual KFileItem * prevItem( const KFileItem * ) const = 0;
void setOnlyDoubleClickSelectsFiles( bool enable ) {
myOnlyDoubleClickSelectsFiles = enable;
}
bool onlyDoubleClickSelectsFiles() const {
return myOnlyDoubleClickSelectsFiles;
}
bool updateNumbers(const KFileItem *i);
virtual KActionCollection * actionCollection() const;
KFileViewSignaler * signaler() const { return sig; }
virtual void readConfig( KConfig *, const QString& group = QString::null );
virtual void writeConfig( KConfig *, const QString& group = QString::null);
enum DropOptions {
AutoOpenDirs = 1
};
// KDE 4: Make virtual
void setDropOptions(int options);
int dropOptions();
static QString sortingKey( const QString& value, bool isDir, int sortSpec);
static QString sortingKey( KIO::filesize_t value, bool isDir,int sortSpec);
static int autoOpenDelay();
protected:
KFileViewSignaler *sig;
private:
static QDir::SortSpec defaultSortSpec;
QDir::SortSpec m_sorting;
QString m_viewName;
uint filesNumber;
uint dirsNumber;
ViewMode view_mode;
KFile::SelectionMode selection_mode;
// never use! It's only guaranteed to contain valid items in the items()
// method!
mutable KFileItemList m_itemList;
mutable KFileItemList *m_selectedList;
bool myOnlyDoubleClickSelectsFiles;
protected:
virtual void virtual_hook( int id, void* data );
/* @internal for virtual_hook */
enum { VIRTUAL_SET_DROP_OPTIONS = 1 };
void setDropOptions_impl(int options);
private:
class KFileViewPrivate;
KFileViewPrivate *d;
};
#endif // KFILEINFOLISTWIDGET_H
KFileViewSignaler::activate
void activate(const KFileItem *item)
Call this method when an item is selected (depends on single click / double click configuration)...
Definition: kfileview.h:46
KFileView::onlyDoubleClickSelectsFiles
bool onlyDoubleClickSelectsFiles() const
Definition: kfileview.h:330
KFileViewSignaler::highlightFile
void highlightFile(const KFileItem *i)
emits the highlighted signal for item.
Definition: kfileview.h:56
KFileView::setViewName
void setViewName(const QString &name)
Sets the name of the view, which could be displayed somewhere.
Definition: kfileview.h:240
KFileView
This class defines an interface to all file views.
Definition: kfileview.h:98
KFileView::viewName
QString viewName() const
Definition: kfileview.h:234
KFileView::isReversed
bool isReversed() const
Tells whether the current items are in reversed order (shortcut to sorting() & QDir::Reversed).
Definition: kfileview.h:199
KFileView::numFiles
uint numFiles() const
Definition: kfileview.h:211
KFileView::sorting
QDir::SortSpec sorting() const
Returns the sorting order of the internal list.
Definition: kfileview.h:177
KFileView::widget
QWidget * widget() const
As const-method, to be fixed in 3.0
Definition: kfileview.h:123
KFileView::DropOptions
DropOptions
Various options for drag and drop support.
Definition: kfileview.h:359
KFileView::count
uint count() const
Definition: kfileview.h:206
KFileViewSignaler
internal class to make easier to use signals possible
Definition: kfileview.h:37
KFileView::setOnlyDoubleClickSelectsFiles
void setOnlyDoubleClickSelectsFiles(bool enable)
This is a KFileDialog specific hack: we want to select directories with single click, but not files.
Definition: kfileview.h:321
KFileView::numDirs
uint numDirs() const
Definition: kfileview.h:216

KDE Home | KDE Accessibility Home | Description of Access Keys