KDevelop API Documentation

pascalglobaloptionsdlg.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 Alexander Dymo                                     *
00003  *   cloudtemple@mksat.net                                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
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     /*kdDebug() << ServiceComboBox::defaultCompiler() << endl;
00053     kdDebug() << ServiceComboBox::itemForText(ServiceComboBox::defaultCompiler(), service_names) << endl;
00054     kdDebug() << compiler_box->text(ServiceComboBox::itemForText(ServiceComboBox::defaultCompiler(), service_names)) << endl;
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 /*    KConfig *config = KGlobal::config();
00115     config->setGroup("Pascal Compiler");
00116 
00117     QMap<QString, QString> settings = config->entryMap("Pascal Compiler");
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"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:40 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003