Browse Source

Implement ToolsDialog (but needs ToolProperties to be of use).

git-svn-id: file:///var/svn/tigccpp/trunk@760 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 18 years ago
parent
commit
d170008362
7 changed files with 186 additions and 6 deletions
  1. 3 1
      ktigcc/KTIGCC.prj
  2. 15 0
      ktigcc/ktigcc.h
  3. 5 1
      ktigcc/mainform.ui.h
  4. 3 0
      ktigcc/toolprops.ui
  5. 31 0
      ktigcc/toolprops.ui.h
  6. 51 4
      ktigcc/toolsdlg.ui
  7. 78 0
      ktigcc/toolsdlg.ui.h

+ 3 - 1
ktigcc/KTIGCC.prj

@@ -81,7 +81,9 @@ module.include.files=\
 	callbacks.h\
 	parsing.h\
 	functions.ui.h\
-	newsdlg.ui.h
+	newsdlg.ui.h\
+	toolsdlg.ui.h\
+	toolprops.ui.h
 
 module.source.name=.
 module.source.type=

+ 15 - 0
ktigcc/ktigcc.h

@@ -23,6 +23,8 @@
 #include <qptrlist.h>
 #include <kconfig.h>
 #include <kaboutdata.h>
+#include <qstring.h>
+#include <qvaluevector.h>
 class QAssistantClient;
 class QClipboard;
 class SourceFile;
@@ -48,3 +50,16 @@ extern QClipboard *clipboard;
 extern QPtrList<SourceFile> sourceFiles;
 extern tprSettings settings;
 extern tprLibOpts libopts;
+
+struct Tool {
+  Tool() : title(), commandLine(), workingDirectory(), runInTerminal(false) {}
+  Tool(const QString &t, const QString &c, const QString &w, bool r) :
+    title(t), commandLine(c), workingDirectory(w), runInTerminal(r) {}
+  QString title;
+  QString commandLine;
+  QString workingDirectory;
+  bool runInTerminal;
+};
+typedef QValueVector<Tool> Tools;
+extern Tools tools, tempTools;
+extern int toolIndex;

+ 5 - 1
ktigcc/mainform.ui.h

@@ -99,6 +99,7 @@
 #include "callbacks.h"
 #include "parsing.h"
 #include "functions.h"
+#include "toolsdlg.h"
 #include "newsdlg.h"
 
 using std::puts;
@@ -409,6 +410,8 @@ static unsigned findCurrentLine;
 QPtrList<SourceFile> sourceFiles;
 static QPopupMenu *findFunctionsPopup;
 bool have_usb;
