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

List:       kde-core-devel
Subject:    KLineEdit handling URL drops
From:       Matthias Kiefer <matthias.kiefer () gmx ! net>
Date:       2001-01-29 21:47:44
[Download RAW message or body]

Hi,

I would like to commit the attached patch to KLineEdit. It correctly handles 
URL drops, because I think it is more likely that users want to have the 
decoded url pasted instead the encoded url.

What do you think?

Greetings,
   Matthias
-- 
Matthias Kiefer
E-Mail: matthias.kiefer@gmx.de, kiefer@kde.org
KBabel: http://i18n.kde.org/tools/kbabel/


["klineedit.diff" (text/x-c)]

Index: klineedit.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/klineedit.cpp,v
retrieving revision 1.70
diff -u -r1.70 klineedit.cpp
--- klineedit.cpp	2001/01/19 12:13:24	1.70
+++ klineedit.cpp	2001/01/29 16:01:14
@@ -27,6 +27,7 @@
 #include <qclipboard.h>
 
 #include <kcursor.h>
+#include <qdragobject.h>
 #include <klocale.h>
 #include <kstdaccel.h>
 #include <kpopupmenu.h>
@@ -360,21 +361,42 @@
 {
     if ( o == this )
     {
-	KCursor::autoHideEventFilter( this, ev );
+        if(ev->type() == QEvent::Drop)
+        {
+            QDropEvent *de = dynamic_cast<QDropEvent *>( ev );
+            QStrList uriList;
+            if(QUriDrag::canDecode(de) && QUriDrag::decode( de, uriList ))
+            {
+                for (QStrListIterator it(uriList); it.current(); ++it)
+                {
+                       KURL u(*it);
+                       if (u.protocol() == "mailto")
+                           insert(u.path());
+                       else 
+                           insert(u.prettyURL());
+                }
+                
+                return true;
+            }
+        }
+        else
+        {
+            KCursor::autoHideEventFilter( this, ev );
 
-	QKeyEvent *e = dynamic_cast<QKeyEvent *>( ev );
-	if ( e )
-	{
-	    if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
+            QKeyEvent *e = dynamic_cast<QKeyEvent *>( ev );
+            if ( e )
             {
-		emit returnPressed( displayText() );
-		if ( d->grabReturnKeyEvents )
-		{
-		    e->accept();
-		    return true;
-		}
-	    }
-	}
+                if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
+                {
+                    emit returnPressed( displayText() );
+                    if ( d->grabReturnKeyEvents )
+                    {
+            		    e->accept();
+            		    return true;
+            		}
+        	    }
+        	}
+        }
     }
     return QLineEdit::eventFilter( o, ev );
 }


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

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