Go to the documentation of this file.
11 #include <QCoreApplication>
26 using VPI_ptr = std::vector<ProgramInfo *> *;
44 void run(
void)
override
55 QMutexLocker locker(&
m_lock);
66 QMutexLocker locker(&
m_lock);
78 QMutexLocker locker(&
m_lock);
91 using ProgId = QPair<uint, QDateTime>;
92 QHash<ProgId, uint> lastPlayFrames;
96 query.
prepare(
"SELECT chanid, starttime, mark "
97 "FROM recordedmarkup "
98 "WHERE type = :TYPE ");
105 ProgId
id = qMakePair(query.
value(0).toUInt(),
107 lastPlayFrames[id] = query.
value(2).toUInt();
113 ProgId
id = qMakePair(pg->GetChanID(),
114 pg->GetRecordingStartTime());
115 pg->CalculateProgress(lastPlayFrames.value(
id));
130 QCoreApplication::postEvent(
139 QMutexLocker locker(&
m_lock);
145 QMutexLocker locker(&
m_lock);
162 QMutexLocker locker(&
m_lock);
168 if (!it->GetChanID())
171 m_cache[it->GetRecordingID()] = it;
180 if ((*it)->GetAvailableStatus() ==
asDeleted)
198 QMutexLocker locker(&
m_lock);
201 Cache::iterator it =
m_cache.find(recordingId);
215 pg.
clone(pginfo,
true);
221 recordingId, 0, flags);
227 LOG(VB_GUI, LOG_DEBUG, QString(
"Pg %1 %2 update state %3")
228 .arg(recordingId).arg(pg.
GetTitle()).arg(flags));
239 Cache::iterator it =
m_cache.find(recordingID);
257 if (pg->
QueryIsInUse(byWhom) && byWhom.contains(QObject::tr(
"Playing")))
265 QString mesg = QString(
"UPDATE_UI_ITEM %1 %2").arg(recordingID).arg(flags);
268 LOG(VB_GUI, LOG_DEBUG, mesg);
289 Cache::iterator it =
m_cache.find(recordingID);
292 (*it)->SetAvailableStatus(
asDeleted,
"PIC::Remove");
322 std::sort(list.begin(), list.end(),
PISort);
328 Cache::const_iterator it =
m_cache.find(recordingID);
339 for (
const auto & pi : std::as_const(
m_cache))
void Add(const ProgramInfo &pginfo)
Adds a ProgramInfo to the cache.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
void SetAvailableStatus(AvailableStatusType status, const QString &where)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
ProgramInfoLoader(ProgramInfoCache &c, const bool updateUI)
QDateTime as_utc(const QDateTime &old_dt)
Returns copy of QDateTime with TimeSpec set to UTC.
QDateTime m_previewUpdate
void GetOrdered(std::vector< ProgramInfo * > &list, bool newest_first=false)
uint GetRecordingID(void) const
virtual void clone(const ProgramInfo &other, bool ignore_non_serialized_data=false)
Copies important fields from other ProgramInfo.
This class is used as a container for messages.
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
QString GetRecordingGroup(void) const
friend class ProgramInfoLoader
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
MBASE_PUBLIC long long copy(QFile &dst, QFile &src, uint block_size=0)
Copies src file to dst file.
QString GetTitle(void) const
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
void ScheduleLoad(bool updateUI=true)
ProgramInfoCache::UpdateStates Update(const ProgramInfo &pginfo)
Updates a ProgramInfo in the cache.
ProgramInfo * GetRecordingInfo(uint recordingID) const
void Refresh(void)
Refreshed the cache.
static void free_vec(VPI_ptr &v)
void run(const QString &name, Class *object, void(Class::*fn)())
virtual void SetFilesize(uint64_t sz)
void CalculateProgress(uint64_t pos)
void WaitForLoadToComplete(void) const
bool IsLoadInProgress(void) const
void Load(bool updateUI=true)
ProgramInfoCache & m_cache
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Holds information on recordings and videos.
bool PISort(const ProgramInfo *a, const ProgramInfo *b)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
QWaitCondition m_loadWait
void UpdateFileSize(uint recordingID, uint64_t filesize, UpdateStates flags)
Updates a ProgramInfo in the cache.
bool Remove(uint recordingID)
Marks a ProgramInfo in the cache for deletion on the next call to Refresh().
std::vector< ProgramInfo * > * VPI_ptr
bool QueryIsInUse(QStringList &byWho) const
Returns true if Program is in use.
uint64_t QueryLastPlayPos(void) const
Gets any lastplaypos position in database, unless the ignore lastplaypos flag is set.
std::vector< ProgramInfo * > * RemoteGetRecordedList(int sort)
static MThreadPool * globalInstance(void)
bool reversePISort(const ProgramInfo *a, const ProgramInfo *b)
void Clear(void)
Clears the cache, m_lock must be held when this is called.
void start(QRunnable *runnable, const QString &debugName, int priority=0)
QDateTime GetBookmarkUpdate(void) const
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
std::vector< ProgramInfo * > * m_nextCache