• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIO

Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
KDirModel Class Reference

#include <kdirmodel.h>

Inheritance diagram for KDirModel:
Inheritance graph
[legend]

Public Types

enum  { ChildCountUnknown = -1 }
 
enum  AdditionalRoles { FileItemRole = 0x07A263FF, ChildCountRole = 0x2C4D0A40, HasJobRole = 0x01E555A5 }
 
enum  DropsAllowedFlag { NoDrops = 0, DropOnDirectory = 1, DropOnAnyFile = 2, DropOnLocalExecutable = 4 }
 
enum  ModelColumns {
  Name = 0, Size, ModifiedTime, Permissions,
  Owner, Group, Type, ColumnCount
}
 

Signals

void expand (const QModelIndex &index)
 
void needSequenceIcon (const QModelIndex &index, int sequenceIndex)
 

Public Member Functions

 KDirModel (QObject *parent=0)
 
 ~KDirModel ()
 
virtual bool canFetchMore (const QModelIndex &parent) const
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
KDirLister * dirLister () const
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 
void expandToUrl (const KUrl &url)
 
virtual void fetchMore (const QModelIndex &parent)
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 
virtual bool hasChildren (const QModelIndex &parent=QModelIndex()) const
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 
QModelIndex indexForItem (const KFileItem *) const
 
QModelIndex indexForItem (const KFileItem &) const
 
QModelIndex indexForUrl (const KUrl &url) const
 
void itemChanged (const QModelIndex &index)
 
KFileItem itemForIndex (const QModelIndex &index) const
 
bool jobTransfersVisible () const
 
virtual QMimeData * mimeData (const QModelIndexList &indexes) const
 
virtual QStringList mimeTypes () const
 
virtual QModelIndex parent (const QModelIndex &index) const
 
void requestSequenceIcon (const QModelIndex &index, int sequenceIndex)
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 
void setDirLister (KDirLister *dirLister)
 
void setDropsAllowed (DropsAllowed dropsAllowed)
 
void setJobTransfersVisible (bool value)
 
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)
 
- Public Member Functions inherited from QAbstractItemModel
 QAbstractItemModel (QObject *parent)
 
virtual  ~QAbstractItemModel ()
 
virtual QModelIndex buddy (const QModelIndex &index) const
 
virtual int columnCount (const QModelIndex &parent) const =0
 
void columnsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void columnsInserted (const QModelIndex &parent, int start, int end)
 
void columnsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
void columnsRemoved (const QModelIndex &parent, int start, int end)
 
virtual QVariant data (const QModelIndex &index, int role) const =0
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
bool hasIndex (int row, int column, const QModelIndex &parent) const
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent) const =0
 
bool insertColumn (int column, const QModelIndex &parent)
 
bool insertRow (int row, const QModelIndex &parent)
 
virtual QMap< int, QVariant > itemData (const QModelIndex &index) const
 
void layoutAboutToBeChanged ()
 
void layoutChanged ()
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits, QFlags< Qt::MatchFlag > flags) const
 
void modelAboutToBeReset ()
 
void modelReset ()
 
virtual QModelIndex parent (const QModelIndex &index) const =0
 
bool removeColumn (int column, const QModelIndex &parent)
 
bool removeRow (int row, const QModelIndex &parent)
 
virtual void revert ()
 
const QHash< int, QByteArray > & roleNames () const
 
virtual int rowCount (const QModelIndex &parent) const =0
 
void rowsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void rowsInserted (const QModelIndex &parent, int start, int end)
 
void rowsMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 
void rowsRemoved (const QModelIndex &parent, int start, int end)
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role)
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 
void setSupportedDragActions (QFlags< Qt::DropAction > actions)
 
QModelIndex sibling (int row, int column, const QModelIndex &index) const
 
virtual QSize span (const QModelIndex &index) const
 
virtual bool submit ()
 
Qt::DropActions supportedDragActions () const
 
