Cleanups in code.
This commit is contained in:
parent
9a9027f4b7
commit
58846e474e
12 changed files with 3 additions and 50 deletions
|
@ -48,7 +48,7 @@ QList<Message> Feed::undeletedMessages() const {
|
||||||
"FROM Messages "
|
"FROM Messages "
|
||||||
"WHERE is_deleted = 0 AND is_pdeleted = 0 AND feed = :feed AND account_id = :account_id;");
|
"WHERE is_deleted = 0 AND is_pdeleted = 0 AND feed = :feed AND account_id = :account_id;");
|
||||||
|
|
||||||
query_read_msg.bindValue(QSL(":feed"), messageForeignKeyId());
|
query_read_msg.bindValue(QSL(":feed"), customId());
|
||||||
query_read_msg.bindValue(QSL(":account_id"), account_id);
|
query_read_msg.bindValue(QSL(":account_id"), account_id);
|
||||||
|
|
||||||
if (query_read_msg.exec()) {
|
if (query_read_msg.exec()) {
|
||||||
|
|
|
@ -96,8 +96,6 @@ class Feed : public RootItem {
|
||||||
|
|
||||||
void updateCounts(bool including_total_count);
|
void updateCounts(bool including_total_count);
|
||||||
|
|
||||||
virtual int messageForeignKeyId() const = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QList<Message> obtainNewMessages() = 0;
|
virtual QList<Message> obtainNewMessages() = 0;
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,7 @@ class RootItem : public QObject {
|
||||||
m_boldFont = bold_font;
|
m_boldFont = bold_font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: For standard feed, this WILL equal to id().
|
||||||
int customId() const;
|
int customId() const;
|
||||||
void setCustomId(int custom_id);
|
void setCustomId(int custom_id);
|
||||||
|
|
||||||
|
|
|
@ -400,7 +400,7 @@ QStringList ServiceRoot::textualFeedIds(const QList<Feed*> &feeds) const {
|
||||||
stringy_ids.reserve(feeds.size());
|
stringy_ids.reserve(feeds.size());
|
||||||
|
|
||||||
foreach (const Feed *feed, feeds) {
|
foreach (const Feed *feed, feeds) {
|
||||||
stringy_ids.append(QString("'%1'").arg(QString::number(feed->messageForeignKeyId())));
|
stringy_ids.append(QString("'%1'").arg(QString::number(feed->customId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringy_ids;
|
return stringy_ids;
|
||||||
|
|
|
@ -57,10 +57,6 @@ OwnCloudServiceRoot *OwnCloudFeed::serviceRoot() const {
|
||||||
return qobject_cast<OwnCloudServiceRoot*>(getParentServiceRoot());
|
return qobject_cast<OwnCloudServiceRoot*>(getParentServiceRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
int OwnCloudFeed::messageForeignKeyId() const {
|
|
||||||
return customId();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Message> OwnCloudFeed::obtainNewMessages() {
|
QList<Message> OwnCloudFeed::obtainNewMessages() {
|
||||||
OwnCloudGetMessagesResponse messages = serviceRoot()->network()->getMessages(customId());
|
OwnCloudGetMessagesResponse messages = serviceRoot()->network()->getMessages(customId());
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ class OwnCloudFeed : public Feed {
|
||||||
bool cleanMessages(bool clear_only_read);
|
bool cleanMessages(bool clear_only_read);
|
||||||
|
|
||||||
OwnCloudServiceRoot *serviceRoot() const;
|
OwnCloudServiceRoot *serviceRoot() const;
|
||||||
int messageForeignKeyId() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Message> obtainNewMessages();
|
QList<Message> obtainNewMessages();
|
||||||
|
|
|
@ -501,10 +501,6 @@ bool StandardFeed::editItself(StandardFeed *new_feed_data) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandardFeed::messageForeignKeyId() const {
|
|
||||||
return id();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Message> StandardFeed::obtainNewMessages() {
|
QList<Message> StandardFeed::obtainNewMessages() {
|
||||||
QByteArray feed_contents;
|
QByteArray feed_contents;
|
||||||
int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||||
|
|
|
@ -82,8 +82,6 @@ class StandardFeed : public Feed {
|
||||||
bool addItself(RootItem *parent);
|
bool addItself(RootItem *parent);
|
||||||
bool editItself(StandardFeed *new_feed_data);
|
bool editItself(StandardFeed *new_feed_data);
|
||||||
|
|
||||||
int messageForeignKeyId() const;
|
|
||||||
|
|
||||||
// Other getters/setters.
|
// Other getters/setters.
|
||||||
inline Type type() const {
|
inline Type type() const {
|
||||||
return m_type;
|
return m_type;
|
||||||
|
|
|
@ -171,34 +171,6 @@ RecycleBin *StandardServiceRoot::recycleBin() const {
|
||||||
return m_recycleBin;
|
return m_recycleBin;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandardServiceRoot::markFeedsReadUnread(QList<Feed*> items, ReadStatus read) {
|
|
||||||
QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
|
||||||
QSqlQuery query_read_msg(db_handle);
|
|
||||||
query_read_msg.setForwardOnly(true);
|
|
||||||
|
|
||||||
query_read_msg.prepare(QString("UPDATE Messages SET is_read = :read "
|
|
||||||
"WHERE feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0;").arg(textualFeedIds(items).join(QSL(", "))));
|
|
||||||
|
|
||||||
query_read_msg.bindValue(QSL(":read"), read == RootItem::Read ? 1 : 0);
|
|
||||||
|
|
||||||
if (query_read_msg.exec()) {
|
|
||||||
// Messages are switched, now inform model about need to reload data.
|
|
||||||
QList<RootItem*> itemss;
|
|
||||||
|
|
||||||
foreach (Feed *feed, items) {
|
|
||||||
feed->updateCounts(false);
|
|
||||||
itemss.append(feed);
|
|
||||||
}
|
|
||||||
|
|
||||||
itemChanged(itemss);
|
|
||||||
requestReloadMessageList(read == RootItem::Read);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StandardServiceRoot::loadFromDatabase(){
|
void StandardServiceRoot::loadFromDatabase(){
|
||||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
|
||||||
Assignment categories;
|
Assignment categories;
|
||||||
|
|
|
@ -69,8 +69,6 @@ class StandardServiceRoot : public ServiceRoot {
|
||||||
// NOTE: This is used for import/export of the model.
|
// NOTE: This is used for import/export of the model.
|
||||||
bool mergeImportExportModel(FeedsImportExportModel *model, RootItem *target_root_node, QString &output_message);
|
bool mergeImportExportModel(FeedsImportExportModel *model, RootItem *target_root_node, QString &output_message);
|
||||||
|
|
||||||
bool markFeedsReadUnread(QList<Feed*> items, ReadStatus read);
|
|
||||||
|
|
||||||
void loadFromDatabase();
|
void loadFromDatabase();
|
||||||
void checkArgumentForFeedAdding(const QString &argument);
|
void checkArgumentForFeedAdding(const QString &argument);
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,6 @@ TtRssFeed::TtRssFeed(const QSqlRecord &record) : Feed(NULL) {
|
||||||
TtRssFeed::~TtRssFeed() {
|
TtRssFeed::~TtRssFeed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int TtRssFeed::messageForeignKeyId() const {
|
|
||||||
return customId();
|
|
||||||
}
|
|
||||||
|
|
||||||
TtRssServiceRoot *TtRssFeed::serviceRoot() const {
|
TtRssServiceRoot *TtRssFeed::serviceRoot() const {
|
||||||
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ class TtRssFeed : public Feed {
|
||||||
explicit TtRssFeed(const QSqlRecord &record);
|
explicit TtRssFeed(const QSqlRecord &record);
|
||||||
virtual ~TtRssFeed();
|
virtual ~TtRssFeed();
|
||||||
|
|
||||||
int messageForeignKeyId() const;
|
|
||||||
TtRssServiceRoot *serviceRoot() const;
|
TtRssServiceRoot *serviceRoot() const;
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const;
|
||||||
bool canBeEdited() const;
|
bool canBeEdited() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue