Refactoring.
This commit is contained in:
parent
e1742d82e1
commit
9a0e17814e
@ -59,10 +59,7 @@ bool OwnCloudFeed::canBeDeleted() const {
|
||||
}
|
||||
|
||||
bool OwnCloudFeed::deleteViaGui() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||
|
||||
if (serviceRoot()->network()->deleteFeed(customId()) &&
|
||||
DatabaseQueries::deleteFeed(database, customId(), serviceRoot()->accountId())) {
|
||||
if (removeItself()) {
|
||||
serviceRoot()->requestItemRemoval(this);
|
||||
return true;
|
||||
}
|
||||
@ -86,6 +83,14 @@ bool OwnCloudFeed::editItself(OwnCloudFeed *new_feed_data) {
|
||||
}
|
||||
}
|
||||
|
||||
bool OwnCloudFeed::removeItself() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||
|
||||
return
|
||||
serviceRoot()->network()->deleteFeed(customId()) &&
|
||||
DatabaseQueries::deleteFeed(database, customId(), serviceRoot()->accountId());
|
||||
}
|
||||
|
||||
bool OwnCloudFeed::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
QStringList ids = getParentServiceRoot()->customIDSOfMessagesForItem(this);
|
||||
QNetworkReply::NetworkError response = serviceRoot()->network()->markMessagesRead(status, ids);
|
||||
|
@ -37,6 +37,7 @@ class OwnCloudFeed : public Feed {
|
||||
bool deleteViaGui();
|
||||
|
||||
bool editItself(OwnCloudFeed *new_feed_data);
|
||||
bool removeItself();
|
||||
|
||||
bool markAsReadUnread(ReadStatus status);
|
||||
bool cleanMessages(bool clear_only_read);
|
||||
|
@ -383,8 +383,8 @@ bool StandardFeed::addItself(RootItem *parent) {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||
bool ok;
|
||||
int new_id = DatabaseQueries::addFeed(database, parent->id(), parent->getParentServiceRoot()->accountId(), title(),
|
||||
description(), creationDate(), icon(), encoding(), url(), passwordProtected(),
|
||||
username(), password(), autoUpdateType(), autoUpdateInitialInterval(), type(), &ok);
|
||||
description(), creationDate(), icon(), encoding(), url(), passwordProtected(),
|
||||
username(), password(), autoUpdateType(), autoUpdateInitialInterval(), type(), &ok);
|
||||
|
||||
if (!ok) {
|
||||
// Query failed.
|
||||
@ -405,11 +405,11 @@ bool StandardFeed::editItself(StandardFeed *new_feed_data) {
|
||||
RootItem *new_parent = new_feed_data->parent();
|
||||
|
||||
if (!DatabaseQueries::editFeed(database, new_parent->id(), original_feed->id(), new_feed_data->title(),
|
||||
new_feed_data->description(), new_feed_data->icon(),
|
||||
new_feed_data->encoding(), new_feed_data->url(), new_feed_data->passwordProtected(),
|
||||
new_feed_data->username(), new_feed_data->password(),
|
||||
new_feed_data->autoUpdateType(), new_feed_data->autoUpdateInitialInterval(),
|
||||
new_feed_data->type())) {
|
||||
new_feed_data->description(), new_feed_data->icon(),
|
||||
new_feed_data->encoding(), new_feed_data->url(), new_feed_data->passwordProtected(),
|
||||
new_feed_data->username(), new_feed_data->password(),
|
||||
new_feed_data->autoUpdateType(), new_feed_data->autoUpdateInitialInterval(),
|
||||
new_feed_data->type())) {
|
||||
// Persistent storage update failed, no way to continue now.
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user