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),
26 PIRKeysetMetaData::~PIRKeysetMetaData()
28 if (threadableProtocol) delete threadableProtocol;
29 threadableProtocol = 0;
33 bool PIRKeysetMetaData::hasKey(
34 PIRKeyName name) const
36 return (keys.find(name) != keys.end());
40 void PIRKeysetMetaData::moveToThread(
43 if (threadableProtocol)
45 // Do I need some error checking here?
46 threadableProtocol->moveToThread(thread);
51 void PIRKeysetMetaData::populateDevices(
52 PIRSelectDeviceForm *sdf)
54 PIRKeysetWidgetItem *kwi;
56 PIRDeviceCollection::const_iterator i = controlledDevices.begin();
58 while (i != controlledDevices.end())
60 // Create a widget for the keyset:
61 QString tempString = makeManager.getMakeString(i->first.make);
62 tempString.append(" ");
63 tempString.append(i->first.model);
65 kwi = new PIRKeysetWidgetItem(
66 tempString, i->first.model, i->second, i->first.make, i->first.type);
68 sdf->addWidgetItem(kwi);
75 unsigned int PIRKeysetMetaData::getID() const
81 PIRMakeName PIRKeysetMetaData::getMake() const
86 const char *PIRKeysetMetaData::getKeysetName() const
92 void PIRKeysetMetaData::addControlledDevice(
95 PIRDeviceTypeName type)
97 controlledDevices.insert(
99 DeviceInfo(make, model, type),
104 void PIRKeysetMetaData::addKey(
110 // Don't have a system for the unmapped keys yet!
111 if (key != Unmapped_Key)
115 threadableProtocol->addKey(key, data, size);
120 void PIRKeysetMetaData::addSIRC12Key(
123 unsigned int addressData,
124 unsigned int commandData)
126 if (key != Unmapped_Key)
129 threadableProtocol->addSIRCKey(key, addressData, 5, commandData);
134 void PIRKeysetMetaData::addSIRC15Key(
137 unsigned int addressData,
138 unsigned int commandData)
140 if (key != Unmapped_Key)
143 threadableProtocol->addSIRCKey(key, addressData, 8, commandData);
148 void PIRKeysetMetaData::addSIRC20Key(
151 unsigned int secondaryAddressData,
152 unsigned int primaryAddressData,
153 unsigned int commandData)
155 if (key != Unmapped_Key)
158 threadableProtocol->addSIRC20Key(
159 key, secondaryAddressData, primaryAddressData, commandData);
164 void PIRKeysetMetaData::addSharpKey(
167 unsigned int addressData,
168 unsigned int commandData)
170 if (key != Unmapped_Key)
173 threadableProtocol->addSharpKey(key, addressData, commandData);
178 void PIRKeysetMetaData::addNECKey(
181 unsigned int addressData,
182 unsigned int commandData)
184 if (key != Unmapped_Key)
187 threadableProtocol->addNECKey(key, addressData, commandData);
192 void PIRKeysetMetaData::addPanOldKey(
195 unsigned int addressData,
196 unsigned int commandData)
198 if (key != Unmapped_Key)
201 threadableProtocol->addPanOldKey(key, addressData, commandData);
206 void PIRKeysetMetaData::addPioneerKey(
209 unsigned int addressOne,
210 unsigned int commandOne,
211 unsigned int addressTwo,
212 unsigned int commandTwo)
214 if (key != Unmapped_Key)
217 threadableProtocol->addPioneerKey(
218 key, addressOne, commandOne, addressTwo, commandTwo);
224 void PIRKeysetMetaData::addRCAKey(
227 unsigned int addressData,
228 unsigned int commandData)
230 if (key != Unmapped_Key)
233 threadableProtocol->addPioneerKey(
234 key, addressData, commandData);
240 void PIRKeysetMetaData::addKaseikyoKey(
243 unsigned int addressData,
244 unsigned int commandData)
246 if (key != Unmapped_Key)
249 threadableProtocol->addKaseikyoKey(key, addressData, commandData);
254 void PIRKeysetMetaData::addDishKey(
257 unsigned int firstCommand,
258 unsigned int secondCommand)
260 if (key != Unmapped_Key)
263 threadableProtocol->addDishKey(key, firstCommand, secondCommand);
268 void PIRKeysetMetaData::addXMPKey(
271 unsigned int firstCommand,
272 unsigned int secondCommand)
274 if (key != Unmapped_Key)
277 threadableProtocol->addXMPKey(key, firstCommand, secondCommand);
282 void PIRKeysetMetaData::setPreData(
286 threadableProtocol->setPreData(data, bits);
290 void PIRKeysetMetaData::setPostData(
294 threadableProtocol->setPostData(data, bits);
298 void PIRKeysetMetaData::setKeysetName(
305 void PIRKeysetMetaData::clearProtocol()
307 if (threadableProtocol)
309 delete threadableProtocol;
310 threadableProtocol = 0;