88
103
QString msg = GetSummary(transports.size(), info, stats);
89
104
cout << msg.toAscii().constData() << endl << endl;
94
MythPopupBox::showOkPopup(
95
gContext->GetMainWindow(), QObject::tr("Channel Importer"), msg);
101
107
InsertChannels(transports, info);
109
if (do_delete && sourceid)
110
DeleteUnusedTransports(sourceid);
112
if (do_delete || do_insert)
102
113
ScanInfo::MarkProcessed(saved_scan);
106
116
QString ChannelImporter::toString(ChannelType type)
123
133
return "Unknown";
136
uint ChannelImporter::DeleteChannels(
137
ScanDTVTransportList &transports)
139
vector<uint> off_air_list;
140
QMap<uint,bool> deleted;
142
for (uint i = 0; i < transports.size(); i++)
144
for (uint j = 0; j < transports[i].channels.size(); j++)
146
ChannelInsertInfo chan = transports[i].channels[j];
147
bool was_in_db = chan.db_mplexid && chan.channel_id;
152
off_air_list.push_back(i<<16|j);
156
ScanDTVTransportList newlist;
157
if (off_air_list.empty())
162
// ask user whether to delete all or some of these stale channels
163
// if some is selected ask about each individually
164
QString msg = QObject::tr(
165
"Found %1 off-air channels.").arg(off_air_list.size());
166
DeleteAction action = QueryUserDelete(msg);
167
if (kDeleteIgnoreAll == action)
170
if (kDeleteAll == action)
172
for (uint k = 0; k < off_air_list.size(); k++)
174
int i = off_air_list[k] >> 16, j = off_air_list[k] & 0xFFFF;
175
ChannelUtil::DeleteChannel(
176
transports[i].channels[j].channel_id);
177
deleted[off_air_list[k]] = true;
180
else if (kDeleteInvisibleAll == action)
182
for (uint k = 0; k < off_air_list.size(); k++)
184
int i = off_air_list[k] >> 16, j = off_air_list[k] & 0xFFFF;
185
ChannelUtil::SetVisible(
186
transports[i].channels[j].channel_id, false);
191
// TODO manual delete
194
// TODO delete encrypted channels when m_fta_only set
196
if (deleted.size() == 0)
199
// Create a new transports list without the deleted channels
200
for (uint i = 0; i < transports.size(); i++)
202
newlist.push_back(transports[i]);
203
newlist.back().channels.clear();
204
for (uint j = 0; j < transports[i].channels.size(); j++)
206
if (!deleted.contains(i<<16|j))
208
newlist.back().channels.push_back(
209
transports[i].channels[j]);
214
// TODO print list of stale channels (as deleted if action approved).
216
transports = newlist;
217
return deleted.size();
220
uint ChannelImporter::DeleteUnusedTransports(uint sourceid)
222
MSqlQuery query(MSqlQuery::InitCon());
224
"SELECT mplexid FROM dtv_multiplex "
225
"WHERE sourceid = :SOURCEID1 AND "
229
" WHERE sourceid = :SOURCEID2)");
230
query.bindValue(":SOURCEID1", sourceid);
231
query.bindValue(":SOURCEID2", sourceid);
234
MythDB::DBError("DeleteUnusedTransports() -- select", query);
238
VERBOSE(VB_IMPORTANT,
239
QObject::tr("Found %1 unused transports.").arg(query.size()));
241
if (query.size() == 0)
244
QString msg = QObject::tr("Found %1 unused transports.").arg(query.size());
245
DeleteAction action = QueryUserDelete(msg);
246
if (kDeleteIgnoreAll == action)
249
if (kDeleteAll == action)
252
"DELETE FROM dtv_multiplex "
253
"WHERE sourceid = :SOURCEID1 AND "
257
" WHERE sourceid = :SOURCEID2)");
258
query.bindValue(":SOURCEID1", sourceid);
259
query.bindValue(":SOURCEID2", sourceid);
262
MythDB::DBError("DeleteUnusedTransports() -- delete", query);
268
// TODO manual delete
126
273
void ChannelImporter::InsertChannels(
127
274
const ScanDTVTransportList &transports,
128
275
const ChannelImporterBasicStats &info)
208
// if scan was not aborted prematurely
209
// ask user whether to delete all or some of these stale channels
210
// if some is selected ask about each individually
211
// ask user whether to delete all or some of these stale transports
212
// if some is selected ask about each individually
214
355
// print list of inserted channels
215
356
// print list of ignored channels (by ignored reason category)
216
357
// print list of invalid channels
217
// print list of stale channels (as deleted if action approved).
220
360
ScanDTVTransportList ChannelImporter::InsertChannels(
1012
1154
return chan_num;
1157
ChannelImporter::DeleteAction
1158
ChannelImporter::QueryUserDelete(const QString &msg)
1160
DeleteAction action = kDeleteAll;
1163
QStringList buttons;
1164
buttons.push_back(QObject::tr("Delete all"));
1165
buttons.push_back(QObject::tr("Set all invisible"));
1166
// buttons.push_back(QObject::tr("Handle manually"));
1167
buttons.push_back(QObject::tr("Ignore all"));
1172
ret = MythPopupBox::ShowButtonPopup(
1173
gContext->GetMainWindow(), QObject::tr("Channel Importer"),
1174
msg, buttons, kDialogCodeButton0);
1176
ret = (kDialogCodeRejected == ret) ? kDialogCodeButton2 : ret;
1178
} while (!(kDialogCodeButton0 <= ret && ret <= kDialogCodeButton3));
1180
action = (kDialogCodeButton0 == ret) ? kDeleteAll : action;
1181
action = (kDialogCodeButton1 == ret) ? kDeleteInvisibleAll : action;
1182
action = (kDialogCodeButton2 == ret) ? kDeleteIgnoreAll : action;
1183
// action = (kDialogCodeButton2 == ret) ? kDeleteManual : action;
1184
// action = (kDialogCodeButton3 == ret) ? kDeleteIgnoreAll : action;
1186
else if (is_interactive)
1188
cout << msg.toAscii().constData() << endl;
1189
cout << "Do you want to:" << endl;
1190
cout << "1. Delete all" << endl;
1191
cout << "2. Set all invisible" << endl;
1192
// cout << "3. Handle manually" << endl;
1193
cout << "4. Ignore all" << endl;
1199
uint val = QString(ret.c_str()).toUInt(&ok);
1200
if (ok && (1 <= val) && (val <= 3))
1202
action = (1 == val) ? kDeleteAll : action;
1203
action = (2 == val) ? kDeleteInvisibleAll : action;
1204
//action = (3 == val) ? kDeleteManual : action;
1205
action = (3 == val) ? kDeleteIgnoreAll : action;
1206
action = (4 == val) ? kDeleteIgnoreAll : action;
1211
//cout << "Please enter either 1, 2, 3 or 4:" << endl;
1212
cout << "Please enter either 1, 2 or 4:" << endl;//
1015
1220
ChannelImporter::InsertAction
1016
1221
ChannelImporter::QueryUserInsert(const QString &msg)