00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
#include <qlayout.h>
00012
#include <qlabel.h>
00013
#include <qlineedit.h>
00014
#include <qcombobox.h>
00015
00016
#include <kurlrequester.h>
00017
#include <kdebug.h>
00018
#include <kconfig.h>
00019
00020
#include "kdevcompileroptions.h"
00021
00022
#include "service.h"
00023
#include "pascalproject_part.h"
00024
#include "pascalglobaloptionsdlg.h"
00025
00026 PascalGlobalOptionsDlg::PascalGlobalOptionsDlg(
PascalProjectPart *part,
QWidget* parent,
const char* name, WFlags fl)
00027 :
PascalProjectOptionsDlgBase(parent,name,fl), m_part(part)
00028 {
00029
delete config_label;
00030
delete config_combo;
00031
delete addconfig_button;
00032
delete removeconfig_button;
00033
delete compiler_label;
00034
delete configuration_layout;
00035
delete configuration_line;
00036
delete exec_label;
00037
delete exec_edit;
00038
delete mainSourceLabel;
00039
delete mainSourceUrl;
00040
delete defaultopts_button;
00041
00042
00043
offers = KTrader::self()->query(
"KDevelop/CompilerOptions",
"[X-KDevelop-Language] == 'Pascal'");
00044
00045 ServiceComboBox::insertStringList(compiler_box,
offers, &
service_names, &
service_execs);
00046
00047
if (
offers.isEmpty())
00048 options_button->setEnabled(
false);
00049
00050
currentCompiler = QString::null;
00051
00052
00053
00054
00055
00056 ServiceComboBox::setCurrentText(compiler_box, ServiceComboBox::defaultCompiler(),
service_names);
00057
compiler_box_activated(compiler_box->currentText());
00058 }
00059
00060 PascalGlobalOptionsDlg::~PascalGlobalOptionsDlg()
00061 {
00062 }
00063
00064 void PascalGlobalOptionsDlg::optionsButtonClicked()
00065 {
00066
QString name = ServiceComboBox::currentText(compiler_box,
service_names);
00067
KDevCompilerOptions *plugin =
m_part->
createCompilerOptions(name);
00068
00069
if (plugin) {
00070
QString flags = plugin->
exec(
this, options_edit->text());
00071 options_edit->setText(flags);
00072
delete plugin;
00073 }
00074 }
00075
00076 void PascalGlobalOptionsDlg::compiler_box_activated(
const QString& text)
00077 {
00078
kdDebug() <<
"text changed from " <<
currentCompiler <<
" to " <<
text <<
endl;
00079
if (
currentCompiler ==
text)
00080
return;
00081
if (!
currentCompiler.isEmpty())
00082
saveCompilerOpts(
currentCompiler);
00083
currentCompiler =
text;
00084
readCompilerOpts(
currentCompiler);
00085 }
00086
00087 void PascalGlobalOptionsDlg::accept()
00088 {
00089
saveCompilerOpts(
currentCompiler);
00090
00091
saveConfigCache();
00092 }
00093
00094 void PascalGlobalOptionsDlg::saveCompilerOpts(
QString compiler )
00095 {
00096
configCache[compiler] = options_edit->text();
00097 }
00098
00099 void PascalGlobalOptionsDlg::readCompilerOpts(
QString compiler )
00100 {
00101
QString settings =
configCache[compiler];
00102
if (settings.isEmpty())
00103 {
00104
KConfig *config =
KGlobal::config();
00105 config->
setGroup(
"Pascal Compiler");
00106 settings = config->
readPathEntry(compiler);
00107 }
00108
00109 options_edit->setText(settings);
00110 }
00111
00112 void PascalGlobalOptionsDlg::readConfigCache( )
00113 {
00114
00115
00116
00117
00118
00119 }
00120
00121 void PascalGlobalOptionsDlg::saveConfigCache( )
00122 {
00123
KConfig *config =
KGlobal::config();
00124 config->
setGroup(
"Pascal Compiler");
00125
00126
for (
QMap<QString, QString>::iterator it =
configCache.begin(); it !=
configCache.end(); ++it)
00127 {
00128 config->
writeEntry(it.key(), it.data());
00129 }
00130 }
00131
00132
#include "pascalglobaloptionsdlg.moc"