CVS commit by goffioul: Added support for drag-n-drop (bug #78370) M +14 -0 ktnefmain.cpp 1.15 M +1 -0 ktnefmain.h 1.10 M +17 -0 ktnefview.cpp 1.6 M +6 -0 ktnefview.h 1.3 --- kdepim/ktnef/gui/ktnefmain.cpp #1.14:1.15 @@ -53,4 +53,5 @@ #include #include +#include @@ -148,4 +149,5 @@ void KTNEFMain::setupTNEF() connect(view_, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), SLOT(viewRightButtonPressed(QListViewItem*,const QPoint&,int))); connect(view_, SIGNAL(doubleClicked(QListViewItem*)), SLOT(viewDoubleClicked(QListViewItem*))); + connect(view_, SIGNAL(dragRequested(const QValueList&)), SLOT(viewDragRequested(const QValueList&))); } @@ -354,4 +356,16 @@ void KTNEFMain::viewDoubleClicked(QListV } +void KTNEFMain::viewDragRequested( const QValueList& list ) +{ + KURL::List urlList; + for ( QValueList::ConstIterator it=list.constBegin(); it!=list.constEnd(); ++it ) + urlList << KURL( extractTemp( *it ) ); + if ( !list.isEmpty() ) + { + KURLDrag *urlDrag = new KURLDrag( urlList, this ); + urlDrag->dragCopy(); + } +} + void KTNEFMain::slotEditToolbars() { --- kdepim/ktnef/gui/ktnefmain.h #1.9:1.10 @@ -56,4 +56,5 @@ protected slots: void viewRightButtonPressed(QListViewItem *item, const QPoint& p, int c); void viewDoubleClicked(QListViewItem*); + void viewDragRequested( const QValueList& list ); void slotConfigureKeys(); //protected: --- kdepim/ktnef/gui/ktnefview.cpp #1.5:1.6 @@ -26,4 +26,5 @@ #include #include +#include #include @@ -53,4 +54,5 @@ Attachment::Attachment(QListView *parent else setPixmap(0, mimeType->pixmap(KIcon::Small)); + setDragEnabled( true ); } @@ -111,2 +113,17 @@ QPtrList* KTNEFView::getSel return &attachments_; } + +void KTNEFView::startDrag() +{ + QListViewItemIterator it( this, QListViewItemIterator::Selected ); + QValueList list; + while ( it.current() ) + { + list << static_cast( it.current() )->getAttachment(); + ++it; + } + if ( !list.isEmpty() ) + emit dragRequested( list ); +} + +#include "ktnefview.moc" --- kdepim/ktnef/gui/ktnefview.h #1.2:1.3 @@ -26,4 +26,6 @@ class KTNEFAttach; class KTNEFView : public KListView { + Q_OBJECT + public: KTNEFView(QWidget *parent = 0, const char *name = 0); @@ -33,6 +35,10 @@ public: QPtrList* getSelection(); +signals: + void dragRequested( const QValueList& list ); + protected: void resizeEvent(QResizeEvent *e); + void startDrag(); private: