[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE_3_2_BRANCH: kdepim/ktnef/gui
From:       Michael Goffioul <kdeprint () swing ! be>
Date:       2004-03-25 9:32:02
Message-ID: 20040325093202.54EC299B4 () office ! kde ! org
[Download RAW message or body]

CVS commit by goffioul: 

[Backport] Added support for drag-n-drop (bug #78370)


  M +16 -2     ktnefmain.cpp   1.13.4.1
  M +1 -0      ktnefmain.h   1.9.4.1
  M +17 -0     ktnefview.cpp   1.5.4.1
  M +6 -0      ktnefview.h   1.2.4.1


--- kdepim/ktnef/gui/ktnefmain.cpp  #1.13:1.13.4.1
@@ -53,4 +53,5 @@
 #include <kedittoolbar.h>
 #include <kstatusbar.h>
+#include <kurldrag.h>
 
 
@@ -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<KTNEFAttach*>&)), SLOT(viewDragRequested(const \
QValueList<KTNEFAttach*>&)));  }
 
@@ -207,5 +209,5 @@ void KTNEFMain::viewFileAs()
 {
         KURL::List      list;
-        list.append(extractTemp(view_->getSelection()->first()));
+        list.append(KURL::fromPathOrURL( extractTemp(view_->getSelection()->first()) \
));  
   KRun::displayOpenWithDialog(list);
@@ -354,4 +356,16 @@ void KTNEFMain::viewDoubleClicked(QListV
 }
 
+void KTNEFMain::viewDragRequested( const QValueList<KTNEFAttach*>& list )
+{
+        KURL::List urlList;
+        for ( QValueList<KTNEFAttach*>::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()
 {
@@ -382,5 +396,5 @@ void KTNEFMain::slotShowMessageText()
         tmpFile.close();
 
-        KRun::runURL( tmpFile.name(), "text/rtf", true );
+        KRun::runURL( KURL::fromPathOrURL( tmpFile.name() ), "text/rtf", true );
 }
 

--- kdepim/ktnef/gui/ktnefmain.h  #1.9:1.9.4.1
@@ -56,4 +56,5 @@ protected slots:
         void viewRightButtonPressed(QListViewItem *item, const QPoint& p, int c);
         void viewDoubleClicked(QListViewItem*);
+        void viewDragRequested( const QValueList<KTNEFAttach*>& list );
     void slotConfigureKeys();
 //protected:

--- kdepim/ktnef/gui/ktnefview.cpp  #1.5:1.5.4.1
@@ -26,4 +26,5 @@
 #include <kiconloader.h>
 #include <klocale.h>
+#include <kdebug.h>
 
 #include <kmimetype.h>
@@ -53,4 +54,5 @@ Attachment::Attachment(QListView *parent
         else
                 setPixmap(0, mimeType->pixmap(KIcon::Small));
+        setDragEnabled( true );
 }
 
@@ -111,2 +113,17 @@ QPtrList<KTNEFAttach>* KTNEFView::getSel
         return &attachments_;
 }
+
+void KTNEFView::startDrag()
+{
+        QListViewItemIterator it( this, QListViewItemIterator::Selected );
+        QValueList<KTNEFAttach*> list;
+        while ( it.current() )
+        {
+                list << static_cast<Attachment*>( it.current() )->getAttachment();
+                ++it;
+        }
+        if ( !list.isEmpty() )
+                emit dragRequested( list );
+}
+
+#include "ktnefview.moc"

--- kdepim/ktnef/gui/ktnefview.h  #1.2:1.2.4.1
@@ -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<KTNEFAttach>* getSelection();
 
+signals:
+        void dragRequested( const QValueList<KTNEFAttach*>& list );
+
 protected:
         void resizeEvent(QResizeEvent *e);
+        void startDrag();
 
 private:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic