qtmobility/src/messaging/qmessagefolderfilter_qmf.cpp
changeset 1 2b40d63a9c3d
child 11 06b8e2af4411
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 "qmessagefolderfilter.h"
       
    42 #include "qmfhelpers_p.h"
       
    43 
       
    44 #include <qmailaccountkey.h>
       
    45 #include <qmailfolderkey.h>
       
    46 #include <qmailmessagekey.h>
       
    47 
       
    48 using namespace QTM_PREPEND_NAMESPACE(QmfHelpers);
       
    49 
       
    50 QTM_BEGIN_NAMESPACE
       
    51 
       
    52 class QMessageFolderFilterPrivate
       
    53 {
       
    54 public:
       
    55     QMessageFolderFilterPrivate() : _key(), _matchFlags(0) {}
       
    56 
       
    57     QMailFolderKey _key;
       
    58     QMessageDataComparator::MatchFlags _matchFlags;
       
    59 
       
    60     //static QMessageFolderFilter convert(const QMailFolderKey &key);
       
    61     static QMailFolderKey convert(const QMessageFolderFilter &filter);
       
    62 };
       
    63 
       
    64 /*
       
    65 QMessageFolderFilter QMessageFolderFilterPrivate::convert(const QMailFolderKey &key)
       
    66 {
       
    67     QMessageFolderFilter result;
       
    68     result.d_ptr->_key = key;
       
    69     return result;
       
    70 }
       
    71 */
       
    72 
       
    73 QMailFolderKey QMessageFolderFilterPrivate::convert(const QMessageFolderFilter &filter)
       
    74 {
       
    75     return filter.d_ptr->_key;
       
    76 }
       
    77 
       
    78 namespace QmfHelpers {
       
    79 
       
    80 /*
       
    81 QMessageFolderFilter convert(const QMailFolderKey &key)
       
    82 {
       
    83     return QMessageFolderFilterPrivate::convert(key);
       
    84 }
       
    85 */
       
    86 
       
    87 QMailFolderKey convert(const QMessageFolderFilter &filter)
       
    88 {
       
    89     return QMessageFolderFilterPrivate::convert(filter);
       
    90 }
       
    91 
       
    92 }
       
    93 
       
    94 QMessageFolderFilter::QMessageFolderFilter()
       
    95     : d_ptr(new QMessageFolderFilterPrivate)
       
    96 {
       
    97 }
       
    98 
       
    99 QMessageFolderFilter::QMessageFolderFilter(const QMessageFolderFilter &other)
       
   100     : d_ptr(new QMessageFolderFilterPrivate)
       
   101 {
       
   102     this->operator=(other);
       
   103 }
       
   104 
       
   105 QMessageFolderFilter::~QMessageFolderFilter()
       
   106 {
       
   107     delete d_ptr;
       
   108     d_ptr = 0;
       
   109 }
       
   110 
       
   111 QMessageFolderFilter& QMessageFolderFilter::operator=(const QMessageFolderFilter& other)
       
   112 {
       
   113     if (&other != this) {
       
   114         d_ptr->_key = other.d_ptr->_key;
       
   115         d_ptr->_matchFlags = other.d_ptr->_matchFlags;
       
   116     }
       
   117 
       
   118     return *this;
       
   119 }
       
   120 
       
   121 void QMessageFolderFilter::setMatchFlags(QMessageDataComparator::MatchFlags matchFlags)
       
   122 {
       
   123     d_ptr->_matchFlags = matchFlags;
       
   124 }
       
   125 
       
   126 QMessageDataComparator::MatchFlags QMessageFolderFilter::matchFlags() const
       
   127 {
       
   128     return d_ptr->_matchFlags;
       
   129 }
       
   130 
       
   131 bool QMessageFolderFilter::isEmpty() const
       
   132 {
       
   133     return d_ptr->_key.isEmpty();
       
   134 }
       
   135 
       
   136 bool QMessageFolderFilter::isSupported() const
       
   137 {
       
   138     return !d_ptr->_matchFlags;
       
   139 }
       
   140 
       
   141 QMessageFolderFilter QMessageFolderFilter::operator~() const
       
   142 {
       
   143     QMessageFolderFilter result;
       
   144     result.d_ptr->_key = ~d_ptr->_key;
       
   145     return result;
       
   146 }
       
   147 
       
   148 QMessageFolderFilter QMessageFolderFilter::operator&(const QMessageFolderFilter& other) const
       
   149 {
       
   150     QMessageFolderFilter result;
       
   151     result.d_ptr->_key = d_ptr->_key & other.d_ptr->_key;
       
   152     result.d_ptr->_matchFlags = d_ptr->_matchFlags | other.d_ptr->_matchFlags; // matchFlags not supported
       
   153     return result;
       
   154 }
       
   155 
       
   156 QMessageFolderFilter QMessageFolderFilter::operator|(const QMessageFolderFilter& other) const
       
   157 {
       
   158     QMessageFolderFilter result;
       
   159     result.d_ptr->_key = d_ptr->_key | other.d_ptr->_key;
       
   160     result.d_ptr->_matchFlags = d_ptr->_matchFlags | other.d_ptr->_matchFlags; // matchFlags not supported
       
   161     return result;
       
   162 }
       
   163 
       
   164 const QMessageFolderFilter& QMessageFolderFilter::operator&=(const QMessageFolderFilter& other)
       
   165 {
       
   166     d_ptr->_key &= other.d_ptr->_key;
       
   167     d_ptr->_matchFlags |= other.d_ptr->_matchFlags; // matchFlags not supported
       
   168     return *this;
       
   169 }
       
   170 
       
   171 const QMessageFolderFilter& QMessageFolderFilter::operator|=(const QMessageFolderFilter& other)
       
   172 {
       
   173     d_ptr->_key |= other.d_ptr->_key;
       
   174     d_ptr->_matchFlags |= other.d_ptr->_matchFlags; // matchFlags not supported
       
   175     return *this;
       
   176 }
       
   177 
       
   178 bool QMessageFolderFilter::operator==(const QMessageFolderFilter& other) const
       
   179 {
       
   180     return ((d_ptr->_key == other.d_ptr->_key)
       
   181             && (d_ptr->_matchFlags == other.d_ptr->_matchFlags));
       
   182 }
       
   183 
       
   184 QMessageFolderFilter QMessageFolderFilter::byId(const QMessageFolderId &id, QMessageDataComparator::EqualityComparator cmp)
       
   185 {
       
   186     QMessageFolderFilter result;
       
   187     result.d_ptr->_key = QMailFolderKey::id(convert(id), convert(cmp));
       
   188     return result;
       
   189 }
       
   190 
       
   191 QMessageFolderFilter QMessageFolderFilter::byId(const QMessageFolderIdList &ids, QMessageDataComparator::InclusionComparator cmp)
       
   192 {
       
   193     QMessageFolderFilter result;
       
   194     result.d_ptr->_key = QMailFolderKey::id(convert(ids), convert(cmp));
       
   195     return result;
       
   196 }
       
   197 
       
   198 QMessageFolderFilter QMessageFolderFilter::byId(const QMessageFolderFilter &filter, QMessageDataComparator::InclusionComparator cmp)
       
   199 {
       
   200     QMessageFolderFilter result;
       
   201     result.d_ptr->_key = QMailFolderKey::id(convert(filter), convert(cmp));
       
   202     return result;
       
   203 }
       
   204 
       
   205 QMessageFolderFilter QMessageFolderFilter::byName(const QString &value, QMessageDataComparator::EqualityComparator cmp)
       
   206 {
       
   207     QMessageFolderFilter result;
       
   208     result.d_ptr->_key = QMailFolderKey::displayName(value, convert(cmp));
       
   209     return result;
       
   210 }
       
   211 
       
   212 QMessageFolderFilter QMessageFolderFilter::byName(const QString &value, QMessageDataComparator::InclusionComparator cmp)
       
   213 {
       
   214     QMessageFolderFilter result;
       
   215     result.d_ptr->_key = QMailFolderKey::displayName(value, convert(cmp));
       
   216     return result;
       
   217 }
       
   218 
       
   219 QMessageFolderFilter QMessageFolderFilter::byPath(const QString &value, QMessageDataComparator::EqualityComparator cmp)
       
   220 {
       
   221     QMessageFolderFilter result;
       
   222     result.d_ptr->_key = QMailFolderKey::path(value, convert(cmp));
       
   223     return result;
       
   224 }
       
   225 
       
   226 QMessageFolderFilter QMessageFolderFilter::byPath(const QString &value, QMessageDataComparator::InclusionComparator cmp)
       
   227 {
       
   228     QMessageFolderFilter result;
       
   229     result.d_ptr->_key = QMailFolderKey::path(value, convert(cmp));
       
   230     return result;
       
   231 }
       
   232 
       
   233 QMessageFolderFilter QMessageFolderFilter::byParentAccountId(const QMessageAccountId &id, QMessageDataComparator::EqualityComparator cmp)
       
   234 {
       
   235     QMessageFolderFilter result;
       
   236     result.d_ptr->_key = QMailFolderKey::parentAccountId(convert(id), convert(cmp));
       
   237     return result;
       
   238 }
       
   239 
       
   240 QMessageFolderFilter QMessageFolderFilter::byParentAccountId(const QMessageAccountFilter &filter, QMessageDataComparator::InclusionComparator cmp)
       
   241 {
       
   242     QMessageFolderFilter result;
       
   243     result.d_ptr->_key = QMailFolderKey::parentAccountId(convert(filter), convert(cmp));
       
   244     return result;
       
   245 }
       
   246 
       
   247 QMessageFolderFilter QMessageFolderFilter::byParentFolderId(const QMessageFolderId &id, QMessageDataComparator::EqualityComparator cmp)
       
   248 {
       
   249     QMessageFolderFilter result;
       
   250     result.d_ptr->_key = QMailFolderKey::parentFolderId(convert(id), convert(cmp));
       
   251     return result;
       
   252 }
       
   253 
       
   254 QMessageFolderFilter QMessageFolderFilter::byParentFolderId(const QMessageFolderFilter &filter, QMessageDataComparator::InclusionComparator cmp)
       
   255 {
       
   256     QMessageFolderFilter result;
       
   257     result.d_ptr->_key = QMailFolderKey::parentFolderId(convert(filter), convert(cmp));
       
   258     return result;
       
   259 }
       
   260 
       
   261 QMessageFolderFilter QMessageFolderFilter::byAncestorFolderIds(const QMessageFolderId &id, QMessageDataComparator::InclusionComparator cmp)
       
   262 {
       
   263     QMessageFolderFilter result;
       
   264     result.d_ptr->_key = QMailFolderKey::ancestorFolderIds(convert(id), convert(cmp));
       
   265     return result;
       
   266 }
       
   267 
       
   268 QMessageFolderFilter QMessageFolderFilter::byAncestorFolderIds(const QMessageFolderFilter &filter, QMessageDataComparator::InclusionComparator cmp)
       
   269 {
       
   270     QMessageFolderFilter result;
       
   271     result.d_ptr->_key = QMailFolderKey::ancestorFolderIds(convert(filter), convert(cmp));
       
   272     return result;
       
   273 }
       
   274 
       
   275 QTM_END_NAMESPACE