summaryrefslogtreecommitdiff
path: root/displaymenu.c
diff options
context:
space:
mode:
Diffstat (limited to 'displaymenu.c')
-rw-r--r--displaymenu.c97
1 files changed, 64 insertions, 33 deletions
diff --git a/displaymenu.c b/displaymenu.c
index 3bdab0c6..f83a97c3 100644
--- a/displaymenu.c
+++ b/displaymenu.c
@@ -1373,26 +1373,6 @@ bool cFlatDisplayMenu::SetItemEvent(const cEvent *Event, int Index, bool Current
return true;
}
-const char * cFlatDisplayMenu::GetRecordingName(const cRecording *Recording, int Level, bool isFolder) {
- std::string recNamePart;
- std::string recName = Recording->Name();
- try {
- std::vector<std::string> tokens;
- std::istringstream f(recName.c_str());
- std::string s;
- while (std::getline(f, s, FOLDERDELIMCHAR)) {
- tokens.push_back(s);
- }
- recNamePart = tokens.at(Level);
- if(!isFolder && Recording->IsEdited() ) {
- recNamePart = recNamePart.substr(1);
- }
- } catch (...) {
- recNamePart = recName.c_str();
- }
- return recNamePart.c_str();
-}
-
bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index, bool Current, bool Selectable, int Level, int Total, int New) {
if( Config.MenuRecordingView == 0 )
return false;
@@ -1427,7 +1407,7 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index,
ColorBg = Theme.Color(clrItemBg);
}
}
-
+
menuPixmap->DrawRectangle(cRect(Config.decorBorderMenuItemSize, y, menuItemWidth, Height), ColorBg);
cImage *img = NULL;
cImage *imgRecNew = imgLoader.LoadIcon("recording_new", fontHeight, fontHeight);
@@ -1478,9 +1458,9 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index,
Left += img->Width() + marginItem;
}
- buffer = cString::sprintf("%d ", Total);
- menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, font, menuItemWidth - Left - marginItem);
- Left += font->Width( buffer );
+ buffer = cString::sprintf(" %d", Total);
+ menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, font, font->Width(" 9999"), fontHeight, taRight);
+ Left += font->Width(" 9999 ");
if( imgRecNew )
menuIconsPixmap->DrawImage( cPoint(Left, Top), *imgRecNew );
@@ -1488,11 +1468,13 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index,
buffer = cString::sprintf("%d", New);
menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, font, menuItemWidth - Left - marginItem);
Left += font->Width( buffer );
+ if( Config.MenuItemRecordingShowFolderDate != 0 ) {
+ buffer = cString::sprintf(" (%s)", *ShortDateString(GetLastRecTimeFromFolder(Recording, Level)));
+ menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorExtraTextFg, ColorBg, font, menuItemWidth - Left - marginItem);
+ }
menuPixmap->DrawText(cPoint(LeftWidth, Top), RecName, ColorFg, ColorBg, font, menuItemWidth - LeftWidth - marginItem);
LeftWidth += font->Width(RecName) + marginItem*2;
- buffer = cString::sprintf("(%s)", *ShortDateString(Recording->Start()));
- menuPixmap->DrawText(cPoint(LeftWidth, Top), buffer, ColorExtraTextFg, ColorBg, font, menuItemWidth - LeftWidth - marginItem);
} else if( Total == -1 ) {
img = imgLoader.LoadIcon("folder", fontHeight, fontHeight);
if( img ) {
@@ -1544,21 +1526,23 @@ bool cFlatDisplayMenu::SetItemRecording(const cRecording *Recording, int Index,
Left += img->Width() + marginItem;
}
menuPixmap->DrawText(cPoint(Left, Top), RecName, ColorFg, ColorBg, font, menuItemWidth - Left - marginItem);
- Left += font->Width(RecName) + marginItem*2;
- buffer = cString::sprintf("(%s)", *ShortDateString(Recording->Start()));
- menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorExtraTextFg, ColorBg, font, menuItemWidth - Left - marginItem);
- Left -= font->Width(RecName) + marginItem*2;
Top += fontHeight;
- buffer = cString::sprintf("%d ", Total);
- menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, fontSml, menuItemWidth - Left - marginItem);
- Left += fontSml->Width( buffer );
+ buffer = cString::sprintf(" %d", Total);
+ menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, fontSml, fontSml->Width(" 9999"), fontSmlHeight, taRight);
+ Left += fontSml->Width(" 9999 ");
if( imgRecNewSml )
menuIconsPixmap->DrawImage( cPoint(Left, Top), *imgRecNewSml );
Left += imgRecNewSml->Width() + marginItem;
buffer = cString::sprintf("%d", New);
menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorFg, ColorBg, fontSml, menuItemWidth - Left - marginItem);
+ Left += fontSml->Width( buffer );
+
+ if( Config.MenuItemRecordingShowFolderDate != 0 ) {
+ buffer = cString::sprintf(" (%s)", *ShortDateString(GetLastRecTimeFromFolder(Recording, Level)));
+ menuPixmap->DrawText(cPoint(Left, Top), buffer, ColorExtraTextFg, ColorBg, fontSml, menuItemWidth - Left - marginItem);
+ }
} else if( Total == -1 ) {
img = imgLoader.LoadIcon("folder", fontHeight, fontHeight);
if( img ) {
@@ -2332,6 +2316,26 @@ void cFlatDisplayMenu::ItemBorderClear(void) {
ItemsBorder.clear();
}
+time_t cFlatDisplayMenu::GetLastRecTimeFromFolder(const cRecording *Recording, int Level) {
+ std::string RecFolder = GetRecordingName(Recording, Level, true);
+ time_t RecStart = Recording->Start();
+
+ for(cRecording *rec = Recordings.First(); rec; rec = Recordings.Next(rec)) {
+ std::string RecFolder2 = GetRecordingName(rec, Level, true);
+ if( RecFolder == RecFolder2 ) { // recordings must be in the same folder
+ time_t RecStart2 = rec->Start();
+ if( Config.MenuItemRecordingShowFolderDate == 1) { // newest
+ if( RecStart2 > RecStart )
+ RecStart = RecStart2;
+ } else if( Config.MenuItemRecordingShowFolderDate == 2 ) // oldest
+ if( RecStart2 < RecStart )
+ RecStart = RecStart2;
+ }
+ }
+
+ return RecStart;
+}
+
// returns the string between start and end or an empty string if not found
string cFlatDisplayMenu::xml_substring(string source, const char* str_start, const char* str_end) {
size_t start = source.find(str_start);
@@ -2343,3 +2347,30 @@ string cFlatDisplayMenu::xml_substring(string source, const char* str_start, con
return string();
}
+
+const char * cFlatDisplayMenu::GetRecordingName(const cRecording *Recording, int Level, bool isFolder) {
+ std::string recNamePart;
+ std::string recName = Recording->Name();
+ try {
+ std::vector<std::string> tokens;
+ std::istringstream f(recName.c_str());
+ std::string s;
+ while (std::getline(f, s, FOLDERDELIMCHAR)) {
+ tokens.push_back(s);
+ }
+ recNamePart = tokens.at(Level);
+ if(!isFolder && Recording->IsEdited() ) {
+ recNamePart = recNamePart.substr(1);
+ }
+ } catch (...) {
+ recNamePart = recName.c_str();
+ }
+
+ if( Config.MenuItemRecordingClearPercent && isFolder ) {
+ if( recNamePart[0] == '%' ) {
+ recNamePart.erase(0, 1);
+ }
+ }
+
+ return recNamePart.c_str();
+}