• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Buildtool Widgets Library
 

KDevelop Buildtool Widgets Library

  • buildtools
  • lib
  • widgets
environmentvariableswidget.cpp
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>
4
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.
9
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.
14
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "environmentvariableswidget.h"
22#include "environmentdisplaydialog.h"
23
24#include <tqcheckbox.h>
25#include <tqlineedit.h>
26#include <tqspinbox.h>
27#include <tqlistview.h>
28#include "domutil.h"
29#include "addenvvardlg.h"
30
31
32void EnvironmentVariablesWidget::addVarClicked()
33{
34 AddEnvvarDialog dlg( this, "add env dialog" ) ;
35 if (TQListViewItem *Item = listview->selectedItem())
36 {
37 dlg.setvarname(Item->text(0));
38 dlg.setvalue(Item->text(1));
39 }
40 if (!dlg.exec())
41 return;
42
43 (void) new TQListViewItem(listview, dlg.varname(), dlg.value());
44}
45
46
47void EnvironmentVariablesWidget::editVarClicked()
48{
49 AddEnvvarDialog dlg( this, "edit env dialog" );
50 TQListViewItem *item = listview->selectedItem();
51 if ( !item )
52 return;
53 dlg.setvarname(item->text(0));
54 dlg.setvalue(item->text(1));
55 if (!dlg.exec())
56 return;
57
58 item->setText(0,dlg.varname());
59 item->setText(1,dlg.value());
60}
61
62
63void EnvironmentVariablesWidget::removeVarClicked()
64{
65 delete listview->selectedItem();
66}
67
68
69EnvironmentVariablesWidget::EnvironmentVariablesWidget(TQDomDocument &dom, const TQString &configGroup,
70 TQWidget *parent, const char *name)
71 : EnvironmentVariablesWidgetBase(parent, name),
72 m_dom(dom), m_configGroup(configGroup)
73{
74 readEnvironment(dom, configGroup);
75 connect( listview, TQ_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int ) ), this, TQ_SLOT( editVarClicked() ) );
76}
77
78
79EnvironmentVariablesWidget::~EnvironmentVariablesWidget()
80{}
81
82void EnvironmentVariablesWidget::readEnvironment(TQDomDocument &dom, const TQString &configGroup)
83{
84 m_dom = dom;
85 m_configGroup = configGroup;
86
87 listview->clear();
88
89 DomUtil::PairList list =
90 DomUtil::readPairListEntry(dom, m_configGroup, "envvar", "name", "value");
91
92 TQListViewItem *lastItem = 0;
93
94 DomUtil::PairList::ConstIterator it;
95 for (it = list.begin(); it != list.end(); ++it) {
96 TQListViewItem *newItem = new TQListViewItem(listview, (*it).first, (*it).second);
97 if (lastItem)
98 newItem->moveItem(lastItem);
99 lastItem = newItem;
100 }
101}
102
103void EnvironmentVariablesWidget::changeConfigGroup( const TQString &configGroup)
104{
105 m_configGroup = configGroup;
106}
107
108void EnvironmentVariablesWidget::accept()
109{
110 DomUtil::PairList list;
111 TQListViewItem *item = listview->firstChild();
112 while (item) {
113 list << DomUtil::Pair(item->text(0), item->text(1));
114 item = item->nextSibling();
115 }
116
117 DomUtil::writePairListEntry(m_dom, m_configGroup, "envvar", "name", "value", list);
118}
119
120void EnvironmentVariablesWidget::environmentClicked()
121{
122 EnvironmentDisplayDialog dlg;
123 dlg.exec();
124}
125
126#include "environmentvariableswidget.moc"
EnvironmentVariablesWidget::changeConfigGroup
void changeConfigGroup(const TQString &configGroup)
changes the path in the DOM structure where the environment variables are stored
Definition environmentvariableswidget.cpp:103
EnvironmentVariablesWidget::readEnvironment
void readEnvironment(TQDomDocument &dom, const TQString &configGroup)
read in a set of environment variables from the DOM document
Definition environmentvariableswidget.cpp:82

KDevelop Buildtool Widgets Library

Skip menu "KDevelop Buildtool Widgets Library"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDevelop Buildtool Widgets Library

Skip menu "KDevelop Buildtool Widgets Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Buildtool Widgets Library by doxygen 1.15.0
This website is maintained by Timothy Pearson.