]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Directory list updates totals if programmes are deleted
authorChris Tallon <chris@vomp.tv>
Sun, 7 Aug 2005 19:23:46 +0000 (19:23 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 7 Aug 2005 19:23:46 +0000 (19:23 +0000)
message.h
vrecordinglist.cc
vrecordinglist.h
vwelcome.cc

index 1ce6c72c61b0549251d67b27f7804138cf3e3012..abd09a43e7e8e074a4c4b83d52e892bd5d5c6ef5 100644 (file)
--- 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
index 8dd20e40cc6f87c48a137023a946985a5315ac48..3c6b0a0e95c57bec73dee8ffe262aaaa01915feb 100644 (file)
 
 #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);
 
index c13468bc32f2fe00ad04e519f48104ab72f1ac28..8e932acca8d5ddba4d0bee687e9f9c6dacbc734d 100644 (file)
 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();
index 8881035c64fe7ccc17a026c7e6ac4104a7d9e165..1e840defadc9a98214d645d50cd2c6c27094269d 100644 (file)
@@ -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);