MythTV  master
mythutil.cpp
Go to the documentation of this file.
1 // Qt includes
2 #include <QDateTime>
3 #include <QString>
4 
5 // libmyth* includes
6 #include "mythlogging.h"
7 
8 // Local includes
9 #include "mythutil.h"
10 
12  ProgramInfo &pginfo)
13 {
14  if (cmdline.toBool("video"))
15  {
16  QString video = cmdline.toString("video");
17  pginfo = ProgramInfo(video);
18  return true;
19  }
20  if (!cmdline.toBool("chanid"))
21  {
22  LOG(VB_GENERAL, LOG_ERR, "No chanid specified");
23  return false;
24  }
25 
26  if (!cmdline.toBool("starttime"))
27  {
28  LOG(VB_GENERAL, LOG_ERR, "No start time specified");
29  return false;
30  }
31 
32  uint chanid = cmdline.toUInt("chanid");
33  QDateTime starttime = cmdline.toDateTime("starttime");
34  QString startstring = starttime.toString("yyyyMMddhhmmss");
35 
36  const ProgramInfo tmpInfo(chanid, starttime);
37 
38  if (!tmpInfo.GetChanID())
39  {
40  LOG(VB_GENERAL, LOG_ERR,
41  QString("No program data exists for channel %1 at %2")
42  .arg(chanid).arg(startstring));
43  return false;
44  }
45 
46  pginfo = tmpInfo;
47 
48  return true;
49 }
50 
51 /* vim: set expandtab tabstop=4 shiftwidth=4: */
QDateTime toDateTime(const QString &key) const
Returns stored QVariant as a QDateTime, falling to default if not provided.
bool GetProgramInfo(const MythUtilCommandLineParser &cmdline, ProgramInfo &pginfo)
Definition: mythutil.cpp:11
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
unsigned int uint
Definition: compat.h:140
Holds information on recordings and videos.
Definition: programinfo.h:66
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
MythCommFlagCommandLineParser cmdline
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:364
uint toUInt(const QString &key) const
Returns stored QVariant as an unsigned integer, falling to default if not provided.