svn path=/branches/work/akonadi-ports/kdepim/; revision=1058454
wilder-work
Laurent Montel 17 years ago
parent f6ecd8b23a
commit ff75cf0ae6
  1. 14
      attachmentcontroller.cpp
  2. 3
      attachmentcontroller.h
  3. 56
      attachmentmodel.cpp
  4. 2
      attachmentmodel.h

@ -29,6 +29,8 @@
#include "globalsettings.h"
#include "kmkernel.h"
#include "kmcomposewin.h"
#include "kmcommands.h"
#include "foldercollection.h"
#include <QMenu>
#include <QPointer>
@ -363,6 +365,7 @@ AttachmentController::AttachmentController( AttachmentModel *model, AttachmentVi
d->model = model;
connect( model, SIGNAL(attachUrlsRequested(KUrl::List)), this, SLOT(addAttachments(KUrl::List)) );
connect( model, SIGNAL(attachItemsRequester(Akonadi::Item::List ) ), this, SLOT( addAttachmentItems( Akonadi::Item::List ) ) );
connect( model, SIGNAL(attachmentRemoved(KPIM::AttachmentPart::Ptr)),
this, SLOT(attachmentRemoved(KPIM::AttachmentPart::Ptr)) );
connect( model, SIGNAL(attachmentCompressRequested(KPIM::AttachmentPart::Ptr,bool)),
@ -670,6 +673,17 @@ void AttachmentController::addAttachments( const KUrl::List &urls )
}
}
void AttachmentController::addAttachmentItems( const Akonadi::Item::List &items )
{
uint identity = 0;
if ( items.at( 0 ).isValid() && items.at( 0 ).parentCollection().isValid() ) {
FolderCollection fd( items.at( 0 ).parentCollection(),false );
identity = fd.identity();
}
KMCommand *command = new KMForwardAttachedCommand( d->composer, items,identity, d->composer );
command->start();
}
void AttachmentController::showAttachPublicKeyDialog()
{
using Kleo::KeySelectionDialog;

@ -30,7 +30,7 @@
#include <KPIMIdentities/Identity>
#include <messagecore/attachmentpart.h>
#include <akonadi/item.h>
class KMComposeWin;
@ -69,6 +69,7 @@ class AttachmentController : public QObject
void addAttachment( KPIM::AttachmentPart::Ptr part );
void addAttachment( const KUrl &url );
void addAttachments( const KUrl::List &urls );
void addAttachmentItems( const Akonadi::Item::List &items );
void showAttachPublicKeyDialog();
void attachMyPublicKey();

@ -30,11 +30,12 @@
#include <KTempDir>
#include <kmime/kmime_util.h>
#include <akonadi/item.h>
#include "foldercollection.h"
#include "kmcommands.h"
#include <kpimutils/kfileio.h>
#include <libkdepim/maillistdrag.h>
using namespace KMail;
using namespace KPIM;
@ -106,45 +107,24 @@ bool AttachmentModel::dropMimeData( const QMimeData *data, Qt::DropAction action
//} else if( action != Qt::CopyAction ) {
// return false;
}
if( KPIM::MailList::canDecode( data ) ) {
// The dropped data is a list of messages.
kDebug() << "Port me to Akonadi..."; // TODO
#if 0
// Decode the list of serial numbers stored as the drag data
QByteArray serNums = KPIM::MailList::serialsFromMimeData( md );
QBuffer serNumBuffer( &serNums );
serNumBuffer.open( QIODevice::ReadOnly );
QDataStream serNumStream( &serNumBuffer );
quint32 serNum;
KMFolder *folder = 0;
int idx;
QList<KMMsgBase*> messageList;
while( !serNumStream.atEnd() ) {
KMMsgBase *msgBase = 0;
serNumStream >> serNum;
KMMsgDict::instance()->getLocation( serNum, &folder, &idx );
if( folder )
msgBase = folder->getMsgBase( idx );
if( msgBase )
messageList.append( msgBase );
// The dropped data is a list of URLs.
KUrl::List urls = KUrl::List::fromMimeData( data );
if( !urls.isEmpty() ) {
Akonadi::Item::List items;
foreach ( const KUrl &url, urls ) {
Akonadi::Item item = Akonadi::Item::fromUrl( url );
if ( item.isValid() ) {
items << item;
}
}
serNumBuffer.close();
uint identity = folder ? folder->identity() : 0;
KMCommand *command = new KMForwardAttachedCommand( mComposer, messageList,
identity, mComposer );
command->start();
#endif
return true;
} else {
// The dropped data is a list of URLs.
KUrl::List urls = KUrl::List::fromMimeData( data );
if( !urls.isEmpty() ) {
if ( items.isEmpty() )
emit attachUrlsRequested( urls );
return true;
} else {
return false;
else {
emit attachItemsRequester( items );
}
return true;
} else {
return false;
}
}

@ -25,6 +25,7 @@
#include <KDE/KUrl>
#include <messagecore/attachmentpart.h>
#include <akonadi/item.h>
namespace KMail {
@ -104,6 +105,7 @@ class AttachmentModel : public QAbstractItemModel
void encryptEnabled( bool enabled );
void signEnabled( bool enabled );
void attachUrlsRequested( const KUrl::List &urls );
void attachItemsRequester( const Akonadi::Item::List & );
void attachmentRemoved( KPIM::AttachmentPart::Ptr part );
void attachmentCompressRequested( KPIM::AttachmentPart::Ptr part, bool compress );

Loading…
Cancel
Save