Changeset View
Changeset View
Standalone View
Standalone View
libs/models/networkmodel.cpp
Show First 20 Lines • Show All 272 Lines • ▼ Show 20 Line(s) | 269 | if (state == NetworkManager::VpnConnection::Prepare || | |||
---|---|---|---|---|---|
273 | item->setConnectionState(NetworkManager::ActiveConnection::Activating); | 273 | item->setConnectionState(NetworkManager::ActiveConnection::Activating); | ||
274 | } else if (state == NetworkManager::VpnConnection::Activated) { | 274 | } else if (state == NetworkManager::VpnConnection::Activated) { | ||
275 | item->setConnectionState(NetworkManager::ActiveConnection::Activated); | 275 | item->setConnectionState(NetworkManager::ActiveConnection::Activated); | ||
276 | } else { | 276 | } else { | ||
277 | item->setConnectionState(NetworkManager::ActiveConnection::Deactivated); | 277 | item->setConnectionState(NetworkManager::ActiveConnection::Deactivated); | ||
278 | } | 278 | } | ||
279 | item->setVpnState(state); | 279 | item->setVpnState(state); | ||
280 | } | 280 | } | ||
281 | item->updateDetails(); | 281 | item->invalidateDetails(); | ||
282 | qCDebug(PLASMA_NM) << "Item " << item->name() << ": active connection state changed to " << item->connectionState(); | 282 | qCDebug(PLASMA_NM) << "Item " << item->name() << ": active connection state changed to " << item->connectionState(); | ||
283 | } | 283 | } | ||
284 | } | 284 | } | ||
285 | endResetModel(); | 285 | endResetModel(); | ||
286 | } | 286 | } | ||
287 | 287 | | |||
288 | void NetworkModel::addAvailableConnection(const QString &connection, const NetworkManager::Device::Ptr &device) | 288 | void NetworkModel::addAvailableConnection(const QString &connection, const NetworkManager::Device::Ptr &device) | ||
289 | { | 289 | { | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 368 | if (!m_list.contains(NetworkItemsList::Connection, connection->path())) { | |||
377 | if (item->type() == NetworkManager::ConnectionSettings::Vpn) { | 377 | if (item->type() == NetworkManager::ConnectionSettings::Vpn) { | ||
378 | item->setVpnType(vpnSetting->serviceType().section('.', -1)); | 378 | item->setVpnType(vpnSetting->serviceType().section('.', -1)); | ||
379 | } else if (item->type() == NetworkManager::ConnectionSettings::Wireless) { | 379 | } else if (item->type() == NetworkManager::ConnectionSettings::Wireless) { | ||
380 | item->setMode(wirelessSetting->mode()); | 380 | item->setMode(wirelessSetting->mode()); | ||
381 | item->setSecurityType(NetworkManager::securityTypeFromConnectionSetting(settings)); | 381 | item->setSecurityType(NetworkManager::securityTypeFromConnectionSetting(settings)); | ||
382 | item->setSsid(QString::fromUtf8(wirelessSetting->ssid())); | 382 | item->setSsid(QString::fromUtf8(wirelessSetting->ssid())); | ||
383 | } | 383 | } | ||
384 | 384 | | |||
385 | item->updateDetails(); | 385 | item->invalidateDetails(); | ||
386 | 386 | | |||
387 | const int index = m_list.count(); | 387 | const int index = m_list.count(); | ||
388 | beginInsertRows(QModelIndex(), index, index); | 388 | beginInsertRows(QModelIndex(), index, index); | ||
389 | m_list.insertItem(item); | 389 | m_list.insertItem(item); | ||
390 | endInsertRows(); | 390 | endInsertRows(); | ||
391 | qCDebug(PLASMA_NM) << "New connection " << item->name() << " added"; | 391 | qCDebug(PLASMA_NM) << "New connection " << item->name() << " added"; | ||
392 | } | 392 | } | ||
393 | } | 393 | } | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 412 | { | |||
460 | item->setDevicePath(device->uni()); | 460 | item->setDevicePath(device->uni()); | ||
461 | item->setMode(mode); | 461 | item->setMode(mode); | ||
462 | item->setName(network->ssid()); | 462 | item->setName(network->ssid()); | ||
463 | item->setSignal(network->signalStrength()); | 463 | item->setSignal(network->signalStrength()); | ||
464 | item->setSpecificPath(network->referenceAccessPoint()->uni()); | 464 | item->setSpecificPath(network->referenceAccessPoint()->uni()); | ||
465 | item->setSsid(network->ssid()); | 465 | item->setSsid(network->ssid()); | ||
466 | item->setType(NetworkManager::ConnectionSettings::Wireless); | 466 | item->setType(NetworkManager::ConnectionSettings::Wireless); | ||
467 | item->setSecurityType(securityType); | 467 | item->setSecurityType(securityType); | ||
468 | item->updateDetails(); | 468 | item->invalidateDetails(); | ||
469 | 469 | | |||
470 | const int index = m_list.count(); | 470 | const int index = m_list.count(); | ||
471 | beginInsertRows(QModelIndex(), index, index); | 471 | beginInsertRows(QModelIndex(), index, index); | ||
472 | m_list.insertItem(item); | 472 | m_list.insertItem(item); | ||
473 | endInsertRows(); | 473 | endInsertRows(); | ||
474 | qCDebug(PLASMA_NM) << "New wireless network " << item->name() << " added"; | 474 | qCDebug(PLASMA_NM) << "New wireless network " << item->name() << " added"; | ||
475 | } | 475 | } | ||
476 | 476 | | |||
Show All 9 Lines | 482 | for (NetworkModelItem *item : m_list.returnItems(NetworkItemsList::Connection, connection)) { | |||
486 | 486 | | |||
487 | if (!item->duplicate() && item->itemType() == NetworkModelItem::AvailableConnection && (item->devicePath() != device->uni() && !item->devicePath().isEmpty())) { | 487 | if (!item->duplicate() && item->itemType() == NetworkModelItem::AvailableConnection && (item->devicePath() != device->uni() && !item->devicePath().isEmpty())) { | ||
488 | createDuplicate = true; | 488 | createDuplicate = true; | ||
489 | } | 489 | } | ||
490 | } | 490 | } | ||
491 | 491 | | |||
492 | if (createDuplicate) { | 492 | if (createDuplicate) { | ||
493 | NetworkModelItem *duplicatedItem = new NetworkModelItem(originalItem); | 493 | NetworkModelItem *duplicatedItem = new NetworkModelItem(originalItem); | ||
494 | duplicatedItem->updateDetails(); | 494 | duplicatedItem->invalidateDetails(); | ||
495 | 495 | | |||
496 | const int index = m_list.count(); | 496 | const int index = m_list.count(); | ||
497 | beginInsertRows(QModelIndex(), index, index); | 497 | beginInsertRows(QModelIndex(), index, index); | ||
498 | m_list.insertItem(duplicatedItem); | 498 | m_list.insertItem(duplicatedItem); | ||
499 | endInsertRows(); | 499 | endInsertRows(); | ||
500 | } | 500 | } | ||
501 | } | 501 | } | ||
502 | 502 | | |||
503 | void NetworkModel::onItemUpdated() | 503 | void NetworkModel::onItemUpdated() | ||
504 | { | 504 | { | ||
505 | NetworkModelItem *item = static_cast<NetworkModelItem*>(sender()); | 505 | NetworkModelItem *item = static_cast<NetworkModelItem*>(sender()); | ||
506 | if (item) { | 506 | if (item) { | ||
507 | updateItem(item); | 507 | updateItem(item); | ||
508 | } | 508 | } | ||
509 | } | 509 | } | ||
510 | 510 | | |||
511 | void NetworkModel::updateItem(NetworkModelItem*item) | 511 | void NetworkModel::updateItem(NetworkModelItem*item) | ||
512 | { | 512 | { | ||
513 | const int row = m_list.indexOf(item); | 513 | const int row = m_list.indexOf(item); | ||
514 | 514 | | |||
515 | if (row >= 0) { | 515 | if (row >= 0) { | ||
516 | item->updateDetails(); | 516 | item->invalidateDetails(); | ||
517 | QModelIndex index = createIndex(row, 0); | 517 | QModelIndex index = createIndex(row, 0); | ||
518 | Q_EMIT dataChanged(index, index); | 518 | Q_EMIT dataChanged(index, index); | ||
519 | } | 519 | } | ||
520 | } | 520 | } | ||
521 | 521 | | |||
522 | void NetworkModel::accessPointSignalStrengthChanged(int signal) | 522 | void NetworkModel::accessPointSignalStrengthChanged(int signal) | ||
523 | { | 523 | { | ||
524 | NetworkManager::AccessPoint *apPtr = qobject_cast<NetworkManager::AccessPoint*>(sender()); | 524 | NetworkManager::AccessPoint *apPtr = qobject_cast<NetworkManager::AccessPoint*>(sender()); | ||
Show All 30 Lines | |||||
555 | 555 | | |||
556 | void NetworkModel::activeConnectionStateChanged(NetworkManager::ActiveConnection::State state) | 556 | void NetworkModel::activeConnectionStateChanged(NetworkManager::ActiveConnection::State state) | ||
557 | { | 557 | { | ||
558 | NetworkManager::ActiveConnection *activePtr = qobject_cast<NetworkManager::ActiveConnection*>(sender()); | 558 | NetworkManager::ActiveConnection *activePtr = qobject_cast<NetworkManager::ActiveConnection*>(sender()); | ||
559 | if (activePtr) { | 559 | if (activePtr) { | ||
560 | beginResetModel(); | 560 | beginResetModel(); | ||
561 | for (NetworkModelItem *item : m_list.returnItems(NetworkItemsList::ActiveConnection, activePtr->path())) { | 561 | for (NetworkModelItem *item : m_list.returnItems(NetworkItemsList::ActiveConnection, activePtr->path())) { | ||
562 | item->setConnectionState(state); | 562 | item->setConnectionState(state); | ||
563 | item->updateDetails(); | 563 | item->invalidateDetails(); | ||
564 | qCDebug(PLASMA_NM) << "Item " << item->name() << ": active connection changed to " << item->connectionState(); | 564 | qCDebug(PLASMA_NM) << "Item " << item->name() << ": active connection changed to " << item->connectionState(); | ||
565 | } | 565 | } | ||
566 | endResetModel(); | 566 | endResetModel(); | ||
567 | } | 567 | } | ||
568 | } | 568 | } | ||
569 | 569 | | |||
570 | void NetworkModel::activeVpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason) | 570 | void NetworkModel::activeVpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason) | ||
571 | { | 571 | { | ||
▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Line(s) | 764 | { | |||
766 | Q_UNUSED(reason); | 766 | Q_UNUSED(reason); | ||
767 | 767 | | |||
768 | NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni()); | 768 | NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device*>(sender())->uni()); | ||
769 | 769 | | |||
770 | if (device) { | 770 | if (device) { | ||
771 | beginResetModel(); | 771 | beginResetModel(); | ||
772 | for (NetworkModelItem *item : m_list.returnItems(NetworkItemsList::Device, device->uni())) { | 772 | for (NetworkModelItem *item : m_list.returnItems(NetworkItemsList::Device, device->uni())) { | ||
773 | item->setDeviceState(state); | 773 | item->setDeviceState(state); | ||
774 | item->updateDetails(); | 774 | item->invalidateDetails(); | ||
775 | // qCDebug(PLASMA_NM) << "Item " << item->name() << ": device state changed to " << item->deviceState(); | 775 | // qCDebug(PLASMA_NM) << "Item " << item->name() << ": device state changed to " << item->deviceState(); | ||
776 | } | 776 | } | ||
777 | endResetModel(); | 777 | endResetModel(); | ||
778 | } | 778 | } | ||
779 | } | 779 | } | ||
780 | 780 | | |||
781 | #if WITH_MODEMMANAGER_SUPPORT | 781 | #if WITH_MODEMMANAGER_SUPPORT | ||
782 | void NetworkModel::gsmNetworkAccessTechnologiesChanged(QFlags<MMModemAccessTechnology> accessTechnologies) | 782 | void NetworkModel::gsmNetworkAccessTechnologiesChanged(QFlags<MMModemAccessTechnology> accessTechnologies) | ||
▲ Show 20 Lines • Show All 227 Lines • Show Last 20 Lines |