From patchwork Sun May 20 17:14:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Laitio X-Patchwork-Id: 12952 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SW9jw-0003Q1-UD for vdr@linuxtv.org; Sun, 20 May 2012 19:16:22 +0200 X-tubIT-Incoming-IP: 46.163.230.9 Received: from pilppa.org ([46.163.230.9] helo=shogun.pilppa.org) by mail.tu-berlin.de (exim-4.75/mailfrontend-3) with esmtps [TLSv1:AES256-SHA:256] for id 1SW9jw-0002Iw-ET; Sun, 20 May 2012 19:16:20 +0200 Received: from localhost (shogun.pilppa.org [127.0.0.1]) by shogun.pilppa.org (Postfix) with ESMTP id 3A79D11CC0DF for ; Sun, 20 May 2012 20:16:18 +0300 (EEST) X-Virus-Scanned: amavisd-new at pilppa.org Received: from shogun.pilppa.org ([127.0.0.1]) by localhost (shogun.pilppa.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LVb79ujQJhG9 for ; Sun, 20 May 2012 20:16:12 +0300 (EEST) Received: from mail.pilppa.org (mail.pilppa.org [83.102.60.31]) Message-ID: <4FB9265B.5090407@pilppa.org> Date: Sun, 20 May 2012 20:14:03 +0300 From: Mika Laitio User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120426 Thunderbird/10.0.4 MIME-Version: 1.0 To: vdr@linuxtv.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.5.20.170615 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, MIME_TEXT_ONLY_MP_MIXED 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_5000_5999 0, BODY_SIZE_7000_LESS 0, RATWARE_LC_DIGITS_HELO 0, __ANY_URI 0, __BAT_BOUNDARY 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __DATE_TZ_RU 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_MAILTO 0, __URI_NS , __USER_AGENT 0' X-LSpam-Score: -1.1 (-) X-LSpam-Report: No, score=-1.1 required=5.0 tests=BAYES_00=-1.9, RDNS_NONE=0.793, UNPARSEABLE_RELAY=0.001 autolearn=no Subject: [vdr] [PATCH] toggle between recordings sort order with 0 key X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2012 17:16:22 -0000 Status: O X-Status: X-Keywords: X-UID: 26281 Hi Attached is a patch which allows to toggle the sort order of recordings in the recording menu with vdr-1.7.27 between - name - date - recording length by pressing 0 key. At least I have found this to be very useful feature when trying to find a just made recording from which you do not know/remember the exact name to search from the long list of recordings. The thing I do not like in the patch is that the user must know this "0" key as all 4 colors are already reserved in VDR for other functions in recordings menu. (play, go to beginning, delete and info). But I do not know any better way to handle this at the moment. Patch got inspiration from http://www.u32.de/vdr-1.3.37-simple_record_sort-0.1.diff originally submitted by Walter Koch some years ago. Mika >From d15458f012c5463648ee25b163284f1db14d5f1c Mon Sep 17 00:00:00 2001 From: Mika Laitio Date: Sun, 20 May 2012 19:45:40 +0300 Subject: [PATCH] toggle between recordings sort order with 0 key By default the recordings are sorted in the recordings menu in alphabetical order just like previously. But now the user can toggle between following sorting rules by pressing the 0 key: - sort by recordings name - sort by recordings date - sort by recordings length Patch got inspiration from http://www.u32.de/vdr-1.3.37-simple_record_sort-0.1.diff originally submitted by Walter Koch. Signed-off-by: Mika Laitio --- menu.c | 11 +++++++++++ recording.c | 30 +++++++++++++++++++++++++++++- recording.h | 2 ++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/menu.c b/menu.c index ad1cac3..4fcb16d 100644 --- a/menu.c +++ b/menu.c @@ -2470,6 +2470,17 @@ eOSState cMenuRecordings::ProcessKey(eKeys Key) case kInfo: case kBlue: return Info(); case k1...k9: return Commands(Key); + case k0: SortingRule++; + if (SortingRule >= 3) + SortingRule = 0; + if (SortingRule == 0) + Skins.Message(mtInfo, tr("Sorting recordings by name")); + else if (SortingRule == 1) + Skins.Message(mtInfo, tr("Sorting recordings by date")); + else + Skins.Message(mtInfo, tr("Sorting recordings by length")); + Set(true); + return osContinue; case kNone: if (Recordings.StateChanged(recordingsState)) Set(true); break; diff --git a/recording.c b/recording.c index e1f7ec9..42d554d 100644 --- a/recording.c +++ b/recording.c @@ -68,6 +68,7 @@ bool VfatFileSystem = false; int InstanceId = 0; +int SortingRule = 0; cRecordings DeletedRecordings(true); @@ -842,7 +843,21 @@ int cRecording::GetResume(void) const int cRecording::Compare(const cListObject &ListObject) const { cRecording *r = (cRecording *)&ListObject; - return strcasecmp(SortName(), r->SortName()); + int ret; + + switch(SortingRule) { + // sort by recording name + case 0: + default:ret = strcasecmp(SortName(), r->SortName()); + break; + // sort by recording date that is stored in BaseFileName + case 1: ret = strcasecmp(BaseFileName(), r->BaseFileName()); + break; + // sort by recording length + case 2: ret = (LengthInSeconds() > r->LengthInSeconds()); + break; + } + return ret; } const char *cRecording::FileName(void) const @@ -860,6 +875,19 @@ const char *cRecording::FileName(void) const return fileName; } +const char *cRecording::BaseFileName(void) const +{ + const char *s; + const char *fullname; + + fullname = FileName(); + s = strrchr(fullname, '/'); + if (s) + return s + 1; + else + return fullname; +} + const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level) const { char New = NewIndicator && IsNew() ? '*' : ' '; diff --git a/recording.h b/recording.h index 5f94ee2..37e970f 100644 --- a/recording.h +++ b/recording.h @@ -26,6 +26,7 @@ extern bool VfatFileSystem; extern int InstanceId; +extern int SortingRule; void RemoveDeletedRecordings(void); void AssertFreeDiskSpace(int Priority = 0, bool Force = false); @@ -118,6 +119,7 @@ public: virtual int Compare(const cListObject &ListObject) const; const char *Name(void) const { return name; } const char *FileName(void) const; + const char *BaseFileName(void) const; const char *Title(char Delimiter = ' ', bool NewIndicator = false, int Level = -1) const; const cRecordingInfo *Info(void) const { return info; } const char *PrefixFileName(char Prefix); -- 1.7.10