KDevelop API Documentation

buildtools/custommakefiles/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 dontact_box->setChecked(DomUtil::readBoolEntry(m_dom, m_configGroup + "/make/dontact")); 00039 makebin_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/makebin")); 00040 00041 envs_combo->setValidator(new QRegExpValidator(QRegExp("^\\D.*"), this)); 00042 m_allEnvironments = m_part->allMakeEnvironments(); 00043 m_currentEnvironment = m_part->currentMakeEnvironment(); 00044 env_var_group->setColumnLayout( 1, Qt::Vertical ); 00045 m_envWidget = new EnvironmentVariablesWidget(m_dom, m_configGroup + "/make/environments/" + m_currentEnvironment, env_var_group); 00046 envs_combo->insertStringList(m_allEnvironments); 00047 envs_combo->setEditText(m_currentEnvironment); 00048 } 00049 00050 00051 CustomMakeConfigWidget::~CustomMakeConfigWidget() 00052 { 00053 00054 } 00055 00056 void CustomMakeConfigWidget::envNameChanged(const QString& envName) 00057 { 00058 QStringList allEnvNames = m_part->allMakeEnvironments(); 00059 bool canAdd = !allEnvNames.contains(envName) && !envName.contains("/") && !envName.isEmpty(); 00060 bool canRemove = allEnvNames.contains(envName) && allEnvNames.count() > 1; 00061 addenvs_button->setEnabled(canAdd); 00062 copyenvs_button->setEnabled(canAdd); 00063 removeenvs_button->setEnabled(canRemove); 00064 } 00065 00066 void CustomMakeConfigWidget::envChanged(const QString& envName) 00067 { 00068 if (envName == m_currentEnvironment || !m_allEnvironments.contains(envName)) 00069 return; 00070 00071 // save settings of previously active environment 00072 if (!m_currentEnvironment.isNull() ) 00073 m_envWidget->accept(); 00074 00075 m_currentEnvironment = envName; 00076 m_envWidget->readEnvironment(m_dom, m_configGroup + "/make/environments/" + envName); 00077 envs_combo->setEditText(envName); 00078 } 00079 00080 void CustomMakeConfigWidget::envAdded() 00081 { 00082 QString env = envs_combo->currentText(); 00083 m_allEnvironments.append(env); 00084 00085 envs_combo->clear(); 00086 envs_combo->insertStringList(m_allEnvironments); 00087 envChanged(env); 00088 } 00089 00090 void CustomMakeConfigWidget::envRemoved() 00091 { 00092 QString env = envs_combo->currentText(); 00093 QDomNode node = DomUtil::elementByPath(m_dom, m_configGroup + "/make/environments"); 00094 node.removeChild(node.namedItem(env)); 00095 m_allEnvironments.remove(env); 00096 envs_combo->clear(); 00097 envs_combo->insertStringList(m_allEnvironments); 00098 m_currentEnvironment = QString::null; 00099 envChanged( m_allEnvironments[0] ); 00100 } 00101 00102 void CustomMakeConfigWidget::envCopied() 00103 { 00104 QString env = envs_combo->currentText(); 00105 m_allEnvironments.append(env); 00106 envs_combo->clear(); 00107 envs_combo->insertStringList(m_allEnvironments); 00108 m_currentEnvironment = env; 00109 m_envWidget->changeConfigGroup(m_configGroup + "/make/environments/" + env); 00110 envs_combo->setEditText(env); 00111 } 00112 00113 void CustomMakeConfigWidget::accept() 00114 { 00115 DomUtil::writeBoolEntry(m_dom, m_configGroup + "/make/abortonerror", abort_box->isChecked()); 00116 DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/numberofjobs", jobs_box->value()); 00117 DomUtil::writeBoolEntry(m_dom, m_configGroup + "/make/dontact", dontact_box->isChecked()); 00118 DomUtil::writeEntry(m_dom, m_configGroup + "/make/makebin", makebin_edit->text()); 00119 DomUtil::writeEntry(m_dom, m_configGroup + "/make/selectedenvironment", m_currentEnvironment); 00120 m_envWidget->accept(); 00121 } 00122 00123 #include "custommakeconfigwidget.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:38:54 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003