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

List:       kde-commits
Subject:    KDE/kdepim/kaddressbook
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2010-07-29 11:56:06
Message-ID: 20100729115606.87615AC7A9 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1156620 by tokoe:

Create a Grantlee based formatter for contact groups.

This allows us to create custom formatting for mobile platform for example.


 M  +8 -2      CMakeLists.txt  
 M  +6 -3      grantleecontactformatter.cpp  
 A             grantleecontactgroupformatter.cpp   [License: LGPL (v2+)]
 A             grantleecontactgroupformatter.h   [License: LGPL (v2+)]
 M  +6 -0      mainwidget.cpp  
 M  +16 -16    viewertemplates/contact_embedded.html  
 A             viewertemplates/contact_row.html   viewertemplates/row.html#1156169
 A             viewertemplates/contactgroup.html  
 A             viewertemplates/contactgroup_additionalfieldrow.html  
 A             viewertemplates/contactgroup_embedded.html  
 A             viewertemplates/contactgroup_memberrow.html  
 D             viewertemplates/row.html  


--- trunk/KDE/kdepim/kaddressbook/CMakeLists.txt #1156619:1156620
@@ -66,7 +66,9 @@
 
 if (Grantlee_FOUND)
   set( kaddressbook_LIB_SRCS ${kaddressbook_LIB_SRCS}
-       grantleecontactformatter.cpp )
+       grantleecontactformatter.cpp
+       grantleecontactgroupformatter.cpp
+     )
   add_definitions(-DGRANTLEE_FOUND)
 endif (Grantlee_FOUND)
 
@@ -119,5 +121,9 @@
 install( FILES
          viewertemplates/contact.html
          viewertemplates/contact_embedded.html
-         viewertemplates/row.html
+         viewertemplates/contact_row.html
+         viewertemplates/contactgroup.html
+         viewertemplates/contactgroup_embedded.html
+         viewertemplates/contactgroup_additionalfieldrow.html
+         viewertemplates/contactgroup_memberrow.html
          DESTINATION ${DATA_INSTALL_DIR}/kaddressbook/viewertemplates/default/)
--- trunk/KDE/kdepim/kaddressbook/grantleecontactformatter.cpp #1156619:1156620
@@ -41,7 +41,6 @@
   public:
     Private( const QString &templatePath )
     {
-      qDebug("GrantleeContactFormatter::Private called");
       mEngine = new Grantlee::Engine;
 
       mTemplateLoader = Grantlee::FileSystemTemplateLoader::Ptr( new \
Grantlee::FileSystemTemplateLoader ); @@ -51,11 +50,11 @@
       mEngine->addTemplateLoader( mTemplateLoader );
       mSelfcontainedTemplate = mEngine->loadByName( "contact.html" );
       if ( mSelfcontainedTemplate->error() )
-        qDebug() << "error:" << mSelfcontainedTemplate->errorString();
+        mErrorMessage += mSelfcontainedTemplate->errorString();
 
       mEmbeddableTemplate = mEngine->loadByName( "contact_embedded.html" );
       if ( mEmbeddableTemplate->error() )
-        qDebug() << "error:" << mEmbeddableTemplate->errorString();
+        mErrorMessage += mEmbeddableTemplate->errorString();
     }
 
     ~Private()
@@ -68,6 +67,7 @@
     Grantlee::FileSystemTemplateLoader::Ptr mTemplateLoader;
     Grantlee::Template mSelfcontainedTemplate;
     Grantlee::Template mEmbeddableTemplate;
+    QString mErrorMessage;
 };
 
 GrantleeContactFormatter::GrantleeContactFormatter( const QString &templatePath )
@@ -135,6 +135,9 @@
 
 QString GrantleeContactFormatter::toHtml( HtmlForm form ) const
 {
+  if ( !d->mErrorMessage.isEmpty() )
+    return d->mErrorMessage;
+
   KABC::Addressee rawContact;
   const Akonadi::Item localItem = item();
   if ( localItem.isValid() && localItem.hasPayload<KABC::Addressee>() )
--- trunk/KDE/kdepim/kaddressbook/mainwidget.cpp #1156619:1156620
@@ -32,6 +32,7 @@
 
 #ifdef GRANTLEE_FOUND
 #include "grantleecontactformatter.h"
+#include "grantleecontactgroupformatter.h"
 #endif
 
 #include <akonadi/akonadi_next/collectionselectionproxymodel.h>
@@ -386,6 +387,11 @@
        new Akonadi::GrantleeContactFormatter( KStandardDirs::locate( "data", \
QLatin1String( "kaddressbook/viewertemplates/" ) ) );  
  mContactDetails->setContactFormatter( formatter );
+
+ Akonadi::GrantleeContactGroupFormatter *groupFormatter =
+       new Akonadi::GrantleeContactGroupFormatter( KStandardDirs::locate( "data", \
QLatin1String( "kaddressbook/viewertemplates/" ) ) ); +
+ mContactGroupDetails->setContactGroupFormatter( groupFormatter );
 #endif
 }
 
--- trunk/KDE/kdepim/kaddressbook/viewertemplates/contact_embedded.html \
#1156619:1156620 @@ -15,7 +15,7 @@
       {% if contact.birthday %}
         {% with "Birthday" as title %}
         {% with contact.birthday as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -23,7 +23,7 @@
       {% for phoneNumber in contact.phoneNumbers %}
         {% with phoneNumber.type as title %}
         {% with phoneNumber.numberLink|safe as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endfor %}
@@ -31,7 +31,7 @@
       {% for email in contact.emails %}
         {% with "Email" as title %}
         {% with email as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endfor %}
@@ -39,7 +39,7 @@
       {% if contact.website %}
         {% with "Website" as title %}
         {% with contact.website|safe as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -47,7 +47,7 @@
       {% if contact.blogUrl %}
         {% with "Blog Feed" as title %}
         {% with contact.blogUrl|safe as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -55,7 +55,7 @@
       {% for address in contact.addresses %}
         {% with address.type as title %}
         {% with address.formattedAddressLink|safe as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endfor %}
@@ -63,7 +63,7 @@
       {% if contact.imAddress %}
         {% with "IM Address" as title %}
         {% with contact.imAddress as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -71,7 +71,7 @@
       {% if contact.profession %}
         {% with "Profession" as title %}
         {% with contact.profession as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -79,7 +79,7 @@
       {% if contact.department %}
         {% with "Department" as title %}
         {% with contact.department as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -87,7 +87,7 @@
       {% if contact.office %}
         {% with "Office" as title %}
         {% with contact.department as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -95,7 +95,7 @@
       {% if contact.manager %}
         {% with "Manager's Name" as title %}
         {% with contact.manager as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -103,7 +103,7 @@
       {% if contact.assistant %}
         {% with "Assistant's Name" as title %}
         {% with contact.assistant as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -111,7 +111,7 @@
       {% if contact.spouse %}
         {% with "Partner's Name" as title %}
         {% with contact.spouse as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -119,7 +119,7 @@
       {% if contact.anniversary %}
         {% with "Anniversary" as title %}
         {% with contact.anniversary as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}
@@ -127,7 +127,7 @@
       {% for customField in contact.customFields %}
         {% with customField.title as title %}
         {% with customField.value as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endfor %}
@@ -135,7 +135,7 @@
       {% if contact.addressBookName %}
         {% with "Address Book" as title %}
         {% with contact.addressBookName as value %}
-        {% include "row.html" %}
+        {% include "contact_row.html" %}
         {% endwith %}
         {% endwith %}
       {% endif %}


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

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