virtual Qt::DropActions supportedDropActions () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Static Public Member Functions

static KUrl::List simplifiedUrlList (const KUrl::List &urls)
 
- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Additional Inherited Members

- Protected Member Functions inherited from QAbstractItemModel
void beginInsertColumns (const QModelIndex &parent, int first, int last)
 
void beginInsertRows (const QModelIndex &parent, int first, int last)
 
bool beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
 
bool beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
 
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
 
void beginRemoveRows (const QModelIndex &parent, int first, int last)
 
void beginResetModel ()
 
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
 
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
 
QModelIndex createIndex (int row, int column, void *ptr) const
 
QModelIndex createIndex (int row, int column, int id) const
 
QModelIndex createIndex (int row, int column, quint32 id) const
 
void endInsertColumns ()
 
void endInsertRows ()
 
void endMoveColumns ()
 
void endMoveRows ()
 
void endRemoveColumns ()
 
void endRemoveRows ()
 
void endResetModel ()
 
QModelIndexList persistentIndexList () const
 
void reset ()
 
void resetInternalData ()
 
void setRoleNames (const QHash< int, QByteArray > &roleNames)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

A model for a KIO-based directory tree.

KDirModel implements the QAbstractItemModel interface (for use with Qt's model/view widgets) around the directory listing for one directory or a tree of directories.

Note that there are some cases when using QPersistentModelIndexes from this model will not give expected results. QPersistentIndexes will remain valid and updated if its siblings are added or removed. However, if the QPersistentIndex or one of its ancestors is moved, the QPersistentIndex will become invalid. For example, if a file or directory is renamed after storing a QPersistentModelIndex for it, the index (along with any stored children) will become invalid even though it is still in the model. The reason for this is that moves of files and directories are treated as separate insert and remove actions.

See also
KDirSortFilterProxyModel
Author
David Faure Based on work by Hamish Rodda and Pascal Letourneau

Definition at line 48 of file kdirmodel.h.

Member Enumeration Documentation

anonymous enum

Possible return value for data(ChildCountRole), meaning the item isn't a directory, or we haven't calculated its child count yet.

Enumerator
ChildCountUnknown 

Definition at line 132 of file kdirmodel.h.

enum KDirModel::AdditionalRoles
Enumerator
FileItemRole 

returns the KFileItem for a given index

ChildCountRole 

returns the number of items in a directory, or ChildCountUnknown

HasJobRole 

returns whether or not there is a job on an item (file/directory)

Definition at line 134 of file kdirmodel.h.

enum KDirModel::DropsAllowedFlag
Enumerator
NoDrops 
DropOnDirectory 

allow drops on any directory

DropOnAnyFile 

allow drops on any file

DropOnLocalExecutable 

allow drops on local executables, shell scripts and desktop files. Can be used with DropOnDirectory.

Definition at line 142 of file kdirmodel.h.

enum KDirModel::ModelColumns
Enumerator
Name 
Size 
ModifiedTime 
Permissions 
Owner 
Group 
Type 
ColumnCount 

Definition at line 119 of file kdirmodel.h.

Constructor & Destructor Documentation

KDirModel::KDirModel ( QObject *  parent = 0)
explicit
Parameters
parentparent qobject

Definition at line 326 of file kdirmodel.cpp.

KDirModel::~KDirModel ( )

Definition at line 333 of file kdirmodel.cpp.

Member Function Documentation

bool KDirModel::canFetchMore ( const QModelIndex &  parent) const
virtual

Reimplemented from QAbstractItemModel. Returns true for empty directories.

Reimplemented from QAbstractItemModel.

Definition at line 1068 of file kdirmodel.cpp.

int KDirModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Reimplemented from QAbstractItemModel. Returns ColumnCount.

Definition at line 644 of file kdirmodel.cpp.

QVariant KDirModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual

Reimplemented from QAbstractItemModel.

Definition at line 649 of file kdirmodel.cpp.

KDirLister * KDirModel::dirLister ( ) const

Return the directory lister used by this model.

Definition at line 358 of file kdirmodel.cpp.

bool KDirModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)
virtual

