Branch 'kolab/integration/4.13.0' - 2 commits - akonadi/tag.cpp akonadi/tageditwidget.cpp akonadi/tag.h

Christian Mollekopf mollekopf at kolabsys.com
Wed Jan 28 20:15:54 CET 2015


 akonadi/tag.cpp           |   12 ++++++++++++
 akonadi/tag.h             |   15 ++++++++++++++-
 akonadi/tageditwidget.cpp |    2 +-
 3 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit 7f3abb24e299032d39cf881a27a12ec12668e984
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Jan 28 02:01:27 2015 +0100

    use GENERIC tag type as default for new tags.

diff --git a/akonadi/tageditwidget.cpp b/akonadi/tageditwidget.cpp
index d0e0177..32be0a6 100644
--- a/akonadi/tageditwidget.cpp
+++ b/akonadi/tageditwidget.cpp
@@ -111,7 +111,7 @@ void TagEditWidget::Private::onRowsInserted(const QModelIndex &parent, int start
 
 void TagEditWidget::Private::slotCreateTag()
 {
-    Akonadi::TagCreateJob *createJob = new Akonadi::TagCreateJob(Akonadi::Tag(m_newTagEdit->text()), this);
+    Akonadi::TagCreateJob *createJob = new Akonadi::TagCreateJob(Akonadi::Tag::genericTag(m_newTagEdit->text()), this);
     connect(createJob, SIGNAL(finished(KJob*)),
             this, SLOT(slotCreateTagFinished(KJob*)));
 


commit e1c67f574bd4913b4a299e0ac55d78e6f83ac0b8
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Jan 28 02:00:35 2015 +0100

    Add GENERIC tag type
    
    To have a tag type that is mutable and have a RFC4122 compatiple tag.

diff --git a/akonadi/tag.cpp b/akonadi/tag.cpp
index f1157f6..7a942fa 100644
--- a/akonadi/tag.cpp
+++ b/akonadi/tag.cpp
@@ -19,10 +19,12 @@
 
 #include "tag.h"
 #include <akonadi/tagattribute.h>
+#include <QUuid>
 
 using namespace Akonadi;
 
 const char *Akonadi::Tag::PLAIN = "PLAIN";
+const char *Akonadi::Tag::GENERIC = "GENERIC";
 
 struct Akonadi::Tag::Private {
     Private()
@@ -212,3 +214,13 @@ QDebug &operator<<(QDebug &debug, const Tag &tag)
     debug << "Akonadi::Tag( ID " << tag.id() << ", GID " << tag.gid() << ", parent" << tag.parent().id() << ")";
     return debug;
 }
+
+Tag Tag::genericTag(QString name)
+{
+  Tag tag;
+  tag.d->type = GENERIC;
+  tag.d->gid = QUuid::createUuid().toByteArray().mid(1, 36);
+  tag.setName(name);
+  return tag;
+}
+
diff --git a/akonadi/tag.h b/akonadi/tag.h
index ea43a0c..b478cfe 100644
--- a/akonadi/tag.h
+++ b/akonadi/tag.h
@@ -56,6 +56,16 @@ public:
      */
     static const char *PLAIN;
 
+    /**
+     * The GENERIC type has the following properties:
+     * * mutable
+     * * gid is RFC 4122 compatible
+     * * no hierarchy (no parent)
+     *
+     * GENERIC tags are general purpose tags, that are used, if you can change tag name.
+     */
+    static const char *GENERIC;
+
     Tag();
     explicit Tag(Id id);
     /**
@@ -112,13 +122,16 @@ public:
      */
     bool isImmutable() const;
 
+    /**
+     * Returns a GENERIC tag with the given name and a valid gid
+     */
+    static Tag genericTag(QString name);
 private:
     class Private;
     QSharedPointer<Private> d;
 };
 
 }
-
 AKONADI_EXPORT QDebug &operator<<(QDebug &debug, const Akonadi::Tag &tag);
 
 Q_DECLARE_METATYPE(Akonadi::Tag)




More information about the commits mailing list