~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to buildtools/custommakefiles/customotherconfigwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2005 by Achim Herwig                                    *
3
 
 *   achim.herwig@wodca.de                                                 *
4
 
 *                                                                         *
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.                                   *
9
 
 *                                                                         *
10
 
 ***************************************************************************/
11
 
#include "customotherconfigwidget.h"
12
 
#include <custombuildoptionswidgetbase.h>
13
 
#include <customprojectpart.h>
14
 
#include <qcombobox.h>
15
 
#include <qdir.h>
16
 
#include <qfile.h>
17
 
#include <qfileinfo.h>
18
 
#include <qlabel.h>
19
 
#include <qlineedit.h>
20
 
#include <qpushbutton.h>
21
 
#include <qcheckbox.h>
22
 
#include <qlineedit.h>
23
 
#include <qspinbox.h>
24
 
#include <qlistview.h>
25
 
#include <qgroupbox.h>
26
 
#include <qvalidator.h>
27
 
#include <kdebug.h>
28
 
#include <klocale.h>
29
 
 
30
 
#include <environmentvariableswidget.h>
31
 
 
32
 
CustomOtherConfigWidget::CustomOtherConfigWidget(CustomProjectPart* part, const QString& configGroup, QWidget* parent)
33
 
 : CustomOtherConfigWidgetBase(parent),
34
 
    m_part(part), m_configGroup(configGroup), m_dom( *part->projectDom() )
35
 
{
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"));
40
 
 
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);
48
 
}
49
 
 
50
 
 
51
 
CustomOtherConfigWidget::~CustomOtherConfigWidget()
52
 
{
53
 
 
54
 
}
55
 
 
56
 
void CustomOtherConfigWidget::envNameChanged(const QString& envName)
57
 
{
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);
64
 
}
65
 
 
66
 
void CustomOtherConfigWidget::envChanged(const QString& envName)
67
 
{
68
 
    if (envName == m_currentEnvironment || !m_allEnvironments.contains(envName))
69
 
        return;
70
 
 
71
 
    // save settings of previously active environment
72
 
    if (!m_currentEnvironment.isNull() )
73
 
        m_envWidget->accept();
74
 
 
75
 
    m_currentEnvironment = envName;
76
 
    m_envWidget->readEnvironment(m_dom, m_configGroup + "/other/environments/" + envName);
77
 
    envs_combo->setEditText(envName);
78
 
}
79
 
 
80
 
void CustomOtherConfigWidget::envAdded()
81
 
{
82
 
    QString env = envs_combo->currentText();
83
 
    m_allEnvironments.append(env);
84
 
 
85
 
    envs_combo->clear();
86
 
    envs_combo->insertStringList(m_allEnvironments);
87
 
    envChanged(env);
88
 
}
89
 
 
90
 
void CustomOtherConfigWidget::envRemoved()
91
 
{
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);
96
 
    envs_combo->clear();
97
 
    envs_combo->insertStringList(m_allEnvironments);
98
 
    m_currentEnvironment = QString::null;
99
 
    envChanged( m_allEnvironments[0] );
100
 
}
101
 
 
102
 
void CustomOtherConfigWidget::envCopied()
103
 
{
104
 
    QString env = envs_combo->currentText();
105
 
    m_allEnvironments.append(env);
106
 
    envs_combo->clear();
107
 
    envs_combo->insertStringList(m_allEnvironments);
108
 
    m_currentEnvironment = env;
109
 
    m_envWidget->changeConfigGroup(m_configGroup + "/other/environments/" + env);
110
 
    envs_combo->setEditText(env);
111
 
}
112
 
 
113
 
void CustomOtherConfigWidget::accept()
114
 
{
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();
121
 
}
122
 
 
123
 
#include "customotherconfigwidget.moc"
124
 
// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on
125