src/hbcore/image/hbframebackground.cpp
changeset 5 627c4a0fd0e7
parent 0 16d8024aca5e
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    26 #include "hbframebackground_p.h"
    26 #include "hbframebackground_p.h"
    27 
    27 
    28 #include <QVariant>
    28 #include <QVariant>
    29 
    29 
    30 /*!
    30 /*!
    31 	@stable
    31     @stable
    32     @hbcore
    32     @hbcore
    33     \class HbFrameBackground
    33     \class HbFrameBackground
    34     \brief HbFrameBackground stores the frame data.
    34     \brief HbFrameBackground stores the frame data.
    35 
    35 
    36     This class is a data container for frame related data. It stores data that defines the 
    36     This class is a data container for frame related data. It stores data that defines the
    37     frame background into single object that can be stored into QVariant.
    37     frame background into single object that can be stored into QVariant.
    38 */
    38 */
    39 
    39 
    40 // Must be initialized dynamically because QIcon cannot be constructed 
    40 // Must be initialized dynamically because QIcon cannot be constructed
    41 // when static variables are constructed.
    41 // when static variables are constructed.
    42 static HbFrameBackgroundPrivate *shared_null = 0;
    42 static HbFrameBackgroundPrivate *shared_null = 0;
    43 
    43 
    44 static const int frameBackgroundMetaType = qRegisterMetaType<HbFrameBackground>();
    44 static const int frameBackgroundMetaType = qRegisterMetaType<HbFrameBackground>();
    45 
    45 
    60 /*! Default constructor.
    60 /*! Default constructor.
    61 */
    61 */
    62 HbFrameBackground::HbFrameBackground()
    62 HbFrameBackground::HbFrameBackground()
    63 {
    63 {
    64     // Construct shared_null if not done yet.
    64     // Construct shared_null if not done yet.
    65     if ( !shared_null ) {
    65     if (!shared_null) {
    66         shared_null = new HbFrameBackgroundPrivate;
    66         shared_null = new HbFrameBackgroundPrivate;
    67     }
    67     }
    68     d = shared_null;
    68     d = shared_null;
    69 }
    69 }
    70 
    70 
    76 }
    76 }
    77 
    77 
    78 /*!
    78 /*!
    79 * Copy constructs a new frame background using the \a other frame background.
    79 * Copy constructs a new frame background using the \a other frame background.
    80 */
    80 */
    81 HbFrameBackground::HbFrameBackground( const HbFrameBackground &other ) :
    81 HbFrameBackground::HbFrameBackground(const HbFrameBackground &other) :
    82     d(other.d)
    82     d(other.d)
    83 {
    83 {
    84 }
    84 }
    85 
    85 
    86 /*!
    86 /*!
    90 {
    90 {
    91 }
    91 }
    92 
    92 
    93 /*!
    93 /*!
    94 * Assigns the \a other frame background to this frame background and returns a reference to
    94 * Assigns the \a other frame background to this frame background and returns a reference to
    95 * this frame background. Copy-on-write semantics is used, so this only does a shallow copy. 
    95 * this frame background. Copy-on-write semantics is used, so this only does a shallow copy.
    96 */
    96 */
    97 HbFrameBackground &HbFrameBackground::operator=( const HbFrameBackground &other )
    97 HbFrameBackground &HbFrameBackground::operator=(const HbFrameBackground &other)
    98 {
    98 {
    99     if (&other != this) {
    99     if (&other != this) {
   100         d = other.d;
   100         d = other.d;
   101     }
   101     }
   102     return *this;
   102     return *this;
   103 }
   103 }
   104 
   104 
   105 /*!
   105 /*!
   106 * Equality operator. 
   106 * Equality operator.
   107 */
   107 */
   108 bool HbFrameBackground::operator==( const HbFrameBackground &other ) const
   108 bool HbFrameBackground::operator==(const HbFrameBackground &other) const
   109 {
   109 {
   110     return !( *this != other );
   110     return !(*this != other);
   111 }
   111 }
   112 
   112 
   113 /*!
   113 /*!
   114 * Inequality operator. 
   114 * Inequality operator.
   115 */
   115 */
   116 bool HbFrameBackground::operator!=( const HbFrameBackground &other ) const
   116 bool HbFrameBackground::operator!=(const HbFrameBackground &other) const
   117 {
   117 {
   118     if (d->frameGraphicsName != other.d->frameGraphicsName
   118     if (d->frameGraphicsName != other.d->frameGraphicsName
   119         || d->frameGraphicsName.isNull() != other.d->frameGraphicsName.isNull()) {
   119             || d->frameGraphicsName.isNull() != other.d->frameGraphicsName.isNull()) {
   120         return true;
   120         return true;
   121     }
   121     }
   122 
   122 
   123     if (d->type != other.d->type) {
   123     if (d->type != other.d->type) {
   124         return true;
   124         return true;
   152 void HbFrameBackground::setFrameGraphicsName(const QString &frameGraphicsName)
   152 void HbFrameBackground::setFrameGraphicsName(const QString &frameGraphicsName)
   153 {
   153 {
   154     // Remove possible file extension
   154     // Remove possible file extension
   155     QString nameWithoutExt = frameGraphicsName;
   155     QString nameWithoutExt = frameGraphicsName;
   156     int index = nameWithoutExt.lastIndexOf(QChar('.'));
   156     int index = nameWithoutExt.lastIndexOf(QChar('.'));
   157     if (index>0) {
   157     if (index > 0) {
   158         nameWithoutExt.resize(index);
   158         nameWithoutExt.resize(index);
   159     }
   159     }
   160 
   160 
   161     if (d->frameGraphicsName != nameWithoutExt
   161     if (d->frameGraphicsName != nameWithoutExt
   162         || d->frameGraphicsName.isNull() != nameWithoutExt.isNull()) {
   162             || d->frameGraphicsName.isNull() != nameWithoutExt.isNull()) {
   163         d.detach();
   163         d.detach();
   164         d->frameGraphicsName = nameWithoutExt;
   164         d->frameGraphicsName = nameWithoutExt;
   165     }
   165     }
   166 }
   166 }
   167 
   167