Skip to content

Commit

Permalink
Big restructuring of the RSS code
Browse files Browse the repository at this point in the history
Dropped Qt 4.4 support
  • Loading branch information
Christophe Dumez committed Oct 16, 2010
1 parent f7cb6a7 commit a27d2dc
Show file tree
Hide file tree
Showing 21 changed files with 1,611 additions and 1,344 deletions.
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ qBittorrent - A BitTorrent client in C++ / Qt4
will install and execute qBittorrent hopefully without any problems.

Dependencies:
- Qt >= 4.4.0 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml)
- Qt >= 4.5.0 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml)

- pkg-config executable

Expand Down
26 changes: 13 additions & 13 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,22 @@ cat >$1/modules.cpp <<EOT
#line 1 "qt4.qcm"
/*
-----BEGIN QCMOD-----
name: Qt >= 4.4
name: Qt >= 4.5
arg: disable-gui, Disable qBittorrent Graphical user interface for headless running
-----END QCMOD-----
*/
class qc_qt4 : public ConfObj
{
public:
qc_qt4(Conf *c) : ConfObj(c) {}
QString name() const { return "Qt >= 4.4"; }
QString shortname() const { return "Qt 4.4"; }
QString name() const { return "Qt >= 4.5"; }
QString shortname() const { return "Qt 4.5"; }
bool exec()
{
if(!conf->getenv("QC_DISABLE_GUI").isEmpty()) {
conf->addDefine("DISABLE_GUI");
}
return(QT_VERSION >= 0x040400);
return(QT_VERSION >= 0x040500);
}
};
#line 1 "pkg-config.qcm"
Expand Down Expand Up @@ -616,22 +616,22 @@ arg: with-qtsingleapplication=[system|shipped], Use the shipped qtsingleapplicat
class qc_qtsingleapplication : public ConfObj
{
public:
qc_qtsingleapplication(Conf *c) : ConfObj(c) {}
QString name() const { return "qtsingleapplication library"; }
QString shortname() const { return "qtsingleapplication"; }
qc_qtsingleapplication(Conf *c) : ConfObj(c) {}
QString name() const { return "qtsingleapplication library"; }
QString shortname() const { return "qtsingleapplication"; }
bool exec(){
QString s;
s = conf->getenv("QC_WITH_QTSINGLEAPPLICATION");
bool exec(){
QString s;
s = conf->getenv("QC_WITH_QTSINGLEAPPLICATION");
if(s.compare("system", Qt::CaseInsensitive) == 0) {
// System
conf->addDefine("USE_SYSTEM_QTSINGLEAPPLICATION");
printf(" [system] ");
} else {
printf(" [shipped] ");
}
return true;
}
}
return true;
}
};
EOT
Expand Down
8 changes: 4 additions & 4 deletions qcm/qt4.qcm
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
-----BEGIN QCMOD-----
name: Qt >= 4.4
name: Qt >= 4.5
arg: disable-gui, Disable qBittorrent Graphical user interface for headless running
-----END QCMOD-----
*/
class qc_qt4 : public ConfObj
{
public:
qc_qt4(Conf *c) : ConfObj(c) {}
QString name() const { return "Qt >= 4.4"; }
QString shortname() const { return "Qt 4.4"; }
QString name() const { return "Qt >= 4.5"; }
QString shortname() const { return "Qt 4.5"; }
bool exec()
{
if(!conf->getenv("QC_DISABLE_GUI").isEmpty()) {
conf->addDefine("DISABLE_GUI");
}
return(QT_VERSION >= 0x040400);
return(QT_VERSION >= 0x040500);
}
};
11 changes: 1 addition & 10 deletions src/rss/feeddownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,12 @@
#include <QFile>
#include <QDataStream>
#include <QFileDialog>
#include <QHash>

#include "qbtsession.h"
#include "ui_feeddownloader.h"
#include "qinisettings.h"

#if QT_VERSION >= 0x040500
#include <QHash>
#else
#include <QMap>
#define QHash QMap
#define toHash toMap
#endif

class FeedFilter: public QHash<QString, QVariant> {
private:
Expand Down Expand Up @@ -508,7 +502,4 @@ protected slots:

};

#undef QHash
#undef toHash

#endif // FEEDDOWNLOADER_H
22 changes: 12 additions & 10 deletions src/rss/feedlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@
* Contact: [email protected], [email protected]
*/