Reimplemented from QAbstractItemModel. Not implemented yet.

Reimplemented from QAbstractItemModel.

Definition at line 1103 of file kdirmodel.cpp.

void KDirModel::expand ( const QModelIndex &  index)
signal

Emitted for each subdirectory that is a parent of a url passed to expandToUrl This allows to asynchronously open a tree view down to a given directory.

Also emitted for the final file, if expandToUrl is called with a file (for instance so that it can be selected).

void KDirModel::expandToUrl ( const KUrl &  url)

Lists subdirectories using fetchMore() as needed until the given url exists in the model.

When the model is used by a treeview, call KDirLister::openUrl with the base url of the tree, then the treeview will take care of calling fetchMore() when the user opens directories. However if you want the tree to show a given URL (i.e. open the tree recursively until that URL), call expandToUrl(). Note that this is asynchronous; the necessary listing of subdirectories will take time so the model will not immediately have this url available. The model emits the signal expand() when an index has become available; this can be connected to the treeview in order to let it open that index.

Parameters
urlthe url of a subdirectory of the directory model (or a file in a subdirectory)

Definition at line 1120 of file kdirmodel.cpp.

void KDirModel::fetchMore ( const QModelIndex &  parent)
virtual

Reimplemented from QAbstractItemModel. Lists the subdirectory.

Reimplemented from QAbstractItemModel.

Definition at line 1084 of file kdirmodel.cpp.

Qt::ItemFlags KDirModel::flags ( const QModelIndex &  index) const
virtual

Reimplemented from QAbstractItemModel.

Reimplemented from QAbstractItemModel.

Definition at line 1027 of file kdirmodel.cpp.

bool KDirModel::hasChildren ( const QModelIndex &  parent = QModelIndex()) const
virtual

Reimplemented from QAbstractItemModel. Returns true for directories.

Reimplemented from QAbstractItemModel.

Definition at line 1017 of file kdirmodel.cpp.

QVariant KDirModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual

Reimplemented from QAbstractItemModel. Returns the column titles.

Reimplemented from QAbstractItemModel.

Definition at line 991 of file kdirmodel.cpp.

QModelIndex KDirModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
virtual

Reimplemented from QAbstractItemModel. O(1)

Definition at line 979 of file kdirmodel.cpp.

QModelIndex KDirModel::indexForItem ( const KFileItem *  item) const

Return the index for a given kfileitem.

This can be slow.

Deprecated:
use the method that takes a KFileItem by value

Definition at line 953 of file kdirmodel.cpp.

QModelIndex KDirModel::indexForItem ( const KFileItem &  item) const

Return the index for a given kfileitem.

This can be slow.

Definition at line 961 of file kdirmodel.cpp.

QModelIndex KDirModel::indexForUrl ( const KUrl &  url) const

Return the index for a given url.

This can be slow.

Definition at line 969 of file kdirmodel.cpp.

void KDirModel::itemChanged ( const QModelIndex &  index)

Notify the model that the item at this index has changed.

For instance because KMimeTypeResolver called determineMimeType on it. This makes the model emit its dataChanged signal at this index, so that views repaint. Note that for most things (renaming, changing size etc.), KDirLister's signals tell the model already.

Definition at line 629 of file kdirmodel.cpp.

KFileItem KDirModel::itemForIndex ( const QModelIndex &  index) const

Return the fileitem for a given index.

This is O(1), i.e. fast.

Definition at line 943 of file kdirmodel.cpp.

bool KDirModel::jobTransfersVisible ( ) const

Returns whether or not displaying job transfers has been enabled.

Since
4.5

Definition at line 873 of file kdirmodel.cpp.

QMimeData * KDirModel::mimeData ( const QModelIndexList &  indexes) const
virtual

