From 31a9886c4e8ba12606ce3276774b00731c419af1 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 7 Aug 2005 19:23:46 +0000 Subject: [PATCH] Directory list updates totals if programmes are deleted --- message.h | 1 + vrecordinglist.cc | 60 ++++++++++++++++++++++++++++++++++++++--------- vrecordinglist.h | 5 +++- vwelcome.cc | 2 +- 4 files changed, 55 insertions(+), 13 deletions(-) diff --git a/message.h b/message.h index 1ce6c72..abd09a4 100644 --- a/message.h +++ b/message.h @@ -49,6 +49,7 @@ class Message const static ULONG STOP_PLAYBACK = 10; const static ULONG SERVER_SELECTED = 11; const static ULONG VDR_CONNECTED = 12; + const static ULONG REDRAW_DATA = 13; }; #endif diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 8dd20e4..3c6b0a0 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -20,8 +20,11 @@ #include "vrecordinglist.h" -VRecordingList::VRecordingList() +VRecordingList::VRecordingList(VRecordingList* parent) { + myParent = parent; + dataInvalid = 0; + if (Video::getInstance()->getFormat() == Video::PAL) { setScreenPos(80, 70); @@ -50,6 +53,25 @@ VRecordingList::~VRecordingList() void VRecordingList::setDir(Directory* tdir) { recDir = tdir; + + drawData(); + + char title[300]; + if (!recDir->isRoot) + { + snprintf(title, 299, "Recordings - %s", recDir->name); + setTitleText(title); + } + else + { + setTitleText("Recordings"); + } +} + +void VRecordingList::drawData() +{ + sl.clear(); + int first = 1; char tempA[300]; // FIXME this is guesswork! @@ -64,6 +86,12 @@ void VRecordingList::setDir(Directory* tdir) recDir->dirList->reset(); while((dir = (Directory*)recDir->dirList->getCurrent())) { + if (dir->getNumRecordings() == 0) + { + recDir->dirList->remove(dir); + continue; + } + strcpy(spaces, " "); theNumberLength = snprintf(theNumber, 9, "%lu", dir->getNumRecordings()); @@ -75,6 +103,7 @@ void VRecordingList::setDir(Directory* tdir) dir->index = sl.addOption(tempA, first); first = 0; + recDir->dirList->next(); } @@ -96,20 +125,15 @@ void VRecordingList::setDir(Directory* tdir) recList->next(); } - if (!recDir->isRoot) - { - snprintf(tempA, 299, "Recordings - %s", recDir->name); - setTitleText(tempA); - } - else - { - setTitleText("Recordings"); - } + dataInvalid = 0; } void VRecordingList::draw() { View::draw(); + + if (dataInvalid) drawData(); + sl.draw(); // Put the status stuff at the bottom @@ -184,6 +208,12 @@ void VRecordingList::processMessage(Message* m) doResume(); return; } + + if (m->message == Message::REDRAW_DATA) + { + dataInvalid = 1; + return; + } } void VRecordingList::doDeleteSelected() @@ -213,6 +243,14 @@ void VRecordingList::doDeleteSelected() draw(); } + if (myParent) // if this is not root send a message to parent to say redraw data + { + Message* m1 = new Message(); + m1->to = myParent; + m1->message = Message::REDRAW_DATA; + ViewMan::getInstance()->postMessage(m1); + } + Message* m2 = new Message(); m2->from = this; m2->to = ViewMan::getInstance(); @@ -316,7 +354,7 @@ int VRecordingList::handleCommand(int command) { if (curDir->index == sl.getCurrentOption()) { - VRecordingList* sub = new VRecordingList(); + VRecordingList* sub = new VRecordingList(this); sub->setDir(curDir); ViewMan::getInstance()->addNoLock(sub); diff --git a/vrecordinglist.h b/vrecordinglist.h index c13468b..8e932ac 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -41,19 +41,22 @@ class VRecordingList : public View { public: - VRecordingList(); + VRecordingList(VRecordingList* parent); ~VRecordingList(); void setDir(Directory* dir); + void drawData(); int handleCommand(int command); void processMessage(Message* m); void draw(); private: + VRecordingList* myParent; Directory* recDir; WSelectList sl; + int dataInvalid; void doShowingBar(); void doDeleteSelected(); diff --git a/vwelcome.cc b/vwelcome.cc index 8881035..1e840de 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -229,7 +229,7 @@ void VWelcome::doRecordingsList() if (recDir) { - VRecordingList* vrec = new VRecordingList(); + VRecordingList* vrec = new VRecordingList(NULL); vrec->setDir(recDir); ViewMan::getInstance()->addNoLock(vrec); -- 2.39.5