environmentvariableswidget.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "environmentvariableswidget.h"
00022
00023 #include <qcheckbox.h>
00024 #include <qlineedit.h>
00025 #include <qspinbox.h>
00026 #include <qlistview.h>
00027 #include "domutil.h"
00028 #include "addenvvardlg.h"
00029
00030
00031 void EnvironmentVariablesWidget::addVarClicked()
00032 {
00033 AddEnvvarDialog dlg;
00034 if (QListViewItem *Item = listview->selectedItem())
00035 {
00036 dlg.setvarname(Item->text(0));
00037 dlg.setvalue(Item->text(1));
00038 }
00039 if (!dlg.exec())
00040 return;
00041
00042 (void) new QListViewItem(listview, dlg.varname(), dlg.value());
00043 }
00044
00045
00046 void EnvironmentVariablesWidget::editVarClicked()
00047 {
00048 AddEnvvarDialog dlg;
00049 QListViewItem *item = listview->selectedItem();
00050 if ( !item )
00051 return;
00052 dlg.setvarname(item->text(0));
00053 dlg.setvalue(item->text(1));
00054 if (!dlg.exec())
00055 return;
00056
00057 item->setText(0,dlg.varname());
00058 item->setText(1,dlg.value());
00059 }
00060
00061
00062 void EnvironmentVariablesWidget::removeVarClicked()
00063 {
00064 delete listview->selectedItem();
00065 }
00066
00067
00068 EnvironmentVariablesWidget::EnvironmentVariablesWidget(QDomDocument &dom, const QString &configGroup,
00069 QWidget *parent, const char *name)
00070 : EnvironmentVariablesWidgetBase(parent, name),
00071 m_dom(dom), m_configGroup(configGroup)
00072 {
00073 readEnvironment(dom, configGroup);
00074 connect( listview, SIGNAL( doubleClicked ( QListViewItem *, const QPoint &, int ) ), this, SLOT( editVarClicked() ) );
00075 }
00076
00077
00078 EnvironmentVariablesWidget::~EnvironmentVariablesWidget()
00079 {}
00080
00081 void EnvironmentVariablesWidget::readEnvironment(QDomDocument &dom, const QString &configGroup)
00082 {
00083 m_dom = dom;
00084 m_configGroup = configGroup;
00085
00086 listview->clear();
00087
00088 DomUtil::PairList list =
00089 DomUtil::readPairListEntry(dom, m_configGroup, "envvar", "name", "value");
00090
00091 QListViewItem *lastItem = 0;
00092
00093 DomUtil::PairList::ConstIterator it;
00094 for (it = list.begin(); it != list.end(); ++it) {
00095 QListViewItem *newItem = new QListViewItem(listview, (*it).first, (*it).second);
00096 if (lastItem)
00097 newItem->moveItem(lastItem);
00098 lastItem = newItem;
00099 }
00100 }
00101
00102 void EnvironmentVariablesWidget::changeConfigGroup( const QString &configGroup)
00103 {
00104 m_configGroup = configGroup;
00105 }
00106
00107 void EnvironmentVariablesWidget::accept()
00108 {
00109 DomUtil::PairList list;
00110 QListViewItem *item = listview->firstChild();
00111 while (item) {
00112 list << DomUtil::Pair(item->text(0), item->text(1));
00113 item = item->nextSibling();
00114 }
00115
00116 DomUtil::writePairListEntry(m_dom, m_configGroup, "envvar", "name", "value", list);
00117 }
00118
00119 #include "environmentvariableswidget.moc"
This file is part of the documentation for KDevelop Version 3.1.2.