1
/* This file is part of the KDE project
2
Copyright (C) 2001-2002 Bernd Gehrmann <bernd@kdevelop.org>
3
Copyright (C) 2003 John Firebaugh <jfirebaugh@kde.org>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
21
#include "environmentvariableswidget.h"
23
#include <qcheckbox.h>
24
#include <qlineedit.h>
26
#include <qlistview.h>
28
#include "addenvvardlg.h"
31
void EnvironmentVariablesWidget::addVarClicked()
33
AddEnvvarDialog dlg( this, "add env dialog" ) ;
34
if (QListViewItem *Item = listview->selectedItem())
36
dlg.setvarname(Item->text(0));
37
dlg.setvalue(Item->text(1));
42
(void) new QListViewItem(listview, dlg.varname(), dlg.value());
46
void EnvironmentVariablesWidget::editVarClicked()
48
AddEnvvarDialog dlg( this, "edit env dialog" );
49
QListViewItem *item = listview->selectedItem();
52
dlg.setvarname(item->text(0));
53
dlg.setvalue(item->text(1));
57
item->setText(0,dlg.varname());
58
item->setText(1,dlg.value());
62
void EnvironmentVariablesWidget::removeVarClicked()
64
delete listview->selectedItem();
68
EnvironmentVariablesWidget::EnvironmentVariablesWidget(QDomDocument &dom, const QString &configGroup,
69
QWidget *parent, const char *name)
70
: EnvironmentVariablesWidgetBase(parent, name),
71
m_dom(dom), m_configGroup(configGroup)
73
readEnvironment(dom, configGroup);
74
connect( listview, SIGNAL( doubleClicked ( QListViewItem *, const QPoint &, int ) ), this, SLOT( editVarClicked() ) );
78
EnvironmentVariablesWidget::~EnvironmentVariablesWidget()
81
void EnvironmentVariablesWidget::readEnvironment(QDomDocument &dom, const QString &configGroup)
84
m_configGroup = configGroup;
88
DomUtil::PairList list =
89
DomUtil::readPairListEntry(dom, m_configGroup, "envvar", "name", "value");
91
QListViewItem *lastItem = 0;
93
DomUtil::PairList::ConstIterator it;
94
for (it = list.begin(); it != list.end(); ++it) {
95
QListViewItem *newItem = new QListViewItem(listview, (*it).first, (*it).second);
97
newItem->moveItem(lastItem);
102
void EnvironmentVariablesWidget::changeConfigGroup( const QString &configGroup)
104
m_configGroup = configGroup;
107
void EnvironmentVariablesWidget::accept()
109
DomUtil::PairList list;
110
QListViewItem *item = listview->firstChild();
112
list << DomUtil::Pair(item->text(0), item->text(1));
113
item = item->nextSibling();
116
DomUtil::writePairListEntry(m_dom, m_configGroup, "envvar", "name", "value", list);
119
#include "environmentvariableswidget.moc"