diff options
Diffstat (limited to 'buildtools/pascal')
-rw-r--r-- | buildtools/pascal/Makefile.am | 24 | ||||
-rw-r--r-- | buildtools/pascal/README.dox | 13 | ||||
-rw-r--r-- | buildtools/pascal/kdevpascalproject.desktop | 93 | ||||
-rw-r--r-- | buildtools/pascal/kdevpascalproject.rc | 14 | ||||
-rw-r--r-- | buildtools/pascal/pascalglobaloptionsdlg.cpp | 132 | ||||
-rw-r--r-- | buildtools/pascal/pascalglobaloptionsdlg.h | 52 | ||||
-rw-r--r-- | buildtools/pascal/pascalproject_optionsdlgbase.ui | 474 | ||||
-rw-r--r-- | buildtools/pascal/pascalproject_part.cpp | 493 | ||||
-rw-r--r-- | buildtools/pascal/pascalproject_part.h | 95 | ||||
-rw-r--r-- | buildtools/pascal/pascalproject_widget.cpp | 26 | ||||
-rw-r--r-- | buildtools/pascal/pascalproject_widget.h | 25 | ||||
-rw-r--r-- | buildtools/pascal/pascalprojectoptionsdlg.cpp | 210 | ||||
-rw-r--r-- | buildtools/pascal/pascalprojectoptionsdlg.h | 59 | ||||
-rw-r--r-- | buildtools/pascal/service.cpp | 77 | ||||
-rw-r--r-- | buildtools/pascal/service.h | 29 |
15 files changed, 1816 insertions, 0 deletions
diff --git a/buildtools/pascal/Makefile.am b/buildtools/pascal/Makefile.am new file mode 100644 index 00000000..d975575a --- /dev/null +++ b/buildtools/pascal/Makefile.am @@ -0,0 +1,24 @@ +INCLUDES = -I$(top_srcdir)/buildtools/lib/base \ + -I$(top_srcdir)/buildtools/lib/widgets -I$(top_srcdir)/lib/interfaces \ + -I$(top_srcdir)/lib/interfaces/extensions -I$(top_srcdir)/lib/interfaces/external \ + -I$(top_srcdir)/lib/interfaces/extras -I$(top_srcdir)/lib/util -I$(top_builddir)/buildtools/lib/widgets \ + $(all_includes) + +kde_module_LTLIBRARIES = libkdevpascalproject.la +libkdevpascalproject_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkdevpascalproject_la_LIBADD = $(top_builddir)/lib/libkdevelop.la \ + $(top_builddir)/buildtools/lib/widgets/libkdevbuildtoolswidgets.la $(top_builddir)/buildtools/lib/base/libkdevbuildbase.la + +libkdevpascalproject_la_SOURCES = pascalproject_part.cpp pascalproject_widget.cpp pascalproject_optionsdlgbase.ui pascalprojectoptionsdlg.cpp pascalglobaloptionsdlg.cpp service.cpp + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = kdevpascalproject.desktop + +rcdir = $(kde_datadir)/kdevpascalproject +rc_DATA = kdevpascalproject.rc + + + + diff --git a/buildtools/pascal/README.dox b/buildtools/pascal/README.dox new file mode 100644 index 00000000..4f3b9897 --- /dev/null +++ b/buildtools/pascal/README.dox @@ -0,0 +1,13 @@ +/** \class PascalProjectPart +This is the Pascal build tool part. + +Common build tool part part for all available pascal compilers (gpc, fpc, dcc). +It holds no project file list and tries to abstract from their specifics. + +\authors <a href="mailto:cloudtemple AT mksat.net">Alexander Dymo</a> + +\maintainer <a href="mailto:cloudtemple AT mksat.net">Alexander Dymo</a> + +\deprecated This class is deprecated, use GenericProjectPart (buildtools/generic) instead. + +*/ diff --git a/buildtools/pascal/kdevpascalproject.desktop b/buildtools/pascal/kdevpascalproject.desktop new file mode 100644 index 00000000..05b7e507 --- /dev/null +++ b/buildtools/pascal/kdevpascalproject.desktop @@ -0,0 +1,93 @@ +[Desktop Entry] +Type=Service +Exec=blubb +Comment=Pascal Project +Comment[br]=Raktres Pascal +Comment[ca]=Projecte Pascal +Comment[da]=Pascal projekt +Comment[de]=Pascal-Projekt für KDevelop +Comment[el]=Έργο Pascal +Comment[es]=Proyecto de Pascal +Comment[et]=Pascali projekt +Comment[eu]=Pascal proiektua +Comment[fa]=پروژۀ پاسکال +Comment[fr]=Projet en langage PASCAL +Comment[ga]=Tionscadal Pascal +Comment[gl]=Proxecto Pascal +Comment[hi]=पास्कल परियोजना +Comment[hu]=Pascal-projekt +Comment[is]=Pascal verkefni +Comment[it]=Progetto per Pascal +Comment[ja]=Pascal プロジェクト +Comment[ms]=Projek Pascal +Comment[nds]=Pascal-Projekt +Comment[ne]=पास्कल परियोजना +Comment[nl]=Pascal-project +Comment[pa]=ਪਾਸਕਲ ਪ੍ਰੋਜੈਕਟ +Comment[pl]=Projekt: Pascal +Comment[pt]=Projecto de Pascal +Comment[pt_BR]=Projeto Pascal +Comment[ru]=Проект Pascal +Comment[sk]=Pascal projekt +Comment[sl]=Projekt Pascal +Comment[sr]=Pascal пројекат +Comment[sr@Latn]=Pascal projekat +Comment[sv]=Pascal-projekt +Comment[ta]=பாஸ்கல் பிராஜக்ட் +Comment[tg]=Лоиҳаи Pascal +Comment[tr]=Pascal Projesi +Comment[uz]=Pascal loyihasi +Comment[uz@cyrillic]=Pascal лойиҳаси +Comment[zh_CN]=Pascal 工程 +Comment[zh_TW]=Pascal 專案 +Name=KDevPascalProject +Name[da]=KDevelop Pascal-projekt +Name[de]=Pascal-Projekt (KDevelop) +Name[hi]=के-डेव-पास्कल-परियोजना +Name[nds]=Pascal-Projekt (KDevelop) +Name[ne]=केडीई विकास पास्कल परियोजना +Name[pl]=KDevProjektPascal +Name[sk]=KDevPascalProjekt +Name[sv]=KDevelop Pascal-projekt +Name[ta]=கெடெவ் பாஸ்கல் பிராஜக்ட் +Name[tg]=Лоиҳаи ПаскалKDev +Name[zh_TW]=KDevelop Pascal 專案 +GenericName=Pascal Project +GenericName[br]=Raktres Pascal +GenericName[ca]=Projecte Pascal +GenericName[da]=Pascal projekt +GenericName[de]=Pascal-Projekt +GenericName[el]=Έργο Pascal +GenericName[es]=Proyecto de Pascal +GenericName[et]=Pascali projekt +GenericName[eu]=Pascal proiektua +GenericName[fa]=پروژۀ پاسکال +GenericName[fr]=Projet en langage PASCAL +GenericName[ga]=Tionscadal Pascal +GenericName[gl]=Proxecto Pascal +GenericName[hi]=पास्कल परियोजना +GenericName[hu]=Pascal-projekt +GenericName[it]=Progetto in Pascal +GenericName[ja]=Pascal プロジェクト +GenericName[ms]=Projek Pascal +GenericName[nds]=Pascal-Projekt +GenericName[ne]=पास्कल परियोजना +GenericName[nl]=Pascal-project +GenericName[pl]=Projekt: Pascal +GenericName[pt]=Projecto de Pascal +GenericName[pt_BR]=Projeto Pascal +GenericName[ru]=Проект Pascal +GenericName[sk]=Pascal projekt +GenericName[sl]=Projekt Pascal +GenericName[sr]=Pascal пројекат +GenericName[sr@Latn]=Pascal projekat +GenericName[sv]=Pascal-projekt +GenericName[ta]=பாஸ்கல் பிராஜக்ட் +GenericName[tr]=Pascal Projesi +GenericName[uz]=Pascal loyihasi +GenericName[uz@cyrillic]=Pascal лойиҳаси +GenericName[zh_CN]=Pascal 工程 +GenericName[zh_TW]=Pascal 專案 +ServiceTypes=KDevelop/Project +X-KDE-Library=libkdevpascalproject +X-KDevelop-Version=5 diff --git a/buildtools/pascal/kdevpascalproject.rc b/buildtools/pascal/kdevpascalproject.rc new file mode 100644 index 00000000..9e7f46fd --- /dev/null +++ b/buildtools/pascal/kdevpascalproject.rc @@ -0,0 +1,14 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="KDevPascalProject" version="2"> +<MenuBar> + <Menu name="build" > + <Action name="build_build" /> + <Separator/> + <Action name="build_execute" /> + </Menu> +</MenuBar> +<ToolBar name="buildToolBar" noMerge="1"> + <Action name="build_build" group="build_operations" /> + <Action name="build_execute" group="build_operations" /> +</ToolBar> +</kpartplugin> diff --git a/buildtools/pascal/pascalglobaloptionsdlg.cpp b/buildtools/pascal/pascalglobaloptionsdlg.cpp new file mode 100644 index 00000000..a710db19 --- /dev/null +++ b/buildtools/pascal/pascalglobaloptionsdlg.cpp @@ -0,0 +1,132 @@ +/*************************************************************************** + * Copyright (C) 2003 Alexander Dymo * + * cloudtemple@mksat.net * + * * + * 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 <qlayout.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qcombobox.h> + +#include <kurlrequester.h> +#include <kdebug.h> +#include <kconfig.h> + +#include "kdevcompileroptions.h" + +#include "service.h" +#include "pascalproject_part.h" +#include "pascalglobaloptionsdlg.h" + +PascalGlobalOptionsDlg::PascalGlobalOptionsDlg(PascalProjectPart *part, QWidget* parent, const char* name, WFlags fl) + :PascalProjectOptionsDlgBase(parent,name,fl), m_part(part) +{ + delete config_label; + delete config_combo; + delete addconfig_button; + delete removeconfig_button; + delete compiler_label; + delete configuration_layout; + delete configuration_line; + delete exec_label; + delete exec_edit; + delete mainSourceLabel; + delete mainSourceUrl; + delete defaultopts_button; + + + offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Pascal'"); + + ServiceComboBox::insertStringList(compiler_box, offers, &service_names, &service_execs); + + if (offers.isEmpty()) + options_button->setEnabled(false); + + currentCompiler = QString::null; + + /*kdDebug() << ServiceComboBox::defaultCompiler() << endl; + kdDebug() << ServiceComboBox::itemForText(ServiceComboBox::defaultCompiler(), service_names) << endl; + kdDebug() << compiler_box->text(ServiceComboBox::itemForText(ServiceComboBox::defaultCompiler(), service_names)) << endl; +*/ + ServiceComboBox::setCurrentText(compiler_box, ServiceComboBox::defaultCompiler(), service_names); + compiler_box_activated(compiler_box->currentText()); +} + +PascalGlobalOptionsDlg::~PascalGlobalOptionsDlg() +{ +} + +void PascalGlobalOptionsDlg::optionsButtonClicked() +{ + QString name = ServiceComboBox::currentText(compiler_box, service_names); + KDevCompilerOptions *plugin = m_part->createCompilerOptions(name); + + if (plugin) { + QString flags = plugin->exec(this, options_edit->text()); + options_edit->setText(flags); + delete plugin; + } +} + +void PascalGlobalOptionsDlg::compiler_box_activated(const QString& text) +{ + kdDebug() << "text changed from " << currentCompiler << " to " << text << endl; + if (currentCompiler == text) + return; + if (!currentCompiler.isEmpty()) + saveCompilerOpts(currentCompiler); + currentCompiler = text; + readCompilerOpts(currentCompiler); +} + +void PascalGlobalOptionsDlg::accept() +{ + saveCompilerOpts(currentCompiler); + + saveConfigCache(); +} + +void PascalGlobalOptionsDlg::saveCompilerOpts( QString compiler ) +{ + configCache[compiler] = options_edit->text(); +} + +void PascalGlobalOptionsDlg::readCompilerOpts( QString compiler ) +{ + QString settings = configCache[compiler]; + if (settings.isEmpty()) + { + KConfig *config = KGlobal::config(); + config->setGroup("Pascal Compiler"); + settings = config->readPathEntry(compiler); + } + + options_edit->setText(settings); +} + +void PascalGlobalOptionsDlg::readConfigCache( ) +{ +/* KConfig *config = KGlobal::config(); + config->setGroup("Pascal Compiler"); + + QMap<QString, QString> settings = config->entryMap("Pascal Compiler"); +*/ +} + +void PascalGlobalOptionsDlg::saveConfigCache( ) +{ + KConfig *config = KGlobal::config(); + config->setGroup("Pascal Compiler"); + + for (QMap<QString, QString>::iterator it = configCache.begin(); it != configCache.end(); ++it) + { + config->writeEntry(it.key(), it.data()); + } +} + +#include "pascalglobaloptionsdlg.moc" diff --git a/buildtools/pascal/pascalglobaloptionsdlg.h b/buildtools/pascal/pascalglobaloptionsdlg.h new file mode 100644 index 00000000..14da2221 --- /dev/null +++ b/buildtools/pascal/pascalglobaloptionsdlg.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2003 Alexander Dymo * + * cloudtemple@mksat.net * + * * + * 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 PASCALGLOBALOPTIONSDLG_H +#define PASCALGLOBALOPTIONSDLG_H + +#include <qmap.h> + +#include <ktrader.h> + +#include "pascalproject_optionsdlgbase.h" + +class PascalProjectPart; + +class PascalGlobalOptionsDlg : public PascalProjectOptionsDlgBase +{ + Q_OBJECT + +public: + PascalGlobalOptionsDlg(PascalProjectPart *part, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~PascalGlobalOptionsDlg(); + +public slots: + virtual void accept(); + +protected slots: + virtual void optionsButtonClicked(); + virtual void compiler_box_activated(const QString& text); + +private: + PascalProjectPart *m_part; + KTrader::OfferList offers; + QString currentCompiler; + QStringList service_names; + QStringList service_execs; + QMap<QString, QString> configCache; + + void saveCompilerOpts(QString compiler); + void readCompilerOpts(QString compiler); + + void readConfigCache(); + void saveConfigCache(); +}; + +#endif diff --git a/buildtools/pascal/pascalproject_optionsdlgbase.ui b/buildtools/pascal/pascalproject_optionsdlgbase.ui new file mode 100644 index 00000000..0f0b2324 --- /dev/null +++ b/buildtools/pascal/pascalproject_optionsdlgbase.ui @@ -0,0 +1,474 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>PascalProjectOptionsDlgBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>PascalProjectOptionsDlgBase</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>480</height> + </rect> + </property> + <property name="caption"> + <string>Pascal Compiler</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="0" column="0" rowspan="1" colspan="5"> + <property name="name"> + <cstring>configuration_layout</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>config_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>Con&figuration:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>config_combo</cstring> + </property> + </widget> + <widget class="QComboBox"> + <property name="name"> + <cstring>config_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> + <spacer> + <property name="name"> + <cstring>Spacer17_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>8</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>addconfig_button</cstring> + </property> + <property name="text"> + <string>&Add</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>removeconfig_button</cstring> + </property> + <property name="text"> + <string>&Remove</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer18_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QPushButton" row="6" column="4"> + <property name="name"> + <cstring>options_button</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>30</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + <widget class="QLabel" row="6" column="0"> + <property name="name"> + <cstring>options_label</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>4</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Compiler op&tions:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>compiler_box</cstring> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>compiler_label</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>4</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Pascal compiler:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>compiler_box</cstring> + </property> + </widget> + <widget class="QLineEdit" row="4" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>exec_edit</cstring> + </property> + </widget> + <widget class="QLineEdit" row="6" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>options_edit</cstring> + </property> + </widget> + <widget class="QComboBox" row="2" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>compiler_box</cstring> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>exec_label</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>4</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Compiler co&mmand:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>compiler_box</cstring> + </property> + </widget> + <widget class="Line" row="1" column="0" rowspan="1" colspan="5"> + <property name="name"> + <cstring>configuration_line</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer11</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>16</height> + </size> + </property> + </spacer> + <spacer row="5" column="3"> + <property name="name"> + <cstring>spacer12</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>16</height> + </size> + </property> + </spacer> + <spacer row="8" column="2"> + <property name="name"> + <cstring>spacer13</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>30</height> + </size> + </property> + </spacer> + <spacer row="7" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>400</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton" row="7" column="3" rowspan="1" colspan="2"> + <property name="name"> + <cstring>defaultopts_button</cstring> + </property> + <property name="text"> + <string>Load &Default Compiler Options</string> + </property> + </widget> + <widget class="KURLRequester" row="9" column="1" rowspan="1" colspan="4"> + <property name="name"> + <cstring>mainSourceUrl</cstring> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>26</height> + </size> + </property> + <property name="focusPolicy"> + <enum>WheelFocus</enum> + </property> + </widget> + <widget class="QLabel" row="9" column="0"> + <property name="name"> + <cstring>mainSourceLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>4</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Main &source file:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>compiler_box</cstring> + </property> + </widget> + <spacer row="12" column="1"> + <property name="name"> + <cstring>spacer1</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> + </grid> +</widget> +<connections> + <connection> + <sender>compiler_box</sender> + <signal>activated(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>compiler_box_activated(const QString&)</slot> + </connection> + <connection> + <sender>removeconfig_button</sender> + <signal>clicked()</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>configRemoved()</slot> + </connection> + <connection> + <sender>config_combo</sender> + <signal>textChanged(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>configComboTextChanged(const QString&)</slot> + </connection> + <connection> + <sender>config_combo</sender> + <signal>activated(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>configChanged(const QString&)</slot> + </connection> + <connection> + <sender>addconfig_button</sender> + <signal>clicked()</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>configAdded()</slot> + </connection> + <connection> + <sender>options_button</sender> + <signal>clicked()</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>optionsButtonClicked()</slot> + </connection> + <connection> + <sender>exec_edit</sender> + <signal>textChanged(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>setDirty()</slot> + </connection> + <connection> + <sender>options_edit</sender> + <signal>textChanged(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>setDirty()</slot> + </connection> + <connection> + <sender>mainSourceUrl</sender> + <signal>textChanged(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>setDirty()</slot> + </connection> + <connection> + <sender>mainSourceUrl</sender> + <signal>urlSelected(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>setDirty()</slot> + </connection> + <connection> + <sender>compiler_box</sender> + <signal>activated(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>setDirty()</slot> + </connection> + <connection> + <sender>compiler_box</sender> + <signal>textChanged(const QString&)</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>setDirty()</slot> + </connection> + <connection> + <sender>defaultopts_button</sender> + <signal>clicked()</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>setDefaultOptions()</slot> + </connection> + <connection> + <sender>defaultopts_button</sender> + <signal>clicked()</signal> + <receiver>PascalProjectOptionsDlgBase</receiver> + <slot>setDirty()</slot> + </connection> +</connections> +<tabstops> + <tabstop>compiler_box</tabstop> + <tabstop>exec_edit</tabstop> + <tabstop>options_edit</tabstop> + <tabstop>options_button</tabstop> + <tabstop>defaultopts_button</tabstop> + <tabstop>mainSourceUrl</tabstop> + <tabstop>config_combo</tabstop> + <tabstop>addconfig_button</tabstop> + <tabstop>removeconfig_button</tabstop> +</tabstops> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<slots> + <slot access="protected">compiler_box_activated(const QString&)</slot> + <slot access="protected">addconfig_button_clicked()</slot> + <slot access="protected">configRemoved()</slot> + <slot access="protected">configComboTextChanged(const QString&)</slot> + <slot access="protected">configChanged(const QString&)</slot> + <slot access="protected">optionsButtonClicked()</slot> + <slot access="protected">configAdded()</slot> + <slot access="protected">setDirty()</slot> + <slot access="protected">setDefaultOptions()</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/pascal/pascalproject_part.cpp b/buildtools/pascal/pascalproject_part.cpp new file mode 100644 index 00000000..3fe09420 --- /dev/null +++ b/buildtools/pascal/pascalproject_part.cpp @@ -0,0 +1,493 @@ +/*************************************************************************** + * Copyright (C) 2003 Alexander Dymo * + * cloudtemple@mksat.net * + * * + * 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 "pascalproject_part.h" + +#include <qdom.h> +#include <qfileinfo.h> +#include <qdir.h> +#include <qvaluestack.h> +#include <qregexp.h> +#include <qvbox.h> +#include <qlabel.h> + +#include <kiconloader.h> +#include <klocale.h> +#include <kaction.h> +#include <kdevgenericfactory.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <kmessagebox.h> +#include <klibloader.h> +#include <kservice.h> +#include <kconfig.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 "kdevlanguagesupport.h" +#include "kdevcompileroptions.h" +#include "runoptionswidget.h" +#include "envvartools.h" + +#include "pascalproject_widget.h" +#include "pascalprojectoptionsdlg.h" +#include "pascalglobaloptionsdlg.h" + +#include <kdevplugininfo.h> + +typedef KDevGenericFactory<PascalProjectPart> PascalProjectFactory; +static const KDevPluginInfo data("kdevpascalproject"); +K_EXPORT_COMPONENT_FACTORY( libkdevpascalproject, PascalProjectFactory( data ) ) + +PascalProjectPart::PascalProjectPart(QObject *parent, const char *name, const QStringList& ) + :KDevBuildTool(&data, parent, name ? name : "PascalProjectPart" ) +{ + setInstance(PascalProjectFactory::instance()); + setXMLFile("kdevpascalproject.rc"); + + KAction *action; + 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 the compiler on a main source file of the project. " + "The compiler and the main source file can be set in project settings, <b>Pascal Compiler</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 nothing is set, the binary file with the same name as the main source file name is executed.")); + + connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)), + this, SLOT(projectConfigWidget(KDialogBase*)) ); + + connect( core(), SIGNAL(configWidget(KDialogBase*)), + this, SLOT(configWidget(KDialogBase*)) ); + +// m_widget = new PascalProjectWidget(this); + +// QWhatsThis::add(m_widget, i18n("WHAT DOES THIS PART DO?")); + + // now you decide what should happen to the widget. Take a look at kdevcore.h + // or at other plugins how to embed it. + + // if you want to embed your widget as an outputview, simply uncomment + // the following line. + + // mainWindow()->embedOutputView( m_widget, "name that should appear", "enter a tooltip" ); + +} + +PascalProjectPart::~PascalProjectPart() +{ +// delete m_widget; +} + +/** + * @todo This should really be merged with FileTreeWidget::matchesHidePattern() + * and put in its own class. Currently this is repeated in scriptprojectpart.cpp, pascalproject_part.cpp, adaproject_part.cpp + */ +static bool matchesPattern(const QString &fileName, const QStringList &patternList) +{ + QStringList::ConstIterator it; + for (it = patternList.begin(); it != patternList.end(); ++it) { + QRegExp re(*it, true, true); + if (re.search(fileName) == 0 && re.matchedLength() == (int)fileName.length()) + return true; + } + + return false; +} + +void PascalProjectPart::openProject(const QString &dirName, const QString &projectName) +{ + m_buildDir = dirName; + m_projectDir = dirName; + m_projectName = projectName; + + QDomDocument &dom = *projectDom(); + // Set the default directory radio to "executable" + if (DomUtil::readEntry(dom, "/kdevpascalproject/run/directoryradio") == "" ) { + DomUtil::writeEntry(dom, "/kdevpascalproject/run/directoryradio", "executable"); + } + + loadProjectConfig(); + + // Put all files from all subdirectories into file list + QValueStack<QString> s; + int prefixlen = m_projectDir.length()+1; + s.push(m_projectDir); + + QStringList includepatternList; + if ( languageSupport() ) + { + KMimeType::List list = languageSupport()->mimeTypes(); + KMimeType::List::Iterator it = list.begin(); + while( it != list.end() ){ + includepatternList += (*it)->patterns(); + ++it; + } + } + QString excludepatterns = "*~"; + QStringList excludepatternList = QStringList::split(",", excludepatterns); + + QDir dir; + do { + dir.setPath(s.pop()); + kdDebug(9033) << "Examining: " << dir.path() << endl; + const QFileInfoList *dirEntries = dir.entryInfoList(); + QPtrListIterator<QFileInfo> it(*dirEntries); + for (; it.current(); ++it) { + QString fileName = it.current()->fileName(); + if (fileName == "." || fileName == "..") + continue; + QString path = it.current()->absFilePath(); + if (it.current()->isDir()) { + kdDebug(9033) << "Pushing: " << path << endl; + s.push(path); + } + else { + if (matchesPattern(path, includepatternList) + && !matchesPattern(path, excludepatternList)) { + kdDebug(9033) << "Adding: " << path << endl; + m_sourceFiles.append(path.mid(prefixlen)); + } else { + kdDebug(9033) << "Ignoring: " << path << endl; + } + } + } + } while (!s.isEmpty()); + + KDevProject::openProject( dirName, projectName ); +} + +void PascalProjectPart::closeProject() +{ +} + +/** Retuns a PairList with the run environment variables */ +DomUtil::PairList PascalProjectPart::runEnvironmentVars() const +{ + return DomUtil::readPairListEntry(*projectDom(), "/kdevpascalproject/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 PascalProjectPart::runDirectory() const +{ + QString cwd = defaultRunDirectory("kdevpascalproject"); + 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 PascalProjectPart::mainProgram() const +{ + QDomDocument * dom = projectDom(); + + if ( !dom ) return QString(); + + QString DomMainProgram = DomUtil::readEntry( *dom, "/kdevpascalproject/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 PascalProjectPart::debugArguments() const +{ + return DomUtil::readEntry(*projectDom(), "/kdevpascalproject/run/globaldebugarguments"); +} + + +/** Retuns a QString with the run command line arguments */ +QString PascalProjectPart::runArguments() const +{ + return DomUtil::readEntry(*projectDom(), "/kdevpascalproject/run/programargs"); +} + +QString PascalProjectPart::mainSource() const +{ + return projectDirectory() + "/" + m_mainSource; +} + +void PascalProjectPart::setMainSource(QString fullPath) +{ + QString olddir = activeDirectory(); + m_mainSource = fullPath.replace(QRegExp(QString(projectDirectory() + QString("/"))),""); + emit activeDirectoryChanged( olddir, activeDirectory() ); +} + +QString PascalProjectPart::projectDirectory() const +{ + return m_projectDir; +} + +QString PascalProjectPart::projectName() const +{ + return m_projectName; +} + +QString PascalProjectPart::activeDirectory() const +{ + QFileInfo fi(mainSource()); + return fi.dirPath(true).replace(QRegExp(projectDirectory()),""); +} + +QString PascalProjectPart::buildDirectory() const +{ + QFileInfo fi(mainSource()); + return fi.dirPath(true); +} + +void PascalProjectPart::listOfFiles(QStringList &result, QString path) const +{ + QDir d(path); + if (!d.exists()) + return; + QFileInfoList *entries = const_cast<QFileInfoList*>(d.entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden)); + for (QFileInfo *it = entries->first(); it; it = entries->next()) + { + if ((it->isDir()) && (it->filePath() != path)) + { +// qWarning("entering dir %s", it->dirPath().latin1()); + listOfFiles(result, it->dirPath()); + } + else + { +// qWarning("adding to result: %s", it->filePath().latin1()); + result << it->filePath(); + } + } +} + +QStringList PascalProjectPart::allFiles() const +{ +// QStringList files; + +// listOfFiles(files, projectDirectory()); + +// return files; + return m_sourceFiles; +} + +void PascalProjectPart::addFile(const QString& /*fileName*/) +{ +} + +void PascalProjectPart::addFiles(const QStringList& /*fileList*/) +{ +} + +void PascalProjectPart::removeFile(const QString& /*fileName*/) +{ +} + +void PascalProjectPart::removeFiles(const QStringList& /*fileList*/) +{ +} + +void PascalProjectPart::slotBuild() +{ + if (partController()->saveAllFiles()==false) + return; //user cancelled + + QString cmdline = m_compilerExec + " " + m_compilerOpts + " "; + + if (cmdline.isEmpty()) + { + KMessageBox::sorry(0, i18n("Could not find pascal compiler.\nCheck if your compiler settings are correct.")); + return; + } + + QFileInfo fi(mainSource()); + cmdline += fi.fileName(); + + QString dircmd = "cd "; + dircmd += KProcess::quote(buildDirectory()); + dircmd += " && "; + + makeFrontend()->queueCommand(buildDirectory(), dircmd + cmdline); +} + +void PascalProjectPart::slotExecute() +{ + partController()->saveAllFiles(); + + QDomDocument &dom = *(projectDom()); + bool runInTerminal = DomUtil::readBoolEntry(dom, "/kdevpascalproject/run/terminal", true); + + // 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 = + DomUtil::readPairListEntry(*projectDom(), "/kdevpascalproject/run/envvars", "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 += " "; + } + + QString program = mainProgram(); + program.prepend(environstr); + program += " " + DomUtil::readEntry(*projectDom(), "/kdevpascalproject/run/programargs"); + + appFrontend()->startAppCommand(buildDirectory(), program, runInTerminal); +} + +void PascalProjectPart::changedFiles( const QStringList & fileList ) +{ + KDevProject::changedFiles(fileList); +} + +void PascalProjectPart::changedFile( const QString & fileName ) +{ + KDevProject::changedFile(fileName); +} + +void PascalProjectPart::projectConfigWidget( KDialogBase * dlg ) +{ + QVBox *vbox; + vbox = dlg->addVBoxPage(i18n("Pascal Compiler")); + PascalProjectOptionsDlg *w = new PascalProjectOptionsDlg(this, vbox); + connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) ); + connect( dlg, SIGNAL(okClicked()), this, SLOT(loadProjectConfig()) ); + + vbox = dlg->addVBoxPage(i18n("Run Options"), i18n("Run Options"), BarIcon( "make", KIcon::SizeMedium )); + RunOptionsWidget *w3 = new RunOptionsWidget(*projectDom(), "/kdevpascalproject", buildDirectory(), vbox); + connect( dlg, SIGNAL(okClicked()), w3, SLOT(accept()) ); + +} + +void PascalProjectPart::loadProjectConfig( ) +{ + QDomDocument &dom = *(projectDom()); + + QString config = DomUtil::readEntry(dom, "/kdevpascalproject/general/useconfiguration", "default"); + m_mainSource = DomUtil::readEntry(dom, QString("/kdevpascalproject/configurations/") + config + QString("/mainsource") ); + m_compilerOpts = DomUtil::readEntry(dom, QString("/kdevpascalproject/configurations/") + config + QString("/compileroptions")); + m_compilerExec = DomUtil::readEntry(dom, QString("/kdevpascalproject/configurations/") + config + QString("/compilerexec")); + + if (m_compilerExec.isEmpty()) + { + KTrader::OfferList offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Pascal'"); + QValueList<KService::Ptr>::ConstIterator it; + for (it = offers.begin(); it != offers.end(); ++it) { + if ((*it)->property("X-KDevelop-Default").toBool()) { + m_compilerExec = (*it)->exec(); + break; + } + } + } +} + +void PascalProjectPart::configWidget( KDialogBase * dlg ) +{ + QVBox *vbox; + vbox = dlg->addVBoxPage(i18n("Pascal Compiler")); + PascalGlobalOptionsDlg *w = new PascalGlobalOptionsDlg(this, vbox); + connect( dlg, SIGNAL(okClicked()), w, SLOT(accept()) ); +} + +KDevCompilerOptions *PascalProjectPart::createCompilerOptions(const QString &name) +{ + KService::Ptr service = KService::serviceByDesktopName(name); + if (!service) { + kdDebug() << "Can't find service " << name; + return 0; + } + + KLibFactory *factory = KLibLoader::self()->factory(QFile::encodeName(service->library())); + if (!factory) { + QString errorMessage = KLibLoader::self()->lastErrorMessage(); + KMessageBox::error(0, i18n("There was an error loading the module %1.\n" + "The diagnostics is:\n%2").arg(service->name()).arg(errorMessage)); + exit(1); + } + + QStringList args; + QVariant prop = service->property("X-KDevelop-Args"); + if (prop.isValid()) + args = QStringList::split(" ", prop.toString()); + + QObject *obj = factory->create(this, service->name().latin1(), + "KDevCompilerOptions", args); + + if (!obj->inherits("KDevCompilerOptions")) { + kdDebug() << "Component does not inherit KDevCompilerOptions" << endl; + return 0; + } + KDevCompilerOptions *dlg = (KDevCompilerOptions*) obj; + + return dlg; +} + +QString PascalProjectPart::defaultOptions( const QString compiler ) const +{ + KConfig *config = KGlobal::config(); + config->setGroup("Pascal Compiler"); + return config->readPathEntry(compiler); +} + +#include "pascalproject_part.moc" + + +/*! + \fn PascalProjectPart::distFiles() const + */ +QStringList PascalProjectPart::distFiles() const +{ + QStringList sourceList = allFiles(); + // Scan current source directory for any .pro files. + QString projectDir = projectDirectory(); + QDir dir(projectDir); + QStringList files = dir.entryList( "Makefile"); + return sourceList + files; +} diff --git a/buildtools/pascal/pascalproject_part.h b/buildtools/pascal/pascalproject_part.h new file mode 100644 index 00000000..3273011d --- /dev/null +++ b/buildtools/pascal/pascalproject_part.h @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (C) 2003 Alexander Dymo * + * cloudtemple@mksat.net * + * * + * 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 __KDEVPART_PASCALPROJECT_H__ +#define __KDEVPART_PASCALPROJECT_H__ + +#include <qguardedptr.h> + +#include "kdevbuildtool.h" + +class PascalProjectWidget; +class KDialogBase; +class KDevCompilerOptions; + +class PascalProjectPart : public KDevBuildTool +{ + Q_OBJECT +public: + PascalProjectPart(QObject *parent, const char *name, const QStringList &); + ~PascalProjectPart(); + + virtual void openProject(const QString &dirName, const QString &projectName); + virtual void closeProject(); + + /**Returns the name of the main source file without extension. + All pascal compilers call the binary by that way*/ + virtual QString mainProgram() const; + /**Main source file (like src/main.pp)*/ + virtual QString mainSource() const; + virtual void setMainSource(QString fullPath); + + virtual QString projectDirectory() const; + virtual QString projectName() const; + virtual QString activeDirectory() const; + /**The location of the main source file*/ + virtual QString buildDirectory() const; + virtual QString runDirectory() const; + virtual QString debugArguments() const; + virtual QString runArguments() const; + virtual DomUtil::PairList runEnvironmentVars() const; + + /**Returns everything in the project directory*/ + virtual QStringList allFiles() const; + /**This does absolutelly nothing*/ + virtual void addFile(const QString &fileName); + /**This does absolutelly nothing*/ + virtual void addFiles(const QStringList &fileList); + /**This does absolutelly nothing*/ + virtual void removeFile(const QString &fileName); + /**This does absolutelly nothing*/ + virtual void removeFiles(const QStringList &fileList); + + virtual void changedFiles( const QStringList & fileList ); + virtual void changedFile( const QString & fileName ); + + KDevCompilerOptions *createCompilerOptions(const QString &name); + + virtual QString defaultOptions(const QString compiler) const; + QStringList distFiles() const; + +public slots: + /**loads config from project file*/ + void loadProjectConfig(); + +private slots: + void slotBuild(); + void slotExecute(); + void projectConfigWidget(KDialogBase *dlg); + void configWidget(KDialogBase *dlg); + +private: + QGuardedPtr<PascalProjectWidget> m_widget; + + void listOfFiles(QStringList &result, QString path) const; + + QString m_buildDir; + QString m_projectDir; + QString m_projectName; + + QString m_mainProg; + QString m_mainSource; + QString m_compilerExec; + QString m_compilerOpts; + + QStringList m_sourceFiles; +}; + +#endif diff --git a/buildtools/pascal/pascalproject_widget.cpp b/buildtools/pascal/pascalproject_widget.cpp new file mode 100644 index 00000000..039c97e6 --- /dev/null +++ b/buildtools/pascal/pascalproject_widget.cpp @@ -0,0 +1,26 @@ +#include <kparts/part.h> +#include <klibloader.h> +#include <kurl.h> +#include <kdebug.h> + + +#include <kdevcore.h> + + +#include "pascalproject_part.h" +#include "pascalproject_widget.h" + + +PascalProjectWidget::PascalProjectWidget(PascalProjectPart *part) + : QWidget(0, "PascalProject widget") +{ + Q_UNUSED( part ); +} + + +PascalProjectWidget::~PascalProjectWidget() +{ +} + + +#include "pascalproject_widget.moc" diff --git a/buildtools/pascal/pascalproject_widget.h b/buildtools/pascal/pascalproject_widget.h new file mode 100644 index 00000000..198cf794 --- /dev/null +++ b/buildtools/pascal/pascalproject_widget.h @@ -0,0 +1,25 @@ +#ifndef __PASCALPROJECT_WIDGET_H__ +#define __PASCALPROJECT_WIDGET_H__ + + +#include <qwidget.h> +#include <qstring.h> + + +class KDevProject; +class PascalProjectPart; + + +class PascalProjectWidget : public QWidget +{ + Q_OBJECT + +public: + + PascalProjectWidget(PascalProjectPart *part); + ~PascalProjectWidget(); + +}; + + +#endif diff --git a/buildtools/pascal/pascalprojectoptionsdlg.cpp b/buildtools/pascal/pascalprojectoptionsdlg.cpp new file mode 100644 index 00000000..7a97cea3 --- /dev/null +++ b/buildtools/pascal/pascalprojectoptionsdlg.cpp @@ -0,0 +1,210 @@ +/*************************************************************************** + * Copyright (C) 2003 Alexander Dymo * + * cloudtemple@mksat.net * + * * + * 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 <kurlrequester.h> +#include <kservice.h> +#include <kdebug.h> +#include <kmessagebox.h> +#include <klocale.h> + +#include <qlineedit.h> +#include <qcombobox.h> +#include <qregexp.h> +#include <qvalidator.h> + +#include "domutil.h" +#include "kdevcompileroptions.h" + +#include "service.h" +#include "pascalproject_part.h" +#include "pascalprojectoptionsdlg.h" + +PascalProjectOptionsDlg::PascalProjectOptionsDlg(PascalProjectPart *part, QWidget* parent, const char* name, WFlags fl) + : PascalProjectOptionsDlgBase(parent,name, fl), m_part(part) +{ + config_combo->setValidator(new QRegExpValidator(QRegExp("^\\D.*"), this)); + + offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Pascal'"); + + ServiceComboBox::insertStringList(compiler_box, offers, &service_names, &service_execs); + + if (offers.isEmpty()) + options_button->setEnabled(false); + + allConfigs = allBuildConfigs(); + config_combo->insertStringList(allConfigs); + + dirty = false; + + QDomDocument &dom = *(m_part->projectDom()); + currentConfig = QString::null; + configChanged(DomUtil::readEntry(dom, "/kdevpascalproject/general/useconfiguration", "default")); +} + +PascalProjectOptionsDlg::~PascalProjectOptionsDlg() +{ +} + +QStringList PascalProjectOptionsDlg::allBuildConfigs() +{ + QDomDocument &dom = *(m_part->projectDom()); + + QStringList allConfigs; + allConfigs.append("default"); + + QDomNode node = dom.documentElement().namedItem("kdevpascalproject").namedItem("configurations"); + QDomElement childEl = node.firstChild().toElement(); + while (!childEl.isNull()) { + QString config = childEl.tagName(); + kdDebug() << "Found config " << config << endl; + if (config != "default") + allConfigs.append(config); + childEl = childEl.nextSibling().toElement(); + } + + return allConfigs; +} + +void PascalProjectOptionsDlg::accept() +{ + DomUtil::writeEntry(*m_part->projectDom(), "/kdevpascalproject/general/useconfiguration", currentConfig); + if (dirty) + { + saveConfig(currentConfig); + } +} + +void PascalProjectOptionsDlg::compiler_box_activated( const QString& /*s*/ ) +{ + QString exec = ServiceComboBox::currentText(compiler_box, service_execs); + exec_edit->setText(exec); +} + +void PascalProjectOptionsDlg::saveConfig( QString config ) +{ + QDomDocument dom = *m_part->projectDom(); + QString prefix = "/kdevpascalproject/configurations/" + config + "/"; + + DomUtil::writeEntry(dom, prefix + "compiler", + ServiceComboBox::currentText(compiler_box, service_names)); + DomUtil::writeEntry(dom, prefix + "compileroptions", options_edit->text()); + DomUtil::writeEntry(dom, prefix + "compilerexec", exec_edit->text()); + DomUtil::writeEntry(dom, prefix + "mainsource", mainSourceUrl->url().replace(QRegExp(m_part->projectDirectory() + QString("/")),"")); +} + +void PascalProjectOptionsDlg::readConfig( QString config ) +{ + QDomDocument dom = *m_part->projectDom(); + QString prefix = "/kdevpascalproject/configurations/" + config + "/"; + + QString compiler = DomUtil::readEntry(dom, prefix + "compiler", ""); + + if (compiler.isEmpty()) + { + offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Pascal'"); + QValueList<KService::Ptr>::ConstIterator it; + for (it = offers.begin(); it != offers.end(); ++it) { + if ((*it)->property("X-KDevelop-Default").toBool()) { + compiler = (*it)->name(); + kdDebug() << "compiler is " << compiler << endl; + break; + } + } + } + ServiceComboBox::setCurrentText(compiler_box, compiler, service_names); + + QString exec = DomUtil::readEntry(dom, prefix + "compilerexec", ""); + if (exec.isEmpty()) + exec = ServiceComboBox::currentText(compiler_box, service_execs); + exec_edit->setText(exec); + options_edit->setText(DomUtil::readEntry(dom, prefix + "compileroptions")); + mainSourceUrl->setURL(m_part->projectDirectory() + "/" + DomUtil::readEntry(dom, prefix + "mainsource")); +} + +void PascalProjectOptionsDlg::configComboTextChanged(const QString &config) +{ + bool canAdd = !allConfigs.contains(config) && !config.contains("/") && !config.isEmpty(); + bool canRemove = allConfigs.contains(config) && config != "default"; + addconfig_button->setEnabled(canAdd); + removeconfig_button->setEnabled(canRemove); +} + + +void PascalProjectOptionsDlg::configChanged(const QString &config) +{ + if (config == currentConfig || !allConfigs.contains(config)) + return; + + if (!currentConfig.isNull() && dirty) + saveConfig(currentConfig); + + currentConfig = config; + readConfig(config); + dirty = false; + + config_combo->blockSignals(true); + config_combo->setEditText(config); + config_combo->blockSignals(false); +} + + +void PascalProjectOptionsDlg::configAdded() +{ + QString config = config_combo->currentText(); + + allConfigs.append(config); + + config_combo->clear(); + config_combo->insertStringList(allConfigs); + configChanged(config); + setDirty(); // force saving +} + + +void PascalProjectOptionsDlg::configRemoved() +{ + QString config = config_combo->currentText(); + + QDomDocument dom = *m_part->projectDom(); + QDomNode node = dom.documentElement().namedItem("kdevpascalproject").namedItem("configurations"); + node.removeChild(node.namedItem(config)); + allConfigs.remove(config); + + config_combo->clear(); + config_combo->insertStringList(allConfigs); + + currentConfig = QString::null; + configChanged("default"); +} + +void PascalProjectOptionsDlg::optionsButtonClicked( ) +{ + QString name = ServiceComboBox::currentText(compiler_box, service_names); + KDevCompilerOptions *plugin = m_part->createCompilerOptions(name); + + if (plugin) { + QString flags = plugin->exec(this, options_edit->text()); + options_edit->setText(flags); + delete plugin; + } +} + +void PascalProjectOptionsDlg::setDirty( ) +{ + dirty = true; +} + +void PascalProjectOptionsDlg::setDefaultOptions( ) +{ + if (!compiler_box->currentText().isEmpty()) + options_edit->setText(m_part->defaultOptions(compiler_box->currentText())); +} + +#include "pascalprojectoptionsdlg.moc" diff --git a/buildtools/pascal/pascalprojectoptionsdlg.h b/buildtools/pascal/pascalprojectoptionsdlg.h new file mode 100644 index 00000000..70e911de --- /dev/null +++ b/buildtools/pascal/pascalprojectoptionsdlg.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2003 Alexander Dymo * + * cloudtemple@mksat.net * + * * + * 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 PASCALPROJECTOPTIONSDLG_H +#define PASCALPROJECTOPTIONSDLG_H + +#include <ktrader.h> + +#include "pascalproject_optionsdlgbase.h" + +class PascalProjectPart; +class KDevCompilerOptions; + +class PascalProjectOptionsDlg : public PascalProjectOptionsDlgBase +{ + Q_OBJECT + +public: + PascalProjectOptionsDlg(PascalProjectPart *part, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~PascalProjectOptionsDlg(); + +public slots: + virtual void accept(); + +protected slots: + virtual void compiler_box_activated(const QString &s); + void configComboTextChanged(const QString &config); + void configChanged(const QString &config); + void configAdded(); + void configRemoved(); + void optionsButtonClicked(); + void setDirty(); + void setDefaultOptions(); + +private: + QStringList allConfigs; + QString currentConfig; + bool dirty; + + KTrader::OfferList offers; + QStringList service_names; + QStringList service_execs; + + PascalProjectPart *m_part; + + void saveConfig(QString config); + void readConfig(QString config); + QStringList allBuildConfigs(); +}; + +#endif + diff --git a/buildtools/pascal/service.cpp b/buildtools/pascal/service.cpp new file mode 100644 index 00000000..c678f916 --- /dev/null +++ b/buildtools/pascal/service.cpp @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (C) 2001-2002 by Bernd Gehrmann * + * bernd@kdevelop.org * + * Copyright (C) 2003 Alexander Dymo * + * cloudtemple@mksat.net * + * * + * 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 <qcombobox.h> +#include <qvaluelist.h> + +#include <kservice.h> +#include <kdebug.h> + +#include "service.h" + + +void ServiceComboBox::insertStringList(QComboBox *combo, const QValueList<KService::Ptr> &list, + QStringList *names, QStringList *execs) +{ + QValueList<KService::Ptr>::ConstIterator it; + for (it = list.begin(); it != list.end(); ++it) { + combo->insertItem((*it)->comment()); + (*names) << (*it)->desktopEntryName(); + (*execs) << (*it)->exec(); + kdDebug() << "insertStringList item " << (*it)->name() << "," << (*it)->exec() << endl; + } +} + +QString ServiceComboBox::currentText(QComboBox *combo, const QStringList &names) +{ + if (combo->currentItem() == -1) + return QString::null; + return names[combo->currentItem()]; +} + +void ServiceComboBox::setCurrentText(QComboBox *combo, const QString &str, const QStringList &names) +{ + QStringList::ConstIterator it; + int i = 0; + for (it = names.begin(); it != names.end(); ++it) { + if (*it == str) { + combo->setCurrentItem(i); + break; + } + ++i; + } +} + +int ServiceComboBox::itemForText(const QString &str, const QStringList &names) +{ + QStringList::ConstIterator it; + int i = 0; + for (it = names.begin(); it != names.end(); ++it) { + if (*it == str) { + return i; + } + ++i; + } + return 0; +} + +QString ServiceComboBox::defaultCompiler() +{ + KTrader::OfferList offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Pascal'"); + QValueList<KService::Ptr>::ConstIterator it; + for (it = offers.begin(); it != offers.end(); ++it) { + if ((*it)->property("X-KDevelop-Default").toBool()) { + return (*it)->name();; + } + } + return ""; +} diff --git a/buildtools/pascal/service.h b/buildtools/pascal/service.h new file mode 100644 index 00000000..30bb142b --- /dev/null +++ b/buildtools/pascal/service.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (C) 2001-2002 by Bernd Gehrmann * + * bernd@kdevelop.org * + * Copyright (C) 2003 Alexander Dymo * + * cloudtemple@mksat.net * + * * + * 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 SERVICE_H +#define SERVICE_H + +#include <ktrader.h> + +class ServiceComboBox +{ +public: + static void insertStringList(QComboBox *combo, const QValueList<KService::Ptr> &list, + QStringList *names, QStringList *execs); + static QString currentText(QComboBox *combo, const QStringList &names); + static void setCurrentText(QComboBox *combo, const QString &str, const QStringList &names); + static int itemForText(const QString &str, const QStringList &names); + static QString defaultCompiler(); +}; + +#endif |