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) | |
Creates an item representing a file, from a UDSEntry. | |
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. | |
KFileItem (const KURL &url, const QString &mimeType, mode_t mode) | |
Creates an item representing a file, for which the mimetype is already known. | |
KFileItem (const KFileItem &item) | |
Copy constructor. | |
virtual | ~KFileItem () |
Destructs the KFileItem. | |
void | refresh () |
Re-reads information (currently only permissions and mimetype). | |
void | refreshMimeType () |
Re-reads mimetype information. | |
const KURL & | url () const |
Returns the url of the file. | |
void | setURL (const KURL &url) |
Sets the item's URL. | |
mode_t | permissions () const |
Returns the permissions of the file (stat.st_mode containing only permissions). | |
QString | permissionsString () const |
Returns the access permissions for the file as a string. | |
mode_t | mode () const |
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...). | |
QString | user () const |
Returns the owner of the file. | |
QString | group () const |
Returns the group of the file. | |
bool | isLink () const |
Returns true if this item represents a link in the UNIX sense of a link. | |
bool | isDir () const |
Returns true if this item represents a directory. | |
bool | isFile () const |
Returns true if this item represents a file (and not a a directory). | |
bool | isReadable () const |
QString | linkDest () const |
Returns the link destination if isLink() == true. | |
KIO::filesize_t | size () const |
Returns the size of the file, if known. | |
time_t | time (unsigned int which) const |
QString | timeString (unsigned int which=KIO::UDS_MODIFICATION_TIME) const |
bool | isLocalFile () const |
Returns true if the file is a local file. | |
const QString & | text () const |
Returns the text of the file item. | |
const QString & | name (bool lowerCase=false) const |
QString | mimetype () const |
Returns the mimetype of the file item. | |
KMimeType::Ptr | determineMimeType () |
Returns the mimetype of the file item. | |
KMimeType::Ptr | mimeTypePtr () const |
Returns the currently known mimetype of the file item. | |
bool | isMimeTypeKnown () const |
QString | mimeComment () |
Returns the descriptive comment for this mime type, or the mime type itself if none is present. | |
QString | iconName () |
Returns the full path name to the icon that represents this mime type. | |
QPixmap | pixmap (int _size, int _state=0) const |
Returns a pixmap representing the file. | |
int | overlays () const |
Returns the overlays (bitfield of KIcon::*Overlay flags) that are used for this item's pixmap. | |
QString | getStatusBarInfo () |
Returns the string to be displayed in the statusbar, e.g. | |
QString | getToolTipText (int maxcount=6) |
bool | acceptsDrops () |
Returns true if files can be dropped over this item. | |
void | run () |
Let's "KRun" this file ! (e.g. | |
const KIO::UDSEntry & | entry () const |
Returns the UDS entry. | |
bool | isMarked () const |
void | mark () |
void | unmark () |
bool | cmp (const KFileItem &item) |
Somewhat like a comparison operator, but more explicit. | |
virtual void | setExtraData (const void *key, void *value) |
This allows to associate some "extra" data to a KFileItem. | |
virtual const void * | extraData (const void *key) const |
virtual void * | extraData (const void *key) |
The non-const version of the previous extraData() method. | |
virtual void | removeExtraData (const void *key) |
Removes the extra data associated with an item via key . | |
void | setMetaInfo (const KFileMetaInfo &info) |
Sets the metainfo of this item to info . | |
const KFileMetaInfo & | metaInfo (bool autoget=true, int what=KFileMetaInfo::Fastest) const |
Returns the metainfo of this item. | |
void | assign (const KFileItem &item) |
Somewhat like an assignment operator, but more explicit. | |
Protected Member Functions | |
void | init (bool _determineMimeTypeOnDemand) |
Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called again later. | |
QString | parsePermissions (mode_t perm) const |
Parses the given permission set and provides it for access(). | |
virtual void | virtual_hook (int id, void *data) |
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 40 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 47 of file kfileitem.cpp. References KURL::addPath(), QValueList::begin(), KIO::decodeFileName(), QValueList::end(), init(), QString::isEmpty(), KMimeType::mimeType(), KGlobal::staticQString(), and KIO::UDSEntry. |
|
Creates an item representing a file, from all the necessary info for it.
Definition at line 113 of file kfileitem.cpp. References KIO::decodeFileName(), and init(). |
|
Creates an item representing a file, for which the mimetype is already known.
Definition at line 130 of file kfileitem.cpp. References KIO::decodeFileName(), 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 146 of file kfileitem.cpp. References assign(). |
|
Destructs the KFileItem. Extra data set via setExtraData() is not deleted. Definition at line 152 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 214 of file kfileitem.cpp. References init(), and KIO::UDSEntry. Referenced by KDirListerCache::FilesChanged(). |
|
Re-reads mimetype information. This is called when the mimetype database changes. Definition at line 234 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(), KFilePropsPlugin::KFilePropsPlugin(), KPropertiesDialog::KPropertiesDialog(), 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 240 of file kfileitem.cpp. References KIO::decodeFileName(). Referenced by KDirListerCache::FileRenamed(). |
|
Returns the permissions of the file (stat.st_mode containing only permissions).
Definition at line 122 of file kfileitem.h. Referenced by KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(). |
|
Returns the access permissions for the file as a string.
Definition at line 717 of file kfileitem.cpp. References QString::isNull(), and parsePermissions(). Referenced by KFileListViewItem::init(). |
|
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
Definition at line 132 of file kfileitem.h. Referenced by acceptsDrops(), init(), KPropsDlgPlugin::isDesktopFile(), and KFilePropsPlugin::KFilePropsPlugin(). |
|
Returns the owner of the file.
Definition at line 334 of file kfileitem.cpp. References QFile::encodeName(), QString::fromLocal8Bit(), QString::isEmpty(), KURL::path(), and user(). Referenced by getToolTipText(), KFileListViewItem::init(), KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(), and user(). |
|
Returns the group of the file.
Definition at line 349 of file kfileitem.cpp. References QFile::encodeName(), QString::fromLocal8Bit(), group(), QString::isEmpty(), KURL::path(), and QString::sprintf(). Referenced by getToolTipText(), group(), KFileListViewItem::init(), and KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(). |
|
Returns true if this item represents a link in the UNIX sense of a link.
Definition at line 148 of file kfileitem.h. Referenced by KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin(), KFilePropsPlugin::KFilePropsPlugin(), and parsePermissions(). |
|
Returns true if this item represents a directory.
Definition at line 494 of file kfileitem.cpp. References QString::isEmpty(). Referenced by KFileViewSignaler::activate(), KDirListerCache::FilesRemoved(), KCombiView::insertItem(), 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 158 of file kfileitem.h. References isDir(). Referenced by KFileView::updateNumbers(). |
|
Definition at line 473 of file kfileitem.cpp. References QFile::encodeName(), and KURL::path(). Referenced by overlays(). |
|
Returns the link destination if isLink() == true.
Definition at line 247 of file kfileitem.cpp. References QValueList::begin(), QFile::decodeName(), QFile::encodeName(), QValueList::end(), and KURL::path(). Referenced by getStatusBarInfo(), KFilePropsPlugin::KFilePropsPlugin(), and run(). |
|
Returns the size of the file, if known.
Definition at line 268 of file kfileitem.cpp. References QValueList::begin(), QFile::encodeName(), QValueList::end(), and KURL::path(). Referenced by cmp(), getStatusBarInfo(), getToolTipText(), KFileListViewItem::init(), KFilePropsPlugin::KFilePropsPlugin(), and KFileIconView::setSorting(). |
|
Definition at line 290 of file kfileitem.cpp. References QValueList::begin(), QFile::encodeName(), QValueList::end(), and KURL::path(). Referenced by cmp(), KFilePropsPlugin::KFilePropsPlugin(), KFileIconView::setSorting(), and timeString(). |
|
Definition at line 759 of file kfileitem.cpp. References KLocale::formatDateTime(), KGlobal::locale(), QDateTime::setTime_t(), and time(). Referenced by getToolTipText(), and KFileListViewItem::init(). |
|
Returns true if the file is a local file.
Definition at line 195 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 201 of file kfileitem.h. Referenced by getStatusBarInfo(), KFileListViewItem::init(), KFileIconView::insertItem(), KDirLister::matchesFilter(), and KFileIconView::setSorting(). |
|
Definition at line 209 of file kfileitem.h. References QString::isNull(), and QString::lower(). Referenced by KFileDialog::multiSelectionChanged(), KDirOperator::prepareCompletionObjects(), and KFileView::setCurrentItem(). |
|
Returns the mimetype of the file item. If determineMimeTypeOnDemand was used, this will determine the mimetype first. Equivalent to determineMimeType()->name() Definition at line 368 of file kfileitem.cpp. References determineMimeType(). Referenced by acceptsDrops(), KPropsDlgPlugin::isDesktopFile(), KDirLister::matchesMimeFilter(), and metaInfo(). |
|
Returns the mimetype of the file item. If determineMimeTypeOnDemand was used, this will determine the mimetype first. Definition at line 374 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 235 of file kfileitem.h. |
|
Returns the descriptive comment for this mime type, or the mime type itself if none is present.
Definition at line 394 of file kfileitem.cpp. References determineMimeType(), and QString::isEmpty(). Referenced by KFilePropsPlugin::KFilePropsPlugin(). |
|
Returns the full path name to the icon that represents this mime type.
Definition at line 404 of file kfileitem.cpp. References determineMimeType(). |
|
Returns a pixmap representing the file.
Definition at line 436 of file kfileitem.cpp. References KURL::fileName(), KMimeType::findByURL(), KServiceType::icon(), QString::isEmpty(), QPixmap::isNull(), QString::left(), QString::length(), KMimeType::mimeType(), overlays(), KURL::path(), QString::right(), and KGlobal::staticQString(). Referenced by KFileListViewItem::init(), KFileIconView::insertItem(), and KFileDetailView::updateView(). |
|
Returns the overlays (bitfield of KIcon::*Overlay flags) that are used for this item's pixmap.
Definition at line 409 of file kfileitem.cpp. References KURL::fileName(), KIcon::HiddenOverlay, KFileShare::isDirectoryShared(), isReadable(), KIcon::LinkOverlay, KIcon::LockOverlay, KURL::path(), QString::right(), 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 529 of file kfileitem.cpp. References QString::arg(), determineMimeType(), QString::isEmpty(), linkDest(), size(), and text(). |
|
Definition at line 568 of file kfileitem.cpp. References QString::arg(), KIO::convertSize(), determineMimeType(), KStdAccel::end(), QStyleSheet::escape(), group(), QString::isEmpty(), KFileMetaInfo::isEmpty(), KFileMetaInfoItem::isValid(), KFileMetaInfo::isValid(), KFileMetaInfo::item(), QString::left(), QString::length(), metaInfo(), parsePermissions(), KFileMetaInfo::preferredKeys(), size(), KFileMetaInfoItem::string(), timeString(), KFileMetaInfoItem::translatedKey(), 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 504 of file kfileitem.cpp. References QFile::encodeName(), 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 636 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 298 of file kfileitem.h. References KIO::UDSEntry. |
|
Somewhat like a comparison operator, but more explicit.
Definition at line 647 of file kfileitem.cpp. References m_bIsLocalURL, m_bLink, m_fileMode, m_group, m_permissions, m_strName, m_user, size(), and 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
Definition at line 688 of file kfileitem.cpp. References KStdAccel::key(). Referenced by KFileIconView::insertItem(), and KFileDetailView::insertItem(). |
|
Definition at line 696 of file kfileitem.cpp. References QMapConstIterator::data(), and KStdAccel::key(). Referenced by KFileDetailView::ensureItemVisible(), KFileTreeView::findItem(), KFileTreeBranch::findTVIByURL(), KFileDetailView::isSelected(), KFileDetailView::removeItem(), KFileDetailView::setCurrentItem(), and KFileDetailView::setSelected(). |
|
The non-const version of the previous
Definition at line 704 of file kfileitem.cpp. References QMapIterator::data(), and KStdAccel::key(). |
|
Removes the extra data associated with an item via
Definition at line 712 of file kfileitem.cpp. References KStdAccel::key(). |
|
Sets the metainfo of this item to
Definition at line 766 of file kfileitem.cpp. Referenced by KFileMetaPropsPlugin::KFileMetaPropsPlugin(). |
|
Returns the metainfo of this item.
If Definition at line 771 of file kfileitem.cpp. References KURL::isLocalFile(), KFileMetaInfo::isValid(), mimetype(), and KURL::path(). 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 660 of file kfileitem.cpp. References determineMimeType(), m_access, m_bIsLocalURL, m_bLink, m_bMimeTypeKnown, m_entry, m_fileMode, m_group, m_guessedMimeType, m_metaInfo, m_permissions, m_pMimeType, m_size, m_strLowerCaseName, m_strName, m_strText, m_time, m_url, and m_user. Referenced by KFileItem(). |
|
Computes the text, mode, and mimetype from the UDSEntry Called by constructor, but can be called again later.
Definition at line 156 of file kfileitem.cpp. References KMimeType::defaultMimeType(), QFile::encodeName(), KMimeType::findByURL(), 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 725 of file kfileitem.cpp. References QString::fromLatin1(), isDir(), and isLink(). Referenced by getToolTipText(), and permissionsString(). |
The documentation for this class was generated from the following files: