Missed a few files
[pierogi] / pirkeysetmanager.cpp
index 29eefd5..f9732f2 100644 (file)
@@ -1,17 +1,29 @@
 #include "pirkeysetmanager.h"
+
 #include "pirkeysetmetadata.h"
+#include "pirselectkeysetform.h"
+#include "pirkeysetwidgetitem.h"
+
+#include "keysets/acer.h"
+#include "keysets/aiwa.h"
 #include "keysets/apple.h"
+#include "keysets/bose.h"
 #include "keysets/denon.h"
 #include "keysets/ei.h"
+#include "keysets/elgato.h"
 #include "keysets/goldstar.h"
 #include "keysets/hauppauge.h"
 #include "keysets/hitachi.h"
 #include "keysets/jvc.h"
 #include "keysets/lg.h"
+#include "keysets/magnavox.h"
+#include "keysets/mce.h"
 #include "keysets/mitsubishi.h"
 #include "keysets/nokia.h"
 #include "keysets/panasonic.h"
+#include "keysets/philips.h"
 #include "keysets/pinnacle.h"
+#include "keysets/pioneer.h"
 #include "keysets/raite.h"
 #include "keysets/rca.h"
 #include "keysets/sagem.h"
 #include "keysets/sanyo.h"
 #include "keysets/sharp.h"
 #include "keysets/sony.h"
+#include "keysets/tivo.h"
 #include "keysets/toshiba.h"
 #include "keysets/westinghouse.h"
 #include "keysets/yamaha.h"
 #include "keysets/zenith.h"
-#include "pirmakenames.h"
 
 #include "pirexception.h"
 
-#include <QObject>
-
 // I'll be handling the threading of the keyset commands in this object:
 #include <QMutex>
 
@@ -47,8 +57,31 @@ PIRKeysetManager::PIRKeysetManager(
   : counter(0)
 {
   // Create the keysets.  Ugly!  This needs to be worked on!
+  populateKeyset(new AcerTV1(guiObject, counter++));
+  populateKeyset(new AcerPC1(guiObject, counter++));
+
+  populateKeyset(new AiwaVCR1(guiObject, counter++));
+  populateKeyset(new AiwaVCR2(guiObject, counter++));
+  populateKeyset(new AiwaVCR3(guiObject, counter++));
+  populateKeyset(new AiwaAudio1(guiObject, counter++));
+  populateKeyset(new AiwaAudio1a(guiObject, counter++));
+  populateKeyset(new AiwaAudio2(guiObject, counter++));
+  populateKeyset(new AiwaAudio2a(guiObject, counter++));
+  populateKeyset(new AiwaAudio2b(guiObject, counter++));
+  populateKeyset(new AiwaAudio2c(guiObject, counter++));
+  populateKeyset(new AiwaAudio3(guiObject, counter++));
+  populateKeyset(new AiwaAudio4(guiObject, counter++));
+  populateKeyset(new AiwaAudio5(guiObject, counter++));
+  populateKeyset(new AiwaAudio6(guiObject, counter++));
+  populateKeyset(new AiwaCarStereo1(guiObject, counter++));
+  populateKeyset(new AiwaDVD1(guiObject, counter++));
+
   populateKeyset(new AppleWhiteRemote(guiObject, counter++));
 
+  populateKeyset(new BoseRadio1(guiObject, counter++));
+  populateKeyset(new BoseRadio2(guiObject, counter++));
+  populateKeyset(new BoseRadio3(guiObject, counter++));
+
   populateKeyset(new DenonDVD1(guiObject, counter++));
   populateKeyset(new DenonDVD2(guiObject, counter++));
   populateKeyset(new DenonDVD3(guiObject, counter++));
@@ -56,12 +89,12 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new DenonReceiver1a(guiObject, counter++));
   populateKeyset(new DenonReceiver1b(guiObject, counter++));
   populateKeyset(new DenonReceiver1c(guiObject, counter++));
+  populateKeyset(new DenonReceiver1d(guiObject, counter++));
+  populateKeyset(new DenonReceiver1e(guiObject, counter++));
+  populateKeyset(new DenonReceiver1f(guiObject, counter++));
   populateKeyset(new DenonReceiver2(guiObject, counter++));
   populateKeyset(new DenonReceiver2a(guiObject, counter++));
   populateKeyset(new DenonReceiver3(guiObject, counter++));
-  populateKeyset(new DenonReceiver3a(guiObject, counter++));
-  populateKeyset(new DenonReceiver4(guiObject, counter++));
-  populateKeyset(new DenonReceiver5(guiObject, counter++));
   populateKeyset(new DenonAudio1(guiObject, counter++));
   populateKeyset(new DenonAudio1a(guiObject, counter++));
   populateKeyset(new DenonAudio1b(guiObject, counter++));
@@ -70,9 +103,10 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new DenonAudio2(guiObject, counter++));
   populateKeyset(new DenonAudio3(guiObject, counter++));
   populateKeyset(new DenonAudio4(guiObject, counter++));
-  populateKeyset(new DenonAudio5(guiObject, counter++));
 
-  populateKeyset(new EiKeyset(guiObject, counter++));
+  populateKeyset(new EiTV1(guiObject, counter++));
+
+  populateKeyset(new ElgatoEyeTV1(guiObject, counter++));
 
   populateKeyset(new GoldStarTV1(guiObject, counter++));
   populateKeyset(new GoldStarTV2(guiObject, counter++));
@@ -80,7 +114,6 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new GoldStarVCR1a(guiObject, counter++));
   populateKeyset(new GoldStarVCR1b(guiObject, counter++));
   populateKeyset(new GoldStarVCR1c(guiObject, counter++));
-  populateKeyset(new GoldStarVCR1d(guiObject, counter++));
   populateKeyset(new GoldStarCD1(guiObject, counter++));
 
   populateKeyset(new HauppaugePCTV1(guiObject, counter++));
@@ -89,32 +122,34 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new HauppaugePCTV1c(guiObject, counter++));
   populateKeyset(new HauppaugePCTV2(guiObject, counter++));
 
+  populateKeyset(new HitachiTV1(guiObject, counter++));
+  populateKeyset(new HitachiTV1a(guiObject, counter++));
+  populateKeyset(new HitachiTV1b(guiObject, counter++));
+  populateKeyset(new HitachiTV1c(guiObject, counter++));
+  populateKeyset(new HitachiTV2(guiObject, counter++));
+  populateKeyset(new HitachiTV3(guiObject, counter++));
+  populateKeyset(new HitachiProjector(guiObject, counter++));
+  populateKeyset(new HitachiDVD1(guiObject, counter++));
+  populateKeyset(new HitachiAudio1(guiObject, counter++));
+  populateKeyset(new HitachiVCR1(guiObject, counter++));
+
   populateKeyset(new JVCSat1(guiObject, counter++));
   populateKeyset(new JVCSat2(guiObject, counter++));
   populateKeyset(new JVCVCR1(guiObject, counter++));
   populateKeyset(new JVCVCR1a(guiObject, counter++));
-  populateKeyset(new JVCVCR1b(guiObject, counter++));
-  populateKeyset(new JVCVCR1c(guiObject, counter++));
-  populateKeyset(new JVCVCR2(guiObject, counter++));
-  populateKeyset(new JVCVCR2a(guiObject, counter++));
-  populateKeyset(new JVCVCR2b(guiObject, counter++));
-  populateKeyset(new JVCVCR2c(guiObject, counter++));
+  populateKeyset(new JVCVCRBmode1(guiObject, counter++));
+  populateKeyset(new JVCVCRBmode1a(guiObject, counter++));
   populateKeyset(new JVCTV1(guiObject, counter++));
   populateKeyset(new JVCTV1a(guiObject, counter++));
   populateKeyset(new JVCTV1b(guiObject, counter++));
   populateKeyset(new JVCTV1c(guiObject, counter++));
   populateKeyset(new JVCTV1d(guiObject, counter++));
