home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bdataitem.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  6.0 KB  |  226 lines

  1. /* 
  2.  *
  3.  * $Id: k3bdataitem.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BDATAITEM_H
  18. #define K3BDATAITEM_H
  19.  
  20.  
  21. class K3bDirItem;
  22. class K3bDataDoc;
  23.  
  24. #include <qstring.h>
  25.  
  26. #include <kio/global.h>
  27.  
  28. #include <k3bmsf.h>
  29. #include "k3b_export.h"
  30.  
  31.  
  32. /**
  33.   *@author Sebastian Trueg
  34.   */
  35. class LIBK3B_EXPORT K3bDataItem
  36. {
  37.  public: 
  38.   K3bDataItem( K3bDataDoc* doc, K3bDataItem* parent = 0, int flags = 0 );
  39.  
  40.   /**
  41.    * Default copy constructor.
  42.    *
  43.    * The result is an exact copy except that no parent dir it set and, thus, also no doc.
  44.    */
  45.   K3bDataItem( const K3bDataItem& );
  46.  
  47.   virtual ~K3bDataItem();
  48.  
  49.   /**
  50.    * Return an exact copy of this data item.
  51.    *
  52.    * The result is an exact copy except that no parent dir it set and, thus, also no doc.
  53.    *
  54.    * Implementations should use the default constructor.
  55.    */
  56.   virtual K3bDataItem* copy() const = 0;
  57.     
  58.   K3bDirItem* parent() { return m_parentDir; }
  59.   K3bDirItem* getParent() const { return m_parentDir; }
  60.  
  61.   /**
  62.    * Remove this item from it's parent and return a pointer to it.
  63.    */
  64.   K3bDataItem* take();
  65.     
  66.   K3bDataDoc* doc() const { return m_doc; }
  67.   virtual const QString& k3bName() const;
  68.   virtual void setK3bName( const QString& );
  69.  
  70.   /** 
  71.    * returns the path as defined by the k3b-hierachy, NOT starting with a slash
  72.    * (since this is used for graft-points!) 
  73.    * directories have a trailing "/"
  74.    */
  75.   virtual QString k3bPath() const;
  76.  
  77.   /**
  78.    * Returns the name of the item as used on the CD or DVD image.
  79.    *
  80.    * This is only valid after a call to @p K3bDataDoc::prepareFilenames()
  81.    */
  82.   const QString& writtenName() const { return m_writtenName; }
  83.  
  84.   /**
  85.    * \return the pure name used in the Iso9660 tree.
  86.    *
  87.    * This is only valid after a call to @p K3bDataDoc::prepareFilenames()
  88.    */
  89.   const QString& iso9660Name() const { return m_rawIsoName; }
  90.  
  91.   /**
  92.    * Returns the path of the item as written to the CD or DVD image.
  93.    *
  94.    * This is suited to be used for mkisofs graftpoints.
  95.    *
  96.    * This is only valid after a call to @p K3bDataDoc::prepareFilenames()
  97.    */
  98.   virtual QString writtenPath() const;
  99.  
  100.   virtual QString iso9660Path() const;
  101.  
  102.   /**
  103.    * Used to set the written name by @p K3bDataDoc::prepareFilenames()
  104.    */
  105.   void setWrittenName( const QString& s ) { m_writtenName = s; }
  106.  
  107.   /**
  108.    * Used to set the pure Iso9660 name by @p K3bDataDoc::prepareFilenames()
  109.    */
  110.   void setIso9660Name( const QString& s ) { m_rawIsoName = s; }
  111.  
  112.   virtual K3bDataItem* nextSibling() const;
  113.     
  114.   /** returns the path to the file on the local filesystem */
  115.   virtual QString localPath() const { return QString::null; }
  116.  
  117.   /**
  118.    * The size of the item
  119.    */
  120.   KIO::filesize_t size() const;
  121.  
  122.   /**
  123.    * \return The number of blocks (2048 bytes) occupied by this item.
  124.    *         This value equals to ceil(size()/2048)
  125.    */
  126.   K3b::Msf blocks() const;
  127.  
  128.   /** 
  129.    * \returne the dir of the item (or the item itself if it is a dir)
  130.    */
  131.   virtual K3bDirItem* getDirItem() const { return getParent(); }
  132.  
  133.   virtual void reparent( K3bDirItem* );
  134.  
  135.   // FIXME: use all these flags and make the isXXX methods
  136.   // non-virtual. Then move the parent()->addDataItem call
  137.   // to the K3bDataItem constructor
  138.   enum ItemFlags {
  139.     DIR = 0x1,
  140.     FILE = 0x2,
  141.     SPECIALFILE = 0x4,
  142.     SYMLINK = 0x8,
  143.     OLD_SESSION = 0x10,
  144.     BOOT_IMAGE = 0x11
  145.   };
  146.  
  147.   int flags() const;
  148.  
  149.   virtual bool isDir() const { return false; }
  150.   virtual bool isFile() const { return false; }
  151.   virtual bool isSpecialFile() const { return false; }
  152.   virtual bool isSymLink() const { return false; }    
  153.   virtual bool isFromOldSession() const { return false; }
  154.   bool isBootItem() const;
  155.  
  156.   bool hideOnRockRidge() const;
  157.   bool hideOnJoliet() const;
  158.  
  159.   virtual void setHideOnRockRidge( bool b );
  160.   virtual void setHideOnJoliet( bool b );
  161.  
  162.   virtual long sortWeight() const { return m_sortWeight; }
  163.   virtual void setSortWeight( long w ) { m_sortWeight = w; }
  164.  
  165.   virtual int depth() const;
  166.  
  167.   virtual bool isValid() const { return true; }
  168.  
  169.   // these are all needed for special fileitems like
  170.   // imported sessions or the movix filesystem
  171.   virtual bool isRemoveable() const { return m_bRemoveable; }
  172.   virtual bool isMoveable() const { return m_bMovable; }
  173.   virtual bool isRenameable() const { return m_bRenameable; }
  174.   virtual bool isHideable() const { return m_bHideable; }
  175.   virtual bool writeToCd() const { return m_bWriteToCd; }
  176.   virtual const QString& extraInfo() const { return m_extraInfo; }
  177.  
  178.   void setRenameable( bool b ) { m_bRenameable = b; }
  179.   void setMoveable( bool b ) { m_bMovable = b; }
  180.   void setRemoveable( bool b ) { m_bRemoveable = b; }
  181.   void setHideable( bool b ) { m_bHideable = b; }
  182.   void setWriteToCd( bool b ) { m_bWriteToCd = b; }
  183.   void setExtraInfo( const QString& i ) { m_extraInfo = i; }
  184.  
  185.  protected:
  186.   virtual KIO::filesize_t itemSize( bool followSymlinks ) const = 0;
  187.  
  188.   /**
  189.    * \param followSymlinks If true symlinks will be followed and their
  190.    *                       size equals the size of the file they are
  191.    *                       pointing to.
  192.    *
  193.    * \return The number of blocks (2048 bytes) occupied by this item.
  194.    */
  195.   virtual K3b::Msf itemBlocks( bool followSymlinks ) const;
  196.  
  197.   QString m_k3bName;
  198.  
  199.   void setFlags( int flags );
  200.  
  201.  private:
  202.   class Private;
  203.   Private* d;
  204.  
  205.   QString m_writtenName;
  206.   QString m_rawIsoName;
  207.  
  208.   K3bDataDoc* m_doc;
  209.   K3bDirItem* m_parentDir;
  210.  
  211.   bool m_bHideOnRockRidge;
  212.   bool m_bHideOnJoliet;
  213.   bool m_bRemoveable;
  214.   bool m_bRenameable;
  215.   bool m_bMovable;
  216.   bool m_bHideable;
  217.   bool m_bWriteToCd;
  218.   QString m_extraInfo;
  219.  
  220.   long m_sortWeight;
  221.  
  222.   friend class K3bDirItem;
  223. };
  224.  
  225. #endif
  226.