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

« back to all changes in this revision

Viewing changes to buildtools/custommakefiles/custommakeconfigwidget.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) 2003 by Hendrik Kueck                                   *
3
 
 *   kueck@cs.ubc.ca                                                       *
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 "custommakeconfigwidget.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 <qpushbutton.h>
20
 
#include <qcheckbox.h>
21
 
#include <qspinbox.h>
22
 
#include <qlistview.h>
23
 
#include <qgroupbox.h>
24
 
#include <qvalidator.h>
25
 
#include <klineedit.h>
26
 
#include <kdebug.h>
27
 
#include <klocale.h>
28
 
 
29
 
#include <environmentvariableswidget.h>
30
 
 
31
 
CustomMakeConfigWidget::CustomMakeConfigWidget(CustomProjectPart* part, const QString& configGroup, QWidget* parent)
32
 
 : CustomMakeConfigWidgetBase(parent),
33
 
    m_part(part), m_configGroup(configGroup), m_dom( *part->projectDom() )
34
 
{
35
 
    abort_box->setChecked(DomUtil::readBoolEntry(m_dom, m_configGroup + "/make/abortonerror"));
36
 
    int numjobs = DomUtil::readIntEntry(m_dom, m_configGroup + "/make/numberofjobs");
37
 
    jobs_box->setValue(numjobs);
38
 
    runMultiJobs->setChecked( (numjobs > 0 ) );
39
 
 
40
 
    prio_box->setValue(DomUtil::readIntEntry(m_dom, m_configGroup + "/make/prio"));
41
 
    dontact_box->setChecked(DomUtil::readBoolEntry(m_dom, m_configGroup + "/make/dontact"));
42
 
    makebin_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/makebin"));
43
 
    defaultTarget_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/defaulttarget"));
44
 
    makeoptions_edit->setText(DomUtil::readEntry(m_dom, m_configGroup + "/make/makeoptions"));
45
 
 
46
 
    envs_combo->setValidator(new QRegExpValidator(QRegExp("^\\D[^\\s]*"), this));
47
 
    m_allEnvironments = m_part->allMakeEnvironments();
48
 
    m_currentEnvironment = m_part->currentMakeEnvironment();
49
 
    env_var_group->setColumnLayout( 1, Qt::Vertical );
50
 
    m_envWidget = new EnvironmentVariablesWidget(m_dom, m_configGroup + "/make/environments/" + m_currentEnvironment, env_var_group);
51
 
    envs_combo->insertStringList(m_allEnvironments);
52
 
    envs_combo->setEditText(m_currentEnvironment);
53
 
}
54
 
 
55
 
 
56
 
CustomMakeConfigWidget::~CustomMakeConfigWidget()
57
 
{
58
 
 
59
 
}
60
 
 
61
 
void CustomMakeConfigWidget::envNameChanged(const QString& envName)
62
 
{
63
 
    QStringList allEnvNames = m_part->allMakeEnvironments();
64
 
    bool canAdd = !allEnvNames.contains(envName) && !envName.contains("/") && !envName.isEmpty();
65
 
    bool canRemove = allEnvNames.contains(envName) && allEnvNames.count() > 1;
66
 
    addenvs_button->setEnabled(canAdd);
67
 
    copyenvs_button->setEnabled(canAdd);
68
 
    removeenvs_button->setEnabled(canRemove);
69
 
}
70
 
 
71
 
void CustomMakeConfigWidget::envChanged(const QString& envName)
72
 
{
73
 
    if (envName == m_currentEnvironment || !m_allEnvironments.contains(envName))
74
 
        return;
75
 
 
76
 
    // save settings of previously active environment
77
 
    if (!m_currentEnvironment.isNull() )
78
 
        m_envWidget->accept();
79
 
 
80
 
    m_currentEnvironment = envName;
81
 
    m_envWidget->readEnvironment(m_dom, m_configGroup + "/make/environments/" + envName);
82
 
    envs_combo->setEditText(envName);
83
 
}
84
 
 
85
 
void CustomMakeConfigWidget::envAdded()
86
 
{
87
 
    QString env = envs_combo->currentText();
88
 
    m_allEnvironments.append(env);
89
 
 
90
 
    envs_combo->clear();
91
 
    envs_combo->insertStringList(m_allEnvironments);
92
 
    envChanged(env);
93
 
}
94
 
 
95
 
void CustomMakeConfigWidget::envRemoved()
96
 
{
97
 
    QString env = envs_combo->currentText();
98
 
    QDomNode node = DomUtil::elementByPath(m_dom, m_configGroup + "/make/environments");
99
 
    node.removeChild(node.namedItem(env));
100
 
    m_allEnvironments.remove(env);
101
 
    envs_combo->clear();
102
 
    envs_combo->insertStringList(m_allEnvironments);
103
 
    m_currentEnvironment = QString::null;
104
 
    envChanged( m_allEnvironments[0] );
105
 
}
106
 
 
107
 
void CustomMakeConfigWidget::envCopied()
108
 
{
109
 
    QString env = envs_combo->currentText();
110
 
    m_allEnvironments.append(env);
111
 
    envs_combo->clear();
112
 
    envs_combo->insertStringList(m_allEnvironments);
113
 
    m_currentEnvironment = env;
114
 
    m_envWidget->changeConfigGroup(m_configGroup + "/make/environments/" + env);
115
 
    envs_combo->setEditText(env);
116
 
}
117
 
 
118
 
void CustomMakeConfigWidget::accept()
119
 
{
120
 
    DomUtil::writeBoolEntry(m_dom, m_configGroup + "/make/abortonerror", abort_box->isChecked());
121
 
    if( runMultiJobs->isChecked() )
122
 
        DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/numberofjobs", jobs_box->value());
123
 
    else
124
 
        DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/numberofjobs", 0);
125
 
    DomUtil::writeIntEntry(m_dom, m_configGroup + "/make/prio", prio_box->value());
126
 
    DomUtil::writeBoolEntry(m_dom, m_configGroup + "/make/dontact", dontact_box->isChecked());
127
 
    DomUtil::writeEntry(m_dom, m_configGroup + "/make/makebin", makebin_edit->text());
128
 
    DomUtil::writeEntry(m_dom, m_configGroup + "/make/defaulttarget", defaultTarget_edit->text());
129
 
    DomUtil::writeEntry(m_dom, m_configGroup + "/make/makeoptions", makeoptions_edit->text());
130
 
    DomUtil::writeEntry(m_dom, m_configGroup + "/make/selectedenvironment", m_currentEnvironment);
131
 
    m_envWidget->accept();
132
 
}
133
 
 
134
 
#include "custommakeconfigwidget.moc"