KnowIt – tool for managing notes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

knowitedit.cpp 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /***************************************************************************
  2. knowitedit.cpp - description
  3. -------------------
  4. begin : pi± maj 23 2003
  5. copyright : (C) 2003 by Micha³ Rudolf
  6. email : mrudolf@kdewebdev.org
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #include "knowitedit.h"
  17. #include <kurldrag.h>
  18. KnowitEdit::KnowitEdit(const TQString& text, const TQString& context, TQWidget* parent,
  19. const char* name) : KTextEdit(text, context, parent, name), swapEOL(true)
  20. {
  21. setAcceptDrops(true);
  22. }
  23. KnowitEdit::KnowitEdit(TQWidget* parent, const char* name) : KTextEdit(parent, name),
  24. swapEOL(true)
  25. {
  26. }
  27. void KnowitEdit::keyPressEvent(TQKeyEvent* e)
  28. {
  29. if (swapEOL &&
  30. (e->key() == TQt::Key_Enter || e->key() == TQt::Key_Return) &&
  31. (e->state() | (Qt::NoButton | TQt::ControlButton | TQt::Keypad) ==
  32. (Qt::NoButton | TQt::ControlButton | TQt::Keypad))) {
  33. TQKeyEvent* e1 = new TQKeyEvent(TQKeyEvent::KeyPress, e->key(),
  34. e->ascii(), e->state() ^ TQt::ControlButton, e->text(), e->isAutoRepeat(),
  35. e->count());
  36. e->ignore();
  37. TQTextEdit::keyPressEvent(e1);
  38. }
  39. else TQTextEdit::keyPressEvent(e);
  40. }
  41. void KnowitEdit::contentsDragEnterEvent(TQDragEnterEvent* event)
  42. {
  43. if (KURLDrag::canDecode(event))
  44. event->accept(true);
  45. else TQTextEdit::contentsDragEnterEvent(event);
  46. }
  47. void KnowitEdit::contentsDropEvent(TQDropEvent* event)
  48. {
  49. if (KURLDrag::canDecode(event)) {
  50. KURL::List L;
  51. KURLDrag::decode(event, L);
  52. for (uint i=0; i<L.count(); i++)
  53. emit textDropped(L[i].url(), L.count() > 1);
  54. }
  55. else TQTextEdit::contentsDropEvent(event);
  56. }