From 739a6e9404257d462321f835bccb532d26c15571 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 21 Jan 2006 14:33:37 +0000 Subject: [PATCH] Sort recordings from VDR 1.3, patch from Dave --- recording.cc | 2 +- recording.h | 2 +- vdr.cc | 2 ++ vdr.h | 26 +++++++++++++++++++------- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/recording.cc b/recording.cc index 016ef5a..2b28d54 100644 --- a/recording.cc +++ b/recording.cc @@ -58,7 +58,7 @@ char* Recording::getDirName() return dirName; } -char* Recording::getProgName() +char* Recording::getProgName() const { return progName; } diff --git a/recording.h b/recording.h index 57e0701..0d65eda 100644 --- a/recording.h +++ b/recording.h @@ -34,7 +34,7 @@ class Recording int isInDir(); char* getDirName(); - char* getProgName(); + char* getProgName() const; unsigned long start; char* fileName; diff --git a/vdr.cc b/vdr.cc index f5bd948..7d7a550 100644 --- a/vdr.cc +++ b/vdr.cc @@ -359,6 +359,8 @@ Directory* VDR::getRecordingsList() freePacket(); pthread_mutex_unlock(&mutex); + sort(recDir->recList.begin(), recDir->recList.end(), RecordingSorter()); + return recDir; } diff --git a/vdr.h b/vdr.h index 9111d2c..22ae2c1 100644 --- a/vdr.h +++ b/vdr.h @@ -45,6 +45,12 @@ typedef vector EventList; typedef vector ChannelList; typedef vector RecTimerList; +struct VDRServer +{ + char* ip; + char* name; +}; + struct RecTimerSorter // : public binary_function { bool operator() (const RecTimer* a, const RecTimer* b) @@ -53,21 +59,27 @@ struct RecTimerSorter // : public binary_function } }; -struct VDRServer -{ - char* ip; - char* name; -}; - struct ServerSorter { - bool operator() (const VDRServer a, const VDRServer b) + bool operator() (const VDRServer& a, const VDRServer& b) { if (strcmp(b.name, a.name) > 0) return true; return false; } }; +struct RecordingSorter +{ + bool operator() (const Recording* a, const Recording* b) + { + int c = strcmp(b->getProgName(), a->getProgName()); + if (c > 0) return true; + if (c < 0) return false; + + return a->start < b->start; + } +}; + class VDR { -- 2.39.5