MythTV  master
importicons.h
Go to the documentation of this file.
1 /* -*- Mode: c++ -*-
2  * vim: set expandtab tabstop=4 shiftwidth=4:
3  *
4  * Original Project
5  * MythTV http://www.mythtv.org
6  *
7  * Author(s):
8  * John Pullan, Matthew Wire
9  *
10  * Description:
11  */
12 
13 #ifndef IMPORTICONS_H
14 #define IMPORTICONS_H
15 
16 #include <QUrl>
17 #include <QDir>
18 
19 #include "mythscreentype.h"
20 
21 class MythUIButton;
22 class MythUIButtonList;
24 class MythUITextEdit;
25 class MythUIText;
27 
29 {
30  Q_OBJECT
31 
32  public:
33  ImportIconsWizard(MythScreenStack *parent, bool fRefresh,
34  QString channelname = "");
35  ~ImportIconsWizard() override;
36 
37  bool Create(void) override; // MythScreenType
38  void Load(void) override; // MythScreenType
39 // bool keyPressEvent(QKeyEvent *) override; // MythScreenType
40  void customEvent(QEvent *event) override; // MythUIType
41 
42  struct SearchEntry
43  {
44  QString strID;
45  QString strName;
46  QString strLogo;
47  };
48 
49  private:
50 
52  {
56  };
57 
58  struct CSVEntry
59  {
60  QString strChanId;
61  QString strName;
62  QString strXmlTvId;
63  QString strCallsign;
64  QString strTransportId;
65  QString strAtscMajorChan;
66  QString strAtscMinorChan;
67  QString strNetworkId;
68  QString strServiceId;
69  QString strIconCSV;
70  QString strNameCSV;
71  };
73  using ListEntries = QList<CSVEntry>;
75  using ListEntriesIter = QList<CSVEntry>::Iterator;
76 
81 
83  using ListSearchEntries = QList<SearchEntry>;
85  using ListSearchEntriesIter = QList<SearchEntry>::Iterator;
86 
91  static QString escape_csv(const QString& str);
92 
97  static QStringList extract_csv(const QString& strLine);
98 
104  static QString wget(QUrl& url,const QString& strParam);
105 
110  bool lookup(const QString& strParam);
111 
116  bool search(const QString& strParam);
117 
121  bool submit();
122 
127  bool findmissing(const QString& strParam);
128 
135  bool checkAndDownload(const QString& url, const QString& localChanId);
136 
140  bool initialLoad(const QString& name="");
141 
145  bool doLoad();
146 
147  protected slots:
149  void manualSearch();
151  void skip();
152  void askSubmit(const QString& strParam);
153  void Close() override; // MythScreenType
154 
155  private slots:
156  void itemChanged(MythUIButtonListItem *item);
157 
158  protected:
159  void Init(void) override; // MythScreenType
160 
161  private:
163  QString m_strMatches;
164 
165  QString m_strChannelDir;
167  QString m_strParam;
168 
169  bool m_fRefresh {false};
170  int m_nMaxCount {0};
171  int m_nCount {0};
173  int m_missingCount {0};
174 
176  const QString m_url {"http://services.mythtv.org/channel-icon/"};
177  QDir m_tmpDir;
178 
179  void startDialog();
180 
183 
186  MythUIText *m_nameText {nullptr};
190 
191  MythUIImage *m_preview {nullptr};
193 
194 };
195 
197 
198 #endif // IMPORTICONS_H
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(GrabberScript *)
ImportIconsWizard::CSVEntry::strCallsign
QString strCallsign
callsign
Definition: importicons.h:63
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:98
slots
std::array< unsigned int, 4 > slots
Definition: element.cpp:38
ImportIconsWizard::ListEntries
QList< CSVEntry > ListEntries
List of CSV entries.
Definition: importicons.h:73
ImportIconsWizard::SearchEntry::strName
QString strName
the remote name
Definition: importicons.h:45
ImportIconsWizard::itemChanged
void itemChanged(MythUIButtonListItem *item)
Definition: importicons.cpp:245
ImportIconsWizard::escape_csv
static QString escape_csv(const QString &str)
changes a string into csv format
Definition: importicons.cpp:488
ImportIconsWizard::m_popupStack
MythScreenStack * m_popupStack
Definition: importicons.h:181
ImportIconsWizard::CSVEntry::strNameCSV
QString strNameCSV
name (csv form)
Definition: importicons.h:70
ImportIconsWizard::m_strChannelname
QString m_strChannelname
the channel name if searching for a single channel icon
Definition: importicons.h:166
ImportIconsWizard::ListSearchEntries
QList< SearchEntry > ListSearchEntries
List of SearchEntry entries.
Definition: importicons.h:83
ImportIconsWizard::m_url
const QString m_url
Definition: importicons.h:176
MythScreenStack
Definition: mythscreenstack.h:16
ImportIconsWizard::m_missingCount
int m_missingCount
the current search point (0..m_missingCount)
Definition: importicons.h:173
ImportIconsWizard::doLoad
bool doLoad()
attempts to move the iteration on one/more than one
Definition: importicons.cpp:451
ImportIconsWizard::Create
bool Create(void) override
Definition: importicons.cpp:61
ImportIconsWizard::search
bool search(const QString &strParam)
search the remote db for icons etc
Definition: importicons.cpp:635
ImportIconsWizard::CSVEntry::strServiceId
QString strServiceId
service id
Definition: importicons.h:68
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:33
ImportIconsWizard::extract_csv
static QStringList extract_csv(const QString &strLine)
extracts the csv values out of a string
Definition: importicons.cpp:496
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
ImportIconsWizard::m_nCount
int m_nCount
the current search point (0..m_nMaxCount)
Definition: importicons.h:171
ImportIconsWizard::CSVEntry::strIconCSV
QString strIconCSV
icon name (csv form)
Definition: importicons.h:69
ImportIconsWizard::m_manualButton
MythUIButton * m_manualButton
manual button field
Definition: importicons.h:187
ImportIconsWizard::initialLoad
bool initialLoad(const QString &name="")
attempt the inital load of the TV channel information
Definition: importicons.cpp:265
ImportIconsWizard::m_iter
ListEntriesIter m_iter
the current iterator
Definition: importicons.h:79
ImportIconsWizard::m_nMaxCount
int m_nMaxCount
the maximum number of TV channels
Definition: importicons.h:170
ImportIconsWizard::m_iconsList
MythUIButtonList * m_iconsList
list of potential icons
Definition: importicons.h:184
ImportIconsWizard::m_listEntries
ListEntries m_listEntries
list of TV channels to search for
Definition: importicons.h:77
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
ImportIconsWizard::STATE_NORMAL
@ STATE_NORMAL
Definition: importicons.h:53
ImportIconsWizard
Definition: importicons.h:29
ImportIconsWizard::CSVEntry::strName
QString strName
channel name
Definition: importicons.h:61
ImportIconsWizard::CSVEntry::strNetworkId
QString strNetworkId
network id
Definition: importicons.h:67
ImportIconsWizard::lookup
bool lookup(const QString &strParam)
looks up the string to determine the caller/xmltvid
Definition: importicons.cpp:618
ImportIconsWizard::m_preview
MythUIImage * m_preview
Definition: importicons.h:191
MythUIProgressDialog
Definition: mythprogressdialog.h:60
ImportIconsWizard::m_strChannelDir
QString m_strChannelDir
the location of the channel icon dir
Definition: importicons.h:165
ImportIconsWizard::m_missingEntries
ListEntries m_missingEntries
list of TV channels with no unique icon
Definition: importicons.h:78
ImportIconsWizard::enableControls
void enableControls(ImportIconsWizard::dialogState state=STATE_NORMAL)
enable/disable the controls
Definition: importicons.cpp:126
ImportIconsWizard::m_manualEdit
MythUITextEdit * m_manualEdit
manual edit field
Definition: importicons.h:185
MythUIButton
A single button widget.
Definition: mythuibutton.h:22
ImportIconsWizard::STATE_DISABLED
@ STATE_DISABLED
Definition: importicons.h:55
ImportIconsWizard::m_progressDialog
MythUIProgressDialog * m_progressDialog
Definition: importicons.h:182
ImportIconsWizard::skip
void skip()
skip this icon
Definition: importicons.cpp:171
ImportIconsWizard::Close
void Close() override
Definition: importicons.cpp:880
ImportIconsWizard::CSVEntry::strXmlTvId
QString strXmlTvId
the xmltvid
Definition: importicons.h:62
ImportIconsWizard::m_strParam
QString m_strParam
Definition: importicons.h:167
ImportIconsWizard::m_tmpDir
QDir m_tmpDir
Definition: importicons.h:177
ImportIconsWizard::m_missingIter
ListEntriesIter m_missingIter
Definition: importicons.h:80
ImportIconsWizard::m_listSearch
ListSearchEntries m_listSearch
the list of SearchEntry
Definition: importicons.h:162
ImportIconsWizard::CSVEntry
describes the TV channel name
Definition: importicons.h:59
ImportIconsWizard::SearchEntry
search entry results
Definition: importicons.h:43
ImportIconsWizard::checkAndDownload
bool checkAndDownload(const QString &url, const QString &localChanId)
checks and attempts to download the logo file to the appropriate place
Definition: importicons.cpp:560
ImportIconsWizard::~ImportIconsWizard
~ImportIconsWizard() override
Definition: importicons.cpp:48
ImportIconsWizard::m_strMatches
QString m_strMatches
the string for the submit() call
Definition: importicons.h:163
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
ImportIconsWizard::ImportIconsWizard
ImportIconsWizard(MythScreenStack *parent, bool fRefresh, QString channelname="")
Definition: importicons.cpp:25
ImportIconsWizard::wget
static QString wget(QUrl &url, const QString &strParam)
use the equivalent of wget to fetch the POST command
Definition: importicons.cpp:539
ImportIconsWizard::m_statusText
MythUIText * m_statusText
Definition: importicons.h:189
ImportIconsWizard::askSubmit
void askSubmit(const QString &strParam)
Definition: importicons.cpp:781
ImportIconsWizard::CSVEntry::strAtscMajorChan
QString strAtscMajorChan
ATSC major number.
Definition: importicons.h:65
ImportIconsWizard::m_previewtitle
MythUIText * m_previewtitle
Definition: importicons.h:192
ImportIconsWizard::CSVEntry::strChanId
QString strChanId
local channel id
Definition: importicons.h:60
ImportIconsWizard::m_missingMaxCount
int m_missingMaxCount
the total number of missing icons
Definition: importicons.h:172
ImportIconsWizard::SearchEntry::strLogo
QString strLogo
the actual logo
Definition: importicons.h:46
ImportIconsWizard::customEvent
void customEvent(QEvent *event) override
Definition: importicons.cpp:855
ImportIconsWizard::ListSearchEntriesIter
QList< SearchEntry >::Iterator ListSearchEntriesIter
iterator over list of SearchEntry entries
Definition: importicons.h:85
ImportIconsWizard::menuSelection
void menuSelection(MythUIButtonListItem *item)
process the icon selection
Definition: importicons.cpp:185
ImportIconsWizard::manualSearch
void manualSearch()
process the manual search
Definition: importicons.cpp:162
ImportIconsWizard::CSVEntry::strTransportId
QString strTransportId
transport id
Definition: importicons.h:64
ImportIconsWizard::m_nameText
MythUIText * m_nameText
name field for the icon
Definition: importicons.h:186
ImportIconsWizard::m_fRefresh
bool m_fRefresh
are we doing a refresh or not
Definition: importicons.h:169
ImportIconsWizard::STATE_SEARCHING
@ STATE_SEARCHING
Definition: importicons.h:54
ImportIconsWizard::m_skipButton
MythUIButton * m_skipButton
button skip
Definition: importicons.h:188
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:144
ImportIconsWizard::ListEntriesIter
QList< CSVEntry >::Iterator ListEntriesIter
iterator over list of CSV entries
Definition: importicons.h:75
ImportIconsWizard::submit
bool submit()
submit the icon information back to the remote db
Definition: importicons.cpp:796
ImportIconsWizard::CSVEntry::strAtscMinorChan
QString strAtscMinorChan
ATSC minor number.
Definition: importicons.h:66
ImportIconsWizard::Load
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
Definition: importicons.cpp:107
ImportIconsWizard::findmissing
bool findmissing(const QString &strParam)
retrieve the actual logo for the TV channel
Definition: importicons.cpp:739
mythscreentype.h
ImportIconsWizard::Init
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
Definition: importicons.cpp:113
ImportIconsWizard::SearchEntry::strID
QString strID
the remote channel id
Definition: importicons.h:44
ImportIconsWizard::dialogState
dialogState
Definition: importicons.h:52
ImportIconsWizard::startDialog
void startDialog()