diff --git a/CMakeLists.txt b/CMakeLists.txt index b27fe9a07..d5e9a949e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp old mode 100644 new mode 100755 index 8482e11a6..8afef756c --- a/src/core/feeddownloader.cpp +++ b/src/core/feeddownloader.cpp @@ -17,7 +17,7 @@ #include "core/feeddownloader.h" -#include "core/feed.h" +#include "services/standard/standardfeed.h" #include "definitions/definitions.h" #include @@ -32,7 +32,7 @@ FeedDownloader::~FeedDownloader() { qDebug("Destroying FeedDownloader instance."); } -void FeedDownloader::updateFeeds(const QList &feeds) { +void FeedDownloader::updateFeeds(const QList &feeds) { qDebug().nospace() << "Performing feed updates in thread: \'" << QThread::currentThreadId() << "\'."; // Job starts now. diff --git a/src/core/feeddownloader.h b/src/core/feeddownloader.h old mode 100644 new mode 100755 index 88f8992b7..eab2aac2e --- a/src/core/feeddownloader.h +++ b/src/core/feeddownloader.h @@ -23,7 +23,7 @@ #include -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 &feeds); + void updateFeeds(const QList &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 diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index f78b4dd23..7dad793e8 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -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 feeds_for_update = feedsForScheduledUpdate(m_globalAutoUpdateEnabled && m_globalAutoUpdateRemainingInterval == 0); + QList 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 FeedsModel::feedsForScheduledUpdate(bool auto_update_now) { - QList feeds_for_update; +QList FeedsModel::feedsForScheduledUpdate(bool auto_update_now) { + QList 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 FeedsModel::feedsForScheduledUpdate(bool auto_update_now) { return feeds_for_update; } -QList FeedsModel::messagesForFeeds(const QList &feeds) { +QList FeedsModel::messagesForFeeds(const QList &feeds) { QList messages; QSqlDatabase database = qApp->database()->connection(objectName(), @@ -482,7 +482,7 @@ QList FeedsModel::messagesForFeeds(const QList &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 &feeds) { +QStringList FeedsModel::textualFeedIds(const QList &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(query_feeds.value(FDS_DB_TYPE_INDEX).toInt()); + StandardFeed::Type type = static_cast(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 FeedsModel::feedsForIndex(const QModelIndex &index) { +QList 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 FeedsModel::feedsForIndexes(const QModelIndexList &indexes) { - QList feeds; +QList FeedsModel::feedsForIndexes(const QModelIndexList &indexes) { + QList feeds; // Get selected feeds for each index. foreach (const QModelIndex &index, indexes) { @@ -782,7 +782,7 @@ QList FeedsModel::feedsForIndexes(const QModelIndexList &indexes) { return feeds; } -bool FeedsModel::markFeedsRead(const QList &feeds, int read) { +bool FeedsModel::markFeedsRead(const QList &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 &feeds, int read) { } } -bool FeedsModel::markFeedsDeleted(const QList &feeds, int deleted, bool read_only) { +bool FeedsModel::markFeedsDeleted(const QList &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 &feeds, int deleted, bool r } } -QHash FeedsModel::allCategories() { +QHash FeedsModel::allCategories() { return categoriesForItem(m_rootItem); } -QHash FeedsModel::categoriesForItem(RootItem *root) { - QHash categories; +QHash FeedsModel::categoriesForItem(RootItem *root) { + QHash categories; QList parents; parents.append(root->childItems()); @@ -880,7 +880,7 @@ QHash 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 FeedsModel::categoriesForItem(RootItem *root) { return categories; } -QList FeedsModel::allFeeds() { +QList FeedsModel::allFeeds() { return feedsForItem(m_rootItem); } -QList FeedsModel::feedsForItem(RootItem *root) { +QList FeedsModel::feedsForItem(RootItem *root) { QList children = root->getRecursiveChildren(); - QList feeds; + QList feeds; foreach (RootItem *child, children) { if (child->kind() == RootItem::Feeed) { @@ -911,7 +911,7 @@ QList FeedsModel::feedsForItem(RootItem *root) { } void FeedsModel::assembleFeeds(FeedAssignment feeds) { - QHash categories = allCategories(); + QHash categories = allCategories(); foreach (const FeedAssignmentItem &feed, feeds) { if (feed.first == NO_PARENT_CATEGORY) { diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h old mode 100644 new mode 100755 index a4eb30c3d..ad029b443 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -26,23 +26,23 @@ #include -class Category; -class Feed; +class StandardCategory; +class StandardFeed; class RecycleBin; class FeedsImportExportModel; class QTimer; -typedef QList > CategoryAssignment; -typedef QPair CategoryAssignmentItem; +typedef QList > CategoryAssignment; +typedef QPair CategoryAssignmentItem; -typedef QList > FeedAssignment; -typedef QPair FeedAssignmentItem; +typedef QList > FeedAssignment; +typedef QPair 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 feedsForScheduledUpdate(bool auto_update_now); + QList feedsForScheduledUpdate(bool auto_update_now); // Returns (undeleted) messages for given feeds. // This is usually used for displaying whole feeds // in "newspaper" mode. - QList messagesForFeeds(const QList &feeds); + QList messagesForFeeds(const QList &feeds); // Returns all categories, each pair // consists of ID of parent item and pointer to category. - QHash allCategories(); + QHash allCategories(); // Returns categories from the subtree with given root node, each pair // consists of ID of parent item and pointer to category. - QHash categoriesForItem(RootItem *root); + QHash categoriesForItem(RootItem *root); // Returns list of all feeds contained in the model. - QList allFeeds(); + QList allFeeds(); // Get list of feeds from tree with particular item // as root. If root itself is a feed, then it is returned. - QList feedsForItem(RootItem *root); + QList feedsForItem(RootItem *root); // Returns list of ALL CHILD feeds which belong to given parent indexes. - QList feedsForIndexes(const QModelIndexList &indexes); + QList feedsForIndexes(const QModelIndexList &indexes); // Returns ALL CHILD feeds contained within single index. - QList feedsForIndex(const QModelIndex &index); + QList 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 &feeds, int read); - bool markFeedsDeleted(const QList &feeds, int deleted, bool read_only); + bool markFeedsRead(const QList &feeds, int read); + bool markFeedsDeleted(const QList &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 &feeds); + QStringList textualFeedIds(const QList &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 feeds); + void feedsUpdateRequested(const QList feeds); private: RootItem *m_rootItem; diff --git a/src/core/feedsproxymodel.cpp b/src/core/feedsproxymodel.cpp index 36215a3d8..9c1b54f6c 100755 --- a/src/core/feedsproxymodel.cpp +++ b/src/core/feedsproxymodel.cpp @@ -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) diff --git a/src/core/feedsselection.cpp b/src/core/feedsselection.cpp index 4b7328c1b..e01624d21 100755 --- a/src/core/feedsselection.cpp +++ b/src/core/feedsselection.cpp @@ -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" diff --git a/src/core/feedsselection.h b/src/core/feedsselection.h old mode 100644 new mode 100755 index 2eb1d27cb..1295bdffa --- a/src/core/feedsselection.h +++ b/src/core/feedsselection.h @@ -23,7 +23,7 @@ class RootItem; -class Feed; +class StandardFeed; class FeedsSelection { public: diff --git a/src/core/rootitem.cpp b/src/core/rootitem.cpp old mode 100644 new mode 100755 index a262b8d96..a9789c816 --- a/src/core/rootitem.cpp +++ b/src/core/rootitem.cpp @@ -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(this); } -Category *RootItem::toCategory() { - return static_cast(this); +StandardCategory *RootItem::toCategory() { + return static_cast(this); } -Feed *RootItem::toFeed() { - return static_cast(this); +StandardFeed *RootItem::toFeed() { + return static_cast(this); } RootItem *RootItem::child(RootItem::Kind kind_of_child, const QString &identifier) { diff --git a/src/core/rootitem.h b/src/core/rootitem.h old mode 100644 new mode 100755 index 7ee0e49ef..964fa6122 --- a/src/core/rootitem.h +++ b/src/core/rootitem.h @@ -24,8 +24,8 @@ #include 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); diff --git a/src/gui/dialogs/formmain.cpp b/src/gui/dialogs/formmain.cpp index 35ef10a99..b9fad65a0 100755 --- a/src/gui/dialogs/formmain.cpp +++ b/src/gui/dialogs/formmain.cpp @@ -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 #include @@ -411,14 +411,14 @@ void FormMain::loadWebBrowserMenu(int index) { } void FormMain::exportFeeds() { - QPointer form = new FormImportExport(this); + QPointer form = new FormStandardImportExport(this); form.data()->setMode(FeedsImportExportModel::Export); form.data()->exec(); delete form.data(); } void FormMain::importFeeds() { - QPointer form = new FormImportExport(this); + QPointer form = new FormStandardImportExport(this); form.data()->setMode(FeedsImportExportModel::Import); form.data()->exec(); delete form.data(); diff --git a/src/gui/dialogs/formmain.ui b/src/gui/dialogs/formmain.ui index 9aeaa3567..bca5de13f 100755 --- a/src/gui/dialogs/formmain.ui +++ b/src/gui/dialogs/formmain.ui @@ -184,9 +184,18 @@ + + + &Services + + + + + + @@ -680,6 +689,21 @@ E + + + &Add new service + + + + + &Delete selected service + + + + + &Edit selected service + + diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 28639c7cd..cbc77346b 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -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))); // Downloader connections. - connect(m_feedsView, SIGNAL(feedsUpdateRequested(QList)), this, SLOT(updateFeeds(QList))); + connect(m_feedsView, SIGNAL(feedsUpdateRequested(QList)), this, SLOT(updateFeeds(QList))); // 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 feeds) { +void FeedMessageViewer::updateFeeds(QList 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 feeds) { m_feedDownloaderThread = new QThread(); // Downloader setup. - qRegisterMetaType >("QList"); + qRegisterMetaType >("QList"); m_feedDownloader->moveToThread(m_feedDownloaderThread); - connect(this, SIGNAL(feedsUpdateRequested(QList)), m_feedDownloader, SLOT(updateFeeds(QList))); + connect(this, SIGNAL(feedsUpdateRequested(QList)), m_feedDownloader, SLOT(updateFeeds(QList))); 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(); diff --git a/src/gui/feedmessageviewer.h b/src/gui/feedmessageviewer.h old mode 100644 new mode 100755 index 539f4cb35..8c087427f --- a/src/gui/feedmessageviewer.h +++ b/src/gui/feedmessageviewer.h @@ -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 feeds); + void updateFeeds(QList 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 feeds); + void feedsUpdateRequested(const QList feeds); private: bool m_toolBarsEnabled; diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 89f634c06..0c01a9698 100755 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -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 #include @@ -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)), this, SIGNAL(feedsUpdateRequested(QList))); + connect(m_sourceModel, SIGNAL(feedsUpdateRequested(QList)), this, SIGNAL(feedsUpdateRequested(QList))); 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 FeedsView::selectedFeeds() const { +QList FeedsView::selectedFeeds() const { QModelIndex current_index = currentIndex(); if (current_index.isValid()) { return m_sourceModel->feedsForIndex(m_proxyModel->mapToSource(current_index)); } else { - return QList(); + return QList(); } } -QList FeedsView::allFeeds() const { +QList 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 form_pointer = new FormCategoryDetails(m_sourceModel, this); + QPointer 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 form_pointer = new FormCategoryDetails(m_sourceModel, this); +void FeedsView::editCategory(StandardCategory *category) { + QPointer form_pointer = new FormStandardCategoryDetails(m_sourceModel, this); form_pointer.data()->exec(category, NULL); @@ -233,7 +233,7 @@ void FeedsView::addNewFeed() { return; } - QPointer form_pointer = new FormFeedDetails(m_sourceModel, this); + QPointer 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 form_pointer = new FormFeedDetails(m_sourceModel, this); +void FeedsView::editFeed(StandardFeed *feed) { + QPointer 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()) { diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 61c249175..0a8615f94 100755 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -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 selectedFeeds() const; - QList allFeeds() const; + QList selectedFeeds() const; + QList 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 feeds); + void feedsUpdateRequested(const QList feeds); // Emitted if counts of messages are changed. void messageCountsChanged(int unread_messages, int total_messages, bool any_feed_has_unread_messages); diff --git a/src/gui/dialogs/formcategorydetails.cpp b/src/services/standard/gui/formstandardcategorydetails.cpp similarity index 87% rename from src/gui/dialogs/formcategorydetails.cpp rename to src/services/standard/gui/formstandardcategorydetails.cpp index bac6ad7ec..55af700e2 100755 --- a/src/gui/dialogs/formcategorydetails.cpp +++ b/src/services/standard/gui/formstandardcategorydetails.cpp @@ -15,12 +15,12 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#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 -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(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); - 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 categories, +void FormStandardCategoryDetails::loadCategories(const QList 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 diff --git a/src/gui/dialogs/formcategorydetails.h b/src/services/standard/gui/formstandardcategorydetails.h old mode 100644 new mode 100755 similarity index 74% rename from src/gui/dialogs/formcategorydetails.h rename to src/services/standard/gui/formstandardcategorydetails.h index 67abd4196..51c9f60c4 --- a/src/gui/dialogs/formcategorydetails.h +++ b/src/services/standard/gui/formstandardcategorydetails.h @@ -18,33 +18,33 @@ #ifndef FORMCATEGORYDETAILS_H #define FORMCATEGORYDETAILS_H -#include "ui_formcategorydetails.h" +#include "ui_formstandardcategorydetails.h" #include 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 categories, RootItem *root_item, Category *input_category); + void loadCategories(const QList 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; diff --git a/src/gui/dialogs/formcategorydetails.ui b/src/services/standard/gui/formstandardcategorydetails.ui old mode 100644 new mode 100755 similarity index 96% rename from src/gui/dialogs/formcategorydetails.ui rename to src/services/standard/gui/formstandardcategorydetails.ui index 7c2fd546c..67bbed086 --- a/src/gui/dialogs/formcategorydetails.ui +++ b/src/services/standard/gui/formstandardcategorydetails.ui @@ -1,7 +1,7 @@ - FormCategoryDetails - + FormStandardCategoryDetails + 0 @@ -153,7 +153,7 @@ m_buttonBox rejected() - FormCategoryDetails + FormStandardCategoryDetails reject() diff --git a/src/gui/dialogs/formfeeddetails.cpp b/src/services/standard/gui/formstandardfeeddetails.cpp similarity index 83% rename from src/gui/dialogs/formfeeddetails.cpp rename to src/services/standard/gui/formstandardfeeddetails.cpp index e022cb814..f1884a1c4 100755 --- a/src/gui/dialogs/formfeeddetails.cpp +++ b/src/services/standard/gui/formstandardfeeddetails.cpp @@ -15,13 +15,13 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#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 -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(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt()); +void FormStandardFeedDetails::onAutoUpdateTypeChanged(int new_index) { + StandardFeed::AutoUpdateType auto_update_type = static_cast(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(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value()); - Feed::Type type = static_cast(m_ui->m_cmbType->itemData(m_ui->m_cmbType->currentIndex()).value()); - Feed *new_feed = new Feed(); + StandardFeed::Type type = static_cast(m_ui->m_cmbType->itemData(m_ui->m_cmbType->currentIndex()).value()); + 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(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt())); + new_feed->setAutoUpdateType(static_cast(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 result = Feed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(), +void FormStandardFeedDetails::guessFeed() { + QPair 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 result = Feed::guessFeed(m_ui->m_txtUrl->lineEdit()->text(), +void FormStandardFeedDetails::guessIconOnly() { + QPair 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 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 categories, +void FormStandardFeedDetails::loadCategories(const QList 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(), category->title(), diff --git a/src/gui/dialogs/formfeeddetails.h b/src/services/standard/gui/formstandardfeeddetails.h old mode 100644 new mode 100755 similarity index 78% rename from src/gui/dialogs/formfeeddetails.h rename to src/services/standard/gui/formstandardfeeddetails.h index 550b0bcb9..6b3ed95a7 --- a/src/gui/dialogs/formfeeddetails.h +++ b/src/services/standard/gui/formstandardfeeddetails.h @@ -18,31 +18,31 @@ #ifndef FORMSTANDARDFEEDDETAILS_H #define FORMSTANDARDFEEDDETAILS_H -#include "ui_formfeeddetails.h" - #include +#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 categories, + void loadCategories(const QList 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; diff --git a/src/gui/dialogs/formfeeddetails.ui b/src/services/standard/gui/formstandardfeeddetails.ui old mode 100644 new mode 100755 similarity index 95% rename from src/gui/dialogs/formfeeddetails.ui rename to src/services/standard/gui/formstandardfeeddetails.ui index dd8755df2..fa1511ab4 --- a/src/gui/dialogs/formfeeddetails.ui +++ b/src/services/standard/gui/formstandardfeeddetails.ui @@ -1,7 +1,7 @@ - FormFeedDetails - + FormStandardFeedDetails + 0 @@ -325,7 +325,7 @@ m_buttonBox rejected() - FormFeedDetails + FormStandardFeedDetails reject() diff --git a/src/gui/dialogs/formimportexport.cpp b/src/services/standard/gui/formstandardimportexport.cpp similarity index 90% rename from src/gui/dialogs/formimportexport.cpp rename to src/services/standard/gui/formstandardimportexport.cpp index d56421e75..e0c4188b3 100755 --- a/src/gui/dialogs/formimportexport.cpp +++ b/src/services/standard/gui/formstandardimportexport.cpp @@ -15,9 +15,9 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#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 -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)) { diff --git a/src/gui/dialogs/formimportexport.h b/src/services/standard/gui/formstandardimportexport.h old mode 100644 new mode 100755 similarity index 80% rename from src/gui/dialogs/formimportexport.h rename to src/services/standard/gui/formstandardimportexport.h index cab60cc05..fc1fa85dd --- a/src/gui/dialogs/formimportexport.h +++ b/src/services/standard/gui/formstandardimportexport.h @@ -20,15 +20,15 @@ #include -#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; }; diff --git a/src/gui/dialogs/formimportexport.ui b/src/services/standard/gui/formstandardimportexport.ui old mode 100644 new mode 100755 similarity index 96% rename from src/gui/dialogs/formimportexport.ui rename to src/services/standard/gui/formstandardimportexport.ui index 46af7e659..53b635d74 --- a/src/gui/dialogs/formimportexport.ui +++ b/src/services/standard/gui/formstandardimportexport.ui @@ -1,7 +1,7 @@ - FormImportExport - + FormStandardImportExport + 0 @@ -149,7 +149,7 @@ m_buttonBox rejected() - FormImportExport + FormStandardImportExport reject() diff --git a/src/core/category.cpp b/src/services/standard/standardcategory.cpp old mode 100644 new mode 100755 similarity index 89% rename from src/core/category.cpp rename to src/services/standard/standardcategory.cpp index cf2fb0bdd..b87ae4b6f --- a/src/core/category.cpp +++ b/src/services/standard/standardcategory.cpp @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#include "core/category.h" +#include "services/standard/standardcategory.h" #include "definitions/definitions.h" #include "miscellaneous/databasefactory.h" @@ -29,11 +29,11 @@ #include -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()); diff --git a/src/core/category.h b/src/services/standard/standardcategory.h old mode 100644 new mode 100755 similarity index 80% rename from src/core/category.h rename to src/services/standard/standardcategory.h index 3cf04adb1..c0a952b8a --- a/src/core/category.h +++ b/src/services/standard/standardcategory.h @@ -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(); diff --git a/src/core/feed.cpp b/src/services/standard/standardfeed.cpp old mode 100644 new mode 100755 similarity index 91% rename from src/core/feed.cpp rename to src/services/standard/standardfeed.cpp index 210a8932e..812529db0 --- a/src/core/feed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#include "core/feed.h" +#include "services/standard/standardfeed.h" #include "definitions/definitions.h" #include "core/parsingfactory.h" @@ -38,7 +38,7 @@ #include -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 metadata = guessFeed(url(), username(), password()); +void StandardFeed::fetchMetadataForItself() { + QPair 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::guessFeed(const QString &url, const QString &username, const QString &password) { - QPair result; result.first = NULL; +QPair StandardFeed::guessFeed(const QString &url, const QString &username, const QString &password) { + QPair result; result.first = NULL; QByteArray feed_contents; NetworkResult network_result = NetworkFactory::downloadFeedFile(url, @@ -196,7 +196,7 @@ QPair 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::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 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 &messages) { +int StandardFeed::updateMessages(const QList &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 &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(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt())); + setAutoUpdateType(static_cast(record.value(FDS_DB_UPDATE_TYPE_INDEX).toInt())); setAutoUpdateInitialInterval(record.value(FDS_DB_UPDATE_INTERVAL_INDEX).toInt()); updateCounts(); } diff --git a/src/core/feed.h b/src/services/standard/standardfeed.h old mode 100644 new mode 100755 similarity index 89% rename from src/core/feed.h rename to src/services/standard/standardfeed.h index 68df38152..d3d23b3cc --- a/src/core/feed.h +++ b/src/services/standard/standardfeed.h @@ -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 guessFeed(const QString &url, const QString &username, const QString &password); + static QPair 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 diff --git a/src/core/feedsimportexportmodel.cpp b/src/services/standard/standardfeedsimportexportmodel.cpp old mode 100644 new mode 100755 similarity index 95% rename from src/core/feedsimportexportmodel.cpp rename to src/services/standard/standardfeedsimportexportmodel.cpp index b73d9a1c9..96c01a16f --- a/src/core/feedsimportexportmodel.cpp +++ b/src/services/standard/standardfeedsimportexportmodel.cpp @@ -15,10 +15,10 @@ // You should have received a copy of the GNU General Public License // along with RSS Guard. If not, see . -#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()); diff --git a/src/core/feedsimportexportmodel.h b/src/services/standard/standardfeedsimportexportmodel.h old mode 100644 new mode 100755 similarity index 100% rename from src/core/feedsimportexportmodel.h rename to src/services/standard/standardfeedsimportexportmodel.h