kfileitem.h
/* This file is part of the KDE project
Copyright (C) 1999 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __kfileitem_h__
#define __kfileitem_h__
#include <qstringlist.h>
#include <sys/stat.h>
#include <qptrlist.h>
#include <kio/global.h>
#include <kurl.h>
#include <kacl.h>
#include <kmimetype.h>
#include <kfilemetainfo.h>
#define KFILEITEM_HAS_ISWRITABLE // only used in libkonq/konq_iconviewwidget.cc, will be removed for 3.4
class KIO_EXPORT KFileItem
{
public:
enum { Unknown = (mode_t) - 1 };
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 { return m_url; }
void setURL( const KURL &url );
void setName( const QString &name );
mode_t permissions() const { return m_permissions; }
QString permissionsString() const;
bool hasExtendedACL() const;
KACL ACL() const;
KACL defaultACL() const;
mode_t mode() const { return m_fileMode; }
QString user() const;
QString group() const;
bool isLink() const { return m_bLink; }
bool isDir() const;
bool isFile() const { return !isDir(); }
bool isReadable() const;
bool isWritable() const;
bool isHidden() const;
QString linkDest() const;
QString localPath() const;
//FIXME KDE4 deprecate this in favor of size(bool &hasSize)
KIO::filesize_t size() const;
KIO::filesize_t size(bool &hasSize) const;
//FIXME KDE4 deprecate this in favor of time(unsigned int which, bool &hasSize)
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 { return m_bIsLocalURL; }
const QString& text() const { return m_strText; }
const QString& name( bool lowerCase = false ) const {
if ( !lowerCase )
return m_strName;
else
if ( m_strLowerCaseName.isNull() )
m_strLowerCaseName = m_strName.lower();
return m_strLowerCaseName;
}
QString mimetype() const;
KMimeType::Ptr determineMimeType();
KMimeType::Ptr mimeTypePtr() const { return m_pMimeType; }
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 { return m_entry; }
bool isMarked() const { return m_bMarked; }
void mark() { m_bMarked = true; }
void unmark() { m_bMarked = false; }
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:
void init( bool _determineMimeTypeOnDemand );
void readUDSEntry( bool _urlIsDirectory );
QString parsePermissions( mode_t perm ) const;
private:
KIO::UDSEntry m_entry;
KURL m_url;
QString m_strName;
QString m_strText;
mutable QString m_user, m_group;
mutable QString m_strLowerCaseName;
KMimeType::Ptr m_pMimeType;
mode_t m_fileMode;
mode_t m_permissions;
bool m_bMarked:1;
bool m_bLink:1;
bool m_bIsLocalURL:1;
bool m_bMimeTypeKnown:1;
// Auto: check leading dot.
enum { Auto, Hidden, Shown } m_hidden:3;
// For special case like link to dirs over FTP
QString m_guessedMimeType;
mutable QString m_access;
QMap<const void*, void*> m_extra;
mutable KFileMetaInfo m_metaInfo;
enum { Modification = 0, Access = 1, Creation = 2, NumFlags = 3 };
mutable time_t m_time[3];
mutable KIO::filesize_t m_size;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KFileItemPrivate;
KFileItemPrivate * d;
KIO_EXPORT friend QDataStream & operator<< ( QDataStream & s, const KFileItem & a );
KIO_EXPORT friend QDataStream & operator>> ( QDataStream & s, KFileItem & a );
};
typedef QPtrList<KFileItem> KFileItemList;
typedef QPtrListIterator<KFileItem> KFileItemListIterator;
KIO_EXPORT QDataStream & operator<< ( QDataStream & s, const KFileItem & a );
KIO_EXPORT QDataStream & operator>> ( QDataStream & s, KFileItem & a );
#endif
KFileItem::url
const KURL & url() const
Returns the url of the file.
Definition: kfileitem.h:113
KFileMetaInfo::Fastest
do the fastest possible read and omit all items that might need a significantly longer time than the ...
Definition: kfilemetainfo.h:940
KFileItem::entry
const KIO::UDSEntry & entry() const
Returns the UDS entry.
Definition: kfileitem.h:399
KIO::UDS_MODIFICATION_TIME
The last time the file was modified.
Definition: global.h:355
KFileItem::text
const QString & text() const
Returns the text of the file item.
Definition: kfileitem.h:289
KFileItem::permissions
mode_t permissions() const
Returns the permissions of the file (stat.st_mode containing only permissions).
Definition: kfileitem.h:134
KFileItem::mark
void mark()
Marks the item.
Definition: kfileitem.h:410
KFileItem::isLocalFile
bool isLocalFile() const
Returns true if the file is a local file.
Definition: kfileitem.h:282
KFileMetaInfo
Meta Information about a file.
Definition: kfilemetainfo.h:926
KFileItem::isFile
bool isFile() const
Returns true if this item represents a file (and not a a directory)
Definition: kfileitem.h:198
KIO::filesize_t
Q_ULLONG filesize_t
64-bit file size
Definition: global.h:39
KFileItem::isLink
bool isLink() const
Returns true if this item represents a link in the UNIX sense of a link.
Definition: kfileitem.h:186
KFileItem::mimeTypePtr
KMimeType::Ptr mimeTypePtr() const
Returns the currently known mimetype of the file item.
Definition: kfileitem.h:328
KIO::UDSEntry
QValueList< UDSAtom > UDSEntry
An entry is the list of atoms containing all the informations for a file or URL.
Definition: global.h:504
KFileItem::isMarked
bool isMarked() const
Used when updating a directory.
Definition: kfileitem.h:405
KACL
The KCAL class encapsulates a POSIX Access Control List.
Definition: kacl.h:42
KFileItem::unmark
void unmark()
Unmarks the item.
Definition: kfileitem.h:415
KFileItem::mode
mode_t mode() const
Returns the file type (stat.st_mode containing only S_IFDIR, S_IFLNK, ...).
Definition: kfileitem.h:167
KFileItem::name
const QString & name(bool lowerCase=false) const
Return the name of the file item (without a path).
Definition: kfileitem.h:298
KFileItem
A KFileItem is a generic class to handle a file, local or remote.
Definition: kfileitem.h:41

KDE Home | KDE Accessibility Home | Description of Access Keys