mirror of https://github.com/KDE/kasts.git
Remove authors when removing feed
This commit is contained in:
parent
593d221c9c
commit
276d8ba831
|
@ -55,7 +55,7 @@ bool Database::migrateTo1() {
|
|||
QSqlQuery query(QSqlDatabase::database());
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Feeds (name TEXT, url TEXT, image TEXT);")));
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Entries (feed TEXT, id TEXT UNIQUE, title TEXT, content TEXT, created INTEGER, updated INTEGER);")));
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Authors (id TEXT, name TEXT, uri TEXT, email TEXT);")));
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("CREATE TABLE IF NOT EXISTS Authors (feed TEXT, id TEXT, name TEXT, uri TEXT, email TEXT);")));
|
||||
TRUE_OR_RETURN(execute(QStringLiteral("PRAGMA user_version = 1;")));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,10 @@ bool FeedListModel::feedExists(QString url) {
|
|||
void FeedListModel::removeFeed(int index)
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.prepare(QStringLiteral("DELETE FROM Authors WHERE feed=:feed;"));
|
||||
query.bindValue(QStringLiteral(":feed"), data(createIndex(index, 0), 1).toString());
|
||||
Database::instance().execute(query);
|
||||
|
||||
query.prepare(QStringLiteral("DELETE FROM Entries WHERE feed=:feed;"));
|
||||
query.bindValue(QStringLiteral(":feed"), data(createIndex(index, 0), 1).toString());
|
||||
Database::instance().execute(query);
|
||||
|
|
|
@ -74,7 +74,8 @@ void Fetcher::fetch(QUrl url)
|
|||
query.bindValue(QStringLiteral(":content"), entry->description());
|
||||
Database::instance().execute(query);
|
||||
for (const auto &author : entry->authors()) {
|
||||
query.prepare(QStringLiteral("INSERT INTO Authors VALUES(:id, :name, :uri, :email);"));
|
||||
query.prepare(QStringLiteral("INSERT INTO Authors VALUES(:feed, :id, :name, :uri, :email);"));
|
||||
query.bindValue(QStringLiteral(":feed"), url.toString());
|
||||
query.bindValue(QStringLiteral(":id"), entry->id());
|
||||
query.bindValue(QStringLiteral(":name"), author->name());
|
||||
query.bindValue(QStringLiteral(":uri"), author->uri());
|
||||
|
|
Loading…
Reference in New Issue