[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/pim/mailody/src
From: Tom Albers <toma () kde ! org>
Date: 2009-10-17 19:11:00
Message-ID: 1255806660.390778.7730.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1036771 by toma:
Add support for contact groups in Mailody. Yay!
M +22 -1 composer.cpp
M +1 -0 composer.h
M +1 -1 contactcreation.cpp
M +21 -4 contacttooltipproxymodel.cpp
M +2 -0 contacttooltipproxymodel.h
M +26 -14 contacttreemodel.cpp
--- trunk/extragear/pim/mailody/src/composer.cpp #1036770:1036771
@@ -37,11 +37,14 @@
#include <QToolButton>
// KDEPIM
+#include <kabc/addressee.h>
+#include <kabc/contactgroup.h>
#include <mailtransport/transportmanager.h>
#include <kpimidentities/identitycombo.h>
#include <kpimidentities/identity.h>
#include <akonadi/changerecorder.h>
#include <akonadi/contact/contacteditordialog.h>
+#include <akonadi/contact/contactgroupexpandjob.h>
#include <akonadi/itemcreatejob.h>
#include <akonadi/itemfetchscope.h>
#include <akonadi/itemdeletejob.h>
@@ -665,9 +668,27 @@
void Composer::slotAddAddressFromAddressBook( const QModelIndex& index )
{
- m_recipientWidget->slotAddAddress( index.data( ContactTreeModel::AddressRole ).toString() );
+ Akonadi::Item item = index.data( ContactTreeModel::ItemRole ).value<Akonadi::Item>();
+ if ( item.mimeType() == "text/directory") {
+ m_recipientWidget->slotAddAddress( index.data( ContactTreeModel::AddressRole ).toString() );
+ } else if ( item.mimeType() == "application/x-vnd.kde.contactgroup") {
+ const KABC::ContactGroup group = item.payload<KABC::ContactGroup>();
+ Akonadi::ContactGroupExpandJob *job = new Akonadi::ContactGroupExpandJob( group );
+ connect( job, SIGNAL( result( KJob* ) ), this, SLOT( expandResult( KJob* ) ) );
+ job->start();
+ }
}
+void Composer::expandResult( KJob *job )
+ {
+ Akonadi::ContactGroupExpandJob *expandJob = qobject_cast<Akonadi::ContactGroupExpandJob*>( job );
+ const KABC::Addressee::List contacts = expandJob->contacts();
+ foreach ( const KABC::Addressee &contact, contacts ) {
+ m_recipientWidget->slotAddAddress( contact.fullEmail() );
+ }
+}
+
+
void Composer::slotContextMenuAddressBook()
{
const QModelIndex lvi = m_addressbookView->currentIndex();
--- trunk/extragear/pim/mailody/src/composer.h #1036770:1036771
@@ -213,6 +213,7 @@
void slotAddAddressFromAddressBook( const QModelIndex& );
void slotContextMenuAddressBook();
void slotContextMenuAddressList();
+ void expandResult( KJob *job );
void slotAddAddressFromRecentBook( const QModelIndex& );
void slotContextMenuRecentBook();
--- trunk/extragear/pim/mailody/src/contactcreation.cpp #1036770:1036771
@@ -38,7 +38,7 @@
QString email, name;
bool ok = KPIMUtils::extractEmailAddressAndName( address, email, name );
if ( !ok ) {
- kDebug() << "splitting name and mail failed";
+ kDebug() << "splitting name and mail failed for:" << address;
return;
}
kDebug() << name << email;
--- trunk/extragear/pim/mailody/src/contacttooltipproxymodel.cpp #1036770:1036771
@@ -22,6 +22,8 @@
//KDE
#include <akonadi/contact/contactviewer.h>
#include <akonadi/contact/contactviewerdialog.h>
+#include <akonadi/contact/contactgroupviewer.h>
+#include <akonadi/contact/contactgroupviewerdialog.h>
#include <akonadi/entitytreemodel.h>
using namespace Mailody;
@@ -35,11 +37,18 @@
SIGNAL( emailClicked( const QString&, const QString& ) ),
SLOT( slotMailClicked( const QString&, const QString& ) ) );
m_contactViewer->hide();
+
+ m_contactGroupViewer = new Akonadi::ContactGroupViewerDialog( 0 );
+ connect( m_contactGroupViewer->viewer(),
+ SIGNAL( emailClicked( const QString&, const QString& ) ),
+ SLOT( slotMailClicked( const QString&, const QString& ) ) );
+ m_contactGroupViewer->hide();
}
ContactToolTipProxyModel::~ContactToolTipProxyModel()
{
delete m_contactViewer;
+ delete m_contactGroupViewer;
}
QVariant ContactToolTipProxyModel::data( const QModelIndex & index, int role ) const
@@ -59,10 +68,18 @@
if ( item == m_contactViewer->contact() )
return QVariant();
- m_contactViewer->setContact( item );
- m_contactViewer->move( QCursor::pos() );
- m_contactViewer->resize( QSize( 400, 400 ) );
- m_contactViewer->show();
+ if ( item.mimeType() == "text/directory") {
+ m_contactViewer->setContact( item );
+ m_contactViewer->move( QCursor::pos() );
+ m_contactViewer->resize( QSize( 400, 400 ) );
+ m_contactViewer->show();
+ } else if ( item.mimeType() == "application/x-vnd.kde.contactgroup") {
+ m_contactGroupViewer->setContactGroup( item );
+ m_contactGroupViewer->move( QCursor::pos() );
+ m_contactGroupViewer->resize( QSize( 400, 400 ) );
+ m_contactGroupViewer->show();
+ }
+
return QVariant();
}
--- trunk/extragear/pim/mailody/src/contacttooltipproxymodel.h #1036770:1036771
@@ -25,6 +25,7 @@
//KDE
#include <akonadi/entitytreemodel.h>
#include <akonadi/contact/contactviewerdialog.h>
+#include <akonadi/contact/contactgroupviewerdialog.h>
#include <kmime/kmime_header_parsing.h>
namespace Mailody
@@ -47,6 +48,7 @@
private:
Akonadi::ContactViewerDialog *m_contactViewer;
+ Akonadi::ContactGroupViewerDialog *m_contactGroupViewer;
};
}
--- trunk/extragear/pim/mailody/src/contacttreemodel.cpp #1036770:1036771
@@ -22,6 +22,7 @@
//KDE
#include <klocale.h>
#include <kabc/addressee.h>
+#include <kabc/contactgroup.h>
#include <kmime/kmime_header_parsing.h>
#include <akonadi/changerecorder.h>
@@ -42,23 +43,34 @@
if ( !item.isValid() )
return Akonadi::EntityTreeModel::data( index, role );
- if ( !item.hasPayload<KABC::Addressee>() ) {
- kDebug() << "No payload?";
- return Akonadi::EntityTreeModel::data( index, role );
- }
+ if ( item.mimeType() == "text/directory") {
+ if ( !item.hasPayload<KABC::Addressee>() ) {
+ kDebug() << "No payload?";
+ return Akonadi::EntityTreeModel::data( index, role );
+ }
- const KABC::Addressee addr = item.payload<KABC::Addressee>();
+ const KABC::Addressee addr = item.payload<KABC::Addressee>();
- if ( role == Qt::DisplayRole ) {
- return i18nc( "fullname (emailaddress)","%1 (%2)",
- addr.formattedName(), addr.preferredEmail() );
- } else if ( role == AddressRole ) {
- KMime::Types::Mailbox mb;
- mb.setAddress( addr.preferredEmail().toLocal8Bit() );
- mb.setName( addr.formattedName().toLocal8Bit() );
- kDebug() << mb.address();
- return mb.prettyAddress();
+ if ( role == Qt::DisplayRole ) {
+ return i18nc( "fullname (emailaddress)","%1 (%2)",
+ addr.formattedName(), addr.preferredEmail() );
+ } else if ( role == AddressRole ) {
+ KMime::Types::Mailbox mb;
+ mb.setAddress( addr.preferredEmail().toLocal8Bit() );
+ mb.setName( addr.formattedName().toLocal8Bit() );
+ kDebug() << mb.address();
+ return mb.prettyAddress();
+ }
+ } else if ( item.mimeType() == "application/x-vnd.kde.contactgroup") {
+ if ( !item.hasPayload<KABC::ContactGroup>() ) {
+ kDebug() << "No payload?";
+ return Akonadi::EntityTreeModel::data( index, role );
+ }
+
+ const KABC::ContactGroup group = item.payload<KABC::ContactGroup>();
+ return group.name();
}
+
return QVariant();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic