All pastes #1681881 Raw Edit

Miscellany

public text v1 · immutable
#1681881 ·published 2009-11-22 04:51 UTC
rendered paste body
Index: libs/libmyth/programinfo.h
===================================================================
--- libs/libmyth/programinfo.h	(revision 22880)
+++ libs/libmyth/programinfo.h	(working copy)
@@ -378,6 +378,8 @@
   protected:
     // Creates a basename from the start and end times
     QString CreateRecordBasename(const QString &ext) const;
+    /// Sends event out that the ProgramInfo should be reloaded.
+    void Update(void) const;
 
   public:
     // data
Index: libs/libmyth/programinfo.cpp
===================================================================
--- libs/libmyth/programinfo.cpp	(revision 22880)
+++ libs/libmyth/programinfo.cpp	(working copy)
@@ -1551,6 +1551,7 @@
         return false;
     }
 
+    Update();
     return true;
 }
 
@@ -1672,6 +1673,8 @@
 
     if (!query.exec() || !query.isActive())
         MythDB::DBError("File size update", query);
+
+    Update();
 }
 
 /** \fn ProgramInfo::GetFilesize(void)
@@ -1752,8 +1755,18 @@
         if (!query.exec() || !query.isActive())
             MythDB::DBError("bookmark flag update", query);
     }
+
+    Update();
 }
 
+void ProgramInfo::Update(void) const
+{
+    QStringList list;
+    ToStringList(list);
+    MythEvent me(QString("UPDATE_PROG_INFO"), list);
+    gContext->dispatch(me);
+}
+
 /** \fn ProgramInfo::GetBookmark(void) const
  *  \brief Gets any bookmark position in database,
  *         unless "ignoreBookmark" is set.
@@ -1856,6 +1869,8 @@
 
     if (!query.exec() || !query.isActive())
         MythDB::DBError("SetDVDBookmark updating", query);
+
+    Update();
 }
 /** \fn ProgramInfo::SetWatchedFlag(bool) const
  *  \brief Set "watched" field in recorded/videometadata to "watchedFlag".
@@ -1915,6 +1930,8 @@
         if (!query.exec() || !query.isActive())
             MythDB::DBError("Set watched flag", query);
     }
+
+    Update();
 }
 
 /** \fn ProgramInfo::IsEditing(void) const
@@ -1958,6 +1975,8 @@
 
     if (!query.exec() || !query.isActive())
         MythDB::DBError("Edit status update", query);
+
+    Update();
 }
 
 /** \fn ProgramInfo::SetDeleteFlag(bool) const
@@ -1982,6 +2001,8 @@
 
     if (!query.exec() || !query.isActive())
         MythDB::DBError("Set delete flag", query);
+
+    Update();
 }
 
 /** \fn ProgramInfo::IsCommFlagged(void) const
@@ -2097,6 +2118,8 @@
 
     if(!query.exec() || !query.isActive())
         MythDB::DBError("Transcoded status update", query);
+
+    Update();
 }
 
 /** \fn ProgramInfo::SetCommFlagged(int) const
@@ -2117,6 +2140,8 @@
 
     if (!query.exec() || !query.isActive())
         MythDB::DBError("Commercial Flagged status update", query);
+
+    Update();
 }
 
 /** \fn ProgramInfo::SetPreserveEpisode(bool) const
@@ -2139,6 +2164,8 @@
         MythDB::DBError("PreserveEpisode update", query);
     else
         UpdateLastDelete(false);
+
+    Update();
 }
 
 /**
@@ -2161,6 +2188,8 @@
         MythDB::DBError("AutoExpire update", query);
     else if (updateDelete)
         UpdateLastDelete(true);
+
+    Update();
 }
 
 /** \fn ProgramInfo::UpdateLastDelete(bool) const
@@ -2287,6 +2316,8 @@
         if (!query.exec() || !query.isActive())
             MythDB::DBError("cutlist flag update", query);
     }
+
+    Update();
 }
 
 void ProgramInfo::SetCommBreakList(frm_dir_map_t &frames) const
@@ -3430,6 +3461,8 @@
     {
         recgroup = query.value(0).toString();
     }
+
+    Update();
 }
 
 void ProgramInfo::MarkAsInUse(bool inuse, QString usedFor)
Index: programs/mythfrontend/playbackbox.cpp
===================================================================
--- programs/mythfrontend/playbackbox.cpp	(revision 22880)
+++ programs/mythfrontend/playbackbox.cpp	(working copy)
@@ -3715,6 +3715,44 @@
             if (evinfo.FromStringList(me->ExtraDataList(), 0))
                 HandlePreviewEvent(evinfo);
         }
+        else if (message == "UPDATE_PROG_INFO")
+        {
+            ProgramInfo evinfo;
+            if (evinfo.FromStringList(me->ExtraDataList(), 0))
+            {
+                QMutexLocker locker(&m_progCacheLock);
+
+                ProgramInfo *dst = NULL;
+                if (m_progCache)
+                {
+                    vector<ProgramInfo *>::iterator it = m_progCache->begin();
+                    for ( ; it != m_progCache->end(); ++it)
+                    {
+                        if ((evinfo.chanid == (*it)->chanid) &&
+                            (evinfo.recstartts == (*it)->recstartts))
+                        {
+                            dst = *it;
+                            *dst = evinfo;
+                            break;
+                        }
+                    }
+                }
+
+                MythUIButtonListItem *item = NULL;
+                if (dst)
+                {
+                    item = m_recordingList->GetItemByData(
+                        qVariantFromValue(dst));
+                }
+
+                if (item)
+                {
+                    MythUIButtonListItem *sel_item =
+                        m_recordingList->GetItemCurrent();
+                    UpdateProgramInfo(item, item == sel_item, true);
+                }
+            }
+        }
     }
     else
         ScheduleCommon::customEvent(event);