toolsdlg.ui.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /****************************************************************************
  2. ** ui.h extension file, included from the uic-generated form implementation.
  3. **
  4. ** If you want to add, delete, or rename functions or slots, use
  5. ** Qt Designer to update this file, preserving your code.
  6. **
  7. ** You should not define a constructor or destructor in this file.
  8. ** Instead, write your code in functions called init() and destroy().
  9. ** These will automatically be called by the form's constructor and
  10. ** destructor.
  11. *****************************************************************************/
  12. /*
  13. ktigcc - TIGCC IDE for KDE
  14. Copyright (C) 2006 Kevin Kofler
  15. This program is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 2, or (at your option)
  18. any later version.
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software Foundation,
  25. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #include <klistview.h>
  28. #include "ktigcc.h"
  29. #include "toolprops.h"
  30. void ToolsDialog::init()
  31. {
  32. tempTools=tools;
  33. listView->clear();
  34. listView->setSorting(-1);
  35. Tools::iterator it;
  36. for(it=tempTools.begin(); it!=tempTools.end(); ++it)
  37. new KListViewItem(listView,listView->lastItem(),(*it).title,
  38. (*it).commandLine,(*it).workingDirectory,
  39. (*it).runInTerminal?"Yes":"No");
  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 KListViewItem(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. QListViewItem *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. }