#include <tdefileitem.h>
Public Types | |
enum | { Unknown = (mode_t) - 1 } |
Public Member Functions | |
KFileItem (const TDEIO::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 TQString &mimeType, mode_t mode) | |
KFileItem (const KFileItem &item) | |
virtual | ~KFileItem () |
void | refresh () |
void | refreshMimeType () |
const KURL & | url () const |
void | setURL (const KURL &url) |
const KURL & | listerURL () const |
void | setListerURL (const KURL &url) |
void | setName (const TQString &name) |
mode_t | permissions () const |
TQString | permissionsString () const |
bool | hasExtendedACL () const |
KACL | ACL () const |
KACL | defaultACL () const |
mode_t | mode () const |
TQString | user () const |
TQString | group () const |
bool | isLink () const |
bool | isDir () const |
bool | isFile () const |
bool | isReadable () const |
bool | isWritable () const |
bool | isHidden () const |
TQString | linkDest () const |
TQString | localPath () const |
TDEIO::filesize_t | size () const |
TDEIO::filesize_t | size (bool &hasSize) const |
time_t | time (unsigned int which) const |
time_t | time (unsigned int which, bool &hasTime) const |
TQString | timeString (unsigned int which=TDEIO::UDS_MODIFICATION_TIME) const |
bool | isLocalFile () const |
const TQString & | text () const |
const TQString & | name (bool lowerCase=false) const |
TQString | mimetype () const |
TQString | mimetypeFast () const |
KMimeType::Ptr | mimeTypePtrFast () |
KMimeType::Ptr | determineMimeType () |
KMimeType::Ptr | mimeTypePtr () const |
bool | isMimeTypeKnown () const |
TQString | mimeComment () |
TQString | iconName () |
TQPixmap | pixmap (int _size, int _state=0) const |
int | overlays () const |
TQString | getStatusBarInfo () |
TQString | getToolTipText (int maxcount=6) |
bool | acceptsDrops () |
void | run () |
const TDEIO::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 TQString &mimetype) |
const KFileMetaInfo & | metaInfo (bool autoget=true, int what=KFileMetaInfo::Fastest) const |
void | assign (const KFileItem &item) |
void | setUDSEntry (const TDEIO::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) |
TQString | parsePermissions (mode_t perm) const |
virtual void | virtual_hook (int id, void *data) |
Friends | |
TDEIO_EXPORT friend TQDataStream & | operator<< (TQDataStream &s, const KFileItem &a) |
TDEIO_EXPORT friend TQDataStream & | operator>> (TQDataStream &s, KFileItem &a) |
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 TDEIO::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 tdefileitem.h.
Constructor & Destructor Documentation
◆ KFileItem() [1/4]
KFileItem::KFileItem | ( | const TDEIO::UDSEntry & | _entry, |
const KURL & | _url, | ||
bool | _determineMimeTypeOnDemand = false , |
||
bool | _urlIsDirectory = false |
||
) |
Creates an item representing a file, from a UDSEntry.
This is the preferred constructor when using TDEIO::listDir().
- Parameters
-
_entry the TDEIO entry used to get the file, contains info about it _url the file url _determineMimeTypeOnDemand specifies if the mimetype of the given URL should be determined immediately or on demand _urlIsDirectory specifies if the url is just the directory of the fileitem and the filename from the UDSEntry should be used.
Definition at line 68 of file tdefileitem.cpp.
◆ KFileItem() [2/4]
KFileItem::KFileItem | ( | mode_t | _mode, |
mode_t | _permissions, | ||
const KURL & | _url, | ||
bool | _determineMimeTypeOnDemand = false |
||
) |
Creates an item representing a file, from all the necessary info for it.
- Parameters
-
_mode the file mode (according to stat() (e.g. S_IFDIR...) Set to KFileItem::Unknown if unknown. For local files, KFileItem will use stat(). _permissions the access permissions If you set both the mode and the permissions, you save a ::stat() for local files. Set to KFileItem::Unknown if you don't know the mode or the permission. _url the file url _determineMimeTypeOnDemand specify if the mimetype of the given URL should be determined immediately or on demand
Definition at line 86 of file tdefileitem.cpp.
◆ KFileItem() [3/4]
KFileItem::KFileItem | ( | const KURL & | url, |
const TQString & | mimeType, | ||
mode_t | mode | ||
) |
Creates an item representing a file, for which the mimetype is already known.
- Parameters
-
url the file url mimeType the name of the file's mimetype mode the mode (S_IFDIR...)
Definition at line 104 of file tdefileitem.cpp.
◆ KFileItem() [4/4]
KFileItem::KFileItem | ( | const KFileItem & | item | ) |
Copy constructor.
Note that extra-data set via setExtraData() is not deeply copied – just the pointers are copied.
Definition at line 125 of file tdefileitem.cpp.
◆ ~KFileItem()
|
virtual |
Destructs the KFileItem.
Extra data set via setExtraData() is not deleted.
Definition at line 137 of file tdefileitem.cpp.
Member Function Documentation
◆ acceptsDrops()
bool KFileItem::acceptsDrops | ( | ) |
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.
- Returns
- true if you can drop files over the item
Definition at line 862 of file tdefileitem.cpp.
◆ ACL()
KACL KFileItem::ACL | ( | ) | const |
Returns the access control list for the file.
- Returns
- the access control list as a KACL
- Since
- 3.5
Definition at line 423 of file tdefileitem.cpp.
◆ assign()
void KFileItem::assign | ( | const KFileItem & | item | ) |
Somewhat like an assignment operator, but more explicit.
Note: extra-data set with setExtraData() is not copied, so be careful what you do!
- Parameters
-
item the item to copy
Definition at line 1047 of file tdefileitem.cpp.
◆ cmp()
bool KFileItem::cmp | ( | const KFileItem & | item | ) |
Somewhat like a comparison operator, but more explicit.
- Parameters
-
item the item to compare
- Returns
- true if all values are equal
Definition at line 1024 of file tdefileitem.cpp.
◆ defaultACL()
KACL KFileItem::defaultACL | ( | ) | const |
Returns the default access control list for the directory.
- Returns
- the default access control list as a KACL
- Since
- 3.5
Definition at line 438 of file tdefileitem.cpp.
◆ determineMimeType()
KMimeType::Ptr KFileItem::determineMimeType | ( | ) |
Returns the mimetype of the file item.
If _determineMimeTypeOnDemand was used in the constructor, this will determine the mimetype first.
- Returns
- the mime type
Definition at line 572 of file tdefileitem.cpp.
◆ entry()
|
inline |
Returns the UDS entry.
Used by the tree view to access all details by position.
- Returns
- the UDS entry
Definition at line 429 of file tdefileitem.h.
◆ extraData() [1/2]
|
virtual |
Retrieves the extra data with the given key
.
- Parameters
-
key the key of the extra data
- Returns
- the extra data associated to an item with
key
via setExtraData. 0L if nothing was associated withkey
.
- See also
- extraData
Definition at line 1147 of file tdefileitem.cpp.
◆ extraData() [2/2]
|
virtual |
Retrieves the extra data with the given key
.
- Parameters
-
key the key of the extra data
- Returns
- the extra data associated to an item with
key
via setExtraData. 0L if nothing was associated withkey
.
- See also
- extraData
Definition at line 1139 of file tdefileitem.cpp.
◆ getStatusBarInfo()
TQString KFileItem::getStatusBarInfo | ( | ) |
Returns the string to be displayed in the statusbar, e.g.
when the mouse is over this item
- Returns
- the status bar information
Definition at line 889 of file tdefileitem.cpp.
◆ getToolTipText()
TQString KFileItem::getToolTipText | ( | int | maxcount = 6 | ) |
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.
- Parameters
-
maxcount the maximum number of entries shown
- Returns
- the tool tip string
Definition at line 934 of file tdefileitem.cpp.
◆ group()
TQString KFileItem::group | ( | ) | const |
Returns the group of the file.
- Returns
- the file's group
Definition at line 530 of file tdefileitem.cpp.
◆ hasExtendedACL()
bool KFileItem::hasExtendedACL | ( | ) | const |
Tells if the file has extended access level information ( Posix ACL )
- Returns
- true if the file has extend ACL information or false if it hasn't
- Since
- 3.5
Definition at line 412 of file tdefileitem.cpp.
◆ iconName()
TQString KFileItem::iconName | ( | ) |
Returns the full path name to the icon that represents this mime type.
- Returns
- iconName the name of the file's icon
Definition at line 621 of file tdefileitem.cpp.
◆ init()
|
protected |
Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called again later.
Definition at line 142 of file tdefileitem.cpp.
◆ isDir()
bool KFileItem::isDir | ( | ) | const |
Returns true if this item represents a directory.
- Returns
- true if the item is a directory
Definition at line 844 of file tdefileitem.cpp.
◆ isFile()
|
inline |
Returns true if this item represents a file (and not a a directory)
- Returns
- true if the item is a file
Definition at line 212 of file tdefileitem.h.
◆ isHidden()
bool KFileItem::isHidden | ( | ) | const |
Checks whether the file is hidden.
- Returns
- true if the file is hidden.
Definition at line 833 of file tdefileitem.cpp.
◆ isLink()
|
inline |
Returns true if this item represents a link in the UNIX sense of a link.
- Returns
- true if the file is a link
Definition at line 200 of file tdefileitem.h.
◆ isLocalFile()
|
inline |
Returns true if the file is a local file.
- Returns
- true if the file is local, false otherwise
Definition at line 296 of file tdefileitem.h.
◆ isMarked()
|
inline |
Used when updating a directory.
marked == seen when refreshing.
- Returns
- true if the file item is marked
Definition at line 435 of file tdefileitem.h.
◆ isReadable()
bool KFileItem::isReadable | ( | ) | const |
Checks whether the file or directory is readable.
In some cases (remote files), we may return true even though it can't be read.
- Returns
- true if the file can be read - more precisely, false if we know for sure it can't
Definition at line 783 of file tdefileitem.cpp.
◆ isWritable()
bool KFileItem::isWritable | ( | ) | const |
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.
- Returns
- true if the file or directory can be written to - more precisely, false if we know for sure it can't
- Since
- 3.4
Definition at line 810 of file tdefileitem.cpp.
◆ linkDest()
TQString KFileItem::linkDest | ( | ) | const |
Returns the link destination if isLink() == true.
- Returns
- the link destination. TQString::null if the item is not a link
Definition at line 332 of file tdefileitem.cpp.
◆ listerURL()
|
inline |
Returns the lister url of the file.
- Returns
- the lister url of the file
Definition at line 127 of file tdefileitem.h.
◆ localPath()
TQString KFileItem::localPath | ( | ) | const |
Returns the local path if isLocalFile() == true or the TDEIO item has a UDS_LOCAL_PATH atom.
- Returns
- the item local path, or TQString::null if not known
- Since
- 3.4
Definition at line 355 of file tdefileitem.cpp.
◆ mark()
|
inline |
◆ metaInfo()
const KFileMetaInfo & KFileItem::metaInfo | ( | bool | autoget = true , |
int | what = KFileMetaInfo::Fastest |
||
) | const |
Returns the metainfo of this item.
- Parameters
-
autoget if true, the metainfo will automatically be created what ignored
Definition at line 1224 of file tdefileitem.cpp.
◆ mimeComment()
TQString KFileItem::mimeComment | ( | ) |
Returns the descriptive comment for this mime type, or the mime type itself if none is present.
- Returns
- the mime type description, or the mime type itself
Definition at line 595 of file tdefileitem.cpp.
◆ mimetype()
TQString KFileItem::mimetype | ( | ) | const |
Returns the mimetype of the file item.
If _determineMimeTypeOnDemand
was used in the constructor, this will determine the mimetype first. Equivalent to determineMimeType()->name()
- Returns
- the mime type of the file
Definition at line 551 of file tdefileitem.cpp.
◆ mimetypeFast()
TQString KFileItem::mimetypeFast | ( | ) | const |
Returns the mimetype of the file item.
If _determineMimeTypeOnDemand
was used in the constructor, this will return the mimetype as fast as possible at the expense of accuracy.
- Returns
- the fast mime type of the file
Definition at line 557 of file tdefileitem.cpp.
◆ mimeTypePtr()
|
inline |
Returns the currently known mimetype of the file item.
This will not try to determine the mimetype if unknown.
- Returns
- the known mime type
Definition at line 358 of file tdefileitem.h.
◆ mimeTypePtrFast()
KMimeType::Ptr KFileItem::mimeTypePtrFast | ( | ) |
Returns the mimetype of the file item.
If _determineMimeTypeOnDemand
was used in the constructor, this will return the mimetype as fast as possible at the expense of accuracy.
- Returns
- the fast mime type
Definition at line 567 of file tdefileitem.cpp.
◆ mode()
|
inline |
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
- Returns
- the file type
Definition at line 181 of file tdefileitem.h.
◆ mostLocalURL()
KURL KFileItem::mostLocalURL | ( | bool & | local | ) | const |
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 1238 of file tdefileitem.cpp.
◆ name()
|
inline |
Return the name of the file item (without a path).
Similar to text(), but unencoded, i.e. the original name.
- Parameters
-
lowerCase if true, the name will be returned in lower case, which is useful to speed up sorting by name, case insensitively.
- Returns
- the file's name
Definition at line 312 of file tdefileitem.h.
◆ operator=()
Assignment operator, calls assign()
Definition at line 131 of file tdefileitem.cpp.
◆ overlays()
int KFileItem::overlays | ( | ) | const |
Returns the overlays (bitfield of TDEIcon::*Overlay flags) that are used for this item's pixmap.
Overlays are used to show for example, whether a file can be modified.
- Returns
- the overlays of the pixmap
Definition at line 632 of file tdefileitem.cpp.
◆ parsePermissions()
|
protected |
Parses the given permission set and provides it for access()
Definition at line 1168 of file tdefileitem.cpp.
◆ permissions()
|
inline |
Returns the permissions of the file (stat.st_mode containing only permissions).
- Returns
- the permissions of the file
Definition at line 148 of file tdefileitem.h.
◆ permissionsString()
TQString KFileItem::permissionsString | ( | ) | const |
Returns the access permissions for the file as a string.
- Returns
- the access persmission as string
Definition at line 1160 of file tdefileitem.cpp.
◆ pixmap()
TQPixmap KFileItem::pixmap | ( | int | _size, |
int | _state = 0 |
||
) | const |
Returns a pixmap representing the file.
- Parameters
-
_size Size for the pixmap in pixels. Zero will return the globally configured default size. _state The state of the icon: TDEIcon::DefaultState, TDEIcon::ActiveState or TDEIcon::DisabledState.
- Returns
- the pixmap
Definition at line 660 of file tdefileitem.cpp.
◆ readUDSEntry()
|
protected |
Extracts the data from the UDSEntry member and updates the KFileItem accordingly.
- Since
- 3.4.1
Definition at line 209 of file tdefileitem.cpp.
◆ refresh()
void KFileItem::refresh | ( | ) |
Throw away and re-read (for local files) all information about the file.
This is called when the file changes.
Definition at line 285 of file tdefileitem.cpp.
◆ refreshMimeType()
void KFileItem::refreshMimeType | ( | ) |
Re-reads mimetype information.
This is called when the mimetype database changes.
Definition at line 303 of file tdefileitem.cpp.
◆ removeExtraData()
|
virtual |
Removes the extra data associated with an item via key
.
- Parameters
-
key the key of the extra data to remove
Definition at line 1155 of file tdefileitem.cpp.
◆ run()
void KFileItem::run | ( | ) |
Let's "KRun" this file ! (e.g.
when file is clicked or double-clicked or return is pressed)
Definition at line 1016 of file tdefileitem.cpp.
◆ setExtraData()
|
virtual |
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 TQIconView) does
and can later access the iconViewItem by doing
This is usually more efficient then having every view associate data to items by using a separate TQDict or TQMap.
Note: you have to remove and destroy the data you associated yourself when you don't need it anymore!
- Parameters
-
key the key of the extra data value the value of the extra data
- See also
- extraData
- removeExtraData
Definition at line 1131 of file tdefileitem.cpp.
◆ setFileMode()
void KFileItem::setFileMode | ( | mode_t | m | ) |
Sets the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
- Parameters
-
m the new file type
- Since
- 3.5.0
- Todo:
- Actually explain what this does – does setting S_IFDIR mean the file type is set to Directory?
Definition at line 1121 of file tdefileitem.cpp.
◆ setListerURL()
void KFileItem::setListerURL | ( | const KURL & | url | ) |
Sets the item's lister URL.
Do not call unless you know what you are doing!
- Parameters
-
url the item's lister URL
Definition at line 321 of file tdefileitem.cpp.
◆ setMetaInfo()
void KFileItem::setMetaInfo | ( | const KFileMetaInfo & | info | ) |
Sets the metainfo of this item to info
.
- Parameters
-
info the new meta info
Definition at line 1219 of file tdefileitem.cpp.
◆ setMimeType()
void KFileItem::setMimeType | ( | const TQString & | mimetype | ) |
Sets new mimetype for item.
- Parameters
-
mimetype the new mimetype
- Since
- 3.5.0
Definition at line 1126 of file tdefileitem.cpp.
◆ setName()
void KFileItem::setName | ( | const TQString & | name | ) |
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)
- Parameters
-
name the item's name
Definition at line 326 of file tdefileitem.cpp.
◆ setUDSEntry()
void KFileItem::setUDSEntry | ( | const TDEIO::UDSEntry & | entry, |
const KURL & | url, | ||
bool | determineMimeTypeOnDemand = false , |
||
bool | urlIsDirectory = false |
||
) |
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.
- Parameters
-
entry the UDSEntry to assign to this KFileItem url the file url determineMimeTypeOnDemand specifies if the mimetype of the given URL should be determined immediately or on demand urlIsDirectory specifies if the url is just the directory of the fileitem and the filename from the UDSEntry should be used.
- Since
- 3.4.1
Definition at line 1090 of file tdefileitem.cpp.
◆ setURL()
void KFileItem::setURL | ( | const KURL & | url | ) |
Sets the item's URL.
Do not call unless you know what you are doing! (used for example when an item got renamed).
- Parameters
-
url the item's URL
Definition at line 314 of file tdefileitem.cpp.
◆ size() [1/2]
TDEIO::filesize_t KFileItem::size | ( | ) | const |
Returns the size of the file, if known.
- Returns
- the file size, or 0 if not known
Definition at line 450 of file tdefileitem.cpp.
◆ size() [2/2]
TDEIO::filesize_t KFileItem::size | ( | bool & | hasSize | ) | const |
Returns the size of the file, if known, and sets hasSize
to false if not known.
- Parameters
-
Definition at line 386 of file tdefileitem.cpp.
◆ text()
|
inline |
Returns the text of the file item.
It's not exactly the filename since some decoding happens ('%2F'->'/').
- Returns
- the text of the file item
Definition at line 303 of file tdefileitem.h.
◆ time() [1/2]
time_t KFileItem::time | ( | unsigned int | which | ) | const |
Requests the modification, access or creation time, depending on which
.
- Parameters
-
which UDS_MODIFICATION_TIME, UDS_ACCESS_TIME or UDS_CREATION_TIME
- Returns
- the time asked for, (time_t)0 if not available
- See also
- timeString()
Definition at line 456 of file tdefileitem.cpp.
◆ time() [2/2]
time_t KFileItem::time | ( | unsigned int | which, |
bool & | hasTime | ||
) | const |
Requests the modification, access or creation time, depending on which
.
- Parameters
-
which UDS_MODIFICATION_TIME, UDS_ACCESS_TIME or UDS_CREATION_TIME hasTime This is set to true is the time is known, and false if not known
- Returns
- the time asked for, (time_t)0 if not known/available
- See also
- timeString()
Definition at line 461 of file tdefileitem.cpp.
◆ timeString()
TQString KFileItem::timeString | ( | unsigned int | which = TDEIO::UDS_MODIFICATION_TIME | ) | const |
Requests the modification, access or creation time as a string, depending on which
.
- Parameters
-
which UDS_MODIFICATION_TIME, UDS_ACCESS_TIME or UDS_CREATION_TIME
- Returns
- a formatted string of the requested time, TQString::null if time is not known
- See also
- time
Definition at line 1208 of file tdefileitem.cpp.
◆ unmark()
|
inline |
◆ url()
|
inline |
Returns the url of the file.
- Returns
- the url of the file
Definition at line 113 of file tdefileitem.h.
◆ user()
TQString KFileItem::user | ( | ) | const |
Returns the owner of the file.
- Returns
- the file's owner
Definition at line 515 of file tdefileitem.cpp.
The documentation for this class was generated from the following files: