Esempio n. 1
0
int Feed::updateMessages(const QList<Message> &messages) {
  int custom_id = customId();
  int account_id = getParentServiceRoot()->accountId();
  bool anything_updated = false;
  bool ok;
  QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
  int updated_messages = DatabaseQueries::updateMessages(database, messages, custom_id, account_id, url(),
                                                         &anything_updated, &ok);

  if (ok) {
    if (updated_messages > 0) {
      setStatus(NewMessages);
    }
    else {
      setStatus(Normal);
    }

    QList<RootItem*> items_to_update;

    updateCounts(true);
    items_to_update.append(this);

    if (getParentServiceRoot()->recycleBin() != nullptr && anything_updated) {
      getParentServiceRoot()->recycleBin()->updateCounts(true);
      items_to_update.append(getParentServiceRoot()->recycleBin());
    }

    getParentServiceRoot()->itemChanged(items_to_update);
  }

  return updated_messages;
}
Esempio n. 2
0
void Feed::updateCounts(bool including_total_count) {
  QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
  int account_id = getParentServiceRoot()->accountId();

  if (including_total_count) {
    setCountOfAllMessages(DatabaseQueries::getMessageCountsForFeed(database, customId(), account_id, true));
  }

  setCountOfUnreadMessages(DatabaseQueries::getMessageCountsForFeed(database, customId(), account_id, false));
}
Esempio n. 3
0
StandardServiceRoot *StandardCategory::serviceRoot() const {
  return qobject_cast<StandardServiceRoot*>(getParentServiceRoot());
}
Esempio n. 4
0
QList<Message> Feed::undeletedMessages() const {
  QSqlDatabase database = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
  return DatabaseQueries::getUndeletedMessagesForFeed(database, customId(), getParentServiceRoot()->accountId());
}
Esempio n. 5
0
TtRssServiceRoot *TtRssRecycleBin::serviceRoot() {
  return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
}
Esempio n. 6
0
bool StandardFeed::removeItself() {
  QSqlDatabase database = qApp->database()->connection(metaObject()->className());

  return DatabaseQueries::deleteFeed(database, customId().toInt(), getParentServiceRoot()->accountId());
}