toolsdlg.cpp 3.0 KB

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