2
Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) version 3, or any
8
later version accepted by the membership of KDE e.V. (or its
9
successor approved by the membership of KDE e.V.), which shall
10
act as a proxy defined in Section 6 of version 3 of the license.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library. If not, see <http://www.gnu.org/licenses/>.
21
#include "vlanwidget.h"
25
#include <NetworkManagerQt/VlanSetting>
26
#include <NetworkManagerQt/Settings>
28
VlanWidget::VlanWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
29
SettingWidget(setting, parent, f),
30
m_ui(new Ui::VlanWidget)
36
connect(m_ui->ifaceName, SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
37
connect(m_ui->parent, SIGNAL(currentIndexChanged(int)), SLOT(slotWidgetChanged()));
38
connect(m_ui->parent->lineEdit(), SIGNAL(textChanged(QString)), SLOT(slotWidgetChanged()));
40
KAcceleratorManager::manage(this);
46
VlanWidget::~VlanWidget()
51
void VlanWidget::loadConfig(const NetworkManager::Setting::Ptr &setting)
53
NetworkManager::VlanSetting::Ptr vlanSetting = setting.staticCast<NetworkManager::VlanSetting>();
55
m_ui->parent->setCurrentIndex(m_ui->parent->findData(vlanSetting->parent()));
57
m_ui->id->setValue(vlanSetting->id());
58
m_ui->ifaceName->setText(vlanSetting->interfaceName());
60
m_ui->reorderHeaders->setChecked(vlanSetting->flags().testFlag(NetworkManager::VlanSetting::ReorderHeaders));
61
m_ui->gvrp->setChecked(vlanSetting->flags().testFlag(NetworkManager::VlanSetting::Gvrp));
62
m_ui->looseBinding->setChecked(vlanSetting->flags().testFlag(NetworkManager::VlanSetting::LooseBinding));
65
QVariantMap VlanWidget::setting(bool agentOwned) const
69
NetworkManager::VlanSetting setting;
71
setting.setParent(m_ui->parent->itemData(m_ui->parent->currentIndex()).toString());
72
setting.setId(m_ui->id->value());
74
const QString ifaceName = m_ui->ifaceName->text();
75
if (!ifaceName.isEmpty())
76
setting.setInterfaceName(ifaceName);
78
NetworkManager::VlanSetting::Flags flags;
79
if (m_ui->reorderHeaders->isChecked())
80
flags |= NetworkManager::VlanSetting::ReorderHeaders;
81
if (m_ui->gvrp->isChecked())
82
flags |= NetworkManager::VlanSetting::Gvrp;
83
if (m_ui->looseBinding->isChecked())
84
flags |= NetworkManager::VlanSetting::LooseBinding;
86
setting.setFlags(flags);
88
return setting.toMap();
91
void VlanWidget::fillConnections()
93
m_ui->parent->clear();
95
foreach (const NetworkManager::Connection::Ptr &con, NetworkManager::listConnections()) {
96
if (!con->settings()->isSlave() && con->settings()->connectionType() == NetworkManager::ConnectionSettings::Wired)
97
m_ui->parent->addItem(con->name(), con->uuid());
101
bool VlanWidget::isValid() const
103
return !m_ui->parent->currentText().isEmpty() || !m_ui->ifaceName->text().isEmpty();