diff options
author | Timo Eskola <timo@tolleri.net> | 2018-08-28 11:08:42 +0300 |
---|---|---|
committer | Timo Eskola <timo@tolleri.net> | 2018-08-28 11:08:42 +0300 |
commit | 2f4ac127c3a0948fae9b22226e235b867908b6c3 (patch) | |
tree | 8aebb70cb0f963cef10ced7cffc6ceb92c674179 | |
parent | ed56164c362dac89ca8fedfee89f16fded90a4d5 (diff) | |
download | vdr-plugin-duplicates-2f4ac127c3a0948fae9b22226e235b867908b6c3.tar.gz vdr-plugin-duplicates-2f4ac127c3a0948fae9b22226e235b867908b6c3.tar.bz2 |
Fixed current item selection after deletion.
-rw-r--r-- | menu.c | 32 | ||||
-rw-r--r-- | menu.h | 1 |
2 files changed, 20 insertions, 13 deletions
@@ -339,18 +339,7 @@ void cMenuDuplicates::Set(bool Refresh) { if (Count() == 0) Add(SeparatorItem(cString::sprintf(tr("%d duplicate recordings"), 0))); if (Refresh) { - if (currentIndex >= 0) { - if(currentIndex >= Count()) - currentIndex = Count() - 1; - cOsdItem *current = Get(currentIndex); - while (current) { - if (current->Selectable()) { - SetCurrent(current); - break; - } - current = Prev(current); - } - } + SetCurrentIndex(currentIndex); Display(); } gettimeofday(&stopTime, NULL); @@ -437,6 +426,21 @@ static bool TimerStillRecording(const char *FileName) { return false; } +void cMenuDuplicates::SetCurrentIndex(int index) { + if (index >= 0) { + if (index >= Count()) + index = Count() - 1; + cOsdItem *current = Get(index); + while (current) { + if (current->Selectable()) { + SetCurrent(current); + break; + } + current = Prev(current); + } + } +} + eOSState cMenuDuplicates::Delete(void) { if (HasSubMenu() || Count() == 0) return osContinue; @@ -490,7 +494,8 @@ eOSState cMenuDuplicates::Delete(void) { Recordings->SetModified(); recordingsStateKey.Remove(); #endif - cOsdMenu::Del(Current()); + int currentIndex = Current(); + cOsdMenu::Del(currentIndex); // remove items that have less than 2 duplicates int d = 0; for (int i = Count() - 1; i >= 0; i--) { @@ -504,6 +509,7 @@ eOSState cMenuDuplicates::Delete(void) { } else d++; } + SetCurrentIndex(currentIndex); SetHelpKeys(); Display(); } else @@ -37,6 +37,7 @@ private: int helpKeys; void SetHelpKeys(void); void Set(bool Refresh = false); + void SetCurrentIndex(int index); eOSState Play(void); eOSState Setup(void); eOSState Delete(void); |