2009-05-12 09:48:41 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-05-12 09:48:41 +02:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-05-12 09:48:41 +02:00
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2009-05-12 09:48:41 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef RSSFETCHER_H
|
|
|
|
|
#define RSSFETCHER_H
|
|
|
|
|
|
2010-09-24 17:30:10 +02:00
|
|
|
#include "core_global.h"
|
|
|
|
|
|
2010-05-05 16:02:54 +02:00
|
|
|
#include <QtCore/QThread>
|
2010-02-18 17:36:17 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
2010-11-01 16:29:45 +01:00
|
|
|
class QUrl;
|
2010-02-18 17:36:17 +01:00
|
|
|
class QNetworkReply;
|
2010-03-31 11:49:06 +02:00
|
|
|
class QNetworkAccessManager;
|
|
|
|
|
class QIODevice;
|
2010-02-18 17:36:17 +01:00
|
|
|
QT_END_NAMESPACE
|
2009-05-12 09:48:41 +02:00
|
|
|
|
2010-09-24 17:30:10 +02:00
|
|
|
namespace Core {
|
2009-05-12 09:48:41 +02:00
|
|
|
|
2010-09-24 17:30:10 +02:00
|
|
|
class CORE_EXPORT RssItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QString title;
|
|
|
|
|
QString description;
|
|
|
|
|
QString category;
|
|
|
|
|
QString url;
|
|
|
|
|
QString imagePath;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CORE_EXPORT RssFetcher : public QThread
|
2009-05-12 09:48:41 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2010-09-24 17:30:10 +02:00
|
|
|
explicit RssFetcher(int maxItems = -1);
|
2010-05-05 16:02:54 +02:00
|
|
|
virtual void run();
|
2010-09-24 17:30:10 +02:00
|
|
|
virtual ~RssFetcher();
|
2009-05-12 09:48:41 +02:00
|
|
|
|
|
|
|
|
signals:
|
2009-05-28 13:47:15 +02:00
|
|
|
void newsItemReady(const QString& title, const QString& desciption, const QString& url);
|
2010-11-01 16:29:45 +01:00
|
|
|
void rssItemReady(const Core::RssItem& item);
|
2010-02-18 17:36:17 +01:00
|
|
|
void finished(bool error);
|
2009-05-12 09:48:41 +02:00
|
|
|
|
|
|
|
|
public slots:
|
2010-02-18 17:36:17 +01:00
|
|
|
void fetchingFinished(QNetworkReply *reply);
|
2009-05-12 09:48:41 +02:00
|
|
|
void fetch(const QUrl &url);
|
|
|
|
|
|
|
|
|
|
private:
|
2010-09-24 17:30:10 +02:00
|
|
|
enum TagElement { itemElement, titleElement, descriptionElement, linkElement,
|
|
|
|
|
imageElement, imageLinkElement, categoryElement, otherElement };
|
|
|
|
|
static TagElement tagElement(const QStringRef &, TagElement prev);
|
2010-03-31 11:49:06 +02:00
|
|
|
void parseXml(QIODevice *);
|
2009-05-12 09:48:41 +02:00
|
|
|
|
2010-03-31 11:49:06 +02:00
|
|
|
const int m_maxItems;
|
2009-05-12 09:48:41 +02:00
|
|
|
int m_items;
|
2010-09-24 17:30:10 +02:00
|
|
|
int m_requestCount;
|
2010-05-05 16:02:54 +02:00
|
|
|
|
|
|
|
|
QNetworkAccessManager* m_networkAccessManager;
|
2009-05-12 09:48:41 +02:00
|
|
|
};
|
|
|
|
|
|
2009-07-27 13:55:30 +02:00
|
|
|
} // namespace Internal
|
2009-05-12 09:48:41 +02:00
|
|
|
|
|
|
|
|
#endif // RSSFETCHER_H
|
|
|
|
|
|