errorlist.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. bool ErrorList::event(QEvent *e)
  28. {
  29. if (e->type()==QEvent::AccelOverride) {
  30. QKeyEvent *ke=static_cast<QKeyEvent*>(e);
  31. if ((ke->key()==Qt::Key_Insert || ke->key()==Qt::Key_C)
  32. && ke->state()==Qt::ControlModifier)
  33. ke->accept();
  34. }
  35. return QWidget::event(e);
  36. }
  37. void ErrorList::keyPressEvent(QKeyEvent *e)
  38. {
  39. if ((e->key()==Qt::Key_Insert || e->key()==Qt::Key_C)
  40. && e->state()==Qt::ControlModifier) {
  41. // Copy selected errors to the clipboard.
  42. Q3ListViewItemIterator lvit(errorListView,Q3ListViewItemIterator::Selected);
  43. Q3ListViewItem *errorItem;
  44. QString clipboardText;
  45. for (errorItem=lvit.current();errorItem;errorItem=(++lvit).current()) {
  46. clipboardText.append(errorItem->text(0));
  47. clipboardText.append('\n');
  48. }
  49. QApplication::clipboard()->setText(clipboardText,QClipboard::Clipboard);
  50. e->accept();
  51. } else QWidget::keyPressEvent(e);
  52. }
  53. /*
  54. * Constructs a ErrorList as a child of 'parent', with the
  55. * name 'name' and widget flags set to 'f'.
  56. */
  57. ErrorList::ErrorList(QWidget* parent, const char* name, Qt::WindowFlags fl)
  58. : QWidget(parent, name, fl)
  59. {
  60. setupUi(this);
  61. }
  62. /*
  63. * Destroys the object and frees any allocated resources
  64. */
  65. ErrorList::~ErrorList()
  66. {
  67. // no need to delete child widgets, Qt does it all for us
  68. }
  69. /*
  70. * Sets the strings of the subwidgets using the current
  71. * language.
  72. */
  73. void ErrorList::languageChange()
  74. {
  75. retranslateUi(this);
  76. }