1 #include "pirkeysetmetadata.h"
2 #include "pirselectdeviceform.h"
3 #include "pirkeysetwidgetitem.h"
4 #include "protocols/pirprotocol.h"
8 // Global helper objects:
9 extern PIRMakeMgr makeManager;
10 //extern PIRDeviceTypeMgr deviceManager;
12 PIRKeysetMetaData::PIRKeysetMetaData(
16 : threadableProtocol(NULL),
23 bool PIRKeysetMetaData::hasKey(
24 PIRKeyName name) const
26 return (keys.find(name) != keys.end());
30 void PIRKeysetMetaData::moveToThread(
33 if (threadableProtocol)
35 // Do I need some error checking here?
36 threadableProtocol->moveToThread(thread);
41 void PIRKeysetMetaData::populateDevices(
43 PIRSelectDeviceForm *sdf) const
45 PIRKeysetWidgetItem *kwi;
47 PIRDeviceCollection::const_iterator i = controlledDevices.begin();
49 while (i != controlledDevices.end())
51 // Create a widget for the keyset:
52 QString tempString = makeManager.getMakeString(i->make);
53 tempString.append(" ");
54 tempString.append(i->model);
55 kwi = new PIRKeysetWidgetItem(tempString, id, i->make, i->type);
56 sdf->addWidgetItem(kwi);
63 unsigned int PIRKeysetMetaData::getID() const
69 PIRMakeName PIRKeysetMetaData::getMake() const
74 const char *PIRKeysetMetaData::getKeysetName() const
80 void PIRKeysetMetaData::addControlledDevice(
83 PIRDeviceTypeName type)
85 controlledDevices.push_back(DeviceInfo(make, model, type));
87 deviceTypes.insert(type);
91 void PIRKeysetMetaData::addKey(
97 // Don't have a system for the unmapped keys yet!
98 if (key != Unmapped_Key)
102 threadableProtocol->addKey(key, data, size);
107 void PIRKeysetMetaData::addSIRC12Key(
110 unsigned int addressData,
111 unsigned int commandData)
113 if (key != Unmapped_Key)
116 threadableProtocol->addSIRCKey(key, addressData, 5, commandData);
121 void PIRKeysetMetaData::addSIRC15Key(
124 unsigned int addressData,
125 unsigned int commandData)
127 if (key != Unmapped_Key)
130 threadableProtocol->addSIRCKey(key, addressData, 8, commandData);
135 void PIRKeysetMetaData::addSIRC20Key(
138 unsigned int secondaryAddressData,
139 unsigned int primaryAddressData,
140 unsigned int commandData)
142 if (key != Unmapped_Key)
145 threadableProtocol->addSIRC20Key(
146 key, secondaryAddressData, primaryAddressData, commandData);
151 void PIRKeysetMetaData::addSharpKey(
154 unsigned int addressData,
155 unsigned int commandData)
157 if (key != Unmapped_Key)
160 threadableProtocol->addSharpKey(key, addressData, commandData);
165 void PIRKeysetMetaData::addNECKey(
168 unsigned int addressData,
169 unsigned int commandData)
171 if (key != Unmapped_Key)
174 threadableProtocol->addNECKey(key, addressData, commandData);
179 void PIRKeysetMetaData::addPioneerKey(
182 unsigned int addressOne,
183 unsigned int commandOne,
184 unsigned int addressTwo,
185 unsigned int commandTwo)
187 if (key != Unmapped_Key)
190 threadableProtocol->addPioneerKey(
191 key, addressOne, commandOne, addressTwo, commandTwo);
197 void PIRKeysetMetaData::addRCAKey(
200 unsigned int addressData,
201 unsigned int commandData)
203 if (key != Unmapped_Key)
206 threadableProtocol->addPioneerKey(
207 key, addressData, commandData);
213 void PIRKeysetMetaData::addKaseikyoKey(
216 unsigned int addressData,
217 unsigned int commandData)
219 if (key != Unmapped_Key)
222 threadableProtocol->addKaseikyoKey(key, addressData, commandData);
227 void PIRKeysetMetaData::addDishKey(
230 unsigned int firstCommand,
231 unsigned int secondCommand)
233 if (key != Unmapped_Key)
236 threadableProtocol->addDishKey(key, firstCommand, secondCommand);
241 void PIRKeysetMetaData::setPreData(
245 threadableProtocol->setPreData(data, bits);
249 void PIRKeysetMetaData::setPostData(
253 threadableProtocol->setPostData(data, bits);
257 void PIRKeysetMetaData::setKeysetName(