Plasma5Support

devicesignalmapmanager.cpp
1/*
2 SPDX-FileCopyrightText: 2007 Christopher Blauvelt <cblauvelt@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-only
5*/
6
7#include "devicesignalmapmanager.h"
8
9DeviceSignalMapManager::DeviceSignalMapManager(QObject *parent)
10 : QObject(parent)
11{
12 user = parent;
13}
14
15DeviceSignalMapManager::~DeviceSignalMapManager()
16{
17}
18
19void DeviceSignalMapManager::mapDevice(Solid::Battery *battery, const QString &udi)
20{
21 BatterySignalMapper *map = nullptr;
22 if (!signalmap.contains(Solid::DeviceInterface::Battery)) {
23 map = new BatterySignalMapper(this);
24 signalmap[Solid::DeviceInterface::Battery] = map;
25 connect(map, SIGNAL(deviceChanged(QString, QString, QVariant)), user, SLOT(deviceChanged(QString, QString, QVariant)));
26 } else {
27 map = (BatterySignalMapper *)signalmap[Solid::DeviceInterface::Battery];
28 }
29
30 connect(battery, &Solid::Battery::chargePercentChanged, map, &BatterySignalMapper::chargePercentChanged);
31 connect(battery, &Solid::Battery::chargeStateChanged, map, &BatterySignalMapper::chargeStateChanged);
32 connect(battery, &Solid::Battery::presentStateChanged, map, &BatterySignalMapper::presentStateChanged);
33 map->setMapping(battery, udi);
34}
35
36void DeviceSignalMapManager::mapDevice(Solid::StorageAccess *storageaccess, const QString &udi)
37{
38 StorageAccessSignalMapper *map = nullptr;
39 if (!signalmap.contains(Solid::DeviceInterface::StorageAccess)) {
40 map = new StorageAccessSignalMapper(this);
41 signalmap[Solid::DeviceInterface::StorageAccess] = map;
42 connect(map, SIGNAL(deviceChanged(QString, QString, QVariant)), user, SLOT(deviceChanged(QString, QString, QVariant)));
43 } else {
44 map = (StorageAccessSignalMapper *)signalmap[Solid::DeviceInterface::StorageAccess];
45 }
46
47 connect(storageaccess, &Solid::StorageAccess::accessibilityChanged, map, &StorageAccessSignalMapper::accessibilityChanged);
48 map->setMapping(storageaccess, udi);
49}
50
51void DeviceSignalMapManager::unmapDevice(Solid::Battery *battery)
52{
53 BatterySignalMapper *map = (BatterySignalMapper *)signalmap.value(Solid::DeviceInterface::Battery);
54 if (!map) {
55 return;
56 }
57
58 disconnect(battery, &Solid::Battery::chargePercentChanged, map, &BatterySignalMapper::chargePercentChanged);
59 disconnect(battery, &Solid::Battery::chargeStateChanged, map, &BatterySignalMapper::chargeStateChanged);
60 disconnect(battery, &Solid::Battery::presentStateChanged, map, &BatterySignalMapper::presentStateChanged);
61}
62
63void DeviceSignalMapManager::unmapDevice(Solid::StorageAccess *storageaccess)
64{
65 StorageAccessSignalMapper *map = (StorageAccessSignalMapper *)signalmap.value(Solid::DeviceInterface::StorageAccess);
66 if (!map) {
67 return;
68 }
69
70 disconnect(storageaccess, &Solid::StorageAccess::accessibilityChanged, map, &StorageAccessSignalMapper::accessibilityChanged);
71}
void presentStateChanged(bool newState, const QString &udi)
void chargePercentChanged(int value, const QString &udi)
void chargeStateChanged(int newState, const QString &udi=QString())
void accessibilityChanged(bool accessible, const QString &udi)
bool contains(const Key &key) const const
T value(const Key &key, const T &defaultValue) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.