Reimplemented from QAbstractItemModel.

Reimplemented from QAbstractItemModel.

Definition at line 907 of file kdirmodel.cpp.

QStringList KDirModel::mimeTypes ( ) const
virtual

Reimplemented from QAbstractItemModel.

Reimplemented from QAbstractItemModel.

Definition at line 902 of file kdirmodel.cpp.

void KDirModel::needSequenceIcon ( const QModelIndex &  index,
int  sequenceIndex 
)
signal

Emitted when another icon sequence index is requested.

Parameters
indexIndex of the item that should get another icon
sequenceIndexIndex in the sequence. If it is zero, the standard icon should be assigned. For higher indices, arbitrary different meaningful icons should be generated. This is usually slowly counted up while the user hovers the icon. If no meaningful alternative icons can be generated, this should be ignored.
Since
4.3
QModelIndex KDirModel::parent ( const QModelIndex &  index) const
virtual

Reimplemented from QAbstractItemModel.

Definition at line 839 of file kdirmodel.cpp.

void KDirModel::requestSequenceIcon ( const QModelIndex &  index,
int  sequenceIndex 
)

This emits the needSequenceIcon signal, requesting another sequence icon.

If there is a KFilePreviewGenerator attached to this model, that generator will care about creating another preview.

Parameters
indexIndex of the item that should get another icon
sequenceIndexIndex in the sequence. If it is zero, the standard icon will be assigned. For higher indices, arbitrary different meaningful icons will be generated.
Since
4.3

Definition at line 855 of file kdirmodel.cpp.

int KDirModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Reimplemented from QAbstractItemModel.

Definition at line 819 of file kdirmodel.cpp.

bool KDirModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
virtual

Reimplemented from QAbstractItemModel.

Call this to set a new icon, e.g. a preview

Reimplemented from QAbstractItemModel.

Definition at line 776 of file kdirmodel.cpp.

void KDirModel::setDirLister ( KDirLister *  dirLister)

Set the directory lister to use by this model, instead of the default KDirLister created internally.

The model takes ownership.

Definition at line 338 of file kdirmodel.cpp.

void KDirModel::setDropsAllowed ( DropsAllowed  dropsAllowed)

Set whether dropping onto items should be allowed, and for which kind of item Drops are disabled by default.

Definition at line 1115 of file kdirmodel.cpp.

void KDirModel::setJobTransfersVisible ( bool  value)

Enable/Disable the displaying of an animated overlay that is shown for any destination urls (in the view).

When enabled, the animations (if any) will be drawn automatically.

Only the files/folders that are visible and have jobs associated with them will display the animation. You would likely not want this enabled if you perform some kind of custom painting that takes up a whole item, and will just make this(and what you paint) look funky.

Default is disabled.

Note: KFileItemDelegate needs to have it's method called with the same value, when you make the call to this method.

Since
4.5

Definition at line 860 of file kdirmodel.cpp.

KUrl::List KDirModel::simplifiedUrlList ( const KUrl::List &  urls)
static

Remove urls from the list if an ancestor is present on the list.

This can be used to delete only the ancestor url and skip a potential error of a non-existent url.

For example, for a list of "/home/foo/a", "/home/foo/a/a.txt", "/home/foo/a/a/a.txt", "/home/foo/a/b/b.txt", "home/foo/b/b.txt", this method will return the list "/home/foo/a", "/home/foo/b/b.txt".

Returns
the list urls without parented urls inside.
Since
4.2

Definition at line 878 of file kdirmodel.cpp.

void KDirModel::sort ( int  column,
Qt::SortOrder  order = Qt::AscendingOrder 
)
virtual

Reimplemented from QAbstractItemModel. Not implemented.

See also
KDirSortFilterProxyModel

Reimplemented from QAbstractItemModel.

Definition at line 770 of file kdirmodel.cpp.


The documentation for this class was generated from the following files:
  • kdirmodel.h
  • kdirmodel.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:54 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal