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/knowitedit.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/knowitedit.cpp')
-rw-r--r-- | src/knowitedit.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/knowitedit.cpp b/src/knowitedit.cpp new file mode 100644 index 0000000..298d63c --- /dev/null +++ b/src/knowitedit.cpp @@ -0,0 +1,66 @@ +/*************************************************************************** + knowitedit.cpp - description + ------------------- + begin : pi± maj 23 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 "knowitedit.h" +#include <kurldrag.h> + +KnowitEdit::KnowitEdit(const QString& text, const QString& context, QWidget* parent, + const char* name) : KTextEdit(text, context, parent, name), swapEOL(true) +{ + setAcceptDrops(true); +} + + +KnowitEdit::KnowitEdit(QWidget* parent, const char* name) : KTextEdit(parent, name), + swapEOL(true) +{ + +} + +void KnowitEdit::keyPressEvent(QKeyEvent* e) +{ + if (swapEOL && + (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) && + (e->state() | (Qt::NoButton | Qt::ControlButton | Qt::Keypad) == + (Qt::NoButton | Qt::ControlButton | Qt::Keypad))) { + QKeyEvent* e1 = new QKeyEvent(QKeyEvent::KeyPress, e->key(), + e->ascii(), e->state() ^ Qt::ControlButton, e->text(), e->isAutoRepeat(), + e->count()); + e->ignore(); + QTextEdit::keyPressEvent(e1); + } + else QTextEdit::keyPressEvent(e); +} + +void KnowitEdit::contentsDragEnterEvent(QDragEnterEvent* event) +{ + if (KURLDrag::canDecode(event)) + event->accept(true); + else QTextEdit::contentsDragEnterEvent(event); +} + +void KnowitEdit::contentsDropEvent(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); + } + else QTextEdit::contentsDropEvent(event); +} + |