qtmobility/src/versit/qversitdocument.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 8 71781823f776
--- a/qtmobility/src/versit/qversitdocument.cpp	Fri Apr 16 15:51:22 2010 +0300
+++ b/qtmobility/src/versit/qversitdocument.cpp	Mon May 03 13:18:40 2010 +0300
@@ -45,7 +45,7 @@
 
 #include <QTextCodec>
 
-QTM_USE_NAMESPACE
+QTM_BEGIN_NAMESPACE
 
 /*!
   \class QVersitDocument
@@ -75,6 +75,13 @@
 {
 }
 
+/*! 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)
 {
@@ -106,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.
  */
@@ -177,3 +205,5 @@
 {
     return d->mProperties.count() == 0 && d->mVersitType == QVersitDocument::InvalidType;
 }
+
+QTM_END_NAMESPACE