diff --git a/CMakeLists.txt b/CMakeLists.txt index b833d490d..0b1cd88fa 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,7 +271,6 @@ set(APP_SOURCES src/core/feedsproxymodel.cpp src/core/feedsmodelcategory.cpp src/core/feedsmodelrootitem.cpp - src/core/feedsmodelnonrootitem.cpp src/core/feedsmodelfeed.cpp src/core/feedsmodelstandardcategory.cpp src/core/feedsmodelstandardfeed.cpp diff --git a/resources/misc/db_init.sql b/resources/misc/db_init.sql index 6b8c6e808..01d518148 100644 --- a/resources/misc/db_init.sql +++ b/resources/misc/db_init.sql @@ -32,6 +32,7 @@ CREATE TABLE IF NOT EXISTS Feeds ( category INTEGER NOT NULL CHECK (category >= -1), encoding TEXT NOT NULL CHECK (encoding != ''), url TEXT NOT NULL UNIQUE CHECK (url != ''), + language TEXT, type INTEGER NOT NULL ); -- ! diff --git a/src/core/debugging.cpp b/src/core/debugging.cpp index 881c46a3d..2e07d2d9f 100644 --- a/src/core/debugging.cpp +++ b/src/core/debugging.cpp @@ -48,9 +48,9 @@ void Debugging::debugHandler(QtMsgType type, break; } #else - Q_UNUSED(type); - Q_UNUSED(placement); - Q_UNUSED(message); + Q_UNUSED(type) + Q_UNUSED(placement) + Q_UNUSED(message) #endif } #else @@ -73,8 +73,8 @@ void Debugging::debugHandler(QtMsgType type, const char *message) { break; } #else - Q_UNUSED(type); - Q_UNUSED(message); + Q_UNUSED(type) + Q_UNUSED(message) #endif } #endif diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index 79305198a..8ade74f36 100644 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -1,17 +1,28 @@ #include "core/feedsmodel.h" -#include "core/feedsmodelrootitem.h" -#include "core/feedsmodelnonrootitem.h" -#include "core/feedsmodelfeed.h" -#include "core/feedsmodelcategory.h" +#include "core/feedsmodelstandardcategory.h" +#include "core/feedsmodelstandardfeed.h" + FeedsModel::FeedsModel(QObject *parent) : QAbstractItemModel(parent) { - m_rootItem = new FeedsModelRootItem(); + m_rootItem = new FeedsModelRootItem(NULL); - FeedsModelCategory *cat = new FeedsModelCategory(m_rootItem); - cat->m_childItems.append(new FeedsModelFeed(cat)); - m_rootItem->m_childItems.append(cat); + FeedsModelStandardCategory *cat1 = new FeedsModelStandardCategory(m_rootItem); + FeedsModelStandardCategory *cat2 = new FeedsModelStandardCategory(cat1); + FeedsModelStandardFeed *feed1 = new FeedsModelStandardFeed(cat1); + FeedsModelStandardFeed *feed2 = new FeedsModelStandardFeed(cat1); + FeedsModelStandardFeed *feed3 = new FeedsModelStandardFeed(m_rootItem); + FeedsModelStandardFeed *feed4 = new FeedsModelStandardFeed(cat2); + FeedsModelStandardFeed *feed5 = new FeedsModelStandardFeed(cat2); + cat1->appendChild(feed1); + cat1->appendChild(feed2); + cat1->appendChild(cat2); + cat2->appendChild(feed4); + cat2->appendChild(feed5); + + m_rootItem->appendChild(cat1); + m_rootItem->appendChild(feed3); } FeedsModel::~FeedsModel() { diff --git a/src/core/feedsmodelcategory.cpp b/src/core/feedsmodelcategory.cpp index 0dc4a21eb..0d5680318 100644 --- a/src/core/feedsmodelcategory.cpp +++ b/src/core/feedsmodelcategory.cpp @@ -2,7 +2,7 @@ FeedsModelCategory::FeedsModelCategory(FeedsModelRootItem *parent_item) - : FeedsModelNonRootItem(parent_item) { + : FeedsModelRootItem(parent_item) { } FeedsModelCategory::~FeedsModelCategory() { diff --git a/src/core/feedsmodelcategory.h b/src/core/feedsmodelcategory.h index 717634431..6ca36cab3 100644 --- a/src/core/feedsmodelcategory.h +++ b/src/core/feedsmodelcategory.h @@ -1,12 +1,12 @@ #ifndef FEEDSMODELCLASSICCATEGORY_H #define FEEDSMODELCLASSICCATEGORY_H -#include "core/feedsmodelnonrootitem.h" +#include "core/feedsmodelrootitem.h" // Base class for all categories contained in FeedsModel. // NOTE: This class should be derived to create PARTICULAR category types. -class FeedsModelCategory : public FeedsModelNonRootItem { +class FeedsModelCategory : public FeedsModelRootItem { public: // Constructors and destructors explicit FeedsModelCategory(FeedsModelRootItem *parent_item); diff --git a/src/core/feedsmodelfeed.cpp b/src/core/feedsmodelfeed.cpp index 51a9c3090..e74126bdc 100644 --- a/src/core/feedsmodelfeed.cpp +++ b/src/core/feedsmodelfeed.cpp @@ -2,7 +2,7 @@ FeedsModelFeed::FeedsModelFeed(FeedsModelRootItem *parent_item) - :FeedsModelNonRootItem(parent_item) { + : FeedsModelRootItem(parent_item) { } FeedsModelFeed::~FeedsModelFeed() { diff --git a/src/core/feedsmodelfeed.h b/src/core/feedsmodelfeed.h index cbbace0a8..8125610c2 100644 --- a/src/core/feedsmodelfeed.h +++ b/src/core/feedsmodelfeed.h @@ -1,12 +1,12 @@ #ifndef FEEDSMODELFEED_H #define FEEDSMODELFEED_H -#include "core/feedsmodelnonrootitem.h" +#include "core/feedsmodelrootitem.h" // Represents BASE class for feeds contained in FeedsModel. // NOTE: This class should be derived to create PARTICULAR feed types. -class FeedsModelFeed : public FeedsModelNonRootItem +class FeedsModelFeed : public FeedsModelRootItem { public: // Constructors and destructors. diff --git a/src/core/feedsmodelnonrootitem.cpp b/src/core/feedsmodelnonrootitem.cpp deleted file mode 100644 index 523395464..000000000 --- a/src/core/feedsmodelnonrootitem.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "core/feedsmodelnonrootitem.h" - - -FeedsModelNonRootItem::FeedsModelNonRootItem(FeedsModelRootItem *parent_item) - : FeedsModelRootItem(), m_parentItem(parent_item) { -} - -FeedsModelNonRootItem::~FeedsModelNonRootItem() { - qDebug("Destroying FeedsModelNonRootItem instance."); -} - -FeedsModelRootItem *FeedsModelNonRootItem::parent() { - return m_parentItem; -} - -int FeedsModelNonRootItem::row() const { - if (m_parentItem) { - return static_cast(m_parentItem)->m_childItems.indexOf((FeedsModelRootItem*) this); - } - else { - return 0; - } -} diff --git a/src/core/feedsmodelnonrootitem.h b/src/core/feedsmodelnonrootitem.h deleted file mode 100644 index f6dc2025c..000000000 --- a/src/core/feedsmodelnonrootitem.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FEEDSMODELNONROOTITEM_H -#define FEEDSMODELNONROOTITEM_H - -#include "core/feedsmodelrootitem.h" - - -// Base class for non-root items of FeedsModel. -// NOTE: This class add member for pointer to parent item (which is not needed -// for root item). -class FeedsModelNonRootItem : public FeedsModelRootItem { - public: - // Constructors and destructors. - explicit FeedsModelNonRootItem(FeedsModelRootItem *parent_item); - virtual ~FeedsModelNonRootItem(); - - FeedsModelRootItem *parent(); - int row() const; - - protected: - FeedsModelRootItem *m_parentItem; -}; - -#endif // FEEDSMODELNONROOTITEM_H diff --git a/src/core/feedsmodelrootitem.cpp b/src/core/feedsmodelrootitem.cpp index b0b65d63a..33fc2d0dc 100644 --- a/src/core/feedsmodelrootitem.cpp +++ b/src/core/feedsmodelrootitem.cpp @@ -3,7 +3,8 @@ #include "core/feedsmodelrootitem.h" -FeedsModelRootItem::FeedsModelRootItem() { +FeedsModelRootItem::FeedsModelRootItem(FeedsModelRootItem *parent_item) + : m_parentItem(parent_item) { } FeedsModelRootItem::~FeedsModelRootItem() { @@ -12,11 +13,15 @@ FeedsModelRootItem::~FeedsModelRootItem() { } FeedsModelRootItem *FeedsModelRootItem::parent() { - return NULL; + return m_parentItem; } FeedsModelRootItem *FeedsModelRootItem::child(int row) { - return m_childItems.at(0); + return m_childItems.value(row); +} + +void FeedsModelRootItem::appendChild(FeedsModelRootItem *child) { + m_childItems.append(child); } int FeedsModelRootItem::columnCount() const { @@ -24,7 +29,12 @@ int FeedsModelRootItem::columnCount() const { } int FeedsModelRootItem::row() const { - return 0; + if (m_parentItem) { + return m_parentItem->m_childItems.indexOf(const_cast(this)); + } + else { + return 0; + } } int FeedsModelRootItem::childCount() const { @@ -32,9 +42,8 @@ int FeedsModelRootItem::childCount() const { } QVariant FeedsModelRootItem::data(int column, int role) const { - if (role == Qt::DisplayRole) { - return "aaa"; - } + Q_UNUSED(column) + Q_UNUSED(role) return QVariant(); } diff --git a/src/core/feedsmodelrootitem.h b/src/core/feedsmodelrootitem.h index 810d656d4..b40b24ba7 100644 --- a/src/core/feedsmodelrootitem.h +++ b/src/core/feedsmodelrootitem.h @@ -13,11 +13,12 @@ class FeedsModelRootItem { public: // Constructors and destructors. - explicit FeedsModelRootItem(); + explicit FeedsModelRootItem(FeedsModelRootItem *parent_item); virtual ~FeedsModelRootItem(); virtual FeedsModelRootItem *parent(); virtual FeedsModelRootItem *child(int row); + virtual void appendChild(FeedsModelRootItem *child); virtual int childCount() const; virtual int columnCount() const; virtual int row() const; @@ -26,6 +27,7 @@ class FeedsModelRootItem { protected: QIcon m_icon; QList m_childItems; + FeedsModelRootItem *m_parentItem; }; diff --git a/src/core/feedsmodelstandardcategory.cpp b/src/core/feedsmodelstandardcategory.cpp index 88b82d040..0f14a8799 100644 --- a/src/core/feedsmodelstandardcategory.cpp +++ b/src/core/feedsmodelstandardcategory.cpp @@ -1,3 +1,5 @@ +#include + #include "core/feedsmodelstandardcategory.h" @@ -8,3 +10,12 @@ FeedsModelStandardCategory::FeedsModelStandardCategory(FeedsModelRootItem *paren FeedsModelStandardCategory::~FeedsModelStandardCategory() { qDebug("Destroying FeedsModelStandardCategory instance."); } + +QVariant FeedsModelStandardCategory::data(int column, int role) const { + if (role == Qt::DisplayRole) { + return "aaa"; + } + else { + return QVariant(); + } +} diff --git a/src/core/feedsmodelstandardcategory.h b/src/core/feedsmodelstandardcategory.h index 6dfb83d6b..cf89ddb36 100644 --- a/src/core/feedsmodelstandardcategory.h +++ b/src/core/feedsmodelstandardcategory.h @@ -14,6 +14,9 @@ class FeedsModelStandardCategory : public FeedsModelCategory { // Constructors and destructors. explicit FeedsModelStandardCategory(FeedsModelRootItem *parent_item); virtual ~FeedsModelStandardCategory(); + + QVariant data(int column, int role) const; + }; #endif // FEEDSMODELSTANDARDCATEGORY_H diff --git a/src/core/feedsmodelstandardfeed.cpp b/src/core/feedsmodelstandardfeed.cpp index d0e8180b2..b2ca9cd82 100644 --- a/src/core/feedsmodelstandardfeed.cpp +++ b/src/core/feedsmodelstandardfeed.cpp @@ -1,3 +1,5 @@ +#include + #include "feedsmodelstandardfeed.h" @@ -8,3 +10,12 @@ FeedsModelStandardFeed::FeedsModelStandardFeed(FeedsModelRootItem *parent_item) FeedsModelStandardFeed::~FeedsModelStandardFeed() { qDebug("Destroying FeedsModelStandardFeed instance."); } + +QVariant FeedsModelStandardFeed::data(int column, int role) const { + if (role == Qt::DisplayRole) { + return "bbb"; + } + else { + return QVariant(); + } +} diff --git a/src/core/feedsmodelstandardfeed.h b/src/core/feedsmodelstandardfeed.h index 75e265c7c..e946ecc0b 100644 --- a/src/core/feedsmodelstandardfeed.h +++ b/src/core/feedsmodelstandardfeed.h @@ -11,6 +11,9 @@ class FeedsModelStandardFeed : public FeedsModelFeed { // Constructors and destructors. explicit FeedsModelStandardFeed(FeedsModelRootItem *parent_item); virtual ~FeedsModelStandardFeed(); + + QVariant data(int column, int role) const; + }; #endif // FEEDSMODELSTANDARDFEED_H diff --git a/src/core/messagesmodel.cpp b/src/core/messagesmodel.cpp index dfca2cbc7..95f0c8b9e 100644 --- a/src/core/messagesmodel.cpp +++ b/src/core/messagesmodel.cpp @@ -102,7 +102,7 @@ void MessagesModel::setupHeaderData() { } Qt::ItemFlags MessagesModel::flags(const QModelIndex &idx) const { - Q_UNUSED(idx); + Q_UNUSED(idx) if (m_isInEditingMode) { // NOTE: Editing of model must be temporarily enabled here. @@ -319,7 +319,7 @@ bool MessagesModel::setAllMessagesRead(int read) { QVariant MessagesModel::headerData(int section, Qt::Orientation orientation, int role) const { - Q_UNUSED(orientation); + Q_UNUSED(orientation) switch (role) { case Qt::DisplayRole: diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 1c6ab1471..d71dd60b6 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -65,23 +65,11 @@ void FeedMessageViewer::initialize() { m_toolBar->setAllowedAreas(Qt::TopToolBarArea); m_toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); - QToolButton *update_button = new QToolButton(m_toolBar); - update_button->setPopupMode(QToolButton::InstantPopup); - update_button->setIcon(IconThemeFactory::getInstance()->fromTheme("view-refresh")); - update_button->setText(tr("Update selected/all feeds")); - update_button->setToolTip(tr("Select which feeds you want to update.")); - - QMenu *update_menu = new QMenu(tr("Feed update menu"), update_button); - update_menu->addAction(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds); - update_menu->addAction(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds); - - update_button->setMenu(update_menu); - - QWidgetAction *update_action = new QWidgetAction(m_toolBar); - update_action->setDefaultWidget(update_button); - // Add everything to toolbar. - m_toolBar->addAction(update_action); + m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds); + m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionUpdateSelectedFeeds); + m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionAddNewFeed); + m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionEditSelectedFeed); m_toolBar->addSeparator(); m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkAllMessagesAsRead); m_toolBar->addAction(FormMain::getInstance()->m_ui->m_actionMarkAllMessagesAsUnread); diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index fb40897d7..a5eb8db02 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -11,6 +11,7 @@ class FeedsView : public QTreeView { Q_OBJECT public: + // Constructors and destructors. explicit FeedsView(QWidget *parent = 0); virtual ~FeedsView(); diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index ea2c31e48..5fc8af8bc 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -147,7 +147,7 @@ void FormMain::display() { } void FormMain::onCommitData(QSessionManager &manager) { - Q_UNUSED(manager); + Q_UNUSED(manager) qDebug("OS asked application to commit its data."); } diff --git a/src/gui/formmain.ui b/src/gui/formmain.ui index 9a4c04fb2..31289e2d8 100644 --- a/src/gui/formmain.ui +++ b/src/gui/formmain.ui @@ -101,6 +101,7 @@ + @@ -136,7 +137,7 @@ Import stuff. - Ctrl+Shift+I + Ctrl+Shift+I @@ -147,7 +148,7 @@ Export stuff. - Ctrl+Shift+E + Ctrl+Shift+E @@ -158,7 +159,7 @@ Quit the application. - Ctrl+Shift+Q + Ctrl+Shift+Q @@ -169,7 +170,7 @@ Display settings of the application. - Ctrl+Shift+S + Ctrl+Shift+S @@ -180,7 +181,7 @@ About RSS Guard. - Ctrl+Shift+A + Ctrl+Shift+A @@ -194,7 +195,7 @@ Switch fullscreen mode. - Ctrl+Shift+F + Ctrl+Shift+F @@ -205,7 +206,7 @@ Add new web browser tab. - Ctrl+Shift+T + Ctrl+Shift+T @@ -227,7 +228,7 @@ Close current web browser tab. - Ctrl+Shift+C + Ctrl+Shift+C @@ -251,6 +252,9 @@ Update all feeds. + + + @@ -259,6 +263,9 @@ Update selected feeds/categories. + + + @@ -267,6 +274,9 @@ Edit selected feed/category. + + + @@ -275,6 +285,9 @@ Delete selected feeds/categories. + + + @@ -316,6 +329,9 @@ Mark selected feed(s)/category(ies) as read. + + + @@ -324,6 +340,9 @@ Mark all messages read. + + + @@ -332,6 +351,9 @@ Mark all messages unread. + + + @@ -340,6 +362,9 @@ Delete selected messages. + + + @@ -348,6 +373,9 @@ Delete all messages. + + + @@ -356,6 +384,9 @@ Add new feed. + + + @@ -364,6 +395,9 @@ Open selected source articles in external browser. + + + @@ -383,6 +417,17 @@ Open selected source messages in internal browser. + + + + + + + Add new &category + + + + diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 64efb0a21..3d597f3e3 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -109,7 +109,7 @@ void FormSettings::changeDefaultBrowserArguments(int index) { void FormSettings::onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *previous) { - Q_UNUSED(previous); + Q_UNUSED(previous) if (current != NULL) { Skin skin = current->data(0, Qt::UserRole).value(); diff --git a/src/gui/locationlineedit.cpp b/src/gui/locationlineedit.cpp index 2f02af84d..861dd55bb 100644 --- a/src/gui/locationlineedit.cpp +++ b/src/gui/locationlineedit.cpp @@ -59,10 +59,11 @@ void LocationLineEdit::paintEvent(QPaintEvent *event) { QPalette current_palette = palette(); QColor loadingColor = settings->value(APP_CFG_BROWSER, "browser_progress_color", - QColor(0, 255, 0, 100)).value(); + QColor(0, 100, 0, 100)).value(); QLinearGradient gradient(0, 0, width(), 0); qreal percentage_border = m_progress / 100.0; + // TODO: Use better gradient here, something fancy. gradient.setColorAt(0, loadingColor); gradient.setColorAt(percentage_border - 0.01, loadingColor); gradient.setColorAt(percentage_border - 0.008, loadingColor.lighter(130));