Changeset View
Changeset View
Standalone View
Standalone View
libs/editor/settings/bondwidget.cpp
Show All 30 Lines | |||||
31 | #include <NetworkManagerQt/ConnectionSettings> | 31 | #include <NetworkManagerQt/ConnectionSettings> | ||
32 | 32 | | |||
33 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
34 | #include <KMessageBox> | 34 | #include <KMessageBox> | ||
35 | 35 | | |||
36 | #define NM_SETTING_BOND_OPTION_MII_MONITOR "mii" | 36 | #define NM_SETTING_BOND_OPTION_MII_MONITOR "mii" | ||
37 | #define NM_SETTING_BOND_OPTION_ARP_MONITOR "arp" | 37 | #define NM_SETTING_BOND_OPTION_ARP_MONITOR "arp" | ||
38 | 38 | | |||
39 | BondWidget::BondWidget(const QString & masterUuid, const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f): | 39 | BondWidget::BondWidget(const QString & masterUuid, const QString &masterId, | ||
40 | const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f): | ||||
40 | SettingWidget(setting, parent, f), | 41 | SettingWidget(setting, parent, f), | ||
41 | m_uuid(masterUuid), | 42 | m_uuid(masterUuid), | ||
43 | m_id(masterId), | ||||
42 | m_ui(new Ui::BondWidget) | 44 | m_ui(new Ui::BondWidget) | ||
43 | { | 45 | { | ||
44 | m_ui->setupUi(this); | 46 | m_ui->setupUi(this); | ||
45 | 47 | | |||
46 | // Action buttons and menu | 48 | // Action buttons and menu | ||
47 | m_menu = new QMenu(this); | 49 | m_menu = new QMenu(this); | ||
48 | QAction * action = new QAction(i18n("Ethernet"), this); | 50 | QAction * action = new QAction(i18n("Ethernet"), this); | ||
49 | action->setData(NetworkManager::ConnectionSettings::Wired); | 51 | action->setData(NetworkManager::ConnectionSettings::Wired); | ||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Line(s) | |||||
272 | } | 274 | } | ||
273 | 275 | | |||
274 | void BondWidget::populateBonds() | 276 | void BondWidget::populateBonds() | ||
275 | { | 277 | { | ||
276 | m_ui->bonds->clear(); | 278 | m_ui->bonds->clear(); | ||
277 | 279 | | |||
278 | for (const NetworkManager::Connection::Ptr &connection : NetworkManager::listConnections()) { | 280 | for (const NetworkManager::Connection::Ptr &connection : NetworkManager::listConnections()) { | ||
279 | NetworkManager::ConnectionSettings::Ptr settings = connection->settings(); | 281 | NetworkManager::ConnectionSettings::Ptr settings = connection->settings(); | ||
280 | if (settings->master() == m_uuid && settings->slaveType() == type()) { | 282 | // The mapping from slave to master may be by uuid or name, try our best to | ||
283 | // figure out if we are master to the slave. | ||||
284 | const QString master = settings->master(); | ||||
285 | bool isSlave = ((master == m_uuid) || // by-uuid | ||||
286 | (!m_id.isEmpty() && master == m_id)); // by-name | ||||
287 | if (isSlave && (settings->slaveType() == type())) { | ||||
281 | const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType())); | 288 | const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType())); | ||
282 | QListWidgetItem * slaveItem = new QListWidgetItem(label, m_ui->bonds); | 289 | QListWidgetItem * slaveItem = new QListWidgetItem(label, m_ui->bonds); | ||
283 | slaveItem->setData(Qt::UserRole, connection->uuid()); | 290 | slaveItem->setData(Qt::UserRole, connection->uuid()); | ||
284 | } | 291 | } | ||
285 | } | 292 | } | ||
286 | } | 293 | } | ||
287 | 294 | | |||
288 | bool BondWidget::isValid() const | 295 | bool BondWidget::isValid() const | ||
Show All 17 Lines |