-  populateKeyset(new JVCTV2(guiObject, counter++));
-  populateKeyset(new JVCTV2a(guiObject, counter++));
-  populateKeyset(new JVCTV2b(guiObject, counter++));
-  populateKeyset(new JVCTV2c(guiObject, counter++));
-  populateKeyset(new JVCTV2d(guiObject, counter++));
   populateKeyset(new JVCDAT1(guiObject, counter++));
   populateKeyset(new JVCCarDeck1(guiObject, counter++));
-  populateKeyset(new JVCPortableAudio1(guiObject, counter++));
-  populateKeyset(new JVCPortableAudio1a(guiObject, counter++));
-  populateKeyset(new JVCPortableAudio1b(guiObject, counter++));
-  populateKeyset(new JVCPortableAudio2(guiObject, counter++));
+  populateKeyset(new JVCAudio1(guiObject, counter++));
+  populateKeyset(new JVCAudio1a(guiObject, counter++));
+  populateKeyset(new JVCAudio1b(guiObject, counter++));
+  populateKeyset(new JVCAudio2(guiObject, counter++));
   populateKeyset(new JVCDVD1(guiObject, counter++));
 
   populateKeyset(new LGTV1(guiObject, counter++));
@@ -124,13 +159,27 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new LGTV2(guiObject, counter++));
   populateKeyset(new LGTV2a(guiObject, counter++));
   populateKeyset(new LGTV2b(guiObject, counter++));
-  populateKeyset(new LGDisc1(guiObject, counter++));
-  populateKeyset(new LGDisc2(guiObject, counter++));
-  populateKeyset(new LGDisc2a(guiObject, counter++));
+//  populateKeyset(new LGDisc1(guiObject, counter++));
+//  populateKeyset(new LGDisc2(guiObject, counter++));
+//  populateKeyset(new LGDisc2a(guiObject, counter++));
   populateKeyset(new LGVCR1(guiObject, counter++));
   populateKeyset(new LGVCR1a(guiObject, counter++));
   populateKeyset(new LGVCR1b(guiObject, counter++));
 
+  populateKeyset(new MagnavoxDVD1(guiObject, counter++));
+  populateKeyset(new MagnavoxVCR1(guiObject, counter++));
+  populateKeyset(new MagnavoxConverterBox1(guiObject, counter++));
+  populateKeyset(new MagnavoxTV1(guiObject, counter++));
+
+  populateKeyset(new MCERemote1(guiObject, counter++));
+  populateKeyset(new MCERemote1a(guiObject, counter++));
+  populateKeyset(new MCERemote1b(guiObject, counter++));
+  populateKeyset(new MCERemote1c(guiObject, counter++));
+  populateKeyset(new MCERemote1d(guiObject, counter++));
+  populateKeyset(new MCERemote1e(guiObject, counter++));
+  populateKeyset(new MCERemote1f(guiObject, counter++));
+  populateKeyset(new MCERemote1g(guiObject, counter++));
+
   populateKeyset(new MitsubishiTV1(guiObject, counter++));
   populateKeyset(new MitsubishiTV1a(guiObject, counter++));
   populateKeyset(new MitsubishiVCR1(guiObject, counter++));
@@ -138,7 +187,6 @@ PIRKeysetManager::PIRKeysetManager(
 
   populateKeyset(new NokiaGenericVCR(guiObject, counter++));
 
-  populateKeyset(new PanasonicAmp(guiObject, counter++));
   populateKeyset(new PanasonicCarAudio(guiObject, counter++));
   populateKeyset(new PanasonicSat1(guiObject, counter++));
   populateKeyset(new PanasonicSat1a(guiObject, counter++));
@@ -152,22 +200,70 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new PanasonicDVD1(guiObject, counter++));
   populateKeyset(new PanasonicDVD1a(guiObject, counter++));
   populateKeyset(new PanasonicAudio1(guiObject, counter++));
