errorlist.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. ktigcc - TIGCC IDE for KDE
  3. Copyright (C) 2006-2007 Kevin Kofler
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #include "errorlist.h"
  17. #include <QVariant>
  18. #include <QImage>
  19. #include <QPixmap>
  20. #include <QEvent>
  21. #include <Q3ListView>
  22. #include <QApplication>
  23. #include <QClipboard>
  24. #include <QString>
  25. #include <QFocusEvent>
  26. #include <QKeyEvent>
  27. ErrorList::ErrorList(QWidget* parent, const char* name, Qt::WindowFlags fl)
  28. : QWidget(parent, name, fl)
  29. {
  30. setupUi(this);
  31. }
  32. ErrorList::~ErrorList()
  33. {
  34. }
  35. bool ErrorList::event(QEvent *e)
  36. {
  37. if (e->type()==QEvent::AccelOverride) {
  38. QKeyEvent *ke=static_cast<QKeyEvent*>(e);
  39. if ((ke->key()==Qt::Key_Insert || ke->key()==Qt::Key_C)
  40. && ke->state()==Qt::ControlModifier)
  41. ke->accept();
  42. }
  43. return QWidget::event(e);
  44. }
  45. void ErrorList::keyPressEvent(QKeyEvent *e)
  46. {
  47. if ((e->key()==Qt::Key_Insert || e->key()==Qt::Key_C)
  48. && e->state()==Qt::ControlModifier) {
  49. // Copy selected errors to the clipboard.
  50. Q3ListViewItemIterator lvit(errorListView,Q3ListViewItemIterator::Selected);
  51. Q3ListViewItem *errorItem;
  52. QString clipboardText;
  53. for (errorItem=lvit.current();errorItem;errorItem=(++lvit).current()) {
  54. clipboardText.append(errorItem->text(0));
  55. clipboardText.append('\n');
  56. }
  57. QApplication::clipboard()->setText(clipboardText,QClipboard::Clipboard);
  58. e->accept();
  59. } else QWidget::keyPressEvent(e);
  60. }
  61. void ErrorList::languageChange()
  62. {
  63. retranslateUi(this);
  64. }