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 
26 typedef enum {
28  kOCTCancel = +0,
29  kOCTOk = +1,
30  kOCTOkAll = +2,
31 } OkCancelType;
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  ServiceRequirements service_requirements,
82  bool success = false) :
83  m_use_gui(gui),
84  m_is_interactive(interactive),
85  m_do_delete(_delete),
86  m_do_insert(insert),
87  m_do_save(save),
88  m_fta_only(fta_only),
89  m_lcn_only(lcn_only),
90  m_complete_only(complete_only),
91  m_success(success),
92  m_service_requirements(service_requirements) { }
93 
94  void Process(const ScanDTVTransportList&, int sourceid = -1);
95 
96  protected:
97  typedef enum
98  {
103  } DeleteAction;
104  typedef enum
105  {
109  } InsertAction;
110  typedef enum
111  {
115  } UpdateAction;
116 
117  typedef enum
118  {
119  kChannelTypeFirst = 0,
120 
121  kChannelTypeNonConflictingFirst = kChannelTypeFirst,
122  kATSCNonConflicting = kChannelTypeFirst,
127  kChannelTypeNonConflictingLast = kNTSCNonConflicting,
128 
130  kATSCConflicting = kChannelTypeConflictingFirst,
135  kChannelTypeConflictingLast = kNTSCConflicting,
136  kChannelTypeLast = kChannelTypeConflictingLast,
137  } ChannelType;
138 
139  QString toString(ChannelType type);
140 
141  void CleanupDuplicates(ScanDTVTransportList &transports) const;
142  void FilterServices(ScanDTVTransportList &transports) const;
143  ScanDTVTransportList GetDBTransports(
144  uint sourceid, ScanDTVTransportList&) const;
145 
146  uint DeleteChannels(ScanDTVTransportList&);
147  uint DeleteUnusedTransports(uint sourceid);
148 
149  void InsertChannels(const ScanDTVTransportList&,
151 
152  ScanDTVTransportList InsertChannels(
153  const ScanDTVTransportList &transports,
154  const ChannelImporterBasicStats &info,
155  InsertAction action,
156  ChannelType type,
157  ScanDTVTransportList &inserted,
158  ScanDTVTransportList &skipped);
159 
160  ScanDTVTransportList UpdateChannels(
161  const ScanDTVTransportList &transports,
162  const ChannelImporterBasicStats &info,
163  UpdateAction action,
164  ChannelType type,
165  ScanDTVTransportList &updated,
166  ScanDTVTransportList &skipped);
167 
169  DeleteAction QueryUserDelete(const QString &msg);
170 
172  InsertAction QueryUserInsert(const QString &msg);
173 
175  UpdateAction QueryUserUpdate(const QString &msg);
176 
178  OkCancelType QueryUserResolve(
179  const ChannelImporterBasicStats &info,
180  const ScanDTVTransport &transport,
181  ChannelInsertInfo &chan);
182 
184  OkCancelType QueryUserInsert(
185  const ChannelImporterBasicStats &info,
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 GetSummary(
223  uint transport_count,
224  const ChannelImporterBasicStats &info,
225  const ChannelImporterUniquenessStats &stats);
226 
227  static bool IsType(
228  const ChannelImporterBasicStats &info,
229  const ChannelInsertInfo &chan, ChannelType type);
230 
231  static void CountChannels(
232  const ScanDTVTransportList &transports,
233  const ChannelImporterBasicStats &info,
234  ChannelType type, uint &new_chan, uint &old_chan);
235 
236  static int SimpleCountChannels(
237  const ScanDTVTransportList &transports);
238 
239  static bool CheckChannelNumber(
240  const QString &num,
241  const ChannelInsertInfo &chan);
242 
243  static void AddChanToCopy(
244  ScanDTVTransport &transport_copy,
245  const ScanDTVTransport &transport,
246  const ChannelInsertInfo &chan);
247 
248  private:
249  bool m_use_gui;
253  bool m_do_save;
261  bool m_keep_channel_numbers {true};
263  bool m_success {false};
266 
267  QEventLoop m_eventLoop;
268 };
269 
270 #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
vector< ScanDTVTransport > ScanDTVTransportList
Definition: dtvmultiplex.h:141
unsigned int uint
Definition: compat.h:140
QMap< uint, uint > m_atscmaj_cnt
QMap< uint, uint > m_atscmin_cnt
#define MTV_PUBLIC
Definition: mythtvexp.h:15
ChannelImporter(bool gui, bool interactive, bool _delete, bool insert, bool save, bool fta_only, bool lcn_only, bool complete_only, ServiceRequirements service_requirements, bool success=false)
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?
QMap< uint, uint > m_atscnum_cnt
QEventLoop m_eventLoop