From 610d5843f59680670c7651781660cdd4ac75fdea Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 6 Jan 2013 17:32:17 +0100 Subject: Fixed displaying Recording Names and Recording Folder Names correctly --- displaymenu.c | 2 +- menuitem.c | 33 ++++++++++++++++----------------- menuitem.h | 4 ++-- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/displaymenu.c b/displaymenu.c index a7c4940..7e41197 100644 --- a/displaymenu.c +++ b/displaymenu.c @@ -356,7 +356,7 @@ bool cNopacityDisplayMenu::SetItemRecording(const cRecording *Recording, int Ind bool isFolder = false; if (Total > 0) isFolder = true; - cNopacityMenuItem *item = new cNopacityRecordingMenuItem(osd, Recording, Selectable, isFolder, Total, New); + cNopacityMenuItem *item = new cNopacityRecordingMenuItem(osd, Recording, Selectable, isFolder, Level, Total, New); cPoint itemSize; menuView->GetMenuItemSize(MenuCategory(), &itemSize); item->SetFont(menuView->GetMenuItemFont(mcRecording)); diff --git a/menuitem.c b/menuitem.c index ce66983..dc05670 100644 --- a/menuitem.c +++ b/menuitem.c @@ -2,6 +2,8 @@ #include #include #include +#include +#include // cNopacityMenuItem ------------- @@ -577,9 +579,10 @@ void cNopacityChannelMenuItem::Render() { // cNopacityRecordingMenuItem ------------- -cNopacityRecordingMenuItem::cNopacityRecordingMenuItem(cOsd *osd, const cRecording *Recording, bool sel, bool isFolder, int Total, int New) : cNopacityMenuItem (osd, "", sel) { +cNopacityRecordingMenuItem::cNopacityRecordingMenuItem(cOsd *osd, const cRecording *Recording, bool sel, bool isFolder, int Level, int Total, int New) : cNopacityMenuItem (osd, "", sel) { this->Recording = Recording; this->isFolder = isFolder; + this->Level = Level; this->Total = Total; this->New = New; } @@ -605,23 +608,19 @@ void cNopacityRecordingMenuItem::CreatePixmapTextScroller(int totalWidth) { } void cNopacityRecordingMenuItem::CreateText() { - if (isFolder) { - const cRecordingInfo *recInfo = Recording->Info(); - strRecName = recInfo->Title(); - } else { - std::string recName = Recording->Name(); - if (Recording->IsEdited()) { - try { - if (recName.at(0) == '%') { - recName = recName.substr(1); - } - } catch (...) {} + std::string recName = Recording->Name(); + try { + std::vector tokens; + std::istringstream f(recName.c_str()); + std::string s; + while (std::getline(f, s, FOLDERDELIMCHAR)) { + tokens.push_back(s); } - try { - if (recName.find(FOLDERDELIMCHAR) != std::string::npos) { - recName = recName.substr(recName.find(FOLDERDELIMCHAR) + 1); - } - } catch (...) {} + strRecName = tokens.at(Level); + if (!isFolder && Recording->IsEdited()) { + strRecName = strRecName.substr(1); + } + } catch (...) { strRecName = recName.c_str(); } } diff --git a/menuitem.h b/menuitem.h index ada2f41..1cf63e5 100644 --- a/menuitem.h +++ b/menuitem.h @@ -121,7 +121,7 @@ class cNopacityRecordingMenuItem : public cNopacityMenuItem { private: const cRecording *Recording; bool isFolder; - int Total, New; + int Level, Total, New; std::string strRecName; std::string strRecNameFull; void SetTextFull(void); @@ -138,7 +138,7 @@ private: int CheckScrollableRecording(void); int CheckScrollableFolder(void); public: - cNopacityRecordingMenuItem(cOsd *osd, const cRecording *Recording, bool sel, bool isFolder, int Total, int New); + cNopacityRecordingMenuItem(cOsd *osd, const cRecording *Recording, bool sel, bool isFolder, int Level, int Total, int New); ~cNopacityRecordingMenuItem(void); void CreatePixmapTextScroller(int totalWidth); void CreateText(void); -- cgit v1.2.3