1 #include "pirkeysetmetadata.h"
2 #include "pirselectdeviceform.h"
3 #include "pirkeysetwidgetitem.h"
4 #include "protocols/pirprotocol.h"
8 // Global helper object:
9 extern PIRMakeMgr makeManager;
11 // Static member definition:
12 PIRDeviceCollection PIRKeysetMetaData::controlledDevices;
14 PIRKeysetMetaData::PIRKeysetMetaData(
18 : threadableProtocol(NULL),
25 bool PIRKeysetMetaData::hasKey(
26 PIRKeyName name) const
28 return (keys.find(name) != keys.end());
32 void PIRKeysetMetaData::moveToThread(
35 if (threadableProtocol)
37 // Do I need some error checking here?
38 threadableProtocol->moveToThread(thread);
43 void PIRKeysetMetaData::populateDevices(
44 PIRSelectDeviceForm *sdf)
46 PIRKeysetWidgetItem *kwi;
48 PIRDeviceCollection::const_iterator i = controlledDevices.begin();
50 while (i != controlledDevices.end())
52 // Create a widget for the keyset:
53 QString tempString = makeManager.getMakeString(i->first.make);
54 tempString.append(" ");
55 tempString.append(i->first.model);
57 kwi = new PIRKeysetWidgetItem(
58 tempString, i->second, i->first.make, i->first.type);
60 sdf->addWidgetItem(kwi);
67 unsigned int PIRKeysetMetaData::getID() const
73 PIRMakeName PIRKeysetMetaData::getMake() const
78 const char *PIRKeysetMetaData::getKeysetName() const
84 void PIRKeysetMetaData::addControlledDevice(
87 PIRDeviceTypeName type)
89 controlledDevices.insert(
91 DeviceInfo(make, model, type),
96 void PIRKeysetMetaData::addKey(
102 // Don't have a system for the unmapped keys yet!
103 if (key != Unmapped_Key)
107 threadableProtocol->addKey(key, data, size);
112 void PIRKeysetMetaData::addSIRC12Key(
115 unsigned int addressData,
116 unsigned int commandData)
118 if (key != Unmapped_Key)
121 threadableProtocol->addSIRCKey(key, addressData, 5, commandData);
126 void PIRKeysetMetaData::addSIRC15Key(
129 unsigned int addressData,
130 unsigned int commandData)
132 if (key != Unmapped_Key)
135 threadableProtocol->addSIRCKey(key, addressData, 8, commandData);
140 void PIRKeysetMetaData::addSIRC20Key(
143 unsigned int secondaryAddressData,
144 unsigned int primaryAddressData,
145 unsigned int commandData)
147 if (key != Unmapped_Key)
150 threadableProtocol->addSIRC20Key(
151 key, secondaryAddressData, primaryAddressData, commandData);
156 void PIRKeysetMetaData::addSharpKey(
159 unsigned int addressData,
160 unsigned int commandData)
162 if (key != Unmapped_Key)
165 threadableProtocol->addSharpKey(key, addressData, commandData);
170 void PIRKeysetMetaData::addNECKey(
173 unsigned int addressData,
174 unsigned int commandData)
176 if (key != Unmapped_Key)
179 threadableProtocol->addNECKey(key, addressData, commandData);
184 void PIRKeysetMetaData::addPioneerKey(
187 unsigned int addressOne,
188 unsigned int commandOne,
189 unsigned int addressTwo,
190 unsigned int commandTwo)
192 if (key != Unmapped_Key)
195 threadableProtocol->addPioneerKey(
196 key, addressOne, commandOne, addressTwo, commandTwo);
202 void PIRKeysetMetaData::addRCAKey(
205 unsigned int addressData,
206 unsigned int commandData)
208 if (key != Unmapped_Key)
211 threadableProtocol->addPioneerKey(
212 key, addressData, commandData);
218 void PIRKeysetMetaData::addKaseikyoKey(
221 unsigned int addressData,
222 unsigned int commandData)
224 if (key != Unmapped_Key)
227 threadableProtocol->addKaseikyoKey(key, addressData, commandData);
232 void PIRKeysetMetaData::addDishKey(
235 unsigned int firstCommand,
236 unsigned int secondCommand)
238 if (key != Unmapped_Key)
241 threadableProtocol->addDishKey(key, firstCommand, secondCommand);
246 void PIRKeysetMetaData::addXMPKey(
249 unsigned int firstCommand,
250 unsigned int secondCommand)
252 if (key != Unmapped_Key)
255 threadableProtocol->addXMPKey(key, firstCommand, secondCommand);
260 void PIRKeysetMetaData::setPreData(
264 threadableProtocol->setPreData(data, bits);
268 void PIRKeysetMetaData::setPostData(
272 threadableProtocol->setPostData(data, bits);
276 void PIRKeysetMetaData::setKeysetName(