diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 02:48:30 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 02:48:30 +0000 |
commit | e1481e0a7c066357dfb67136f331b5f069d94f3c (patch) | |
tree | 19599adc9a54e8295402ceb25d6f2ea42edea439 /src/knowitlinks.cpp | |
download | knowit-e1481e0a7c066357dfb67136f331b5f069d94f3c.tar.gz knowit-e1481e0a7c066357dfb67136f331b5f069d94f3c.zip |
Added abandoned KDE3 version of knowit
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knowit@1091582 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/knowitlinks.cpp')
-rw-r--r-- | src/knowitlinks.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/knowitlinks.cpp b/src/knowitlinks.cpp new file mode 100644 index 0000000..daab0bb --- /dev/null +++ b/src/knowitlinks.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + knowitlinks.cpp - description + ------------------- + begin : nie gru 21 2003 + copyright : (C) 2003 by Micha³ Rudolf + email : mrudolf@kdewebdev.org + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "knowitlinks.h" +#include <qevent.h> +#include <kurldrag.h> + +KnowitLinks::KnowitLinks(QWidget* parent, const char* name) + : KListBox(parent, name) +{ + setAcceptDrops(true); +} + +void KnowitLinks::dragEnterEvent(QDragEnterEvent* event) +{ + event->accept(KURLDrag::canDecode(event)); +} + +void KnowitLinks::dropEvent(QDropEvent* event) +{ + if (KURLDrag::canDecode(event)) { + KURL::List L; + KURLDrag::decode(event, L); + for (uint i=0; i<L.count(); i++) + emit textDropped(L[i].url(), L.count() > 1); + } +} + +void KnowitLinks::keyPressEvent(QKeyEvent* e) +{ + if (currentItem() != -1 && (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return)) { + e->ignore(); + if ((e->state() | Qt::NoButton | Qt::Keypad) == + (Qt::NoButton | Qt::Keypad)) emit linkOpen(); + else emit linkOpenWith(); + } + else if (currentItem() != -1 && e->key() == Qt::Key_Delete) { + e->ignore(); + emit linkRemove(); + } + else KListBox::keyPressEvent(e); +} |