errorlist.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.h>
  18. #include <qimage.h>
  19. #include <qpixmap.h>
  20. #include <qevent.h>
  21. #include <q3listview.h>
  22. #include <qapplication.h>
  23. #include <qclipboard.h>
  24. #include <qstring.h>
  25. #include <QFocusEvent>
  26. #include <QKeyEvent>
  27. void ErrorList::keyPressEvent(QKeyEvent *e)
  28. {
  29. if ((e->key()==Qt::Key_Insert || e->key()==Qt::Key_C)
  30. && e->state()==Qt::ControlModifier) {
  31. // Copy selected errors to the clipboard.
  32. Q3ListViewItemIterator lvit(errorListView,Q3ListViewItemIterator::Selected);
  33. Q3ListViewItem *errorItem;
  34. QString clipboardText;
  35. for (errorItem=lvit.current();errorItem;errorItem=(++lvit).current()) {
  36. clipboardText.append(errorItem->text(0));
  37. clipboardText.append('\n');
  38. }
  39. QApplication::clipboard()->setText(clipboardText,QClipboard::Clipboard);
  40. e->accept();
  41. } else QWidget::keyPressEvent(e);
  42. }
  43. void ErrorList::focusInEvent(QFocusEvent *e)
  44. {
  45. QWidget::focusInEvent(e);
  46. grabKeyboard();
  47. }
  48. void ErrorList::focusOutEvent(QFocusEvent *e)
  49. {
  50. releaseKeyboard();
  51. QWidget::focusOutEvent(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. }