Patch for select main program

DUCLOS Andre shirka at wanadoo.fr
Tue May 13 02:17:08 UTC 2003


Hi,

(My english is poor..)

A path for improve the select main program.

Test please.

Thanks.



Index: lib/project/runoptionswidget.cpp
===================================================================
RCS file: /home/kde/kdevelop/lib/project/runoptionswidget.cpp,v
retrieving revision 1.10
diff -u -r1.10 runoptionswidget.cpp
--- lib/project/runoptionswidget.cpp	2 Apr 2003 16:38:28 -0000	1.10
+++ lib/project/runoptionswidget.cpp	11 May 2003 15:23:02 -0000
@@ -18,6 +18,7 @@
 #include <qlistview.h>
 #include <qgroupbox.h>
 #include <qcheckbox.h>
+#include <kdebug.h>

 #include "domutil.h"
 #include "environmentvariableswidget.h"
@@ -54,17 +55,46 @@

 void RunOptionsWidget::browseMainProgram()
 {
-  QString path = KFileDialog::getOpenFileName(m_projectDirectory,
-                               i18n("*|All Files"),
-                               this,
-                               i18n("Select main program
executable."));
-
-  if (path.find(m_projectDirectory)==0)
-  {
-    path.remove(0,m_projectDirectory.length()+1);
-    path = "./" + path;
-  }
-  mainprogram_edit->setText(path);
+	KFileDialog *dlg = new KFileDialog(m_projectDirectory, QString::null,
this, QString::null, true);
+	QStringList filters;
+	filters << "application/x-executable"
+		<< "application/x-shellscript"
+		<< "application/x-perl"
+		<< "application/x-python";
+	dlg->setMimeFilter(filters);
+	dlg->setCaption(i18n("Select main program executable."));
+	kdDebug(9000) << "Project dir : " << m_projectDirectory << endl;
+	kdDebug(9000) << "Main program : " << mainprogram_edit->text() <<
endl;
+	QString path = mainprogram_edit->text().stripWhiteSpace();
+	if (!path.isEmpty())
+	{
+		QString dir;
+		if ((path.length() > 2) && (path.left(2) == "./"))
+			path = path.mid(2);
+		int pos = path.findRev("/");
+		if (path.left(1) != "/")
+			dir = m_projectDirectory + "/" + path.left(pos);
+		else
+			dir = path.left(pos);
+		dlg->setURL(dir);
+		dlg->setSelection(path.mid(pos + 1));
+		kdDebug(9000) << " with path : " << dir << endl;
+		kdDebug(9000) << " with name : " << path.mid(pos + 1) << endl;
+	}
+	if (dlg->exec())
+	{
+		path = dlg->selectedFile().stripWhiteSpace();
+		if (!path.isEmpty())
+		{
+			if (path.find(m_projectDirectory)==0)
+			{
+    				path.remove(0,m_projectDirectory.length()+1);
+    				path = "./" + path;
+  			}
+  			mainprogram_edit->setText(path);
+		}
+	}
+	delete dlg;
 }
 
 #include "runoptionswidget.moc"



-- 
DUCLOS Andre <duclos at shirka.dyndns.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20030513/2107e4da/attachment.sig>


More information about the KDevelop-devel mailing list