KFileItem Class Reference
A KFileItem is a generic class to handle a file, local or remote. More...
#include <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 |
mode_t | mode () const |
QString | user () const |
QString | group () const |
bool | isLink () const |
bool | isDir () const |
bool | isFile () const |
bool | isReadable () const |
bool | isHidden () const |
QString | linkDest () const |
KIO::filesize_t | size () const |
time_t | time (unsigned int which) 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) |
const KFileMetaInfo & | metaInfo (bool autoget=true, int what=KFileMetaInfo::Fastest) const |
void | assign (const KFileItem &item) |
Protected Member Functions | |
void | init (bool _determineMimeTypeOnDemand) |
QString | parsePermissions (mode_t perm) const |
virtual void | virtual_hook (int id, void *data) |
Friends | |
QDataStream & | operator<< (QDataStream &s, const KFileItem &a) |
QDataStream & | operator>> (QDataStream &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 KIO::listDir (UDSEntry isn't very friendly to use). It includes many file attributes such as mimetype, icon, text, mode, link...
Definition at line 39 of file kfileitem.h.
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. References KURL::addPath(), KIO::decodeFileName(), init(), KMimeType::mimeType(), KGlobal::staticQString(), KIO::UDS_ACCESS, KIO::UDS_FILE_TYPE, KIO::UDS_GROUP, KIO::UDS_GUESSED_MIME_TYPE, KIO::UDS_ICON_NAME, KIO::UDS_LINK_DEST, KIO::UDS_MIME_TYPE, KIO::UDS_NAME, KIO::UDS_URL, and KIO::UDS_USER. |
|
Creates an item representing a file, from all the necessary info for it.
Definition at line 124 of file kfileitem.cpp. References init(). |
|
Creates an item representing a file, for which the mimetype is already known.
Definition at line 141 of file kfileitem.cpp. References init(), and KMimeType::mimeType(). |
|
Copy constructor. Note that extra-data set via setExtraData() is not deeply copied -- just the pointers are copied. Definition at line 160 of file kfileitem.cpp. References assign(). |
|
Destructs the KFileItem. Extra data set via setExtraData() is not deleted. Definition at line 166 of file kfileitem.cpp. |
Member Function Documentation
|
Re-reads information (currently only permissions and mimetype). This is called when the _file_ changes. Definition at line 230 of file kfileitem.cpp. References init(). Referenced by KDirListerCache::FilesChanged(). |
|
Re-reads mimetype information. This is called when the mimetype database changes. Definition at line 250 of file kfileitem.cpp. References init(). Referenced by KDirListerCache::FileRenamed(). |
|
Returns the url of the file.
Definition at line 111 of file kfileitem.h. Referenced by KDirListerCache::FilesRemoved(), KDirOperator::insertNewFiles(), KPropsDlgPlugin::isDesktopFile(), KFileTreeViewItem::path(), run(), KDirOperator::selectDir(), and KFileTreeViewItem::url(). |
|
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 256 of file kfileitem.cpp. References KURL::fileName(), and setName(). Referenced by KDirListerCache::FileRenamed(). |
|
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 262 of file kfileitem.cpp. References KIO::decodeFileName(). Referenced by setURL(). |
|
Returns the permissions of the file (stat.st_mode containing only permissions).
Definition at line 132 of file kfileitem.h. Referenced by KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(). |
|
Returns the access permissions for the file as a string.
Definition at line 759 of file kfileitem.cpp. References parsePermissions(). Referenced by KFileListViewItem::init(). |
|
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, . ..).
Definition at line 144 of file kfileitem.h. Referenced by acceptsDrops(), init(), KPropsDlgPlugin::isDesktopFile(), KFilePropsPlugin::KFilePropsPlugin(), and KSimpleFileFilter::passesFilter(). |
|
Returns the owner of the file.
Definition at line 355 of file kfileitem.cpp. References KURL::path(). Referenced by getToolTipText(), KFileListViewItem::init(), and KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(). |
|
Returns the group of the file.
Definition at line 370 of file kfileitem.cpp. References KURL::path(). Referenced by getToolTipText(), KFileListViewItem::init(), and KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(). |
|
Returns true if this item represents a link in the UNIX sense of a link.
Definition at line 163 of file kfileitem.h. Referenced by KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(), KFilePropsPlugin::KFilePropsPlugin(), and parsePermissions(). |
|
Returns true if this item represents a directory.
Definition at line 530 of file kfileitem.cpp. References endl(), and kdDebug(). Referenced by KFileViewSignaler::activate(), KDirListerCache::FilesRemoved(), KDirOperator::insertNewFiles(), KFileTreeViewItem::isDir(), isFile(), KDirLister::itemsForDir(), KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(), KFilePropsPlugin::KFilePropsPlugin(), KDirLister::matchesFilter(), parsePermissions(), KDirOperator::prepareCompletionObjects(), KFileView::removeItem(), KFileDialog::setSelection(), KFileIconView::setSorting(), and KFileView::updateNumbers(). |
|
Returns true if this item represents a file (and not a a directory).
Definition at line 175 of file kfileitem.h. References isDir(). Referenced by KFileView::updateNumbers(). |
|
Checks whether the file is readable. In some cases (remote files), we may return true even though it can't be read.
Definition at line 501 of file kfileitem.cpp. References KURL::path(). Referenced by overlays(). |
|
Checks whether the file is hidden.
Definition at line 522 of file kfileitem.cpp. References KURL::fileName(), and KURL::isEmpty(). Referenced by overlays(). |
|
Returns the link destination if isLink() == true.
Definition at line 268 of file kfileitem.cpp. References KURL::path(), and KIO::UDS_LINK_DEST. Referenced by getStatusBarInfo(), getToolTipText(), KFilePropsPlugin::KFilePropsPlugin(), and run(). |
|
Returns the size of the file, if known.
Definition at line 289 of file kfileitem.cpp. References KURL::path(), and KIO::UDS_SIZE. Referenced by cmp(), getStatusBarInfo(), getToolTipText(), KFileListViewItem::init(), KFilePropsPlugin::KFilePropsPlugin(), and KFileIconView::setSorting(). |
|
Requests the modification, access or creation time, depending on
Definition at line 311 of file kfileitem.cpp. References KURL::path(), KIO::UDS_ACCESS_TIME, KIO::UDS_CREATION_TIME, and KIO::UDS_MODIFICATION_TIME. Referenced by cmp(), KFilePropsPlugin::KFilePropsPlugin(), KFileIconView::setSorting(), and timeString(). |
|
Requests the modification, access or creation time as a string, depending on
Definition at line 801 of file kfileitem.cpp. References KGlobal::locale(), and time(). Referenced by getToolTipText(), and KFileListViewItem::init(). |
|
Returns true if the file is a local file.
Definition at line 224 of file kfileitem.h. Referenced by KPropsDlgPlugin::isDesktopFile(). |
|
Returns the text of the file item. It's not exactly the filename since some decoding happens ('2F'->'/').
Definition at line 231 of file kfileitem.h. Referenced by getStatusBarInfo(), KFileListViewItem::init(), KDirLister::matchesFilter(), and KFileIconView::setSorting(). |
|
Return the name of the file item (without a path). Similar to text(), but unencoded, i.e. the original name.
Definition at line 240 of file kfileitem.h. Referenced by KFileDialog::multiSelectionChanged(), KSimpleFileFilter::passesFilter(), KDirOperator::prepareCompletionObjects(), and KFileView::setCurrentItem(). |
|
Returns the mimetype of the file item.
If
Definition at line 389 of file kfileitem.cpp. References determineMimeType(). Referenced by acceptsDrops(), KPropsDlgPlugin::isDesktopFile(), KFilePropsPlugin::KFilePropsPlugin(), KDirLister::matchesMimeFilter(), and metaInfo(). |
|
Returns the mimetype of the file item. If _determineMimeTypeOnDemand was used in the constructor, this will determine the mimetype first.
Definition at line 395 of file kfileitem.cpp. References KMimeType::findByURL(). Referenced by assign(), getStatusBarInfo(), getToolTipText(), iconName(), mimeComment(), and mimetype(). |
|
Returns the currently known mimetype of the file item. This will not try to determine the mimetype if unknown.
Definition at line 270 of file kfileitem.h. Referenced by KSimpleFileFilter::passesFilter(). |
|
Returns the descriptive comment for this mime type, or the mime type itself if none is present.
Definition at line 415 of file kfileitem.cpp. References determineMimeType(). Referenced by KFilePropsPlugin::KFilePropsPlugin(). |
|
Returns the full path name to the icon that represents this mime type.
Definition at line 425 of file kfileitem.cpp. References determineMimeType(). |
|
Returns a pixmap representing the file.
Definition at line 459 of file kfileitem.cpp. References endl(), KURL::fileName(), KMimeType::findByURL(), KServiceType::icon(), kdWarning(), KMimeType::mimeType(), overlays(), KURL::path(), KURL::setPath(), and KGlobal::staticQString(). Referenced by KFileListViewItem::init(). |
|
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 431 of file kfileitem.cpp. References KURL::fileName(), KIcon::HiddenOverlay, KNFSShare::instance(), KSambaShare::instance(), isHidden(), isReadable(), KIcon::LinkOverlay, KIcon::LockOverlay, KURL::path(), KIcon::ShareOverlay, and KIcon::ZipOverlay. Referenced by pixmap(). |
|
Returns the string to be displayed in the statusbar, e.g. when the mouse is over this item
Definition at line 565 of file kfileitem.cpp. References KIO::convertSize(), determineMimeType(), linkDest(), size(), and text(). |
|
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 604 of file kfileitem.cpp. References KIO::convertSize(), determineMimeType(), group(), KFileMetaInfo::isEmpty(), KFileMetaInfoItem::isValid(), KFileMetaInfo::isValid(), KFileMetaInfo::item(), linkDest(), metaInfo(), parsePermissions(), KFileMetaInfo::preferredKeys(), size(), KFileMetaInfoItem::string(), timeString(), KFileMetaInfoItem::translatedKey(), KIO::UDS_MODIFICATION_TIME, and user(). |
|
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 540 of file kfileitem.cpp. References mimetype(), mode(), and KURL::path(). |
|
Let's "KRun" this file ! (e.g. when file is clicked or double-clicked or return is pressed) Definition at line 674 of file kfileitem.cpp. References linkDest(), and url(). |
|
Returns the UDS entry. Used by the tree view to access all details by position.
Definition at line 341 of file kfileitem.h. |
|
Used when updating a directory. marked == seen when refreshing.
Definition at line 347 of file kfileitem.h. |
|
Marks the item.
Definition at line 352 of file kfileitem.h. |
|
Unmarks the item.
Definition at line 357 of file kfileitem.h. |
|
Somewhat like a comparison operator, but more explicit.
Definition at line 685 of file kfileitem.cpp. References m_bIsLocalURL, m_bLink, m_fileMode, m_group, m_permissions, m_strName, m_user, size(), time(), and KIO::UDS_MODIFICATION_TIME. |
|
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 730 of file kfileitem.cpp. Referenced by KFileIconView::insertItem(), and KFileDetailView::insertItem(). |
|
Retrieves the extra data with the given
Definition at line 738 of file kfileitem.cpp. Referenced by KFileDetailView::ensureItemVisible(), KFileTreeView::findItem(), KFileTreeBranch::findTVIByURL(), KFileDetailView::isSelected(), KFileDetailView::setCurrentItem(), and KFileDetailView::setSelected(). |
|
Retrieves the extra data with the given
Definition at line 746 of file kfileitem.cpp. |
|
Removes the extra data associated with an item via
Definition at line 754 of file kfileitem.cpp. |
|
Sets the metainfo of this item to
Definition at line 808 of file kfileitem.cpp. Referenced by KFileMetaPropsPlugin::KFileMetaPropsPlugin(). |
|
Returns the metainfo of this item.
Definition at line 813 of file kfileitem.cpp. References KFileMetaInfo::isValid(), mimetype(), and KGlobalSettings::showFilePreview(). Referenced by getToolTipText(), and KFileMetaPropsPlugin::KFileMetaPropsPlugin(). |
|
Somewhat like an assignment operator, but more explicit. Note: extra-data set with setExtraData() is not copied, so be careful what you do! I.e. KDirLister uses it to update existing items from a fresh item.
Definition at line 698 of file kfileitem.cpp. References determineMimeType(). Referenced by KFileItem(). |
|
Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called again later.
Definition at line 171 of file kfileitem.cpp. References KMimeType::findByURL(), KURL::isEmpty(), KURL::isLocalFile(), mode(), and KURL::path(). Referenced by KFileItem(), refresh(), and refreshMimeType(). |
|
Parses the given permission set and provides it for access().
Definition at line 767 of file kfileitem.cpp. References isDir(), and isLink(). Referenced by getToolTipText(), and permissionsString(). |
The documentation for this class was generated from the following files: