2 * Copyright (C) 2007 Christopher Blauvelt <cblauvelt@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "devicesignalmapmanager.h"
21 DeviceSignalMapManager::DeviceSignalMapManager(QObject
*parent
) : QObject(parent
)
26 DeviceSignalMapManager::~DeviceSignalMapManager()
30 void DeviceSignalMapManager::mapDevice(Solid::AcAdapter
*ac
, const QString
&udi
)
32 AcAdapterSignalMapper
*map
=0;
33 if(!signalmap
.contains(Solid::DeviceInterface::AcAdapter
)) {
34 signalmap
[Solid::DeviceInterface::AcAdapter
] = new AcAdapterSignalMapper(this);
36 map
= (AcAdapterSignalMapper
*)signalmap
[Solid::DeviceInterface::AcAdapter
];
38 connect(ac
, SIGNAL(plugStateChanged(bool, const QString
&)), map
, SLOT(plugStateChanged(bool)));
39 connect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
40 map
->setMapping(ac
, udi
);
43 void DeviceSignalMapManager::mapDevice(Solid::Button
*button
, const QString
&udi
)
45 ButtonSignalMapper
*map
=0;
46 if(!signalmap
.contains(Solid::DeviceInterface::Button
)) {
47 signalmap
[Solid::DeviceInterface::Button
] = new ButtonSignalMapper(this);
49 map
= (ButtonSignalMapper
*)signalmap
[Solid::DeviceInterface::Button
];
51 connect(button
, SIGNAL(pressed(Solid::Button::ButtonType
, const QString
&)), map
, SLOT(pressed(Solid::Button::ButtonType
)));
52 connect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
53 map
->setMapping(button
, udi
);
56 void DeviceSignalMapManager::mapDevice(Solid::Battery
*battery
, const QString
&udi
)
58 BatterySignalMapper
*map
=0;
59 if(!signalmap
.contains(Solid::DeviceInterface::Battery
)) {
60 signalmap
[Solid::DeviceInterface::Battery
] = new BatterySignalMapper(this);
62 map
= (BatterySignalMapper
*)signalmap
[Solid::DeviceInterface::Battery
];
64 connect(battery
, SIGNAL(chargePercentChanged(int, const QString
&)), map
, SLOT(chargePercentChanged(int)));
65 connect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
66 connect(battery
, SIGNAL(chargeStateChanged(int, const QString
&)), map
, SLOT(chargeStateChanged(int)));
67 connect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
68 connect(battery
, SIGNAL(plugStateChanged(bool, const QString
&)), map
, SLOT(plugStateChanged(bool)));
69 connect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
70 map
->setMapping(battery
, udi
);
73 void DeviceSignalMapManager::mapDevice(Solid::StorageAccess
*storageaccess
, const QString
&udi
)
75 StorageAccessSignalMapper
*map
=0;
76 if(!signalmap
.contains(Solid::DeviceInterface::StorageAccess
)) {
77 signalmap
[Solid::DeviceInterface::StorageAccess
] = new StorageAccessSignalMapper(this);
79 map
= (StorageAccessSignalMapper
*)signalmap
[Solid::DeviceInterface::StorageAccess
];
81 connect(storageaccess
, SIGNAL(accessibilityChanged(bool, const QString
&)), map
, SLOT(accessibilityChanged(bool)));
82 connect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
83 map
->setMapping(storageaccess
, udi
);
86 void DeviceSignalMapManager::unmapDevice(Solid::AcAdapter
*ac
)
88 if(!signalmap
.contains(Solid::DeviceInterface::AcAdapter
)) {
91 AcAdapterSignalMapper
*map
= (AcAdapterSignalMapper
*)signalmap
[Solid::DeviceInterface::AcAdapter
];
92 disconnect(ac
, SIGNAL(plugStateChanged(bool, const QString
&)), map
, SLOT(plugStateChanged(bool)));
93 disconnect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
96 void DeviceSignalMapManager::unmapDevice(Solid::Button
*button
)
98 if(!signalmap
.contains(Solid::DeviceInterface::Button
)) {
101 ButtonSignalMapper
*map
= (ButtonSignalMapper
*)signalmap
[Solid::DeviceInterface::Button
];
102 disconnect(button
, SIGNAL(pressed(Solid::Button::ButtonType
, const QString
&)), map
, SLOT(pressed(Solid::Button::ButtonType
)));
103 disconnect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
106 void DeviceSignalMapManager::unmapDevice(Solid::Battery
*battery
)
108 if(!signalmap
.contains(Solid::DeviceInterface::Battery
)) {
111 BatterySignalMapper
*map
= (BatterySignalMapper
*)signalmap
[Solid::DeviceInterface::Battery
];
112 disconnect(battery
, SIGNAL(chargePercentChanged(int, const QString
&)), map
, SLOT(chargePercentChanged(int)));
113 disconnect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
114 disconnect(battery
, SIGNAL(chargeStateChanged(int, const QString
&)), map
, SLOT(chargeStateChanged(int)));
115 disconnect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
116 disconnect(battery
, SIGNAL(plugStateChanged(bool, const QString
&)), map
, SLOT(plugStateChanged(bool)));
117 disconnect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
120 void DeviceSignalMapManager::unmapDevice(Solid::StorageAccess
*storageaccess
)
122 if(!signalmap
.contains(Solid::DeviceInterface::StorageAccess
)) {
125 StorageAccessSignalMapper
*map
= (StorageAccessSignalMapper
*)signalmap
[Solid::DeviceInterface::StorageAccess
];
126 disconnect(storageaccess
, SIGNAL(accessibilityChanged(bool, const QString
&)), map
, SLOT(accessibilityChanged(bool)));
127 disconnect(map
, SIGNAL(deviceChanged(const QString
&, const QString
&, QVariant
)), user
, SLOT(deviceChanged(const QString
&, const QString
&, QVariant
)));
130 #include "devicesignalmapmanager.moc"