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 / kabc / picture.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.0 KB  |  129 lines

  1. /*
  2.     This file is part of libkabc.
  3.     Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef KABC_PICTURE_H
  22. #define KABC_PICTURE_H
  23.  
  24. #include <qimage.h>
  25.  
  26. #include <kdelibs_export.h>
  27.  
  28. namespace KABC {
  29.  
  30. class KABC_EXPORT Picture
  31. {
  32.   friend KABC_EXPORT QDataStream &operator<<( QDataStream &, const Picture & );
  33.   friend KABC_EXPORT QDataStream &operator>>( QDataStream &, Picture & );
  34.  
  35. public:
  36.  
  37.   /**
  38.    * Consturctor. Creates an empty object.
  39.    */
  40.   Picture();
  41.  
  42.   /**
  43.    * Consturctor.
  44.    *
  45.    * @param url  A URL that describes the position of the picture file.
  46.    */
  47.   Picture( const QString &url );
  48.  
  49.   /**
  50.    * Consturctor.
  51.    *
  52.    * @param data  The raw data of the picture.
  53.    */
  54.   Picture( const QImage &data );
  55.  
  56.   /**
  57.    * Destructor.
  58.    */
  59.   ~Picture();
  60.  
  61.  
  62.   bool operator==( const Picture & ) const;
  63.   bool operator!=( const Picture & ) const;
  64.  
  65.   /**
  66.    * Sets a URL for the location of the picture file. When using this
  67.    * function, isIntern() will return 'false' until you use
  68.    * setData().
  69.    *
  70.    * @param url  The location URL of the picture file.
  71.    */
  72.   void setUrl( const QString &url );
  73.  
  74.   /**
  75.    * Sets the raw data of the picture. When using this function,
  76.    * isIntern() will return 'true' until you use setUrl().
  77.    *
  78.    * @param data  The raw data of the picture.
  79.    */
  80.   void setData( const QImage &data );
  81.  
  82.   /**
  83.    * Sets the type of the picture.
  84.    */
  85.   void setType( const QString &type );
  86.  
  87.   /**
  88.    * Returns whether the picture is described by a URL (extern) or
  89.    * by the raw data (intern).
  90.    * When this method returns 'true' you can use data() to
  91.    * get the raw data. Otherwise you can request the URL of this
  92.    * picture by url() and load the raw data from that location.
  93.    */
  94.   bool isIntern() const;
  95.  
  96.   /**
  97.    * Returns the location URL of this picture.
  98.    */
  99.   QString url() const;
  100.  
  101.   /**
  102.    * Returns the raw data of this picture.
  103.    */
  104.   QImage data() const;
  105.  
  106.   /**
  107.    * Returns the type of this picture.
  108.    */
  109.   QString type() const;
  110.  
  111.   /**
  112.    * Returns string representation of the picture.
  113.    */
  114.   QString asString() const;
  115.  
  116. private:
  117.   QString mUrl;
  118.   QString mType;
  119.   QImage mData;
  120.  
  121.   int mIntern;
  122. };
  123.  
  124. KABC_EXPORT QDataStream &operator<<( QDataStream &, const Picture & );
  125. KABC_EXPORT QDataStream &operator>>( QDataStream &, Picture & );
  126.  
  127. }
  128. #endif
  129.