Progresss.....

This commit is contained in:
Martin Rotter 2013-12-12 10:10:17 +01:00
parent 93e1fb0ef7
commit 5742c60051
23 changed files with 142 additions and 103 deletions

View File

@ -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

View File

@ -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
);
-- !

View File

@ -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

View File

@ -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() {

View File

@ -2,7 +2,7 @@
FeedsModelCategory::FeedsModelCategory(FeedsModelRootItem *parent_item)
: FeedsModelNonRootItem(parent_item) {
: FeedsModelRootItem(parent_item) {
}
FeedsModelCategory::~FeedsModelCategory() {

View File

@ -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);

View File

@ -2,7 +2,7 @@
FeedsModelFeed::FeedsModelFeed(FeedsModelRootItem *parent_item)
:FeedsModelNonRootItem(parent_item) {
: FeedsModelRootItem(parent_item) {
}
FeedsModelFeed::~FeedsModelFeed() {

View File

@ -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.

View File

@ -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<FeedsModelRootItem*>(m_parentItem)->m_childItems.indexOf((FeedsModelRootItem*) this);
}
else {
return 0;
}
}

View File

@ -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

View File

@ -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 {
if (m_parentItem) {
return m_parentItem->m_childItems.indexOf(const_cast<FeedsModelRootItem*>(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();
}

View File

@ -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<FeedsModelRootItem*> m_childItems;
FeedsModelRootItem *m_parentItem;
};

View File

@ -1,3 +1,5 @@
#include <QVariant>
#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();
}
}

View File

@ -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

View File

@ -1,3 +1,5 @@
#include <QVariant>
#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();
}
}

View File

@ -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

View File

@ -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:

View File

@ -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);

View File

@ -11,6 +11,7 @@ class FeedsView : public QTreeView {
Q_OBJECT
public:
// Constructors and destructors.
explicit FeedsView(QWidget *parent = 0);
virtual ~FeedsView();

View File

@ -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.");
}

View File

@ -101,6 +101,7 @@
<addaction name="m_actionUpdateSelectedFeeds"/>
<addaction name="separator"/>
<addaction name="m_actionAddNewFeed"/>
<addaction name="m_actionAddNewCategory"/>
<addaction name="m_actionEditSelectedFeed"/>
<addaction name="m_actionDeleteSelectedFeeds"/>
<addaction name="separator"/>
@ -136,7 +137,7 @@
<string>Import stuff.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+I</string>
<string notr="true">Ctrl+Shift+I</string>
</property>
</action>
<action name="m_actionExport">
@ -147,7 +148,7 @@
<string>Export stuff.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+E</string>
<string notr="true">Ctrl+Shift+E</string>
</property>
</action>
<action name="m_actionQuit">
@ -158,7 +159,7 @@
<string>Quit the application.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+Q</string>
<string notr="true">Ctrl+Shift+Q</string>
</property>
</action>
<action name="m_actionSettings">
@ -169,7 +170,7 @@
<string>Display settings of the application.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>
<string notr="true">Ctrl+Shift+S</string>
</property>
</action>
<action name="m_actionAboutGuard">
@ -180,7 +181,7 @@
<string>About RSS Guard.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+A</string>
<string notr="true">Ctrl+Shift+A</string>
</property>
</action>
<action name="m_actionFullscreen">
@ -194,7 +195,7 @@
<string>Switch fullscreen mode.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+F</string>
<string notr="true">Ctrl+Shift+F</string>
</property>
</action>
<action name="m_actionAddBrowser">
@ -205,7 +206,7 @@
<string>Add new web browser tab.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+T</string>
<string notr="true">Ctrl+Shift+T</string>
</property>
</action>
<action name="m_actionCloseAllTabs">
@ -227,7 +228,7 @@
<string>Close current web browser tab.</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+C</string>
<string notr="true">Ctrl+Shift+C</string>
</property>
</action>
<action name="m_actionNoActions">
@ -251,6 +252,9 @@
<property name="toolTip">
<string>Update all feeds.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionUpdateSelectedFeeds">
<property name="text">
@ -259,6 +263,9 @@
<property name="toolTip">
<string>Update selected feeds/categories.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionEditSelectedFeed">
<property name="text">
@ -267,6 +274,9 @@
<property name="toolTip">
<string>Edit selected feed/category.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionDeleteSelectedFeeds">
<property name="text">
@ -275,6 +285,9 @@
<property name="toolTip">
<string>Delete selected feeds/categories.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionMarkSelectedMessagesAsRead">
<property name="text">
@ -316,6 +329,9 @@
<property name="toolTip">
<string>Mark selected feed(s)/category(ies) as read.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionMarkAllMessagesAsRead">
<property name="text">
@ -324,6 +340,9 @@
<property name="toolTip">
<string>Mark all messages read.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionMarkAllMessagesAsUnread">
<property name="text">
@ -332,6 +351,9 @@
<property name="toolTip">
<string>Mark all messages unread.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionDeleteSelectedMessages">
<property name="text">
@ -340,6 +362,9 @@
<property name="toolTip">
<string>Delete selected messages.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionDeleteAllMessages">
<property name="text">
@ -348,6 +373,9 @@
<property name="toolTip">
<string>Delete all messages.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionAddNewFeed">
<property name="text">
@ -356,6 +384,9 @@
<property name="toolTip">
<string>Add new feed.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionOpenSelectedSourceArticlesExternally">
<property name="text">
@ -364,6 +395,9 @@
<property name="toolTip">
<string>Open selected source articles in external browser.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionOpenSelectedMessagesInternally">
<property name="text">
@ -383,6 +417,17 @@
<property name="toolTip">
<string>Open selected source messages in internal browser.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionAddNewCategory">
<property name="text">
<string>Add new &amp;category</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
</widget>
<customwidgets>

View File

@ -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<Skin>();

View File

@ -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>();
QColor(0, 100, 0, 100)).value<QColor>();
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));