#
#include "feedlistwidget.h"
#include "rssmanager.h"
#include "rssfeed.h"

FeedListWidget::FeedListWidget(QWidget *parent, RssManager *rssmanager): QTreeWidget(parent), rssmanager(rssmanager) {
setContextMenuPolicy(Qt::CustomContextMenu);
setDragDropMode(QAbstractItemView::InternalMove);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setColumnCount(1);
QTreeWidgetItem *___qtreewidgetitem = headerItem();
___qtreewidgetitem->setText(0, QApplication::translate("RSS", "RSS feeds", 0, QApplication::UnicodeUTF8));
headerItem()->setText(0, tr("RSS feeds"));
unread_item = new QTreeWidgetItem(this);
unread_item->setText(0, tr("Unread") + QString::fromUtf8(" (") + QString::number(rssmanager->getNbUnRead(), 10)+ QString(")"));
unread_item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/mail-folder-inbox.png")));
Expand All @@ -52,18 +54,18 @@ FeedListWidget::~FeedListWidget() {

void FeedListWidget::itemAdded(QTreeWidgetItem *item, RssFile* file) {
mapping[item] = file;
if(file->getType() == RssFile::STREAM) {
if(file->getType() == RssFile::FEED) {
feeds_items[file->getID()] = item;
}
}

void FeedListWidget::itemAboutToBeRemoved(QTreeWidgetItem *item) {
RssFile* file = mapping.take(item);
if(file->getType() == RssFile::STREAM) {
if(file->getType() == RssFile::FEED) {
feeds_items.remove(file->getID());
} else {
QList<RssStream*> feeds = ((RssFolder*)file)->getAllFeeds();
foreach(RssStream* feed, feeds) {
QList<RssFeed*> feeds = ((RssFolder*)file)->getAllFeeds();
foreach(RssFeed* feed, feeds) {
feeds_items.remove(feed->getID());
}
}
Expand Down Expand Up @@ -121,7 +123,7 @@ QList<QTreeWidgetItem*> FeedListWidget::getAllFeedItems(QTreeWidgetItem* folder)
int nbChildren = folder->childCount();
for(int i=0; i<nbChildren; ++i) {
QTreeWidgetItem *item = folder->child(i);
if(getItemType(item) == RssFile::STREAM) {
if(getItemType(item) == RssFile::FEED) {
feeds << item;
} else {
feeds << getAllFeedItems(item);
Expand All @@ -146,8 +148,8 @@ QTreeWidgetItem* FeedListWidget::getTreeItemFromUrl(QString url) const{
return feeds_items.value(url, 0);
}

RssStream* FeedListWidget::getRSSItemFromUrl(QString url) const {
return (RssStream*)getRSSItem(getTreeItemFromUrl(url));
RssFeed* FeedListWidget::getRSSItemFromUrl(QString url) const {
return (RssFeed*)getRSSItem(getTreeItemFromUrl(url));
}

QTreeWidgetItem* FeedListWidget::currentItem() const {
Expand All @@ -161,7 +163,7 @@ QTreeWidgetItem* FeedListWidget::currentFeed() const {
void FeedListWidget::updateCurrentFeed(QTreeWidgetItem* new_item) {
if(!new_item) return;
if(!mapping.contains(new_item)) return;
if((getItemType(new_item) == RssFile::STREAM) || new_item == unread_item)
if((getItemType(new_item) == RssFile::FEED) || new_item == unread_item)
current_feed = new_item;
}

Expand Down
8 changes: 6 additions & 2 deletions src/rss/feedlistwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
#include <QStringList>
#include <QHash>
#include <QUrl>
#include "rss.h"

#include "rssfile.h"

class RssManager;
class RssFeed;

class FeedListWidget: public QTreeWidget {
Q_OBJECT
Expand All @@ -59,7 +63,7 @@ class FeedListWidget: public QTreeWidget {
RssFile::FileType getItemType(QTreeWidgetItem *item) const;
QString getItemID(QTreeWidgetItem *item) const;
QTreeWidgetItem* getTreeItemFromUrl(QString url) const;
RssStream* getRSSItemFromUrl(QString url) const;
RssFeed* getRSSItemFromUrl(QString url) const;
QTreeWidgetItem* currentItem() const;
QTreeWidgetItem* currentFeed() const;

Expand Down
Loading

0 comments on commit a27d2dc

Please sign in to comment.