return total;
}
-void Directory::sort()
+void Directory::sort(bool chronoSortOrder)
{
// Sort the directory order
::sort(dirList.begin(), dirList.end(), DirectorySorter());
// Sort the recordings order
- ::sort(recList.begin(), recList.end(), RecordingSorter());
+ if (chronoSortOrder)
+ ::sort(recList.begin(), recList.end(), RecordingSorterChrono());
+ else
+ ::sort(recList.begin(), recList.end(), RecordingSorterAlpha());
// Now get the dirs to sort themselves! oh I love recursion.
- for(UINT i = 0; i < dirList.size(); i++) dirList[i]->sort();
+ for(UINT i = 0; i < dirList.size(); i++) dirList[i]->sort(chronoSortOrder);
}
Directory* getDirByName(char* dirName);
ULONG getNumRecordings();
- void sort();
+ void sort(bool chronoSortOrder);
char* name;
}
};
-struct RecordingSorter
+struct RecordingSorterAlpha
{
bool operator() (const Recording* a, const Recording* b)
{
}
};
+struct RecordingSorterChrono
+{
+ bool operator() (const Recording* a, const Recording* b)
+ {
+ return a->getStartTime() < b->getStartTime();
+ }
+};
+
#endif
rootDir = new Directory("/");
currentDir = rootDir;
+
+ chronoSortOrder = false;
}
RecMan::~RecMan()
}
targetDirectory->recList.push_back(rec);
-
- // Sort it all.
- rootDir->sort();
}
ULONG RecMan::getTotalSpace()
currentDir->recList.erase(i);
toDir->recList.push_back(toMove);
- toDir->sort();
+ toDir->sort(chronoSortOrder);
}
break;
}
{
return rootDir;
}
+
+void RecMan::setSortOrderChron()
+{
+ chronoSortOrder = true;
+}
+
+void RecMan::toggleSortOrder()
+{
+ chronoSortOrder = !chronoSortOrder;
+}
+
+void RecMan::sort()
+{
+ Log::getInstance()->log("RecMan", Log::DEBUG, "Sort");
+ rootDir->sort(chronoSortOrder);
+}
RecMan();
~RecMan();
+ void setSortOrderChron();
+ void toggleSortOrder();
void setStats(ULONG totalSpace, ULONG freeSpace, ULONG usedPercent);
void addEntry(ULONG startTime, char* name, char* filename); // modifies name
+ void sort();
int deleteRecording(Recording* rec);
int moveRecording(Recording* toMove, Directory* toDir);
Directory* rootDir;
Directory* currentDir;
+ bool chronoSortOrder;
+
void constructPath(char* target, Directory* dir) ;
};
void VOptionsMenu::doGeneral()
{
- static const int numOptions = 7;
+ static const int numOptions = 8;
static const char* options1[] = {"Old", "New"};
static const char* options3[] = {"RGB+composite", "S-Video"};
static const char* options5[] = {"Chop sides", "Letterbox"};
static const char* options6[] = {"On", "Off", "Last state"};
static const char* options7[] = {"All", "FTA only"};
+ static const char* options15[] = {"Alphabetical", "Chronological"};
const static OPTIONDATA optionData[numOptions] =
{
{5, "16:9 on 4:3 display mode", "TV", "Widemode", OPTIONTYPE_TEXT, 2, 0, 0, options5 },
{6, "Power state after bootup", "General", "Power After Boot", OPTIONTYPE_TEXT, 3, 0, 0, options6 },
{7, "Display channels", "General", "Channels", OPTIONTYPE_TEXT, 2, 0, 0, options7 },
+ {15, "Recordings sort order", "General", "Recordings Sort Order", OPTIONTYPE_TEXT, 2, 0, 0, options15 },
};
// As all the above data is const static, it can be sent to the new View, this stack frame can
if (doPlay(true)) return 2;
return 1;
}
-
+ case Remote::LEFT:
+ case Remote::RIGHT:
+ case Remote::ZERO:
+ {
+ reSort();
+ return 2;
+ }
}
// stop command getting to any more views
return 1;
bool VRecordingList::load()
{
+ VDR* vdr = VDR::getInstance();
+
recman = new RecMan();
- bool success = VDR::getInstance()->getRecordingsList(recman);
+ bool success = vdr->getRecordingsList(recman);
if (success)
{
loading = false;
+
+ char* defaultSortOrder = vdr->configLoad("General", "Recordings Sort Order");
+ if (defaultSortOrder)
+ {
+ if (!STRCASECMP(defaultSortOrder, "Chronological")) recman->setSortOrderChron();
+ delete[] defaultSortOrder;
+ }
+
+ recman->sort();
+
draw();
viewman->updateView(this);
}
return success;
}
+
+void VRecordingList::reSort()
+{
+ recman->toggleSortOrder();
+ recman->sort();
+ sl.clear();
+ draw();
+ viewman->updateView(this);
+}
int doPlay(bool resume);
void doMoveRecording(Directory* toDir);
Recording* getCurrentOptionRecording();
+ void reSort();
stack<int> slIndexStack;
};