summaryrefslogtreecommitdiffstats
path: root/buildtools/custommakefiles
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools/custommakefiles')
-rw-r--r--buildtools/custommakefiles/Makefile.am26
-rw-r--r--buildtools/custommakefiles/README.dox47
-rw-r--r--buildtools/custommakefiles/custombuildoptionswidget.cpp99
-rw-r--r--buildtools/custommakefiles/custombuildoptionswidget.h46
-rw-r--r--buildtools/custommakefiles/custombuildoptionswidgetbase.ui164
-rw-r--r--buildtools/custommakefiles/custommakeconfigwidget.cpp134
-rw-r--r--buildtools/custommakefiles/custommakeconfigwidget.h54
-rw-r--r--buildtools/custommakefiles/custommakeconfigwidgetbase.ui395
-rw-r--r--buildtools/custommakefiles/custommanagerwidget.cpp80
-rw-r--r--buildtools/custommakefiles/custommanagerwidget.h41
-rw-r--r--buildtools/custommakefiles/custommanagerwidgetbase.ui74
-rw-r--r--buildtools/custommakefiles/customotherconfigwidget.cpp125
-rw-r--r--buildtools/custommakefiles/customotherconfigwidget.h57
-rw-r--r--buildtools/custommakefiles/customotherconfigwidgetbase.ui288
-rw-r--r--buildtools/custommakefiles/customprojectpart.cpp1669
-rw-r--r--buildtools/custommakefiles/customprojectpart.h158
-rw-r--r--buildtools/custommakefiles/kdevcustomproject.desktop91
-rw-r--r--buildtools/custommakefiles/kdevcustomproject.rc30
-rw-r--r--buildtools/custommakefiles/selectnewfilesdialog.cpp131
-rw-r--r--buildtools/custommakefiles/selectnewfilesdialog.h53
-rw-r--r--buildtools/custommakefiles/selectnewfilesdialogbase.ui50
21 files changed, 3812 insertions, 0 deletions
diff --git a/buildtools/custommakefiles/Makefile.am b/buildtools/custommakefiles/Makefile.am
new file mode 100644
index 00000000..fab92b8b
--- /dev/null
+++ b/buildtools/custommakefiles/Makefile.am
@@ -0,0 +1,26 @@
+# Here resides the custom project 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/util $(all_includes) \
+ -I$(top_builddir)/buildtools/lib/widgets
+
+kde_module_LTLIBRARIES = libkdevcustomproject.la
+libkdevcustomproject_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkdevcustomproject_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \
+ $(top_builddir)/buildtools/lib/widgets/libkdevbuildtoolswidgets.la $(top_builddir)/buildtools/lib/base/libkdevbuildbase.la
+
+libkdevcustomproject_la_SOURCES = selectnewfilesdialog.cpp selectnewfilesdialogbase.ui \
+ custombuildoptionswidget.cpp custombuildoptionswidgetbase.ui custommakeconfigwidget.cpp \
+ custommakeconfigwidgetbase.ui custommanagerwidget.cpp custommanagerwidgetbase.ui \
+ customotherconfigwidget.cpp customotherconfigwidgetbase.ui customprojectpart.cpp
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)
+service_DATA = kdevcustomproject.desktop
+
+rcdir = $(kde_datadir)/kdevcustomproject
+rc_DATA = kdevcustomproject.rc
+noinst_HEADERS = selectnewfilesdialog.h custommanagerwidget.h \
+ customotherconfigwidget.h
diff --git a/buildtools/custommakefiles/README.dox b/buildtools/custommakefiles/README.dox
new file mode 100644
index 00000000..28762d87
--- /dev/null
+++ b/buildtools/custommakefiles/README.dox
@@ -0,0 +1,47 @@
+/** \class CustomProjectPart
+This is the custom build tools 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
+
+\feature Describe the first feature
+\feature Describe the second feature
+...
+\feature Describe the last feature
+
+\bug bugs in <a href="http://bugs.kde.org/buglist.cgi?product=kdevelop&component=customproject&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=Bug+Number">customproject component at Bugzilla database</a>
+\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/custommakefiles/custombuildoptionswidget.cpp b/buildtools/custommakefiles/custombuildoptionswidget.cpp
new file mode 100644
index 00000000..37b087b2
--- /dev/null
+++ b/buildtools/custommakefiles/custombuildoptionswidget.cpp
@@ -0,0 +1,99 @@
+/***************************************************************************
+ * 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 "custombuildoptionswidget.h"
+
+#include <qcheckbox.h>
+#include <klineedit.h>
+#include <kurlrequester.h>
+#include <kurlcompletion.h>
+#include <kfiledialog.h>
+#include <qradiobutton.h>
+#include <qtabwidget.h>
+#include "domutil.h"
+
+
+CustomBuildOptionsWidget::CustomBuildOptionsWidget(QDomDocument &dom,
+ QWidget *parent, const char *name)
+ : CustomBuildOptionsWidgetBase(parent, name),
+ m_dom(dom)
+{
+ ant_button->setChecked(DomUtil::readEntry(dom, "/kdevcustomproject/build/buildtool") == "ant");
+ other_button->setChecked(DomUtil::readEntry(dom, "/kdevcustomproject/build/buildtool") == "other");
+ if( !DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir").isEmpty()
+ && QFileInfo( DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir") ).exists() )
+ {
+ builddir_edit->setURL(DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir"));
+ builddir_edit->fileDialog()->setURL( DomUtil::readEntry(dom, "/kdevcustomproject/build/builddir") );
+ }
+ else
+ {
+ builddir_edit->setURL( QString() );
+ builddir_edit->fileDialog()->setURL( QString() );
+ }
+ builddir_edit->completionObject()->setMode(KURLCompletion::DirCompletion);
+ builddir_edit->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
+
+ // This connection must not be made before the ant->setChecked() line,
+ // because at this time makeToggled() would crash
+ connect( make_button, SIGNAL(toggled(bool)),
+ this, SLOT(makeToggled(bool)) );
+ connect( other_button, SIGNAL(toggled(bool)),
+ this, SLOT(otherToggled(bool)) );
+}
+
+
+CustomBuildOptionsWidget::~CustomBuildOptionsWidget()
+{}
+
+
+void CustomBuildOptionsWidget::accept()
+{
+ QString buildtool;
+ if (ant_button->isChecked())
+ {
+ buildtool = "ant";
+ }
+ else if (other_button->isChecked())
+ {
+ buildtool = "other";
+ }
+ else
+ {
+ buildtool = "make";
+ }
+ DomUtil::writeEntry(m_dom, "/kdevcustomproject/build/buildtool", buildtool);
+ DomUtil::writeEntry(m_dom, "/kdevcustomproject/build/builddir", builddir_edit->url());
+}
+
+
+void CustomBuildOptionsWidget::setMakeOptionsWidget(QTabWidget *tw, QWidget *mow, QWidget* oow)
+{
+ m_tabWidget = tw;
+ m_makeOptions = mow;
+ m_otherOptions = oow;
+ makeToggled(make_button->isChecked());
+ otherToggled(other_button->isChecked());
+}
+
+void CustomBuildOptionsWidget::otherToggled(bool b)
+{
+ m_tabWidget->setTabEnabled(m_otherOptions, b);
+}
+
+void CustomBuildOptionsWidget::makeToggled(bool b)
+{
+ m_tabWidget->setTabEnabled(m_makeOptions, b);
+}
+
+#include "custombuildoptionswidget.moc"
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
diff --git a/buildtools/custommakefiles/custombuildoptionswidget.h b/buildtools/custommakefiles/custombuildoptionswidget.h
new file mode 100644
index 00000000..1b049574
--- /dev/null
+++ b/buildtools/custommakefiles/custombuildoptionswidget.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * 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 _CUSTOMBUILDOPTIONSWIDGET_H_
+#define _CUSTOMBUILDOPTIONSWIDGET_H_
+
+#include "custombuildoptionswidgetbase.h"
+#include <qdom.h>
+
+class QTabWidget;
+
+
+class CustomBuildOptionsWidget : public CustomBuildOptionsWidgetBase
+{
+ Q_OBJECT
+
+public:
+ CustomBuildOptionsWidget( QDomDocument &dom, QWidget *parent=0, const char *name=0 );
+ ~CustomBuildOptionsWidget();
+
+ void setMakeOptionsWidget(QTabWidget *tw, QWidget *mow, QWidget *oow);
+
+public slots:
+ void accept();
+
+private:
+ virtual void makeToggled(bool b);
+ virtual void otherToggled(bool b);
+
+ QDomDocument &m_dom;
+ QTabWidget *m_tabWidget;
+ QWidget *m_makeOptions;
+ QWidget *m_otherOptions;
+};
+
+#endif
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
diff --git a/buildtools/custommakefiles/custombuildoptionswidgetbase.ui b/buildtools/custommakefiles/custombuildoptionswidgetbase.ui
new file mode 100644
index 00000000..59ca9ba2
--- /dev/null
+++ b/buildtools/custommakefiles/custombuildoptionswidgetbase.ui
@@ -0,0 +1,164 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>CustomBuildOptionsWidgetBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>configure_options_widget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>592</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Custom Build Options</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>buildtool_group</cstring>
+ </property>
+ <property name="title">
+ <string>Build Tool</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>make_button</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Make</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>ant_button</cstring>
+ </property>
+ <property name="text">
+ <string>A&amp;nt</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>other_button</cstring>
+ </property>
+ <property name="text">
+ <string>Other</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>other custom build tool, e.g. script</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>There are myriads of buildtools out there that are not ant or make. If you use one of them (or have your own scripts), select this option.</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer19</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>builddir_label</cstring>
+ </property>
+ <property name="text">
+ <string>Run &amp;the build tool in the following directory:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>builddir_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer38</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>16</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>builddir_edit</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer39</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>
+<slots>
+ <slot access="protected">makeToggled(bool)</slot>
+ <slot access="protected">otherToggled(bool)</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/buildtools/custommakefiles/custommakeconfigwidget.cpp b/buildtools/custommakefiles/custommakeconfigwidget.cpp
new file mode 100644
index 00000000..2af0d137
--- /dev/null
+++ b/buildtools/custommakefiles/custommakeconfigwidget.cpp
@@ -0,0 +1,134 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Hendrik Kueck *
+ * kueck@cs.ubc.ca *
+ * *
+ * 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 "custommakeconfigwidget.h"
+#include <custombuildoptionswidgetbase.h>
+#include <customprojectpart.h>
+#include <qcombobox.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qspinbox.h>
+#include <qlistview.h>
+#include <qgroupbox.h>
+#include <qvalidator.h>
+#include <klineedit.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include <environmentvariableswidget.h>
+
+CustomMakeConfigWidget::CustomMakeConfigWidget(CustomProjectPart* part, const QString& configGroup, QWidget* parent)
+ : CustomMakeConfigWidgetBase(parent),
+ m_part(part), m_configGroup(configGroup), m_dom( *part->projectDom() )
+{
+ abort_box->setChecked(DomUtil::readBoolEntry(m_dom, m_configGroup + "/make/abortonerror"));
+ int numjobs = DomUtil::readIntEntry(m_dom, m_configGroup + "/make/numberofjobs");
+ jobs_box->setValue(numjobs);
+ runMultiJobs->setChecked( (numjobs > 0 ) );
+
+ prio_box->setValue(DomUtil::readIntEntry(m_dom, m_configGroup + "/make/prio"));
+ dontact_box->setChecked(DomUtil::readBoolEntry(m_dom, m_configGroup + "/make/dontact"));
+ makebin_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/makebin"));
+ defaultTarget_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/defaulttarget"));
+ makeoptions_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/makeoptions"));
+
+ envs_combo->setValidator(new QRegExpValidator(QRegExp("^\\D[^\\s]*"), this));
+ m_allEnvironments = m_part->allMakeEnvironments();
+ m_currentEnvironment = m_part->currentMakeEnvironment();
+ env_var_group->setColumnLayout( 1, Qt::Vertical );
+ m_envWidget = new EnvironmentVariablesWidget(m_dom, m_configGroup + "/make/environments/" + m_currentEnvironment, env_var_group);
+ envs_combo->insertStringList(m_allEnvironments);
+ envs_combo->setEditText(m_currentEnvironment);
+}
+
+
+CustomMakeConfigWidget::~CustomMakeConfigWidget()
+{
+
+}
+
+void CustomMakeConfigWidget::envNameChanged(const QString& envName)
+{
+ QStringList allEnvNames = m_part->allMakeEnvironments();
+ bool canAdd = !allEnvNames.contains(envName) && !envName.contains("/") && !envName.isEmpty();
+ bool canRemove = allEnvNames.contains(envName) && allEnvNames.count() > 1;
+ addenvs_button->setEnabled(canAdd);
+ copyenvs_button->setEnabled(canAdd);
+ removeenvs_button->setEnabled(canRemove);
+}
+
+void CustomMakeConfigWidget::envChanged(const QString& envName)
+{
+ if (envName == m_currentEnvironment || !m_allEnvironments.contains(envName))
+ return;
+
+ // save settings of previously active environment
+ if (!m_currentEnvironment.isNull() )
+ m_envWidget->accept();
+
+ m_currentEnvironment = envName;
+ m_envWidget->readEnvironment(m_dom, m_configGroup + "/make/environments/" + envName);
+ envs_combo->setEditText(envName);
+}
+
+void CustomMakeConfigWidget::envAdded()
+{
+ QString env = envs_combo->currentText();
+ m_allEnvironments.append(env);
+
+ envs_combo->clear();
+ envs_combo->insertStringList(m_allEnvironments);
+ envChanged(env);
+}
+
+void CustomMakeConfigWidget::envRemoved()
+{
+ QString env = envs_combo->currentText();
+ QDomNode node = DomUtil::elementByPath(m_dom, m_configGroup + "/make/environments");
+ node.removeChild(node.namedItem(env));
+ m_allEnvironments.remove(env);
+ envs_combo->clear();
+ envs_combo->insertStringList(m_allEnvironments);
+ m_currentEnvironment = QString::null;
+ envChanged( m_allEnvironments[0] );
+}
+
+void CustomMakeConfigWidget::envCopied()
+{
+ QString env = envs_combo->currentText();
+ m_allEnvironments.append(env);
+ envs_combo->clear();
+ envs_combo->insertStringList(m_allEnvironments);
+ m_currentEnvironment = env;
+ m_envWidget->changeConfigGroup(m_configGroup + "/make/environments/" + env);
+ envs_combo->setEditText(env);
+}
+
+void CustomMakeConfigWidget::accept()
+{
+ DomUtil::writeBoolEntry(m_dom, m_configGroup + "/make/abortonerror", abort_box->isChecked());
+ if( runMultiJobs->isChecked() )
+ DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/numberofjobs", jobs_box->value());
+ else
+ DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/numberofjobs", 0);
+ DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/prio", prio_box->value());
+ DomUtil::writeBoolEntry(m_dom, m_configGroup + "/make/dontact", dontact_box->isChecked());
+ DomUtil::writeEntry(m_dom, m_configGroup + "/make/makebin", makebin_edit->text());
+ DomUtil::writeEntry(m_dom, m_configGroup + "/make/defaulttarget", defaultTarget_edit->text());
+ DomUtil::writeEntry(m_dom, m_configGroup + "/make/makeoptions", makeoptions_edit->text());
+ DomUtil::writeEntry(m_dom, m_configGroup + "/make/selectedenvironment", m_currentEnvironment);
+ m_envWidget->accept();
+}
+
+#include "custommakeconfigwidget.moc"
diff --git a/buildtools/custommakefiles/custommakeconfigwidget.h b/buildtools/custommakefiles/custommakeconfigwidget.h
new file mode 100644
index 00000000..ae8376c1
--- /dev/null
+++ b/buildtools/custommakefiles/custommakeconfigwidget.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Hendrik Kueck *
+ * kueck@cs.ubc.ca *
+ * *
+ * 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 CUSTOMMAKECONFIGWIDGET_H
+#define CUSTOMMAKECONFIGWIDGET_H
+
+#include "domutil.h"
+
+#include <custommakeconfigwidgetbase.h>
+
+class CustomProjectPart;
+class EnvironmentVariablesWidget;
+
+/**
+@author KDevelop Authors
+*/
+class CustomMakeConfigWidget : public CustomMakeConfigWidgetBase
+{
+ Q_OBJECT
+
+public:
+ CustomMakeConfigWidget(CustomProjectPart* part, const QString& configGroup, QWidget* parent);
+
+ ~CustomMakeConfigWidget();
+
+public slots:
+ void accept();
+
+protected:
+ CustomProjectPart* m_part;
+ QString m_configGroup;
+ QDomDocument& m_dom;
+
+ QStringList m_allEnvironments;
+ QString m_currentEnvironment;
+
+ EnvironmentVariablesWidget* m_envWidget;
+
+ virtual void envNameChanged(const QString& envName);
+ virtual void envChanged(const QString& envName);
+ virtual void envAdded();
+ virtual void envRemoved();
+ virtual void envCopied();
+
+};
+
+#endif
diff --git a/buildtools/custommakefiles/custommakeconfigwidgetbase.ui b/buildtools/custommakefiles/custommakeconfigwidgetbase.ui
new file mode 100644
index 00000000..b864a18f
--- /dev/null
+++ b/buildtools/custommakefiles/custommakeconfigwidgetbase.ui
@@ -0,0 +1,395 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>CustomMakeConfigWidgetBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>CustomMakeConfigWidgetBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>659</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Make Options</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>abort_box</cstring>
+ </property>
+ <property name="text">
+ <string>A&amp;bort on first error</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>dontact_box</cstring>
+ </property>
+ <property name="text">
+ <string>Only di&amp;splay commands without actually executing them</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>defaultTarget_edit</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>makebin_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>makeoptions_label</cstring>
+ </property>
+ <property name="text">
+ <string>A&amp;dditional make options:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>makeoptions_edit</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>makeoptions_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>makebin_label</cstring>
+ </property>
+ <property name="text">
+ <string>Name of make e&amp;xecutable:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>makebin_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>defTarget_label</cstring>
+ </property>
+ <property name="text">
+ <string>Default make &amp;target:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>defaultTarget_edit</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>runMultiJobs</cstring>
+ </property>
+ <property name="text">
+ <string>Run multiple jobs</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>jobs_label</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Number of simultaneous &amp;jobs:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>jobs_box</cstring>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>jobs_box</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maxValue">
+ <number>30</number>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>200</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>prio_label</cstring>
+ </property>
+ <property name="text">
+ <string>Make &amp;priority:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>jobs_box</cstring>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>prio_box</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maxValue">
+ <number>19</number>
+ </property>
+ <property name="minValue">
+ <number>-20</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>192</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>envs_label</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>E&amp;nvironment:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>envs_combo</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>envs_combo</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>addenvs_button</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>copyenvs_button</cstring>
+ </property>
+ <property name="text">
+ <string>Co&amp;py</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>removeenvs_button</cstring>
+ </property>
+ <property name="text">
+ <string>Re&amp;move</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>env_var_group</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Environment &amp;Variables</string>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>envs_combo</sender>
+ <signal>textChanged(const QString&amp;)</signal>
+ <receiver>CustomMakeConfigWidgetBase</receiver>
+ <slot>envNameChanged(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>envs_combo</sender>
+ <signal>activated(const QString&amp;)</signal>
+ <receiver>CustomMakeConfigWidgetBase</receiver>
+ <slot>envChanged(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>copyenvs_button</sender>
+ <signal>clicked()</signal>
+ <receiver>CustomMakeConfigWidgetBase</receiver>
+ <slot>envCopied()</slot>
+ </connection>
+ <connection>
+ <sender>addenvs_button</sender>
+ <signal>clicked()</signal>
+ <receiver>CustomMakeConfigWidgetBase</receiver>
+ <slot>envAdded()</slot>
+ </connection>
+ <connection>
+ <sender>removeenvs_button</sender>
+ <signal>clicked()</signal>
+ <receiver>CustomMakeConfigWidgetBase</receiver>
+ <slot>envRemoved()</slot>
+ </connection>
+ <connection>
+ <sender>runMultiJobs</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>jobs_label</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>runMultiJobs</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>jobs_box</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>abort_box</tabstop>
+ <tabstop>dontact_box</tabstop>
+ <tabstop>makebin_edit</tabstop>
+ <tabstop>makeoptions_edit</tabstop>
+ <tabstop>jobs_box</tabstop>
+ <tabstop>envs_combo</tabstop>
+ <tabstop>addenvs_button</tabstop>
+ <tabstop>copyenvs_button</tabstop>
+ <tabstop>removeenvs_button</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in implementation">kdialog.h</include>
+</includes>
+<slots>
+ <slot access="protected">envNameChanged(const QString &amp;)</slot>
+ <slot access="protected">envChanged(const QString&amp;)</slot>
+ <slot access="protected">envAdded()</slot>
+ <slot access="protected">envRemoved()</slot>
+ <slot access="protected">envCopied()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/buildtools/custommakefiles/custommanagerwidget.cpp b/buildtools/custommakefiles/custommanagerwidget.cpp
new file mode 100644
index 00000000..9001480e
--- /dev/null
+++ b/buildtools/custommakefiles/custommanagerwidget.cpp
@@ -0,0 +1,80 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Andreas Pakulat *
+ * apaku@gmx.de *
+ * *
+ * 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 "custommanagerwidget.h"
+
+#include <qstringlist.h>
+#include <qlayout.h>
+#include <qlistbox.h>
+#include <qwhatsthis.h>
+#include <qtooltip.h>
+
+#include <ktextedit.h>
+#include <kurlrequester.h>
+#include <kurlcompletion.h>
+#include <kfiledialog.h>
+#include <keditlistbox.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+#include "customprojectpart.h"
+#include "domutil.h"
+
+CustomManagerWidget::CustomManagerWidget( CustomProjectPart* part, QWidget* parent )
+ : CustomManagerWidgetBase( parent ), m_part( part), m_dom( *part->projectDom() )
+{
+ m_filetypes->insertStringList( DomUtil::readListEntry( m_dom, "kdevcustomproject/filetypes", "filetype" ) );
+ KURLRequester* urlselector = new KURLRequester( );
+ urlselector->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly );
+ urlselector->setURL( QString::null );
+ urlselector->completionObject() ->setDir( part->projectDirectory() );
+ urlselector->fileDialog() ->setURL( KURL( part->projectDirectory() ) );
+ m_blacklistBox = new KEditListBox( i18n("blacklisted files and directories are not"
+ " considered part of the project, even if they fit one of "
+ "the wildcard patterns in the project file list",
+ "Blacklisted files/dirs"), urlselector->customEditor(), this);
+ m_blacklistBox->setButtons( KEditListBox::Add | KEditListBox::Remove );
+ m_blacklistBox->insertStringList( DomUtil::readListEntry( m_dom, "kdevcustomproject/blacklist","path") );
+ grid->addWidget( m_blacklistBox, 0, 1 );
+ connect(m_blacklistBox, SIGNAL(added(const QString&)), this, SLOT(checkUrl(const QString&)));
+}
+
+void CustomManagerWidget::checkUrl(const QString& url)
+{
+ kdDebug(9025) << "got file:" << url << endl;
+ if( !QFileInfo(url).isRelative() )
+ {
+ kdDebug(9025) << "seems to be non-relative" << endl;
+ QString relpath = m_part->relativeToProject( url );
+ QListBoxItem* item = m_blacklistBox->listBox()->findItem( url );
+ m_blacklistBox->listBox()->takeItem( item );
+ kdDebug(9025) << "relative path:" << relpath << endl;
+ if( !relpath.isEmpty() )
+ m_blacklistBox->insertItem( relpath );
+ }
+}
+
+CustomManagerWidget::~CustomManagerWidget()
+{
+}
+
+void CustomManagerWidget::accept()
+{
+ DomUtil::writeListEntry( m_dom, "kdevcustomproject/filetypes", "filetype",
+ m_filetypes->items() );
+ DomUtil::writeListEntry( m_dom, "kdevcustomproject/blacklist", "path",
+ m_blacklistBox->items() );
+}
+
+
+#include "custommanagerwidget.moc"
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
diff --git a/buildtools/custommakefiles/custommanagerwidget.h b/buildtools/custommakefiles/custommanagerwidget.h
new file mode 100644
index 00000000..4f15f156
--- /dev/null
+++ b/buildtools/custommakefiles/custommanagerwidget.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Andreas Pakulat *
+ * apaku@gmx.de *
+ * *
+ * 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 CUSTOMMANAGERWIDGET_H
+#define CUSTOMMANAGERWIDGET_H
+
+#include "custommanagerwidgetbase.h"
+
+
+#include <qdom.h>
+
+class CustomProjectPart;
+class KEditListBox;
+
+class CustomManagerWidget : public CustomManagerWidgetBase
+{
+Q_OBJECT
+
+public:
+ CustomManagerWidget( CustomProjectPart* part, QWidget* parent );
+ ~CustomManagerWidget();
+public slots:
+ void checkUrl(const QString& url);
+ void accept();
+private:
+ CustomProjectPart* m_part;
+ QDomDocument& m_dom;
+ KEditListBox* m_blacklistBox;
+};
+
+#endif
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
diff --git a/buildtools/custommakefiles/custommanagerwidgetbase.ui b/buildtools/custommakefiles/custommanagerwidgetbase.ui
new file mode 100644
index 00000000..a388b288
--- /dev/null
+++ b/buildtools/custommakefiles/custommanagerwidgetbase.ui
@@ -0,0 +1,74 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>CustomManagerWidgetBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>CustomManagerWidgetBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>467</width>
+ <height>393</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Custom Manager Options</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>grid</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KEditListBox" row="0" column="0">
+ <property name="name">
+ <cstring>m_filetypes</cstring>
+ </property>
+ <property name="title">
+ <string>Filetypes used in Project</string>
+ </property>
+ <property name="buttons">
+ <set>Remove|Add</set>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Add filetypes to be used in Projects, can be full filenames or shell wildcards</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Each entry contains a filetype used in the project in the form of a filename or a filename wildcard (using shell wildcards).
+This will be used when adding/removing files in directories and re-populating the project</string>
+ </property>
+ </widget>
+ <spacer row="1" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>108</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>keditlistbox.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/buildtools/custommakefiles/customotherconfigwidget.cpp b/buildtools/custommakefiles/customotherconfigwidget.cpp
new file mode 100644
index 00000000..47fe4b4d
--- /dev/null
+++ b/buildtools/custommakefiles/customotherconfigwidget.cpp
@@ -0,0 +1,125 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Achim Herwig *
+ * achim.herwig@wodca.de *
+ * *
+ * 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 "customotherconfigwidget.h"
+#include <custombuildoptionswidgetbase.h>
+#include <customprojectpart.h>
+#include <qcombobox.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qlineedit.h>
+#include <qspinbox.h>
+#include <qlistview.h>
+#include <qgroupbox.h>
+#include <qvalidator.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include <environmentvariableswidget.h>
+
+CustomOtherConfigWidget::CustomOtherConfigWidget(CustomProjectPart* part, const QString& configGroup, QWidget* parent)
+ : CustomOtherConfigWidgetBase(parent),
+ m_part(part), m_configGroup(configGroup), m_dom( *part->projectDom() )
+{
+ prio_box->setValue(DomUtil::readIntEntry(m_dom, m_configGroup + "/other/prio"));
+ makebin_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/other/otherbin"));
+ defaultTarget_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/other/defaulttarget"));
+ makeoptions_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/other/otheroptions"));
+
+ envs_combo->setValidator(new QRegExpValidator(QRegExp("^\\D.*"), this));
+ m_allEnvironments = m_part->allMakeEnvironments();
+ m_currentEnvironment = m_part->currentMakeEnvironment();
+ env_var_group->setColumnLayout( 1, Qt::Vertical );
+ m_envWidget = new EnvironmentVariablesWidget(m_dom, m_configGroup + "/other/environments/" + m_currentEnvironment, env_var_group);
+ envs_combo->insertStringList(m_allEnvironments);
+ envs_combo->setEditText(m_currentEnvironment);
+}
+
+
+CustomOtherConfigWidget::~CustomOtherConfigWidget()
+{
+
+}
+
+void CustomOtherConfigWidget::envNameChanged(const QString& envName)
+{
+ QStringList allEnvNames = m_part->allMakeEnvironments();
+ bool canAdd = !allEnvNames.contains(envName) && !envName.contains("/") && !envName.isEmpty();
+ bool canRemove = allEnvNames.contains(envName) && allEnvNames.count() > 1;
+ addenvs_button->setEnabled(canAdd);
+ copyenvs_button->setEnabled(canAdd);
+ removeenvs_button->setEnabled(canRemove);
+}
+
+void CustomOtherConfigWidget::envChanged(const QString& envName)
+{
+ if (envName == m_currentEnvironment || !m_allEnvironments.contains(envName))
+ return;
+
+ // save settings of previously active environment
+ if (!m_currentEnvironment.isNull() )
+ m_envWidget->accept();
+
+ m_currentEnvironment = envName;
+ m_envWidget->readEnvironment(m_dom, m_configGroup + "/other/environments/" + envName);
+ envs_combo->setEditText(envName);
+}
+
+void CustomOtherConfigWidget::envAdded()
+{
+ QString env = envs_combo->currentText();
+ m_allEnvironments.append(env);
+
+ envs_combo->clear();
+ envs_combo->insertStringList(m_allEnvironments);
+ envChanged(env);
+}
+
+void CustomOtherConfigWidget::envRemoved()
+{
+ QString env = envs_combo->currentText();
+ QDomNode node = DomUtil::elementByPath(m_dom, m_configGroup + "/other/environments");
+ node.removeChild(node.namedItem(env));
+ m_allEnvironments.remove(env);
+ envs_combo->clear();
+ envs_combo->insertStringList(m_allEnvironments);
+ m_currentEnvironment = QString::null;
+ envChanged( m_allEnvironments[0] );
+}
+
+void CustomOtherConfigWidget::envCopied()
+{
+ QString env = envs_combo->currentText();
+ m_allEnvironments.append(env);
+ envs_combo->clear();
+ envs_combo->insertStringList(m_allEnvironments);
+ m_currentEnvironment = env;
+ m_envWidget->changeConfigGroup(m_configGroup + "/other/environments/" + env);
+ envs_combo->setEditText(env);
+}
+
+void CustomOtherConfigWidget::accept()
+{
+ DomUtil::writeIntEntry(m_dom, m_configGroup + "/other/prio", prio_box->value());
+ DomUtil::writeEntry(m_dom, m_configGroup + "/other/otherbin", makebin_edit->text());
+ DomUtil::writeEntry(m_dom, m_configGroup + "/other/defaulttarget", defaultTarget_edit->text());
+ DomUtil::writeEntry(m_dom, m_configGroup + "/other/otheroptions", makeoptions_edit->text());
+ DomUtil::writeEntry(m_dom, m_configGroup + "/other/selectedenvironment", m_currentEnvironment);
+ m_envWidget->accept();
+}
+
+#include "customotherconfigwidget.moc"
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
+
diff --git a/buildtools/custommakefiles/customotherconfigwidget.h b/buildtools/custommakefiles/customotherconfigwidget.h
new file mode 100644
index 00000000..755df98b
--- /dev/null
+++ b/buildtools/custommakefiles/customotherconfigwidget.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Achim Herwig *
+ * achim.herwig@wodca.de *
+ * *
+ * 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 CUSTOMOTHERCONFIGWIDGET_H
+#define CUSTOMOTHERCONFIGWIDGET_H
+
+#include "domutil.h"
+
+#include <customotherconfigwidgetbase.h>
+
+class CustomProjectPart;
+class EnvironmentVariablesWidget;
+
+/**
+@author KDevelop Authors
+*/
+class CustomOtherConfigWidget : public CustomOtherConfigWidgetBase
+{
+ Q_OBJECT
+
+public:
+ CustomOtherConfigWidget(CustomProjectPart* part, const QString& configGroup, QWidget* parent);
+
+ ~CustomOtherConfigWidget();
+
+public slots:
+ void accept();
+
+protected:
+ CustomProjectPart* m_part;
+ QString m_configGroup;
+ QDomDocument& m_dom;
+
+ QStringList m_allEnvironments;
+ QString m_currentEnvironment;
+
+ EnvironmentVariablesWidget* m_envWidget;
+
+ virtual void envNameChanged(const QString& envName);
+ virtual void envChanged(const QString& envName);
+ virtual void envAdded();
+ virtual void envRemoved();
+ virtual void envCopied();
+
+};
+
+#endif
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
+
diff --git a/buildtools/custommakefiles/customotherconfigwidgetbase.ui b/buildtools/custommakefiles/customotherconfigwidgetbase.ui
new file mode 100644
index 00000000..174391ae
--- /dev/null
+++ b/buildtools/custommakefiles/customotherconfigwidgetbase.ui
@@ -0,0 +1,288 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>CustomOtherConfigWidgetBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>CustomOtherConfigWidgetBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>659</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Make Options</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>defaultTarget_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>makebin_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>makeoptions_label</cstring>
+ </property>
+ <property name="text">
+ <string>Add&amp;itional options:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>makeoptions_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>makeoptions_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>makebin_label</cstring>
+ </property>
+ <property name="text">
+ <string>Name of build &amp;script</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>makebin_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>defTarget_label</cstring>
+ </property>
+ <property name="text">
+ <string>Default &amp;target:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>defaultTarget_edit</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>prio_label</cstring>
+ </property>
+ <property name="text">
+ <string>Run with priority:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>jobs_box</cstring>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>prio_box</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maxValue">
+ <number>19</number>
+ </property>
+ <property name="minValue">
+ <number>-20</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>envs_label</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>E&amp;nvironment:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>envs_combo</cstring>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>envs_combo</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>addenvs_button</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>copyenvs_button</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Copy</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>removeenvs_button</cstring>
+ </property>
+ <property name="text">
+ <string>Re&amp;move</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>env_var_group</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>3</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Environment &amp;Variables</string>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>envs_combo</sender>
+ <signal>textChanged(const QString&amp;)</signal>
+ <receiver>CustomOtherConfigWidgetBase</receiver>
+ <slot>envNameChanged(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>envs_combo</sender>
+ <signal>activated(const QString&amp;)</signal>
+ <receiver>CustomOtherConfigWidgetBase</receiver>
+ <slot>envChanged(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>copyenvs_button</sender>
+ <signal>clicked()</signal>
+ <receiver>CustomOtherConfigWidgetBase</receiver>
+ <slot>envCopied()</slot>
+ </connection>
+ <connection>
+ <sender>addenvs_button</sender>
+ <signal>clicked()</signal>
+ <receiver>CustomOtherConfigWidgetBase</receiver>
+ <slot>envAdded()</slot>
+ </connection>
+ <connection>
+ <sender>removeenvs_button</sender>
+ <signal>clicked()</signal>
+ <receiver>CustomOtherConfigWidgetBase</receiver>
+ <slot>envRemoved()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>makebin_edit</tabstop>
+ <tabstop>makeoptions_edit</tabstop>
+ <tabstop>envs_combo</tabstop>
+ <tabstop>addenvs_button</tabstop>
+ <tabstop>copyenvs_button</tabstop>
+ <tabstop>removeenvs_button</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in implementation">kdialog.h</include>
+</includes>
+<slots>
+ <slot access="protected">envNameChanged(const QString &amp;)</slot>
+ <slot access="protected">envChanged(const QString&amp;)</slot>
+ <slot access="protected">envAdded()</slot>
+ <slot access="protected">envRemoved()</slot>
+ <slot access="protected">envCopied()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+</UI>
diff --git a/buildtools/custommakefiles/customprojectpart.cpp b/buildtools/custommakefiles/customprojectpart.cpp
new file mode 100644
index 00000000..f061dadc
--- /dev/null
+++ b/buildtools/custommakefiles/customprojectpart.cpp
@@ -0,0 +1,1669 @@
+/***************************************************************************
+ * Copyright (C) 2001-2002 by Bernd Gehrmann *
+ * bernd@kdevelop.org *
+ * Copyright (C) 2007 by Andreas Pakulat *
+ * apaku@gmx.de *
+ * *
+ * 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 "customprojectpart.h"
+
+#include <qapplication.h>
+#include <kapplication.h>
+#include <qdir.h>
+#include <qfileinfo.h>
+#include <qpopupmenu.h>
+#include <qregexp.h>
+#include <qstringlist.h>
+#include <qtabwidget.h>
+#include <qvaluestack.h>
+#include <qvbox.h>
+#include <qwhatsthis.h>
+#include <qdom.h>
+
+#include <kaction.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <keditlistbox.h>
+#include <kdevgenericfactory.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kmainwindow.h>
+#include <kmessagebox.h>
+#include <kparts/part.h>
+#include <kpopupmenu.h>
+#include <kdeversion.h>
+#include <kprocess.h>
+
+#include "domutil.h"
+#include "kdevcore.h"
+#include "kdevmainwindow.h"
+#include "kdevmakefrontend.h"
+#include "kdevappfrontend.h"
+#include "kdevpartcontroller.h"
+#include "runoptionswidget.h"
+#include "makeoptionswidget.h"
+#include "custombuildoptionswidget.h"
+#include "custommakeconfigwidget.h"
+#include "customotherconfigwidget.h"
+#include "custommanagerwidget.h"
+#include "config.h"
+#include "envvartools.h"
+#include "urlutil.h"
+
+#include "selectnewfilesdialog.h"
+
+#include <kdevplugininfo.h>
+
+typedef KDevGenericFactory<CustomProjectPart> CustomProjectFactory;
+static const KDevPluginInfo data( "kdevcustomproject" );
+K_EXPORT_COMPONENT_FACTORY( libkdevcustomproject, CustomProjectFactory( data ) )
+
+CustomProjectPart::CustomProjectPart( QObject *parent, const char *name, const QStringList & )
+ : KDevBuildTool( &data, parent, name ? name : "CustomProjectPart" )
+ , m_lastCompilationFailed( false ), m_recursive( false ), m_first_recursive( false )
+{
+ setInstance( CustomProjectFactory::instance() );
+ setXMLFile( "kdevcustomproject.rc" );
+
+ m_executeAfterBuild = false;
+
+ KAction *action;
+
+ action = new KAction( i18n( "Re-Populate Project" ), 0, this, SLOT( populateProject() ), actionCollection(), "repopulate_project" );
+ action->setToolTip( i18n( "Re-Populate Project" ) );
+ action->setWhatsThis( i18n( "<b>Re-Populate Project</b><p>Re-Populates the project, searching through the project directory and adding all files that match one of the wildcards set in the custom manager options of the project filelist." ) );
+
+ action = new KAction( i18n( "&Build Project" ), "make_kdevelop", Key_F8,
+ this, SLOT( slotBuild() ),
+ actionCollection(), "build_build" );
+ action->setToolTip( i18n( "Build project" ) );
+ action->setWhatsThis( i18n( "<b>Build project</b><p>Runs <b>make</b> from the project directory.<br>"
+ "Environment variables and make arguments can be specified "
+ "in the project settings dialog, <b>Build Options</b> tab." ) );
+
+ action = new KAction( i18n( "&Build Active Directory" ), "make_kdevelop", Key_F7,
+ this, SLOT( slotBuildActiveDir() ),
+ actionCollection(), "build_buildactivetarget" );
+ action->setToolTip( i18n( "Build active directory" ) );
+ action->setWhatsThis( i18n( "<b>Build active directory</b><p>Constructs a series of make commands to build the active directory. "
+ "Environment variables and make arguments can be specified "
+ "in the project settings dialog, <b>Make Options</b> tab." ) );
+
+ action = new KAction( i18n( "Compile &File" ), "make_kdevelop",
+ this, SLOT( slotCompileFile() ),
+ actionCollection(), "build_compilefile" );
+ action->setToolTip( i18n( "Compile file" ) );
+ action->setWhatsThis( i18n( "<b>Compile file</b><p>Runs <b>make filename.o</b> command from the directory where 'filename' is the name of currently opened file.<br>"
+ "Environment variables and make arguments can be specified "
+ "in the project settings dialog, <b>Build Options</b> tab." ) );
+
+ action = new KAction( i18n( "Install" ), 0,
+ this, SLOT( slotInstall() ),
+ actionCollection(), "build_install" );
+ action->setToolTip( i18n( "Install" ) );
+ action->setWhatsThis( i18n( "<b>Install</b><p>Runs <b>make install</b> command from the project directory.<br>"
+ "Environment variables and make arguments can be specified "
+ "in the project settings dialog, <b>Make Options</b> tab." ) );
+
+ action = new KAction( i18n( "Install Active Directory" ), 0,
+ this, SLOT( slotInstallActiveDir() ),
+ actionCollection(), "build_installactivetarget" );
+ action->setToolTip( i18n( "Install active directory" ) );
+ action->setWhatsThis( i18n( "<b>Install active directory</b><p>Runs <b>make install</b> command from the active directory.<br>"
+ "Environment variables and make arguments can be specified "
+ "in the project settings dialog, <b>Make Options</b> tab." ) );
+
+ action = new KAction( i18n( "Install (as root user)" ), 0,
+ this, SLOT( slotInstallWithKdesu() ),
+ actionCollection(), "build_install_kdesu" );
+ action->setToolTip( i18n( "Install as root user" ) );
+ action->setWhatsThis( i18n( "<b>Install</b><p>Runs <b>make install</b> command from the project directory with root privileges.<br>"
+ "It is executed via kdesu command.<br>"
+ "Environment variables and make arguments can be specified "
+ "in the project settings dialog, <b>Make Options</b> tab." ) );
+
+ action = new KAction( i18n( "&Clean Project" ), 0,
+ this, SLOT( slotClean() ),
+ actionCollection(), "build_clean" );
+ action->setToolTip( i18n( "Clean project" ) );
+ action->setWhatsThis( i18n( "<b>Clean project</b><p>Runs <b>make clean</b> command from the project directory.<br>"
+ "Environment variables and make arguments can be specified "
+ "in the project settings dialog, <b>Build Options</b> tab." ) );
+
+ action = new KAction( i18n( "Execute Program" ), "exec", 0,
+ this, SLOT( slotExecute() ),
+ actionCollection(), "build_execute" );
+ action->setToolTip( i18n( "Execute program" ) );
+ action->setWhatsThis( i18n( "<b>Execute program</b><p>Executes the main program specified in project settings, <b>Run Options</b> tab. "
+ "If it is not specified then the active target is used to determine the application to run." ) );
+
+ KActionMenu *menu = new KActionMenu( i18n( "Build &Target" ),
+ actionCollection(), "build_target" );
+ m_targetMenu = menu->popupMenu();
+ menu->setToolTip( i18n( "Build target" ) );
+ menu->setWhatsThis( i18n( "<b>Build target</b><p>Runs <b>make targetname</b> from the project directory (targetname is the name of the target selected).<br>"
+ "Environment variables and make arguments can be specified "
+ "in the project settings dialog, <b>Build Options</b> tab." ) );
+
+ m_targetObjectFilesMenu = new QPopupMenu();
+ m_targetOtherFilesMenu = new QPopupMenu();
+
+ m_makeEnvironmentsSelector = new KSelectAction( i18n( "Make &Environment" ), 0,
+ actionCollection(), "build_make_environment" );
+ m_makeEnvironmentsSelector->setToolTip( i18n( "Make environment" ) );
+ m_makeEnvironmentsSelector->setWhatsThis( i18n( "<b>Make Environment</b><p> Choose the set of environment variables to be passed on to make.<br>"
+ "Environment variables can be specified in the project "
+ "settings dialog, <b>Build Options</b> tab." ) );
+
+ connect( m_targetMenu, SIGNAL( aboutToShow() ),
+ this, SLOT( updateTargetMenu() ) );
+ connect( m_targetMenu, SIGNAL( activated( int ) ),
+ this, SLOT( targetMenuActivated( int ) ) );
+ connect( m_targetObjectFilesMenu, SIGNAL( activated( int ) ),
+ this, SLOT( targetObjectFilesMenuActivated( int ) ) );
+ connect( m_targetOtherFilesMenu, SIGNAL( activated( int ) ),
+ this, SLOT( targetOtherFilesMenuActivated( int ) ) );
+ connect( m_makeEnvironmentsSelector->popupMenu(), SIGNAL( aboutToShow() ),
+ this, SLOT( updateMakeEnvironmentsMenu() ) );
+ connect( m_makeEnvironmentsSelector->popupMenu(), SIGNAL( activated( int ) ),
+ this, SLOT( makeEnvironmentsMenuActivated( int ) ) );
+ connect( core(), SIGNAL( projectConfigWidget( KDialogBase* ) ),
+ this, SLOT( projectConfigWidget( KDialogBase* ) ) );
+ connect( core(), SIGNAL( contextMenu( QPopupMenu *, const Context * ) ),
+ this, SLOT( contextMenu( QPopupMenu *, const Context * ) ) );
+
+ connect( makeFrontend(), SIGNAL( commandFinished( const QString& ) ),
+ this, SLOT( slotCommandFinished( const QString& ) ) );
+ connect( makeFrontend(), SIGNAL( commandFailed( const QString& ) ),
+ this, SLOT( slotCommandFailed( const QString& ) ) );
+}
+
+
+CustomProjectPart::~CustomProjectPart()
+{}
+
+
+void CustomProjectPart::projectConfigWidget( KDialogBase *dlg )
+{
+ QVBox *vbox;
+ vbox = dlg->addVBoxPage( i18n( "Custom Manager" ), i18n( "Custom Manager" ), BarIcon( "make", KIcon::SizeMedium ) );
+ CustomManagerWidget *w0 = new CustomManagerWidget( this, vbox );
+ connect( dlg, SIGNAL( okClicked() ), w0, SLOT( accept() ) );
+
+ vbox = dlg->addVBoxPage( i18n( "Run Options" ), i18n( "Run Options" ), BarIcon( "make", KIcon::SizeMedium ) );
+ RunOptionsWidget *w1 = new RunOptionsWidget( *projectDom(), "/kdevcustomproject", buildDirectory(), vbox );
+ connect( dlg, SIGNAL( okClicked() ), w1, SLOT( accept() ) );
+ vbox = dlg->addVBoxPage( i18n( "Build Options" ), i18n( "Build Options" ), BarIcon( "make", KIcon::SizeMedium ) );
+ QTabWidget *buildtab = new QTabWidget( vbox );
+
+ CustomBuildOptionsWidget *w2 = new CustomBuildOptionsWidget( *projectDom(), buildtab );
+ connect( dlg, SIGNAL( okClicked() ), w2, SLOT( accept() ) );
+ buildtab->addTab( w2, i18n( "&Build" ) );
+
+ CustomOtherConfigWidget *w4 = new CustomOtherConfigWidget( this, "/kdevcustomproject", buildtab );
+ connect( dlg, SIGNAL( okClicked() ), w4, SLOT( accept() ) );
+ buildtab->addTab( w4, i18n( "&Other" ) );
+
+ CustomMakeConfigWidget *w3 = new CustomMakeConfigWidget( this, "/kdevcustomproject", buildtab );
+ buildtab->addTab( w3, i18n( "Ma&ke" ) );
+ w2->setMakeOptionsWidget( buildtab, w3, w4 );
+ connect( dlg, SIGNAL( okClicked() ), w3, SLOT( accept() ) );
+
+}
+
+
+void CustomProjectPart::contextMenu( QPopupMenu *popup, const Context *context )
+{
+ if ( !context->hasType( Context::FileContext ) )
+ return;
+
+ const FileContext *fcontext = static_cast<const FileContext*>( context );
+
+ m_contextAddFiles.clear();
+ m_contextRemoveFiles.clear();
+
+ QString popupstr = fcontext->urls().first().fileName();
+
+ if ( popupstr == QString::null )
+ popupstr = ".";
+
+ if ( fcontext->urls().size() == 1 && URLUtil::isDirectory( fcontext->urls().first() ) && !isInBlacklist( fcontext->urls().first().path() ) )
+ {
+ popup->insertSeparator();
+ // remember the name of the directory
+ m_contextDirName = fcontext->urls().first().path();
+ m_contextDirName = m_contextDirName.mid( project()->projectDirectory().length() + 1 );
+ int id = popup->insertItem( i18n( "Make Active Directory" ),
+ this, SLOT( slotChooseActiveDirectory() ) );
+ popup->setWhatsThis( id, i18n( "<b>Make active directory</b><p>"
+ "Chooses this directory as the destination for new files created using wizards "
+ "like the <i>New Class</i> wizard." ) );
+ }
+
+ kdDebug( 9025 ) << "context urls: " << fcontext->urls() << endl;
+ if ( fcontext->urls().size() == 1 && ( isProjectFileType( fcontext->urls().first().path() ) || URLUtil::isDirectory( fcontext->urls().first() ) ) )
+ {
+ popup->insertSeparator();
+ m_contextDirName = fcontext->urls().first().path();
+ m_contextDirName = m_contextDirName.mid( project()->projectDirectory().length() + 1 );
+ int id;
+ if ( isInBlacklist( m_contextDirName ) )
+ {
+ id = popup->insertItem( i18n( "Remove from blacklist" ),
+ this, SLOT( slotChangeBlacklist() ) );
+ popup->setWhatsThis( id, i18n( "<b>Remove from blacklist</b><p>"
+ "Removes the given file or directory from the "
+ "blacklist if it is already in it.<br>The blacklist contains files and"
+ " directories that should be ignored even if they match a project filetype "
+ "pattern" ) );
+ }
+ else
+ {
+ id = popup->insertItem( i18n( "Add to blacklist" ),
+ this, SLOT( slotChangeBlacklist() ) );
+ popup->setWhatsThis( id, i18n( "<b>Add to blacklist</b><p>"
+ "Adds the given file or directory to the blacklist.<br>The blacklist contains files and"
+ " directories that should be ignored even if they match a project filetype "
+ "pattern" ) );
+ }
+ }
+
+ const KURL::List urls = fcontext->urls();
+
+ bool dirAddRecursive = false;
+ bool dirDelRecursive = false;
+
+ for ( KURL::List::ConstIterator it = urls.begin(); it != urls.end(); ++it )
+ {
+ kdDebug( 9025 ) << "Checking URL: " << *it << endl;
+ QString canPath( URLUtil::canonicalPath(( *it ).path() ) );
+ QString relPath = relativeToProject( canPath );
+ kdDebug( 9025 ) << "relpath: " << relPath << "|canpath: " << canPath << endl;
+ if ( isInBlacklist( relPath ) )
+ continue;
+ if ((( *it ).isLocalFile() && isProjectFileType(( *it ).fileName() ) ) )
+ {
+ if ( project()->isProjectFile( canPath ) )
+ m_contextRemoveFiles << relPath;
+ if ( !project()->isProjectFile( canPath ) )
+ m_contextAddFiles << relPath;
+ }
+ if ( QFileInfo(( *it ).path() ).isDir() )
+ {
+ if ( containsProjectFiles( canPath ) || project()->isProjectFile( canPath ) )
+ {
+ if ( containsProjectFiles( canPath ) )
+ dirDelRecursive = true;
+ m_contextRemoveFiles << relPath;
+ }
+ if ( containsNonProjectFiles( canPath ) || !project()->isProjectFile( canPath ) )
+ {
+ if ( containsNonProjectFiles( canPath ) )
+ dirAddRecursive = true;
+ m_contextAddFiles << relPath;
+ }
+ }
+ }
+
+ if ( m_contextAddFiles.size() > 0 || m_contextRemoveFiles.size() > 0 )
+ popup->insertSeparator();
+ if ( m_contextAddFiles.size() > 0 )
+ {
+ int id = popup->insertItem( i18n( "Add Selected File/Dir(s) to Project" ),
+ this, SLOT( slotAddToProject() ) );
+ popup->setWhatsThis( id, i18n( "<b>Add to project</b><p>Adds selected file/dir(s) to the list of files in the project. "
+ "Note that the files should be manually added to the corresponding makefile or build.xml." ) );
+ if ( dirAddRecursive )
+ {
+ int id = popup->insertItem( i18n( "Add Selected Dir(s) to Project (recursive)" ),
+ this, SLOT( slotAddToProjectRecursive() ) );
+ popup->setWhatsThis( id, i18n( "<b>Add to project</b><p>Recursively adds selected dir(s) to the list of files in the project. "
+ "Note that the files should be manually added to the corresponding makefile or build.xml." ) );
+ }
+ }
+
+ if ( m_contextRemoveFiles.size() > 0 )
+ {
+ int id = popup->insertItem( i18n( "Remove Selected File/Dir(s) From Project" ),
+ this, SLOT( slotRemoveFromProject() ) );
+ popup->setWhatsThis( id, i18n( "<b>Remove from project</b><p>Removes selected file/dir(s) from the list of files in the project. "
+ "Note that the files should be manually excluded from the corresponding makefile or build.xml." ) );
+
+ if ( dirDelRecursive )
+ {
+ int id = popup->insertItem( i18n( "Remove Selected Dir(s) From Project (recursive)" ),
+ this, SLOT( slotRemoveFromProjectRecursive() ) );
+ popup->setWhatsThis( id, i18n( "<b>Remove from project</b><p>Recursively removes selected dir(s) from the list of files in the project. "
+ "Note that the files should be manually excluded from the corresponding makefile or build.xml." ) );
+ }
+ }
+}
+
+
+void CustomProjectPart::slotAddToProject()
+{
+ m_recursive = false;
+ m_first_recursive = true;
+ addFiles( m_contextAddFiles );
+}
+
+
+void CustomProjectPart::slotRemoveFromProject()
+{
+ m_recursive = false;
+ m_first_recursive = true;
+ removeFiles( m_contextRemoveFiles );
+}
+
+
+void CustomProjectPart::slotAddToProjectRecursive()
+{
+ m_recursive = true;
+ addFiles( m_contextAddFiles );
+ m_recursive = false;
+}
+
+
+void CustomProjectPart::slotRemoveFromProjectRecursive()
+{
+ m_recursive = true;
+ removeFiles( m_contextRemoveFiles );
+ m_recursive = false;
+}
+
+void CustomProjectPart::slotChangeBlacklist()
+{
+ switchBlacklistEntry( m_contextDirName );
+}
+
+void CustomProjectPart::slotChooseActiveDirectory()
+{
+ QString olddir = activeDirectory();
+ QDomDocument &dom = *projectDom();
+ DomUtil::writeEntry( dom, "/kdevcustomproject/general/activedir", m_contextDirName );
+ emit activeDirectoryChanged( olddir, activeDirectory() );
+}
+
+
+void CustomProjectPart::openProject( const QString &dirName, const QString &projectName )
+{
+ m_projectDirectory = dirName;
+ m_projectName = projectName;
+
+ QDomDocument &dom = *projectDom();
+ // Set the default directory radio to "executable"
+ if ( DomUtil::readEntry( dom, "/kdevcustomproject/run/directoryradio" ) == "" )
+ {
+ DomUtil::writeEntry( dom, "/kdevcustomproject/run/directoryradio", "executable" );
+ }
+
+ if ( filetypes().isEmpty() )
+ {
+ QStringList types;
+ types << "*.java" << "*.h" << "*.H" << "*.hh" << "*.hxx" << "*.hpp" << "*.c" << "*.C"
+ << "*.cc" << "*.cpp" << "*.c++" << "*.cxx" << "Makefile" << "CMakeLists.txt";
+ DomUtil::writeListEntry( dom, "/kdevcustomproject/filetypes", "filetype", types );
+ }
+
+ /*this entry is currently only created by the cmake kdevelop3 project generator
+ in order to support completely-out-of-source builds, where nothing, not
+ even the kdevelop project files are created in the source directory, Alex <neundorf@kde.org>
+ */
+ m_filelistDir = DomUtil::readEntry( dom, "/kdevcustomproject/filelistdirectory" );
+ if ( m_filelistDir.isEmpty() )
+ m_filelistDir = dirName;
+
+ if ( QFileInfo( m_filelistDir + "/" + projectName.lower() +
+ ".kdevelop.filelist" ).exists() )
+ {
+ QDir( m_filelistDir ).rename(
+ projectName.lower() + ".kdevelop.filelist",
+ projectName + ".kdevelop.filelist" );
+ }
+
+ QFile f( m_filelistDir + "/" + projectName + ".kdevelop.filelist" );
+ if ( f.open( IO_ReadOnly ) )
+ {
+ QTextStream stream( &f );
+ while ( !stream.atEnd() )
+ {
+ QString s = stream.readLine();
+ // Skip comments.
+ if ( s.isEmpty() || s.startsWith( "#" ) )
+ continue;
+ // Skip non-existent files.
+ if ( ! QFileInfo( projectDirectory() + "/" + s ).exists() )
+ continue;
+ // Do not bother with files already in project or on blacklist.
+ if ( isInProject( s ) || isInBlacklist( s ) )
+ continue;
+ addToProject( s );
+ }
+ QStringList newfiles;
+ findNewFiles( dirName, newfiles );
+
+ if ( newfiles.count() > 0 )
+ {
+ addNewFilesToProject( newfiles );
+ }
+
+ }
+ else
+ {
+ int r = KMessageBox::questionYesNo( mainWindow()->main(),
+ i18n( "This project does not contain any files yet.\n"
+ "Populate it with all C/C++/Java files below "
+ "the project directory?" ), QString::null, i18n( "Populate" ), i18n( "Do Not Populate" ) );
+ if ( r == KMessageBox::Yes )
+ populateProject();
+ }
+
+
+ // check if there is an old envvars entry (from old project file with single make environment)
+ QString buildtool = DomUtil::readEntry( dom , "/kdevcustomproject/build/buildtool" );
+ QDomElement el =
+ DomUtil::elementByPath( dom , "/kdevcustomproject/" + buildtool + "/envvars" );
+ if ( !el.isNull() )
+ {
+ QDomElement envs = DomUtil::createElementByPath( dom , "/kdevcustomproject/" + buildtool + "/environments" );
+ DomUtil::makeEmpty( envs );
+ el.setTagName( "default" );
+ envs.appendChild( el );
+ }
+ KDevProject::openProject( dirName, projectName );
+}
+
+
+/**
+ * @brief Recursively search given directory searching for files which may be part of this project.
+ *
+ * The files found not in a black list,
+ * and not being already part of our project are gathered.
+ *
+ * @param dir directory to scan (and recurse) for potential project files.
+ * @param[out] fileList the list of files found.
+ */
+void CustomProjectPart::findNewFiles( const QString& dir, QStringList& filelist ) const
+{
+ if ( dir.isEmpty() )
+ return;
+ QStringList fileentries = QDir( dir ).entryList( filetypes().join( ";" ) );
+ QStringList dirs = QDir( dir ).entryList( QDir::Dirs );
+ QStringList entries = fileentries + dirs;
+ QString relpath = relativeToProject( dir );
+ if ( !relpath.isEmpty() )
+ relpath += "/";
+ for ( QStringList::const_iterator it = entries.begin(); it != entries.end(); ++it )
+ {
+ // Only process genuine entries - files and directories.
+ if (( *it == "." ) || ( *it == ".." ) )
+ continue;
+ // If the entry (be it a file or a directory) is already part of this project, proceed to next one.
+ const QString relativeEntry( relpath + *it );
+ if ( isInProject( relativeEntry ) )
+ continue;
+ // If the entry is blacklisted, proceed to next one.
+ // Note that by using generic isInBlacklist(),
+ // we are actually wasting resources,
+ // because it also tests whether any parent directory of relativeEntry is blacklisted.
+ // But by the order we are traversing and processing the directories,
+ // we know it is not the case, ever.
+ if ( isInBlacklist( relativeEntry ) )
+ continue;
+ // We have a new, non-blacklisted entry.
+ // Recurse into it (a directory) or add it to the potential list of new project files.
+ const QString absoluteEntry( dir + "/" + *it );
+ if ( QFileInfo( absoluteEntry ).isFile() )
+ {
+ filelist << relativeEntry;
+ }
+ else if ( QFileInfo( absoluteEntry ).isDir() )
+ {
+ bool searchRecursive = true;
+ QFileInfo fi( absoluteEntry );
+ if( fi.isSymLink() )
+ {
+ QString realDir = fi.readLink();
+ if( QFileInfo( realDir ).exists() )
+ {
+ for( QStringList::const_iterator it = filelist.constBegin(); it != filelist.constEnd(); ++it )
+ {
+
+ if( QFileInfo(projectDirectory()+"/"+*it).absFilePath().startsWith( realDir ) )
+ {
+ searchRecursive = false;
+ }
+ }
+ } else {
+ searchRecursive = false;
+ }
+ }
+ if( searchRecursive )
+ {
+ findNewFiles( absoluteEntry, filelist );
+ }
+ }
+ }
+}
+
+
+void CustomProjectPart::populateProject()
+{
+
+ KDialogBase* dlg = new KDialogBase( mainWindow()->main(), "typeselector", true,
+ "Select filetypes of project", KDialogBase::Ok | KDialogBase::Cancel );
+ QVBox* box = dlg->makeVBoxMainWidget();
+ KEditListBox* lb = new KEditListBox( "Filetypes in the project", box, "selecttypes",
+ false, KEditListBox::Add | KEditListBox::Remove );
+ lb->setItems( filetypes() );
+ if ( dlg->exec() == QDialog::Accepted )
+ {
+ setFiletypes( lb->items() );
+ }
+
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ removeFiles( allFiles() );
+ updateBlacklist( QStringList() );
+
+ QStringList newlist;
+
+ findNewFiles( projectDirectory(), newlist );
+
+ QApplication::restoreOverrideCursor();
+ addNewFilesToProject( newlist );
+}
+
+
+void CustomProjectPart::closeProject()
+{
+ saveProject();
+}
+
+void CustomProjectPart::saveProject()
+{
+ QFile f( m_filelistDir + "/" + m_projectName + ".kdevelop.filelist" );
+ if ( !f.open( IO_WriteOnly ) )
+ return;
+
+ QTextStream stream( &f );
+ stream << "# KDevelop Custom Project File List" << endl;
+
+ ProjectFilesSet::ConstIterator it;
+ for ( it = m_sourceFilesSet.constBegin(); it != m_sourceFilesSet.constEnd(); ++it )
+ stream << it.key() << endl;
+ f.close();
+}
+
+
+QString CustomProjectPart::projectDirectory() const
+{
+ return m_projectDirectory;
+}
+
+
+QString CustomProjectPart::projectName() const
+{
+ return m_projectName;
+}
+
+
+/** Retuns a PairList with the run environment variables */
+DomUtil::PairList CustomProjectPart::runEnvironmentVars() const
+{
+ return DomUtil::readPairListEntry( *projectDom(), "/kdevcustomproject/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 CustomProjectPart::runDirectory() const
+{
+ QString cwd = defaultRunDirectory( "kdevcustomproject" );
+ 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 CustomProjectPart::mainProgram() const
+{
+ QDomDocument * dom = projectDom();
+
+ if ( !dom ) return QString();
+
+ QString DomMainProgram = DomUtil::readEntry( *dom, "/kdevcustomproject/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 CustomProjectPart::debugArguments() const
+{
+ return DomUtil::readEntry( *projectDom(), "/kdevcustomproject/run/globaldebugarguments" );
+}
+
+
+/** Retuns a QString with the run command line arguments */
+QString CustomProjectPart::runArguments() const
+{
+ return DomUtil::readEntry( *projectDom(), "/kdevcustomproject/run/programargs" );
+}
+
+QString CustomProjectPart::activeDirectory() const
+{
+ QDomDocument &dom = *projectDom();
+ return DomUtil::readEntry( dom, "/kdevcustomproject/general/activedir", "." );
+}
+
+
+QStringList CustomProjectPart::allFiles() const
+{
+ return m_sourceFilesSet.keys();
+}
+
+
+void CustomProjectPart::addFile( const QString &fileName )
+{
+ QStringList fileList;
+ fileList.append( fileName );
+
+ this->addFiles( fileList );
+}
+
+void CustomProjectPart::addFiles( const QStringList& fileList )
+{
+ QStringList::ConstIterator it;
+ QStringList addedFiles;
+ QStringList myfileList = fileList;
+ kdDebug( 9025 ) << "Adding files: " << myfileList << endl;
+ myfileList.remove( "." );
+ myfileList.remove( "" );
+ myfileList.remove( ".." );
+ for ( it = myfileList.begin(); it != myfileList.end(); ++it )
+ {
+ if ( isInBlacklist( *it ) )
+ continue;
+ QString relpath;
+ kdDebug( 9025 ) << "Checking path: " << *it << endl;
+ if ( QDir::isRelativePath( *it ) )
+ {
+ kdDebug( 9025 ) << *it << " is relative" << endl;
+ relpath = *it;
+ }
+ else
+ {
+ kdDebug( 9025 ) << *it << " is not relative" << endl;
+ relpath = relativeToProject( *it );
+ }
+
+ if ( !QFileInfo( projectDirectory() + "/" + relpath ).exists() )
+ continue;
+
+ if ( QFileInfo( projectDirectory() + "/" + relpath ).isDir() && ( m_recursive || m_first_recursive ) )
+ {
+ kdDebug( 9025 ) << "is a dir and " << m_recursive << "|" << m_first_recursive << endl;
+ m_first_recursive = false;
+ QStringList fileentries = QDir( projectDirectory() + "/" + relpath ).entryList( filetypes().join( ";" ) );
+ QStringList dirs = QDir( projectDirectory() + "/" + relpath ).entryList( QDir::Dirs );
+ QStringList subentries = fileentries + dirs;
+ for ( QStringList::iterator subit = subentries.begin(); subit != subentries.end(); ++subit )
+ {
+ if ( *subit != "." && *subit != ".." )
+ *subit = relpath + "/" + ( *subit );
+ if (( *subit ).startsWith( "/" ) )
+ *subit = ( *subit ).mid( 1, ( *subit ).length() );
+ }
+ addFiles( subentries );
+ addedFiles << relpath;
+ addToProject( relpath );
+ m_first_recursive = true;
+ }
+ else if ( isProjectFileType( QFileInfo( relpath ).fileName() ) && ( ! isInProject( relpath ) ) )
+ {
+ QStringList paths = QStringList::split( "/", relpath );
+ paths.pop_back();
+ QString path;
+ for ( QStringList::const_iterator it = paths.begin(); it != paths.end(); ++it )
+ {
+ path += *it;
+ if ( ! isInProject( path ) )
+ {
+ addedFiles << path;
+ addToProject( path );
+ }
+ path += "/";
+ }
+ addedFiles << relpath;
+ addToProject( relpath );
+ }
+ else
+ {
+ kdDebug( 9025 ) << "not adding " << relpath << endl;
+ }
+ }
+ m_first_recursive = false;
+ saveProject();
+
+ kdDebug( 9025 ) << "Emitting addedFilesToProject" << addedFiles << endl;
+ emit addedFilesToProject( addedFiles );
+}
+
+void CustomProjectPart::removeFile( const QString &fileName )
+{
+ QStringList fileList;
+ fileList.append( fileName );
+
+ this->removeFiles( fileList );
+}
+
+void CustomProjectPart::removeFiles( const QStringList& fileList )
+{
+ kdDebug( 9025 ) << "Emitting removedFilesFromProject" << fileList << endl;
+ QStringList removedFiles;
+ QStringList myfileList = fileList;
+ QStringList::ConstIterator it;
+ myfileList.remove( "." );
+ myfileList.remove( ".." );
+ myfileList.remove( "" );
+
+ for ( it = myfileList.begin(); it != myfileList.end(); ++it )
+ {
+ QString relpath;
+ if ( QDir::isRelativePath( *it ) )
+ relpath = *it;
+ else
+ relpath = relativeToProject( *it );
+
+ if ( QFileInfo( projectDirectory() + "/" + relpath ).isDir() && ( m_recursive || m_first_recursive ) )
+ {
+ m_first_recursive = false;
+ QStringList fileentries = QDir( projectDirectory() + "/" + relpath ).entryList( filetypes().join( ";" ) );
+ QStringList dirs = QDir( projectDirectory() + "/" + relpath ).entryList( QDir::Dirs );
+ QStringList subentries = fileentries + dirs;
+ for ( QStringList::iterator subit = subentries.begin(); subit != subentries.end(); ++subit )
+ if ( *subit != "." && *subit != ".." )
+ *subit = relpath + "/" + ( *subit );
+ removeFiles( subentries );
+ if ( !containsProjectFiles( relpath ) )
+ {
+ removedFiles << relpath;
+ removeFromProject( relpath );
+ }
+ m_first_recursive = true;
+ }
+ else if ( isInProject( relpath ) )
+ {
+ removedFiles << relpath;
+ removeFromProject( relpath );
+ QStringList paths = QStringList::split( "/", relpath );
+ QString lastsubentry = paths[paths.size()-1];
+ paths.pop_back();
+ while ( paths.size() > 0 )
+ {
+ QString dir = paths.join( "/" );
+ QStringList projectentries = projectFilesInDir( dir );
+ if ( projectentries.size() == 0 )
+ {
+ removedFiles << dir;
+ removeFromProject( dir );
+ }
+ else
+ break;
+ lastsubentry = paths[paths.size()-1];
+ paths.pop_back();
+ }
+ }
+ }
+
+ saveProject();
+ emit removedFilesFromProject( removedFiles );
+}
+
+QString CustomProjectPart::buildDirectory() const
+{
+ QString dir = DomUtil::readEntry( *projectDom(), "/kdevcustomproject/build/builddir" );
+ if ( dir.isEmpty() )
+ return projectDirectory();
+ if ( QFileInfo( dir ).isRelative() )
+ return QDir::cleanDirPath( projectDirectory() + "/" + dir );
+ return dir;
+}
+
+
+QString CustomProjectPart::makeEnvironment() const
+{
+ // Get the make environment variables pairs into the environstr string
+ // in the form of: "ENV_VARIABLE=ENV_VALUE"
+ // Note that we quote the variable value due to the possibility of
+ // embedded spaces
+ QString buildtool = DomUtil::readEntry( *projectDom(), "/kdevcustomproject/build/buildtool" );
+ DomUtil::PairList envvars =
+ DomUtil::readPairListEntry( *projectDom(), "/kdevcustomproject/" + buildtool + "/environments/" + currentMakeEnvironment(), "envvar", "name", "value" );
+
+ QString environstr;
+ DomUtil::PairList::ConstIterator it;
+ for ( it = envvars.begin(); it != envvars.end(); ++it )
+ {
+ environstr += ( *it ).first;
+ environstr += "=";
+ environstr += EnvVarTools::quote(( *it ).second );
+ environstr += " ";
+ }
+
+ KConfigGroup grp( kapp->config(), "MakeOutputView" );
+ if( grp.readBoolEntry( "ForceCLocale", true ) )
+ environstr += "LC_MESSAGES=" + EnvVarTools::quote( "C" )+" "+" "+"LC_CTYPE="+EnvVarTools::quote("C")+" ";
+
+ return environstr;
+}
+
+
+void CustomProjectPart::startMakeCommand( const QString &dir, const QString &target, bool withKdesu )
+{
+ if ( partController()->saveAllFiles() == false )
+ return; //user cancelled
+
+ QDomDocument &dom = *projectDom();
+ QString buildtool = DomUtil::readEntry( dom, "/kdevcustomproject/build/buildtool" );
+
+ QString cmdline;
+ if ( buildtool == "ant" )
+ {
+ cmdline = "ant";
+ }
+ else if ( buildtool == "other" )
+ {
+ cmdline = DomUtil::readEntry( dom, "/kdevcustomproject/other/otherbin" );
+ if ( cmdline.isEmpty() )
+ cmdline = "echo";
+ else if ( cmdline.find( "/" ) == -1 )
+ cmdline = "./" + cmdline;
+ cmdline += " " + DomUtil::readEntry( dom, "/kdevcustomproject/other/otheroptions" );
+ }
+ else
+ {
+ cmdline = DomUtil::readEntry( dom, "/kdevcustomproject/make/makebin" );
+ if ( cmdline.isEmpty() )
+ cmdline = MAKE_COMMAND;
+ if ( !DomUtil::readBoolEntry( dom, "/kdevcustomproject/make/abortonerror" ) )
+ cmdline += " -k";
+ int jobs = DomUtil::readIntEntry( dom, "/kdevcustomproject/make/numberofjobs" );
+ if ( jobs != 0 )
+ {
+ cmdline += " -j";
+ cmdline += QString::number( jobs );
+ }
+ if ( DomUtil::readBoolEntry( dom, "/kdevcustomproject/make/dontact" ) )
+ cmdline += " -n";
+ cmdline += " " + DomUtil::readEntry( dom, "/kdevcustomproject/make/makeoptions" );
+ }
+
+ cmdline += " ";
+ if ( !target.isEmpty() )
+ cmdline += KProcess::quote( target );
+
+ QString dircmd = "cd ";
+ dircmd += KProcess::quote( dir );
+ dircmd += " && ";
+
+ int prio = DomUtil::readIntEntry( dom, "/kdevcustomproject/" + buildtool + "/prio" );
+ QString nice;
+ if ( prio != 0 )
+ {
+ nice = QString( "nice -n%1 " ).arg( prio );
+ }
+
+ cmdline.prepend( nice );
+ cmdline.prepend( makeEnvironment() );
+
+ if ( withKdesu )
+ cmdline = "kdesu -t -c '" + cmdline + "'";
+
+ m_buildCommand = dircmd + cmdline;
+
+
+ makeFrontend()->queueCommand( dir, dircmd + cmdline );
+}
+
+
+void CustomProjectPart::slotBuild()
+{
+ m_lastCompilationFailed = false;
+ QString buildtool = DomUtil::readEntry( *projectDom(), "/kdevcustomproject/build/buildtool" );
+ startMakeCommand( buildDirectory(), DomUtil::readEntry( *projectDom(),
+ "/kdevcustomproject/" + buildtool + "/defaulttarget" ) );
+}
+
+void CustomProjectPart::slotBuildActiveDir()
+{
+ m_lastCompilationFailed = false;
+ QString buildtool = DomUtil::readEntry( *projectDom(), "/kdevcustomproject/build/buildtool" );
+ startMakeCommand( buildDirectory() + "/" + activeDirectory(), DomUtil::readEntry( *projectDom(),
+ "/kdevcustomproject/" + buildtool + "/defaulttarget" ) );
+}
+
+
+void CustomProjectPart::slotCompileFile()
+{
+ KParts::ReadWritePart *part = dynamic_cast<KParts::ReadWritePart*>( partController()->activePart() );
+ if ( !part || !part->url().isLocalFile() )
+ return;
+
+ QString fileName = part->url().path();
+ QFileInfo fi( fileName );
+ QString sourceDir = fi.dirPath();
+ QString baseName = fi.baseName( true );
+ kdDebug( 9025 ) << "Compiling " << fileName
+ << "in dir " << sourceDir
+ << " with baseName " << baseName << endl;
+
+ // What would be nice: In case of non-recursive build system, climb up from
+ // the source dir until a Makefile is found
+
+ QString buildDir = sourceDir;
+ QString target = baseName + ".o";
+
+ QString buildtool = DomUtil::readEntry( *projectDom(), "/kdevcustomproject/build/buildtool" );
+
+ //if there is no Makefile in the directory of the source file
+ //try to build it from the main build dir
+ //this works e.g. for non-recursive cmake Makefiles, Alex
+ if ( buildtool == "make" && ( QFile::exists( sourceDir + "/Makefile" ) == false )
+ && ( QFile::exists( sourceDir + "/makefile" ) == false ) )
+ {
+ buildDir = buildDirectory();
+ }
+
+ startMakeCommand( buildDir, target );
+}
+
+void CustomProjectPart::slotInstallActiveDir()
+{
+ startMakeCommand( buildDirectory() + "/" + activeDirectory(), QString::fromLatin1( "install" ) );
+}
+
+void CustomProjectPart::slotInstall()
+{
+ startMakeCommand( buildDirectory(), QString::fromLatin1( "install" ) );
+}
+
+
+void CustomProjectPart::slotInstallWithKdesu()
+{
+ // First issue "make" to build the entire project with the current user
+ // This way we make sure all files are up to date before we do the "make install"
+ slotBuild();
+
+ // After that issue "make install" with the root user
+ startMakeCommand( buildDirectory(), QString::fromLatin1( "install" ), true );
+}
+
+void CustomProjectPart::slotClean()
+{
+ startMakeCommand( buildDirectory(), QString::fromLatin1( "clean" ) );
+}
+
+
+void CustomProjectPart::slotExecute()
+{
+ partController()->saveAllFiles();
+
+ bool _auto = false;
+ if ( DomUtil::readBoolEntry( *projectDom(), "/kdevcustomproject/run/autocompile", true ) && ( isDirty() || !QFileInfo( mainProgram() ).exists() ) )
+ {
+ m_executeAfterBuild = true;
+ slotBuild();
+ _auto = true;
+ }
+
+ if ( DomUtil::readBoolEntry( *projectDom(), "/kdevcustomproject/run/autoinstall", false ) && ( isDirty() || !QFileInfo( mainProgram() ).exists() ) )
+ {
+ m_executeAfterBuild = true;
+ // Use kdesu??
+ if ( DomUtil::readBoolEntry( *projectDom(), "/kdevcustomproject/run/autokdesu", false ) )
+ //slotInstallWithKdesu assumes that it hasn't just been build...
+ _auto ? slotInstallWithKdesu() : startMakeCommand( buildDirectory(), QString::fromLatin1( "install" ), true );
+ else
+ slotInstall();
+ _auto = true;
+ }
+
+ if ( _auto )
+ return;
+
+ // Get the run environment variables pairs into the environstr string
+ // in the form of: "ENV_VARIABLE=ENV_VALUE"
+ // Note that we quote the variable value due to the possibility of
+ // embedded spaces
+ DomUtil::PairList envvars = runEnvironmentVars();
+ QString environstr;
+ DomUtil::PairList::ConstIterator it;
+ for ( it = envvars.begin(); it != envvars.end(); ++it )
+ {
+ environstr += ( *it ).first;
+ environstr += "=";
+ environstr += EnvVarTools::quote(( *it ).second );
+ environstr += " ";
+ }
+
+ if ( mainProgram().isEmpty() )
+ // Do not execute non executable targets
+ return;
+
+ QString program = environstr;
+ program += mainProgram();
+ program += " " + runArguments();
+
+ bool inTerminal = DomUtil::readBoolEntry( *projectDom(), "/kdevcustomproject/run/terminal" );
+
+ kdDebug( 9025 ) << "runDirectory: <" << runDirectory() << ">" << endl;
+ kdDebug( 9025 ) << "environstr : <" << environstr << ">" << endl;
+ kdDebug( 9025 ) << "mainProgram : <" << mainProgram() << ">" << endl;
+ kdDebug( 9025 ) << "runArguments: <" << runArguments() << ">" << endl;
+
+ appFrontend()->startAppCommand( runDirectory(), program, inTerminal );
+}
+
+void CustomProjectPart::updateTargetMenu()
+{
+ m_targets.clear();
+ m_targetsObjectFiles.clear();
+ m_targetsOtherFiles.clear();
+ m_targetMenu->clear();
+ m_targetObjectFilesMenu->clear();
+ m_targetOtherFilesMenu->clear();
+
+ QDomDocument &dom = *projectDom();
+ bool ant = DomUtil::readEntry( dom, "/kdevcustomproject/build/buildtool" ) == "ant";
+
+ if ( ant )
+ {
+ QFile f( buildDirectory() + "/build.xml" );
+ if ( !f.open( IO_ReadOnly ) )
+ {
+ kdDebug( 9025 ) << "No build file" << endl;
+ return;
+ }
+ QDomDocument dom;
+ if ( !dom.setContent( &f ) )
+ {
+ kdDebug( 9025 ) << "Build script not valid xml" << endl;
+ f.close();
+ return;
+ }
+ f.close();
+
+ QDomNode node = dom.documentElement().firstChild();
+ while ( !node.isNull() )
+ {
+ if ( node.toElement().tagName() == "target" )
+ m_targets.append( node.toElement().attribute( "name" ) );
+ node = node.nextSibling();
+ }
+ }
+ else
+ {
+ kdDebug( 9025 ) << "Trying to load a makefile... " << endl;
+
+ m_makefileVars.clear();
+ m_parsedMakefiles.clear();
+ m_makefilesToParse.clear();
+ m_makefilesToParse.push( "Makefile" );
+ m_makefilesToParse.push( "makefile" );
+ putEnvVarsInVarMap();
+ while ( !m_makefilesToParse.isEmpty() )
+ parseMakefile( m_makefilesToParse.pop() );
+
+ //free the memory again
+ m_makefileVars.clear();
+ m_parsedMakefiles.clear();
+
+ m_targets.sort();
+ m_targetsObjectFiles.sort();
+ m_targetsOtherFiles.sort();
+
+ }
+
+ m_targetMenu->insertItem( i18n( "Object Files" ), m_targetObjectFilesMenu );
+ m_targetMenu->insertItem( i18n( "Other Files" ), m_targetOtherFilesMenu );
+
+ int id = 0;
+ QStringList::ConstIterator it;
+ for ( it = m_targets.begin(); it != m_targets.end(); ++it )
+ m_targetMenu->insertItem( *it, id++ );
+
+ id = 0;
+ for ( it = m_targetsObjectFiles.begin(); it != m_targetsObjectFiles.end(); ++it )
+ m_targetObjectFilesMenu->insertItem( *it, id++ );
+
+ id = 0;
+ for ( it = m_targetsOtherFiles.begin(); it != m_targetsOtherFiles.end(); ++it )
+ m_targetOtherFilesMenu->insertItem( *it, id++ );
+}
+
+void CustomProjectPart::putEnvVarsInVarMap()
+{
+ DomUtil::PairList envvars =
+ DomUtil::readPairListEntry( *projectDom(), "/kdevcustomproject/make/environments/" + currentMakeEnvironment(), "envvar", "name", "value" );
+
+ for ( DomUtil::PairList::ConstIterator it = envvars.begin(); it != envvars.end(); ++it )
+ m_makefileVars[( *it ).first] = ( *it ).second; //is qouting here required as in makeEnvironment() ??
+}
+
+void CustomProjectPart::parseMakefile( const QString& filename )
+{
+ if ( m_parsedMakefiles.contains( filename ) )
+ return;
+
+ m_parsedMakefiles.insert( filename, 1 );
+
+ QString absFilename = filename;
+ if ( !filename.startsWith( "/" ) )
+ absFilename = buildDirectory() + "/" + filename;
+
+ QFile f( absFilename );
+ if ( !f.open( IO_ReadOnly ) )
+ {
+ kdDebug( 9025 ) << "could not open " << absFilename << endl;
+ return;
+ }
+ QRegExp targetRe( "^ *([^\\t$.#]\\S+) *:.*$" );
+ targetRe.setMinimal( true );
+
+ QRegExp variablesRe( "\\$\\(\\s*([^\\)\\s]+)\\s*\\)" );
+ QRegExp assignmentRe( "^\\s*(\\S+)\\s*[:\\?]?=\\s*(\\S+)\\s*(#.*)?$" );
+
+ QRegExp includedMakefilesRe( "^include\\s+(\\S+)" );
+ QString str = "";
+ while ( !f.atEnd() )
+ {
+ f.readLine( str, 200 );
+
+ // Replace any variables in the current line
+ int offset = -1;
+ while (( offset = variablesRe.search( str, offset + 1 ) ) != -1 )
+ {
+ QString variableName = variablesRe.cap( 1 ).simplifyWhiteSpace();
+ if ( m_makefileVars.contains( variableName ) )
+ {
+ str.replace( variablesRe.cap( 0 ), m_makefileVars[variableName] );
+ }
+ }
+
+ // Read all continuation lines
+ // kdDebug(9025) << "Trying: " << str.simplifyWhiteSpace() << endl;
+ //while (str.right(1) == "\\" && !stream.atEnd()) {
+ // str.remove(str.length()-1, 1);
+ // str += stream.readLine();
+ //}
+ // Find any variables
+ if ( assignmentRe.search( str ) != -1 )
+ {
+ m_makefileVars[assignmentRe.cap( 1 ).simplifyWhiteSpace()] = assignmentRe.cap( 2 ).simplifyWhiteSpace();
+ }
+ else if ( includedMakefilesRe.search( str ) != -1 )
+ {
+ QString includedMakefile = includedMakefilesRe.cap( 1 ).simplifyWhiteSpace();
+ m_makefilesToParse.push( includedMakefile );
+ }
+ else if ( targetRe.search( str ) != -1 )
+ {
+ QString tmpTarget = targetRe.cap( 1 ).simplifyWhiteSpace();
+ if ( tmpTarget.endsWith( ".o" ) )
+ {
+ if ( m_targetsObjectFiles.find( tmpTarget ) == m_targetsObjectFiles.end() )
+ m_targetsObjectFiles += tmpTarget;
+ }
+ else if ( tmpTarget.contains( '.' ) )
+ {
+ if ( m_targetsOtherFiles.find( tmpTarget ) == m_targetsOtherFiles.end() )
+ m_targetsOtherFiles += tmpTarget;
+ }
+ else
+ {
+ if ( m_targets.find( tmpTarget ) == m_targets.end() )
+ m_targets += tmpTarget;
+ }
+ }
+ }
+ f.close();
+}
+
+void CustomProjectPart::targetMenuActivated( int id )
+{
+ QString target = m_targets[id];
+ startMakeCommand( buildDirectory(), target );
+}
+
+void CustomProjectPart::targetObjectFilesMenuActivated( int id )
+{
+ QString target = m_targetsObjectFiles[id];
+ startMakeCommand( buildDirectory(), target );
+}
+
+void CustomProjectPart::targetOtherFilesMenuActivated( int id )
+{
+ QString target = m_targetsOtherFiles[id];
+ startMakeCommand( buildDirectory(), target );
+}
+
+void CustomProjectPart::updateMakeEnvironmentsMenu()
+{
+ QDomDocument &dom = *projectDom();
+ bool makeUsed = ( DomUtil::readEntry( dom, "/kdevcustomproject/build/buildtool" ) == "make" );
+ if ( makeUsed )
+ {
+ QStringList l = allMakeEnvironments();
+ m_makeEnvironmentsSelector->setItems( l );
+ m_makeEnvironmentsSelector->setCurrentItem( l.findIndex( currentMakeEnvironment() ) );
+ }
+ else
+ {
+ m_makeEnvironmentsSelector->clear();
+ }
+ /*
+ m_makeEnvironmentsMenu->clear();
+ QDomDocument &dom = *projectDom();
+
+ QStringList environments = allMakeEnvironments();
+ QStringList::ConstIterator it;
+ int id = 0;
+ for (it = environments.begin(); it != environments.end(); ++it)
+ m_makeEnvironmentsMenu->insertItem(*it, id++);
+ }
+ */
+}
+
+void CustomProjectPart::makeEnvironmentsMenuActivated( int id )
+{
+ QDomDocument &dom = *projectDom();
+ QString environment = allMakeEnvironments()[id];
+ DomUtil::writeEntry( dom, "/kdevcustomproject/make/selectedenvironment", environment );
+}
+
+void CustomProjectPart::slotCommandFinished( const QString& command )
+{
+ kdDebug( 9025 ) << "CustomProjectPart::slotProcessFinished()" << endl;
+
+ if ( m_buildCommand != command )
+ return;
+
+ m_buildCommand = QString::null;
+
+ m_timestamp.clear();
+ QStringList fileList = allFiles();
+ QStringList::Iterator it = fileList.begin();
+ while ( it != fileList.end() )
+ {
+ QString fileName = *it;
+ ++it;
+
+ m_timestamp[ fileName ] = QFileInfo( projectDirectory(), fileName ).lastModified();
+ }
+
+ emit projectCompiled();
+
+ if ( m_executeAfterBuild )
+ {
+ slotExecute();
+ m_executeAfterBuild = false;
+ }
+}
+
+void CustomProjectPart::slotCommandFailed( const QString& /*command*/ )
+{
+ m_lastCompilationFailed = true;
+ m_executeAfterBuild = false;
+}
+
+bool CustomProjectPart::isDirty()
+{
+ if ( m_lastCompilationFailed ) return true;
+
+ QStringList fileList = allFiles();
+ QStringList::Iterator it = fileList.begin();
+ while ( it != fileList.end() )
+ {
+ QString fileName = *it;
+ ++it;
+
+ QMap<QString, QDateTime>::Iterator it = m_timestamp.find( fileName );
+ QDateTime t = QFileInfo( projectDirectory(), fileName ).lastModified();
+ if ( it == m_timestamp.end() || *it != t )
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+QStringList CustomProjectPart::allMakeEnvironments() const
+{
+ QDomDocument &dom = *projectDom();
+
+ QStringList allConfigs;
+
+ QDomNode node =
+ DomUtil::elementByPath( dom , "/kdevcustomproject/make/environments" );
+ // extract the names of the different make environments
+ QDomElement childEl = node.firstChild().toElement();
+ while ( !childEl.isNull() )
+ {
+ QString config = childEl.tagName();
+ allConfigs.append( config );
+ childEl = childEl.nextSibling().toElement();
+ }
+ if ( allConfigs.isEmpty() )
+ allConfigs.append( "default" );
+
+ return allConfigs;
+}
+
+
+QString CustomProjectPart::currentMakeEnvironment() const
+{
+ QStringList allEnvs = allMakeEnvironments();
+ QDomDocument &dom = *projectDom();
+ QString environment = DomUtil::readEntry( dom, "/kdevcustomproject/make/selectedenvironment" );
+ if ( environment.isEmpty() || !allEnvs.contains( environment ) )
+ environment = allEnvs[0];
+ return environment;
+}
+
+/*!
+ \fn CustomProjectPart::distFiles() const
+ */
+QStringList CustomProjectPart::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;
+}
+
+bool CustomProjectPart::containsNonProjectFiles( const QString& dir )
+{
+ if ( isInBlacklist( dir ) )
+ return false;
+ QStringList fileentries = QDir( dir ).entryList( filetypes().join( ";" ) );
+ QStringList dirs = QDir( dir ).entryList( QDir::Dirs );
+ QStringList subentries = fileentries + dirs;
+ subentries.remove( "." );
+ subentries.remove( ".." );
+ for ( QStringList::const_iterator it = subentries.begin(); it != subentries.end(); ++it )
+ {
+ if ( isInBlacklist( *it ) )
+ continue;
+ if ( QFileInfo( dir + "/" + *it ).isDir() && !isInBlacklist( *it ) )
+ {
+ if ( containsNonProjectFiles( dir + "/" + *it ) )
+ {
+ return true;
+ }
+ }
+ else if ( !project()->isProjectFile( URLUtil::canonicalPath( dir + "/" + *it ) )
+ && !isInBlacklist( *it ) )
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool CustomProjectPart::containsProjectFiles( const QString& dir )
+{
+ if ( isInBlacklist( dir ) )
+ return false;
+
+ QStringList fileentries = QDir( dir ).entryList( filetypes().join( ";" ) );
+ QStringList dirs = QDir( dir ).entryList( QDir::Dirs );
+ QStringList subentries = fileentries + dirs;
+ subentries.remove( "." );
+ subentries.remove( ".." );
+ for ( QStringList::const_iterator it = subentries.begin(); it != subentries.end(); ++it )
+ {
+ if ( isInBlacklist( *it ) )
+ continue;
+
+ if ( QFileInfo( dir + "/" + *it ).isDir() && !isInBlacklist( *it ) )
+ {
+ if ( containsProjectFiles( dir + "/" + *it ) )
+ {
+ return true;
+ }
+ }
+ else if ( project()->isProjectFile( URLUtil::canonicalPath( dir + "/" + *it ) ) && !isInBlacklist( *it ) )
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+QStringList CustomProjectPart::projectFilesInDir( const QString& dir )
+{
+ QStringList result;
+ QStringList fileentries = QDir( projectDirectory() + "/" + dir ).entryList( filetypes().join( ";" ) );
+ QStringList dirs = QDir( projectDirectory() + "/" + dir ).entryList( QDir::Dirs );
+ QStringList subentries = fileentries + dirs;
+ subentries.remove( "." );
+ subentries.remove( ".." );
+ for ( QStringList::const_iterator it = subentries.begin(); it != subentries.end(); ++it )
+ {
+ if ( isInProject( dir + "/" + *it ) )
+ {
+ result << ( *it );
+ }
+ }
+ return result;
+}
+
+QStringList CustomProjectPart::filetypes( ) const
+{
+ return DomUtil::readListEntry( *projectDom(), "/kdevcustomproject/filetypes", "filetype" );
+}
+
+bool CustomProjectPart::isProjectFileType( const QString& filename ) const
+{
+ QStringList types = filetypes();
+ QRegExp re( "", true, true );
+ for ( QStringList::const_iterator it = types.begin(); it != types.end(); ++it )
+ {
+ re.setPattern( *it );
+ int pos = re.search( filename );
+ uint len = re.matchedLength();
+ if ((( *it ).find( "*" ) != -1 || ( *it ).find( "?" ) != -1 ) && pos + len == filename.length() )
+ return true;
+ else if ( filename.find( "/" ) != -1 && filename.find( *it ) != -1 )
+ return true;
+ else if ( filename.find( "/" ) == -1 && filename == *it )
+ return true;
+ }
+ return false;
+}
+
+void CustomProjectPart::switchBlacklistEntry( const QString& path )
+{
+ QStringList blacklist = this->blacklist();
+ kdDebug( 9025 ) << "Switching path " << path << endl;
+ if ( !isInBlacklist( path ) )
+ {
+ blacklist << path;
+ m_recursive = true;
+ removeFile( path );
+ m_recursive = false;
+ }
+ else
+ {
+ blacklist.remove( path );
+ }
+ updateBlacklist( blacklist );
+}
+
+QString CustomProjectPart::relativeToProject( const QString& abspath ) const
+{
+ QString path = abspath.mid( projectDirectory().length() + 1 );
+ kdDebug( 9025 ) << "abspath: " << "|project dir: " << projectDirectory() << "|path: " << path << endl;
+ if ( path.endsWith( "/" ) )
+ path = path.mid( 0, path.length() - 1 );
+ if ( path.startsWith( "/" ) )
+ path = path.mid( 1, path.length() );
+ return path;
+}
+
+bool CustomProjectPart::isInBlacklist( const QString& path ) const
+{
+ QString relpath = path;
+ QStringList blacklist = this->blacklist();
+ if ( !QFileInfo( relpath ).isRelative() )
+ relpath = relativeToProject( path );
+ if ( blacklist.find( relpath ) != blacklist.end() )
+ return true;
+ QStringList paths = QStringList::split( "/", relpath );
+ QString parentpath;
+ for ( QStringList::const_iterator it = paths.begin(); it != paths.end(); ++it )
+ {
+ parentpath += *it;
+ if ( blacklist.find( parentpath ) != blacklist.end() )
+ return true;
+ parentpath = parentpath + "/";
+ }
+ return false;
+}
+
+void CustomProjectPart::updateBlacklist( const QStringList& l )
+{
+ DomUtil::writeListEntry( *projectDom(), "kdevcustomproject/blacklist", "path", l );
+}
+
+QStringList CustomProjectPart::blacklist() const
+{
+ return DomUtil::readListEntry( *projectDom(), "kdevcustomproject/blacklist", "path" );
+}
+
+void CustomProjectPart::addNewFilesToProject( const QStringList& filelist )
+{
+ QStringList addfiles;
+ for ( QStringList::const_iterator it = filelist.begin(); it != filelist.end(); ++it )
+ {
+ if (( ! isInProject( *it ) ) && ( isProjectFileType( *it ) || QFileInfo( projectDirectory() + "/" + *it ).isDir() ) && !isInBlacklist( *it ) )
+ {
+ addfiles << *it;
+ }
+ }
+
+ if ( addfiles.isEmpty() )
+ return;
+
+ SelectNewFilesDialog *dlg = new SelectNewFilesDialog( addfiles, mainWindow()->main() );
+ if ( dlg->exec() == KDialog::Accepted )
+ {
+ m_first_recursive = false;
+ m_recursive = false;
+ QStringList blacklist = this->blacklist();
+ QStringList excludelist = dlg->excludedPaths();
+ QStringList removeFromExcludes;
+ for ( QStringList::const_iterator it = excludelist.begin(); it != excludelist.end(); ++it )
+ {
+ if ( QFileInfo( projectDirectory() + "/" + *it ).isDir() )
+ {
+ for ( ProjectFilesSet::ConstIterator it2 = m_sourceFilesSet.constBegin(); it2 != m_sourceFilesSet.constEnd(); ++it2 )
+ {
+ if ( it2.key().find( *it ) != -1 )
+ {
+ removeFromExcludes << *it;
+ }
+ }
+ }
+ }
+ for ( QStringList::const_iterator it = removeFromExcludes.begin(); it != removeFromExcludes.end(); ++it )
+ {
+ excludelist.remove( *it );
+ }
+ blacklist += excludelist;
+ updateBlacklist( blacklist );
+ addFiles( dlg->includedPaths() );
+ }
+}
+
+void CustomProjectPart::setFiletypes( const QStringList& l )
+{
+ DomUtil::writeListEntry( *projectDom(), "kdevcustomproject/filetypes", "filetype", l );
+}
+
+
+/**
+ * @brief Is a given file (or a directory) part of this project?
+ *
+ * @param fileName
+ */
+bool CustomProjectPart::isInProject( const QString& fileName ) const
+{
+ return m_sourceFilesSet.contains( fileName );
+}
+
+
+/**
+ * @brief Add a file (or a directory) to this project.
+ *
+ * @param fileName
+ *
+ * @see removeFromProject()
+ */
+void CustomProjectPart::addToProject( const QString& fileName )
+{
+ m_sourceFilesSet.insert( fileName, false );
+}
+
+
+/**
+ * @brief Remove a file (or a directory) from this project.
+ *
+ * @param fileName
+ */
+void CustomProjectPart::removeFromProject( const QString& fileName )
+{
+ m_sourceFilesSet.remove( fileName );
+}
+
+
+#include "customprojectpart.moc"
+
diff --git a/buildtools/custommakefiles/customprojectpart.h b/buildtools/custommakefiles/customprojectpart.h
new file mode 100644
index 00000000..f3fb9ec4
--- /dev/null
+++ b/buildtools/custommakefiles/customprojectpart.h
@@ -0,0 +1,158 @@
+/***************************************************************************
+ * Copyright (C) 2001-2002 by Bernd Gehrmann *
+ * bernd@kdevelop.org *
+ * Copyright (C) 2007 by Andreas Pakulat *
+ * apaku@gmx.de *
+ * *
+ * 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 _CUSTOMPROJECTPART_H_
+#define _CUSTOMPROJECTPART_H_
+
+#include <qdict.h>
+#include <qguardedptr.h>
+#include <qmap.h>
+#include <qdatetime.h>
+#include <qvaluestack.h>
+
+#include <kdevbuildtool.h>
+
+class QListViewItem;
+class QPopupMenu;
+class QStringList;
+class KDialogBase;
+class CustomProjectWidget;
+class Context;
+class KSelectAction;
+
+class CustomProjectPart : public KDevBuildTool
+{
+ Q_OBJECT
+
+public:
+ CustomProjectPart( QObject *parent, const char *name, const QStringList & );
+ ~CustomProjectPart();
+
+ QStringList allMakeEnvironments() const;
+ QString currentMakeEnvironment() const;
+
+ bool isDirty();
+ QStringList distFiles() const;
+
+ 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;
+ QString relativeToProject( const QString& ) const;
+
+
+private slots:
+ void populateProject();
+ void projectConfigWidget( KDialogBase *dlg );
+ void contextMenu( QPopupMenu *popup, const Context *context );
+ void slotAddToProject();
+ void slotRemoveFromProject();
+ void slotAddToProjectRecursive();
+ void slotRemoveFromProjectRecursive();
+ void addNewFilesToProject( const QStringList& );
+ void slotChangeBlacklist();
+ void slotChooseActiveDirectory();
+ void slotBuild();
+ void slotBuildActiveDir();
+ void slotCompileFile();
+ void slotInstall();
+ void slotInstallActiveDir();
+ void slotInstallWithKdesu();
+ void slotClean();
+ void slotExecute();
+ void updateTargetMenu();
+ void targetMenuActivated( int id );
+ void targetObjectFilesMenuActivated( int id );
+ void targetOtherFilesMenuActivated( int id );
+ void updateMakeEnvironmentsMenu();
+ void makeEnvironmentsMenuActivated( int id );
+ void slotCommandFinished( const QString& command );
+ void slotCommandFailed( const QString& command );
+
+private:
+ bool containsNonProjectFiles( const QString& url );
+ QStringList projectFilesInDir( const QString& dir );
+ bool containsProjectFiles( const QString& url );
+ bool isProjectFileType( const QString& absFile ) const;
+ bool isInBlacklist( const QString& ) const;
+ void cleanFileList();
+ void setFiletypes( const QStringList& );
+ void findNewFiles( const QString& dir, QStringList& list) const;
+
+ QStringList filetypes() const;
+ QStringList blacklist() const;
+ void updateBlacklist( const QStringList& );
+ void saveProject();
+ void startMakeCommand( const QString &dir, const QString &target, bool withKdesu = false );
+ void parseMakefile( const QString& file );
+ QString makeEnvironment() const;
+ void putEnvVarsInVarMap();
+ void switchBlacklistEntry(const QString& );
+
+ bool isInProject( const QString& fileName ) const;
+ void addToProject( const QString& fileName );
+ void removeFromProject( const QString& fileName );
+
+ /**
+ * @brief Set of all the project's files.
+ *
+ * @bug
+ * Due to deficiency in QT3,
+ * we have to use a map with next-to-useless element value,
+ * keyed by the file name,
+ * as a set-container replacement.
+ */
+ typedef QMap<QString, bool> ProjectFilesSet;
+
+ QString m_projectDirectory;
+ QString m_projectName;
+ QString m_filelistDir;
+ /** All the sources (files and directories) of this project. */
+ ProjectFilesSet m_sourceFilesSet;
+ QPopupMenu *m_targetMenu;
+ QPopupMenu *m_targetObjectFilesMenu;
+ QPopupMenu *m_targetOtherFilesMenu;
+ KSelectAction *m_makeEnvironmentsSelector;
+ QStringList m_targets;
+ QStringList m_targetsObjectFiles;
+ QStringList m_targetsOtherFiles;
+ QStringList m_contextAddFiles;
+ QStringList m_contextRemoveFiles;
+ QString m_contextDirName;
+
+ QMap<QString, QDateTime> m_timestamp;
+ bool m_executeAfterBuild;
+ QString m_buildCommand;
+ bool m_lastCompilationFailed;
+ QMap<QString, int> m_parsedMakefiles;
+ QValueStack<QString> m_makefilesToParse;
+ QMap<QString, QString> m_makefileVars;
+ bool m_recursive;
+ bool m_first_recursive;
+};
+
+#endif
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
diff --git a/buildtools/custommakefiles/kdevcustomproject.desktop b/buildtools/custommakefiles/kdevcustomproject.desktop
new file mode 100644
index 00000000..276f4c1a
--- /dev/null
+++ b/buildtools/custommakefiles/kdevcustomproject.desktop
@@ -0,0 +1,91 @@
+[Desktop Entry]
+Type=Service
+Exec=blubb
+Comment=Custom Project
+Comment[br]=Raktres diouzhoc'h
+Comment[ca]=Projecte a mida
+Comment[cs]=Vlastní projekt
+Comment[da]=Brugerdefineret projekt
+Comment[de]=Benutzerdefiniertes Projekt für KDevelop
+Comment[el]=Προσαρμοσμένo έργο
+Comment[es]=Proyecto personalizado
+Comment[et]=Kohandatav projekt
+Comment[eu]=Proiektu pertsonalizatua
+Comment[fa]=پروژۀ سفارشی
+Comment[fr]=Projet personnalisé
+Comment[ga]=Tionscadal Saincheaptha
+Comment[gl]=Proxecto persoalizado
+Comment[hi]=कस्टम परियोजना
+Comment[hu]=Egyedi projekt
+Comment[is]=Sérsniðið verkefni
+Comment[it]=Progetto personalizzato
+Comment[ja]=カスタムプロジェクト
+Comment[ms]=Projek Tersendiri
+Comment[nds]=Egen Projekt
+Comment[ne]=अनुकूल परियोजना
+Comment[nl]=Aangepast project
+Comment[pl]=Własny projekt
+Comment[pt]=Projecto Personalizado
+Comment[pt_BR]=Projeto Personalizado
+Comment[ru]=Особый проект
+Comment[sk]=Vlastný projekt
+Comment[sl]=Poljuben projekt
+Comment[sr]=Произвољан пројекат
+Comment[sr@Latn]=Proizvoljan projekat
+Comment[sv]=Eget projekt
+Comment[ta]=தனிப்பயன் பிராஜக்ட்
+Comment[tg]=Лоиҳаи оддӣ
+Comment[tr]=Özel Proje
+Comment[zh_CN]=自定义工程
+Comment[zh_TW]=自訂專案
+Name=KDevCustomProject
+Name[da]=KDevelop brugerdefineret projekt
+Name[de]=Benutzerdefiniertes Projekt (KDevelop)
+Name[hi]=के-डेव-कस्टम-परियोजना
+Name[nds]=Egen Projekt (KDevelop)
+Name[ne]=केडीई विकास अनुकूल परियोजना
+Name[pl]=KDevWłasnyProjekt
+Name[sk]=KDevVlastnýProjekt
+Name[sv]=KDevelop eget projekt
+Name[ta]=கெடெவ் தனிப்பயன் பிராஜக்ட்
+Name[tg]=Лоиҳаи оддӣKDev
+Name[zh_TW]=KDevelop 自訂專案
+GenericName=Custom Project
+GenericName[br]=Raktres diouzhoc'h
+GenericName[ca]=Projecte a mida
+GenericName[da]=Brugerdefineret projekt
+GenericName[de]=Benutzerdefiniertes Projekt
+GenericName[el]=Προσαρμοσμένο έργο
+GenericName[es]=Proyecto personalizado
+GenericName[et]=Kohandatav projekt
+GenericName[eu]=Proiektu pertsonalizatua
+GenericName[fa]=پروژۀ سفارشی
+GenericName[fr]=Projet personnalisé
+GenericName[ga]=Tionscadal Saincheaptha
+GenericName[gl]=Proxecto persoalizado
+GenericName[hi]=कस्टम परियोजना
+GenericName[hu]=Egyedi projekt
+GenericName[it]=Progetto personalizzato
+GenericName[ja]=カスタムプロジェクト
+GenericName[ms]=Projek Tersendiri
+GenericName[nds]=Egen Projekt
+GenericName[ne]=अनुकूल परियोजना
+GenericName[nl]=Aangepast project
+GenericName[pl]=Projekt: własny
+GenericName[pt]=Projecto Personalizado
+GenericName[pt_BR]=Projeto Personalizado
+GenericName[ru]=Особый проект
+GenericName[sk]=Vlastný projekt
+GenericName[sl]=Poljuben projekt
+GenericName[sr]=Произвољан пројекат
+GenericName[sr@Latn]=Proizvoljan projekat
+GenericName[sv]=Eget projekt
+GenericName[ta]=தனிப்பயன் பிராஜக்ட்
+GenericName[tg]=Лоиҳаи оддӣ
+GenericName[tr]=Özel Proje
+GenericName[zh_CN]=自定义工程
+GenericName[zh_TW]=自訂專案
+ServiceTypes=KDevelop/Project
+X-KDE-Library=libkdevcustomproject
+X-KDevelop-Version=5
+X-KDevelop-Args=
diff --git a/buildtools/custommakefiles/kdevcustomproject.rc b/buildtools/custommakefiles/kdevcustomproject.rc
new file mode 100644
index 00000000..c744b4be
--- /dev/null
+++ b/buildtools/custommakefiles/kdevcustomproject.rc
@@ -0,0 +1,30 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="KDevCustomProject" version="7">
+<MenuBar>
+ <Menu name="project" >
+ <Action name="repopulate_project" />
+ <Action name="addnewfiles_project" />
+ </Menu>
+ <Menu name="build" >
+ <Action name="build_build" />
+ <Action name="build_buildactivetarget" />
+ <Action name="build_compilefile" />
+ <Action name="build_target" />
+ <Action name="build_install" />
+ <Action name="build_installactivetarget" />
+ <Action name="build_make_environment" />
+ <Action name="build_clean" />
+ <Separator/>
+ <Action name="build_execute" />
+ </Menu>
+</MenuBar>
+<ToolBar name="buildToolBar" noMerge="1">
+ <Action name="build_build" group="build_operations" />
+ <Action name="build_buildactivetarget" group="build_operations" />
+ <Action name="build_compilefile" group="build_operations" />
+ <Separator group="build_operations"/>
+ <Action name="build_install" group="build_operations" />
+ <Action name="build_execute" group="build_operations" />
+</ToolBar>
+</kpartgui>
+
diff --git a/buildtools/custommakefiles/selectnewfilesdialog.cpp b/buildtools/custommakefiles/selectnewfilesdialog.cpp
new file mode 100644
index 00000000..cfcb84e6
--- /dev/null
+++ b/buildtools/custommakefiles/selectnewfilesdialog.cpp
@@ -0,0 +1,131 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Andreas Pakulat *
+ * apaku@gmx.de *
+ * *
+ * 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 "selectnewfilesdialog.h"
+
+#include <qlistview.h>
+#include <klistview.h>
+#include <qheader.h>
+#include <qstringlist.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include "selectnewfilesdialogbase.h"
+
+SelectNewFilesDialog::SelectNewFilesDialog( QStringList paths, QWidget* parent, const char* name )
+ : KDialogBase( parent, name, true, i18n("Add newly created files to project"), KDialogBase::Ok|KDialogBase::Cancel )
+{
+ m_widget = new SelectNewFilesDialogBase(this);
+ m_widget->fileView->header()->hide();
+ m_widget->fileView->addColumn(i18n("Path") );
+ for( QStringList::const_iterator it = paths.begin(); it != paths.end(); ++it)
+ {
+ addPath(0, *it);
+ }
+ setMainWidget( m_widget );
+ resize( 300,400 );
+}
+
+SelectNewFilesDialog::~SelectNewFilesDialog()
+{}
+
+void SelectNewFilesDialog::slotCancel()
+{
+ excludePaths.clear();
+ includePaths.clear();
+ KDialogBase::slotCancel();
+}
+
+void SelectNewFilesDialog::checkItem( QCheckListItem* item, const QString& curpath )
+{
+ if( !item )
+ return;
+
+ QString path = curpath + item->text();
+ if( item->state() != QCheckListItem::Off )
+ includePaths << path;
+ else
+ excludePaths << path;
+ if( item->firstChild() )
+ {
+ checkItem( static_cast<QCheckListItem*>(item->firstChild()), path+"/" );
+ }
+ if( item->nextSibling() )
+ {
+ checkItem( static_cast<QCheckListItem*>(item->nextSibling()), curpath );
+ }
+}
+
+void SelectNewFilesDialog::slotOk()
+{
+ QCheckListItem* item = static_cast<QCheckListItem*> (m_widget->fileView->firstChild());
+ checkItem( item, "" );
+ kdDebug(9025) << "Inc List:" << includePaths << endl;
+ kdDebug(9025) << "Exc List:" << excludePaths << endl;
+ KDialogBase::slotOk();
+}
+
+void SelectNewFilesDialog::addPath( QCheckListItem* item, const QString& path )
+{
+ if( path.isEmpty() )
+ return;
+
+ QStringList parts = QStringList::split("/", path );
+ QString name = parts.first();
+ parts.pop_front();
+ QCheckListItem* i = createItem( item, name, parts.size() );
+ i->setState( QCheckListItem::On );
+ i->setTristate( true );
+ addPath(i, parts.join("/") );
+}
+
+QCheckListItem* SelectNewFilesDialog::createItem( QCheckListItem* parent, const QString& name, int count )
+{
+ QCheckListItem::Type t = QCheckListItem::CheckBox;
+ if( count > 0 )
+ t = QCheckListItem::CheckBoxController;
+
+ if( parent == 0 )
+ {
+ QListViewItem* item = m_widget->fileView->firstChild();
+ while( item )
+ {
+ if( item->text( 0 ) == name )
+ return static_cast<QCheckListItem*>(item);
+ item = item->nextSibling();
+ }
+ return new QCheckListItem( m_widget->fileView, name, t );
+ }else
+ {
+ QListViewItem* item = parent->firstChild();
+ while( item )
+ {
+ if( item->text( 0 ) == name )
+ return static_cast<QCheckListItem*>(item);
+ item = item->nextSibling();
+ }
+ return new QCheckListItem( parent, name, t );
+ }
+}
+
+QStringList SelectNewFilesDialog::excludedPaths() const
+{
+ return excludePaths;
+}
+
+QStringList SelectNewFilesDialog::includedPaths() const
+{
+ return includePaths;
+}
+
+#include "selectnewfilesdialog.moc"
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
diff --git a/buildtools/custommakefiles/selectnewfilesdialog.h b/buildtools/custommakefiles/selectnewfilesdialog.h
new file mode 100644
index 00000000..b970dc7d
--- /dev/null
+++ b/buildtools/custommakefiles/selectnewfilesdialog.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Andreas Pakulat *
+ * apaku@gmx.de *
+ * *
+ * 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 SELECTNEWFILESDIALOG_H
+#define SELECTNEWFILESDIALOG_H
+
+#include "kdialogbase.h"
+
+class QCheckListItem;
+class QStringList;
+class SelectNewFilesDialogBase;
+
+class SelectNewFilesDialog : public KDialogBase
+{
+Q_OBJECT
+
+public:
+ SelectNewFilesDialog( QStringList paths, QWidget* parent = 0, const char* name = 0 );
+ ~SelectNewFilesDialog();
+
+ QStringList excludedPaths() const;
+ QStringList includedPaths() const;
+
+public slots:
+ /*$PUBLIC_SLOTS$*/
+
+protected:
+ /*$PROTECTED_FUNCTIONS$*/
+
+protected slots:
+ /*$PROTECTED_SLOTS$*/
+ virtual void slotCancel();
+ virtual void slotOk();
+private:
+ void addPath( QCheckListItem* , const QString& );
+ void checkItem( QCheckListItem* item, const QString& curpath );
+ QCheckListItem* createItem( QCheckListItem*, const QString&, int );
+ SelectNewFilesDialogBase* m_widget;
+ QStringList excludePaths;
+ QStringList includePaths;
+};
+
+#endif
+
+// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
diff --git a/buildtools/custommakefiles/selectnewfilesdialogbase.ui b/buildtools/custommakefiles/selectnewfilesdialogbase.ui
new file mode 100644
index 00000000..fbd5b5ec
--- /dev/null
+++ b/buildtools/custommakefiles/selectnewfilesdialogbase.ui
@@ -0,0 +1,50 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>SelectNewFilesDialogBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SelectNewFilesDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>532</width>
+ <height>324</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Files to add to the Project:</string>
+ </property>
+ </widget>
+ <widget class="KListView">
+ <property name="name">
+ <cstring>fileView</cstring>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="itemsMovable">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Select the files to add to the project</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Select the files and directories that should be added to the list of project files. All other files and directories will be put into the blacklist.</string>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klistview.h</includehint>
+</includehints>
+</UI>