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

KIO

KDirModel Class Reference

#include <kdirmodel.h>

Inheritance diagram for KDirModel:

Inheritance graph
[legend]

List of all members.


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.

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

Definition at line 40 of file kdirmodel.h.


Public Types

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

Signals

void expand (const QModelIndex &index)

Public Member Functions

 KDirModel (QObject *parent=0)
 ~KDirModel ()
void setDirLister (KDirLister *dirLister)
KDirLister * dirLister () const
KFileItem itemForIndex (const QModelIndex &index) const
QModelIndex indexForItem (const KFileItem *) const
QModelIndex indexForItem (const KFileItem &) const
QModelIndex indexForUrl (const KUrl &url) const
void expandToUrl (const KUrl &url)
void itemChanged (const QModelIndex &index)
void setDropsAllowed (DropsAllowed dropsAllowed)
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
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
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
virtual QMimeData * mimeData (const QModelIndexList &indexes) const
virtual QStringList mimeTypes () const
virtual QModelIndex parent (const QModelIndex &index) const
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
virtual void sort (int column, Qt::SortOrder order=Qt::AscendingOrder)

Friends

class KDirModelPrivate

Member Enumeration Documentation

enum KDirModel::ModelColumns

Enumerator:
Name 
Size 
ModifiedTime 
Permissions 
Owner 
Group 
Type 
ColumnCount 

Definition at line 109 of file kdirmodel.h.

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 122 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

Definition at line 124 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 131 of file kdirmodel.h.


Constructor & Destructor Documentation

KDirModel::KDirModel ( QObject *  parent = 0  )  [explicit]

Parameters:
parent parent qobject

Definition at line 260 of file kdirmodel.cpp.

KDirModel::~KDirModel (  ) 

Definition at line 267 of file kdirmodel.cpp.


Member Function Documentation

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 272 of file kdirmodel.cpp.

KDirLister * KDirModel::dirLister (  )  const

Return the directory lister used by this model.

Definition at line 290 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 593 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 602 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 609 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 617 of file kdirmodel.cpp.

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:
url the url of a subdirectory of the directory model

Definition at line 768 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 417 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 763 of file kdirmodel.cpp.

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

Reimplemented from QAbstractItemModel. Returns true for empty directories.

Definition at line 715 of file kdirmodel.cpp.

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

Reimplemented from QAbstractItemModel. Returns ColumnCount.

Definition at line 422 of file kdirmodel.cpp.

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

Reimplemented from QAbstractItemModel.

Definition at line 427 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 751 of file kdirmodel.cpp.

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

Reimplemented from QAbstractItemModel. Lists the subdirectory.

Reimplemented from QAbstractItemModel.

Definition at line 731 of file kdirmodel.cpp.

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

Reimplemented from QAbstractItemModel.

Definition at line 674 of file kdirmodel.cpp.

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

Reimplemented from QAbstractItemModel. Returns true for directories.

Definition at line 664 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.

Definition at line 639 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 627 of file kdirmodel.cpp.

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

Reimplemented from QAbstractItemModel.

Definition at line 581 of file kdirmodel.cpp.

QStringList KDirModel::mimeTypes (  )  const [virtual]

Reimplemented from QAbstractItemModel.

Definition at line 573 of file kdirmodel.cpp.

QModelIndex KDirModel::parent ( const QModelIndex &  index  )  const [virtual]

Reimplemented from QAbstractItemModel.

Definition at line 562 of file kdirmodel.cpp.

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

Reimplemented from QAbstractItemModel.

Definition at line 552 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 522 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 516 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.


Friends And Related Function Documentation

friend class KDirModelPrivate [friend]

Definition at line 190 of file kdirmodel.h.


The documentation for this class was generated from the following files:
  • kdirmodel.h
  • kdirmodel.cpp

KIO

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   WTF
  • KJSEmbed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  •   core
  • Phonon
  •   Backend
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal