qtmobility/src/messaging/qmessagefolderid_symbian.cpp
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 #include "qmessagefolderid.h"
       
    42 #include "qmessagefolderid_p.h"
       
    43 #include <qhash>
       
    44 
       
    45 QTM_BEGIN_NAMESPACE
       
    46 
       
    47 QMessageFolderId::QMessageFolderId()
       
    48  : d_ptr(0)
       
    49 {
       
    50 }
       
    51 
       
    52 QMessageFolderId::QMessageFolderId(const QMessageFolderId& other)
       
    53  : d_ptr(0)
       
    54 {
       
    55    this->operator=(other);
       
    56 }
       
    57 
       
    58 QMessageFolderId::QMessageFolderId(const QString& id)
       
    59  : d_ptr(new QMessageFolderIdPrivate(this))
       
    60 {
       
    61    d_ptr->_id = id;
       
    62 }
       
    63 
       
    64 QMessageFolderId::~QMessageFolderId()
       
    65 {
       
    66     delete d_ptr;
       
    67 }
       
    68 
       
    69 QMessageFolderId& QMessageFolderId::operator=(const QMessageFolderId& other)
       
    70 {
       
    71     if (&other != this) {
       
    72         if (other.isValid()) {
       
    73             if (!d_ptr) {
       
    74                 d_ptr = new QMessageFolderIdPrivate(this);
       
    75             }
       
    76             d_ptr->_id = other.d_ptr->_id;
       
    77         } else {
       
    78             delete d_ptr;
       
    79             d_ptr = 0;
       
    80         }
       
    81     }
       
    82     
       
    83     return *this;
       
    84 }
       
    85 
       
    86 bool QMessageFolderId::operator==(const QMessageFolderId& other) const
       
    87 {
       
    88     if (isValid()) {
       
    89         if (other.isValid()) {
       
    90             return (d_ptr->_id == other.d_ptr->_id);
       
    91         }
       
    92         return false;
       
    93     } else {
       
    94         return !other.isValid();
       
    95     }
       
    96 }
       
    97 
       
    98 bool QMessageFolderId::operator<(const QMessageFolderId& other) const
       
    99 {
       
   100     QString left("");
       
   101     QString right("");
       
   102     if (d_ptr) {
       
   103         left = d_ptr->_id;
       
   104     }
       
   105     if (other.d_ptr) {
       
   106         right = other.d_ptr->_id;
       
   107     }
       
   108     
       
   109     return (left < right);
       
   110 }
       
   111 
       
   112 QString QMessageFolderId::toString() const
       
   113 {
       
   114     if (!isValid()) {
       
   115         return QString();
       
   116     }
       
   117     
       
   118     return d_ptr->_id;
       
   119 }
       
   120 
       
   121 bool QMessageFolderId::isValid() const
       
   122 {
       
   123     return (d_ptr && !d_ptr->_id.isEmpty());
       
   124 }
       
   125 
       
   126 uint qHash(const QMessageFolderId &id)
       
   127 {
       
   128     return qHash(id.toString());
       
   129 }
       
   130 
       
   131 QTM_END_NAMESPACE