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.

knowitlinks.cpp 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /***************************************************************************
  2. knowitlinks.cpp - description
  3. -------------------
  4. begin : nie gru 21 2003
  5. copyright : (C) 2003 by Micha³ Rudolf
  6. email : mrudolf@tdewebdev.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 "knowitlinks.h"
  17. #include <tqevent.h>
  18. #include <kurldrag.h>
  19. KnowitLinks::KnowitLinks(TQWidget* parent, const char* name)
  20. : TDEListBox(parent, name)
  21. {
  22. setAcceptDrops(true);
  23. }
  24. void KnowitLinks::dragEnterEvent(TQDragEnterEvent* event)
  25. {
  26. event->accept(KURLDrag::canDecode(event));
  27. }
  28. void KnowitLinks::dropEvent(TQDropEvent* event)
  29. {
  30. if (KURLDrag::canDecode(event)) {
  31. KURL::List L;
  32. KURLDrag::decode(event, L);
  33. for (uint i=0; i<L.count(); i++)
  34. emit textDropped(L[i].url(), L.count() > 1);
  35. }
  36. }
  37. void KnowitLinks::keyPressEvent(TQKeyEvent* e)
  38. {
  39. if (currentItem() != -1 && (e->key() == TQt::Key_Enter || e->key() == TQt::Key_Return)) {
  40. e->ignore();
  41. if ((e->state() | Qt::NoButton | TQt::Keypad) ==
  42. (Qt::NoButton | TQt::Keypad)) emit linkOpen();
  43. else emit linkOpenWith();
  44. }
  45. else if (currentItem() != -1 && e->key() == TQt::Key_Delete) {
  46. e->ignore();
  47. emit linkRemove();
  48. }
  49. else TDEListBox::keyPressEvent(e);
  50. }