diff --git a/src/core/basenetworkaccessmanager.cpp b/src/core/basenetworkaccessmanager.cpp index fa8d62938..e7166a3e5 100644 --- a/src/core/basenetworkaccessmanager.cpp +++ b/src/core/basenetworkaccessmanager.cpp @@ -54,7 +54,8 @@ QNetworkReply *BaseNetworkAccessManager::createRequest(QNetworkAccessManager::Op new_request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); // Setup custom user-agent. - new_request.setRawHeader("User-Agent", QString(APP_USERAGENT).toLocal8Bit()); + new_request.setRawHeader(USER_AGENT_HTTP_HEADER, + QString(APP_USERAGENT).toLocal8Bit()); return QNetworkAccessManager::createRequest(op, new_request, outgoingData); } diff --git a/src/core/databasefactory.cpp b/src/core/databasefactory.cpp index 60a56b5cf..dbd2064ea 100644 --- a/src/core/databasefactory.cpp +++ b/src/core/databasefactory.cpp @@ -129,7 +129,7 @@ QSqlDatabase DatabaseFactory::initialize(const QString &connection_name) { return database; } -QSqlDatabase DatabaseFactory::addConnection(const QString &connection_name) { +QSqlDatabase DatabaseFactory::connection(const QString &connection_name) { if (!m_initialized) { m_initialized = true; return initialize(connection_name); diff --git a/src/core/databasefactory.h b/src/core/databasefactory.h index a6f541777..c00675f59 100644 --- a/src/core/databasefactory.h +++ b/src/core/databasefactory.h @@ -9,6 +9,22 @@ class DatabaseFactory : public QObject { Q_OBJECT + public: + // Destructor. + virtual ~DatabaseFactory(); + + // Returns absolute file path to database file. + QString getDatabasePath(); + + // NOTE: This always returns OPENED database. + QSqlDatabase connection(const QString &connection_name); + + // Removes connection. + void removeConnection(const QString &connection_name); + + // Singleton getter. + static DatabaseFactory *getInstance(); + private: // Conctructor. explicit DatabaseFactory(QObject *parent = 0); @@ -28,22 +44,6 @@ class DatabaseFactory : public QObject { // Private singleton value. static QPointer s_instance; - - public: - // Destructor. - virtual ~DatabaseFactory(); - - // Returns absolute file path to database file. - QString getDatabasePath(); - - // NOTE: This returns OPENED database. - QSqlDatabase addConnection(const QString &connection_name); - - // Removes connection. - void removeConnection(const QString &connection_name); - - // Singleton getter. - static DatabaseFactory *getInstance(); }; #endif // DATABASEFACTORY_H diff --git a/src/core/debugging.cpp b/src/core/debugging.cpp index ce9978069..a04589165 100644 --- a/src/core/debugging.cpp +++ b/src/core/debugging.cpp @@ -31,7 +31,8 @@ void Debugging::debugHandler(QtMsgType type, const QMessageLogContext &placement, const QString &message) { #ifndef QT_NO_DEBUG_OUTPUT - const char *file = qPrintable(QString(placement.file).section(QDir::separator(), -1)); + const char *file = qPrintable(QString(placement.file).section(QDir::separator(), + -1)); switch (type) { case QtDebugMsg: diff --git a/src/core/debugging.h b/src/core/debugging.h index 93623da36..67b6da635 100644 --- a/src/core/debugging.h +++ b/src/core/debugging.h @@ -5,13 +5,9 @@ class Debugging { - private: - explicit Debugging(); - public: // Specifies format of output console messages. - // Macros: - // QT_NO_DEBUG_OUTPUT - disables debug outputs completely!!! + // NOTE: QT_NO_DEBUG_OUTPUT - disables debug outputs completely!!! #if QT_VERSION >= 0x050000 static void debugHandler(QtMsgType type, const QMessageLogContext &placement, @@ -20,6 +16,10 @@ class Debugging { static void debugHandler(QtMsgType type, const char *message); #endif + + private: + // Constructor. + explicit Debugging(); }; #endif // DEBUGGING_H diff --git a/src/core/defs.h.in b/src/core/defs.h.in index 0c996830c..13d821c72 100755 --- a/src/core/defs.h.in +++ b/src/core/defs.h.in @@ -23,6 +23,7 @@ #define APP_VERSION "@APP_VERSION@" #define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@; Webkit/") + qWebKitVersion() +#define USER_AGENT_HTTP_HEADER "User-Agent" #define TEXT_TITLE_LIMIT 30 #define MAX_ZOOM_FACTOR 10.0 #define ICON_SIZE_SETTINGS 16 diff --git a/src/core/dynamicshortcuts.h b/src/core/dynamicshortcuts.h index 3035d1107..df1e1e83f 100644 --- a/src/core/dynamicshortcuts.h +++ b/src/core/dynamicshortcuts.h @@ -7,9 +7,6 @@ class QAction; class DynamicShortcuts { - private: - explicit DynamicShortcuts(); - public: // Checks the application settings and then initializes shortcut of // each action from actions from the settings. @@ -18,6 +15,10 @@ class DynamicShortcuts { // Stores shortcut of each action from actions into the application // settings. static void save(const QList actions); + + private: + // Constructor. + explicit DynamicShortcuts(); }; #endif // DYNAMICSHORTCUTS_H diff --git a/src/core/feeddownloader.cpp b/src/core/feeddownloader.cpp index ac90fcb6e..57d3d66fb 100644 --- a/src/core/feeddownloader.cpp +++ b/src/core/feeddownloader.cpp @@ -18,6 +18,8 @@ void FeedDownloader::updateFeeds(const QList &feeds) { qDebug().nospace() << "Performing feed updates in thread: \'" << QThread::currentThreadId() << "\'."; + emit started(); + for (int i = 0, total = feeds.size(); i < total; i++) { feeds.at(i)->update(); diff --git a/src/core/feeddownloader.h b/src/core/feeddownloader.h index e87f48847..bd152d58f 100644 --- a/src/core/feeddownloader.h +++ b/src/core/feeddownloader.h @@ -20,6 +20,9 @@ class FeedDownloader : public QObject { virtual ~FeedDownloader(); signals: + // Emitted if feed updates started. + void started(); + // Emitted if all items from update queue are // processed. void finished(); diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 16b83725d..dd9af3784 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -134,7 +134,7 @@ int FeedsModel::rowCount(const QModelIndex &parent) const { QList FeedsModel::messagesForFeeds(const QList &feeds) { QList messages; - QSqlDatabase database = DatabaseFactory::getInstance()->addConnection(objectName()); + QSqlDatabase database = DatabaseFactory::getInstance()->connection(objectName()); QSqlQuery query_read_msg(database); query_read_msg.setForwardOnly(true); query_read_msg.prepare("SELECT title, url, author, date_created, contents " @@ -274,7 +274,7 @@ void FeedsModel::loadFromDatabase() { qDeleteAll(m_rootItem->childItems()); m_rootItem->clearChilds(); - QSqlDatabase database = DatabaseFactory::getInstance()->addConnection(objectName()); + QSqlDatabase database = DatabaseFactory::getInstance()->connection(objectName()); CategoryAssignment categories; FeedAssignment feeds; @@ -385,7 +385,7 @@ QList FeedsModel::feedsForIndexes(const QModelIndexList &indexe bool FeedsModel::markFeedsRead(const QList &feeds, int read) { - QSqlDatabase db_handle = DatabaseFactory::getInstance()->addConnection(objectName()); + QSqlDatabase db_handle = DatabaseFactory::getInstance()->connection(objectName()); if (!db_handle.transaction()) { qWarning("Starting transaction for feeds read change."); @@ -421,7 +421,7 @@ bool FeedsModel::markFeedsRead(const QList &feeds, bool FeedsModel::markFeedsDeleted(const QList &feeds, int deleted) { - QSqlDatabase db_handle = DatabaseFactory::getInstance()->addConnection(objectName()); + QSqlDatabase db_handle = DatabaseFactory::getInstance()->connection(objectName()); if (!db_handle.transaction()) { qWarning("Starting transaction for feeds clearing."); diff --git a/src/core/feedsmodel.h b/src/core/feedsmodel.h index 45700ba6b..d1bb7e416 100644 --- a/src/core/feedsmodel.h +++ b/src/core/feedsmodel.h @@ -111,7 +111,6 @@ class FeedsModel : public QAbstractItemModel { QList m_headerData; QList m_tooltipData; QIcon m_countsIcon; - }; #endif // FEEDSMODEL_H diff --git a/src/core/feedsmodelcategory.cpp b/src/core/feedsmodelcategory.cpp index 8f06de9a5..74eb16b61 100755 --- a/src/core/feedsmodelcategory.cpp +++ b/src/core/feedsmodelcategory.cpp @@ -52,19 +52,3 @@ FeedsModelCategory:: Type FeedsModelCategory::type() const { void FeedsModelCategory::setType(const Type &type) { m_type = type; } - -QString FeedsModelCategory::description() const { - return m_description; -} - -void FeedsModelCategory::setDescription(const QString &description) { - m_description = description; -} - -QDateTime FeedsModelCategory::creationDate() const { - return m_creationDate; -} - -void FeedsModelCategory::setCreationDate(const QDateTime &creation_date) { - m_creationDate = creation_date; -} diff --git a/src/core/feedsmodelcategory.h b/src/core/feedsmodelcategory.h index bfcd4e9ba..1a9d5420d 100755 --- a/src/core/feedsmodelcategory.h +++ b/src/core/feedsmodelcategory.h @@ -3,8 +3,6 @@ #include "core/feedsmodelrootitem.h" -#include - class FeedsModelFeed; @@ -36,16 +34,8 @@ class FeedsModelCategory : public FeedsModelRootItem { Type type() const; void setType(const Type &type); - QString description() const; - void setDescription(const QString &description); - - QDateTime creationDate() const; - void setCreationDate(const QDateTime &creation_date); - protected: Type m_type; - QDateTime m_creationDate; - QString m_description; }; #endif // FEEDSMODELCLASSICCATEGORY_H diff --git a/src/core/feedsmodelfeed.cpp b/src/core/feedsmodelfeed.cpp index 190948679..ebb36d12c 100755 --- a/src/core/feedsmodelfeed.cpp +++ b/src/core/feedsmodelfeed.cpp @@ -25,18 +25,10 @@ int FeedsModelFeed::countOfAllMessages() const { return m_totalCount; } -void FeedsModelFeed::setCountOfAllMessages(int count) { - m_totalCount = count; -} - int FeedsModelFeed::countOfUnreadMessages() const { return m_unreadCount; } -void FeedsModelFeed::setCountOfUnreadMessages(int count) { - m_unreadCount = count; -} - void FeedsModelFeed::update() { } @@ -66,7 +58,7 @@ QString FeedsModelFeed::typeToString(FeedsModelFeed::Type type) { } void FeedsModelFeed::updateCounts(bool including_total_count) { - QSqlDatabase database = DatabaseFactory::getInstance()->addConnection("FeedsModelFeed"); + QSqlDatabase database = DatabaseFactory::getInstance()->connection("FeedsModelFeed"); QSqlQuery query_all(database); query_all.setForwardOnly(true); diff --git a/src/core/feedsmodelfeed.h b/src/core/feedsmodelfeed.h index 3def6582e..2ed88d341 100755 --- a/src/core/feedsmodelfeed.h +++ b/src/core/feedsmodelfeed.h @@ -28,10 +28,7 @@ class FeedsModelFeed : public FeedsModelRootItem { // NOTE: For feeds, counts are stored internally // and can be updated from the database. int countOfAllMessages() const; - void setCountOfAllMessages(int count); - int countOfUnreadMessages() const; - void setCountOfUnreadMessages(int count); // Each feed can be "updated". // NOTE: This method is used in the "update worker". diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index 3822d19bf..923b93ad6 100755 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -103,6 +103,25 @@ void FeedsModelRootItem::clearChilds() { m_childItems.clear(); } + + +QDateTime FeedsModelRootItem::creationDate() const { + return m_creationDate; +} + +void FeedsModelRootItem::setCreationDate(const QDateTime &creation_date) { + m_creationDate = creation_date; +} + +QString FeedsModelRootItem::description() const { + return m_description; +} + +void FeedsModelRootItem::setDescription(const QString &description) { + m_description = description; +} + + bool FeedsModelRootItem::isEqual(FeedsModelRootItem *lhs, FeedsModelRootItem *rhs) { return (lhs->kind() == rhs->kind()) && (lhs->id() == rhs->id()); diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h index bbd76899a..0f29b0b97 100755 --- a/src/core/feedsmodelrootitem.h +++ b/src/core/feedsmodelrootitem.h @@ -3,6 +3,8 @@ #include +#include + // Represents ROOT item of FeedsModel. // NOTE: This class is derived to add functionality for @@ -49,6 +51,12 @@ class FeedsModelRootItem { QString title() const; void setTitle(const QString &title); + QDateTime creationDate() const; + void setCreationDate(const QDateTime &creation_date); + + QString description() const; + void setDescription(const QString &description); + // Access to children. QList childItems() const; @@ -64,6 +72,8 @@ class FeedsModelRootItem { QString m_title; int m_id; QIcon m_icon; + QDateTime m_creationDate; + QString m_description; QList m_childItems; FeedsModelRootItem *m_parentItem; }; diff --git a/src/core/feedsmodelstandardcategory.cpp b/src/core/feedsmodelstandardcategory.cpp index 0cac6f3f5..1103adb60 100755 --- a/src/core/feedsmodelstandardcategory.cpp +++ b/src/core/feedsmodelstandardcategory.cpp @@ -21,13 +21,12 @@ QVariant FeedsModelStandardCategory::data(int column, int role) const { switch (role) { case Qt::ToolTipRole: if (column == FDS_MODEL_TITLE_INDEX) { - return QObject::tr("%1\n\n" - "Category type: standard\n" - "Creation date: %2%3").arg(m_title, - m_creationDate.toString(Qt::DefaultLocaleShortDate), - m_childItems.size() == 0 ? - QObject::tr("\n\nThis category does not contain any nested items.") : - ""); + return QObject::tr("%1 (standard category)\n" + "%2%3").arg(m_title, + m_description, + m_childItems.size() == 0 ? + QObject::tr("\n\nThis category does not contain any nested items.") : + ""); } else if (column == FDS_MODEL_COUNTS_INDEX) { return QObject::tr("%n unread message(s).", "", countOfUnreadMessages()); diff --git a/src/core/feedsmodelstandardfeed.cpp b/src/core/feedsmodelstandardfeed.cpp index a8cfaf473..295efb4bc 100755 --- a/src/core/feedsmodelstandardfeed.cpp +++ b/src/core/feedsmodelstandardfeed.cpp @@ -22,10 +22,6 @@ FeedsModelStandardFeed::~FeedsModelStandardFeed() { qDebug("Destroying FeedsModelStandardFeed instance."); } -void FeedsModelStandardFeed::setDescription(const QString &description) { - m_description = description; -} - FeedsModelStandardFeed *FeedsModelStandardFeed::loadFromRecord(const QSqlRecord &record) { FeedsModelStandardFeed *feed = new FeedsModelStandardFeed(NULL); @@ -42,14 +38,6 @@ FeedsModelStandardFeed *FeedsModelStandardFeed::loadFromRecord(const QSqlRecord return feed; } -QDateTime FeedsModelStandardFeed::creationDate() const { - return m_creationDate; -} - -void FeedsModelStandardFeed::setCreationDate(const QDateTime &creation_date) { - m_creationDate = creation_date; -} - QString FeedsModelStandardFeed::encoding() const { return m_encoding; } @@ -74,10 +62,6 @@ void FeedsModelStandardFeed::setLanguage(const QString &language) { m_language = language; } -QString FeedsModelStandardFeed::description() const { - return m_description; -} - QVariant FeedsModelStandardFeed::data(int column, int role) const { switch (role) { case Qt::DisplayRole: @@ -114,13 +98,12 @@ QVariant FeedsModelStandardFeed::data(int column, int role) const { case Qt::ToolTipRole: if (column == FDS_MODEL_TITLE_INDEX) { - return QObject::tr("%1\n\n" - "Feed type: %2\n" - "URL: %3\n" + return QObject::tr("%1 (%2)\n" + "%3\n\n" "Encoding: %4\n" "Language: %5").arg(m_title, FeedsModelFeed::typeToString(m_type), - m_url, + m_description, m_encoding, m_language.isEmpty() ? "-" : @@ -206,7 +189,7 @@ void FeedsModelStandardFeed::update() { void FeedsModelStandardFeed::updateMessages(const QList &messages) { int feed_id = id(), message_id; qint64 message_creation_date; - QSqlDatabase database = DatabaseFactory::getInstance()->addConnection("FeedsModelStandardFeed"); + QSqlDatabase database = DatabaseFactory::getInstance()->connection("FeedsModelStandardFeed"); // Prepare queries. QSqlQuery query_select(database); diff --git a/src/core/feedsmodelstandardfeed.h b/src/core/feedsmodelstandardfeed.h index 1ea7ff241..4dd4dcc8d 100644 --- a/src/core/feedsmodelstandardfeed.h +++ b/src/core/feedsmodelstandardfeed.h @@ -25,12 +25,6 @@ class FeedsModelStandardFeed : public FeedsModelFeed { void update(); // Various getters/setters. - QString description() const; - void setDescription(const QString &description); - - QDateTime creationDate() const; - void setCreationDate(const QDateTime &creation_date); - QString encoding() const; void setEncoding(const QString &encoding); @@ -50,10 +44,8 @@ class FeedsModelStandardFeed : public FeedsModelFeed { void updateMessages(const QList &messages); private: - QDateTime m_creationDate; QString m_encoding; QString m_url; - QString m_description; QString m_language; }; diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp index 5a0bc3b0b..7c81fdadb 100644 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -13,7 +13,7 @@ MessagesModel::MessagesModel(QObject *parent) : QSqlTableModel(parent, - DatabaseFactory::getInstance()->addConnection("MessagesModel")) { + DatabaseFactory::getInstance()->connection("MessagesModel")) { setObjectName("MessagesModel"); setupFonts(); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index dc8ca3746..a2fade48b 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -134,18 +134,10 @@ void FeedsView::markAllFeedsRead() { } void FeedsView::openSelectedFeedsInNewspaperMode() { - QList selected_feeds = selectedFeeds(); - QList messages = m_sourceModel->messagesForFeeds(selected_feeds); + QList messages = m_sourceModel->messagesForFeeds(selectedFeeds()); if (!messages.isEmpty()) { emit newspaperModeRequested(messages); - - // Moreover, mark those feeds as read because they were opened in - // newspaper mode, thus, they are read. - m_sourceModel->markFeedsRead(selected_feeds, 1); - updateCountsOfAllFeeds(false); - - emit feedsNeedToBeReloaded(1); } } diff --git a/src/gui/formmain.ui b/src/gui/formmain.ui index 626684b02..be45a9584 100644 --- a/src/gui/formmain.ui +++ b/src/gui/formmain.ui @@ -298,7 +298,7 @@ Mark &selected items read - Marks all messages (without message filters) from selected feeds as read. + Mark all messages (without message filters) from selected feeds as read. @@ -306,7 +306,7 @@ Mark selected items unread - Marks all messages (without message filters) from selected feeds as unread. + Mark all messages (without message filters) from selected feeds as unread. @@ -322,7 +322,7 @@ Clear selected items - Removes all messages from selected feeds. + Remove all messages from selected feeds. @@ -398,7 +398,7 @@ View selected items in newspaper mode - Displays all messages from selected feeds/categories in a new "newspaper mode" tab. All selected feeds are marked as read. + Displays all messages from selected feeds/categories in a new "newspaper mode" tab. Note that messages are not set as read automatically.