1
/***************************************************************************
2
* Copyright (C) 2005 by Achim Herwig *
3
* achim.herwig@wodca.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
***************************************************************************/
11
#include "customotherconfigwidget.h"
12
#include <custombuildoptionswidgetbase.h>
13
#include <customprojectpart.h>
14
#include <qcombobox.h>
17
#include <qfileinfo.h>
19
#include <qlineedit.h>
20
#include <qpushbutton.h>
21
#include <qcheckbox.h>
22
#include <qlineedit.h>
24
#include <qlistview.h>
25
#include <qgroupbox.h>
26
#include <qvalidator.h>
30
#include <environmentvariableswidget.h>
32
CustomOtherConfigWidget::CustomOtherConfigWidget(CustomProjectPart* part, const QString& configGroup, QWidget* parent)
33
: CustomOtherConfigWidgetBase(parent),
34
m_part(part), m_configGroup(configGroup), m_dom( *part->projectDom() )
36
prio_box->setValue(DomUtil::readIntEntry(m_dom, m_configGroup + "/other/prio"));
37
makebin_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/other/otherbin"));
38
defaultTarget_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/other/defaulttarget"));
39
makeoptions_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/other/otheroptions"));
41
envs_combo->setValidator(new QRegExpValidator(QRegExp("^\\D.*"), this));
42
m_allEnvironments = m_part->allMakeEnvironments();
43
m_currentEnvironment = m_part->currentMakeEnvironment();
44
env_var_group->setColumnLayout( 1, Qt::Vertical );
45
m_envWidget = new EnvironmentVariablesWidget(m_dom, m_configGroup + "/other/environments/" + m_currentEnvironment, env_var_group);
46
envs_combo->insertStringList(m_allEnvironments);
47
envs_combo->setEditText(m_currentEnvironment);
51
CustomOtherConfigWidget::~CustomOtherConfigWidget()
56
void CustomOtherConfigWidget::envNameChanged(const QString& envName)
58
QStringList allEnvNames = m_part->allMakeEnvironments();
59
bool canAdd = !allEnvNames.contains(envName) && !envName.contains("/") && !envName.isEmpty();
60
bool canRemove = allEnvNames.contains(envName) && allEnvNames.count() > 1;
61
addenvs_button->setEnabled(canAdd);
62
copyenvs_button->setEnabled(canAdd);
63
removeenvs_button->setEnabled(canRemove);
66
void CustomOtherConfigWidget::envChanged(const QString& envName)
68
if (envName == m_currentEnvironment || !m_allEnvironments.contains(envName))
71
// save settings of previously active environment
72
if (!m_currentEnvironment.isNull() )
73
m_envWidget->accept();
75
m_currentEnvironment = envName;
76
m_envWidget->readEnvironment(m_dom, m_configGroup + "/other/environments/" + envName);
77
envs_combo->setEditText(envName);
80
void CustomOtherConfigWidget::envAdded()
82
QString env = envs_combo->currentText();
83
m_allEnvironments.append(env);
86
envs_combo->insertStringList(m_allEnvironments);
90
void CustomOtherConfigWidget::envRemoved()
92
QString env = envs_combo->currentText();
93
QDomNode node = DomUtil::elementByPath(m_dom, m_configGroup + "/other/environments");
94
node.removeChild(node.namedItem(env));
95
m_allEnvironments.remove(env);
97
envs_combo->insertStringList(m_allEnvironments);
98
m_currentEnvironment = QString::null;
99
envChanged( m_allEnvironments[0] );
102
void CustomOtherConfigWidget::envCopied()
104
QString env = envs_combo->currentText();
105
m_allEnvironments.append(env);
107
envs_combo->insertStringList(m_allEnvironments);
108
m_currentEnvironment = env;
109
m_envWidget->changeConfigGroup(m_configGroup + "/other/environments/" + env);
110
envs_combo->setEditText(env);
113
void CustomOtherConfigWidget::accept()
115
DomUtil::writeIntEntry(m_dom, m_configGroup + "/other/prio", prio_box->value());
116
DomUtil::writeEntry(m_dom, m_configGroup + "/other/otherbin", makebin_edit->text());
117
DomUtil::writeEntry(m_dom, m_configGroup + "/other/defaulttarget", defaultTarget_edit->text());
118
DomUtil::writeEntry(m_dom, m_configGroup + "/other/otheroptions", makeoptions_edit->text());
119
DomUtil::writeEntry(m_dom, m_configGroup + "/other/selectedenvironment", m_currentEnvironment);
120
m_envWidget->accept();
123
#include "customotherconfigwidget.moc"
124
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on