errorlist.ui.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /****************************************************************************
  2. ** ui.h extension file, included from the uic-generated form implementation.
  3. **
  4. ** If you want to add, delete, or rename functions or slots, use
  5. ** Qt Designer to update this file, preserving your code.
  6. **
  7. ** You should not define a constructor or destructor in this file.
  8. ** Instead, write your code in functions called init() and destroy().
  9. ** These will automatically be called by the form's constructor and
  10. ** destructor.
  11. *****************************************************************************/
  12. /*
  13. ktigcc - TIGCC IDE for KDE
  14. Copyright (C) 2006-2007 Kevin Kofler
  15. This program is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 2, or (at your option)
  18. any later version.
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software Foundation,
  25. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #include <qevent.h>
  28. #include <qlistview.h>
  29. #include <qapplication.h>
  30. #include <qclipboard.h>
  31. #include <qstring.h>
  32. bool ErrorList::event(QEvent *e)
  33. {
  34. if (e->type()==QEvent::AccelOverride) {
  35. QKeyEvent *ke=static_cast<QKeyEvent*>(e);
  36. if ((ke->key()==Qt::Key_Insert || ke->key()==Qt::Key_C)
  37. && ke->state()==Qt::ControlButton)
  38. ke->accept();
  39. }
  40. return QWidget::event(e);
  41. }
  42. void ErrorList::keyPressEvent(QKeyEvent *e)
  43. {
  44. if ((e->key()==Qt::Key_Insert || e->key()==Qt::Key_C)
  45. && e->state()==Qt::ControlButton) {
  46. // Copy selected errors to the clipboard.
  47. QListViewItemIterator lvit(errorListView,QListViewItemIterator::Selected);
  48. QListViewItem *errorItem;
  49. QString clipboardText;
  50. for (errorItem=lvit.current();errorItem;errorItem=(++lvit).current()) {
  51. clipboardText.append(errorItem->text(0));
  52. clipboardText.append('\n');
  53. }
  54. QApplication::clipboard()->setText(clipboardText,QClipboard::Clipboard);
  55. e->accept();
  56. } else QWidget::keyPressEvent(e);
  57. }