kio Library: kfileitem.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kfileitem.h

    00001 /* This file is part of the KDE project
    00002    Copyright (C) 1999 David Faure <faure@kde.org>
    00003
    00004    This library is free software; you can redistribute it and/or
    00005    modify it under the terms of the GNU Library General Public
    00006    License as published by the Free Software Foundation; either
    00007    version 2 of the License, or (at your option) any later version.
    00008
    00009    This library is distributed in the hope that it will be useful,
    00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012    Library General Public License for more details.
    00013
    00014    You should have received a copy of the GNU Library General Public License
    00015    along with this library; see the file COPYING.LIB.  If not, write to
    00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017    Boston, MA 02111-1307, USA.
    00018 */
    00019
    00020 #ifndef __kfileitem_h__
    00021 #define __kfileitem_h__
    00022
    00023 #include <qstringlist.h>
    00024 #include <sys/stat.h>
    00025
    00026 #include <qptrlist.h>
    00027 #include <kio/global.h>
    00028 #include <kurl.h>
    00029 #include <kmimetype.h>
    00030 #include <kfilemetainfo.h>
    00031
    00032 #define KFILEITEM_HAS_ISWRITABLE // only used in libkonq/konq_iconviewwidget.cc, will be removed for 3.4
    00033
    00040 class KIO_EXPORT KFileItem
    00041 {
    00042 public:
    00043   enum { Unknown = (mode_t) - 1 };
    00044
    00056   KFileItem( const KIO::UDSEntry& _entry, const KURL& _url,
    00057              bool _determineMimeTypeOnDemand = false,
    00058              bool _urlIsDirectory = false );
    00059
    00073   KFileItem( mode_t _mode, mode_t _permissions, const KURL& _url,
    00074              bool _determineMimeTypeOnDemand = false );
    00075
    00082   KFileItem( const KURL &url, const QString &mimeType, mode_t mode );
    00083
    00088   KFileItem( const KFileItem &item );
    00089
    00094   virtual ~KFileItem();
    00095
    00100   void refresh();
    00101
    00106   void refreshMimeType();
    00107
    00112   const KURL & url() const { return m_url; }
    00113
    00119   void setURL( const KURL &url );
    00120
    00127   void setName( const QString &name );
    00128
    00133   mode_t permissions() const { return m_permissions; }
    00134
    00139   QString permissionsString() const;
    00140
    00145   mode_t mode() const { return m_fileMode; }
    00146
    00151   QString user() const;
    00152
    00157   QString group() const;
    00158
    00164   bool isLink() const { return m_bLink; }
    00165
    00170   bool isDir() const;
    00171
    00176   bool isFile() const { return !isDir(); }
    00177
    00184   bool isReadable() const;
    00185
    00193   bool isWritable() const;
    00194
    00199   bool isHidden() const;
    00200
    00205   QString linkDest() const;
    00206
    00213   QString localPath() const;
    00214
    00219   KIO::filesize_t size() const;
    00220
    00227   time_t time( unsigned int which ) const;
    00228
    00236   QString timeString( unsigned int which = KIO::UDS_MODIFICATION_TIME ) const;
    00237
    00242   bool isLocalFile() const { return m_bIsLocalURL; }
    00243
    00249   const QString& text() const { return m_strText; }
    00250
    00258   const QString& name( bool lowerCase = false ) const {
    00259       if ( !lowerCase )
    00260           return m_strName;
    00261       else
    00262           if ( m_strLowerCaseName.isNull() )
    00263               m_strLowerCaseName = m_strName.lower();
    00264       return m_strLowerCaseName;
    00265   }
    00266
    00273   QString mimetype() const;
    00274
    00281   KMimeType::Ptr determineMimeType();
    00282
    00288   KMimeType::Ptr mimeTypePtr() const { return m_pMimeType; }
    00289
    00290   bool isMimeTypeKnown() const;
    00296   QString mimeComment();
    00297
    00303   QString iconName();
    00304
    00313   QPixmap pixmap( int _size, int _state=0 ) const;
    00314
    00321   int overlays() const;
    00322
    00328   QString getStatusBarInfo();
    00329
    00338   QString getToolTipText(int maxcount = 6);
    00339
    00346   bool acceptsDrops( );
    00347
    00352   void run();
    00353
    00359   const KIO::UDSEntry & entry() const { return m_entry; }
    00360
    00365   bool isMarked() const { return m_bMarked; }
    00370   void mark() { m_bMarked = true; }
    00375   void unmark() { m_bMarked = false; }
    00376
    00382   bool cmp( const KFileItem & item );
    00383
    00417   virtual void setExtraData( const void *key, void *value );
    00418
    00426   virtual const void * extraData( const void *key ) const;
    00427
    00435   virtual void * extraData( const void *key );
    00436
    00441   virtual void removeExtraData( const void *key );
    00442
    00447   void setMetaInfo( const KFileMetaInfo & info );
    00448
    00454   const KFileMetaInfo & metaInfo(bool autoget = true,
    00455                                  int what = KFileMetaInfo::Fastest) const;
    00456
    00464   void assign( const KFileItem & item );
    00465
    00483   void setUDSEntry( const KIO::UDSEntry& entry, const KURL& url,
    00484                     bool determineMimeTypeOnDemand = false,
    00485                     bool urlIsDirectory = false );
    00486
    00490   KFileItem& operator=( const KFileItem& );
    00491
    00496   KURL mostLocalURL(bool &local) const;
    00497
    00499
    00500 protected:
    00505   void init( bool _determineMimeTypeOnDemand );
    00506
    00512   void readUDSEntry( bool _urlIsDirectory );
    00513
    00517   QString parsePermissions( mode_t perm ) const;
    00518
    00519 private:
    00523   KIO::UDSEntry m_entry;
    00527   KURL m_url;
    00528
    00532   QString m_strName;
    00533
    00538   QString m_strText;
    00539
    00543   mutable QString m_user, m_group;
    00544
    00548   mutable QString m_strLowerCaseName;
    00549
    00553   KMimeType::Ptr m_pMimeType;
    00554
    00558   mode_t m_fileMode;
    00562   mode_t m_permissions;
    00563
    00567   bool m_bMarked:1;
    00571   bool m_bLink:1;
    00575   bool m_bIsLocalURL:1;
    00576
    00577   bool m_bMimeTypeKnown:1;
    00578
    00579    // For special case like link to dirs over FTP
    00580   QString m_guessedMimeType;
    00581   mutable QString m_access;
    00582   QMap<const void*, void*> m_extra;
    00583   mutable KFileMetaInfo m_metaInfo;
    00584
    00585   enum { Modification = 0, Access = 1, Creation = 2, NumFlags = 3 };
    00586   mutable time_t m_time[3];
    00587   mutable KIO::filesize_t m_size;
    00588
    00589 protected:
    00590   virtual void virtual_hook( int id, void* data );
    00591 private:
    00592   class KFileItemPrivate;
    00593   KFileItemPrivate * d;
    00594   KIO_EXPORT friend QDataStream & operator<< ( QDataStream & s, const KFileItem & a );
    00595   KIO_EXPORT friend QDataStream & operator>> ( QDataStream & s, KFileItem & a );
    00596 };
    00597
    00601 typedef QPtrList<KFileItem> KFileItemList;
    00602
    00606 typedef QPtrListIterator<KFileItem> KFileItemListIterator;
    00607
    00608 KIO_EXPORT QDataStream & operator<< ( QDataStream & s, const KFileItem & a );
    00609 KIO_EXPORT QDataStream & operator>> ( QDataStream & s, KFileItem & a );
    00610
    00611
    00612 #endif

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:23:58 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003