-  populateKeyset(new PanasonicAudio1a(guiObject, counter++));
+
+  populateKeyset(new PhilipsTV1(guiObject, counter++));
+  populateKeyset(new PhilipsTV1a(guiObject, counter++));
+  populateKeyset(new PhilipsTV1b(guiObject, counter++));
+  populateKeyset(new PhilipsTV1c(guiObject, counter++));
+  populateKeyset(new PhilipsTV1d(guiObject, counter++));
+  populateKeyset(new PhilipsTV1e(guiObject, counter++));
+  populateKeyset(new PhilipsTV1f(guiObject, counter++));
+  populateKeyset(new PhilipsTV2(guiObject, counter++));
+  populateKeyset(new PhilipsTV2a(guiObject, counter++));
+  populateKeyset(new PhilipsTV2b(guiObject, counter++));
+  populateKeyset(new PhilipsTV3(guiObject, counter++));
+  populateKeyset(new PhilipsDVD1(guiObject, counter++));
+  populateKeyset(new PhilipsDVD1a(guiObject, counter++));
+  populateKeyset(new PhilipsDVD1b(guiObject, counter++));
+  populateKeyset(new PhilipsDVD1c(guiObject, counter++));
+  populateKeyset(new PhilipsDVD1d(guiObject, counter++));
+  populateKeyset(new PhilipsDVD2(guiObject, counter++));
+  populateKeyset(new PhilipsDVD3(guiObject, counter++));
+  populateKeyset(new PhilipsDVD4(guiObject, counter++));
+  populateKeyset(new PhilipsVCR1(guiObject, counter++));
+  populateKeyset(new PhilipsVCR1a(guiObject, counter++));
+  populateKeyset(new PhilipsVCR1b(guiObject, counter++));
+  populateKeyset(new PhilipsVCR1c(guiObject, counter++));
+  populateKeyset(new PhilipsSat1(guiObject, counter++));
+  populateKeyset(new PhilipsSat2(guiObject, counter++));
+  populateKeyset(new PhilipsSat2a(guiObject, counter++));
+  populateKeyset(new PhilipsSat3(guiObject, counter++));
+  populateKeyset(new PhilipsAudio1(guiObject, counter++));
+  populateKeyset(new PhilipsAudio1a(guiObject, counter++));
+  populateKeyset(new PhilipsAudio1b(guiObject, counter++));
+  populateKeyset(new PhilipsAudio2(guiObject, counter++));
+  populateKeyset(new PhilipsAudio3(guiObject, counter++));
+  populateKeyset(new PhilipsAudio4(guiObject, counter++));
 
   populateKeyset(new PinnaclePCTV1(guiObject, counter++));
   populateKeyset(new PinnaclePCTV2(guiObject, counter++));
   populateKeyset(new PinnaclePCTV3(guiObject, counter++));
 
+  populateKeyset(new PioneerTV1(guiObject, counter++));
+  populateKeyset(new PioneerTV2(guiObject, counter++));
+  populateKeyset(new PioneerTV3(guiObject, counter++));
+  populateKeyset(new PioneerAudio1(guiObject, counter++));
+  populateKeyset(new PioneerAudio1a(guiObject, counter++));
+  populateKeyset(new PioneerAudio2(guiObject, counter++));
+  populateKeyset(new PioneerAudio3(guiObject, counter++));
+  populateKeyset(new PioneerAudio4(guiObject, counter++));
+  populateKeyset(new PioneerAudio5(guiObject, counter++));
+  populateKeyset(new PioneerCD1(guiObject, counter++));
+  populateKeyset(new PioneerLaserDisc1(guiObject, counter++));
+  populateKeyset(new PioneerDVD1(guiObject, counter++));
+
   populateKeyset(new RaiteDVD1(guiObject, counter++));
 
   populateKeyset(new RCATV1(guiObject, counter++));
   populateKeyset(new RCATV1a(guiObject, counter++));
-  populateKeyset(new RCATV2(guiObject, counter++));
+  populateKeyset(new RCATV1b(guiObject, counter++));
+/*
   populateKeyset(new RCAAux1(guiObject, counter++));
   populateKeyset(new RCAAux2(guiObject, counter++));
   populateKeyset(new RCAAux2a(guiObject, counter++));
+*/
   populateKeyset(new RCAVCR1(guiObject, counter++));
