MythTV  master
channelimporter.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 /*
3  * Copyright (C) Daniel Kristjansson 2007
4  *
5  * This file is licensed under GPL v2 or (at your option) any later version.
6  *
7  */
8 
9 #ifndef _CHANNEL_IMPORTER_H_
10 #define _CHANNEL_IMPORTER_H_
11 
12 // C++ headers
13 #include <cstring>
14 
15 // Qt headers
16 #include <QMap>
17 #include <QString>
18 #include <QCoreApplication>
19 
20 // MythTV headers
21 #include "mythtvexp.h"
22 #include "scaninfo.h"
23 #include "channelscantypes.h"
24 #include "mythmainwindow.h"
25 
28  kOCTCancel = +0,
29  kOCTOk = +1,
30  kOCTOkAll = +2,
31 };
32 
34 {
35  public:
37  {
38  memset(m_atsc_channels, 0, sizeof(m_atsc_channels));
39  memset(m_dvb_channels, 0, sizeof(m_dvb_channels));
40  memset(m_scte_channels, 0, sizeof(m_scte_channels));
41  memset(m_mpeg_channels, 0, sizeof(m_mpeg_channels));
42  memset(m_ntsc_channels, 0, sizeof(m_ntsc_channels));
43  }
44 
45  // totals
51 
52  // per channel counts
53  QMap<uint,uint> m_prognum_cnt;
54  QMap<uint,uint> m_atscnum_cnt;
55  QMap<uint,uint> m_atscmin_cnt;
56  QMap<uint,uint> m_atscmaj_cnt;
57  QMap<QString,uint> m_channum_cnt;
58 };
59 
61 {
62  public:
64 
71 };
72 
74 {
75  Q_DECLARE_TR_FUNCTIONS(ChannelImporter)
76 
77  public:
78  ChannelImporter(bool gui, bool interactive,
79  bool _delete, bool insert, bool save,
80  bool fta_only, bool lcn_only, bool complete_only,
81  bool full_channel_search,
82  ServiceRequirements service_requirements,
83  bool success = false) :
84  m_use_gui(gui),
85  m_is_interactive(interactive),
86  m_do_delete(_delete),
87  m_do_insert(insert),
88  m_do_save(save),
89  m_fta_only(fta_only),
90  m_lcn_only(lcn_only),
91  m_complete_only(complete_only),
92  m_full_channel_search(full_channel_search),
93  m_success(success),
94  m_service_requirements(service_requirements) { }
95 
96  void Process(const ScanDTVTransportList&, int sourceid = -1);
97 
98  protected:
100  {
105  };
107  {
111  };
113  {
117  };
118 
120  {
121  kChannelTypeFirst = 0,
122 
123  kChannelTypeNonConflictingFirst = kChannelTypeFirst,
124  kATSCNonConflicting = kChannelTypeFirst,
129  kChannelTypeNonConflictingLast = kNTSCNonConflicting,
130 
132  kATSCConflicting = kChannelTypeConflictingFirst,
137  kChannelTypeConflictingLast = kNTSCConflicting,
138  kChannelTypeLast = kChannelTypeConflictingLast,
139  };
140 
141  static QString toString(ChannelType type);
142 
143  static void CleanupDuplicates(ScanDTVTransportList &transports);
144  void FilterServices(ScanDTVTransportList &transports) const;
145  ScanDTVTransportList GetDBTransports(
146  uint sourceid, ScanDTVTransportList&) const;
147 
148  uint DeleteChannels(ScanDTVTransportList&);
149  uint DeleteUnusedTransports(uint sourceid);
150 
151  void InsertChannels(const ScanDTVTransportList&,
153 
154  ScanDTVTransportList InsertChannels(
155  const ScanDTVTransportList &transports,
156  const ChannelImporterBasicStats &info,
157  InsertAction action,
158  ChannelType type,
159  ScanDTVTransportList &inserted,
160  ScanDTVTransportList &skipped);
161 
162  ScanDTVTransportList UpdateChannels(
163  const ScanDTVTransportList &transports,
164  const ChannelImporterBasicStats &info,
165  UpdateAction action,
166  ChannelType type,
167  ScanDTVTransportList &updated,
168  ScanDTVTransportList &skipped);
169 
171  DeleteAction QueryUserDelete(const QString &msg);
172 
174  InsertAction QueryUserInsert(const QString &msg);
175 
177  UpdateAction QueryUserUpdate(const QString &msg);
178 
180  OkCancelType QueryUserResolve(
181  const ScanDTVTransport &transport,
182  ChannelInsertInfo &chan);
183 
185  OkCancelType QueryUserInsert(
186  const ScanDTVTransport &transport,
187  ChannelInsertInfo &chan);
188 
189  static QString ComputeSuggestedChannelNum(
190  const ChannelInsertInfo &chan);
191 
192  OkCancelType ShowManualChannelPopup(
193  MythMainWindow *parent, const QString& title,
194  const QString& message, QString &text);
195 
196  OkCancelType ShowResolveChannelPopup(
197  MythMainWindow *parent, const QString& title,
198  const QString& message, QString &text);
199 
200  static void FixUpOpenCable(ScanDTVTransportList &transports);
201 
202  static ChannelImporterBasicStats CollectStats(
203  const ScanDTVTransportList &transports);
204 
205  static ChannelImporterUniquenessStats CollectUniquenessStats(
206  const ScanDTVTransportList &transports,
207  const ChannelImporterBasicStats &info);
208 
209  static QString FormatChannels(
210  const ScanDTVTransportList &transports,
211  const ChannelImporterBasicStats *info = nullptr);
212 
213  static QString FormatChannel(
214  const ScanDTVTransport &transport,
215  const ChannelInsertInfo &chan,
216  const ChannelImporterBasicStats *info = nullptr);
217 
218  static QString SimpleFormatChannel(
219  const ScanDTVTransport &transport,
220  const ChannelInsertInfo &chan);
221 
222  static QString FormatTransport(
223  const ScanDTVTransport &transport);
224 
225  static QString FormatTransports(
226  const ScanDTVTransportList &transports_in);
227 
228  static QString GetSummary(
229  uint transport_count,
230  const ChannelImporterBasicStats &info,
231  const ChannelImporterUniquenessStats &stats);
232 
233  static bool IsType(
234  const ChannelImporterBasicStats &info,
235  const ChannelInsertInfo &chan, ChannelType type);
236 
237  static void CountChannels(
238  const ScanDTVTransportList &transports,
239  const ChannelImporterBasicStats &info,
240  ChannelType type, uint &new_chan, uint &old_chan);
241 
242  static int SimpleCountChannels(
243  const ScanDTVTransportList &transports);
244 
245  static bool CheckChannelNumber(
246  const QString &num,
247  const ChannelInsertInfo &chan);
248 
249  static void AddChanToCopy(
250  ScanDTVTransport &transport_copy,
251  const ScanDTVTransport &transport,
252  const ChannelInsertInfo &chan);
253 
254  private:
255  bool m_use_gui;
259  bool m_do_save;
267  bool m_keep_channel_numbers {true};
269  bool m_full_channel_search {false};
271  bool m_success {false};
274 
275  QEventLoop m_eventLoop;
276 };
277 
278 #endif // _CHANNEL_IMPORTER_H_
QMap< QString, uint > m_channum_cnt
QString toString(MarkTypes type)
bool m_fta_only
Only FreeToAir (non-encrypted) channels desired post scan?
ServiceRequirements m_service_requirements
Services desired post scan.
QMap< uint, uint > m_prognum_cnt
QMap< uint, uint > m_atscmaj_cnt
QMap< uint, uint > m_atscmin_cnt
#define MTV_PUBLIC
Definition: mythtvexp.h:15
unsigned int uint
Definition: compat.h:140
bool m_lcn_only
Only services with logical channel numbers desired post scan?
OkCancelType
ServiceRequirements
bool m_complete_only
Only services with complete scandata desired post scan?
ChannelImporter(bool gui, bool interactive, bool _delete, bool insert, bool save, bool fta_only, bool lcn_only, bool complete_only, bool full_channel_search, ServiceRequirements service_requirements, bool success=false)
vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:141
QMap< uint, uint > m_atscnum_cnt
QEventLoop m_eventLoop