122
122
#endif // PROVIDER_H
123
/* BEGIN_COMMON_COPYRIGHT_HEADER
126
* Copyright: 2012 Labo A.L
128
* Aaron Lewis <the.warl0ck.1989@gmail.com>
130
* This program or library is free software; you can redistribute it
131
* and/or modify it under the terms of the GNU Lesser General Public
132
* License as published by the Free Software Foundation; either
133
* version 2.1 of the License, or (at your option) any later version.
135
* This library is distributed in the hope that it will be useful,
136
* but WITHOUT ANY WARRANTY; without even the implied warranty of
137
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
138
* Lesser General Public License for more details.
140
* You should have received a copy of the GNU Lesser General
141
* Public License along with this library; if not, write to the
142
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
143
* Boston, MA 02110-1301 USA
145
* END_COMMON_COPYRIGHT_HEADER */
150
#include <QNetworkAccessManager>
151
#include <QNetworkReply>
152
#include <QNetworkRequest>
153
#include <QStandardItem>
154
#include <QDomDocument>
156
#include <QStandardItemModel>
160
#include <QWebElement>
161
#include <QWebElementCollection>
163
#define OFFSET_TRANSCRIPT 1
165
class ProviderItem: public QStandardItem
168
ProviderItem (const QString & url, const QString & name,
169
const QString & icon, const QString & subtitle = QString ())
172
setIcon(QIcon(icon));
173
setData(url, Qt::UserRole);
175
if ( ! subtitle.isEmpty() )
176
setData(subtitle, Qt::UserRole + OFFSET_TRANSCRIPT);
181
class Provider: public QObject
190
explicit Provider(QStandardItemModel *model, QObject *parent = 0);
194
\brief start loading of network resources
196
virtual void start() {}
199
QStandardItemModel *m_model;
200
QNetworkAccessManager *m_nam;
201
QNetworkReply *m_reply;
202
QString m_text, m_icon;
203
PlayOptions m_playOptions;
205
void addItem (const QString & icon, const QString & url,
206
const QString & name, const QString & subtitle = QString());
209
/*! all resources loaded */
215
virtual void finished (QNetworkReply *reply) { Q_UNUSED (reply) }
219
class TedProvider: public Provider
223
explicit TedProvider (QStandardItemModel *model, QObject *parent = 0);
227
void finished (QNetworkReply *reply);
230
class SciAmericanProvider: public Provider
234
explicit SciAmericanProvider (QStandardItemModel *model, QObject *parent = 0);
235
~SciAmericanProvider();
241
QMap<QString,QStandardItem*> mapping;