SVN commit 1036744 by toma: Remove most of the code, now the API has been changed so I can pass a Addressee to the dialog in creation mode. M +5 -41 contactcreation.cpp M +0 -11 contactcreation.h --- trunk/extragear/pim/mailody/src/contactcreation.cpp #1036743:1036744 @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -32,7 +33,7 @@ ContactCreation::ContactCreation( QWidget* parent, const QString& address, Akonadi::Collection collection ) - : QObject( parent ), m_parent( parent ) + : QObject( parent ) { QString email, name; bool ok = KPIMUtils::extractEmailAddressAndName( address, email, name ); @@ -46,46 +47,9 @@ addressee.setNameFromString( name ); addressee.setEmails( QStringList( email ) ); - Akonadi::Item item( -1 ); - item.setMimeType( "text/directory" ); - item.setPayload( addressee ); - - Akonadi::ItemCreateJob* job = new Akonadi::ItemCreateJob( item, collection ); - connect( job, SIGNAL( result( KJob* ) ), - SLOT( slotAddContactCompleted( KJob* ) ) ); -} - -void ContactCreation::slotAddContactCompleted( KJob* job ) -{ - kDebug(); - if ( job->error() ) { - kDebug() << "Initial creation failed" << job->errorString(); - return; - } - - Akonadi::ItemCreateJob* createJob = - static_cast( job ); - - m_item = createJob->item(); - - QTimer::singleShot( 1000 /* some delay */, this, SLOT( slotShowDialog() ) ); -} - -void ContactCreation::slotShowDialog() -{ - kDebug(); Akonadi::ContactEditorDialog* dlg = - new Akonadi::ContactEditorDialog( Akonadi::ContactEditorDialog::EditMode, - m_parent ); - dlg->setContact( m_item ); + new Akonadi::ContactEditorDialog( Akonadi::ContactEditorDialog::CreateMode, + parent ); + dlg->editor()->setContactTemplate( addressee ); dlg->show(); - connect( dlg, SIGNAL( cancelClicked() ), SLOT( slotCancelClicked() ) ); } - -void ContactCreation::slotCancelClicked() -{ - kDebug(); - new Akonadi::ItemDeleteJob( m_item ); -} - -#include "contactcreation.moc" --- trunk/extragear/pim/mailody/src/contactcreation.h #1036743:1036744 @@ -34,20 +34,9 @@ class ContactCreation : public QObject { - Q_OBJECT - public: ContactCreation( QWidget* parent, const QString& address, Akonadi::Collection ); - -private slots: - void slotAddContactCompleted( KJob* job ); - void slotShowDialog(); - void slotCancelClicked(); - -private: - Akonadi::Item m_item; - QWidget* m_parent; }; }