-  populateKeyset(new RCAVCR2(guiObject, counter++));
+  populateKeyset(new RCAVCR1a(guiObject, counter++));
   populateKeyset(new RCADVD1(guiObject, counter++));
   populateKeyset(new RCADVD1a(guiObject, counter++));
   populateKeyset(new RCASat1(guiObject, counter++));
@@ -218,13 +314,11 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new SonyTV1(guiObject, counter++));
   populateKeyset(new SonyTV1a(guiObject, counter++));
   populateKeyset(new SonyTV1b(guiObject, counter++));
-  populateKeyset(new SonyTV1d(guiObject, counter++));
+  populateKeyset(new SonyTV1c(guiObject, counter++));
   populateKeyset(new SonyAmp1(guiObject, counter++));
   populateKeyset(new SonyAmp2(guiObject, counter++));
-  populateKeyset(new SonyCD1(guiObject, counter++));
-  populateKeyset(new SonyCD1a(guiObject, counter++));
-  populateKeyset(new SonyCD2(guiObject, counter++));
-  populateKeyset(new SonyCD3(guiObject, counter++));
+  populateKeyset(new SonyAudio1(guiObject, counter++));
+  populateKeyset(new SonyAudio1a(guiObject, counter++));
   populateKeyset(new SonyDAT1(guiObject, counter++));
   populateKeyset(new SonyDVD1(guiObject, counter++));
   populateKeyset(new SonyDVD1a(guiObject, counter++));
@@ -232,14 +326,24 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new SonyDVD1c(guiObject, counter++));
   populateKeyset(new SonyVCR1(guiObject, counter++));
   populateKeyset(new SonyVCR1a(guiObject, counter++));
+  populateKeyset(new SonyVCR1b(guiObject, counter++));
   populateKeyset(new SonyReceiver1(guiObject, counter++));
 
+  populateKeyset(new Tivo1(guiObject, counter++));
+  populateKeyset(new Tivo1a(guiObject, counter++));
+  populateKeyset(new Tivo1b(guiObject, counter++));
+  populateKeyset(new Tivo1c(guiObject, counter++));
+  populateKeyset(new Tivo1d(guiObject, counter++));
+
   populateKeyset(new ToshibaTV1(guiObject, counter++));
   populateKeyset(new ToshibaTV1a(guiObject, counter++));
   populateKeyset(new ToshibaTV1b(guiObject, counter++));
   populateKeyset(new ToshibaTV1c(guiObject, counter++));
   populateKeyset(new ToshibaTV1d(guiObject, counter++));
   populateKeyset(new ToshibaTV1e(guiObject, counter++));
+  populateKeyset(new ToshibaTV1f(guiObject, counter++));
+  populateKeyset(new ToshibaTV1g(guiObject, counter++));
+  populateKeyset(new ToshibaTV1h(guiObject, counter++));
   populateKeyset(new ToshibaVCR1(guiObject, counter++));
   populateKeyset(new ToshibaVCR1a(guiObject, counter++));
   populateKeyset(new ToshibaDisc1(guiObject, counter++));
@@ -262,9 +366,6 @@ PIRKeysetManager::PIRKeysetManager(
   populateKeyset(new YamahaAudio2d(guiObject, counter++));
   populateKeyset(new YamahaAudio3(guiObject, counter++));
   populateKeyset(new YamahaAudio4(guiObject, counter++));
-  populateKeyset(new YamahaAudio5(guiObject, counter++));
-  populateKeyset(new YamahaAudio6(guiObject, counter++));
-  populateKeyset(new YamahaAudio7(guiObject, counter++));
   populateKeyset(new YamahaTV1(guiObject, counter++));
   populateKeyset(new YamahaKaraoke1(guiObject, counter++));
 
@@ -299,51 +400,112 @@ PIRKeysetManager::~PIRKeysetManager()
 }
 
 
