[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/kjots
From:       Stephen Kelly <steveire () gmail ! com>
Date:       2010-06-16 13:44:09
Message-ID: 20100616134409.67514AC8D7 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1138687 by skelly:

Show a lock emblem on locked entries.

 M  +19 -2     kjotsmodel.cpp  


--- trunk/KDE/kdepim/kjots/kjotsmodel.cpp #1138686:1138687
@@ -24,6 +24,8 @@
 #include <QColor>
 #include <QTextDocument>
 
+#include <KIcon>
+
 #include <akonadi/changerecorder.h>
 #include <akonadi/entitydisplayattribute.h>
 
@@ -36,6 +38,7 @@
 #include <grantlee/markupdirector.h>
 #include <grantlee/texthtmlbuilder.h>
 #include <grantlee/plaintextmarkupbuilder.h>
+#include "kjotslockattribute.h"
 
 Q_DECLARE_METATYPE(QTextDocument*)
 
@@ -226,9 +229,10 @@
     return QVariant::fromValue(obj);
   }
 
+
   if ( role == KJotsModel::DocumentRole )
   {
-    Item item = index.data( ItemRole ).value<Item>();
+    const Item item = index.data( ItemRole ).value<Item>();
     Entity::Id itemId = item.id();
     if ( m_documents.contains( itemId ) )
       return QVariant::fromValue( m_documents.value( itemId ) );
@@ -249,7 +253,7 @@
 
   if ( role == KJotsModel::DocumentCursorPositionRole )
   {
-    Item item = EntityTreeModel::data( index, EntityTreeModel::ItemRole ).value<Item>();
+    const Item item = index.data( ItemRole ).value<Item>();
     if (!item.isValid())
       return 0;
 
@@ -259,6 +263,19 @@
     return 0;
   }
 
+  if ( role == Qt::DecorationRole )
+  {
+    const Item item = index.data( ItemRole ).value<Item>();
+    if ( item.isValid() && item.hasAttribute<KJotsLockAttribute>() ) {
+        return KIcon( "emblem-locked" );
+    } else {
+      const Collection col = index.data( CollectionRole ).value<Collection>();
+      if ( col.isValid() && col.hasAttribute<KJotsLockAttribute>() ) {
+        return KIcon( "emblem-locked" );
+      }
+    }
+  }
+
   return EntityTreeModel::data(index, role);
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic