summaryrefslogtreecommitdiffstats
path: root/buildtools/lib/widgets/environmentvariableswidget.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /buildtools/lib/widgets/environmentvariableswidget.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'buildtools/lib/widgets/environmentvariableswidget.cpp')
-rw-r--r--buildtools/lib/widgets/environmentvariableswidget.cpp126
1 files changed, 126 insertions, 0 deletions
diff --git a/buildtools/lib/widgets/environmentvariableswidget.cpp b/buildtools/lib/widgets/environmentvariableswidget.cpp
new file mode 100644
index 00000000..7ba08427
--- /dev/null
+++ b/buildtools/lib/widgets/environmentvariableswidget.cpp
@@ -0,0 +1,126 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001-2002 Bernd Gehrmann <[email protected]>
+ Copyright (C) 2003 John Firebaugh <[email protected]>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "environmentvariableswidget.h"
+#include "environmentdisplaydialog.h"
+
+#include <qcheckbox.h>
+#include <qlineedit.h>
+#include <qspinbox.h>
+#include <qlistview.h>
+#include "domutil.h"
+#include "addenvvardlg.h"
+
+
+void EnvironmentVariablesWidget::addVarClicked()
+{
+ AddEnvvarDialog dlg( this, "add env dialog" ) ;
+ if (QListViewItem *Item = listview->selectedItem())
+ {
+ dlg.setvarname(Item->text(0));
+ dlg.setvalue(Item->text(1));
+ }
+ if (!dlg.exec())
+ return;
+
+ (void) new QListViewItem(listview, dlg.varname(), dlg.value());
+}
+
+
+void EnvironmentVariablesWidget::editVarClicked()
+{
+ AddEnvvarDialog dlg( this, "edit env dialog" );
+ QListViewItem *item = listview->selectedItem();
+ if ( !item )
+ return;
+ dlg.setvarname(item->text(0));
+ dlg.setvalue(item->text(1));
+ if (!dlg.exec())
+ return;
+
+ item->setText(0,dlg.varname());
+ item->setText(1,dlg.value());
+}
+
+
+void EnvironmentVariablesWidget::removeVarClicked()
+{
+ delete listview->selectedItem();
+}
+
+
+EnvironmentVariablesWidget::EnvironmentVariablesWidget(QDomDocument &dom, const QString &configGroup,
+ QWidget *parent, const char *name)
+ : EnvironmentVariablesWidgetBase(parent, name),
+ m_dom(dom), m_configGroup(configGroup)
+{
+ readEnvironment(dom, configGroup);
+ connect( listview, SIGNAL( doubleClicked ( QListViewItem *, const QPoint &, int ) ), this, SLOT( editVarClicked() ) );
+}
+
+
+EnvironmentVariablesWidget::~EnvironmentVariablesWidget()
+{}
+
+void EnvironmentVariablesWidget::readEnvironment(QDomDocument &dom, const QString &configGroup)
+{
+ m_dom = dom;
+ m_configGroup = configGroup;
+
+ listview->clear();
+
+ DomUtil::PairList list =
+ DomUtil::readPairListEntry(dom, m_configGroup, "envvar", "name", "value");
+
+ QListViewItem *lastItem = 0;
+
+ DomUtil::PairList::ConstIterator it;
+ for (it = list.begin(); it != list.end(); ++it) {
+ QListViewItem *newItem = new QListViewItem(listview, (*it).first, (*it).second);
+ if (lastItem)
+ newItem->moveItem(lastItem);
+ lastItem = newItem;
+ }
+}
+
+void EnvironmentVariablesWidget::changeConfigGroup( const QString &configGroup)
+{
+ m_configGroup = configGroup;
+}
+
+void EnvironmentVariablesWidget::accept()
+{
+ DomUtil::PairList list;
+ QListViewItem *item = listview->firstChild();
+ while (item) {
+ list << DomUtil::Pair(item->text(0), item->text(1));
+ item = item->nextSibling();
+ }
+
+ DomUtil::writePairListEntry(m_dom, m_configGroup, "envvar", "name", "value", list);
+}
+
+void EnvironmentVariablesWidget::environmentClicked()
+{
+ EnvironmentDisplayDialog dlg;
+ dlg.exec();
+}
+
+#include "environmentvariableswidget.moc"