20 #include "attachmentlistview.h"
23 #include "kmmsgbase.h"
25 #include "kmcommands.h"
26 #include "kmmsgdict.h"
30 #include <maillistdrag.h>
31 using KPIM::MailListDrag;
38 #include <tqcstring.h>
40 #include <tqptrlist.h>
41 #include <tqdatastream.h>
49 AttachmentListView::AttachmentListView( KMail::Composer * composer,
52 : TDEListView( parent, name ),
55 setAcceptDrops(
true );
56 setDragEnabled(
true );
61 AttachmentListView::~AttachmentListView()
67 void AttachmentListView::contentsDragEnterEvent( TQDragEnterEvent* e )
69 if( e->provides( MailListDrag::format() ) || KURLDrag::canDecode( e ) )
72 TDEListView::dragEnterEvent( e );
77 void AttachmentListView::contentsDragMoveEvent( TQDragMoveEvent* e )
79 if( e->provides( MailListDrag::format() ) || KURLDrag::canDecode( e ) )
82 TDEListView::dragMoveEvent( e );
87 void AttachmentListView::contentsDropEvent( TQDropEvent* e )
89 if( e->provides( MailListDrag::format() ) ) {
92 MailListDrag::decode( e, serNums );
93 TQBuffer serNumBuffer( serNums );
94 serNumBuffer.open( IO_ReadOnly );
95 TQDataStream serNumStream( &serNumBuffer );
99 TQPtrList<KMMsgBase> messageList;
100 while( !serNumStream.atEnd() ) {
101 KMMsgBase *msgBase = 0;
102 serNumStream >> serNum;
107 messageList.append( msgBase );
109 serNumBuffer.close();
110 uint identity = folder ? folder->identity() : 0;
111 KMCommand *command =
new KMForwardAttachedCommand( mComposer, messageList,
112 identity, mComposer );
115 else if( KURLDrag::canDecode( e ) ) {
117 if( KURLDrag::decode( e, urlList ) ) {
118 for( KURL::List::Iterator it = urlList.begin();
119 it != urlList.end(); ++it ) {
120 mComposer->addAttach( *it );
125 TDEListView::dropEvent( e );
131 void AttachmentListView::keyPressEvent( TQKeyEvent * e )
133 if ( e->key() == Key_Delete ) {
134 emit attachmentDeleted();
139 void AttachmentListView::startDrag()
146 #include "attachmentlistview.moc"
const KMMsgBase * getMsgBase(int idx) const
Provides access to the basic message fields that are also stored in the index.
void getLocation(unsigned long key, KMFolder **retFolder, int *retIndex) const
Returns the folder the message represented by the serial number key is in and the index in that folde...
static const KMMsgDict * instance()
Access the globally unique MessageDict.