#ifndef ConfigData_h
#define ConfigData_h

#include <QString>
#include <QStringList>
#include <QSize>
#include <QList>

class QSettings;

// The little "programs" that describe when things should happen consist of a
// list of a time and an action. That list is composed of these structs.
//
struct ProgramEntry {
   QString timespec;
   QString actionspec;
};

typedef QList<ProgramEntry> ProgramEntryList;

// Ths class holds the config data, reading it from the preferences file and
// updating the preferences when the ConfigDialog changes them.
//
class ConfigData {

   friend class ConfigDialog;

public:

   static ConfigData *
   GetConfig();

   ConfigData();

   ~ConfigData();

   void
   SaveConfigData();

   QString
   UK1104Vendor();

   QString
   UK1104Model();

   QString
   UK1104IdCode();

   QStringList
   UK1104Initialize();

   QStringList
   UK1104TurnOnLights();

   QStringList
   UK1104TurnOffLights();

   QStringList
   UK1104TurnOnUSB();

   QStringList
   UK1104TurnOffUSB();

   bool
   UK1104PollInput();

   int
   UK1104InputChannel();

   int
   UK1104ButtonPressedValue();

   QString
   LeftCameraVendor();

   QString
   LeftCameraModel();

   QString
   LeftCameraSerial();

   QString
   LeftCameraSrcDirectory();

   QStringList
   LeftCameraImageFilters();

   QString
   RightCameraVendor();

   QString
   RightCameraModel();

   QString
   RightCameraSerial();

   QString
   RightCameraSrcDirectory();

   QStringList
   RightCameraImageFilters();

   QString
   DestinationDirectory();

   QString
   LeftCameraSubdir();

   QString
   RightCameraSubdir();

   bool
   PreferenceIndependentButtons();

   QSize
   PreferenceImagePreviewSize();

   ProgramEntryList
   LightsProgram();

   ProgramEntryList
   CameraProgram();

   ProgramEntryList
   DownloadProgram();

   int
   DownloadConstTenthsOfSecond();

   int
   DownloadOneImageTenthsOfSecond();

private:

   void
   SaveStringList(QSettings & qs, QString name, QStringList & vals);

   void
   ReadStringList(QSettings & qs, QString name, QStringList & vals);

   void
   SaveProgram(QSettings & qs, QString name, ProgramEntryList & vals);

   void
   ReadProgram(QSettings & qs, QString name, ProgramEntryList & vals);

   QString      uk1104_vendor;
   QString      uk1104_model;
   QString      uk1104_id_code;
   QStringList  uk1104_initialize;
   QStringList  uk1104_turn_on_lights;
   QStringList  uk1104_turn_off_lights;
   QStringList  uk1104_turn_on_USB;
   QStringList  uk1104_turn_off_USB;
   bool         uk1104_poll_input;
   int          uk1104_input_channel;
   int          uk1104_button_pressed_value;

   QString      left_camera_vendor;
   QString      left_camera_model;
   QString      left_camera_serial;
   QString      left_camera_src_directory;
   QStringList  left_camera_image_filters;

   QString      right_camera_vendor;
   QString      right_camera_model;
   QString      right_camera_serial;
   QString      right_camera_src_directory;
   QStringList  right_camera_image_filters;

   QString      destination_directory;
   QString      left_camera_subdir;
   QString      right_camera_subdir;

   bool         preference_independent_buttons;
   QSize        preference_image_preview_size;

   ProgramEntryList lights_prog;
   ProgramEntryList cam_prog;
   ProgramEntryList download_prog;

   int          download_const_tenths_of_seconds;
   int          download_one_image_tenths_of_seconds;

   static ConfigData * config_instance;
};

#endif // ConfigData_h