+bool PIRKeysetManager::keysetExists(
+  unsigned int keysetID) const
+{
+  PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
+
+  return (i != keysetsInfo.end());
+}
+
+
+bool PIRKeysetManager::findKeysetID(
+  QString make,
+  QString name,
+  unsigned int &id) const
+{
+  // Only modify the id if we actually find a match!
+
+  PIRKeysetMakeIndex::const_iterator i = makeIndex.find(make);
+  if (i == makeIndex.end())
+  {
+    return false;
+  }
+
+  PIRKeysetNameIndex::const_iterator ii = (*i).second.find(name);
+  if (ii == (*i).second.end())
+  {
+    return false;
+  }
+
+  //  Ok, we've found it, pull out the id:
+  id = (*ii).second;
+  return true;
+}
+
+
+PIRKeysetWidgetItem *PIRKeysetManager::makeKeysetItem(
+  QString make,
+  QString name) const
+{
+  unsigned int id;
+
+  if (!findKeysetID(make, name, id))
+  {
+    return NULL;
+  }
+
+  QString fullname = make;
+  fullname.append(" ");
+  fullname.append(name);
+
+  return new PIRKeysetWidgetItem(fullname, id, getMake(id));
+}
+
+
 bool PIRKeysetManager::hasKey(
-  int keysetID,
-  PIRKeyName name)
+  unsigned int keysetID,
+  PIRKeyName name) const
 {
-  PIRKeysetMetaData *meta = keysetsInfo[keysetID];
+  PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
 
-  if (!meta) return false;
+  if ((i == keysetsInfo.end()) || !i->second) return false;
 
-  return meta->hasKey(name);
+  return i->second->hasKey(name);
 }
 
 
 PIRMakeName PIRKeysetManager::getMake(
-  int keysetID)
+  unsigned int keysetID) const
 {
-  PIRKeysetMetaData *meta = keysetsInfo[keysetID];
+  PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
 
-  if (!meta) return Any_Make; // Work on this!
+  if ((i == keysetsInfo.end()) || !i->second) return Any_Make;
 
-  return meta->getMake();
+  return i->second->getMake();
 }
 
 
 QString PIRKeysetManager::getDisplayName(
-  int keysetID)
+  unsigned int keysetID) const
 {
-  PIRKeysetMetaData *meta = keysetsInfo[keysetID];
+  PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
 
-  if (!meta) return QString("Database Error");
+  if ((i == keysetsInfo.end()) || !i->second)
+    return QString("Database Error");
 
-  return QString(meta->getKeysetName());
+  return QString(i->second->getKeysetName());
 }
 
 
 void PIRKeysetManager::populateKeyset(
   PIRKeysetMetaData *keyset)
 {
+  // Set up the keyset collection:
   keysetsInfo[keyset->getID()] = keyset;
 
-  keyset->moveProtocolToThread(commandThread);
+  keyset->moveProtocolToThread(&commandThread);
+
+  // Also, set up a name-based index into the collection:
+  makeIndex
+    [QString(makeManager.getMakeString(keyset->getMake()))]
+    [QString(keyset->getKeysetName())]
+    = keyset->getID();
 }
 
 
 void PIRKeysetManager::populateGuiWidget(
-  PIRSelectKeysetForm *skf)
+  PIRSelectKeysetForm *skf) const
 {
   PIRMakeName make;
   PIRKeysetWidgetItem *kwi;
@@ -366,8 +528,11 @@ void PIRKeysetManager::populateGuiWidget(
 
 void PIRKeysetManager::populateDeviceTypes(
   PIRKeysetWidgetItem *kwi,
-  int keysetID)
+  unsigned int keysetID) const
 {
-  // Pass the buck:  (Need to check for bad keysetID here?)
-  keysetsInfo[keysetID]->populateDeviceTypes(kwi);
+  PIRKeysetCollection::const_iterator i = keysetsInfo.find(keysetID);
+  if ((i != keysetsInfo.end()) && i->second)
+  {
+    i->second->populateDeviceTypes(kwi);
+  }
 }