AkonadiBackend.cpp 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#include "AkonadiBackend.h"
#include <QtCore/QTimer>
#include <akonadi/control.h>
#include <akonadi/collectionfilterproxymodel.h>
#include <akonadi/collectionmodel.h>
#include <akonadi/kmime/messagemodel.h>
#include <contactgroupsearchjob.h>

AkonadiBackend::AkonadiBackend(QObject* parent) : QObject(parent)
{
   QTimer::singleShot( 0, this, SLOT( delayedInit() ) );
}

virtual AkonadiBackend::~AkonadiBackend()
{
   
}

AkonadiBackend* AkonadiBackend::getInstance()
{
   
}

static bool AkonadiBackend::init() 
{
   if ( !Akonadi::Control::start( this ) ) {
       return false;
   }
   return true;
}

void AkonadiBackend::createModels()
{
    Akonadi::CollectionModel *collectionModel = new Akonadi::CollectionModel( this );
 
    Akonadi::CollectionFilterProxyModel *filterModel = new Akonadi::CollectionFilterProxyModel( this );
    filterModel->setSourceModel( collectionModel );
    filterModel->addMimeTypeFilter( QLatin1String( "message/rfc822" ) );
 
    Akonadi::ItemModel *itemModel = new Akonadi::MessageModel( this );
 
    ui_detacherview_base.folderView->setModel( filterModel );
    ui_detacherview_base.messageView->setModel( itemModel );
 
    connect( ui_detacherview_base.folderView, SIGNAL( currentChanged( Akonadi::Collection ) ),
             itemModel, SLOT( setCollection( Akonadi::Collection ) ) );
}