From kde-commits Mon Nov 16 18:09:31 2009 From: Tom Albers Date: Mon, 16 Nov 2009 18:09:31 +0000 To: kde-commits Subject: extragear/pim/mailody/src Message-Id: <1258394971.031222.30906.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=125839498004560 SVN commit 1050129 by toma: Add support to Mailody for selecting Images from Image resources as attachments. CCMAIL: lure@kubuntu.org M +1 -0 CMakeLists.txt M +44 -1 composer.cpp M +1 -0 composer.h A imagemodel.cpp [License: UNKNOWN] A imagemodel.h [License: UNKNOWN] --- trunk/extragear/pim/mailody/src/CMakeLists.txt #1050128:1050129 @@ -54,6 +54,7 @@ ip2geohostip.cpp ip2geoipinfodb.cpp contacttreemodel.cpp + imagemodel.cpp ) --- trunk/extragear/pim/mailody/src/composer.cpp #1050128:1050129 @@ -23,6 +23,7 @@ #include "contacttreemodel.h" #include "contacttooltipproxymodel.h" #include "global.h" +#include "imagemodel.h" #include "sendmessage.h" #include "recentmodel.h" #include "recentmanager.h" @@ -34,6 +35,7 @@ #include #include #include +#include #include // KDEPIM @@ -45,6 +47,8 @@ #include #include #include +#include +#include #include #include #include @@ -131,8 +135,40 @@ SIGNAL( doubleClicked( const QModelIndex& ) ), SLOT( slotAddFile( const QModelIndex& ) ) ); + // images. + QSplitter *splitter = new QSplitter( Qt::Vertical, this ); + + Session *session = new Session( QByteArray( "ImageViewAplication-" ) + QByteArray::number( qrand() ), this ); + + ChangeRecorder *changeRecorder = new ChangeRecorder( this ); + changeRecorder->setItemFetchScope( scope ); + changeRecorder->setCollectionMonitored( Collection::root() ); + changeRecorder->setMimeTypeMonitored( "application/x-vnd.kde.image", true ); + + EntityTreeModel *model = new EntityTreeModel( session, changeRecorder, this ); + model->setItemPopulationStrategy( EntityTreeModel::NoItemPopulation ); + + EntityTreeView *lv = new EntityTreeView( splitter ); + lv->setModel( model ); + + ImageModel* im = new ImageModel( this ); + im->setFetchScope( scope ); + + QListView* lv2 = new QListView( splitter ); + lv2->setViewMode( QListView::IconMode ); + lv2->setModel( im ); + connect( lv2, SIGNAL( clicked( const QModelIndex& ) ), + SLOT( slotImageClicked( const QModelIndex& ) ) ); + + connect( lv, SIGNAL( currentChanged( const Akonadi::Collection& ) ), + im, SLOT( setCollection( const Akonadi::Collection& ) ) ); + + QToolBox* toolbox = new QToolBox( this ); + toolbox->addItem( splitter, i18n("Images") ); + toolbox->addItem( m_filebrowser, i18n("Files") ); + QDockWidget* attachDock = new QDockWidget( i18n( "At&tach File" ), this ); - attachDock->setWidget( m_filebrowser ); + attachDock->setWidget( toolbox ); attachDock->setObjectName( "attachDock" ); attachDock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable ); @@ -643,6 +679,13 @@ addAttachment( file.url() ); } +void Composer::slotImageClicked( const QModelIndex& index ) +{ + const ImageModel* model = static_cast( index.model() ); + QString filename = model->itemForIndex( index ).remoteId(); + slotAddFile( filename ); +} + void Composer::slotAddFile( const KUrl& file ) { setDirty( true ); --- trunk/extragear/pim/mailody/src/composer.h #1050128:1050129 @@ -204,6 +204,7 @@ void slotStatusBarClicked( int item ); void slotAddFile( const QModelIndex & index ); + void slotImageClicked( const QModelIndex& index ); void slotAddFile( const KUrl& ); void slotHTMLMode( bool );