#include "autosort_menu.h"

int maxMoves = 20;
int messageLevel = 2;
// 0 - No Messages
// 1 - LoopsReady
// 2 - GroupReady
// 3 - ChannelMove
int messageTime = 5;
bool housekeepingRun = true;
bool versionSorting = true;
bool hideMenu = true;
int timeStampSetDelta = 604800;
// 1 hour   = 3600
// 1 day    = 86400
// 1 week   = 604800
// 1 month  = 2592000
bool writeTimeStamp = true;
int lastTimeStampSet = 0;
bool writeNewTimeStamp = false;
bool saveSetup = false;
bool sortUnsorted = true;
bool sortNew = false;
bool seperateNew = false;
bool useFixedAuto = false;
bool useFixedUnsorted = false;
bool useFixedNew = false;
int fixedAuto = 0;
int fixedUnsorted = 0;
int fixedNew = 0;


cMenuAutoSortSetup::cMenuAutoSortSetup(void)
{
  newTimeStampSetDelta = (int)rint(timeStampSetDelta / 86400);
  newWriteTimeStamp    = writeTimeStamp;
  newMaxMoves          = maxMoves;
  newMessageLevel      = messageLevel;
  newMessageTime       = messageTime;
  newSeperateNew       = seperateNew;
  newSortNew           = sortNew;
  newSortUnsorted      = sortUnsorted;
  newHideMenu          = hideMenu;
  newHousekeepingRun   = housekeepingRun;
  newVersionSorting    = versionSorting;
  newUseFixedAuto      = useFixedAuto;
  newUseFixedUnsorted  = useFixedUnsorted;
  newUseFixedNew       = useFixedNew;
  newFixedAuto         = fixedAuto;
  newFixedUnsorted     = fixedUnsorted;
  newFixedNew          = fixedNew;
  Add(new cMenuEditBoolItem( "Hide MainMenu entry",             &newHideMenu));  
  Add(new cMenuEditBoolItem( "Run on housekeeping",             &newHousekeepingRun));  
  Add(new cMenuEditIntItem ( "Max channels to move",            &newMaxMoves));
  Add(new cMenuEditIntItem ( "Message level",                   &newMessageLevel, 0, 3));
  //Add(new cMenuEditIntItem ( "Message time (s)",                &newMessageTime));  
  Add(new cMenuEditBoolItem( "Use FixedPos for 'Auto Sort'",    &newUseFixedAuto));  
  Add(new cMenuEditIntItem ( "FixedPosition for 'Auto Sort'",   &newFixedAuto));
  Add(new cMenuEditBoolItem( "Sort 'Unsorted' channels",        &newSortUnsorted));  
  Add(new cMenuEditBoolItem( "Use FixedPos for 'Unsorted'",     &newUseFixedUnsorted));  
  Add(new cMenuEditIntItem ( "FixedPosition for 'Unsorted'",    &newFixedUnsorted));
  Add(new cMenuEditBoolItem( "Keep new channels seperated",     &newSeperateNew));  
  Add(new cMenuEditBoolItem( "Sort 'New Channels'",             &newSortNew));  
  Add(new cMenuEditBoolItem( "Use FixedPos for 'New Channels'", &newUseFixedNew));  
  Add(new cMenuEditIntItem ( "FixedPosition for 'New Channels'",&newFixedNew));
  Add(new cMenuEditBoolItem( "Use 'version' sort",              &newVersionSorting));  
  Add(new cMenuEditBoolItem( "Set TimeStamps",                  &newWriteTimeStamp));  
  Add(new cMenuEditIntItem ( "Days between setting TimeStamps", &newTimeStampSetDelta, 1));
}

void cMenuAutoSortSetup::Store(void)
{
  SetupStore("MaxMoves",        maxMoves          = newMaxMoves);
  SetupStore("MessageLevel",    messageLevel      = newMessageLevel);
  SetupStore("MessageTime",     messageTime       = newMessageTime);
  SetupStore("SeperateNew",     seperateNew       = newSeperateNew);
  SetupStore("SortNew",         sortNew           = newSortNew);
  SetupStore("SortUnsorted",    sortUnsorted      = newSortUnsorted);
  SetupStore("HousekeepingRun", housekeepingRun   = newHousekeepingRun);
  SetupStore("HideMenu",        hideMenu          = newHideMenu);
  SetupStore("VersionSort",     versionSorting    = newVersionSorting);
  SetupStore("SetTimeStamps",   writeTimeStamp    = newWriteTimeStamp);
  SetupStore("TimeStampDelta",  timeStampSetDelta = (newTimeStampSetDelta * 86400));
  SetupStore("UseFixedAuto",    useFixedAuto      = newUseFixedAuto);
  SetupStore("UseFixedUnsorted",useFixedUnsorted  = newUseFixedUnsorted);
  SetupStore("UseFixedNew",     useFixedNew       = newUseFixedNew);
  SetupStore("FixedAuto",       fixedAuto         = newFixedAuto);
  SetupStore("FixedUnsorted",   fixedUnsorted     = newFixedUnsorted);
  SetupStore("FixedNew",        fixedNew          = newFixedNew);
}

