mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-27 07:46:17 +01:00
fixup wrong order ids
This commit is contained in:
parent
9b97c34bda
commit
45d7a78684
@ -2096,14 +2096,14 @@ bool DatabaseQueries::deleteCategory(const QSqlDatabase& db, int id) {
|
||||
}
|
||||
|
||||
void DatabaseQueries::fixupOrders(const QSqlDatabase& db) {
|
||||
QSqlQuery res = db.exec(QSL("SELECT COUNT(*) FROM Accounts WHERE ordr = 0 "
|
||||
// We first determine if there are same orders assigned to some items
|
||||
// which have same parent category/acc.
|
||||
QSqlQuery res = db.exec(QSL("SELECT COUNT(*) FROM Accounts GROUP BY ordr HAVING COUNT(*) > 1 "
|
||||
"UNION ALL "
|
||||
"SELECT COUNT(*) FROM Categories WHERE ordr = 0 "
|
||||
"SELECT COUNT(*) FROM Categories GROUP BY account_id, parent_id, ordr HAVING COUNT(*) > 1 "
|
||||
"UNION ALL "
|
||||
"SELECT COUNT(*) FROM Feeds WHERE ordr = 0;"));
|
||||
bool should_fixup = false;
|
||||
|
||||
while (res.next() && !(should_fixup = (res.value(0).toInt() > 1))) {}
|
||||
"SELECT COUNT(*) FROM Feeds GROUP BY account_id, category, ordr HAVING COUNT(*) > 1;"));
|
||||
bool should_fixup = res.lastError().isValid() || res.size() > 0;
|
||||
|
||||
if (should_fixup) {
|
||||
// Some orders are messed up, fix.
|
||||
@ -2117,6 +2117,9 @@ void DatabaseQueries::fixupOrders(const QSqlDatabase& db) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebugNN << LOGSEC_DB << "No fixing of item order is needed.";
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseQueries::moveItemUp(RootItem* item, const QSqlDatabase& db) {}
|
||||
|
@ -205,7 +205,10 @@ class RSSGUARD_DLLSPEC RootItem : public QObject {
|
||||
// which can be manually sorted. Other types like "Label" cannot be
|
||||
// automatically sorted and are always sorted by title.
|
||||
//
|
||||
// Sort order number cannot be negative.
|
||||
// Sort order number cannot be negative but order of list of items with same
|
||||
// parent does not have to form continuous series, for example:
|
||||
// 0, 1, 2, 3, 4, ...
|
||||
// 5, 7, 12, 13, 19
|
||||
int sortOrder() const;
|
||||
void setSortOrder(int sort_order);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user