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

KIO

KFileItemDelegate Class Reference

KFileItemDelegate is intended to be used to provide a KDE file system view, when using one of the standard item views in Qt with KDirModel. More...

#include <kfileitemdelegate.h>

Inheritance diagram for KFileItemDelegate:

List of all members.

Public Types

enum  Information {
  NoInformation, Size, Permissions, OctalPermissions,
  Owner, OwnerAndGroup, CreationTime, ModificationTime,
  AccessTime, MimeType, FriendlyMimeType
}
typedef QList< Information > InformationList

Public Slots

bool helpEvent (QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
QRegion shape (const QStyleOptionViewItem &option, const QModelIndex &index)

Public Member Functions

virtual QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual bool editorEvent (QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
virtual bool eventFilter (QObject *object, QEvent *event)
 KFileItemDelegate (QObject *parent=0)
QSize maximumSize () const
virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void setEditorData (QWidget *editor, const QModelIndex &index) const
void setMaximumSize (const QSize &size)
virtual void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
void setShadowBlur (qreal radius)
void setShadowColor (const QColor &color)
void setShadowOffset (const QPointF &offset)
void setShowInformation (Information information)
void setShowInformation (const InformationList &list)
void setShowToolTipWhenElided (bool showToolTip)
qreal shadowBlur () const
QColor shadowColor () const
QPointF shadowOffset () const
InformationList showInformation () const
bool showToolTipWhenElided () const
virtual QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual ~KFileItemDelegate ()

Properties

InformationList information
QSize maximumSize
qreal shadowBlur
QColor shadowColor
QPointF shadowOffset
bool showToolTipWhenElided

Detailed Description

KFileItemDelegate is intended to be used to provide a KDE file system view, when using one of the standard item views in Qt with KDirModel.

While primarily intended to be used with KDirModel, it uses Qt::DecorationRole and Qt::DisplayRole for the icons and text labels, just like QItemDelegate, and can thus be used with any standard model.

When used with KDirModel however, KFileItemDelegate can change the way the display and/or decoration roles are drawn, based on properties of the file items. For example, if the file item is a symbolic link, it will use an italic font to draw the file name.

KFileItemDelegate also supports showing additional information about the file items below the icon labels.

Which information should be shown, if any, is controlled by the information property, which is a list that can be set by calling setShowInformation(), and read by calling showInformation(). By default this list is empty.

To use KFileItemDelegate, instantiate an object from the delegate, and call setItemDelegate() in one of the standard item views in Qt:

 QListView *listview = new QListView(this);
 KFileItemDelegate *delegate = new KFileItemDelegate(this);
 listview->setItemDelegate(delegate);

Definition at line 66 of file kfileitemdelegate.h.


Member Typedef Documentation

typedef QList<Information> KFileItemDelegate::InformationList

Definition at line 168 of file kfileitemdelegate.h.


Member Enumeration Documentation

enum KFileItemDelegate::Information

This enum defines the additional information that can be displayed below item labels in icon views.

The information will only be shown for indexes for which the model provides a valid value for KDirModel::FileItemRole, and only when there's sufficient vertical space to display at least one line of the information, along with the display label.

For the number of items to be shown for folders, the model must provide a valid value for KDirMode::ChildCountRole, in addition to KDirModel::FileItemRole.

Note that KFileItemDelegate will not call KFileItem::determineMimeType() if KFileItem::isMimeTypeKnown() returns false, so if you want to display mime types you should use a KMimeTypeResolver with the model and the view, to ensure that mime types are resolved. If the mime type isn't known, "Unknown" will be displayed until the mime type has been successfully resolved.

See also:
setShowInformation()
showInformation()
information
Enumerator:
NoInformation 

No additional information will be shown for items.

Size 

The file size for files, and the number of items for folders.

Permissions 

A UNIX permissions string, e.g. -rwxr-xr-x.

OctalPermissions 

The permissions as an octal value, e.g. 0644.

Owner 

The user name of the file owner, e.g. root.

OwnerAndGroup 

The user and group that owns the file, e.g. root:root.

CreationTime 

The date and time the file/folder was created.

ModificationTime 

The date and time the file/folder was last modified.

AccessTime 

The date and time the file/folder was last accessed.

MimeType 

The mime type for the item, e.g. text/html.

FriendlyMimeType 

The descriptive name for the mime type, e.g. HTML Document.

Definition at line 154 of file kfileitemdelegate.h.


Constructor & Destructor Documentation

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

Constructs a new KFileItemDelegate.

Parameters:
parent The parent object for the delegate.

Definition at line 830 of file kfileitemdelegate.cpp.

KFileItemDelegate::~KFileItemDelegate (  )  [virtual]

Destroys the item delegate.

Definition at line 855 of file kfileitemdelegate.cpp.


Member Function Documentation

QWidget * KFileItemDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const [virtual]

Reimplemented from QAbstractItemDelegate.

Definition at line 1302 of file kfileitemdelegate.cpp.

bool KFileItemDelegate::editorEvent ( QEvent *  event,
QAbstractItemModel *  model,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) [virtual]

Reimplemented from QAbstractItemDelegate.

Definition at line 1318 of file kfileitemdelegate.cpp.

bool KFileItemDelegate::eventFilter ( QObject *  object,
QEvent *  event 
) [virtual]

Reimplemented from QAbstractItemDelegate.

Definition at line 1479 of file kfileitemdelegate.cpp.

bool KFileItemDelegate::helpEvent ( QHelpEvent *  event,
QAbstractItemView *  view,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) [slot]

Reimplemented from QAbstractItemDelegate.

Definition at line 1395 of file kfileitemdelegate.cpp.

QSize KFileItemDelegate::maximumSize (  )  const

Returns the maximum size for KFileItemDelegate::sizeHint().

See also:
setMaximumSize()
Since:
4.1
void KFileItemDelegate::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const [virtual]

Paints the item indicated by index, using painter.

The item will be drawn in the rectangle specified by option.rect. The correct size for that rectangle can be obtained by calling sizeHint().

This function will use the following data values if the model provides them for the item, in place of the values in option:

  • Qt::FontRole The font that should be used for the display role.
  • Qt::AlignmentRole The alignment of the display role.
  • Qt::ForegroundRole The text color for the display role.
  • Qt::BackgroundRole The background color for the item.

This function is reimplemented from QAbstractItemDelegate.

Parameters:
painter The painter with which to draw the item.
option The style options that should be used when painting the item.
index The index to the item that should be painted.

### Apply the selection effect to the icon when the item is selected and

Definition at line 1131 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const [virtual]

Reimplemented from QAbstractItemDelegate.

Definition at line 1330 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setMaximumSize ( const QSize &  size  ) 

Sets the maximum size for KFileItemDelegate::sizeHint().

See also:
maximumSize()
Since:
4.1

Definition at line 982 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const [virtual]

Reimplemented from QAbstractItemDelegate.

Definition at line 1361 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setShadowBlur ( qreal  radius  ) 

Sets the blur radius for the text shadow.

See also:
shadowBlur()

Definition at line 970 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setShadowColor ( const QColor &  color  ) 

Sets the color used for drawing the text shadow.

To enable text shadows, set the shadow color to a non-transparent color. To disable text shadows, set the color to Qt::transparent.

See also:
shadowColor()

Definition at line 946 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setShadowOffset ( const QPointF &  offset  ) 

Sets the horizontal and vertical offset for the text shadow.

See also:
shadowOffset()

Definition at line 958 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setShowInformation ( Information  information  ) 

Sets a single information line that is shown below the icon label in list views.

This is a convenience function for when you only want to show a single line of information.

Parameters:
information The information that should be shown

Definition at line 931 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setShowInformation ( const InformationList &  list  ) 

Sets the list of information lines that are shown below the icon label in list views.

You will typically construct the list like this:

 KFileItemDelegate::InformationList list;
 list << KFileItemDelegate::FriendlyMimeType << KFileItemDelegate::Size;
 delegate->setShowInformation(list);

The information lines will be displayed in the list order. The delegate will first draw the item label, and then as many information lines as will fit in the available space.

Parameters:
list A list of information items that should be shown

Definition at line 925 of file kfileitemdelegate.cpp.

void KFileItemDelegate::setShowToolTipWhenElided ( bool  showToolTip  ) 

Sets whether a tooltip should be shown if the display role is elided containing the full display role information.

Note:
The tooltip will only be shown if the Qt::ToolTipRole differs from Qt::DisplayRole, or if they match, showToolTipWhenElided flag is set and the display role information is elided.
See also:
showToolTipWhenElided()
Since:
4.2

Definition at line 994 of file kfileitemdelegate.cpp.

qreal KFileItemDelegate::shadowBlur (  )  const

Returns the blur radius for the text shadow.

See also:
setShadowBlur()
QColor KFileItemDelegate::shadowColor (  )  const

Returns the color used for the text shadow.

See also:
setShadowColor()
QPointF KFileItemDelegate::shadowOffset (  )  const

Returns the offset used for the text shadow.

See also:
setShadowOffset()
QRegion KFileItemDelegate::shape ( const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) [slot]

Returns the shape of the item as a region.

The returned region can be used for precise hit testing of the item.

Definition at line 1436 of file kfileitemdelegate.cpp.

KFileItemDelegate::InformationList KFileItemDelegate::showInformation (  )  const

Returns the file item information that should be shown below item labels in list views.

Definition at line 940 of file kfileitemdelegate.cpp.

bool KFileItemDelegate::showToolTipWhenElided (  )  const

Returns whether a tooltip should be shown if the display role is elided containing the full display role information.

Note:
The tooltip will only be shown if the Qt::ToolTipRole differs from Qt::DisplayRole, or if they match, showToolTipWhenElided flag is set and the display role information is elided.
See also:
setShowToolTipWhenElided()
Since:
4.2
QSize KFileItemDelegate::sizeHint ( const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const [virtual]

Returns the nominal size for the item referred to by index, given the provided options.

If the model provides a valid Qt::FontRole and/or Qt::AlignmentRole for the item, those will be used instead of the ones specified in the style options.

This function is reimplemented from QAbstractItemDelegate.

Parameters:
option The style options that should be used when painting the item.
index The index to the item for which to return the size hint.

Definition at line 861 of file kfileitemdelegate.cpp.

void KFileItemDelegate::updateEditorGeometry ( QWidget *  editor,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const [virtual]

Reimplemented from QAbstractItemDelegate.

Definition at line 1370 of file kfileitemdelegate.cpp.


Property Documentation

InformationList KFileItemDelegate::information [read, write]

This property holds which additional information (if any) should be shown below items in icon views.

Access functions:

  • void setShownformation(InformationList information)
  • InformationList showInformation() const

Definition at line 78 of file kfileitemdelegate.h.

QSize KFileItemDelegate::maximumSize [read, write]

This property holds the maximum size that can be returned by KFileItemDelegate::sizeHint().

If the maximum size is empty, it will be ignored.

Definition at line 118 of file kfileitemdelegate.h.

qreal KFileItemDelegate::shadowBlur [read, write]

This property holds the blur radius for the text shadow.

The default value for this property is 2.

Access functions:

  • void setShadowBlur(qreal radius)
  • qreal shadowBlur() const

Definition at line 111 of file kfileitemdelegate.h.

QColor KFileItemDelegate::shadowColor [read, write]

This property holds the color used for the text shadow.

The alpha value in the color determines the opacity of the shadow. Shadows are only rendered when the alpha value is non-zero. The default value for this property is Qt::transparent.

Access functions:

  • void setShadowColor(const QColor &color)
  • QColor shadowColor() const

Definition at line 91 of file kfileitemdelegate.h.

QPointF KFileItemDelegate::shadowOffset [read, write]

This property holds the horizontal and vertical offset for the text shadow.

The default value for this property is (1, 1).

Access functions:

  • void setShadowOffset(const QPointF &offset)
  • QPointF shadowOffset() const

Definition at line 101 of file kfileitemdelegate.h.

bool KFileItemDelegate::showToolTipWhenElided [read, write]

This property determines whether a tooltip will be shown by the delegate if the display role is elided.

This tooltip will contain the full display role information. The tooltip will only be shown if the Qt::ToolTipRole differs from Qt::DisplayRole, or if they match, showToolTipWhenElided flag is set and the display role information is elided.

Definition at line 127 of file kfileitemdelegate.h.


The documentation for this class was generated from the following files:
  • kfileitemdelegate.h
  • kfileitemdelegate.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
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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