+Tools tools, tempTools;
+int toolIndex;
 
 class DnDListView : public KListView {
   private:
@@ -4824,7 +4827,8 @@ void MainForm::debugReset()
 
 void MainForm::toolsConfigure()
 {
-  
+  ToolsDialog toolsDialog(this);
+  toolsDialog.exec();
 }
 
 void MainForm::helpDocumentation()

+ 3 - 0
ktigcc/toolprops.ui

@@ -199,6 +199,9 @@
         <slot>reject()</slot>
     </connection>
 </connections>
+<includes>
+    <include location="local" impldecl="in implementation">toolprops.ui.h</include>
+</includes>
 <pixmapinproject/>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>

+ 31 - 0
ktigcc/toolprops.ui.h

@@ -0,0 +1,31 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** Qt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+/*
+   ktigcc - TIGCC IDE for KDE
+
+   Copyright (C) 2006 Kevin Kofler
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+*/

+ 51 - 4
ktigcc/toolsdlg.ui

@@ -25,7 +25,7 @@
                     <string>Title</string>
                 </property>
                 <property name="clickable">
-                    <bool>true</bool>
+                    <bool>false</bool>
                 </property>
                 <property name="resizable">
                     <bool>true</bool>
@@ -36,7 +36,7 @@
                     <string>Command Line</string>
                 </property>
                 <property name="clickable">
-                    <bool>true</bool>
+                    <bool>false</bool>
                 </property>
                 <property name="resizable">
                     <bool>true</bool>
@@ -47,7 +47,7 @@
                     <string>Working Directory</string>
                 </property>
                 <property name="clickable">
-                    <bool>true</bool>
+                    <bool>false</bool>
                 </property>
                 <property name="resizable">
                     <bool>true</bool>
@@ -58,7 +58,7 @@
                     <string>Terminal</string>
                 </property>
                 <property name="clickable">
-                    <bool>true</bool>
+                    <bool>false</bool>
                 </property>
                 <property name="resizable">
                     <bool>true</bool>
@@ -67,6 +67,12 @@
             <property name="name">
                 <cstring>listView</cstring>
             </property>
+            <property name="allColumnsShowFocus">
+                <bool>true</bool>
+            </property>
+            <property name="itemsMovable">
+                <bool>false</bool>
+            </property>
         </widget>
         <widget class="QLayoutWidget">
             <property name="name">
@@ -91,6 +97,9 @@
                     <property name="name">
                         <cstring>editButton</cstring>
                     </property>
+                    <property name="enabled">
+                        <bool>false</bool>
+                    </property>
                     <property name="text">
                         <string>&amp;Edit...</string>
                     </property>
@@ -102,6 +111,9 @@
                     <property name="name">
                         <cstring>removeButton</cstring>
                     </property>
+                    <property name="enabled">
+                        <bool>false</bool>
+                    </property>
                     <property name="text">
                         <string>&amp;Remove</string>
                     </property>
@@ -171,7 +183,42 @@
         <receiver>ToolsDialog</receiver>
         <slot>reject()</slot>
     </connection>
+    <connection>
+        <sender>addButton</sender>
+        <signal>clicked()</signal>
+        <receiver>ToolsDialog</receiver>
+        <slot>addButton_clicked()</slot>
+    </connection>
+    <connection>
+        <sender>editButton</sender>
+        <signal>clicked()</signal>
+        <receiver>ToolsDialog</receiver>
+        <slot>editButton_clicked()</slot>
+    </connection>
+    <connection>
+        <sender>removeButton</sender>
+        <signal>clicked()</signal>
+        <receiver>ToolsDialog</receiver>
+        <slot>removeButton_clicked()</slot>
+    </connection>
+    <connection>
+        <sender>listView</sender>
+        <signal>selectionChanged()</signal>
+        <receiver>ToolsDialog</receiver>
+        <slot>listView_selectionChanged()</slot>
+    </connection>
 </connections>
+<includes>
+    <include location="local" impldecl="in implementation">toolsdlg.ui.h</include>
+</includes>
+<slots>
+    <slot>init()</slot>
+    <slot>addButton_clicked()</slot>
+    <slot>editButton_clicked()</slot>
+    <slot>removeButton_clicked()</slot>
+    <slot>listView_selectionChanged()</slot>
+    <slot>accept()</slot>
+</slots>
 <pixmapinproject/>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>

+ 78 - 0
ktigcc/toolsdlg.ui.h

@@ -0,0 +1,78 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** Qt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+/*
+   ktigcc - TIGCC IDE for KDE
+
+   Copyright (C) 2006 Kevin Kofler
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+*/
+
+#include <klistview.h>
+#include "ktigcc.h"
+#include "toolprops.h"
+
+void ToolsDialog::init()
+{
+  tempTools=tools;
+  listView->setSorting(-1);
+  Tools::iterator it;
+  for(it=tempTools.begin(); it!=tempTools.end(); ++it)
+    new KListViewItem(listView,(*it).title,(*it).commandLine,
+                      (*it).workingDirectory,(*it).runInTerminal?"Yes":"No");
+}
+
+void ToolsDialog::addButton_clicked()
+{
+  toolIndex=-1;
+  ToolProperties toolProperties;
+  toolProperties.exec();
+  listView_selectionChanged(); // set the real toolIndex again
+}
+
+void ToolsDialog::editButton_clicked()
+{
+  ToolProperties toolProperties;
+  toolProperties.exec();
+}
+
+void ToolsDialog::removeButton_clicked()
+{
+  tempTools.erase(&tempTools[toolIndex]);
+  delete listView->selectedItem();
+}
+
+void ToolsDialog::listView_selectionChanged()
+{
+  toolIndex=listView->itemIndex(listView->selectedItem());
+  editButton->setEnabled(toolIndex>=0);
+  removeButton->setEnabled(toolIndex>=0);
+}
+
+void ToolsDialog::accept()
+{
+  tools=tempTools;
+  QDialog::accept();
+}