Can edit ownCloud feed auto-update policy.

This commit is contained in:
Martin Rotter 2016-04-13 09:10:14 +02:00
parent a822d6b8c6
commit 4c44bc2859
5 changed files with 20 additions and 36 deletions

View File

@ -8,7 +8,7 @@ Main:
Added:
▪ ownCloud plugin now can delete feeds.
▪ ownCloud plugin now can delete feeds and edit auto-update policy of feeds.
▪ Global auto-update feed interval spinbox now has better format. (issue #176)
▪ Message preview's font is now fully adjustable in settings. (issue #177)
▪ RSS Guard now automatically switches to SQLite backend if MySQL is not available on program startup.

View File

@ -95,7 +95,7 @@ void FormEditOwnCloudFeed::performAction() {
saveFeed();
}
else {
addNewFeed();
// TODO: Add new feed.
}
accept();
@ -200,42 +200,10 @@ void FormEditOwnCloudFeed::saveFeed() {
new_feed_data->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
new_feed_data->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value());
// TODO: todo
//m_loadedFeed->editItself(new_feed_data);
m_loadedFeed->editItself(new_feed_data);
delete new_feed_data;
}
void FormEditOwnCloudFeed::addNewFeed() {
RootItem *parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
// TODO: TODO.
/*
OwnCloudServiceRoot *root = parent->kind() == RootItemKind::Category ?
qobject_cast<OwnCloudCategory*>(parent)->serviceRoot() :
qobject_cast<OwnCloudServiceRoot*>(parent);
const int category_id = parent->kind() == RootItemKind::ServiceRoot ?
0 :
qobject_cast<TtRssCategory*>(parent)->customId();
const TtRssSubscribeToFeedResponse response = root->network()->subscribeToFeed(m_ui->m_txtUrl->lineEdit()->text(),
category_id,
m_ui->m_gbAuthentication->isChecked(),
m_ui->m_txtUsername->lineEdit()->text(),
m_ui->m_txtPassword->lineEdit()->text());
if (response.code() == STF_INSERTED) {
// Feed was added online.
accept();
qApp->showGuiMessage(tr("Feed added"), tr("Feed was added, triggering sync in now."), QSystemTrayIcon::Information);
QTimer::singleShot(100, root, SLOT(syncIn()));
}
else {
reject();
qApp->showGuiMessage(tr("Cannot add feed"),
tr("Feed was not added due to error."),
QSystemTrayIcon::Critical, qApp->mainForm(), true);
}*/
}
void FormEditOwnCloudFeed::loadCategories(const QList<Category*> categories, RootItem *root_item) {
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
root_item->title(),

View File

@ -54,7 +54,6 @@ class FormEditOwnCloudFeed : public QDialog {
void initialize();
void loadFeed(OwnCloudFeed *input_feed);
void saveFeed();
void addNewFeed();
void loadCategories(const QList<Category*> categories, RootItem *root_item);
QScopedPointer<Ui::FormEditOwnCloudFeed> m_ui;

View File

@ -71,6 +71,21 @@ bool OwnCloudFeed::deleteViaGui() {
}
}
bool OwnCloudFeed::editItself(OwnCloudFeed *new_feed_data) {
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
if (!DatabaseQueries::editBaseFeed(database, id(), new_feed_data->autoUpdateType(),
new_feed_data->autoUpdateInitialInterval())) {
// Persistent storage update failed, no way to continue now.
return false;
}
else {
setAutoUpdateType(new_feed_data->autoUpdateType());
setAutoUpdateInitialInterval(new_feed_data->autoUpdateInitialInterval());
return true;
}
}
bool OwnCloudFeed::markAsReadUnread(RootItem::ReadStatus status) {
QStringList ids = getParentServiceRoot()->customIDSOfMessagesForItem(this);
QNetworkReply::NetworkError response = serviceRoot()->network()->markMessagesRead(status, ids);

View File

@ -36,6 +36,8 @@ class OwnCloudFeed : public Feed {
bool canBeDeleted() const;
bool deleteViaGui();
bool editItself(OwnCloudFeed *new_feed_data);
bool markAsReadUnread(ReadStatus status);
bool cleanMessages(bool clear_only_read);