Added ability to change auto-update strategy for individual TT-RSS feeds.
This commit is contained in:
parent
2324544aaf
commit
b4982e5666
10 changed files with 311 additions and 205 deletions
|
@ -444,6 +444,7 @@ set(APP_SOURCES
|
||||||
src/services/tt-rss/ttrsscategory.cpp
|
src/services/tt-rss/ttrsscategory.cpp
|
||||||
src/services/tt-rss/ttrssrecyclebin.cpp
|
src/services/tt-rss/ttrssrecyclebin.cpp
|
||||||
src/services/tt-rss/gui/formeditaccount.cpp
|
src/services/tt-rss/gui/formeditaccount.cpp
|
||||||
|
src/services/tt-rss/gui/formeditfeed.cpp
|
||||||
src/services/tt-rss/network/ttrssnetworkfactory.cpp
|
src/services/tt-rss/network/ttrssnetworkfactory.cpp
|
||||||
|
|
||||||
# NETWORK-WEB sources.
|
# NETWORK-WEB sources.
|
||||||
|
@ -566,6 +567,7 @@ set(APP_HEADERS
|
||||||
src/services/tt-rss/ttrssfeed.h
|
src/services/tt-rss/ttrssfeed.h
|
||||||
src/services/tt-rss/ttrsscategory.h
|
src/services/tt-rss/ttrsscategory.h
|
||||||
src/services/tt-rss/gui/formeditaccount.h
|
src/services/tt-rss/gui/formeditaccount.h
|
||||||
|
src/services/tt-rss/gui/formeditfeed.h
|
||||||
|
|
||||||
# NETWORK-WEB headers.
|
# NETWORK-WEB headers.
|
||||||
src/network-web/webpage.h
|
src/network-web/webpage.h
|
||||||
|
@ -608,6 +610,7 @@ set(APP_FORMS
|
||||||
|
|
||||||
# TT-RSS service forms.
|
# TT-RSS service forms.
|
||||||
src/services/tt-rss/gui/formeditaccount.ui
|
src/services/tt-rss/gui/formeditaccount.ui
|
||||||
|
src/services/tt-rss/gui/formeditfeed.ui
|
||||||
|
|
||||||
# NETWORK forms.
|
# NETWORK forms.
|
||||||
src/network-web/downloadmanager.ui
|
src/network-web/downloadmanager.ui
|
||||||
|
|
|
@ -50,3 +50,30 @@ QVariant Feed::data(int column, int role) const {
|
||||||
return RootItem::data(column, role);
|
return RootItem::data(column, role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Feed::autoUpdateInitialInterval() const {
|
||||||
|
return m_autoUpdateInitialInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Feed::setAutoUpdateInitialInterval(int auto_update_interval) {
|
||||||
|
// If new initial auto-update interval is set, then
|
||||||
|
// we should reset time that remains to the next auto-update.
|
||||||
|
m_autoUpdateInitialInterval = auto_update_interval;
|
||||||
|
m_autoUpdateRemainingInterval = auto_update_interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
Feed::AutoUpdateType Feed::autoUpdateType() const {
|
||||||
|
return m_autoUpdateType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Feed::setAutoUpdateType(Feed::AutoUpdateType auto_update_type) {
|
||||||
|
m_autoUpdateType = auto_update_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Feed::autoUpdateRemainingInterval() const {
|
||||||
|
return m_autoUpdateRemainingInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Feed::setAutoUpdateRemainingInterval(int auto_update_remaining_interval) {
|
||||||
|
m_autoUpdateRemainingInterval = auto_update_remaining_interval;
|
||||||
|
}
|
||||||
|
|
|
@ -69,32 +69,14 @@ class Feed : public RootItem {
|
||||||
// Members to override. */
|
// Members to override. */
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
|
|
||||||
inline int autoUpdateInitialInterval() const {
|
int autoUpdateInitialInterval() const;
|
||||||
return m_autoUpdateInitialInterval;
|
void setAutoUpdateInitialInterval(int auto_update_interval);
|
||||||
}
|
|
||||||
|
|
||||||
inline void setAutoUpdateInitialInterval(int auto_update_interval) {
|
AutoUpdateType autoUpdateType() const;
|
||||||
// If new initial auto-update interval is set, then
|
void setAutoUpdateType(AutoUpdateType auto_update_type);
|
||||||
// we should reset time that remains to the next auto-update.
|
|
||||||
m_autoUpdateInitialInterval = auto_update_interval;
|
|
||||||
m_autoUpdateRemainingInterval = auto_update_interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AutoUpdateType autoUpdateType() const {
|
int autoUpdateRemainingInterval() const;
|
||||||
return m_autoUpdateType;
|
void setAutoUpdateRemainingInterval(int auto_update_remaining_interval);
|
||||||
}
|
|
||||||
|
|
||||||
inline void setAutoUpdateType(const AutoUpdateType &autoUpdateType) {
|
|
||||||
m_autoUpdateType = autoUpdateType;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int autoUpdateRemainingInterval() const {
|
|
||||||
return m_autoUpdateRemainingInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void setAutoUpdateRemainingInterval(int autoUpdateRemainingInterval) {
|
|
||||||
m_autoUpdateRemainingInterval = autoUpdateRemainingInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Status status() const {
|
inline Status status() const {
|
||||||
return m_status;
|
return m_status;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "gui/messagebox.h"
|
#include "gui/messagebox.h"
|
||||||
#include "gui/systemtrayicon.h"
|
#include "gui/systemtrayicon.h"
|
||||||
#include "gui/dialogs/formmain.h"
|
#include "gui/dialogs/formmain.h"
|
||||||
|
#include "services/abstract/category.h"
|
||||||
#include "services/standard/standardcategory.h"
|
#include "services/standard/standardcategory.h"
|
||||||
#include "services/standard/standardserviceroot.h"
|
#include "services/standard/standardserviceroot.h"
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ void FormStandardCategoryDetails::setEditableCategory(StandardCategory *editable
|
||||||
|
|
||||||
int FormStandardCategoryDetails::exec(StandardCategory *input_category, RootItem *parent_to_select) {
|
int FormStandardCategoryDetails::exec(StandardCategory *input_category, RootItem *parent_to_select) {
|
||||||
// Load categories.
|
// Load categories.
|
||||||
loadCategories(m_serviceRoot->allCategories(), m_serviceRoot, input_category);
|
loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot, input_category);
|
||||||
|
|
||||||
if (input_category == NULL) {
|
if (input_category == NULL) {
|
||||||
// User is adding new category.
|
// User is adding new category.
|
||||||
|
@ -246,14 +247,14 @@ void FormStandardCategoryDetails::initialize() {
|
||||||
m_ui->m_txtTitle->lineEdit()->setFocus(Qt::TabFocusReason);
|
m_ui->m_txtTitle->lineEdit()->setFocus(Qt::TabFocusReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormStandardCategoryDetails::loadCategories(const QList<StandardCategory*> categories,
|
void FormStandardCategoryDetails::loadCategories(const QList<Category*> categories,
|
||||||
RootItem *root_item,
|
RootItem *root_item,
|
||||||
StandardCategory *input_category) {
|
StandardCategory *input_category) {
|
||||||
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||||
root_item->title(),
|
root_item->title(),
|
||||||
QVariant::fromValue((void*) root_item));
|
QVariant::fromValue((void*) root_item));
|
||||||
|
|
||||||
foreach (StandardCategory *category, categories) {
|
foreach (Category *category, categories) {
|
||||||
if (input_category != NULL && (category == input_category || category->isChildOf(input_category))) {
|
if (input_category != NULL && (category == input_category || category->isChildOf(input_category))) {
|
||||||
// This category cannot be selected as the new
|
// This category cannot be selected as the new
|
||||||
// parent for currently edited category, so
|
// parent for currently edited category, so
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace Ui {
|
||||||
class FormStandardCategoryDetails;
|
class FormStandardCategoryDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Category;
|
||||||
class StandardCategory;
|
class StandardCategory;
|
||||||
class StandardServiceRoot;
|
class StandardServiceRoot;
|
||||||
class FeedsModel;
|
class FeedsModel;
|
||||||
|
@ -72,7 +73,7 @@ class FormStandardCategoryDetails : public QDialog {
|
||||||
// Loads categories into the dialog + give root "category"
|
// Loads categories into the dialog + give root "category"
|
||||||
// and make sure that no childs of input category (including)
|
// and make sure that no childs of input category (including)
|
||||||
// input category are loaded.
|
// input category are loaded.
|
||||||
void loadCategories(const QList<StandardCategory*> categories, RootItem *root_item, StandardCategory *input_category);
|
void loadCategories(const QList<Category *> categories, RootItem *root_item, StandardCategory *input_category);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FormStandardCategoryDetails *m_ui;
|
Ui::FormStandardCategoryDetails *m_ui;
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
#include "core/feedsmodel.h"
|
#include "core/feedsmodel.h"
|
||||||
#include "services/abstract/rootitem.h"
|
#include "services/abstract/rootitem.h"
|
||||||
|
#include "services/abstract/category.h"
|
||||||
#include "services/standard/standardserviceroot.h"
|
#include "services/standard/standardserviceroot.h"
|
||||||
#include "services/standard/standardcategory.h"
|
|
||||||
#include "services/standard/standardfeed.h"
|
#include "services/standard/standardfeed.h"
|
||||||
#include "miscellaneous/textfactory.h"
|
#include "miscellaneous/textfactory.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
|
@ -61,7 +61,7 @@ FormStandardFeedDetails::~FormStandardFeedDetails() {
|
||||||
|
|
||||||
int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select) {
|
int FormStandardFeedDetails::exec(StandardFeed *input_feed, RootItem *parent_to_select) {
|
||||||
// Load categories.
|
// Load categories.
|
||||||
loadCategories(m_serviceRoot->allCategories(), m_serviceRoot);
|
loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot);
|
||||||
|
|
||||||
if (input_feed == NULL) {
|
if (input_feed == NULL) {
|
||||||
// User is adding new category.
|
// User is adding new category.
|
||||||
|
@ -169,15 +169,15 @@ void FormStandardFeedDetails::onAuthenticationSwitched() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormStandardFeedDetails::onAutoUpdateTypeChanged(int new_index) {
|
void FormStandardFeedDetails::onAutoUpdateTypeChanged(int new_index) {
|
||||||
StandardFeed::AutoUpdateType auto_update_type = static_cast<StandardFeed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt());
|
Feed::AutoUpdateType auto_update_type = static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(new_index).toInt());
|
||||||
|
|
||||||
switch (auto_update_type) {
|
switch (auto_update_type) {
|
||||||
case StandardFeed::DontAutoUpdate:
|
case Feed::DontAutoUpdate:
|
||||||
case StandardFeed::DefaultAutoUpdate:
|
case Feed::DefaultAutoUpdate:
|
||||||
m_ui->m_spinAutoUpdateInterval->setEnabled(false);
|
m_ui->m_spinAutoUpdateInterval->setEnabled(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case StandardFeed::SpecificAutoUpdate:
|
case Feed::SpecificAutoUpdate:
|
||||||
default:
|
default:
|
||||||
m_ui->m_spinAutoUpdateInterval->setEnabled(true);
|
m_ui->m_spinAutoUpdateInterval->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ void FormStandardFeedDetails::apply() {
|
||||||
new_feed->setPasswordProtected(m_ui->m_gbAuthentication->isChecked());
|
new_feed->setPasswordProtected(m_ui->m_gbAuthentication->isChecked());
|
||||||
new_feed->setUsername(m_ui->m_txtUsername->lineEdit()->text());
|
new_feed->setUsername(m_ui->m_txtUsername->lineEdit()->text());
|
||||||
new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text());
|
new_feed->setPassword(m_ui->m_txtPassword->lineEdit()->text());
|
||||||
new_feed->setAutoUpdateType(static_cast<StandardFeed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
new_feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||||
new_feed->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value());
|
new_feed->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value());
|
||||||
|
|
||||||
if (m_editableFeed == NULL) {
|
if (m_editableFeed == NULL) {
|
||||||
|
@ -458,9 +458,9 @@ void FormStandardFeedDetails::initialize() {
|
||||||
|
|
||||||
// Setup auto-update options.
|
// Setup auto-update options.
|
||||||
m_ui->m_spinAutoUpdateInterval->setValue(DEFAULT_AUTO_UPDATE_INTERVAL);
|
m_ui->m_spinAutoUpdateInterval->setValue(DEFAULT_AUTO_UPDATE_INTERVAL);
|
||||||
m_ui->m_cmbAutoUpdateType->addItem(tr("Auto-update using global interval"), QVariant::fromValue((int) StandardFeed::DefaultAutoUpdate));
|
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) StandardFeed::SpecificAutoUpdate));
|
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) StandardFeed::DontAutoUpdate));
|
m_ui->m_cmbAutoUpdateType->addItem(tr("Do not auto-update at all"), QVariant::fromValue((int) Feed::DontAutoUpdate));
|
||||||
|
|
||||||
// Set tab order.
|
// Set tab order.
|
||||||
setTabOrder(m_ui->m_cmbParentCategory, m_ui->m_cmbType);
|
setTabOrder(m_ui->m_cmbParentCategory, m_ui->m_cmbType);
|
||||||
|
@ -484,13 +484,13 @@ void FormStandardFeedDetails::initialize() {
|
||||||
m_ui->m_txtUrl->lineEdit()->setFocus(Qt::TabFocusReason);
|
m_ui->m_txtUrl->lineEdit()->setFocus(Qt::TabFocusReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormStandardFeedDetails::loadCategories(const QList<StandardCategory*> categories,
|
void FormStandardFeedDetails::loadCategories(const QList<Category*> categories,
|
||||||
RootItem *root_item) {
|
RootItem *root_item) {
|
||||||
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||||
root_item->title(),
|
root_item->title(),
|
||||||
QVariant::fromValue((void*) root_item));
|
QVariant::fromValue((void*) root_item));
|
||||||
|
|
||||||
foreach (StandardCategory *category, categories) {
|
foreach (Category *category, categories) {
|
||||||
m_ui->m_cmbParentCategory->addItem(category->icon(),
|
m_ui->m_cmbParentCategory->addItem(category->icon(),
|
||||||
category->title(),
|
category->title(),
|
||||||
QVariant::fromValue((void*) category));
|
QVariant::fromValue((void*) category));
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Ui {
|
||||||
|
|
||||||
class StandardServiceRoot;
|
class StandardServiceRoot;
|
||||||
class StandardFeed;
|
class StandardFeed;
|
||||||
class StandardCategory;
|
class Category;
|
||||||
class RootItem;
|
class RootItem;
|
||||||
|
|
||||||
class FormStandardFeedDetails : public QDialog {
|
class FormStandardFeedDetails : public QDialog {
|
||||||
|
@ -78,8 +78,7 @@ class FormStandardFeedDetails : public QDialog {
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
// Loads categories into the dialog from the model.
|
// Loads categories into the dialog from the model.
|
||||||
void loadCategories(const QList<StandardCategory*> categories,
|
void loadCategories(const QList<Category*> categories, RootItem *root_item);
|
||||||
RootItem *root_item);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FormStandardFeedDetails *m_ui;
|
Ui::FormStandardFeedDetails *m_ui;
|
||||||
|
|
|
@ -7,13 +7,32 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>541</width>
|
<width>541</width>
|
||||||
<height>339</height>
|
<height>377</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string notr="true">Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_lblTitle">
|
||||||
|
<property name="text">
|
||||||
|
<string>URL</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_txtUrl</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QGroupBox" name="m_gbAuthentication">
|
<widget class="QGroupBox" name="m_gbAuthentication">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -119,6 +138,13 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QPushButton" name="m_btnTestSetup">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Test setup</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="LabelWithStatus" name="m_lblTestResult" native="true">
|
<widget class="LabelWithStatus" name="m_lblTestResult" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -132,40 +158,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" colspan="2">
|
|
||||||
<widget class="QDialogButtonBox" name="m_buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="2">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="m_lblTitle">
|
|
||||||
<property name="text">
|
|
||||||
<string>URL</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>m_txtUrl</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
|
||||||
<widget class="QPushButton" name="m_btnTestSetup">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Test setup</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="2" column="0" colspan="2">
|
||||||
<widget class="QCheckBox" name="m_checkServerSideUpdate">
|
<widget class="QCheckBox" name="m_checkServerSideUpdate">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -184,6 +176,18 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="m_buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -22,12 +22,15 @@
|
||||||
#include "miscellaneous/databasefactory.h"
|
#include "miscellaneous/databasefactory.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "miscellaneous/textfactory.h"
|
#include "miscellaneous/textfactory.h"
|
||||||
|
#include "gui/dialogs/formmain.h"
|
||||||
#include "services/tt-rss/definitions.h"
|
#include "services/tt-rss/definitions.h"
|
||||||
#include "services/tt-rss/ttrssserviceroot.h"
|
#include "services/tt-rss/ttrssserviceroot.h"
|
||||||
|
#include "services/tt-rss/gui/formeditfeed.h"
|
||||||
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
||||||
|
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
|
||||||
TtRssFeed::TtRssFeed(RootItem *parent)
|
TtRssFeed::TtRssFeed(RootItem *parent)
|
||||||
|
@ -50,6 +53,49 @@ TtRssServiceRoot *TtRssFeed::serviceRoot() {
|
||||||
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant TtRssFeed::data(int column, int role) const {
|
||||||
|
switch (role) {
|
||||||
|
case Qt::ToolTipRole:
|
||||||
|
if (column == FDS_MODEL_TITLE_INDEX) {
|
||||||
|
QString auto_update_string;
|
||||||
|
|
||||||
|
switch (autoUpdateType()) {
|
||||||
|
case DontAutoUpdate:
|
||||||
|
//: Describes feed auto-update status.
|
||||||
|
auto_update_string = tr("does not use auto-update");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DefaultAutoUpdate:
|
||||||
|
//: Describes feed auto-update status.
|
||||||
|
auto_update_string = tr("uses global settings");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SpecificAutoUpdate:
|
||||||
|
default:
|
||||||
|
//: Describes feed auto-update status.
|
||||||
|
auto_update_string = tr("uses specific settings "
|
||||||
|
"(%n minute(s) to next auto-update)",
|
||||||
|
0,
|
||||||
|
autoUpdateRemainingInterval());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//: Tooltip for feed.
|
||||||
|
return tr("%1"
|
||||||
|
"%2\n\n"
|
||||||
|
"Auto-update status: %3").arg(title(),
|
||||||
|
description().isEmpty() ? QString() : QString('\n') + description(),
|
||||||
|
auto_update_string);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Feed::data(column, role);
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Feed::data(column, role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TtRssFeed::updateCounts(bool including_total_count) {
|
void TtRssFeed::updateCounts(bool including_total_count) {
|
||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
QSqlQuery query_all(database);
|
QSqlQuery query_all(database);
|
||||||
|
@ -76,6 +122,18 @@ void TtRssFeed::updateCounts(bool including_total_count) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TtRssFeed::canBeEdited() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TtRssFeed::editViaGui() {
|
||||||
|
QPointer<FormEditFeed> form_pointer = new FormEditFeed(serviceRoot(), qApp->mainForm());
|
||||||
|
|
||||||
|
form_pointer.data()->execForEdit(this);
|
||||||
|
delete form_pointer.data();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int TtRssFeed::countOfAllMessages() const {
|
int TtRssFeed::countOfAllMessages() const {
|
||||||
return m_totalCount;
|
return m_totalCount;
|
||||||
}
|
}
|
||||||
|
@ -171,6 +229,30 @@ void TtRssFeed::setCustomId(int custom_id) {
|
||||||
m_customId = custom_id;
|
m_customId = custom_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TtRssFeed::editItself(TtRssFeed *new_feed_data) {
|
||||||
|
QSqlDatabase database = qApp->database()->connection("aa", DatabaseFactory::FromSettings);
|
||||||
|
QSqlQuery query_update(database);
|
||||||
|
|
||||||
|
query_update.setForwardOnly(true);
|
||||||
|
query_update.prepare("UPDATE Feeds "
|
||||||
|
"SET update_type = :update_type, update_interval = :update_interval "
|
||||||
|
"WHERE id = :id;");
|
||||||
|
|
||||||
|
query_update.bindValue(QSL(":update_type"), (int) new_feed_data->autoUpdateType());
|
||||||
|
query_update.bindValue(QSL(":update_interval"), new_feed_data->autoUpdateInitialInterval());
|
||||||
|
query_update.bindValue(QSL(":id"), id());
|
||||||
|
|
||||||
|
if (query_update.exec()) {
|
||||||
|
setAutoUpdateType(new_feed_data->autoUpdateType());
|
||||||
|
setAutoUpdateInitialInterval(new_feed_data->autoUpdateInitialInterval());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int TtRssFeed::updateMessages(const QList<Message> &messages) {
|
int TtRssFeed::updateMessages(const QList<Message> &messages) {
|
||||||
if (messages.isEmpty()) {
|
if (messages.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -35,8 +35,13 @@ class TtRssFeed : public Feed {
|
||||||
|
|
||||||
TtRssServiceRoot *serviceRoot();
|
TtRssServiceRoot *serviceRoot();
|
||||||
|
|
||||||
|
QVariant data(int column, int role) const;
|
||||||
|
|
||||||
void updateCounts(bool including_total_count);
|
void updateCounts(bool including_total_count);
|
||||||
|
|
||||||
|
bool canBeEdited();
|
||||||
|
bool editViaGui();
|
||||||
|
|
||||||
int countOfAllMessages() const;
|
int countOfAllMessages() const;
|
||||||
int countOfUnreadMessages() const;
|
int countOfUnreadMessages() const;
|
||||||
|
|
||||||
|
@ -49,6 +54,8 @@ class TtRssFeed : public Feed {
|
||||||
int customId() const;
|
int customId() const;
|
||||||
void setCustomId(int custom_id);
|
void setCustomId(int custom_id);
|
||||||
|
|
||||||
|
bool editItself(TtRssFeed *new_feed_data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int updateMessages(const QList<Message> &messages);
|
int updateMessages(const QList<Message> &messages);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue