NetworkManagerQt

teamsetting.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Lukáš Tinkl <ltinkl@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "teamsetting.h"
8#include "manager.h"
9#include "teamsetting_p.h"
10
11#define NM_SETTING_TEAM_INTERFACE_NAME "interface-name"
12
13#include <QDebug>
14
15NetworkManager::TeamSettingPrivate::TeamSettingPrivate()
16 : name(NM_SETTING_TEAM_SETTING_NAME)
17{
18}
19
20NetworkManager::TeamSetting::TeamSetting()
21 : Setting(Setting::Team)
22 , d_ptr(new TeamSettingPrivate())
23{
24}
25
26NetworkManager::TeamSetting::TeamSetting(const Ptr &other)
27 : Setting(other)
28 , d_ptr(new TeamSettingPrivate())
29{
30 setInterfaceName(other->interfaceName());
31 setConfig(other->config());
32}
33
34NetworkManager::TeamSetting::~TeamSetting()
35{
36 delete d_ptr;
37}
38
40{
41 Q_D(const TeamSetting);
42
43 return d->name;
44}
45
47{
49
50 d->interfaceName = name;
51}
52
53QString NetworkManager::TeamSetting::interfaceName() const
54{
55 Q_D(const TeamSetting);
56
57 return d->interfaceName;
58}
59
60QString NetworkManager::TeamSetting::config() const
61{
62 Q_D(const TeamSetting);
63 return d->config;
64}
65
66void NetworkManager::TeamSetting::setConfig(const QString &config)
67{
68 Q_D(TeamSetting);
69 d->config = config;
70}
71
72void NetworkManager::TeamSetting::fromMap(const QVariantMap &setting)
73{
74 if (setting.contains(QLatin1String(NM_SETTING_TEAM_INTERFACE_NAME))) {
75 setInterfaceName(setting.value(QLatin1String(NM_SETTING_TEAM_INTERFACE_NAME)).toString());
76 }
77
78 if (setting.contains(QLatin1String(NM_SETTING_TEAM_CONFIG))) {
79 setConfig(setting.value(QLatin1String(NM_SETTING_TEAM_CONFIG)).toString());
80 }
81}
82
84{
85 QVariantMap setting;
86
87 if (!interfaceName().isEmpty()) {
88 setting.insert(QLatin1String(NM_SETTING_TEAM_INTERFACE_NAME), interfaceName());
89 }
90 if (!config().isEmpty()) {
91 setting.insert(QLatin1String(NM_SETTING_TEAM_CONFIG), config());
92 }
93
94 return setting;
95}
96
97QDebug NetworkManager::operator<<(QDebug dbg, const NetworkManager::TeamSetting &setting)
98{
99 dbg.nospace() << "type: " << setting.typeAsString(setting.type()) << '\n';
100 dbg.nospace() << "initialized: " << !setting.isNull() << '\n';
101
102 dbg.nospace() << NM_SETTING_TEAM_INTERFACE_NAME << ": " << setting.interfaceName() << '\n';
103 dbg.nospace() << NM_SETTING_TEAM_CONFIG << ": " << setting.config() << '\n';
104
105 return dbg.maybeSpace();
106}
Represents team setting.
Definition teamsetting.h:23
void fromMap(const QVariantMap &setting) override
Must be reimplemented, default implementation does nothing.
void setInterfaceName(const QString &name)
QVariantMap toMap() const override
Must be reimplemented, default implementationd does nothing.
QString name() const override
Must be reimplemented, default implementationd does nothing.
QDebug & maybeSpace()
QDebug & nospace()
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.