Changeset View
Changeset View
Standalone View
Standalone View
libs/editor/settings/teamwidget.cpp
Show All 29 Lines | |||||
30 | #include <NetworkManagerQt/GenericTypes> | 30 | #include <NetworkManagerQt/GenericTypes> | ||
31 | #include <NetworkManagerQt/Connection> | 31 | #include <NetworkManagerQt/Connection> | ||
32 | #include <NetworkManagerQt/Settings> | 32 | #include <NetworkManagerQt/Settings> | ||
33 | #include <NetworkManagerQt/ConnectionSettings> | 33 | #include <NetworkManagerQt/ConnectionSettings> | ||
34 | 34 | | |||
35 | #include <KLocalizedString> | 35 | #include <KLocalizedString> | ||
36 | #include <KMessageBox> | 36 | #include <KMessageBox> | ||
37 | 37 | | |||
38 | TeamWidget::TeamWidget(const QString & masterUuid, const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f): | 38 | TeamWidget::TeamWidget(const QString & masterUuid, const QString &masterId, | ||
39 | const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f): | ||||
39 | SettingWidget(setting, parent, f), | 40 | SettingWidget(setting, parent, f), | ||
40 | m_uuid(masterUuid), | 41 | m_uuid(masterUuid), | ||
42 | m_id(masterId), | ||||
41 | m_ui(new Ui::TeamWidget) | 43 | m_ui(new Ui::TeamWidget) | ||
42 | { | 44 | { | ||
43 | m_ui->setupUi(this); | 45 | m_ui->setupUi(this); | ||
44 | 46 | | |||
45 | // Action buttons and menu | 47 | // Action buttons and menu | ||
46 | m_menu = new QMenu(this); | 48 | m_menu = new QMenu(this); | ||
47 | QAction * action = new QAction(i18n("Ethernet"), this); | 49 | QAction * action = new QAction(i18n("Ethernet"), this); | ||
48 | action->setData(NetworkManager::ConnectionSettings::Wired); | 50 | action->setData(NetworkManager::ConnectionSettings::Wired); | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | |||||
211 | } | 213 | } | ||
212 | 214 | | |||
213 | void TeamWidget::populateTeams() | 215 | void TeamWidget::populateTeams() | ||
214 | { | 216 | { | ||
215 | m_ui->teams->clear(); | 217 | m_ui->teams->clear(); | ||
216 | 218 | | |||
217 | for (const NetworkManager::Connection::Ptr &connection : NetworkManager::listConnections()) { | 219 | for (const NetworkManager::Connection::Ptr &connection : NetworkManager::listConnections()) { | ||
218 | NetworkManager::ConnectionSettings::Ptr settings = connection->settings(); | 220 | NetworkManager::ConnectionSettings::Ptr settings = connection->settings(); | ||
219 | if (settings->master() == m_uuid && settings->slaveType() == type()) { | 221 | // The mapping from slave to master may be by uuid or name, try our best to | ||
222 | // figure out if we are master to the slave. | ||||
223 | const QString master = settings->master(); | ||||
224 | bool isSlave = ((master == m_uuid) || // by-uuid | ||||
225 | (!m_id.isEmpty() && master == m_id)); // by-name | ||||
226 | if (isSlave && (settings->slaveType() == type())) { | ||||
220 | const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType())); | 227 | const QString label = QString("%1 (%2)").arg(connection->name()).arg(connection->settings()->typeAsString(connection->settings()->connectionType())); | ||
221 | QListWidgetItem * slaveItem = new QListWidgetItem(label, m_ui->teams); | 228 | QListWidgetItem * slaveItem = new QListWidgetItem(label, m_ui->teams); | ||
222 | slaveItem->setData(Qt::UserRole, connection->uuid()); | 229 | slaveItem->setData(Qt::UserRole, connection->uuid()); | ||
223 | } | 230 | } | ||
224 | } | 231 | } | ||
225 | } | 232 | } | ||
226 | 233 | | |||
227 | void TeamWidget::importConfig() | 234 | void TeamWidget::importConfig() | ||
Show All 18 Lines |