KDevelop API Documentation

custommakeconfigwidget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hendrik Kueck                                   *
00003  *   kueck@cs.ubc.ca                                                       *
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 "custommakeconfigwidget.h"
00012 #include <custombuildoptionswidgetbase.h>
00013 #include <customprojectpart.h>
00014 #include <qcombobox.h>
00015 #include <qdir.h>
00016 #include <qfile.h>
00017 #include <qfileinfo.h>
00018 #include <qlabel.h>
00019 #include <qlineedit.h>
00020 #include <qpushbutton.h>
00021 #include <qcheckbox.h>
00022 #include <qlineedit.h>
00023 #include <qspinbox.h>
00024 #include <qlistview.h>
00025 #include <qgroupbox.h>
00026 #include <qvalidator.h>
00027 #include <kdebug.h>
00028 #include <klocale.h>
00029 
00030 #include <environmentvariableswidget.h>
00031 
00032 CustomMakeConfigWidget::CustomMakeConfigWidget(CustomProjectPart* part, const QString& configGroup, QWidget* parent)
00033  : CustomMakeConfigWidgetBase(parent),
00034     m_part(part), m_configGroup(configGroup), m_dom( *part->projectDom() )
00035 {
00036     abort_box->setChecked(DomUtil::readBoolEntry(m_dom, m_configGroup + "/make/abortonerror"));
00037     jobs_box->setValue(DomUtil::readIntEntry(m_dom, m_configGroup + "/make/numberofjobs"));
00038     prio_box->setValue(DomUtil::readIntEntry(m_dom, m_configGroup + "/make/prio"));
00039     dontact_box->setChecked(DomUtil::readBoolEntry(m_dom, m_configGroup + "/make/dontact"));
00040     makebin_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/makebin"));
00041     makeoptions_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/makeoptions"));
00042 
00043     envs_combo->setValidator(new QRegExpValidator(QRegExp("^\\D.*"), this));
00044     m_allEnvironments = m_part->allMakeEnvironments();
00045     m_currentEnvironment = m_part->currentMakeEnvironment();
00046     env_var_group->setColumnLayout( 1, Qt::Vertical );
00047     m_envWidget = new EnvironmentVariablesWidget(m_dom, m_configGroup + "/make/environments/" + m_currentEnvironment, env_var_group);
00048     envs_combo->insertStringList(m_allEnvironments);
00049     envs_combo->setEditText(m_currentEnvironment);
00050 }
00051 
00052 
00053 CustomMakeConfigWidget::~CustomMakeConfigWidget()
00054 {
00055 
00056 }
00057 
00058 void CustomMakeConfigWidget::envNameChanged(const QString& envName)
00059 {
00060     QStringList allEnvNames = m_part->allMakeEnvironments();
00061     bool canAdd = !allEnvNames.contains(envName) && !envName.contains("/") && !envName.isEmpty();
00062     bool canRemove = allEnvNames.contains(envName) && allEnvNames.count() > 1;
00063     addenvs_button->setEnabled(canAdd);
00064     copyenvs_button->setEnabled(canAdd);
00065     removeenvs_button->setEnabled(canRemove);
00066 }
00067 
00068 void CustomMakeConfigWidget::envChanged(const QString& envName)
00069 {
00070     if (envName == m_currentEnvironment || !m_allEnvironments.contains(envName))
00071         return;
00072 
00073     // save settings of previously active environment
00074     if (!m_currentEnvironment.isNull() )
00075         m_envWidget->accept();
00076 
00077     m_currentEnvironment = envName;
00078     m_envWidget->readEnvironment(m_dom, m_configGroup + "/make/environments/" + envName);
00079     envs_combo->setEditText(envName);
00080 }
00081 
00082 void CustomMakeConfigWidget::envAdded()
00083 {
00084     QString env = envs_combo->currentText();
00085     m_allEnvironments.append(env);
00086 
00087     envs_combo->clear();
00088     envs_combo->insertStringList(m_allEnvironments);
00089     envChanged(env);
00090 }
00091 
00092 void CustomMakeConfigWidget::envRemoved()
00093 {
00094     QString env = envs_combo->currentText();
00095     QDomNode node = DomUtil::elementByPath(m_dom, m_configGroup + "/make/environments");
00096     node.removeChild(node.namedItem(env));
00097     m_allEnvironments.remove(env);
00098     envs_combo->clear();
00099     envs_combo->insertStringList(m_allEnvironments);
00100     m_currentEnvironment = QString::null;
00101     envChanged( m_allEnvironments[0] );
00102 }
00103 
00104 void CustomMakeConfigWidget::envCopied()
00105 {
00106     QString env = envs_combo->currentText();
00107     m_allEnvironments.append(env);
00108     envs_combo->clear();
00109     envs_combo->insertStringList(m_allEnvironments);
00110     m_currentEnvironment = env;
00111     m_envWidget->changeConfigGroup(m_configGroup + "/make/environments/" + env);
00112     envs_combo->setEditText(env);
00113 }
00114 
00115 void CustomMakeConfigWidget::accept()
00116 {
00117     DomUtil::writeBoolEntry(m_dom, m_configGroup + "/make/abortonerror", abort_box->isChecked());
00118     DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/numberofjobs", jobs_box->value());
00119     DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/prio", prio_box->value());
00120     DomUtil::writeBoolEntry(m_dom, m_configGroup + "/make/dontact", dontact_box->isChecked());
00121     DomUtil::writeEntry(m_dom, m_configGroup + "/make/makebin", makebin_edit->text());
00122     DomUtil::writeEntry(m_dom, m_configGroup + "/make/makeoptions", makeoptions_edit->text());
00123     DomUtil::writeEntry(m_dom, m_configGroup + "/make/selectedenvironment", m_currentEnvironment);
00124     m_envWidget->accept();
00125 }
00126 
00127 #include "custommakeconfigwidget.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