KFileItem Class Reference
#include <kfileitem.h>
Detailed Description
A KFileItem is a generic class to handle a file, local or remote.In particular, it makes it easier to handle the result of KIO::listDir (UDSEntry isn't very friendly to use). It includes many file attributes such as mimetype, icon, text, mode, link...
Definition at line 41 of file kfileitem.h.
Public Types | |
enum | { Unknown = (mode_t) - 1 } |
Public Member Functions | |
KFileItem (const KIO::UDSEntry &_entry, const KURL &_url, bool _determineMimeTypeOnDemand=false, bool _urlIsDirectory=false) | |
KFileItem (mode_t _mode, mode_t _permissions, const KURL &_url, bool _determineMimeTypeOnDemand=false) | |
KFileItem (const KURL &url, const QString &mimeType, mode_t mode) | |
KFileItem (const KFileItem &item) | |
virtual | ~KFileItem () |
void | refresh () |
void | refreshMimeType () |
const KURL & | url () const |
void | setURL (const KURL &url) |
void | setName (const QString &name) |
mode_t | permissions () const |
QString | permissionsString () const |
bool | hasExtendedACL () const |
KACL | ACL () const |
KACL | defaultACL () const |
mode_t | mode () const |
QString | user () const |
QString | group () const |
bool | isLink () const |
bool | isDir () const |
bool | isFile () const |
bool | isReadable () const |
bool | isWritable () const |
bool | isHidden () const |
QString | linkDest () const |
QString | localPath () const |
KIO::filesize_t | size () const |
KIO::filesize_t | size (bool &hasSize) const |
time_t | time (unsigned int which) const |
time_t | time (unsigned int which, bool &hasTime) const |
QString | timeString (unsigned int which=KIO::UDS_MODIFICATION_TIME) const |
bool | isLocalFile () const |
const QString & | text () const |
const QString & | name (bool lowerCase=false) const |
QString | mimetype () const |
KMimeType::Ptr | determineMimeType () |
KMimeType::Ptr | mimeTypePtr () const |
bool | isMimeTypeKnown () const |
QString | mimeComment () |
QString | iconName () |
QPixmap | pixmap (int _size, int _state=0) const |
int | overlays () const |
QString | getStatusBarInfo () |
QString | getToolTipText (int maxcount=6) |
bool | acceptsDrops () |
void | run () |
const KIO::UDSEntry & | entry () const |
bool | isMarked () const |
void | mark () |
void | unmark () |
bool | cmp (const KFileItem &item) |
virtual void | setExtraData (const void *key, void *value) |
virtual const void * | extraData (const void *key) const |
virtual void * | extraData (const void *key) |
virtual void | removeExtraData (const void *key) |
void | setMetaInfo (const KFileMetaInfo &info) |
void | setFileMode (mode_t m) |
void | setMimeType (const QString &mimetype) |
const KFileMetaInfo & | metaInfo (bool autoget=true, int what=KFileMetaInfo::Fastest) const |
void | assign (const KFileItem &item) |
void | setUDSEntry (const KIO::UDSEntry &entry, const KURL &url, bool determineMimeTypeOnDemand=false, bool urlIsDirectory=false) |
KFileItem & | operator= (const KFileItem &) |
KURL | mostLocalURL (bool &local) const |
Protected Member Functions | |
void | init (bool _determineMimeTypeOnDemand) |
void | readUDSEntry (bool _urlIsDirectory) |
QString | parsePermissions (mode_t perm) const |
virtual void | virtual_hook (int id, void *data) |
Friends | |
KIO_EXPORT friend QDataStream & | operator<< (QDataStream &s, const KFileItem &a) |
KIO_EXPORT friend QDataStream & | operator>> (QDataStream &s, KFileItem &a) |
Constructor & Destructor Documentation
|
Creates an item representing a file, from a UDSEntry. This is the preferred constructor when using KIO::listDir().
Definition at line 54 of file kfileitem.cpp. |
|
Creates an item representing a file, from all the necessary info for it.
Definition at line 72 of file kfileitem.cpp. |
|
Creates an item representing a file, for which the mimetype is already known.
Definition at line 90 of file kfileitem.cpp. |
|
Copy constructor. Note that extra-data set via setExtraData() is not deeply copied -- just the pointers are copied. Definition at line 110 of file kfileitem.cpp. |
|
Destructs the KFileItem. Extra data set via setExtraData() is not deleted. Definition at line 122 of file kfileitem.cpp. |
Member Function Documentation
|
Returns true if files can be dropped over this item. Contrary to popular belief, not only dirs will return true :) Executables, .desktop files, will do so as well.
Definition at line 692 of file kfileitem.cpp. |
|
Returns the access control list for the file.
Definition at line 370 of file kfileitem.cpp. |
|
Somewhat like an assignment operator, but more explicit. Note: extra-data set with setExtraData() is not copied, so be careful what you do!
Definition at line 864 of file kfileitem.cpp. |
|
Somewhat like a comparison operator, but more explicit.
Definition at line 842 of file kfileitem.cpp. |
|
Returns the default access control list for the directory.
Definition at line 383 of file kfileitem.cpp. |
|
Returns the mimetype of the file item. If _determineMimeTypeOnDemand was used in the constructor, this will determine the mimetype first.
Definition at line 498 of file kfileitem.cpp. |
|
Returns the UDS entry. Used by the tree view to access all details by position.
Definition at line 399 of file kfileitem.h. |
|
Retrieves the extra data with the given
Definition at line 958 of file kfileitem.cpp. |
|
Retrieves the extra data with the given
Definition at line 950 of file kfileitem.cpp. |
|
Returns the string to be displayed in the statusbar, e.g. when the mouse is over this item
Definition at line 713 of file kfileitem.cpp. |
|
Returns the string to be displayed in the tool tip when the mouse is over this item. This may load a plugin to determine additional information specific to the mimetype of the file.
Definition at line 752 of file kfileitem.cpp. |
|
Returns the group of the file.
Definition at line 471 of file kfileitem.cpp. |
|
Tells if the file has extended access level information ( Posix ACL ).
Definition at line 360 of file kfileitem.cpp. |
|
Returns the full path name to the icon that represents this mime type.
Definition at line 536 of file kfileitem.cpp. |
|
Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called again later.
Definition at line 127 of file kfileitem.cpp. |
|
Returns true if this item represents a directory.
Definition at line 674 of file kfileitem.cpp. |
|
Returns true if this item represents a file (and not a a directory).
Definition at line 198 of file kfileitem.h. |
|
Checks whether the file is hidden.
Definition at line 663 of file kfileitem.cpp. |
|
Returns true if this item represents a link in the UNIX sense of a link.
Definition at line 186 of file kfileitem.h. |
|
Returns true if the file is a local file.
Definition at line 282 of file kfileitem.h. |
|
Used when updating a directory. marked == seen when refreshing.
Definition at line 405 of file kfileitem.h. |
|
Checks whether the file or directory is readable. In some cases (remote files), we may return true even though it can't be read.
Definition at line 621 of file kfileitem.cpp. |
|
Checks whether the file or directory is writable. In some cases (remote files), we may return true even though it can't be written to.
Definition at line 642 of file kfileitem.cpp. |
|
Returns the link destination if isLink() == true.
Definition at line 296 of file kfileitem.cpp. |
|
Returns the local path if isLocalFile() == true or the KIO item has a UDS_LOCAL_PATH atom.
Definition at line 317 of file kfileitem.cpp. |
|
Marks the item.
Definition at line 410 of file kfileitem.h. |
|
Returns the metainfo of this item.
Definition at line 1035 of file kfileitem.cpp. |
|
Returns the descriptive comment for this mime type, or the mime type itself if none is present.
Definition at line 521 of file kfileitem.cpp. |
|
Returns the mimetype of the file item.
If
Definition at line 492 of file kfileitem.cpp. |
|
Returns the currently known mimetype of the file item. This will not try to determine the mimetype if unknown.
Definition at line 328 of file kfileitem.h. |
|
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, . ..).
Definition at line 167 of file kfileitem.h. |
|
Tries to give a local URL for this file item if possible. The given boolean indicates if the returned url is local or not. Definition at line 1049 of file kfileitem.cpp. |
|
Return the name of the file item (without a path). Similar to text(), but unencoded, i.e. the original name.
Definition at line 298 of file kfileitem.h. |
|
Assignment operator, calls assign().
Definition at line 116 of file kfileitem.cpp. |
|
Returns the overlays (bitfield of KIcon::*Overlay flags) that are used for this item's pixmap. Overlays are used to show for example, whether a file can be modified.
Definition at line 547 of file kfileitem.cpp. |
|
Parses the given permission set and provides it for access().
Definition at line 979 of file kfileitem.cpp. |
|
Returns the permissions of the file (stat.st_mode containing only permissions).
Definition at line 134 of file kfileitem.h. |
|
Returns the access permissions for the file as a string.
Definition at line 971 of file kfileitem.cpp. |
|
Returns a pixmap representing the file.
Definition at line 575 of file kfileitem.cpp. |
|
Extracts the data from the UDSEntry member and updates the KFileItem accordingly.
Definition at line 189 of file kfileitem.cpp. |
|
Throw away and re-read (for local files) all information about the file. This is called when the _file_ changes. Definition at line 260 of file kfileitem.cpp. |
|
Re-reads mimetype information. This is called when the mimetype database changes. Definition at line 278 of file kfileitem.cpp. |
|
Removes the extra data associated with an item via
Definition at line 966 of file kfileitem.cpp. |
|
Let's "KRun" this file ! (e.g. when file is clicked or double-clicked or return is pressed) Definition at line 834 of file kfileitem.cpp. |
|
This allows to associate some "extra" data to a KFileItem. As one KFileItem can be used by several objects (often views) which all need to add some data, you have to use a key to reference your extra data within the KFileItem. That way a KFileItem can hold and provide access to all those views separately. I.e. a KFileIconView that associates a KFileIconViewItem (an item suitable for use with QIconView) does
kfileItem->setExtraData( this, iconViewItem );
and can later access the iconViewItem by doing
KFileIconViewItem *iconViewItem = static_cast<KFileIconViewItem*>( kfileItem->extraData( this ));
This is usually more efficient then having every view associate data to items by using a separate QDict or QMap. Note: you have to remove and destroy the data you associated yourself when you don't need it anymore!
Definition at line 942 of file kfileitem.cpp. |
|
Sets the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, . ..).
Definition at line 932 of file kfileitem.cpp. |
|
Sets the metainfo of this item to
Definition at line 1030 of file kfileitem.cpp. |
|
Sets new mimetype for item.
Definition at line 937 of file kfileitem.cpp. |
|
Sets the item's name (i.e. the filename). This is automatically done by setURL, to set the name from the URL's fileName(). This method is provided for some special cases like relative paths as names (KFindPart)
Definition at line 290 of file kfileitem.cpp. |
|
Reinitialize KFileItem with a new UDSEntry. Note: extra-data set with setExtraData() is not changed or deleted, so be careful what you do! KDirListerCache uses it to save new/delete calls by updating existing items that are otherwise not needed anymore.
Definition at line 904 of file kfileitem.cpp. |
|
Sets the item's URL. Do not call unless you know what you are doing! (used for example when an item got renamed).
Definition at line 284 of file kfileitem.cpp. |
|
Returns the size of the file, if known, and sets
Definition at line 336 of file kfileitem.cpp. |
|
Returns the size of the file, if known.
Definition at line 393 of file kfileitem.cpp. |
|
Returns the text of the file item. It's not exactly the filename since some decoding happens ('2F'->'/').
Definition at line 289 of file kfileitem.h. |
|
Requests the modification, access or creation time, depending on
Definition at line 404 of file kfileitem.cpp. |
|
Requests the modification, access or creation time, depending on
Definition at line 399 of file kfileitem.cpp. |
|
Requests the modification, access or creation time as a string, depending on
Definition at line 1019 of file kfileitem.cpp. |
|
Unmarks the item.
Definition at line 415 of file kfileitem.h. |
|
Returns the url of the file.
Definition at line 113 of file kfileitem.h. |
|
Returns the owner of the file.
Definition at line 456 of file kfileitem.cpp. |
The documentation for this class was generated from the following files: