qtcontactsmobility/src/versit/qversitdocument.cpp
changeset 27 de1630741fbe
parent 25 76a2435edfd4
--- a/qtcontactsmobility/src/versit/qversitdocument.cpp	Fri Apr 16 14:53:18 2010 +0300
+++ b/qtcontactsmobility/src/versit/qversitdocument.cpp	Mon May 03 12:24:20 2010 +0300
@@ -45,28 +45,43 @@
 
 #include <QTextCodec>
 
-QTM_USE_NAMESPACE
+QTM_BEGIN_NAMESPACE
 
 /*!
   \class QVersitDocument
   \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 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.
- 
+
   \sa QVersitProperty
  */
 
+/*!
+  \enum QVersitDocument::VersitType
+  This enum describes a versit document type and version.
+  \value InvalidType No type specified or a document with an invalid type was parsed
+  \value VCard21Type vCard version 2.1
+  \value VCard30Type vCard version 3.0
+ */
+
 /*! Constructs a new empty document */
 QVersitDocument::QVersitDocument() : d(new QVersitDocumentPrivate())
 {
 }
 
+/*! Constructs a new empty document with the type set to \a type */
+QVersitDocument::QVersitDocument(VersitType type) : d(new QVersitDocumentPrivate())
+{
+    d->mVersitType = type;
+}
+
+
 /*! Constructs a document that is a copy of \a other */
 QVersitDocument::QVersitDocument(const QVersitDocument& other) : d(other.d)
 {
@@ -82,7 +97,7 @@
 {
     if (this != &other)
         d = other.d;
-    return *this;    
+    return *this;
 }
 
 /*! Returns true if this is equal to \a other; false otherwise. */
@@ -98,6 +113,27 @@
     return !(*this == other);
 }
 
+/*! Returns the hash value for \a key. */
+uint qHash(const QVersitDocument &key)
+{
+    int hash = QT_PREPEND_NAMESPACE(qHash)(key.type());
+    foreach (const QVersitProperty& property, key.properties()) {
+        hash += qHash(property);
+    }
+    return hash;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QVersitDocument& document)
+{
+    dbg.nospace() << "QVersitDocument(" << document.type() << ')';
+    foreach (const QVersitProperty& property, document.properties()) {
+        dbg.space() << '\n' << property;
+    }
+    return dbg.maybeSpace();
+}
+#endif
+
 /*!
  * Sets the versit document type to \a type.
  */
@@ -170,14 +206,4 @@
     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();
-}
+QTM_END_NAMESPACE