summaryrefslogtreecommitdiffstats
path: root/buildtools/script
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /buildtools/script
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'buildtools/script')
-rw-r--r--buildtools/script/Makefile.am26
-rw-r--r--buildtools/script/README.dox48
-rw-r--r--buildtools/script/kdevscriptproject.desktop87
-rw-r--r--buildtools/script/kdevscriptproject.rc12
-rw-r--r--buildtools/script/scriptnewfiledlg.cpp119
-rw-r--r--buildtools/script/scriptnewfiledlg.h39
-rw-r--r--buildtools/script/scriptoptionswidget.cpp69
-rw-r--r--buildtools/script/scriptoptionswidget.h35
-rw-r--r--buildtools/script/scriptoptionswidgetbase.ui155
-rw-r--r--buildtools/script/scriptprojectpart.cpp446
-rw-r--r--buildtools/script/scriptprojectpart.h69
11 files changed, 1105 insertions, 0 deletions
diff --git a/buildtools/script/Makefile.am b/buildtools/script/Makefile.am
new file mode 100644
index 00000000..73cee869
--- /dev/null
+++ b/buildtools/script/Makefile.am
@@ -0,0 +1,26 @@
+# Here resides the script project part.
+# This is a generic part for various scripting languages that simply
+# includes all files from the project directory without managing
+# them. If a language needs more specific features, it deserves
+# its own part (or the respective features should be added to the
+# language support part)
+
+INCLUDES = -I$(top_srcdir)/buildtools/lib/base \
+ -I$(top_srcdir)/buildtools/lib/widgets -I$(top_srcdir)/lib/interfaces \
+ -I$(top_srcdir)/lib/interfaces/extensions -I$(top_srcdir)/lib/interfaces/external -I$(top_srcdir)/lib/util \
+ -I$(top_srcdir)/lib/external_interfaces $(all_includes)
+
+kde_module_LTLIBRARIES = libkdevscriptproject.la
+libkdevscriptproject_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkdevscriptproject_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \
+ $(top_builddir)/buildtools/lib/widgets/libkdevbuildtoolswidgets.la $(top_builddir)/buildtools/lib/base/libkdevbuildbase.la
+
+libkdevscriptproject_la_SOURCES = scriptprojectpart.cpp scriptoptionswidget.cpp scriptoptionswidgetbase.ui scriptnewfiledlg.cpp
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)
+service_DATA = kdevscriptproject.desktop
+
+rcdir = $(kde_datadir)/kdevscriptproject
+rc_DATA = kdevscriptproject.rc
diff --git a/buildtools/script/README.dox b/buildtools/script/README.dox
new file mode 100644
index 00000000..a7a19983
--- /dev/null
+++ b/buildtools/script/README.dox
@@ -0,0 +1,48 @@
+/** \class ScriptProjectPart
+This is the script build tool part
+Put a more detailed description of your part in these lines. It can span
+over several lines. You can even use some html commands in these lines like:
+<code>This is code</code>, html links <a href="http://somelocation">link text</a>,
+and images.
+
+\authors <a href="mailto:bernd AT kdevelop.org">Bernd Gehrmann</a>
+
+\unmaintained This part is currently un-maintained
+
+\deprecated This class is deprecated, use GenericProjectPart (buildtools/generic) instead.
+
+\feature Describe the first feature
+\feature Describe the second feature
+...
+\feature Describe the last feature
+
+\bug Describe a the 1st bug that you know of, but probably hasn't been reported yet.
+..
+\bug Describe a the nth bug that you know of, but probably hasn't been reported yet.
+
+\requirement Describe a the 1st requirement of your part.
+\requirement Describe a the 2nd requirement of your part.
+...
+\requirement Describe a the nth requirement of your part.
+
+\todo Describe a the 1st TODO of your part.
+\todo Describe a the 2nd TODO of your part.
+...
+\todo Describe a the nth TODO of your part.
+
+\faq <b>First frequenly asked question about your part ?</b> Answer.
+\faq <b>Second frequenly asked question about your part ?</b> Answer.
+...
+\faq <b>Last frequenly asked question about your part ?</b> Answer.
+
+\note First note text.
+\note Second note text.
+...
+\note Last note text.
+
+\warning First warning text.
+\warning Second warning text.
+...
+\warning Last warning text.
+
+*/
diff --git a/buildtools/script/kdevscriptproject.desktop b/buildtools/script/kdevscriptproject.desktop
new file mode 100644
index 00000000..1200f9ba
--- /dev/null
+++ b/buildtools/script/kdevscriptproject.desktop
@@ -0,0 +1,87 @@
+[Desktop Entry]
+Type=Service
+Exec=blubb
+Comment=Scripting Language Project
+Comment[ca]=Projecte de llenguatge escrivint scripts
+Comment[da]=Scriptsprog-projekt
+Comment[de]=Skriptsprachen-Projekt für KDevelop
+Comment[el]=Έργο γλώσσας γραφής σεναρίων
+Comment[es]=Proyecto de lenguaje de guiones
+Comment[et]=Skriptikeele projekt
+Comment[eu]=Script lengoai proiektua
+Comment[fa]=پروژۀ زبان دست‌نوشته‌ای
+Comment[fr]=Projet avec les langages de scripts
+Comment[ga]=Tionscadal i dTeanga Scriptithe
+Comment[gl]=Proxecto de linguaxe de scripting
+Comment[hi]=स्क्रिप्टिंग भाषा परियोजना
+Comment[hu]=Szkript-projekt
+Comment[is]=Skriftumálsverkefni
+Comment[it]=Progetto con linguaggio di scripting
+Comment[ja]=スクリプト言語プロジェクト
+Comment[ms]=Projek Bahasa Penskrip
+Comment[nds]=Skriptspraak-Projekt
+Comment[ne]=स्क्रिप्टिङ भाषा परियोजना
+Comment[nl]=Scripttaal-project
+Comment[pl]=Projekt w języku skryptowym
+Comment[pt]=Projecto de uma Linguagem de 'Scripting'
+Comment[pt_BR]=Projeto de Linguagem de Script
+Comment[ru]=Проект скриптового языка
+Comment[sk]=Skriptovací jazyk projekt
+Comment[sl]=Projekt skriptnega jezika
+Comment[sr]=Пројекат скриптног језика
+Comment[sr@Latn]=Projekat skriptnog jezika
+Comment[sv]=Projekt för skriptspråk
+Comment[ta]=ஸ்கிரிப்டிங் மொழி பிராஜக்ட்
+Comment[tg]=Лоиҳа бо забони ғарчкунӣ
+Comment[tr]=Betik Dili Projesi
+Comment[zh_CN]=脚本语言工程
+Comment[zh_TW]=文稿語言專案
+Name=KDevScriptProject
+Name[da]=KDevelop script-projekt
+Name[de]=Skriptsprachen-Projekt (KDevelop)
+Name[hi]=के-डेव-स्क्रिप्ट-परियोजना
+Name[nds]=Skriptspraak-Projekt (KDevelop)
+Name[ne]=केडीई विकास स्क्रिप्ट परियोजना
+Name[pl]=KDevProjektSkrypt
+Name[sk]=KDevSkriptProjekt
+Name[sv]=KDevelop skriptprojekt
+Name[ta]=கெடெவ் ஸ்கிரிப்ட் பிராஜக்ட்
+Name[tg]=KDevЛоиҳаи скрипт
+Name[zh_TW]=KDevelop 文稿專案
+GenericName=Scripting Language Project
+GenericName[ca]=Projecte de llenguatge escrivint scripts
+GenericName[da]=Scriptsprog-projekt
+GenericName[de]=Skriptsprachen-Projekt
+GenericName[el]=Έργο γλώσσας γραφής σεναρίων
+GenericName[es]=Proyecto de lenguaje de guiones
+GenericName[et]=Skriptikeele projekt
+GenericName[eu]=Script lengoaia proiektua
+GenericName[fa]=پروژۀ زبان دست‌نوشته‌ای
+GenericName[fr]=Projet avec les langages de scripts
+GenericName[ga]=Tionscadal i dTeanga Scriptithe
+GenericName[gl]=Proxecto de linguaxe de scripting
+GenericName[hi]=स्क्रिप्टिंग भाषा परियोजना
+GenericName[hu]=Szkript-projekt
+GenericName[it]=Progetto con linguaggio di scripting
+GenericName[ja]=スクリプト言語プロジェクト
+GenericName[nds]=Skriptspraak-Projekt
+GenericName[ne]=स्क्रिप्टिङ भाषा परियोजना
+GenericName[nl]=Scripttaal-project
+GenericName[pl]=Projekt w języku skryptowym
+GenericName[pt]=Projecto de uma Linguagem de 'Scripting'
+GenericName[pt_BR]=Projeto de Linguagem de Script
+GenericName[ru]=Проект скриптового языка
+GenericName[sk]=Skriptovací jazyk projekt
+GenericName[sl]=Projekt skriptnega jezika
+GenericName[sr]=Пројекат скриптног језика
+GenericName[sr@Latn]=Projekat skriptnog jezika
+GenericName[sv]=Projekt för skriptspråk
+GenericName[ta]=ஸ்கிரிப்டிங் மொழி பிராஜக்ட்
+GenericName[tg]=Лоиҳа бо забони ғарчкунӣ
+GenericName[tr]=Betik Dili Projesi
+GenericName[zh_CN]=脚本语言工程
+GenericName[zh_TW]=文稿語言專案
+ServiceTypes=KDevelop/Project
+Icon=kdevelop
+X-KDE-Library=libkdevscriptproject
+X-KDevelop-Version=5
diff --git a/buildtools/script/kdevscriptproject.rc b/buildtools/script/kdevscriptproject.rc
new file mode 100644
index 00000000..651b10b4
--- /dev/null
+++ b/buildtools/script/kdevscriptproject.rc
@@ -0,0 +1,12 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="KDevCustomProject" version="2">
+<MenuBar>
+ <Menu name="file" >
+ <Action name="file_newfile" />
+ </Menu>
+ <Menu name="project" >
+ <Action name="rescan" />
+ </Menu>
+</MenuBar>
+</kpartgui>
+
diff --git a/buildtools/script/scriptnewfiledlg.cpp b/buildtools/script/scriptnewfiledlg.cpp
new file mode 100644
index 00000000..336187d3
--- /dev/null
+++ b/buildtools/script/scriptnewfiledlg.cpp
@@ -0,0 +1,119 @@
+/***************************************************************************
+ * Copyright (C) 2001-2002 by Bernd Gehrmann *
+ * bernd@kdevelop.org *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "scriptnewfiledlg.h"
+
+#include <qcheckbox.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <klineedit.h>
+#include <qpushbutton.h>
+#include <kbuttonbox.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstdguiitem.h>
+#include <kdeversion.h>
+
+#include "scriptprojectpart.h"
+#include "filetemplate.h"
+
+
+ScriptNewFileDialog::ScriptNewFileDialog(ScriptProjectPart *part,
+ QWidget *parent, const char *name)
+ : QDialog(parent, name, true)
+{
+ setCaption(i18n("New File"));
+
+ QLabel *filename_label = new QLabel(i18n("&File name:"), this);
+
+ filename_edit = new KLineEdit(this);
+ filename_edit->setFocus();
+ filename_label->setBuddy(this);
+ QFontMetrics fm(filename_edit->fontMetrics());
+ filename_edit->setMinimumWidth(fm.width('X')*35);
+
+ usetemplate_box = new QCheckBox(i18n("&Use file template"), this);
+ usetemplate_box->setChecked(true);
+
+ QFrame *frame = new QFrame(this);
+ frame->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+
+ KButtonBox *buttonbox = new KButtonBox(this);
+ buttonbox->addStretch();
+ QPushButton *ok_button = buttonbox->addButton(KStdGuiItem::ok());
+ QPushButton *cancel_button = buttonbox->addButton(KStdGuiItem::cancel());
+ ok_button->setDefault(true);
+ connect( ok_button, SIGNAL(clicked()), this, SLOT(accept()) );
+ connect( cancel_button, SIGNAL(clicked()), this, SLOT(reject()) );
+ buttonbox->layout();
+
+ QVBoxLayout *layout = new QVBoxLayout(this, 10, 4);
+ layout->addWidget(filename_label);
+ layout->addWidget(filename_edit);
+ layout->addWidget(usetemplate_box);
+ layout->addWidget(frame, 0);
+ layout->addWidget(buttonbox, 0);
+
+ m_part = part;
+}
+
+
+ScriptNewFileDialog::~ScriptNewFileDialog()
+{}
+
+
+void ScriptNewFileDialog::accept()
+{
+ QString fileName = filename_edit->text();
+ if (fileName.find('/') != -1) {
+ KMessageBox::sorry(this, i18n("Please enter the file name without '/' and so on."));
+ return;
+ }
+
+ KDevProject *project = m_part->project();
+ if (!project->activeDirectory().isEmpty())
+ fileName.prepend(project->activeDirectory() + "/");
+ QString destpath = project->projectDirectory() + "/" + fileName;
+
+ if (QFileInfo(destpath).exists()) {
+ KMessageBox::sorry(this, i18n("A file with this name already exists."));
+ return;
+ }
+
+ bool success = false;
+
+ if (usetemplate_box->isChecked()) {
+ QString extension = QFileInfo(destpath).extension();
+ if (!FileTemplate::exists(m_part, extension)) {
+ KMessageBox::sorry(this, i18n("A file template for this extension does not exist."));
+ return;
+ }
+ success = FileTemplate::copy(m_part, extension, destpath);
+ } else {
+ QFile f(destpath);
+ success = f.open(IO_WriteOnly);
+ if (success)
+ f.close();
+ }
+
+ if (!success)
+ KMessageBox::sorry(this, i18n("Could not create the new file."));
+
+ kdDebug(9015) << "AddFile1: " << fileName << endl;
+ m_part->addFile(fileName);
+
+ QDialog::accept();
+}
+
+#include "scriptnewfiledlg.moc"
diff --git a/buildtools/script/scriptnewfiledlg.h b/buildtools/script/scriptnewfiledlg.h
new file mode 100644
index 00000000..b3c73713
--- /dev/null
+++ b/buildtools/script/scriptnewfiledlg.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * Copyright (C) 2001-2002 by Bernd Gehrmann *
+ * bernd@kdevelop.org *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SCRIPTNEWFILEDLG_H_
+#define _SCRIPTNEWFILEDLG_H_
+
+#include <qdialog.h>
+
+class QCheckBox;
+class KLineEdit;
+class ScriptProjectPart;
+
+
+class ScriptNewFileDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ScriptNewFileDialog( ScriptProjectPart *part, QWidget *parent=0, const char *name=0 );
+ ~ScriptNewFileDialog();
+
+protected:
+ virtual void accept();
+
+private:
+ QCheckBox *usetemplate_box;
+ KLineEdit *filename_edit;
+ ScriptProjectPart *m_part;
+};
+
+#endif
diff --git a/buildtools/script/scriptoptionswidget.cpp b/buildtools/script/scriptoptionswidget.cpp
new file mode 100644
index 00000000..c1660b00
--- /dev/null
+++ b/buildtools/script/scriptoptionswidget.cpp
@@ -0,0 +1,69 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Bernd Gehrmann *
+ * bernd@kdevelop.org *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "scriptoptionswidget.h"
+
+#include <qcheckbox.h>
+#include <klineedit.h>
+#include <qradiobutton.h>
+#include <qtabwidget.h>
+#include "domutil.h"
+#include "kdevlanguagesupport.h"
+
+
+ScriptOptionsWidget::ScriptOptionsWidget(KDevPlugin *part,
+ QWidget *parent, const char *name)
+ : ScriptOptionsWidgetBase(parent, name)
+{
+ m_part = part;
+
+ QDomDocument &dom = *m_part->projectDom();
+
+ QString includepatterns
+ = DomUtil::readEntry(dom, "/kdevscriptproject/general/includepatterns");
+
+ if (includepatterns.isNull() && part->languageSupport()){
+ QStringList includepatternList;
+ KMimeType::List list = part->languageSupport()->mimeTypes();
+ KMimeType::List::Iterator it = list.begin();
+ while( it != list.end() ){
+ includepatternList += (*it)->patterns();
+ ++it;
+ }
+ includepatterns = includepatternList.join( "," );
+ }
+
+ QString excludepatterns
+ = DomUtil::readEntry(dom, "/kdevscriptproject/general/excludepatterns");
+ if (excludepatterns.isNull())
+ excludepatterns = "*~";
+
+ includepatterns_edit->setText(includepatterns);
+ excludepatterns_edit->setText(excludepatterns);
+}
+
+
+ScriptOptionsWidget::~ScriptOptionsWidget()
+{}
+
+
+void ScriptOptionsWidget::accept()
+{
+ QDomDocument &dom = *m_part->projectDom();
+
+ QString includepatterns = includepatterns_edit->text();
+ QString excludepatterns = excludepatterns_edit->text();
+
+ DomUtil::writeEntry(dom, "/kdevscriptproject/general/includepatterns", includepatterns);
+ DomUtil::writeEntry(dom, "/kdevscriptproject/general/excludepatterns", excludepatterns);
+}
+
+#include "scriptoptionswidget.moc"
diff --git a/buildtools/script/scriptoptionswidget.h b/buildtools/script/scriptoptionswidget.h
new file mode 100644
index 00000000..c33d099d
--- /dev/null
+++ b/buildtools/script/scriptoptionswidget.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * Copyright (C) 2002 by Bernd Gehrmann *
+ * bernd@kdevelop.org *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SCRIPTPROJECTOPTIONSWIDGET_H_
+#define _SCRIPTPROJECTOPTIONSWIDGET_H_
+
+#include "scriptoptionswidgetbase.h"
+
+class KDevPlugin;
+
+
+class ScriptOptionsWidget : public ScriptOptionsWidgetBase
+{
+ Q_OBJECT
+
+public:
+ ScriptOptionsWidget( KDevPlugin *part, QWidget *parent=0, const char *name=0 );
+ ~ScriptOptionsWidget();
+
+public slots:
+ void accept();
+
+private:
+ KDevPlugin *m_part;
+};
+
+#endif
diff --git a/buildtools/script/scriptoptionswidgetbase.ui b/buildtools/script/scriptoptionswidgetbase.ui
new file mode 100644
index 00000000..3a8f7b99
--- /dev/null
+++ b/buildtools/script/scriptoptionswidgetbase.ui
@@ -0,0 +1,155 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>ScriptOptionsWidgetBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>script_project_options</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>482</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Script Project Options</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>includepatterns_label</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Include files into the project with the following patterns:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>includepatterns_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Minimum</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>includepatterns_edit</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Minimum</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>excludepatterns_label</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Exclude the following patterns:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>excludepatterns_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout2_2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer4_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Minimum</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>excludepatterns_edit</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer6</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<includes>
+ <include location="global" impldecl="in implementation">kdialog.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+</UI>
diff --git a/buildtools/script/scriptprojectpart.cpp b/buildtools/script/scriptprojectpart.cpp
new file mode 100644
index 00000000..ff560f23
--- /dev/null
+++ b/buildtools/script/scriptprojectpart.cpp
@@ -0,0 +1,446 @@
+/***************************************************************************
+ * Copyright (C) 2001-2002 by Bernd Gehrmann *
+ * bernd@kdevelop.org *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "scriptprojectpart.h"
+
+#include <qdir.h>
+#include <qregexp.h>
+#include <qstringlist.h>
+#include <qvaluestack.h>
+#include <qvbox.h>
+#include <qwhatsthis.h>
+#include <kaction.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdevgenericfactory.h>
+#include <kdevcreatefile.h>
+#include <kdirwatch.h>
+
+#include "domutil.h"
+#include "kdevcore.h"
+#include "kdevmainwindow.h"
+#include "kdevpartcontroller.h"
+#include "kdevlanguagesupport.h"
+#include "scriptoptionswidget.h"
+#include "scriptnewfiledlg.h"
+#include "kdevplugininfo.h"
+
+typedef KDevGenericFactory<ScriptProjectPart> ScriptProjectFactory;
+static const KDevPluginInfo data("kdevscriptproject");
+K_EXPORT_COMPONENT_FACTORY( libkdevscriptproject, ScriptProjectFactory( data ) )
+
+ScriptProjectPart::ScriptProjectPart(QObject *parent, const char *name, const QStringList &)
+ : KDevBuildTool(&data, parent, name ? name : "ScriptProjectPart")
+{
+ setInstance(ScriptProjectFactory::instance());
+
+ setXMLFile("kdevscriptproject.rc");
+
+ // only create new file action if file creation part not available
+ if (!extension<KDevCreateFile>("KDevelop/CreateFile")) {
+ KAction *action;
+ action = new KAction( i18n("New File..."), 0,
+ this, SLOT(slotNewFile()),
+ actionCollection(), "file_newfile" );
+ action->setWhatsThis( i18n("<b>New file</b><p>Creates a new file.") );
+ action->setToolTip( i18n("Create a new file") );
+ }
+ new KAction( i18n("Rescan Project"), 0, CTRL+ALT+Key_R,
+ this, SLOT(rescan()),
+ actionCollection(), "rescan" );
+
+ connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)),
+ this, SLOT(projectConfigWidget(KDialogBase*)) );
+}
+
+
+ScriptProjectPart::~ScriptProjectPart()
+{}
+
+
+void ScriptProjectPart::projectConfigWidget(KDialogBase *dlg)
+{
+ QVBox *vbox;
+ vbox = dlg->addVBoxPage(i18n("Script Project Options"), i18n("Script Project Options"), BarIcon("kdevelop", KIcon::SizeMedium));
+ ScriptOptionsWidget *w = new ScriptOptionsWidget(this, vbox);
+ connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) );
+}
+
+
+/**
+ * @todo This should really be merged with FileTreeWidget::matchesHidePattern()
+ * and put in its own class. Currently this is repeated in scriptprojectpart.cpp, pascalproject_part.cpp, adaproject_part.cpp
+ */
+static bool matchesPattern(const QString &fileName, const QStringList &patternList)
+{
+ QStringList::ConstIterator it;
+ for (it = patternList.begin(); it != patternList.end(); ++it) {
+ QRegExp re(*it, true, true);
+ if (re.search(fileName) == 0 && re.matchedLength() == (int)fileName.length())
+ return true;
+ }
+
+ return false;
+}
+
+
+void ScriptProjectPart::openProject(const QString &dirName, const QString &projectName)
+{
+ if (!languageSupport())
+ kdDebug(9015) << "ScriptProjectPart::openProject: no language support found!" << endl;
+
+ m_projectDirectory = dirName;
+ m_projectName = projectName;
+
+ QDomDocument &dom = *projectDom();
+
+ // Set the default directory radio to "executable"
+ if (DomUtil::readEntry(dom, "/kdevscriptproject/run/directoryradio") == "" ) {
+ DomUtil::writeEntry(dom, "/kdevscriptproject/run/directoryradio", "executable");
+ }
+
+ // Put all files from all subdirectories into file list
+ QValueStack<QString> s;
+ int prefixlen = m_projectDirectory.length()+1;
+ s.push(m_projectDirectory);
+
+ QDir dir;
+ do {
+ dir.setPath(s.pop());
+ kdDebug(9015) << "Examining: " << dir.path() << endl;
+ const QFileInfoList *dirEntries = dir.entryInfoList();
+ if ( dirEntries )
+ {
+ QPtrListIterator<QFileInfo> it(*dirEntries);
+ for (; it.current(); ++it) {
+ QString fileName = it.current()->fileName();
+ if (fileName == "." || fileName == "..")
+ continue;
+ QString path = it.current()->absFilePath();
+ if (it.current()->isDir()) {
+ //do not follow symlinks which point to the themselves
+ if (it.current()->isSymLink())
+ {
+ QString symLink = it.current()->readLink();
+ if ((symLink == path) || (symLink == "./"))
+ continue;
+ } else if (canAddDirectoryToProject(path)) {
+ kdDebug(9015) << "Pushing: " << path << endl;
+ s.push(path);
+ }
+ }
+ else {
+ if (canAddToProject(path))
+ m_sourceFiles.append(path.mid(prefixlen));
+ }
+ }
+ }
+ } while (!s.isEmpty());
+
+ KDevProject::openProject( dirName, projectName );
+}
+
+
+void ScriptProjectPart::closeProject()
+{
+}
+
+
+QString ScriptProjectPart::projectDirectory() const
+{
+ return m_projectDirectory;
+}
+
+
+QString ScriptProjectPart::buildDirectory() const
+{
+ return m_projectDirectory;
+}
+
+QString ScriptProjectPart::projectName() const
+{
+ return m_projectName;
+}
+
+
+/** Retuns a PairList with the run environment variables */
+DomUtil::PairList ScriptProjectPart::runEnvironmentVars() const
+{
+ return DomUtil::readPairListEntry(*projectDom(), "/kdevscriptproject/run/envvars", "envvar", "name", "value");
+}
+
+
+/** Retuns the currently selected run directory
+ * The returned string can be:
+ * if run/directoryradio == executable
+ * The directory where the executable is
+ * if run/directoryradio == build
+ * The directory where the executable is relative to build directory
+ * if run/directoryradio == custom
+ * The custom directory absolute path
+ */
+QString ScriptProjectPart::runDirectory() const
+{
+ QString cwd = defaultRunDirectory("kdevscriptproject");
+ if (cwd.isEmpty())
+ cwd = buildDirectory();
+ return cwd;
+}
+
+
+/** Retuns the currently selected main program
+ * The returned string can be:
+ * if run/directoryradio == executable
+ * The executable name
+ * if run/directoryradio == build
+ * The path to executable relative to build directory
+ * if run/directoryradio == custom or relative == false
+ * The absolute path to executable
+ */
+QString ScriptProjectPart::mainProgram() const
+{
+ QDomDocument * dom = projectDom();
+
+ if ( !dom ) return QString();
+
+ QString DomMainProgram = DomUtil::readEntry( *dom, "/kdevscriptproject/run/mainprogram");
+
+ if ( DomMainProgram.isEmpty() ) return QString();
+
+ if ( DomMainProgram.startsWith("/") ) // assume absolute path
+ {
+ return DomMainProgram;
+ }
+ else // assume project relative path
+ {
+ return projectDirectory() + "/" + DomMainProgram;
+ }
+
+ return QString();
+}
+
+/** Retuns a QString with the debug command line arguments */
+QString ScriptProjectPart::debugArguments() const
+{
+ return DomUtil::readEntry(*projectDom(), "/kdevscriptproject/run/globaldebugarguments");
+}
+
+
+/** Retuns a QString with the run command line arguments */
+QString ScriptProjectPart::runArguments() const
+{
+ return DomUtil::readEntry(*projectDom(), "/kdevscriptproject/run/programargs");
+}
+
+
+QString ScriptProjectPart::activeDirectory() const
+{
+ QDomDocument &dom = *projectDom();
+
+ return DomUtil::readEntry(dom, "/kdevscriptproject/general/activedir");
+}
+
+
+QStringList ScriptProjectPart::allFiles() const
+{
+/* QStringList res;
+
+ QStringList::ConstIterator it;
+ for (it = m_sourceFiles.begin(); it != m_sourceFiles.end(); ++it)
+ res += (m_projectDirectory + "/" + (*it));
+
+ return res;*/
+
+ // return all files relative to the project directory!
+ return m_sourceFiles;
+}
+
+void ScriptProjectPart::addFile(const QString &fileName)
+{
+ kdDebug(9015) << "AddFile2" << fileName << endl;
+
+ QStringList fileList;
+ fileList.append ( fileName );
+
+ this->addFiles ( fileList );
+}
+
+void ScriptProjectPart::addFiles ( const QStringList& fileList )
+{
+ QStringList::ConstIterator it;
+
+ for ( it = fileList.begin(); it != fileList.end(); ++it )
+ {
+ m_sourceFiles.append ( ( *it ) );
+ }
+
+ emit addedFilesToProject ( fileList );
+}
+
+void ScriptProjectPart::removeFile(const QString &fileName)
+{
+ QStringList fileList;
+ fileList.append ( fileName );
+
+ this->addFiles ( fileList );
+}
+
+void ScriptProjectPart::removeFiles ( const QStringList& fileList )
+{
+ emit removedFilesFromProject ( fileList );
+
+ QStringList::ConstIterator it;
+
+ for ( it = fileList.begin(); it != fileList.end(); ++it )
+ {
+ m_sourceFiles.remove ( ( *it ) );
+ }
+}
+
+void ScriptProjectPart::slotNewFile()
+{
+ ScriptNewFileDialog dlg(this);
+ dlg.exec();
+}
+
+/*!
+ \fn ScriptProjectPart::distFiles() const
+ */
+QStringList ScriptProjectPart::distFiles() const
+{
+ QStringList sourceList = allFiles();
+ // Scan current source directory for any .pro files.
+ QString projectDir = projectDirectory();
+ QDir dir(projectDir);
+ QStringList files = dir.entryList( "*README*");
+ return sourceList + files;
+}
+
+void ScriptProjectPart::rescan()
+{
+// kdDebug() << "Directory " << path << " changed, scanning for new files in the project" << endl;
+
+ // Put all files from all subdirectories into file list
+ QValueStack<QString> s;
+ int prefixlen = m_projectDirectory.length()+1;
+ s.push(m_projectDirectory);
+
+ QDir dir;
+ do {
+ dir.setPath(s.pop());
+ kdDebug(9015) << "Examining: " << dir.path() << endl;
+ const QFileInfoList *dirEntries = dir.entryInfoList();
+ if ( dirEntries )
+ {
+ QPtrListIterator<QFileInfo> it(*dirEntries);
+ for (; it.current(); ++it) {
+ QString fileName = it.current()->fileName();
+ if (fileName == "." || fileName == "..")
+ continue;
+ QString path = it.current()->absFilePath();
+ if (it.current()->isDir()) {
+ //do not follow symlinks which point to the themselves
+ if (it.current()->isSymLink())
+ {
+ QString symLink = it.current()->readLink();
+ if ((symLink == path) || (symLink == "./"))
+ continue;
+ } else if (canAddDirectoryToProject(path)) {
+ kdDebug(9015) << "Pushing: " << path << endl;
+ s.push(path);
+ }
+ }
+ else {
+ if (!isProjectFile(path) && canAddToProject(path))
+ addFile(path.mid(prefixlen));
+// m_sourceFiles.append(path.mid(prefixlen));
+ }
+ }
+ }
+ } while (!s.isEmpty());
+
+/* const QFileInfoList *dirEntries = QDir(path).entryInfoList();
+ if ( dirEntries )
+ {
+ kdDebug() << "1" << endl;
+ QPtrListIterator<QFileInfo> it(*dirEntries);
+ for (; it.current(); ++it) {
+ kdDebug() << "2" << endl;
+ QString fileName = it.current()->fileName();
+ if (fileName == "." || fileName == "..")
+ continue;
+ kdDebug() << "3" << endl;
+ QString filePath = it.current()->absFilePath();
+ if (!it.current()->isDir() && canAddToProject(filePath) && !isProjectFile(filePath)) {
+ kdDebug() << "=== adding " << filePath << endl;
+ addFile(filePath);
+ }
+ }
+ }*/
+}
+
+bool ScriptProjectPart::canAddToProject(const QString & path)
+{
+ QDomDocument &dom = *projectDom();
+ QString includepatterns
+ = DomUtil::readEntry(dom, "/kdevscriptproject/general/includepatterns");
+ QStringList includepatternList;
+ if ( includepatterns.isNull() ) {
+ if ( languageSupport() ){
+ KMimeType::List list = languageSupport()->mimeTypes();
+ KMimeType::List::Iterator it = list.begin();
+ while( it != list.end() ){
+ includepatternList += (*it)->patterns();
+ ++it;
+ }
+ }
+ } else {
+ includepatternList = QStringList::split(",", includepatterns);
+ }
+
+ QString excludepatterns
+ = DomUtil::readEntry(dom, "/kdevscriptproject/general/excludepatterns");
+ if (excludepatterns.isNull())
+ excludepatterns = "*~";
+ QStringList excludepatternList = QStringList::split(",", excludepatterns);
+
+ if (matchesPattern(path, includepatternList)
+ && !matchesPattern(path, excludepatternList)) {
+ kdDebug(9015) << "Adding: " << path << endl;
+ return true;
+ } else {
+ kdDebug(9015) << "Ignoring: " << path << endl;
+ return false;
+ }
+}
+
+bool ScriptProjectPart::canAddDirectoryToProject(const QString & path)
+{
+ QDomDocument &dom = *projectDom();
+ QString excludepatterns
+ = DomUtil::readEntry(dom, "/kdevscriptproject/general/excludepatterns");
+ if (excludepatterns.isNull()) {
+ return true;
+ }
+ QStringList excludepatternList = QStringList::split(",", excludepatterns);
+
+ if (!matchesPattern(path, excludepatternList)) {
+ return true;
+ } else {
+ kdDebug(9015) << "Ignoring Directory: " << path << endl;
+ return false;
+ }
+}
+
+#include "scriptprojectpart.moc"
diff --git a/buildtools/script/scriptprojectpart.h b/buildtools/script/scriptprojectpart.h
new file mode 100644
index 00000000..b16c4ffb
--- /dev/null
+++ b/buildtools/script/scriptprojectpart.h
@@ -0,0 +1,69 @@
+/***************************************************************************
+ * Copyright (C) 2001-2002 by Bernd Gehrmann *
+ * bernd@kdevelop.org *
+ * *
+ * 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 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _SCRIPTPROJECTPART_H_
+#define _SCRIPTPROJECTPART_H_
+
+#include <qdict.h>
+#include <qguardedptr.h>
+
+#include "kdevbuildtool.h"
+
+class QListViewItem;
+class QStringList;
+class KDialogBase;
+class ScriptProjectWidget;
+
+class ScriptProjectPart : public KDevBuildTool
+{
+ Q_OBJECT
+
+public:
+ ScriptProjectPart( QObject *parent, const char *name, const QStringList &args );
+ ~ScriptProjectPart();
+ QStringList distFiles() const;
+
+protected:
+ virtual void openProject(const QString &dirName, const QString &projectName);
+ virtual void closeProject();
+
+ virtual QString projectDirectory() const;
+ virtual QString projectName() const;
+ virtual QString mainProgram() const;
+ virtual QString activeDirectory() const;
+ virtual QStringList allFiles() const;
+ virtual void addFile(const QString &fileName);
+ virtual void addFiles ( const QStringList& fileList );
+ virtual void removeFile(const QString &fileName);
+ virtual void removeFiles ( const QStringList& fileList );
+ virtual QString buildDirectory() const;
+ virtual QString runDirectory() const;
+ virtual QString debugArguments() const;
+ virtual QString runArguments() const;
+ virtual DomUtil::PairList runEnvironmentVars() const;
+
+ bool canAddToProject(const QString &path);
+ bool canAddDirectoryToProject(const QString &path);
+
+private slots:
+ void projectConfigWidget(KDialogBase *dlg);
+ void slotNewFile();
+ void rescan();
+
+private:
+ QString m_projectDirectory;
+ QString m_projectName;
+ QStringList m_sourceFiles;
+
+ friend class ScriptNewFileDialog;
+};
+
+#endif