toolsdlg.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 "toolsdlg.h"
  17. #include <QVariant>
  18. #include <QImage>
  19. #include <QPixmap>
  20. #include <k3listview.h>
  21. #include "ktigcc.h"
  22. #include "toolprops.h"
  23. ToolsDialog::ToolsDialog(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
  24. : QDialog(parent, name, modal, fl)
  25. {
  26. setupUi(this);
  27. tempTools=tools;
  28. listView->clear();
  29. listView->setSorting(-1);
  30. listView->header()->setClickEnabled(false);
  31. listView->header()->setResizeEnabled(false);
  32. Tools::iterator it;
  33. for(it=tempTools.begin(); it!=tempTools.end(); ++it)
  34. new K3ListViewItem(listView,listView->lastItem(),(*it).title,
  35. (*it).commandLine,(*it).workingDirectory,
  36. (*it).runInTerminal?"Yes":"No");
  37. }
  38. ToolsDialog::~ToolsDialog()
  39. {
  40. }
  41. void ToolsDialog::addButton_clicked()
  42. {
  43. toolIndex=-1;
  44. ToolProperties toolProperties;
  45. toolProperties.exec();
  46. if (toolProperties.result()==QDialog::Accepted) {
  47. Tool &newTool=tempTools.last();
  48. new K3ListViewItem(listView,listView->lastItem(),newTool.title,
  49. newTool.commandLine,newTool.workingDirectory,
  50. newTool.runInTerminal?"Yes":"No");
  51. } else listView_selectionChanged(); // set the real toolIndex again
  52. }
  53. void ToolsDialog::editButton_clicked()
  54. {
  55. ToolProperties toolProperties;
  56. toolProperties.exec();
  57. if (toolProperties.result()==QDialog::Accepted) {
  58. Tool &newTool=tempTools[toolIndex];
  59. Q3ListViewItem *toolItem=listView->selectedItem();
  60. toolItem->setText(0,newTool.title);
  61. toolItem->setText(1,newTool.commandLine);
  62. toolItem->setText(2,newTool.workingDirectory);
  63. toolItem->setText(3,newTool.runInTerminal?"Yes":"No");
  64. }
  65. }
  66. void ToolsDialog::removeButton_clicked()
  67. {
  68. tempTools.erase(&tempTools[toolIndex]);
  69. delete listView->selectedItem();
  70. }
  71. void ToolsDialog::listView_selectionChanged()
  72. {
  73. toolIndex=listView->itemIndex(listView->selectedItem());
  74. editButton->setEnabled(toolIndex>=0);
  75. removeButton->setEnabled(toolIndex>=0);
  76. }
  77. void ToolsDialog::accept()
  78. {
  79. tools=tempTools;
  80. QDialog::accept();
  81. }
  82. void ToolsDialog::languageChange()
  83. {
  84. retranslateUi(this);
  85. }