|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 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 "qmessageid.h" |
|
42 #include <qhash.h> |
|
43 #include <messagingutil_p.h> |
|
44 |
|
45 QTM_BEGIN_NAMESPACE |
|
46 |
|
47 class QMessageIdPrivate |
|
48 { |
|
49 public: |
|
50 QString _id; |
|
51 }; |
|
52 |
|
53 QMessageId::QMessageId() |
|
54 : d_ptr(0) |
|
55 { |
|
56 } |
|
57 |
|
58 QMessageId::QMessageId(const QMessageId& other) |
|
59 : d_ptr(0) |
|
60 { |
|
61 this->operator=(other); |
|
62 } |
|
63 |
|
64 QMessageId::QMessageId(const QString& id) |
|
65 { |
|
66 d_ptr = new QMessageIdPrivate; |
|
67 d_ptr->_id = id; |
|
68 } |
|
69 |
|
70 QMessageId::~QMessageId() |
|
71 { |
|
72 delete d_ptr; |
|
73 } |
|
74 |
|
75 QMessageId& QMessageId::operator=(const QMessageId& other) |
|
76 { |
|
77 if (!other.d_ptr) { |
|
78 delete d_ptr; |
|
79 return *this; |
|
80 } |
|
81 |
|
82 if (!d_ptr) |
|
83 d_ptr = new QMessageIdPrivate; |
|
84 |
|
85 d_ptr->_id = other.d_ptr->_id; |
|
86 |
|
87 return *this; |
|
88 } |
|
89 |
|
90 bool QMessageId::operator==(const QMessageId& other) const |
|
91 { |
|
92 if (!other.d_ptr && !d_ptr) |
|
93 return true; |
|
94 |
|
95 if (!other.d_ptr || !d_ptr) |
|
96 return false; |
|
97 |
|
98 return (d_ptr->_id == other.d_ptr->_id); |
|
99 } |
|
100 |
|
101 bool QMessageId::operator<(const QMessageId& other) const |
|
102 { |
|
103 long left = 0; |
|
104 long right = 0; |
|
105 if (d_ptr) { |
|
106 left = SymbianHelpers::stripIdPrefix(d_ptr->_id).toLong(); |
|
107 //left = d_ptr->_id.toLong(); |
|
108 } |
|
109 if (other.d_ptr) { |
|
110 right = SymbianHelpers::stripIdPrefix(other.d_ptr->_id).toLong(); |
|
111 //right = other.d_ptr->_id.toLong(); |
|
112 } |
|
113 |
|
114 return (left < right); |
|
115 } |
|
116 |
|
117 QString QMessageId::toString() const |
|
118 { |
|
119 return d_ptr ? d_ptr->_id : QString(); |
|
120 } |
|
121 |
|
122 bool QMessageId::isValid() const |
|
123 { |
|
124 return d_ptr ? true : false; |
|
125 } |
|
126 |
|
127 uint qHash(const QMessageId &id) |
|
128 { |
|
129 return qHash(id.toString()); |
|
130 } |
|
131 |
|
132 |
|
133 QTM_END_NAMESPACE |