KDevelop API Documentation

adaglobaloptionsdlg.cpp

Go to the documentation of this file.
00001 /* $Id: adaglobaloptionsdlg.cpp,v 1.3 2003/07/05 22:19:53 dymo Exp $
00002  * Copyright (C) 2003 Oliver Kellogg
00003  * okellogg@users.sourceforge.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 #include <qlayout.h>
00011 #include <qlabel.h>
00012 #include <qlineedit.h>
00013 #include <qcombobox.h>
00014 
00015 #include <kurlrequester.h>
00016 #include <kdebug.h>
00017 #include <kconfig.h>
00018 
00019 #include "kdevcompileroptions.h"
00020 
00021 #include "service.h"
00022 #include "adaproject_part.h"
00023 #include "adaglobaloptionsdlg.h"
00024 
00025 AdaGlobalOptionsDlg::AdaGlobalOptionsDlg(AdaProjectPart *part, QWidget* parent, const char* name, WFlags fl)
00026     :AdaProjectOptionsDlgBase(parent,name,fl), m_part(part)
00027 {
00028     delete config_label;
00029     delete config_combo;
00030     delete addconfig_button;
00031     delete removeconfig_button;
00032     delete compiler_label;
00033     delete configuration_layout;
00034     delete configuration_line;
00035     delete exec_label;
00036     delete exec_edit;
00037     delete mainSourceLabel;
00038     delete mainSourceUrl;
00039     delete defaultopts_button;
00040 
00041     offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Ada'");
00042 
00043     ServiceComboBox::insertStringList(compiler_box, offers, &service_names, &service_execs);
00044 
00045     if (offers.isEmpty())
00046         options_button->setEnabled(false);
00047 
00048     currentCompiler = QString::null;
00049 
00050     /*kdDebug() << ServiceComboBox::defaultCompiler() << endl;
00051     kdDebug() << ServiceComboBox::itemForText(ServiceComboBox::defaultCompiler(), service_names) << endl;
00052     kdDebug() << compiler_box->text(ServiceComboBox::itemForText(ServiceComboBox::defaultCompiler(), service_names)) << endl;
00053 */
00054     ServiceComboBox::setCurrentText(compiler_box, ServiceComboBox::defaultCompiler(), service_names);
00055     compiler_box_activated(compiler_box->currentText());
00056 }
00057 
00058 AdaGlobalOptionsDlg::~AdaGlobalOptionsDlg()
00059 {
00060 }
00061 
00062 void AdaGlobalOptionsDlg::optionsButtonClicked()
00063 {
00064     QString name = ServiceComboBox::currentText(compiler_box, service_names);
00065     KDevCompilerOptions *plugin = m_part->createCompilerOptions(name);
00066 
00067     if (plugin) {
00068         QString flags = plugin->exec(this, options_edit->text());
00069         options_edit->setText(flags);
00070         delete plugin;
00071     }
00072 }
00073 
00074 void AdaGlobalOptionsDlg::compiler_box_activated(const QString& text)
00075 {
00076     kdDebug() << "text changed from " << currentCompiler << " to " << text << endl;
00077     if (currentCompiler == text)
00078         return;
00079     if (!currentCompiler.isEmpty())
00080         saveCompilerOpts(currentCompiler);
00081     currentCompiler = text;
00082     readCompilerOpts(currentCompiler);
00083 }
00084 
00085 void AdaGlobalOptionsDlg::accept()
00086 {
00087     saveCompilerOpts(currentCompiler);
00088 
00089     saveConfigCache();
00090 }
00091 
00092 void AdaGlobalOptionsDlg::saveCompilerOpts( QString compiler )
00093 {
00094     configCache[compiler] = options_edit->text();
00095 }
00096 
00097 void AdaGlobalOptionsDlg::readCompilerOpts( QString compiler )
00098 {
00099     QString settings = configCache[compiler];
00100     if (settings.isEmpty())
00101     {
00102         KConfig *config = KGlobal::config();
00103         config->setGroup("Ada Compiler");
00104         settings = config->readPathEntry(compiler);
00105     }
00106 
00107     options_edit->setText(settings);
00108 }
00109 
00110 void AdaGlobalOptionsDlg::readConfigCache( )
00111 {
00112 /*    KConfig *config = KGlobal::config();
00113     config->setGroup("Ada Compiler");
00114 
00115     QMap<QString, QString> settings = config->entryMap("Ada Compiler");
00116 */
00117 }
00118 
00119 void AdaGlobalOptionsDlg::saveConfigCache( )
00120 {
00121     KConfig *config = KGlobal::config();
00122     config->setGroup("Ada Compiler");
00123 
00124     for (QMap<QString, QString>::iterator it = configCache.begin(); it != configCache.end(); ++it)
00125     {
00126         config->writeEntry(it.key(), it.data());
00127     }
00128 }
00129 
00130 #include "adaglobaloptionsdlg.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:38 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003