qtcontactsmobility/src/versit/qversitdocument.cpp
changeset 25 76a2435edfd4
parent 24 0ba2181d7c28
child 27 de1630741fbe
--- a/qtcontactsmobility/src/versit/qversitdocument.cpp	Fri Mar 19 09:27:18 2010 +0200
+++ b/qtcontactsmobility/src/versit/qversitdocument.cpp	Fri Apr 16 14:53:18 2010 +0300
@@ -43,20 +43,19 @@
 #include "qversitdocument_p.h"
 #include "qmobilityglobal.h"
 
-QTM_BEGIN_NAMESPACE
+#include <QTextCodec>
+
+QTM_USE_NAMESPACE
 
 /*!
   \class QVersitDocument
- 
-  \brief The QVersitDocument class is a container for 0..n versit properties.
-
+  \preliminary
+  \brief The QVersitDocument class is a container for a list of versit properties.
   \ingroup versit
  
-  For example a vCard can be presented as a QVersitDocument that
-  consists of 0..n properties such as a name (N),
-  a telephone number (TEL) and an email address (EMAIL) to name a few.
-  Each of these properties is stored as
-  an instance of a QVersitProperty in a QVersitDocument.
+  For example a vCard can be presented as a QVersitDocument that consists of a number of properties
+  such as a name (N), a telephone number (TEL) and an email address (EMAIL) to name a few.
+  Each of these properties is stored as an instance of a QVersitProperty in a QVersitDocument.
  
   QVersitDocument supports implicit sharing.
  
@@ -86,10 +85,23 @@
     return *this;    
 }
 
+/*! Returns true if this is equal to \a other; false otherwise. */
+bool QVersitDocument::operator==(const QVersitDocument& other) const
+{
+    return d->mVersitType == other.d->mVersitType &&
+            d->mProperties == other.d->mProperties;
+}
+
+/*! Returns true if this is not equal to \a other; false otherwise. */
+bool QVersitDocument::operator!=(const QVersitDocument& other) const
+{
+    return !(*this == other);
+}
+
 /*!
  * Sets the versit document type to \a type.
  */
-void QVersitDocument::setVersitType(VersitType type)
+void QVersitDocument::setType(VersitType type)
 {
     d->mVersitType = type;
 }
@@ -97,7 +109,7 @@
 /*!
  * Gets the versit document type.
  */
-QVersitDocument::VersitType QVersitDocument::versitType() const
+QVersitDocument::VersitType QVersitDocument::type() const
 {
     return d->mVersitType;
 }
@@ -112,16 +124,15 @@
 }
 
 /*!
- * Gets the list of the contained versit properties.
- * Note that the actual properties cannot be modified using the copy.
+ * Removes the property \a property from the versit document.
  */
-QList<QVersitProperty> QVersitDocument::properties() const
+void QVersitDocument::removeProperty(const QVersitProperty& property)
 {
-    return d->mProperties;  
+    d->mProperties.removeAll(property);
 }
 
 /*!
- * Removes all the properties with \a name from the versit document.
+ * Removes all the properties with the given \a name from the versit document.
  */
 void QVersitDocument::removeProperties(const QString& name)
 {
@@ -132,4 +143,41 @@
     }
 }
 
-QTM_END_NAMESPACE
+/*!
+ * Clears the document, removing all properties and metadata
+ * and resetting the codec to the default.
+ */
+void QVersitDocument::clear()
+{
+    d->mProperties.clear();
+    d->mVersitType = QVersitDocument::InvalidType;
+}
+
+/*!
+ * Gets the list of the contained versit properties.
+ * Note that the actual properties cannot be modified using the copy.
+ */
+QList<QVersitProperty> QVersitDocument::properties() const
+{
+    return d->mProperties;
+}
+
+/*!
+ * Returns true if the document is empty.
+ */
+bool QVersitDocument::isEmpty() const
+{
+    return d->mProperties.count() == 0 && d->mVersitType == QVersitDocument::InvalidType;
+}
+
+/*! \internal */
+void QVersitDocument::setVersitType(VersitType type)
+{
+    setType(type);
+}
+
+/*! \internal */
+QVersitDocument::VersitType QVersitDocument::versitType() const
+{
+    return type();
+}