# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | 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 // $Id: kfileitem.h,v 1.83 2002/06/19 17:46:01 domi Exp $
    00020
    00021 #ifndef __kfileitem_h__
    00022 #define __kfileitem_h__
    00023
    00024 #include <qstringlist.h>
    00025 #include <sys/stat.h>
    00026
    00027 #include <qptrlist.h>
    00028 #include <kio/global.h>
    00029 #include <kurl.h>
    00030 #include <kmimetype.h>
    00031 #include <kio/global.h>
    00032 #include <kfilemetainfo.h>
    00033
    00040 class 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
    00111   const KURL & url() const { return m_url; }
    00112
    00117   void setURL( const KURL &url );
    00118
    00122   mode_t permissions() const { return m_permissions; }
    00123
    00127   QString permissionsString() const;
    00128
    00132   mode_t mode() const { return m_fileMode; }
    00133
    00137   QString user() const;
    00138
    00142   QString group() const;
    00143
    00148   bool isLink() const { return m_bLink; }
    00149
    00153   bool isDir() const;
    00154
    00158   bool isFile() const { return !isDir(); }
    00159
    00165   bool isReadable() const;
    00166
    00170   QString linkDest() const;
    00171
    00175   KIO::filesize_t size() const;
    00176
    00182   time_t time( unsigned int which ) const;
    00183
    00190   QString timeString( unsigned int which = KIO::UDS_MODIFICATION_TIME ) const;
    00191
    00195   bool isLocalFile() const { return m_bIsLocalURL; }
    00196
    00201   const QString& text() const { return m_strText; }
    00202
    00209   const QString& name( bool lowerCase = false ) const {
    00210       if ( !lowerCase )
    00211           return m_strName;
    00212       else
    00213           if ( m_strLowerCaseName.isNull() )
    00214               m_strLowerCaseName = m_strName.lower();
    00215       return m_strLowerCaseName;
    00216   }
    00217
    00223   QString mimetype() const;
    00224
    00229   KMimeType::Ptr determineMimeType();
    00230
    00235   KMimeType::Ptr mimeTypePtr() const { return m_pMimeType; }
    00236
    00237   bool isMimeTypeKnown() const;
    00242   QString mimeComment();
    00243
    00248   QString iconName();
    00249
    00258   QPixmap pixmap( int _size, int _state=0 ) const;
    00259
    00264   int overlays() const;
    00265
    00270   QString getStatusBarInfo();
    00271
    00279   QString getToolTipText(int maxcount = 6);
    00280
    00286   bool acceptsDrops( );
    00287
    00292   void run();
    00293
    00298   const KIO::UDSEntry & entry() const { return m_entry; }
    00299
    00300   // Used when updating a directory - marked == seen when refreshing
    00301   bool isMarked() const { return m_bMarked; }
    00302   void mark() { m_bMarked = true; }
    00303   void unmark() { m_bMarked = false; }
    00304
    00308   bool cmp( const KFileItem & item );
    00309
    00341   virtual void setExtraData( const void *key, void *value );
    00342
    00350   virtual const void * extraData( const void *key ) const;
    00351
    00355   virtual void * extraData( const void *key );
    00356
    00360   virtual void removeExtraData( const void *key );
    00361
    00365   void setMetaInfo( const KFileMetaInfo & info );
    00366
    00371   const KFileMetaInfo & metaInfo(bool autoget = true,
    00372                                  int what = KFileMetaInfo::Fastest) const;
    00373
    00381   void assign( const KFileItem & item );
    00382
    00383
    00385
    00386 protected:
    00391   void init( bool _determineMimeTypeOnDemand );
    00392
    00396   QString parsePermissions( mode_t perm ) const;
    00397
    00398 private:
    00402   KIO::UDSEntry m_entry;
    00406   KURL m_url;
    00407
    00411   QString m_strName;
    00412
    00417   QString m_strText;
    00418
    00422   mutable QString m_user, m_group;
    00423
    00427   mutable QString m_strLowerCaseName;
    00428
    00432   KMimeType::Ptr m_pMimeType;
    00433
    00437   mode_t m_fileMode;
    00441   mode_t m_permissions;
    00442
    00446   bool m_bMarked:1;
    00450   bool m_bLink:1;
    00454   bool m_bIsLocalURL:1;
    00455
    00456   bool m_bMimeTypeKnown:1;
    00457
    00458    // For special case like link to dirs over FTP
    00459   QString m_guessedMimeType;
    00460   mutable QString m_access;
    00461   QMap<const void*, void*> m_extra;
    00462   mutable KFileMetaInfo m_metaInfo;
    00463
    00464   enum { Modification = 0, Access = 1, Creation = 2, NumFlags = 3 };
    00465   mutable time_t m_time[3];
    00466   mutable KIO::filesize_t m_size;
    00467
    00468 protected:
    00469   virtual void virtual_hook( int id, void* data );
    00470 private:
    00471   class KFileItemPrivate;
    00472   KFileItemPrivate * d;
    00473 };
    00474
    00478 typedef QPtrList<KFileItem> KFileItemList;
    00479
    00483 typedef QPtrListIterator<KFileItem> KFileItemListIterator;
    00484
    00485 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:13:30 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001