Advanced Settings Panel
[pierogi] / pirpanelmanager.cpp
index 0511bfc..c3dcaa5 100644 (file)
 #include "forms/piradjustform.h"
 #include "forms/pirairconditionerform.h"
 #include "forms/piraudiodeviceform.h"
+#include "forms/pircameraform.h"
 #include "forms/pirroombaform.h"
+#include "forms/piruserform.h"
+#include "forms/pirmacroform.h"
+#include "forms/pirpowersearchform.h"
+#include "forms/piradvancedform.h"
 
 #include "mainwindow.h"
 
@@ -23,7 +28,7 @@
 
 // Debugging:
 //#include <QMaemo5InformationBox>
-//#include <iostream>
+#include <iostream>
 
 PIRPanelManager::PIRPanelManager(
   MainWindow *mw):
@@ -40,7 +45,12 @@ PIRPanelManager::PIRPanelManager(
     adjustForm(0),
     acForm(0),
     audioDeviceForm(0),
+    cameraForm(0),
     roombaForm(0),
+    userForm(0),
+    macroForm(0),
+    powerSearchForm(0),
+    advancedForm(0),
     altMainPanelFlag(false),
     currentTabsName(Universal_Tabs),
     mainWindow(mw)
@@ -48,7 +58,16 @@ PIRPanelManager::PIRPanelManager(
   QSettings settings("pietrzak.org", "Pierogi");
   if (settings.contains("currentTabsName"))
   {
-    currentTabsName = PIRTabBarName(settings.value("currentTabsName").toInt());
+    int tabVal = settings.value("currentTabsName").toInt();
+
+    if (tabVal >= Last_Tabs_Marker)
+    {
+      currentTabsName = Universal_Tabs;
+    }
+    else
+    {
+      currentTabsName = PIRTabBarName(tabVal);
+    }
   }
 
   // Set up the panel names:
@@ -88,9 +107,24 @@ PIRPanelManager::PIRPanelManager(
   shortPanelNames[Audio_Panel] = "Audio";
   longPanelNames[Audio_Panel] =
     "Audio Device Panel - various audio related buttons";
+  shortPanelNames[Camera_Panel] = "Camera";
+  longPanelNames[Camera_Panel] =
+    "Camera Panel - simple shutter controls";
   shortPanelNames[Roomba_Panel] = "Roomba";
   longPanelNames[Roomba_Panel] =
     "Roomba Panel - robotic vacuum cleaner controls";
+  shortPanelNames[User_Panel] = "User";
+  longPanelNames[User_Panel] =
+    "User Panel - macro control buttons";
+  shortPanelNames[Macro_Panel] = "Edit Macro Contents";
+  longPanelNames[Macro_Panel] =
+    "Edit Macros Panel - create, delete, edit, and manage macros";
+  shortPanelNames[PowerSearch_Panel] = "Keyset Search";
+  longPanelNames[PowerSearch_Panel] =
+    "Keyset Search Panel - execute power button in each keyset";
+  shortPanelNames[Advanced_Panel] = "Advanced Settings";
+  longPanelNames[Advanced_Panel] =
+    "Advanced Settings - allows adjustment of protocol settings";
 
   mainForm = new PIRMainForm(mainWindow);
   panels[Main_Panel] = mainForm;
@@ -131,9 +165,24 @@ PIRPanelManager::PIRPanelManager(
   audioDeviceForm = new PIRAudioDeviceForm(mainWindow);
   panels[Audio_Panel] = audioDeviceForm;
 
+  cameraForm = new PIRCameraForm(mainWindow);
+  panels[Camera_Panel] = cameraForm;
+
   roombaForm = new PIRRoombaForm(mainWindow);
   panels[Roomba_Panel] = roombaForm;
 
+  userForm = new PIRUserForm(mainWindow);
+  panels[User_Panel] = userForm;
+
+  macroForm = new PIRMacroForm(mainWindow);
+  panels[Macro_Panel] = macroForm;
+
+  powerSearchForm = new PIRPowerSearchForm(mainWindow);
+  panels[PowerSearch_Panel] = powerSearchForm;
+
+  advancedForm = new PIRAdvancedForm();
+  panels[Advanced_Panel] = advancedForm;
+
   // Set up the panel collections:
   PIRPanelNameList pset;
 
@@ -143,6 +192,7 @@ PIRPanelManager::PIRPanelManager(
   pset.push_back(Keypad_Panel);
   pset.push_back(Menu_Panel);
   pset.push_back(Media_Panel);
+  pset.push_back(User_Panel);
 //  pset.push_back(Input_Panel);
   tabLists[Universal_Tabs] = pset;
 
@@ -153,7 +203,7 @@ PIRPanelManager::PIRPanelManager(
   pset.push_back(Keypad_Panel);
   pset.push_back(Menu_Panel);
   pset.push_back(TV_Panel);
-  pset.push_back(Adjust_Panel);
+  pset.push_back(Input_Panel);
   tabLists[TV_Tabs] = pset;
 
   // The video media collection:
@@ -163,6 +213,7 @@ PIRPanelManager::PIRPanelManager(
   pset.push_back(Media_Panel);
   pset.push_back(Media2_Panel);
   pset.push_back(Input_Panel);
+  pset.push_back(Adjust_Panel);
   tabLists[VideoMedia_Tabs] = pset;
 
   // Audio panel collection:
@@ -184,10 +235,30 @@ PIRPanelManager::PIRPanelManager(
   pset.push_back(Keypad_Panel);
   tabLists[Record_Tabs] = pset;
 
+  // The camera control collection:
+  pset.clear();
+  pset.push_back(Camera_Panel);
+  tabLists[Camera_Tabs] = pset;
+
   // The Roomba collection:
   pset.clear();
   pset.push_back(Roomba_Panel);
   tabLists[Roomba_Tabs] = pset;
+
+  // The Macro Management collection:
+  pset.clear();
+  pset.push_back(Macro_Panel);
+  tabLists[Macro_Tabs] = pset;
+
+  // The Power Search collection:
+  pset.clear();
+  pset.push_back(PowerSearch_Panel);
+  tabLists[PowerSearch_Tabs] = pset;
+
+  // The Advanced Settings collection:
+  pset.clear();
+  pset.push_back(Advanced_Panel);
+  tabLists[Advanced_Tabs] = pset;
 }
 
 
@@ -230,7 +301,7 @@ void PIRPanelManager::updateTabSet()
 
 
 void PIRPanelManager::enableButtons(
-  const PIRKeysetManager *keyset,
+  PIRKeysetManager *keyset,
   unsigned int id)
 {
   mainForm->enableButtons(keyset, id);
@@ -240,7 +311,7 @@ void PIRPanelManager::enableButtons(
 
 
 void PIRPanelManager::enableButtons(
-  const PIRKeysetManager *keyset,
+  PIRKeysetManager *keyset,
   unsigned int currentID,
   unsigned int defaultID)
 {
@@ -251,7 +322,7 @@ void PIRPanelManager::enableButtons(
 
 
 void PIRPanelManager::commonEnableButtons(
-  const PIRKeysetManager *keyset,
+  PIRKeysetManager *keyset,
   unsigned int id)
 {
   utilityForm->enableButtons(keyset, id);
@@ -265,7 +336,20 @@ void PIRPanelManager::commonEnableButtons(
   adjustForm->enableButtons(keyset, id);
   acForm->enableButtons(keyset, id);
   audioDeviceForm->enableButtons(keyset, id);
+  cameraForm->enableButtons(keyset, id);
   roombaForm->enableButtons(keyset, id);
+
+  // Also, set the label in the power search form:
+  powerSearchForm->setKeysetName(mainWindow->getCurrentFullName());
+
+  // Set up the advanced parameters:
+  advancedForm->setupForm(keyset, id);
+}
+
+
+void PIRPanelManager::updateUserButtons()
+{
+  userForm->setupButtons();
 }
 
 
@@ -352,3 +436,54 @@ void PIRPanelManager::setupTabs(
   currentTabsName = name;
   updateTabSet();
 }
+
+
+void PIRPanelManager::gotoPreviousTabs()
+{
+  PIRTabsCollection::const_iterator i = tabLists.find(currentTabsName);
+
+  if (i == tabLists.end())
+  {
+    // Couldn't find currentTabsName!  Throw an error here?
+    return;
+  }
+
+  if (i == tabLists.begin())
+  {
+    // Already at first collection, nothing to do:
+    return;
+  }
+
+  --i;
+  currentTabsName = i->first;
+  updateTabSet();
+}
+
+
+void PIRPanelManager::gotoNextTabs()
+{
+  PIRTabsCollection::const_iterator i = tabLists.find(currentTabsName);
+
+  if (i == tabLists.end())
+  {
+    // Couldn't find currentTabsName!  Throw an error?
+    return;
+  }
+
+  ++i;
+
+  if (i == tabLists.end())
+  {
+    // We're already at the last collection, nothing to do:
+    return;
+  }
+
+  currentTabsName = i->first;
+  updateTabSet();
+}
+
+
+QComboBox *PIRPanelManager::getKeysetComboBox()
+{
+  return macroForm->getKeysetComboBox();
+}