Go to the documentation of this file.
56 #define LOC QString("RestoreData: ")
63 setLabel(QObject::tr(
"Restore XMLTV ID"));
66 "If checked, copy the XMLTV ID in field \"xmltvid\" "
67 "from a deleted channel "
68 "or from a channel in another video source."));
78 setLabel(QObject::tr(
"Restore Visible status"));
81 "If checked, copy the Visible status in field \"visible\" "
82 "from a deleted channel in this video source."));
92 setLabel(QObject::tr(
"Restore Icon filename"));
95 "If checked, copy the Icon filename in field \"icon\" "
96 "from a deleted channel "
97 "or from a channel in another video source."));
129 m_sourceid(sourceid), m_useGUI(useGUI)
138 "The video source is selected in the Channel Editor page. "
139 "Searching for non-scanned data is done for all channels in this video source."
153 newTransport->setHelpText(
155 "Start searching for non-scanned data. The data is written to the database "
156 "when \'Save and Exit\' is selected in the \'Exit Settings?\' dialog box."
169 doRestore(do_xmltvid, do_icon, do_visible);
174 if (do_xmltvid || do_icon || do_visible)
176 QString msg = QString(
"Restore data from deleted channels for fields ");
189 LOG(VB_GENERAL, LOG_INFO,
LOC + msg);
200 "SELECT chanid, channum, name, serviceid, transportid, networkid, "
204 "FROM channel, dtv_multiplex "
205 "WHERE channel.sourceid = :SOURCEID "
206 " AND channel.mplexid = dtv_multiplex.mplexid "
207 " AND deleted IS NULL ");
227 bool nullNetwork = query.
isNull(5);
232 QString networkCheck;
234 networkCheck =
" networkid IS NULL";
236 networkCheck =
" networkid = :NETWORKID ";
241 if (do_xmltvid && cd.
xmltvid.isEmpty())
245 "FROM channel, dtv_multiplex "
246 "WHERE serviceid = :SERVICEID "
247 " AND transportid = :TRANSPORTID "
248 " AND " + networkCheck +
249 " AND channel.mplexid = dtv_multiplex.mplexid "
251 " AND (deleted IS NOT NULL OR "
252 " channel.sourceid != :SOURCEID)"
253 "ORDER BY deleted DESC;");
274 if (do_icon && cd.
icon.isEmpty())
278 "FROM channel, dtv_multiplex "
279 "WHERE serviceid = :SERVICEID "
280 " AND transportid = :TRANSPORTID "
281 " AND channel.mplexid = dtv_multiplex.mplexid "
283 " AND (deleted IS NOT NULL OR "
284 " channel.sourceid != :SOURCEID)"
285 "ORDER BY deleted DESC;");
308 "SELECT channel.visible "
309 "FROM channel, dtv_multiplex "
310 "WHERE serviceid = :SERVICEID "
311 " AND transportid = :TRANSPORTID "
312 " AND " + networkCheck +
313 " AND channel.sourceid = :SOURCEID "
314 " AND channel.mplexid = dtv_multiplex.mplexid "
315 " AND deleted IS NOT NULL "
316 "ORDER BY deleted DESC;");
329 int visible = query2.
value(0).toInt();
347 LOG(VB_GENERAL, LOG_INFO,
LOC +
"No data found in deleted channels or no data needed");
351 LOG(VB_GENERAL, LOG_INFO,
LOC +
352 QString(
"Restoring data in %1 channels from deleted channels:")
360 for (
auto & cd :
m_ocd)
362 QString msg = QString(
"Channel %1 \'%2\' update ").arg(cd.channum, cd.name);
363 if (cd.found_xmltvid)
365 msg += QString(
"xmltvid(%1) ").arg(cd.xmltvid);
370 msg += QString(
"icon(%1) ").arg(cd.icon);
373 if (cd.found_visible)
375 msg += QString(
"visible(%1) ").arg(cd.visible);
378 LOG(VB_GENERAL, LOG_INFO,
LOC + msg);
387 msg =
"No data found";
391 msg = QString(
"Found data for %1 channels\n").arg(
m_ocd.size());
428 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"No data to Restore"));
432 for (
auto & cd :
m_ocd)
437 " xmltvid = :XMLTVID, "
438 " visible = :VISIBLE "
439 "WHERE chanid = :CHANID");
450 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Restored data for %1 channels").arg(
m_ocd.size()));
bool isActive(void) const
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
bool WaitFor(MythConfirmationDialog *dialog)
Blocks until confirmation dialog exits.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
static RestoreData * s_Instance
VideoSourceShow * m_videosource
bool isNull(int field) const
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
std::vector< OldChannelData > m_ocd
QString doRestore(bool do_xmltvid, bool do_icon, bool do_visible)
virtual void addChild(StandardSetting *child)
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
virtual void setHelpText(const QString &str)
RestoreXMLTVID * m_restoreXMLTVID
RestoreVisible * m_restoreVisible
virtual void setLabel(QString str)
RestoreData(uint sourceid, bool useGUI=true)
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
RestoreIcon * m_restoreIcon
static RestoreData * getInstance(uint sourceid)
static void freeInstance()
void setValue(const QString &newValue) override
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.