qtcontactsmobility/src/versit/qversitdocument.cpp
changeset 24 0ba2181d7c28
child 25 76a2435edfd4
equal deleted inserted replaced
0:e686773b3f54 24:0ba2181d7c28
       
     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 
       
    42 #include "qversitdocument.h"
       
    43 #include "qversitdocument_p.h"
       
    44 #include "qmobilityglobal.h"
       
    45 
       
    46 QTM_BEGIN_NAMESPACE
       
    47 
       
    48 /*!
       
    49   \class QVersitDocument
       
    50  
       
    51   \brief The QVersitDocument class is a container for 0..n versit properties.
       
    52 
       
    53   \ingroup versit
       
    54  
       
    55   For example a vCard can be presented as a QVersitDocument that
       
    56   consists of 0..n properties such as a name (N),
       
    57   a telephone number (TEL) and an email address (EMAIL) to name a few.
       
    58   Each of these properties is stored as
       
    59   an instance of a QVersitProperty in a QVersitDocument.
       
    60  
       
    61   QVersitDocument supports implicit sharing.
       
    62  
       
    63   \sa QVersitProperty
       
    64  */
       
    65 
       
    66 /*! Constructs a new empty document */
       
    67 QVersitDocument::QVersitDocument() : d(new QVersitDocumentPrivate())
       
    68 {
       
    69 }
       
    70 
       
    71 /*! Constructs a document that is a copy of \a other */
       
    72 QVersitDocument::QVersitDocument(const QVersitDocument& other) : d(other.d)
       
    73 {
       
    74 }
       
    75 
       
    76 /*! Frees the memory used by the document */
       
    77 QVersitDocument::~QVersitDocument()
       
    78 {
       
    79 }
       
    80 
       
    81 /*! Assigns this document to \a other */
       
    82 QVersitDocument& QVersitDocument::operator=(const QVersitDocument& other)
       
    83 {
       
    84     if (this != &other)
       
    85         d = other.d;
       
    86     return *this;    
       
    87 }
       
    88 
       
    89 /*!
       
    90  * Sets the versit document type to \a type.
       
    91  */
       
    92 void QVersitDocument::setVersitType(VersitType type)
       
    93 {
       
    94     d->mVersitType = type;
       
    95 }
       
    96 
       
    97 /*!
       
    98  * Gets the versit document type.
       
    99  */
       
   100 QVersitDocument::VersitType QVersitDocument::versitType() const
       
   101 {
       
   102     return d->mVersitType;
       
   103 }
       
   104 
       
   105 /*!
       
   106  * Add \a property to the list of contained versit properties.
       
   107  * The property is appended as the last property of the list.
       
   108  */
       
   109 void QVersitDocument::addProperty(const QVersitProperty& property)
       
   110 {
       
   111     d->mProperties.append(property);
       
   112 }
       
   113 
       
   114 /*!
       
   115  * Gets the list of the contained versit properties.
       
   116  * Note that the actual properties cannot be modified using the copy.
       
   117  */
       
   118 QList<QVersitProperty> QVersitDocument::properties() const
       
   119 {
       
   120     return d->mProperties;  
       
   121 }
       
   122 
       
   123 /*!
       
   124  * Removes all the properties with \a name from the versit document.
       
   125  */
       
   126 void QVersitDocument::removeProperties(const QString& name)
       
   127 {
       
   128     for (int i=d->mProperties.count()-1; i >=0; i--) {
       
   129         if (d->mProperties[i].name() == name) {
       
   130             d->mProperties.removeAt(i);
       
   131         }
       
   132     }
       
   133 }
       
   134 
       
   135 QTM_END_NAMESPACE