Begin to work on #3, rename some classes.
This commit is contained in:
parent
88bbe648a0
commit
f911773ee7
@ -347,10 +347,7 @@ set(APP_SOURCES
|
||||
src/gui/dialogs/formmain.cpp
|
||||
src/gui/dialogs/formsettings.cpp
|
||||
src/gui/dialogs/formabout.cpp
|
||||
src/gui/dialogs/formcategorydetails.cpp
|
||||
src/gui/dialogs/formfeeddetails.cpp
|
||||
src/gui/dialogs/formupdate.cpp
|
||||
src/gui/dialogs/formimportexport.cpp
|
||||
src/gui/dialogs/formdatabasecleanup.cpp
|
||||
src/gui/dialogs/formbackupdatabasesettings.cpp
|
||||
src/gui/dialogs/formrestoredatabasesettings.cpp
|
||||
@ -412,15 +409,20 @@ set(APP_SOURCES
|
||||
src/core/messagesproxymodel.cpp
|
||||
src/core/feedsmodel.cpp
|
||||
src/core/feedsproxymodel.cpp
|
||||
src/core/category.cpp
|
||||
src/core/rootitem.cpp
|
||||
src/core/feed.cpp
|
||||
src/core/parsingfactory.cpp
|
||||
src/core/feeddownloader.cpp
|
||||
src/core/feedsimportexportmodel.cpp
|
||||
src/core/recyclebin.cpp
|
||||
src/core/feedsselection.cpp
|
||||
|
||||
# STANDARD feed service sources.
|
||||
src/services/standard/standardfeed.cpp
|
||||
src/services/standard/standardfeedsimportexportmodel.cpp
|
||||
src/services/standard/standardcategory.cpp
|
||||
src/services/standard/gui/formstandardcategorydetails.cpp
|
||||
src/services/standard/gui/formstandardfeeddetails.cpp
|
||||
src/services/standard/gui/formstandardimportexport.cpp
|
||||
|
||||
# NETWORK-WEB sources.
|
||||
src/network-web/basenetworkaccessmanager.cpp
|
||||
src/network-web/webpage.cpp
|
||||
@ -462,9 +464,6 @@ set(APP_HEADERS
|
||||
src/gui/dialogs/formmain.h
|
||||
src/gui/dialogs/formsettings.h
|
||||
src/gui/dialogs/formabout.h
|
||||
src/gui/dialogs/formcategorydetails.h
|
||||
src/gui/dialogs/formfeeddetails.h
|
||||
src/gui/dialogs/formimportexport.h
|
||||
src/gui/dialogs/formbackupdatabasesettings.h
|
||||
src/gui/dialogs/formrestoredatabasesettings.h
|
||||
src/gui/dialogs/formdatabasecleanup.h
|
||||
@ -518,7 +517,12 @@ set(APP_HEADERS
|
||||
src/core/feedsmodel.h
|
||||
src/core/feedsproxymodel.h
|
||||
src/core/feeddownloader.h
|
||||
src/core/feedsimportexportmodel.h
|
||||
|
||||
# STANDARD service headers.
|
||||
src/services/standard/standardfeedsimportexportmodel.h
|
||||
src/services/standard/gui/formstandardcategorydetails.h
|
||||
src/services/standard/gui/formstandardfeeddetails.h
|
||||
src/services/standard/gui/formstandardimportexport.h
|
||||
|
||||
# NETWORK-WEB headers.
|
||||
src/network-web/webpage.h
|
||||
@ -548,13 +552,18 @@ set(APP_FORMS
|
||||
src/gui/dialogs/formmain.ui
|
||||
src/gui/dialogs/formsettings.ui
|
||||
src/gui/dialogs/formabout.ui
|
||||
src/gui/dialogs/formcategorydetails.ui
|
||||
src/gui/dialogs/formfeeddetails.ui
|
||||
src/gui/toolbareditor.ui
|
||||
src/gui/dialogs/formimportexport.ui
|
||||
src/gui/dialogs/formbackupdatabasesettings.ui
|
||||
src/gui/dialogs/formrestoredatabasesettings.ui
|
||||
src/gui/dialogs/formdatabasecleanup.ui
|
||||
|
||||
src/gui/toolbareditor.ui
|
||||
|
||||
# STANDARD service forms.
|
||||
src/services/standard/gui/formstandardcategorydetails.ui
|
||||
src/services/standard/gui/formstandardfeeddetails.ui
|
||||
src/services/standard/gui/formstandardimportexport.ui
|
||||
|
||||
# NETWORK forms.
|
||||
src/network-web/downloadmanager.ui
|
||||
src/network-web/downloaditem.ui
|
||||
|
||||
|
4
src/core/feeddownloader.cpp
Normal file → Executable file
4
src/core/feeddownloader.cpp
Normal file → Executable file
@ -17,7 +17,7 @@
|
||||
|
||||
#include "core/feeddownloader.h"
|
||||
|
||||
#include "core/feed.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "definitions/definitions.h"
|
||||
|
||||
#include <QThread>
|
||||
@ -32,7 +32,7 @@ FeedDownloader::~FeedDownloader() {
|
||||
qDebug("Destroying FeedDownloader instance.");
|
||||
}
|
||||
|
||||
void FeedDownloader::updateFeeds(const QList<Feed*> &feeds) {
|
||||
void FeedDownloader::updateFeeds(const QList<StandardFeed*> &feeds) {
|
||||
qDebug().nospace() << "Performing feed updates in thread: \'" << QThread::currentThreadId() << "\'.";
|
||||
|
||||
// Job starts now.
|
||||
|
6
src/core/feeddownloader.h
Normal file → Executable file
6
src/core/feeddownloader.h
Normal file → Executable file
@ -23,7 +23,7 @@
|
||||
#include <QPair>
|
||||
|
||||
|
||||
class Feed;
|
||||
class StandardFeed;
|
||||
|
||||
// Represents results of batch feed updates.
|
||||
struct FeedDownloadResults {
|
||||
@ -55,7 +55,7 @@ class FeedDownloader : public QObject {
|
||||
// New messages are downloaded for each feed and they
|
||||
// are stored persistently in the database.
|
||||
// Appropriate signals are emitted.
|
||||
void updateFeeds(const QList<Feed*> &feeds);
|
||||
void updateFeeds(const QList<StandardFeed*> &feeds);
|
||||
|
||||
signals:
|
||||
// Emitted if feed updates started.
|
||||
@ -69,7 +69,7 @@ class FeedDownloader : public QObject {
|
||||
// "Current" number indicates count of processed feeds
|
||||
// and "total" number indicates total number of feeds
|
||||
// which were in the initial queue.
|
||||
void progress(Feed *feed, int current, int total);
|
||||
void progress(StandardFeed *feed, int current, int total);
|
||||
};
|
||||
|
||||
#endif // FEEDDOWNLOADER_H
|
||||
|
@ -18,10 +18,10 @@
|
||||
#include "core/feedsmodel.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "core/category.h"
|
||||
#include "core/feed.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "services/standard/standardfeedsimportexportmodel.h"
|
||||
#include "core/recyclebin.h"
|
||||
#include "core/feedsimportexportmodel.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "miscellaneous/databasefactory.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
@ -100,7 +100,7 @@ void FeedsModel::executeNextAutoUpdate() {
|
||||
|
||||
// Pass needed interval data and lets the model decide which feeds
|
||||
// should be updated in this pass.
|
||||
QList<Feed*> feeds_for_update = feedsForScheduledUpdate(m_globalAutoUpdateEnabled && m_globalAutoUpdateRemainingInterval == 0);
|
||||
QList<StandardFeed*> feeds_for_update = feedsForScheduledUpdate(m_globalAutoUpdateEnabled && m_globalAutoUpdateRemainingInterval == 0);
|
||||
|
||||
qApp->feedUpdateLock()->unlock();
|
||||
|
||||
@ -197,8 +197,8 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
if (dragged_item->kind() == RootItem::Feeed) {
|
||||
qDebug("Drag-drop action for feed '%s' detected, editing the feed.", qPrintable(dragged_item->title()));
|
||||
|
||||
Feed *actual_feed = dragged_item->toFeed();
|
||||
Feed *feed_new = new Feed(*actual_feed);
|
||||
StandardFeed *actual_feed = dragged_item->toFeed();
|
||||
StandardFeed *feed_new = new StandardFeed(*actual_feed);
|
||||
|
||||
feed_new->setParent(target_item);
|
||||
editFeed(actual_feed, feed_new);
|
||||
@ -208,8 +208,8 @@ bool FeedsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
else if (dragged_item->kind() == RootItem::Cattegory) {
|
||||
qDebug("Drag-drop action for category '%s' detected, editing the feed.", qPrintable(dragged_item->title()));
|
||||
|
||||
Category *actual_category = dragged_item->toCategory();
|
||||
Category *category_new = new Category(*actual_category);
|
||||
StandardCategory *actual_category = dragged_item->toCategory();
|
||||
StandardCategory *category_new = new StandardCategory(*actual_category);
|
||||
|
||||
category_new->clearChildren();
|
||||
category_new->setParent(target_item);
|
||||
@ -341,7 +341,7 @@ bool FeedsModel::removeItem(const QModelIndex &index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FeedsModel::addCategory(Category *category, RootItem *parent) {
|
||||
bool FeedsModel::addCategory(StandardCategory *category, RootItem *parent) {
|
||||
// Get index of parent item (parent standard category).
|
||||
QModelIndex parent_index = indexForItem(parent);
|
||||
bool result = category->addItself(parent);
|
||||
@ -361,7 +361,7 @@ bool FeedsModel::addCategory(Category *category, RootItem *parent) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool FeedsModel::editCategory(Category *original_category, Category *new_category_data) {
|
||||
bool FeedsModel::editCategory(StandardCategory *original_category, StandardCategory *new_category_data) {
|
||||
RootItem *original_parent = original_category->parent();
|
||||
RootItem *new_parent = new_category_data->parent();
|
||||
bool result = original_category->editItself(new_category_data);
|
||||
@ -388,7 +388,7 @@ bool FeedsModel::editCategory(Category *original_category, Category *new_categor
|
||||
return result;
|
||||
}
|
||||
|
||||
bool FeedsModel::addFeed(Feed *feed, RootItem *parent) {
|
||||
bool FeedsModel::addFeed(StandardFeed *feed, RootItem *parent) {
|
||||
// Get index of parent item (parent standard category or root item).
|
||||
QModelIndex parent_index = indexForItem(parent);
|
||||
bool result = feed->addItself(parent);
|
||||
@ -406,7 +406,7 @@ bool FeedsModel::addFeed(Feed *feed, RootItem *parent) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool FeedsModel::editFeed(Feed *original_feed, Feed *new_feed_data) {
|
||||
bool FeedsModel::editFeed(StandardFeed *original_feed, StandardFeed *new_feed_data) {
|
||||
RootItem *original_parent = original_feed->parent();
|
||||
RootItem *new_parent = new_feed_data->parent();
|
||||
bool result = original_feed->editItself(new_feed_data);
|
||||
@ -432,23 +432,23 @@ bool FeedsModel::editFeed(Feed *original_feed, Feed *new_feed_data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
QList<Feed*> feeds_for_update;
|
||||
QList<StandardFeed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
QList<StandardFeed*> feeds_for_update;
|
||||
|
||||
foreach (Feed *feed, allFeeds()) {
|
||||
foreach (StandardFeed *feed, allFeeds()) {
|
||||
switch (feed->autoUpdateType()) {
|
||||
case Feed::DontAutoUpdate:
|
||||
case StandardFeed::DontAutoUpdate:
|
||||
// Do not auto-update this feed ever.
|
||||
continue;
|
||||
|
||||
case Feed::DefaultAutoUpdate:
|
||||
case StandardFeed::DefaultAutoUpdate:
|
||||
if (auto_update_now) {
|
||||
feeds_for_update.append(feed);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Feed::SpecificAutoUpdate:
|
||||
case StandardFeed::SpecificAutoUpdate:
|
||||
default:
|
||||
int remaining_interval = feed->autoUpdateRemainingInterval();
|
||||
|
||||
@ -471,7 +471,7 @@ QList<Feed*> FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
return feeds_for_update;
|
||||
}
|
||||
|
||||
QList<Message> FeedsModel::messagesForFeeds(const QList<Feed*> &feeds) {
|
||||
QList<Message> FeedsModel::messagesForFeeds(const QList<StandardFeed*> &feeds) {
|
||||
QList<Message> messages;
|
||||
|
||||
QSqlDatabase database = qApp->database()->connection(objectName(),
|
||||
@ -482,7 +482,7 @@ QList<Message> FeedsModel::messagesForFeeds(const QList<Feed*> &feeds) {
|
||||
"FROM Messages "
|
||||
"WHERE is_deleted = 0 AND feed = :feed;");
|
||||
|
||||
foreach (Feed *feed, feeds) {
|
||||
foreach (StandardFeed *feed, feeds) {
|
||||
query_read_msg.bindValue(QSL(":feed"), feed->id());
|
||||
|
||||
if (query_read_msg.exec()) {
|
||||
@ -519,7 +519,7 @@ RootItem *FeedsModel::itemForIndex(const QModelIndex &index) const {
|
||||
}
|
||||
}
|
||||
|
||||
Category *FeedsModel::categoryForIndex(const QModelIndex &index) const {
|
||||
StandardCategory *FeedsModel::categoryForIndex(const QModelIndex &index) const {
|
||||
RootItem *item = itemForIndex(index);
|
||||
|
||||
if (item->kind() == RootItem::Cattegory) {
|
||||
@ -567,8 +567,8 @@ QModelIndex FeedsModel::indexForItem(RootItem *item) const {
|
||||
}
|
||||
|
||||
bool FeedsModel::hasAnyFeedNewMessages() {
|
||||
foreach (const Feed *feed, allFeeds()) {
|
||||
if (feed->status() == Feed::NewMessages) {
|
||||
foreach (const StandardFeed *feed, allFeeds()) {
|
||||
if (feed->status() == StandardFeed::NewMessages) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -603,8 +603,8 @@ bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_messa
|
||||
}
|
||||
|
||||
if (source_item->kind() == RootItem::Cattegory) {
|
||||
Category *source_category = source_item->toCategory();
|
||||
Category *new_category = new Category(*source_category);
|
||||
StandardCategory *source_category = source_item->toCategory();
|
||||
StandardCategory *new_category = new StandardCategory(*source_category);
|
||||
|
||||
// Add category to model.
|
||||
new_category->clearChildren();
|
||||
@ -630,8 +630,8 @@ bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_messa
|
||||
}
|
||||
}
|
||||
else if (source_item->kind() == RootItem::Feeed) {
|
||||
Feed *source_feed = source_item->toFeed();
|
||||
Feed *new_feed = new Feed(*source_feed);
|
||||
StandardFeed *source_feed = source_item->toFeed();
|
||||
StandardFeed *new_feed = new StandardFeed(*source_feed);
|
||||
|
||||
// Append this feed and end this iteration.
|
||||
if (!addFeed(new_feed, target_parent)) {
|
||||
@ -664,11 +664,11 @@ void FeedsModel::reloadChangedLayout(QModelIndexList list) {
|
||||
}
|
||||
}
|
||||
|
||||
QStringList FeedsModel::textualFeedIds(const QList<Feed*> &feeds) {
|
||||
QStringList FeedsModel::textualFeedIds(const QList<StandardFeed*> &feeds) {
|
||||
QStringList stringy_ids;
|
||||
stringy_ids.reserve(feeds.size());
|
||||
|
||||
foreach (Feed *feed, feeds) {
|
||||
foreach (StandardFeed *feed, feeds) {
|
||||
stringy_ids.append(QString::number(feed->id()));
|
||||
}
|
||||
|
||||
@ -701,7 +701,7 @@ void FeedsModel::loadFromDatabase() {
|
||||
while (query_categories.next()) {
|
||||
CategoryAssignmentItem pair;
|
||||
pair.first = query_categories.value(CAT_DB_PARENT_ID_INDEX).toInt();
|
||||
pair.second = new Category(query_categories.record());
|
||||
pair.second = new StandardCategory(query_categories.record());
|
||||
|
||||
categories << pair;
|
||||
}
|
||||
@ -717,16 +717,16 @@ void FeedsModel::loadFromDatabase() {
|
||||
|
||||
while (query_feeds.next()) {
|
||||
// Process this feed.
|
||||
Feed::Type type = static_cast<Feed::Type>(query_feeds.value(FDS_DB_TYPE_INDEX).toInt());
|
||||
StandardFeed::Type type = static_cast<StandardFeed::Type>(query_feeds.value(FDS_DB_TYPE_INDEX).toInt());
|
||||
|
||||
switch (type) {
|
||||
case Feed::Atom10:
|
||||
case Feed::Rdf:
|
||||
case Feed::Rss0X:
|
||||
case Feed::Rss2X: {
|
||||
case StandardFeed::Atom10:
|
||||
case StandardFeed::Rdf:
|
||||
case StandardFeed::Rss0X:
|
||||
case StandardFeed::Rss2X: {
|
||||
FeedAssignmentItem pair;
|
||||
pair.first = query_feeds.value(FDS_DB_CATEGORY_INDEX).toInt();
|
||||
pair.second = new Feed(query_feeds.record());
|
||||
pair.second = new StandardFeed(query_feeds.record());
|
||||
pair.second->setType(type);
|
||||
|
||||
feeds << pair;
|
||||
@ -746,12 +746,12 @@ void FeedsModel::loadFromDatabase() {
|
||||
m_rootItem->appendChild(m_recycleBin);
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsModel::feedsForIndex(const QModelIndex &index) {
|
||||
QList<StandardFeed*> FeedsModel::feedsForIndex(const QModelIndex &index) {
|
||||
RootItem *item = itemForIndex(index);
|
||||
return feedsForItem(item);
|
||||
}
|
||||
|
||||
Feed *FeedsModel::feedForIndex(const QModelIndex &index) {
|
||||
StandardFeed *FeedsModel::feedForIndex(const QModelIndex &index) {
|
||||
RootItem *item = itemForIndex(index);
|
||||
|
||||
if (item->kind() == RootItem::Feeed) {
|
||||
@ -762,8 +762,8 @@ Feed *FeedsModel::feedForIndex(const QModelIndex &index) {
|
||||
}
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsModel::feedsForIndexes(const QModelIndexList &indexes) {
|
||||
QList<Feed*> feeds;
|
||||
QList<StandardFeed*> FeedsModel::feedsForIndexes(const QModelIndexList &indexes) {
|
||||
QList<StandardFeed*> feeds;
|
||||
|
||||
// Get selected feeds for each index.
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
@ -782,7 +782,7 @@ QList<Feed*> FeedsModel::feedsForIndexes(const QModelIndexList &indexes) {
|
||||
return feeds;
|
||||
}
|
||||
|
||||
bool FeedsModel::markFeedsRead(const QList<Feed*> &feeds, int read) {
|
||||
bool FeedsModel::markFeedsRead(const QList<StandardFeed*> &feeds, int read) {
|
||||
QSqlDatabase db_handle = qApp->database()->connection(objectName(), DatabaseFactory::FromSettings);
|
||||
|
||||
if (!db_handle.transaction()) {
|
||||
@ -817,7 +817,7 @@ bool FeedsModel::markFeedsRead(const QList<Feed*> &feeds, int read) {
|
||||
}
|
||||
}
|
||||
|
||||
bool FeedsModel::markFeedsDeleted(const QList<Feed*> &feeds, int deleted, bool read_only) {
|
||||
bool FeedsModel::markFeedsDeleted(const QList<StandardFeed*> &feeds, int deleted, bool read_only) {
|
||||
QSqlDatabase db_handle = qApp->database()->connection(objectName(), DatabaseFactory::FromSettings);
|
||||
|
||||
if (!db_handle.transaction()) {
|
||||
@ -863,12 +863,12 @@ bool FeedsModel::markFeedsDeleted(const QList<Feed*> &feeds, int deleted, bool r
|
||||
}
|
||||
}
|
||||
|
||||
QHash<int, Category*> FeedsModel::allCategories() {
|
||||
QHash<int, StandardCategory*> FeedsModel::allCategories() {
|
||||
return categoriesForItem(m_rootItem);
|
||||
}
|
||||
|
||||
QHash<int, Category*> FeedsModel::categoriesForItem(RootItem *root) {
|
||||
QHash<int, Category*> categories;
|
||||
QHash<int, StandardCategory*> FeedsModel::categoriesForItem(RootItem *root) {
|
||||
QHash<int, StandardCategory*> categories;
|
||||
QList<RootItem*> parents;
|
||||
|
||||
parents.append(root->childItems());
|
||||
@ -880,7 +880,7 @@ QHash<int, Category*> FeedsModel::categoriesForItem(RootItem *root) {
|
||||
// This item is category, add it to the output list and
|
||||
// scan its children.
|
||||
int category_id = item->id();
|
||||
Category *category = item->toCategory();
|
||||
StandardCategory *category = item->toCategory();
|
||||
|
||||
if (!categories.contains(category_id)) {
|
||||
categories.insert(category_id, category);
|
||||
@ -893,13 +893,13 @@ QHash<int, Category*> FeedsModel::categoriesForItem(RootItem *root) {
|
||||
return categories;
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsModel::allFeeds() {
|
||||
QList<StandardFeed*> FeedsModel::allFeeds() {
|
||||
return feedsForItem(m_rootItem);
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsModel::feedsForItem(RootItem *root) {
|
||||
QList<StandardFeed*> FeedsModel::feedsForItem(RootItem *root) {
|
||||
QList<RootItem*> children = root->getRecursiveChildren();
|
||||
QList<Feed*> feeds;
|
||||
QList<StandardFeed*> feeds;
|
||||
|
||||
foreach (RootItem *child, children) {
|
||||
if (child->kind() == RootItem::Feeed) {
|
||||
@ -911,7 +911,7 @@ QList<Feed*> FeedsModel::feedsForItem(RootItem *root) {
|
||||
}
|
||||
|
||||
void FeedsModel::assembleFeeds(FeedAssignment feeds) {
|
||||
QHash<int, Category*> categories = allCategories();
|
||||
QHash<int, StandardCategory*> categories = allCategories();
|
||||
|
||||
foreach (const FeedAssignmentItem &feed, feeds) {
|
||||
if (feed.first == NO_PARENT_CATEGORY) {
|
||||
|
52
src/core/feedsmodel.h
Normal file → Executable file
52
src/core/feedsmodel.h
Normal file → Executable file
@ -26,23 +26,23 @@
|
||||
#include <QIcon>
|
||||
|
||||
|
||||
class Category;
|
||||
class Feed;
|
||||
class StandardCategory;
|
||||
class StandardFeed;
|
||||
class RecycleBin;
|
||||
class FeedsImportExportModel;
|
||||
class QTimer;
|
||||
|
||||
typedef QList<QPair<int, Category*> > CategoryAssignment;
|
||||
typedef QPair<int, Category*> CategoryAssignmentItem;
|
||||
typedef QList<QPair<int, StandardCategory*> > CategoryAssignment;
|
||||
typedef QPair<int, StandardCategory*> CategoryAssignmentItem;
|
||||
|
||||
typedef QList<QPair<int, Feed*> > FeedAssignment;
|
||||
typedef QPair<int, Feed*> FeedAssignmentItem;
|
||||
typedef QList<QPair<int, StandardFeed*> > FeedAssignment;
|
||||
typedef QPair<int, StandardFeed*> FeedAssignmentItem;
|
||||
|
||||
class FeedsModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
friend class Feed;
|
||||
friend class Category;
|
||||
friend class StandardFeed;
|
||||
friend class StandardCategory;
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
@ -79,57 +79,57 @@ class FeedsModel : public QAbstractItemModel {
|
||||
bool removeItem(const QModelIndex &index);
|
||||
|
||||
// Standard category manipulators.
|
||||
bool addCategory(Category *category, RootItem *parent);
|
||||
bool editCategory(Category *original_category, Category *new_category_data);
|
||||
bool addCategory(StandardCategory *category, RootItem *parent);
|
||||
bool editCategory(StandardCategory *original_category, StandardCategory *new_category_data);
|
||||
|
||||
// Standard feed manipulators.
|
||||
bool addFeed(Feed *feed, RootItem *parent);
|
||||
bool addFeed(StandardFeed *feed, RootItem *parent);
|
||||
|
||||
// New feed is just temporary feed, it is not added to the model.
|
||||
// It is used to fetch its data to the original feed
|
||||
// and the original feed is moved if needed.
|
||||
bool editFeed(Feed *original_feed, Feed *new_feed_data);
|
||||
bool editFeed(StandardFeed *original_feed, StandardFeed *new_feed_data);
|
||||
|
||||
// Returns the list of feeds which should be updated
|
||||
// according to auto-update schedule.
|
||||
// Variable "auto_update_now" is true, when global timeout
|
||||
// for scheduled auto-update was met and global auto-update strategy is enabled
|
||||
// so feeds with "default" auto-update strategy should be updated.
|
||||
QList<Feed*> feedsForScheduledUpdate(bool auto_update_now);
|
||||
QList<StandardFeed*> feedsForScheduledUpdate(bool auto_update_now);
|
||||
|
||||
// Returns (undeleted) messages for given feeds.
|
||||
// This is usually used for displaying whole feeds
|
||||
// in "newspaper" mode.
|
||||
QList<Message> messagesForFeeds(const QList<Feed*> &feeds);
|
||||
QList<Message> messagesForFeeds(const QList<StandardFeed*> &feeds);
|
||||
|
||||
// Returns all categories, each pair
|
||||
// consists of ID of parent item and pointer to category.
|
||||
QHash<int, Category*> allCategories();
|
||||
QHash<int, StandardCategory*> allCategories();
|
||||
|
||||
// Returns categories from the subtree with given root node, each pair
|
||||
// consists of ID of parent item and pointer to category.
|
||||
QHash<int, Category*> categoriesForItem(RootItem *root);
|
||||
QHash<int, StandardCategory*> categoriesForItem(RootItem *root);
|
||||
|
||||
// Returns list of all feeds contained in the model.
|
||||
QList<Feed*> allFeeds();
|
||||
QList<StandardFeed*> allFeeds();
|
||||
|
||||
// Get list of feeds from tree with particular item
|
||||
// as root. If root itself is a feed, then it is returned.
|
||||
QList<Feed*> feedsForItem(RootItem *root);
|
||||
QList<StandardFeed*> feedsForItem(RootItem *root);
|
||||
|
||||
// Returns list of ALL CHILD feeds which belong to given parent indexes.
|
||||
QList<Feed*> feedsForIndexes(const QModelIndexList &indexes);
|
||||
QList<StandardFeed*> feedsForIndexes(const QModelIndexList &indexes);
|
||||
|
||||
// Returns ALL CHILD feeds contained within single index.
|
||||
QList<Feed*> feedsForIndex(const QModelIndex &index);
|
||||
QList<StandardFeed*> feedsForIndex(const QModelIndex &index);
|
||||
|
||||
// Returns pointer to feed if it lies on given index
|
||||
// or NULL if no feed lies on given index.
|
||||
Feed *feedForIndex(const QModelIndex &index);
|
||||
StandardFeed *feedForIndex(const QModelIndex &index);
|
||||
|
||||
// Returns pointer to category if it lies on given index
|
||||
// or NULL if no category lies on given index.
|
||||
Category *categoryForIndex(const QModelIndex &index) const;
|
||||
StandardCategory *categoryForIndex(const QModelIndex &index) const;
|
||||
|
||||
// Returns pointer to recycle bin if lies on given index
|
||||
// or NULL if no recycle bin lies on given index.
|
||||
@ -166,8 +166,8 @@ class FeedsModel : public QAbstractItemModel {
|
||||
|
||||
public slots:
|
||||
// Feeds operations.
|
||||
bool markFeedsRead(const QList<Feed*> &feeds, int read);
|
||||
bool markFeedsDeleted(const QList<Feed*> &feeds, int deleted, bool read_only);
|
||||
bool markFeedsRead(const QList<StandardFeed*> &feeds, int read);
|
||||
bool markFeedsDeleted(const QList<StandardFeed*> &feeds, int deleted, bool read_only);
|
||||
|
||||
// Signals that properties (probably counts)
|
||||
// of ALL items have changed.
|
||||
@ -185,7 +185,7 @@ class FeedsModel : public QAbstractItemModel {
|
||||
protected:
|
||||
// Returns converted ids of given feeds
|
||||
// which are suitable as IN clause for SQL queries.
|
||||
QStringList textualFeedIds(const QList<Feed*> &feeds);
|
||||
QStringList textualFeedIds(const QList<StandardFeed*> &feeds);
|
||||
|
||||
// Loads feed/categories from the database.
|
||||
void loadFromDatabase();
|
||||
@ -199,7 +199,7 @@ class FeedsModel : public QAbstractItemModel {
|
||||
void requireItemValidationAfterDragDrop(const QModelIndex &source_index);
|
||||
|
||||
// Emitted when model requests update of some feeds.
|
||||
void feedsUpdateRequested(const QList<Feed*> feeds);
|
||||
void feedsUpdateRequested(const QList<StandardFeed*> feeds);
|
||||
|
||||
private:
|
||||
RootItem *m_rootItem;
|
||||
|
@ -20,9 +20,9 @@
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "core/feedsmodel.h"
|
||||
#include "core/category.h"
|
||||
#include "core/feed.h"
|
||||
#include "core/rootitem.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
|
||||
|
||||
FeedsProxyModel::FeedsProxyModel(QObject *parent)
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include "core/feedsselection.h"
|
||||
|
||||
#include "core/rootitem.h"
|
||||
#include "core/category.h"
|
||||
#include "core/feed.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "definitions/definitions.h"
|
||||
|
||||
|
||||
|
2
src/core/feedsselection.h
Normal file → Executable file
2
src/core/feedsselection.h
Normal file → Executable file
@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
class RootItem;
|
||||
class Feed;
|
||||
class StandardFeed;
|
||||
|
||||
class FeedsSelection {
|
||||
public:
|
||||
|
12
src/core/rootitem.cpp
Normal file → Executable file
12
src/core/rootitem.cpp
Normal file → Executable file
@ -17,8 +17,8 @@
|
||||
|
||||
#include "core/rootitem.h"
|
||||
|
||||
#include "core/category.h"
|
||||
#include "core/feed.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "core/recyclebin.h"
|
||||
#include "miscellaneous/application.h"
|
||||
|
||||
@ -118,12 +118,12 @@ RecycleBin *RootItem::toRecycleBin() {
|
||||
return static_cast<RecycleBin*>(this);
|
||||
}
|
||||
|
||||
Category *RootItem::toCategory() {
|
||||
return static_cast<Category*>(this);
|
||||
StandardCategory *RootItem::toCategory() {
|
||||
return static_cast<StandardCategory*>(this);
|
||||
}
|
||||
|
||||
Feed *RootItem::toFeed() {
|
||||
return static_cast<Feed*>(this);
|
||||
StandardFeed *RootItem::toFeed() {
|
||||
return static_cast<StandardFeed*>(this);
|
||||
}
|
||||
|
||||
RootItem *RootItem::child(RootItem::Kind kind_of_child, const QString &identifier) {
|
||||
|
8
src/core/rootitem.h
Normal file → Executable file
8
src/core/rootitem.h
Normal file → Executable file
@ -24,8 +24,8 @@
|
||||
#include <QFont>
|
||||
|
||||
class RecycleBin;
|
||||
class Category;
|
||||
class Feed;
|
||||
class StandardCategory;
|
||||
class StandardFeed;
|
||||
|
||||
// Represents ROOT item of FeedsModel.
|
||||
// NOTE: This class is derived to add functionality for
|
||||
@ -183,8 +183,8 @@ class RootItem {
|
||||
|
||||
// Converters
|
||||
RecycleBin *toRecycleBin();
|
||||
Category *toCategory();
|
||||
Feed *toFeed();
|
||||
StandardCategory *toCategory();
|
||||
StandardFeed *toFeed();
|
||||
|
||||
// Compares two model items.
|
||||
static bool isEqual(RootItem *lhs, RootItem *rhs);
|
||||
|
@ -36,10 +36,10 @@
|
||||
#include "gui/dialogs/formabout.h"
|
||||
#include "gui/dialogs/formsettings.h"
|
||||
#include "gui/dialogs/formupdate.h"
|
||||
#include "gui/dialogs/formimportexport.h"
|
||||
#include "gui/dialogs/formbackupdatabasesettings.h"
|
||||
#include "gui/dialogs/formrestoredatabasesettings.h"
|
||||
#include "gui/notifications/notification.h"
|
||||
#include "services/standard/gui/formstandardimportexport.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QSessionManager>
|
||||
@ -411,14 +411,14 @@ void FormMain::loadWebBrowserMenu(int index) {
|
||||
}
|
||||
|
||||
void FormMain::exportFeeds() {
|
||||
QPointer<FormImportExport> form = new FormImportExport(this);
|
||||
QPointer<FormStandardImportExport> form = new FormStandardImportExport(this);
|
||||
form.data()->setMode(FeedsImportExportModel::Export);
|
||||
form.data()->exec();
|
||||
delete form.data();
|
||||
}
|
||||
|
||||
void FormMain::importFeeds() {
|
||||
QPointer<FormImportExport> form = new FormImportExport(this);
|
||||
QPointer<FormStandardImportExport> form = new FormStandardImportExport(this);
|
||||
form.data()->setMode(FeedsImportExportModel::Import);
|
||||
form.data()->exec();
|
||||
delete form.data();
|
||||
|
@ -184,9 +184,18 @@
|
||||
<addaction name="m_actionRestoreRecycleBin"/>
|
||||
<addaction name="m_actionRestoreSelectedMessagesFromRecycleBin"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_menuServices">
|
||||
<property name="title">
|
||||
<string>&Services</string>
|
||||
</property>
|
||||
<addaction name="m_actionServiceAdd"/>
|
||||
<addaction name="m_actionServiceEdit"/>
|
||||
<addaction name="m_actionServiceDelete"/>
|
||||
</widget>
|
||||
<addaction name="m_menuFile"/>
|
||||
<addaction name="m_menuView"/>
|
||||
<addaction name="m_menuFeeds"/>
|
||||
<addaction name="m_menuServices"/>
|
||||
<addaction name="m_menuMessages"/>
|
||||
<addaction name="m_menuRecycleBin"/>
|
||||
<addaction name="m_menuWebBrowser"/>
|
||||
@ -680,6 +689,21 @@
|
||||
<string notr="true">E</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionServiceAdd">
|
||||
<property name="text">
|
||||
<string>&Add new service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionServiceDelete">
|
||||
<property name="text">
|
||||
<string>&Delete selected service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionServiceEdit">
|
||||
<property name="text">
|
||||
<string>&Edit selected service</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -25,9 +25,9 @@
|
||||
#include "miscellaneous/databasecleaner.h"
|
||||
#include "core/messagesproxymodel.h"
|
||||
#include "core/feeddownloader.h"
|
||||
#include "core/feed.h"
|
||||
#include "core/feedsselection.h"
|
||||
#include "core/feedsimportexportmodel.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "services/standard/standardfeedsimportexportmodel.h"
|
||||
#include "network-web/webbrowser.h"
|
||||
#include "gui/messagesview.h"
|
||||
#include "gui/feedsview.h"
|
||||
@ -252,7 +252,7 @@ void FeedMessageViewer::onFeedUpdatesStarted() {
|
||||
qApp->mainForm()->statusBar()->showProgressFeeds(0, tr("Feed update started"));
|
||||
}
|
||||
|
||||
void FeedMessageViewer::onFeedUpdatesProgress(Feed *feed, int current, int total) {
|
||||
void FeedMessageViewer::onFeedUpdatesProgress(StandardFeed *feed, int current, int total) {
|
||||
// Some feed got updated.
|
||||
m_feedsView->updateCountsOfParticularFeed(feed, true);
|
||||
qApp->mainForm()->statusBar()->showProgressFeeds((current * 100.0) / total,
|
||||
@ -369,7 +369,7 @@ void FeedMessageViewer::createConnections() {
|
||||
form_main->m_ui->m_tabWidget, SLOT(addBrowserWithMessages(QList<Message>)));
|
||||
|
||||
// Downloader connections.
|
||||
connect(m_feedsView, SIGNAL(feedsUpdateRequested(QList<Feed*>)), this, SLOT(updateFeeds(QList<Feed*>)));
|
||||
connect(m_feedsView, SIGNAL(feedsUpdateRequested(QList<StandardFeed*>)), this, SLOT(updateFeeds(QList<StandardFeed*>)));
|
||||
|
||||
// Toolbar forwardings.
|
||||
connect(form_main->m_ui->m_actionCleanupDatabase,
|
||||
@ -548,7 +548,7 @@ void FeedMessageViewer::refreshVisualProperties() {
|
||||
m_toolBarMessages->setToolButtonStyle(button_style);
|
||||
}
|
||||
|
||||
void FeedMessageViewer::updateFeeds(QList<Feed *> feeds) {
|
||||
void FeedMessageViewer::updateFeeds(QList<StandardFeed *> feeds) {
|
||||
if (!qApp->feedUpdateLock()->tryLock()) {
|
||||
qApp->showGuiMessage(tr("Cannot update all items"),
|
||||
tr("You cannot update all items because another another critical operation is ongoing."),
|
||||
@ -561,14 +561,14 @@ void FeedMessageViewer::updateFeeds(QList<Feed *> feeds) {
|
||||
m_feedDownloaderThread = new QThread();
|
||||
|
||||
// Downloader setup.
|
||||
qRegisterMetaType<QList<Feed*> >("QList<Feed*>");
|
||||
qRegisterMetaType<QList<StandardFeed*> >("QList<Feed*>");
|
||||
m_feedDownloader->moveToThread(m_feedDownloaderThread);
|
||||
|
||||
connect(this, SIGNAL(feedsUpdateRequested(QList<Feed*>)), m_feedDownloader, SLOT(updateFeeds(QList<Feed*>)));
|
||||
connect(this, SIGNAL(feedsUpdateRequested(QList<StandardFeed*>)), m_feedDownloader, SLOT(updateFeeds(QList<StandardFeed*>)));
|
||||
connect(m_feedDownloaderThread, SIGNAL(finished()), m_feedDownloaderThread, SLOT(deleteLater()));
|
||||
connect(m_feedDownloader, SIGNAL(finished(FeedDownloadResults)), this, SLOT(onFeedUpdatesFinished(FeedDownloadResults)));
|
||||
connect(m_feedDownloader, SIGNAL(started()), this, SLOT(onFeedUpdatesStarted()));
|
||||
connect(m_feedDownloader, SIGNAL(progress(Feed*,int,int)), this, SLOT(onFeedUpdatesProgress(Feed*,int,int)));
|
||||
connect(m_feedDownloader, SIGNAL(progress(StandardFeed*,int,int)), this, SLOT(onFeedUpdatesProgress(StandardFeed*,int,int)));
|
||||
|
||||
// Connections are made, start the feed downloader thread.
|
||||
m_feedDownloaderThread->start();
|
||||
|
8
src/gui/feedmessageviewer.h
Normal file → Executable file
8
src/gui/feedmessageviewer.h
Normal file → Executable file
@ -30,7 +30,7 @@ class MessagesToolBar;
|
||||
class FeedsToolBar;
|
||||
class FeedsView;
|
||||
class DatabaseCleaner;
|
||||
class Feed;
|
||||
class StandardFeed;
|
||||
class QToolBar;
|
||||
class QSplitter;
|
||||
class QProgressBar;
|
||||
@ -103,7 +103,7 @@ class FeedMessageViewer : public TabContent {
|
||||
// Reloads some changeable visual settings.
|
||||
void refreshVisualProperties();
|
||||
|
||||
void updateFeeds(QList<Feed*> feeds);
|
||||
void updateFeeds(QList<StandardFeed*> feeds);
|
||||
|
||||
private slots:
|
||||
// Updates counts of messages for example in tray icon.
|
||||
@ -111,7 +111,7 @@ class FeedMessageViewer : public TabContent {
|
||||
|
||||
// Reacts on feed updates.
|
||||
void onFeedUpdatesStarted();
|
||||
void onFeedUpdatesProgress(Feed *feed, int current, int total);
|
||||
void onFeedUpdatesProgress(StandardFeed *feed, int current, int total);
|
||||
void onFeedUpdatesFinished(FeedDownloadResults results);
|
||||
|
||||
// Switches visibility of feed list and related
|
||||
@ -135,7 +135,7 @@ class FeedMessageViewer : public TabContent {
|
||||
|
||||
signals:
|
||||
// Emitted if user/application requested updating of some feeds.
|
||||
void feedsUpdateRequested(const QList<Feed*> feeds);
|
||||
void feedsUpdateRequested(const QList<StandardFeed*> feeds);
|
||||
|
||||
private:
|
||||
bool m_toolBarsEnabled;
|
||||
|
@ -18,21 +18,21 @@
|
||||
#include "gui/feedsview.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "core/feed.h"
|
||||
#include "core/feedsmodel.h"
|
||||
#include "core/feedsproxymodel.h"
|
||||
#include "core/rootitem.h"
|
||||
#include "core/category.h"
|
||||
#include "core/recyclebin.h"
|
||||
#include "core/feed.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "miscellaneous/systemfactory.h"
|
||||
#include "miscellaneous/mutex.h"
|
||||
#include "gui/systemtrayicon.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/styleditemdelegatewithoutfocus.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/dialogs/formcategorydetails.h"
|
||||
#include "gui/dialogs/formfeeddetails.h"
|
||||
#include "services/standard/gui/formstandardcategorydetails.h"
|
||||
#include "services/standard/gui/formstandardfeeddetails.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QHeaderView>
|
||||
@ -56,7 +56,7 @@ FeedsView::FeedsView(QWidget *parent)
|
||||
|
||||
// Connections.
|
||||
connect(m_sourceModel, SIGNAL(requireItemValidationAfterDragDrop(QModelIndex)), this, SLOT(validateItemAfterDragDrop(QModelIndex)));
|
||||
connect(m_sourceModel, SIGNAL(feedsUpdateRequested(QList<Feed*>)), this, SIGNAL(feedsUpdateRequested(QList<Feed*>)));
|
||||
connect(m_sourceModel, SIGNAL(feedsUpdateRequested(QList<StandardFeed*>)), this, SIGNAL(feedsUpdateRequested(QList<StandardFeed*>)));
|
||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||
|
||||
setModel(m_proxyModel);
|
||||
@ -73,18 +73,18 @@ void FeedsView::setSortingEnabled(bool enable) {
|
||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsView::selectedFeeds() const {
|
||||
QList<StandardFeed*> FeedsView::selectedFeeds() const {
|
||||
QModelIndex current_index = currentIndex();
|
||||
|
||||
if (current_index.isValid()) {
|
||||
return m_sourceModel->feedsForIndex(m_proxyModel->mapToSource(current_index));
|
||||
}
|
||||
else {
|
||||
return QList<Feed*>();
|
||||
return QList<StandardFeed*>();
|
||||
}
|
||||
}
|
||||
|
||||
QList<Feed*> FeedsView::allFeeds() const {
|
||||
QList<StandardFeed*> FeedsView::allFeeds() const {
|
||||
return m_sourceModel->allFeeds();
|
||||
}
|
||||
|
||||
@ -99,12 +99,12 @@ RootItem *FeedsView::selectedItem() const {
|
||||
return selected_item == m_sourceModel->rootItem() ? NULL : selected_item;
|
||||
}
|
||||
|
||||
Category *FeedsView::selectedCategory() const {
|
||||
StandardCategory *FeedsView::selectedCategory() const {
|
||||
QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex());
|
||||
return m_sourceModel->categoryForIndex(current_mapped);
|
||||
}
|
||||
|
||||
Feed *FeedsView::selectedFeed() const {
|
||||
StandardFeed *FeedsView::selectedFeed() const {
|
||||
QModelIndex current_mapped = m_proxyModel->mapToSource(currentIndex());
|
||||
return m_sourceModel->feedForIndex(current_mapped);
|
||||
}
|
||||
@ -118,7 +118,7 @@ void FeedsView::saveExpandedStates() {
|
||||
Settings *settings = qApp->settings();
|
||||
|
||||
// Iterate all categories and save their expand statuses.
|
||||
foreach (Category *category, sourceModel()->allCategories().values()) {
|
||||
foreach (StandardCategory *category, sourceModel()->allCategories().values()) {
|
||||
settings->setValue(GROUP(Categories),
|
||||
QString::number(category->id()),
|
||||
isExpanded(model()->mapFromSource(sourceModel()->indexForItem(category))));
|
||||
@ -129,7 +129,7 @@ void FeedsView::loadExpandedStates() {
|
||||
Settings *settings = qApp->settings();
|
||||
|
||||
// Iterate all categories and save their expand statuses.
|
||||
foreach (Category *category, sourceModel()->allCategories().values()) {
|
||||
foreach (StandardCategory *category, sourceModel()->allCategories().values()) {
|
||||
setExpanded(model()->mapFromSource(sourceModel()->indexForItem(category)),
|
||||
settings->value(GROUP(Categories), QString::number(category->id()), true).toBool());
|
||||
}
|
||||
@ -204,7 +204,7 @@ void FeedsView::addNewCategory() {
|
||||
return;
|
||||
}
|
||||
|
||||
QPointer<FormCategoryDetails> form_pointer = new FormCategoryDetails(m_sourceModel, this);
|
||||
QPointer<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(m_sourceModel, this);
|
||||
|
||||
form_pointer.data()->exec(NULL, selectedItem());
|
||||
|
||||
@ -214,8 +214,8 @@ void FeedsView::addNewCategory() {
|
||||
qApp->feedUpdateLock()->unlock();
|
||||
}
|
||||
|
||||
void FeedsView::editCategory(Category *category) {
|
||||
QPointer<FormCategoryDetails> form_pointer = new FormCategoryDetails(m_sourceModel, this);
|
||||
void FeedsView::editCategory(StandardCategory *category) {
|
||||
QPointer<FormStandardCategoryDetails> form_pointer = new FormStandardCategoryDetails(m_sourceModel, this);
|
||||
|
||||
form_pointer.data()->exec(category, NULL);
|
||||
|
||||
@ -233,7 +233,7 @@ void FeedsView::addNewFeed() {
|
||||
return;
|
||||
}
|
||||
|
||||
QPointer<FormFeedDetails> form_pointer = new FormFeedDetails(m_sourceModel, this);
|
||||
QPointer<FormStandardFeedDetails> form_pointer = new FormStandardFeedDetails(m_sourceModel, this);
|
||||
|
||||
form_pointer.data()->exec(NULL, selectedItem());
|
||||
|
||||
@ -243,8 +243,8 @@ void FeedsView::addNewFeed() {
|
||||
qApp->feedUpdateLock()->unlock();
|
||||
}
|
||||
|
||||
void FeedsView::editFeed(Feed *feed) {
|
||||
QPointer<FormFeedDetails> form_pointer = new FormFeedDetails(m_sourceModel, this);
|
||||
void FeedsView::editFeed(StandardFeed *feed) {
|
||||
QPointer<FormStandardFeedDetails> form_pointer = new FormStandardFeedDetails(m_sourceModel, this);
|
||||
|
||||
form_pointer.data()->exec(feed, NULL);
|
||||
|
||||
@ -302,8 +302,8 @@ void FeedsView::editSelectedItem() {
|
||||
return;
|
||||
}
|
||||
|
||||
Category *category;
|
||||
Feed *feed;
|
||||
StandardCategory *category;
|
||||
StandardFeed *feed;
|
||||
|
||||
if ((category = selectedCategory()) != NULL) {
|
||||
editCategory(category);
|
||||
@ -388,7 +388,7 @@ void FeedsView::markAllFeedsRead() {
|
||||
}
|
||||
|
||||
void FeedsView::fetchMetadataForSelectedFeed() {
|
||||
Feed *selected_feed = selectedFeed();
|
||||
StandardFeed *selected_feed = selectedFeed();
|
||||
|
||||
if (selected_feed != NULL) {
|
||||
selected_feed->fetchMetadataForItself();
|
||||
@ -429,7 +429,7 @@ void FeedsView::restoreRecycleBin() {
|
||||
}
|
||||
|
||||
void FeedsView::updateCountsOfSelectedFeeds(bool update_total_too) {
|
||||
foreach (Feed *feed, selectedFeeds()) {
|
||||
foreach (StandardFeed *feed, selectedFeeds()) {
|
||||
feed->updateCounts(update_total_too);
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ void FeedsView::updateCountsOfRecycleBin(bool update_total_too) {
|
||||
}
|
||||
|
||||
void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||
foreach (Feed *feed, allFeeds()) {
|
||||
foreach (StandardFeed *feed, allFeeds()) {
|
||||
feed->updateCounts(update_total_too);
|
||||
}
|
||||
|
||||
@ -469,7 +469,7 @@ void FeedsView::updateCountsOfAllFeeds(bool update_total_too) {
|
||||
notifyWithCounts();
|
||||
}
|
||||
|
||||
void FeedsView::updateCountsOfParticularFeed(Feed *feed, bool update_total_too) {
|
||||
void FeedsView::updateCountsOfParticularFeed(StandardFeed *feed, bool update_total_too) {
|
||||
QModelIndex index = m_sourceModel->indexForItem(feed);
|
||||
|
||||
if (index.isValid()) {
|
||||
|
@ -28,8 +28,8 @@
|
||||
|
||||
|
||||
class FeedsProxyModel;
|
||||
class Feed;
|
||||
class Category;
|
||||
class StandardFeed;
|
||||
class StandardCategory;
|
||||
class QTimer;
|
||||
|
||||
class FeedsView : public QTreeView {
|
||||
@ -53,14 +53,14 @@ class FeedsView : public QTreeView {
|
||||
|
||||
// Returns list of selected/all feeds.
|
||||
// NOTE: This is recursive method which returns all descendants.
|
||||
QList<Feed*> selectedFeeds() const;
|
||||
QList<Feed*> allFeeds() const;
|
||||
QList<StandardFeed*> selectedFeeds() const;
|
||||
QList<StandardFeed*> allFeeds() const;
|
||||
|
||||
// Returns pointers to selected feed/category if they are really
|
||||
// selected.
|
||||
RootItem *selectedItem() const;
|
||||
Category *selectedCategory() const;
|
||||
Feed *selectedFeed() const;
|
||||
StandardCategory *selectedCategory() const;
|
||||
StandardFeed *selectedFeed() const;
|
||||
RecycleBin *selectedRecycleBin() const;
|
||||
|
||||
// Saves/loads expand states of all nodes (feeds/categories) of the list to/from settings.
|
||||
@ -104,11 +104,11 @@ class FeedsView : public QTreeView {
|
||||
|
||||
// Standard category manipulators.
|
||||
void addNewCategory();
|
||||
void editCategory(Category *category);
|
||||
void editCategory(StandardCategory *category);
|
||||
|
||||
// Standard feed manipulators.
|
||||
void addNewFeed();
|
||||
void editFeed(Feed *feed);
|
||||
void editFeed(StandardFeed *feed);
|
||||
|
||||
// Is called when counts of messages are changed externally,
|
||||
// typically from message view.
|
||||
@ -124,7 +124,7 @@ class FeedsView : public QTreeView {
|
||||
void updateCountsOfAllFeeds(bool update_total_too);
|
||||
|
||||
// Reloads counts for particular feed.
|
||||
void updateCountsOfParticularFeed(Feed *feed, bool update_total_too);
|
||||
void updateCountsOfParticularFeed(StandardFeed *feed, bool update_total_too);
|
||||
|
||||
// Notifies other components about messages
|
||||
// counts.
|
||||
@ -168,7 +168,7 @@ class FeedsView : public QTreeView {
|
||||
|
||||
signals:
|
||||
// Emitted if user/application requested updating of some feeds.
|
||||
void feedsUpdateRequested(const QList<Feed*> feeds);
|
||||
void feedsUpdateRequested(const QList<StandardFeed*> feeds);
|
||||
|
||||
// Emitted if counts of messages are changed.
|
||||
void messageCountsChanged(int unread_messages, int total_messages, bool any_feed_has_unread_messages);
|
||||
|
@ -15,12 +15,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "gui/dialogs/formcategorydetails.h"
|
||||
#include "services/standard/gui/formstandardcategorydetails.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "core/rootitem.h"
|
||||
#include "core/category.h"
|
||||
#include "core/feedsmodel.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "gui/feedsview.h"
|
||||
#include "gui/baselineedit.h"
|
||||
@ -38,9 +38,7 @@
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
FormCategoryDetails::FormCategoryDetails(FeedsModel *model,
|
||||
QWidget *parent)
|
||||
: QDialog(parent),
|
||||
FormStandardCategoryDetails::FormStandardCategoryDetails(FeedsModel *model, QWidget *parent) : QDialog(parent),
|
||||
m_editableCategory(NULL),
|
||||
m_feedsModel(model) {
|
||||
initialize();
|
||||
@ -51,11 +49,11 @@ FormCategoryDetails::FormCategoryDetails(FeedsModel *model,
|
||||
onDescriptionChanged(QString());
|
||||
}
|
||||
|
||||
FormCategoryDetails::~FormCategoryDetails() {
|
||||
FormStandardCategoryDetails::~FormStandardCategoryDetails() {
|
||||
qDebug("Destroying FormCategoryDetails instance.");
|
||||
}
|
||||
|
||||
void FormCategoryDetails::createConnections() {
|
||||
void FormStandardCategoryDetails::createConnections() {
|
||||
// General connections.
|
||||
connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(apply()));
|
||||
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onTitleChanged(QString)));
|
||||
@ -67,7 +65,7 @@ void FormCategoryDetails::createConnections() {
|
||||
connect(m_actionUseDefaultIcon, SIGNAL(triggered()), this, SLOT(onUseDefaultIcon()));
|
||||
}
|
||||
|
||||
void FormCategoryDetails::setEditableCategory(Category *editable_category) {
|
||||
void FormStandardCategoryDetails::setEditableCategory(StandardCategory *editable_category) {
|
||||
m_editableCategory = editable_category;
|
||||
|
||||
m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) editable_category->parent())));
|
||||
@ -76,7 +74,7 @@ void FormCategoryDetails::setEditableCategory(Category *editable_category) {
|
||||
m_ui->m_btnIcon->setIcon(editable_category->icon());
|
||||
}
|
||||
|
||||
int FormCategoryDetails::exec(Category *input_category, RootItem *parent_to_select) {
|
||||
int FormStandardCategoryDetails::exec(StandardCategory *input_category, RootItem *parent_to_select) {
|
||||
// Load categories.
|
||||
loadCategories(m_feedsModel->allCategories().values(), m_feedsModel->rootItem(), input_category);
|
||||
|
||||
@ -112,9 +110,9 @@ int FormCategoryDetails::exec(Category *input_category, RootItem *parent_to_sele
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
void FormCategoryDetails::apply() {
|
||||
void FormStandardCategoryDetails::apply() {
|
||||
RootItem *parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
|
||||
Category *new_category = new Category();
|
||||
StandardCategory *new_category = new StandardCategory();
|
||||
|
||||
new_category->setTitle(m_ui->m_txtTitle->lineEdit()->text());
|
||||
new_category->setCreationDate(QDateTime::currentDateTime());
|
||||
@ -147,7 +145,7 @@ void FormCategoryDetails::apply() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormCategoryDetails::onTitleChanged(const QString &new_title){
|
||||
void FormStandardCategoryDetails::onTitleChanged(const QString &new_title){
|
||||
if (new_title.simplified().size() >= MIN_CATEGORY_NAME_LENGTH) {
|
||||
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
m_ui->m_txtTitle->setStatus(WidgetWithStatus::Ok, tr("Category name is ok."));
|
||||
@ -158,7 +156,7 @@ void FormCategoryDetails::onTitleChanged(const QString &new_title){
|
||||
}
|
||||
}
|
||||
|
||||
void FormCategoryDetails::onDescriptionChanged(const QString &new_description) {
|
||||
void FormStandardCategoryDetails::onDescriptionChanged(const QString &new_description) {
|
||||
if (new_description.simplified().isEmpty()) {
|
||||
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty."));
|
||||
}
|
||||
@ -167,11 +165,11 @@ void FormCategoryDetails::onDescriptionChanged(const QString &new_description) {
|
||||
}
|
||||
}
|
||||
|
||||
void FormCategoryDetails::onNoIconSelected() {
|
||||
void FormStandardCategoryDetails::onNoIconSelected() {
|
||||
m_ui->m_btnIcon->setIcon(QIcon());
|
||||
}
|
||||
|
||||
void FormCategoryDetails::onLoadIconFromFile() {
|
||||
void FormStandardCategoryDetails::onLoadIconFromFile() {
|
||||
QFileDialog dialog(this, tr("Select icon file for the category"),
|
||||
qApp->homeFolderPath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)"));
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
@ -190,12 +188,12 @@ void FormCategoryDetails::onLoadIconFromFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormCategoryDetails::onUseDefaultIcon() {
|
||||
void FormStandardCategoryDetails::onUseDefaultIcon() {
|
||||
m_ui->m_btnIcon->setIcon(qApp->icons()->fromTheme(QSL("folder-category")));
|
||||
}
|
||||
|
||||
void FormCategoryDetails::initialize() {
|
||||
m_ui = new Ui::FormCategoryDetails();
|
||||
void FormStandardCategoryDetails::initialize() {
|
||||
m_ui = new Ui::FormStandardCategoryDetails();
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// Set text boxes.
|
||||
@ -241,14 +239,14 @@ void FormCategoryDetails::initialize() {
|
||||
m_ui->m_txtTitle->lineEdit()->setFocus(Qt::TabFocusReason);
|
||||
}
|
||||
|
||||
void FormCategoryDetails::loadCategories(const QList<Category*> categories,
|
||||
void FormStandardCategoryDetails::loadCategories(const QList<StandardCategory*> categories,
|
||||
RootItem *root_item,
|
||||
Category *input_category) {
|
||||
StandardCategory *input_category) {
|
||||
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||
root_item->title(),
|
||||
QVariant::fromValue((void*) root_item));
|
||||
|
||||
foreach (Category *category, categories) {
|
||||
foreach (StandardCategory *category, categories) {
|
||||
if (input_category != NULL && (category == input_category || category->isChildOf(input_category))) {
|
||||
// This category cannot be selected as the new
|
||||
// parent for currently edited category, so
|
24
src/gui/dialogs/formcategorydetails.h → src/services/standard/gui/formstandardcategorydetails.h
Normal file → Executable file
24
src/gui/dialogs/formcategorydetails.h → src/services/standard/gui/formstandardcategorydetails.h
Normal file → Executable file
@ -18,33 +18,33 @@
|
||||
#ifndef FORMCATEGORYDETAILS_H
|
||||
#define FORMCATEGORYDETAILS_H
|
||||
|
||||
#include "ui_formcategorydetails.h"
|
||||
#include "ui_formstandardcategorydetails.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class FormCategoryDetails;
|
||||
class FormStandardCategoryDetails;
|
||||
}
|
||||
|
||||
class Category;
|
||||
class Category;
|
||||
class StandardCategory;
|
||||
class StandardCategory;
|
||||
class FeedsModel;
|
||||
class RootItem;
|
||||
class QMenu;
|
||||
class QAction;
|
||||
|
||||
class FormCategoryDetails : public QDialog {
|
||||
class FormStandardCategoryDetails : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit FormCategoryDetails(FeedsModel *model, QWidget *parent = 0);
|
||||
virtual ~FormCategoryDetails();
|
||||
explicit FormStandardCategoryDetails(FeedsModel *model, QWidget *parent = 0);
|
||||
virtual ~FormStandardCategoryDetails();
|
||||
|
||||
public slots:
|
||||
// Executes add/edit standard category dialog.
|
||||
int exec(Category *input_category, RootItem *parent_to_select);
|
||||
int exec(StandardCategory *input_category, RootItem *parent_to_select);
|
||||
|
||||
protected slots:
|
||||
// Applies changes.
|
||||
@ -64,7 +64,7 @@ class FormCategoryDetails : public QDialog {
|
||||
void createConnections();
|
||||
|
||||
// Sets the category which will be edited.
|
||||
void setEditableCategory(Category *editable_category);
|
||||
void setEditableCategory(StandardCategory *editable_category);
|
||||
|
||||
// Initializes the dialog.
|
||||
void initialize();
|
||||
@ -72,11 +72,11 @@ class FormCategoryDetails : public QDialog {
|
||||
// Loads categories into the dialog + give root "category"
|
||||
// and make sure that no childs of input category (including)
|
||||
// input category are loaded.
|
||||
void loadCategories(const QList<Category*> categories, RootItem *root_item, Category *input_category);
|
||||
void loadCategories(const QList<StandardCategory*> categories, RootItem *root_item, StandardCategory *input_category);
|
||||
|
||||
private:
|
||||
Ui::FormCategoryDetails *m_ui;
|
||||
Category *m_editableCategory;
|
||||
Ui::FormStandardCategoryDetails *m_ui;
|
||||
StandardCategory *m_editableCategory;
|
||||
FeedsModel *m_feedsModel;
|
||||
|
||||
QMenu *m_iconMenu;
|
6
src/gui/dialogs/formcategorydetails.ui → src/services/standard/gui/formstandardcategorydetails.ui
Normal file → Executable file
6
src/gui/dialogs/formcategorydetails.ui → src/services/standard/gui/formstandardcategorydetails.ui
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FormCategoryDetails</class>
|
||||
<widget class="QDialog" name="FormCategoryDetails">
|
||||
<class>FormStandardCategoryDetails</class>
|
||||
<widget class="QDialog" name="FormStandardCategoryDetails">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -153,7 +153,7 @@
|
||||
<connection>
|
||||
<sender>m_buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>FormCategoryDetails</receiver>
|
||||
<receiver>FormStandardCategoryDetails</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
@ -15,13 +15,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "gui/dialogs/formfeeddetails.h"
|
||||
#include "services/standard/gui/formstandardfeeddetails.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "core/feedsmodel.h"
|
||||
#include "core/rootitem.h"
|
||||
#include "core/category.h"
|
||||
#include "core/feed.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "network-web/networkfactory.h"
|
||||
@ -39,7 +39,7 @@
|
||||
#include <QMimeData>
|
||||
|
||||
|
||||
FormFeedDetails::FormFeedDetails(FeedsModel *model, QWidget *parent)
|
||||
FormStandardFeedDetails::FormStandardFeedDetails(FeedsModel *model, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
m_editableFeed(NULL),
|
||||
m_feedsModel(model) {
|
||||
@ -54,11 +54,11 @@ FormFeedDetails::FormFeedDetails(FeedsModel *model, QWidget *parent)
|
||||
onPasswordChanged(QString());
|
||||
}
|
||||
|
||||
FormFeedDetails::~FormFeedDetails() {
|
||||
FormStandardFeedDetails::~FormStandardFeedDetails() {
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
int FormFeedDetails::exec(Feed *input_feed, RootItem *parent_to_select) {
|
||||
int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select) {
|
||||
// Load categories.
|
||||
loadCategories(m_feedsModel->allCategories().values(), m_feedsModel->rootItem());
|
||||
|
||||
@ -103,7 +103,7 @@ int FormFeedDetails::exec(Feed *input_feed, RootItem *parent_to_select) {
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
void FormFeedDetails::onTitleChanged(const QString &new_title){
|
||||
void FormStandardFeedDetails::onTitleChanged(const QString &new_title){
|
||||
if (new_title.simplified().size() >= MIN_CATEGORY_NAME_LENGTH) {
|
||||
m_ui->m_txtTitle->setStatus(LineEditWithStatus::Ok, tr("Feed name is ok."));
|
||||
}
|
||||
@ -114,7 +114,7 @@ void FormFeedDetails::onTitleChanged(const QString &new_title){
|
||||
checkOkButtonEnabled();
|
||||
}
|
||||
|
||||
void FormFeedDetails::onDescriptionChanged(const QString &new_description) {
|
||||
void FormStandardFeedDetails::onDescriptionChanged(const QString &new_description) {
|
||||
if (new_description.simplified().isEmpty()) {
|
||||
m_ui->m_txtDescription->setStatus(LineEditWithStatus::Warning, tr("Description is empty."));
|
||||
}
|
||||
@ -123,7 +123,7 @@ void FormFeedDetails::onDescriptionChanged(const QString &new_description) {
|
||||
}
|
||||
}
|
||||
|
||||
void FormFeedDetails::onUrlChanged(const QString &new_url) {
|
||||
void FormStandardFeedDetails::onUrlChanged(const QString &new_url) {
|
||||
if (QRegExp(URL_REGEXP).exactMatch(new_url)) {
|
||||
// New url is well-formed.
|
||||
m_ui->m_txtUrl->setStatus(LineEditWithStatus::Ok, tr("The url is ok."));
|
||||
@ -140,7 +140,7 @@ void FormFeedDetails::onUrlChanged(const QString &new_url) {
|
||||
checkOkButtonEnabled();
|
||||
}
|
||||
|
||||
void FormFeedDetails::onUsernameChanged(const QString &new_username) {
|
||||
void FormStandardFeedDetails::onUsernameChanged(const QString &new_username) {
|
||||
bool is_username_ok = !m_ui->m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty();
|
||||
|
||||
m_ui->m_txtUsername->setStatus(is_username_ok ?
|
||||
@ -151,7 +151,7 @@ void FormFeedDetails::onUsernameChanged(const QString &new_username) {
|
||||
tr("Username is empty."));
|
||||
}
|
||||
|
||||
void FormFeedDetails::onPasswordChanged(const QString &new_password) {
|
||||
void FormStandardFeedDetails::onPasswordChanged(const QString &new_password) {
|
||||
bool is_password_ok = !m_ui->m_gbAuthentication->isChecked() || !new_password.simplified().isEmpty();
|
||||
|
||||
m_ui->m_txtPassword->setStatus(is_password_ok ?
|
||||
@ -162,27 +162,27 @@ void FormFeedDetails::onPasswordChanged(const QString &new_password) {
|
||||
tr("Password is empty."));
|
||||
}
|
||||
|
||||
void FormFeedDetails::onAuthenticationSwitched() {
|
||||
void FormStandardFeedDetails::onAuthenticationSwitched() {
|
||||
onUsernameChanged(m_ui->m_txtUsername->lineEdit()->text());
|
||||
onPasswordChanged(m_ui->m_txtPassword->lineEdit()->text());
|
||||
}
|
||||
|
||||
void FormFeedDetails::onAutoUpdateTypeChanged(int new_index) {
|
||||
Feed::AutoUpdateType auto_update_type = static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt());
|
||||
void FormStandardFeedDetails::onAutoUpdateTypeChanged(int new_index) {
|
||||
StandardFeed::AutoUpdateType auto_update_type = static_cast<StandardFeed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt());
|
||||
|
||||
switch (auto_update_type) {
|
||||
case Feed::DontAutoUpdate:
|
||||
case Feed::DefaultAutoUpdate:
|
||||
case StandardFeed::DontAutoUpdate:
|
||||
case StandardFeed::DefaultAutoUpdate:
|
||||
m_ui->m_spinAutoUpdateInterval->setEnabled(false);
|
||||
break;
|
||||
|
||||
case Feed::SpecificAutoUpdate:
|
||||
case StandardFeed::SpecificAutoUpdate:
|
||||
default:
|
||||
m_ui->m_spinAutoUpdateInterval->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void FormFeedDetails::checkOkButtonEnabled() {
|
||||
void FormStandardFeedDetails::checkOkButtonEnabled() {
|
||||
LineEditWithStatus::StatusType title_status = m_ui->m_txtTitle->status();
|
||||
LineEditWithStatus::StatusType url_status = m_ui->m_txtUrl->status();
|
||||
|
||||
@ -191,11 +191,11 @@ void FormFeedDetails::checkOkButtonEnabled() {
|
||||
url_status == LineEditWithStatus::Warning));
|
||||
}
|
||||
|
||||
void FormFeedDetails::onNoIconSelected() {
|
||||
void FormStandardFeedDetails::onNoIconSelected() {
|
||||
m_ui->m_btnIcon->setIcon(QIcon());
|
||||
}
|
||||
|
||||
void FormFeedDetails::onLoadIconFromFile() {
|
||||
void FormStandardFeedDetails::onLoadIconFromFile() {
|
||||
QFileDialog dialog(this, tr("Select icon file for the feed"),
|
||||
qApp->homeFolderPath(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)"));
|
||||
dialog.setFileMode(QFileDialog::ExistingFile);
|
||||
@ -214,14 +214,14 @@ void FormFeedDetails::onLoadIconFromFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormFeedDetails::onUseDefaultIcon() {
|
||||
void FormStandardFeedDetails::onUseDefaultIcon() {
|
||||
m_ui->m_btnIcon->setIcon(qApp->icons()->fromTheme(QSL("folder-feed")));
|
||||
}
|
||||
|
||||
void FormFeedDetails::apply() {
|
||||
void FormStandardFeedDetails::apply() {
|
||||
RootItem *parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
|
||||
Feed::Type type = static_cast<Feed::Type>(m_ui->m_cmbType->itemData(m_ui->m_cmbType->currentIndex()).value<int>());
|
||||
Feed *new_feed = new Feed();
|
||||
StandardFeed::Type type = static_cast<StandardFeed::Type>(m_ui->m_cmbType->itemData(m_ui->m_cmbType->currentIndex()).value<int>());
|
||||
StandardFeed *new_feed = new StandardFeed();
|
||||
|
||||
// Setup data for new_feed.
|
||||
new_feed->setTitle(m_ui->m_txtTitle->lineEdit()->text());
|
||||
@ -234,7 +234,7 @@ void FormFeedDetails::apply() {
|
||||
new_feed->setPasswordProtected(m_ui->m_gbAuthentication->isChecked());
|
||||
new_feed->setUsername(m_ui->m_txtUsername->lineEdit()->text());
|
||||
new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text());
|
||||
new_feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||
new_feed->setAutoUpdateType(static_cast<StandardFeed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||
new_feed->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value());
|
||||
new_feed->setParent(parent);
|
||||
|
||||
@ -262,8 +262,8 @@ void FormFeedDetails::apply() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormFeedDetails::guessFeed() {
|
||||
QPair<Feed*, QNetworkReply::NetworkError> result = Feed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(),
|
||||
void FormStandardFeedDetails::guessFeed() {
|
||||
QPair<StandardFeed*, QNetworkReply::NetworkError> result = StandardFeed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(),
|
||||
m_ui->m_txtUsername->lineEdit()->text(),
|
||||
m_ui->m_txtPassword->lineEdit()->text());
|
||||
|
||||
@ -306,8 +306,8 @@ void FormFeedDetails::guessFeed() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormFeedDetails::guessIconOnly() {
|
||||
QPair<Feed*, QNetworkReply::NetworkError> result = Feed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(),
|
||||
void FormStandardFeedDetails::guessIconOnly() {
|
||||
QPair<StandardFeed*, QNetworkReply::NetworkError> result = StandardFeed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(),
|
||||
m_ui->m_txtUsername->lineEdit()->text(),
|
||||
m_ui->m_txtPassword->lineEdit()->text());
|
||||
|
||||
@ -337,7 +337,7 @@ void FormFeedDetails::guessIconOnly() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormFeedDetails::createConnections() {
|
||||
void FormStandardFeedDetails::createConnections() {
|
||||
// General connections.
|
||||
connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(apply()));
|
||||
connect(m_ui->m_txtTitle->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(onTitleChanged(QString)));
|
||||
@ -356,7 +356,7 @@ void FormFeedDetails::createConnections() {
|
||||
connect(m_actionUseDefaultIcon, SIGNAL(triggered()), this, SLOT(onUseDefaultIcon()));
|
||||
}
|
||||
|
||||
void FormFeedDetails::setEditableFeed(Feed *editable_feed) {
|
||||
void FormStandardFeedDetails::setEditableFeed(StandardFeed *editable_feed) {
|
||||
m_editableFeed = editable_feed;
|
||||
|
||||
m_ui->m_cmbParentCategory->setCurrentIndex(m_ui->m_cmbParentCategory->findData(QVariant::fromValue((void*) editable_feed->parent())));
|
||||
@ -373,8 +373,8 @@ void FormFeedDetails::setEditableFeed(Feed *editable_feed) {
|
||||
m_ui->m_spinAutoUpdateInterval->setValue(editable_feed->autoUpdateInitialInterval());
|
||||
}
|
||||
|
||||
void FormFeedDetails::initialize() {
|
||||
m_ui = new Ui::FormFeedDetails();
|
||||
void FormStandardFeedDetails::initialize() {
|
||||
m_ui = new Ui::FormStandardFeedDetails();
|
||||
m_ui->setupUi(this);
|
||||
|
||||
// Set flags and attributes.
|
||||
@ -405,10 +405,10 @@ void FormFeedDetails::initialize() {
|
||||
#endif
|
||||
|
||||
// Add standard feed types.
|
||||
m_ui->m_cmbType->addItem(Feed::typeToString(Feed::Atom10), QVariant::fromValue((int) Feed::Atom10));
|
||||
m_ui->m_cmbType->addItem(Feed::typeToString(Feed::Rdf), QVariant::fromValue((int) Feed::Rdf));
|
||||
m_ui->m_cmbType->addItem(Feed::typeToString(Feed::Rss0X), QVariant::fromValue((int) Feed::Rss0X));
|
||||
m_ui->m_cmbType->addItem(Feed::typeToString(Feed::Rss2X), QVariant::fromValue((int) Feed::Rss2X));
|
||||
m_ui->m_cmbType->addItem(StandardFeed::typeToString(StandardFeed::Atom10), QVariant::fromValue((int) StandardFeed::Atom10));
|
||||
m_ui->m_cmbType->addItem(StandardFeed::typeToString(StandardFeed::Rdf), QVariant::fromValue((int) StandardFeed::Rdf));
|
||||
m_ui->m_cmbType->addItem(StandardFeed::typeToString(StandardFeed::Rss0X), QVariant::fromValue((int) StandardFeed::Rss0X));
|
||||
m_ui->m_cmbType->addItem(StandardFeed::typeToString(StandardFeed::Rss2X), QVariant::fromValue((int) StandardFeed::Rss2X));
|
||||
|
||||
// Load available encodings.
|
||||
QList<QByteArray> encodings = QTextCodec::availableCodecs();
|
||||
@ -449,9 +449,9 @@ void FormFeedDetails::initialize() {
|
||||
|
||||
// Setup auto-update options.
|
||||
m_ui->m_spinAutoUpdateInterval->setValue(DEFAULT_AUTO_UPDATE_INTERVAL);
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update using global interval"), QVariant::fromValue((int) Feed::DefaultAutoUpdate));
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update every"), QVariant::fromValue((int) Feed::SpecificAutoUpdate));
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Do not auto-update at all"), QVariant::fromValue((int) Feed::DontAutoUpdate));
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update using global interval"), QVariant::fromValue((int) StandardFeed::DefaultAutoUpdate));
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update every"), QVariant::fromValue((int) StandardFeed::SpecificAutoUpdate));
|
||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Do not auto-update at all"), QVariant::fromValue((int) StandardFeed::DontAutoUpdate));
|
||||
|
||||
// Set tab order.
|
||||
setTabOrder(m_ui->m_cmbParentCategory, m_ui->m_cmbType);
|
||||
@ -475,13 +475,13 @@ void FormFeedDetails::initialize() {
|
||||
m_ui->m_txtUrl->lineEdit()->setFocus(Qt::TabFocusReason);
|
||||
}
|
||||
|
||||
void FormFeedDetails::loadCategories(const QList<Category*> categories,
|
||||
void FormStandardFeedDetails::loadCategories(const QList<StandardCategory*> categories,
|
||||
RootItem *root_item) {
|
||||
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||
root_item->title(),
|
||||
QVariant::fromValue((void*) root_item));
|
||||
|
||||
foreach (Category *category, categories) {
|
||||
foreach (StandardCategory *category, categories) {
|
||||
m_ui->m_cmbParentCategory->addItem(category->data(FDS_MODEL_TITLE_INDEX,
|
||||
Qt::DecorationRole).value<QIcon>(),
|
||||
category->title(),
|
26
src/gui/dialogs/formfeeddetails.h → src/services/standard/gui/formstandardfeeddetails.h
Normal file → Executable file
26
src/gui/dialogs/formfeeddetails.h → src/services/standard/gui/formstandardfeeddetails.h
Normal file → Executable file
@ -18,31 +18,31 @@
|
||||
#ifndef FORMSTANDARDFEEDDETAILS_H
|
||||
#define FORMSTANDARDFEEDDETAILS_H
|
||||
|
||||
#include "ui_formfeeddetails.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_formstandardfeeddetails.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class FormFeedDetails;
|
||||
class FormStandardFeedDetails;
|
||||
}
|
||||
|
||||
class FeedsModel;
|
||||
class Feed;
|
||||
class Category;
|
||||
class StandardFeed;
|
||||
class StandardCategory;
|
||||
class RootItem;
|
||||
|
||||
class FormFeedDetails : public QDialog {
|
||||
class FormStandardFeedDetails : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit FormFeedDetails(FeedsModel *model, QWidget *parent = 0);
|
||||
virtual ~FormFeedDetails();
|
||||
explicit FormStandardFeedDetails(FeedsModel *model, QWidget *parent = 0);
|
||||
virtual ~FormStandardFeedDetails();
|
||||
|
||||
public slots:
|
||||
// Executes add/edit standard feed dialog.
|
||||
int exec(Feed *input_feed, RootItem *parent_to_select);
|
||||
int exec(StandardFeed *input_feed, RootItem *parent_to_select);
|
||||
|
||||
protected slots:
|
||||
// Applies changes.
|
||||
@ -72,18 +72,18 @@ class FormFeedDetails : public QDialog {
|
||||
void createConnections();
|
||||
|
||||
// Sets the feed which will be edited.
|
||||
void setEditableFeed(Feed *editable_feed);
|
||||
void setEditableFeed(StandardFeed *editable_feed);
|
||||
|
||||
// Initializes the dialog.
|
||||
void initialize();
|
||||
|
||||
// Loads categories into the dialog from the model.
|
||||
void loadCategories(const QList<Category*> categories,
|
||||
void loadCategories(const QList<StandardCategory*> categories,
|
||||
RootItem *root_item);
|
||||
|
||||
private:
|
||||
Ui::FormFeedDetails *m_ui;
|
||||
Feed *m_editableFeed;
|
||||
Ui::FormStandardFeedDetails *m_ui;
|
||||
StandardFeed *m_editableFeed;
|
||||
FeedsModel *m_feedsModel;
|
||||
|
||||
QMenu *m_iconMenu;
|
6
src/gui/dialogs/formfeeddetails.ui → src/services/standard/gui/formstandardfeeddetails.ui
Normal file → Executable file
6
src/gui/dialogs/formfeeddetails.ui → src/services/standard/gui/formstandardfeeddetails.ui
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FormFeedDetails</class>
|
||||
<widget class="QDialog" name="FormFeedDetails">
|
||||
<class>FormStandardFeedDetails</class>
|
||||
<widget class="QDialog" name="FormStandardFeedDetails">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -325,7 +325,7 @@
|
||||
<connection>
|
||||
<sender>m_buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>FormFeedDetails</receiver>
|
||||
<receiver>FormStandardFeedDetails</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
@ -15,9 +15,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "gui/dialogs/formimportexport.h"
|
||||
#include "services/standard/gui/formstandardimportexport.h"
|
||||
|
||||
#include "core/feedsimportexportmodel.h"
|
||||
#include "services/standard/standardfeedsimportexportmodel.h"
|
||||
#include "core/feedsmodel.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
@ -28,7 +28,8 @@
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
FormImportExport::FormImportExport(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormImportExport) {
|
||||
FormStandardImportExport::FormStandardImportExport(QWidget *parent)
|
||||
: QDialog(parent), m_ui(new Ui::FormStandardImportExport) {
|
||||
m_ui->setupUi(this);
|
||||
m_model = new FeedsImportExportModel(m_ui->m_treeFeeds);
|
||||
|
||||
@ -44,11 +45,11 @@ FormImportExport::FormImportExport(QWidget *parent) : QDialog(parent), m_ui(new
|
||||
connect(m_ui->m_btnUncheckAllItems, SIGNAL(clicked()), m_model, SLOT(uncheckAllItems()));
|
||||
}
|
||||
|
||||
FormImportExport::~FormImportExport() {
|
||||
FormStandardImportExport::~FormStandardImportExport() {
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void FormImportExport::setMode(const FeedsImportExportModel::Mode &mode) {
|
||||
void FormStandardImportExport::setMode(const FeedsImportExportModel::Mode &mode) {
|
||||
m_model->setMode(mode);
|
||||
|
||||
switch (mode) {
|
||||
@ -80,7 +81,7 @@ void FormImportExport::setMode(const FeedsImportExportModel::Mode &mode) {
|
||||
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
|
||||
}
|
||||
|
||||
void FormImportExport::selectFile() {
|
||||
void FormStandardImportExport::selectFile() {
|
||||
switch (m_model->mode()) {
|
||||
case FeedsImportExportModel::Import:
|
||||
selectImportFile();
|
||||
@ -96,7 +97,7 @@ void FormImportExport::selectFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormImportExport::selectExportFile() {
|
||||
void FormStandardImportExport::selectExportFile() {
|
||||
QString filter_opml20 = tr("OPML 2.0 files (*.opml)");
|
||||
|
||||
QString filter;
|
||||
@ -124,7 +125,7 @@ void FormImportExport::selectExportFile() {
|
||||
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setDisabled(selected_file.isEmpty());
|
||||
}
|
||||
|
||||
void FormImportExport::selectImportFile() {
|
||||
void FormStandardImportExport::selectImportFile() {
|
||||
QString filter_opml20 = tr("OPML 2.0 files (*.opml)");
|
||||
|
||||
QString filter;
|
||||
@ -148,7 +149,7 @@ void FormImportExport::selectImportFile() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormImportExport::parseImportFile(const QString &file_name) {
|
||||
void FormStandardImportExport::parseImportFile(const QString &file_name) {
|
||||
QFile input_file(file_name);
|
||||
QByteArray input_data;
|
||||
|
||||
@ -186,7 +187,7 @@ void FormImportExport::parseImportFile(const QString &file_name) {
|
||||
m_ui->m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(parsing_result);
|
||||
}
|
||||
|
||||
void FormImportExport::performAction() {
|
||||
void FormStandardImportExport::performAction() {
|
||||
switch (m_model->mode()) {
|
||||
case FeedsImportExportModel::Import:
|
||||
importFeeds();
|
||||
@ -201,7 +202,7 @@ void FormImportExport::performAction() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormImportExport::exportFeeds() {
|
||||
void FormStandardImportExport::exportFeeds() {
|
||||
switch (m_conversionType) {
|
||||
case OPML20: {
|
||||
QByteArray result_data;
|
||||
@ -237,7 +238,7 @@ void FormImportExport::exportFeeds() {
|
||||
}
|
||||
}
|
||||
|
||||
void FormImportExport::importFeeds() {
|
||||
void FormStandardImportExport::importFeeds() {
|
||||
QString output_message;
|
||||
|
||||
if (qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->mergeModel(m_model, output_message)) {
|
14
src/gui/dialogs/formimportexport.h → src/services/standard/gui/formstandardimportexport.h
Normal file → Executable file
14
src/gui/dialogs/formimportexport.h → src/services/standard/gui/formstandardimportexport.h
Normal file → Executable file
@ -20,15 +20,15 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_formimportexport.h"
|
||||
#include "core/feedsimportexportmodel.h"
|
||||
#include "ui_formstandardimportexport.h"
|
||||
#include "services/standard/standardfeedsimportexportmodel.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class FormExport;
|
||||
class FormStandardImportExport;
|
||||
}
|
||||
|
||||
class FormImportExport : public QDialog {
|
||||
class FormStandardImportExport : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -37,8 +37,8 @@ class FormImportExport : public QDialog {
|
||||
};
|
||||
|
||||
// Constructors.
|
||||
explicit FormImportExport(QWidget *parent = 0);
|
||||
virtual ~FormImportExport();
|
||||
explicit FormStandardImportExport(QWidget *parent = 0);
|
||||
virtual ~FormStandardImportExport();
|
||||
|
||||
void setMode(const FeedsImportExportModel::Mode &mode);
|
||||
|
||||
@ -54,7 +54,7 @@ class FormImportExport : public QDialog {
|
||||
void exportFeeds();
|
||||
void importFeeds();
|
||||
|
||||
Ui::FormImportExport *m_ui;
|
||||
Ui::FormStandardImportExport *m_ui;
|
||||
ConversionType m_conversionType;
|
||||
FeedsImportExportModel *m_model;
|
||||
};
|
6
src/gui/dialogs/formimportexport.ui → src/services/standard/gui/formstandardimportexport.ui
Normal file → Executable file
6
src/gui/dialogs/formimportexport.ui → src/services/standard/gui/formstandardimportexport.ui
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FormImportExport</class>
|
||||
<widget class="QDialog" name="FormImportExport">
|
||||
<class>FormStandardImportExport</class>
|
||||
<widget class="QDialog" name="FormStandardImportExport">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -149,7 +149,7 @@
|
||||
<connection>
|
||||
<sender>m_buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>FormImportExport</receiver>
|
||||
<receiver>FormStandardImportExport</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
22
src/core/category.cpp → src/services/standard/standardcategory.cpp
Normal file → Executable file
22
src/core/category.cpp → src/services/standard/standardcategory.cpp
Normal file → Executable file
@ -15,7 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "core/category.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/databasefactory.h"
|
||||
@ -29,11 +29,11 @@
|
||||
#include <QSqlError>
|
||||
|
||||
|
||||
Category::Category(RootItem *parent_item) : RootItem(parent_item) {
|
||||
StandardCategory::StandardCategory(RootItem *parent_item) : RootItem(parent_item) {
|
||||
init();
|
||||
}
|
||||
|
||||
Category::Category(const Category &other)
|
||||
StandardCategory::StandardCategory(const StandardCategory &other)
|
||||
: RootItem(NULL) {
|
||||
m_kind = other.kind();
|
||||
m_id = other.id();
|
||||
@ -45,15 +45,15 @@ Category::Category(const Category &other)
|
||||
m_parentItem = other.parent();
|
||||
}
|
||||
|
||||
Category::~Category() {
|
||||
StandardCategory::~StandardCategory() {
|
||||
qDebug("Destroying Category instance.");
|
||||
}
|
||||
|
||||
void Category::init() {
|
||||
void StandardCategory::init() {
|
||||
m_kind = RootItem::Cattegory;
|
||||
}
|
||||
|
||||
QVariant Category::data(int column, int role) const {
|
||||
QVariant StandardCategory::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::ToolTipRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
@ -121,7 +121,7 @@ QVariant Category::data(int column, int role) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool Category::removeItself() {
|
||||
bool StandardCategory::removeItself() {
|
||||
bool children_removed = true;
|
||||
|
||||
// Remove all child items (feeds, categories.)
|
||||
@ -146,7 +146,7 @@ bool Category::removeItself() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Category::addItself(RootItem *parent) {
|
||||
bool StandardCategory::addItself(RootItem *parent) {
|
||||
// Now, add category to persistent storage.
|
||||
// Children are removed, remove this standard category too.
|
||||
QSqlDatabase database = qApp->database()->connection(QSL("Category"), DatabaseFactory::FromSettings);
|
||||
@ -185,10 +185,10 @@ bool Category::addItself(RootItem *parent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Category::editItself(Category *new_category_data) {
|
||||
bool StandardCategory::editItself(StandardCategory *new_category_data) {
|
||||
QSqlDatabase database = qApp->database()->connection(QSL("Category"), DatabaseFactory::FromSettings);
|
||||
QSqlQuery query_update_category(database);
|
||||
Category *original_category = this;
|
||||
StandardCategory *original_category = this;
|
||||
RootItem *new_parent = new_category_data->parent();
|
||||
|
||||
query_update_category.setForwardOnly(true);
|
||||
@ -215,7 +215,7 @@ bool Category::editItself(Category *new_category_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Category::Category(const QSqlRecord &record) : RootItem(NULL) {
|
||||
StandardCategory::StandardCategory(const QSqlRecord &record) : RootItem(NULL) {
|
||||
init();
|
||||
|
||||
setId(record.value(CAT_DB_ID_INDEX).toInt());
|
12
src/core/category.h → src/services/standard/standardcategory.h
Normal file → Executable file
12
src/core/category.h → src/services/standard/standardcategory.h
Normal file → Executable file
@ -29,15 +29,15 @@ class FeedsModel;
|
||||
// Base class for all categories contained in FeedsModel.
|
||||
// NOTE: This class should be derived to create PARTICULAR category types.
|
||||
// NOTE: This class should not be instantiated directly.
|
||||
class Category : public RootItem {
|
||||
class StandardCategory : public RootItem {
|
||||
Q_DECLARE_TR_FUNCTIONS(Category)
|
||||
|
||||
public:
|
||||
// Constructors and destructors
|
||||
explicit Category(RootItem *parent_item = NULL);
|
||||
explicit Category(const Category &other);
|
||||
explicit Category(const QSqlRecord &record);
|
||||
virtual ~Category();
|
||||
explicit StandardCategory(RootItem *parent_item = NULL);
|
||||
explicit StandardCategory(const StandardCategory &other);
|
||||
explicit StandardCategory(const QSqlRecord &record);
|
||||
virtual ~StandardCategory();
|
||||
|
||||
// Returns the actual data representation of standard category.
|
||||
QVariant data(int column, int role) const;
|
||||
@ -47,7 +47,7 @@ class Category : public RootItem {
|
||||
bool removeItself();
|
||||
|
||||
bool addItself(RootItem *parent);
|
||||
bool editItself(Category *new_category_data);
|
||||
bool editItself(StandardCategory *new_category_data);
|
||||
|
||||
private:
|
||||
void init();
|
60
src/core/feed.cpp → src/services/standard/standardfeed.cpp
Normal file → Executable file
60
src/core/feed.cpp → src/services/standard/standardfeed.cpp
Normal file → Executable file
@ -15,7 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "core/feed.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "core/parsingfactory.h"
|
||||
@ -38,7 +38,7 @@
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
|
||||
void Feed::init() {
|
||||
void StandardFeed::init() {
|
||||
m_passwordProtected = false;
|
||||
m_username = QString();
|
||||
m_password = QString();
|
||||
@ -55,12 +55,12 @@ void Feed::init() {
|
||||
m_kind = RootItem::Feeed;
|
||||
}
|
||||
|
||||
Feed::Feed(RootItem *parent_item)
|
||||
StandardFeed::StandardFeed(RootItem *parent_item)
|
||||
: RootItem(parent_item) {
|
||||
init();
|
||||
}
|
||||
|
||||
Feed::Feed(const Feed &other)
|
||||
StandardFeed::StandardFeed(const StandardFeed &other)
|
||||
: RootItem(NULL) {
|
||||
m_passwordProtected = other.passwordProtected();
|
||||
m_username = other.username();
|
||||
@ -85,24 +85,24 @@ Feed::Feed(const Feed &other)
|
||||
m_description = other.description();
|
||||
}
|
||||
|
||||
Feed::~Feed() {
|
||||
StandardFeed::~StandardFeed() {
|
||||
qDebug("Destroying Feed instance.");
|
||||
}
|
||||
|
||||
int Feed::childCount() const {
|
||||
int StandardFeed::childCount() const {
|
||||
// Because feed has no children.
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Feed::countOfAllMessages() const {
|
||||
int StandardFeed::countOfAllMessages() const {
|
||||
return m_totalCount;
|
||||
}
|
||||
|
||||
int Feed::countOfUnreadMessages() const {
|
||||
int StandardFeed::countOfUnreadMessages() const {
|
||||
return m_unreadCount;
|
||||
}
|
||||
|
||||
QString Feed::typeToString(Feed::Type type) {
|
||||
QString StandardFeed::typeToString(StandardFeed::Type type) {
|
||||
switch (type) {
|
||||
case Atom10:
|
||||
return QSL("ATOM 1.0");
|
||||
@ -119,7 +119,7 @@ QString Feed::typeToString(Feed::Type type) {
|
||||
}
|
||||
}
|
||||
|
||||
void Feed::updateCounts(bool including_total_count, bool update_feed_statuses) {
|
||||
void StandardFeed::updateCounts(bool including_total_count, bool update_feed_statuses) {
|
||||
QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings);
|
||||
QSqlQuery query_all(database);
|
||||
|
||||
@ -143,8 +143,8 @@ void Feed::updateCounts(bool including_total_count, bool update_feed_statuses) {
|
||||
}
|
||||
}
|
||||
|
||||
void Feed::fetchMetadataForItself() {
|
||||
QPair<Feed*,QNetworkReply::NetworkError> metadata = guessFeed(url(), username(), password());
|
||||
void StandardFeed::fetchMetadataForItself() {
|
||||
QPair<StandardFeed*,QNetworkReply::NetworkError> metadata = guessFeed(url(), username(), password());
|
||||
|
||||
if (metadata.first != NULL && metadata.second == QNetworkReply::NoError) {
|
||||
// Some properties are not updated when new metadata are fetched.
|
||||
@ -166,8 +166,8 @@ void Feed::fetchMetadataForItself() {
|
||||
}
|
||||
}
|
||||
|
||||
QPair<Feed*,QNetworkReply::NetworkError> Feed::guessFeed(const QString &url, const QString &username, const QString &password) {
|
||||
QPair<Feed*,QNetworkReply::NetworkError> result; result.first = NULL;
|
||||
QPair<StandardFeed*,QNetworkReply::NetworkError> StandardFeed::guessFeed(const QString &url, const QString &username, const QString &password) {
|
||||
QPair<StandardFeed*,QNetworkReply::NetworkError> result; result.first = NULL;
|
||||
|
||||
QByteArray feed_contents;
|
||||
NetworkResult network_result = NetworkFactory::downloadFeedFile(url,
|
||||
@ -196,7 +196,7 @@ QPair<Feed*,QNetworkReply::NetworkError> Feed::guessFeed(const QString &url, con
|
||||
}
|
||||
|
||||
if (result.first == NULL) {
|
||||
result.first = new Feed();
|
||||
result.first = new StandardFeed();
|
||||
}
|
||||
|
||||
QTextCodec *custom_codec = QTextCodec::codecForName(xml_schema_encoding.toLocal8Bit());
|
||||
@ -308,7 +308,7 @@ QPair<Feed*,QNetworkReply::NetworkError> Feed::guessFeed(const QString &url, con
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariant Feed::data(int column, int role) const {
|
||||
QVariant StandardFeed::data(int column, int role) const {
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||
@ -373,7 +373,7 @@ QVariant Feed::data(int column, int role) const {
|
||||
"Network status: %6\n"
|
||||
"Encoding: %4\n"
|
||||
"Auto-update status: %5").arg(m_title,
|
||||
Feed::typeToString(m_type),
|
||||
StandardFeed::typeToString(m_type),
|
||||
m_description.isEmpty() ? QString() : QString('\n') + m_description,
|
||||
m_encoding,
|
||||
auto_update_string,
|
||||
@ -415,7 +415,7 @@ QVariant Feed::data(int column, int role) const {
|
||||
}
|
||||
}
|
||||
|
||||
int Feed::update() {
|
||||
int StandardFeed::update() {
|
||||
QByteArray feed_contents;
|
||||
int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||
m_networkError = NetworkFactory::downloadFeedFile(url(), download_timeout, feed_contents,
|
||||
@ -448,16 +448,16 @@ int Feed::update() {
|
||||
QList<Message> messages;
|
||||
|
||||
switch (type()) {
|
||||
case Feed::Rss0X:
|
||||
case Feed::Rss2X:
|
||||
case StandardFeed::Rss0X:
|
||||
case StandardFeed::Rss2X:
|
||||
messages = ParsingFactory::parseAsRSS20(formatted_feed_contents);
|
||||
break;
|
||||
|
||||
case Feed::Rdf:
|
||||
case StandardFeed::Rdf:
|
||||
messages = ParsingFactory::parseAsRDF(formatted_feed_contents);
|
||||
break;
|
||||
|
||||
case Feed::Atom10:
|
||||
case StandardFeed::Atom10:
|
||||
messages = ParsingFactory::parseAsATOM10(formatted_feed_contents);
|
||||
|
||||
default:
|
||||
@ -467,7 +467,7 @@ int Feed::update() {
|
||||
return updateMessages(messages);
|
||||
}
|
||||
|
||||
bool Feed::removeItself() {
|
||||
bool StandardFeed::removeItself() {
|
||||
QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings);
|
||||
QSqlQuery query_remove(database);
|
||||
|
||||
@ -488,7 +488,7 @@ bool Feed::removeItself() {
|
||||
return query_remove.exec();
|
||||
}
|
||||
|
||||
bool Feed::addItself(RootItem *parent) {
|
||||
bool StandardFeed::addItself(RootItem *parent) {
|
||||
// Now, add feed to persistent storage.
|
||||
QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings);
|
||||
QSqlQuery query_add_feed(database);
|
||||
@ -532,10 +532,10 @@ bool Feed::addItself(RootItem *parent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Feed::editItself(Feed *new_feed_data) {
|
||||
bool StandardFeed::editItself(StandardFeed *new_feed_data) {
|
||||
QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings);
|
||||
QSqlQuery query_update_feed(database);
|
||||
Feed *original_feed = this;
|
||||
StandardFeed *original_feed = this;
|
||||
RootItem *new_parent = new_feed_data->parent();
|
||||
|
||||
query_update_feed.setForwardOnly(true);
|
||||
@ -579,7 +579,7 @@ bool Feed::editItself(Feed *new_feed_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int Feed::updateMessages(const QList<Message> &messages) {
|
||||
int StandardFeed::updateMessages(const QList<Message> &messages) {
|
||||
int feed_id = id();
|
||||
int updated_messages = 0;
|
||||
QSqlDatabase database = qApp->database()->connection(QSL("Feed"), DatabaseFactory::FromSettings);
|
||||
@ -706,11 +706,11 @@ int Feed::updateMessages(const QList<Message> &messages) {
|
||||
return updated_messages;
|
||||
}
|
||||
|
||||
QNetworkReply::NetworkError Feed::networkError() const {
|
||||
QNetworkReply::NetworkError StandardFeed::networkError() const {
|
||||
return m_networkError;
|
||||
}
|
||||
|
||||
Feed::Feed(const QSqlRecord &record) : RootItem(NULL) {
|
||||
StandardFeed::StandardFeed(const QSqlRecord &record) : RootItem(NULL) {
|
||||
m_kind = RootItem::Feeed;
|
||||
|
||||
setTitle(record.value(FDS_DB_TITLE_INDEX).toString());
|
||||
@ -723,7 +723,7 @@ Feed::Feed(const QSqlRecord &record) : RootItem(NULL) {
|
||||
setPasswordProtected(record.value(FDS_DB_PROTECTED_INDEX).toBool());
|
||||
setUsername(record.value(FDS_DB_USERNAME_INDEX).toString());
|
||||
setPassword(TextFactory::decrypt(record.value(FDS_DB_PASSWORD_INDEX).toString()));
|
||||
setAutoUpdateType(static_cast<Feed::AutoUpdateType>(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt()));
|
||||
setAutoUpdateType(static_cast<StandardFeed::AutoUpdateType>(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt()));
|
||||
setAutoUpdateInitialInterval(record.value(FDS_DB_UPDATE_INTERVAL_INDEX).toInt());
|
||||
updateCounts();
|
||||
}
|
16
src/core/feed.h → src/services/standard/standardfeed.h
Normal file → Executable file
16
src/core/feed.h → src/services/standard/standardfeed.h
Normal file → Executable file
@ -33,7 +33,7 @@ class FeedsModel;
|
||||
|
||||
// Represents BASE class for feeds contained in FeedsModel.
|
||||
// NOTE: This class should be derived to create PARTICULAR feed types.
|
||||
class Feed : public RootItem {
|
||||
class StandardFeed : public RootItem {
|
||||
Q_DECLARE_TR_FUNCTIONS(Feed)
|
||||
|
||||
public:
|
||||
@ -63,10 +63,10 @@ class Feed : public RootItem {
|
||||
};
|
||||
|
||||
// Constructors and destructors.
|
||||
explicit Feed(RootItem *parent_item = NULL);
|
||||
explicit Feed(const Feed &other);
|
||||
explicit Feed(const QSqlRecord &record);
|
||||
virtual ~Feed();
|
||||
explicit StandardFeed(RootItem *parent_item = NULL);
|
||||
explicit StandardFeed(const StandardFeed &other);
|
||||
explicit StandardFeed(const QSqlRecord &record);
|
||||
virtual ~StandardFeed();
|
||||
|
||||
// Returns 0, feeds have no children.
|
||||
int childCount() const;
|
||||
@ -87,7 +87,7 @@ class Feed : public RootItem {
|
||||
// storage.
|
||||
bool removeItself();
|
||||
bool addItself(RootItem *parent);
|
||||
bool editItself(Feed *new_feed_data);
|
||||
bool editItself(StandardFeed *new_feed_data);
|
||||
|
||||
// Other getters/setters.
|
||||
inline Type type() const {
|
||||
@ -180,7 +180,7 @@ class Feed : public RootItem {
|
||||
// Returns pointer to guessed feed (if at least partially
|
||||
// guessed) and retrieved error/status code from network layer
|
||||
// or NULL feed.
|
||||
static QPair<Feed*,QNetworkReply::NetworkError> guessFeed(const QString &url, const QString &username, const QString &password);
|
||||
static QPair<StandardFeed*,QNetworkReply::NetworkError> guessFeed(const QString &url, const QString &username, const QString &password);
|
||||
|
||||
// Converts particular feed type to string.
|
||||
static QString typeToString(Type type);
|
||||
@ -219,6 +219,6 @@ class Feed : public RootItem {
|
||||
QString m_url;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Feed::Type)
|
||||
Q_DECLARE_METATYPE(StandardFeed::Type)
|
||||
|
||||
#endif // FEEDSMODELFEED_H
|
28
src/core/feedsimportexportmodel.cpp → src/services/standard/standardfeedsimportexportmodel.cpp
Normal file → Executable file
28
src/core/feedsimportexportmodel.cpp → src/services/standard/standardfeedsimportexportmodel.cpp
Normal file → Executable file
@ -15,10 +15,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "core/feedsimportexportmodel.h"
|
||||
#include "services/standard/standardfeedsimportexportmodel.h"
|
||||
|
||||
#include "core/feed.h"
|
||||
#include "core/category.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
#include "services/standard/standardcategory.h"
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
@ -111,7 +111,7 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray &result) {
|
||||
}
|
||||
|
||||
case RootItem::Feeed: {
|
||||
Feed *child_feed = child_item->toFeed();
|
||||
StandardFeed *child_feed = child_item->toFeed();
|
||||
QDomElement outline_feed = opml_document.createElement("outline");
|
||||
outline_feed.setAttribute(QSL("text"), child_feed->title());
|
||||
outline_feed.setAttribute(QSL("xmlUrl"), child_feed->url());
|
||||
@ -121,16 +121,16 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray &result) {
|
||||
outline_feed.setAttribute(QSL("rssguard:icon"), QString(qApp->icons()->toByteArray(child_feed->icon())));
|
||||
|
||||
switch (child_feed->type()) {
|
||||
case Feed::Rss0X:
|
||||
case Feed::Rss2X:
|
||||
case StandardFeed::Rss0X:
|
||||
case StandardFeed::Rss2X:
|
||||
outline_feed.setAttribute(QSL("version"), QSL("RSS"));
|
||||
break;
|
||||
|
||||
case Feed::Rdf:
|
||||
case StandardFeed::Rdf:
|
||||
outline_feed.setAttribute(QSL("version"), QSL("RSS1"));
|
||||
break;
|
||||
|
||||
case Feed::Atom10:
|
||||
case StandardFeed::Atom10:
|
||||
outline_feed.setAttribute(QSL("version"), QSL("ATOM"));
|
||||
break;
|
||||
|
||||
@ -192,23 +192,23 @@ bool FeedsImportExportModel::importAsOPML20(const QByteArray &data) {
|
||||
QString feed_description = child_element.attribute(QSL("description"));
|
||||
QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
||||
|
||||
Feed *new_feed = new Feed(active_model_item);
|
||||
StandardFeed *new_feed = new StandardFeed(active_model_item);
|
||||
new_feed->setTitle(feed_title);
|
||||
new_feed->setDescription(feed_description);
|
||||
new_feed->setEncoding(feed_encoding);
|
||||
new_feed->setUrl(feed_url);
|
||||
new_feed->setCreationDate(QDateTime::currentDateTime());
|
||||
new_feed->setIcon(feed_icon.isNull() ? qApp->icons()->fromTheme(QSL("folder-feed")) : feed_icon);
|
||||
new_feed->setAutoUpdateType(Feed::DefaultAutoUpdate);
|
||||
new_feed->setAutoUpdateType(StandardFeed::DefaultAutoUpdate);
|
||||
|
||||
if (feed_type == QL1S("RSS1")) {
|
||||
new_feed->setType(Feed::Rdf);
|
||||
new_feed->setType(StandardFeed::Rdf);
|
||||
}
|
||||
else if (feed_type == QL1S("ATOM")) {
|
||||
new_feed->setType(Feed::Atom10);
|
||||
new_feed->setType(StandardFeed::Atom10);
|
||||
}
|
||||
else {
|
||||
new_feed->setType(Feed::Rss2X);
|
||||
new_feed->setType(StandardFeed::Rss2X);
|
||||
}
|
||||
|
||||
active_model_item->appendChild(new_feed);
|
||||
@ -230,7 +230,7 @@ bool FeedsImportExportModel::importAsOPML20(const QByteArray &data) {
|
||||
}
|
||||
}
|
||||
|
||||
Category *new_category = new Category(active_model_item);
|
||||
StandardCategory *new_category = new StandardCategory(active_model_item);
|
||||
new_category->setTitle(category_title);
|
||||
new_category->setIcon(category_icon.isNull() ? qApp->icons()->fromTheme(QSL("folder-category")) : category_icon);
|
||||
new_category->setCreationDate(QDateTime::currentDateTime());
|
0
src/core/feedsimportexportmodel.h → src/services/standard/standardfeedsimportexportmodel.h
Normal file → Executable file
0
src/core/feedsimportexportmodel.h → src/services/standard/standardfeedsimportexportmodel.h
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user