mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-26 15:34:59 +01:00
can sort cats and accs too, need to revisit removing of accounts and categories and also moving to parents
This commit is contained in:
parent
3f59abae2a
commit
a312d02a07
@ -7,7 +7,9 @@
|
||||
<file>./graphics/Breeze/categories/32/applications-science.svg</file>
|
||||
<file>./graphics/Breeze/categories/32/applications-system.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/arrow-down.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/arrow-down-double.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/arrow-up.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/arrow-up-double.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/call-start.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/dialog-cancel.svg</file>
|
||||
<file>./graphics/Breeze/status/64/dialog-error.svg</file>
|
||||
@ -31,10 +33,13 @@
|
||||
<file>./graphics/Breeze/places/96/folder.svg</file>
|
||||
<file>./graphics/Breeze/actions/22/format-indent-more.svg</file>
|
||||
<file>./graphics/Breeze/actions/22/format-justify-fill.svg</file>
|
||||
<file>./graphics/Breeze/actions/22/format-text-bold.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/go-down.svg</file>
|
||||
<file>./graphics/Breeze/actions/64/go-home.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/go-jump.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/go-next.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/go-previous.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/go-up.svg</file>
|
||||
<file>./graphics/Breeze/actions/22/gtk-cancel.svg</file>
|
||||
<file>./graphics/Breeze/actions/22/gtk-edit.svg</file>
|
||||
<file>./graphics/Breeze/actions/32/help-about.svg</file>
|
||||
@ -75,7 +80,9 @@
|
||||
<file>./graphics/Breeze Dark/categories/32/applications-science.svg</file>
|
||||
<file>./graphics/Breeze Dark/categories/32/applications-system.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/arrow-down.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/arrow-down-double.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/arrow-up.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/arrow-up-double.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/call-start.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/dialog-cancel.svg</file>
|
||||
<file>./graphics/Breeze Dark/status/64/dialog-error.svg</file>
|
||||
@ -99,10 +106,13 @@
|
||||
<file>./graphics/Breeze Dark/places/96/folder.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/22/format-indent-more.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/22/format-justify-fill.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/22/format-text-bold.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/go-down.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/64/go-home.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/go-jump.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/go-next.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/go-previous.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/go-up.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/22/gtk-cancel.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/22/gtk-edit.svg</file>
|
||||
<file>./graphics/Breeze Dark/actions/32/help-about.svg</file>
|
||||
@ -166,10 +176,13 @@
|
||||
<file>./graphics/Faenza/places/64/folder.png</file>
|
||||
<file>./graphics/Faenza/actions/64/format-indent-more.png</file>
|
||||
<file>./graphics/Faenza/actions/64/format-justify-fill.png</file>
|
||||
<file>./graphics/Faenza/actions/64/format-text-bold.png</file>
|
||||
<file>./graphics/Faenza/actions/64/go-down.png</file>
|
||||
<file>./graphics/Faenza/actions/64/go-home.png</file>
|
||||
<file>./graphics/Faenza/actions/64/go-jump.png</file>
|
||||
<file>./graphics/Faenza/actions/64/go-next.png</file>
|
||||
<file>./graphics/Faenza/actions/64/go-previous.png</file>
|
||||
<file>./graphics/Faenza/actions/64/go-up.png</file>
|
||||
<file>./graphics/Faenza/actions/64/gtk-cancel.png</file>
|
||||
<file>./graphics/Faenza/actions/64/gtk-edit.png</file>
|
||||
<file>./graphics/Faenza/actions/64/help-about.png</file>
|
||||
@ -211,7 +224,9 @@
|
||||
<file>./graphics/Numix/22/categories/applications-science.svg</file>
|
||||
<file>./graphics/Numix/22/categories/applications-system.svg</file>
|
||||
<file>./graphics/Numix/22/actions/arrow-down.svg</file>
|
||||
<file>./graphics/Numix/22/actions/arrow-down-double.svg</file>
|
||||
<file>./graphics/Numix/22/actions/arrow-up.svg</file>
|
||||
<file>./graphics/Numix/22/actions/arrow-up-double.svg</file>
|
||||
<file>./graphics/Numix/22/actions/call-start.svg</file>
|
||||
<file>./graphics/Numix/22/actions/dialog-cancel.svg</file>
|
||||
<file>./graphics/Numix/22/status/dialog-error.svg</file>
|
||||
@ -238,10 +253,13 @@
|
||||
<file>./graphics/Numix/22/places/folder.svg</file>
|
||||
<file>./graphics/Numix/22/actions/format-indent-more.svg</file>
|
||||
<file>./graphics/Numix/22/actions/format-justify-fill.svg</file>
|
||||
<file>./graphics/Numix/22/actions/format-text-bold.svg</file>
|
||||
<file>./graphics/Numix/22/actions/go-down.svg</file>
|
||||
<file>./graphics/Numix/22/actions/go-home.svg</file>
|
||||
<file>./graphics/Numix/22/actions/go-jump.svg</file>
|
||||
<file>./graphics/Numix/22/actions/go-next.svg</file>
|
||||
<file>./graphics/Numix/22/actions/go-previous.svg</file>
|
||||
<file>./graphics/Numix/22/actions/go-up.svg</file>
|
||||
<file>./graphics/Numix/22/actions/gtk-cancel.svg</file>
|
||||
<file>./graphics/Numix/22/actions/gtk-edit.svg</file>
|
||||
<file>./graphics/Numix/22/categories/help-about.svg</file>
|
||||
|
@ -2161,33 +2161,22 @@ bool DatabaseQueries::deleteCategory(const QSqlDatabase& db, int id) {
|
||||
}
|
||||
|
||||
void DatabaseQueries::moveItem(RootItem* item, bool move_top, bool move_bottom, int move_index, const QSqlDatabase& db) {
|
||||
switch (item->kind()) {
|
||||
case RootItem::Kind::Feed:
|
||||
moveFeed(item->toFeed(), move_top, move_bottom, move_index, db);
|
||||
break;
|
||||
|
||||
case RootItem::Kind::Category:
|
||||
break;
|
||||
|
||||
case RootItem::Kind::ServiceRoot:
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
if (item->kind() != RootItem::Kind::Feed &&
|
||||
item->kind() != RootItem::Kind::Category &&
|
||||
item->kind() != RootItem::Kind::ServiceRoot) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseQueries::moveFeed(Feed* feed, bool move_top, bool move_bottom, int move_index, const QSqlDatabase& db) {
|
||||
auto neighbors = feed->parent()->childItems();
|
||||
int max_sort_order = boolinq::from(neighbors).select([](RootItem* it) {
|
||||
return it->kind() == RootItem::Kind::Feed ? it->sortOrder() : 0;
|
||||
auto neighbors = item->parent()->childItems();
|
||||
int max_sort_order = boolinq::from(neighbors).select([=](RootItem* it) {
|
||||
return it->kind() == item->kind() ? it->sortOrder() : 0;
|
||||
}).max();
|
||||
|
||||
if ((!move_top && !move_bottom && feed->sortOrder() == move_index) || /* Item is already sorted OK. */
|
||||
if ((!move_top && !move_bottom && item->sortOrder() == move_index) || /* Item is already sorted OK. */
|
||||
(!move_top && !move_bottom && move_index < 0 ) || /* Order cannot be smaller than 0 if we do not move to begin/end. */
|
||||
(!move_top && !move_bottom && move_index > max_sort_order ) || /* Cannot move past biggest sort order. */
|
||||
(move_top && feed->sortOrder() == 0) || /* Item is already on top. */
|
||||
(move_bottom && feed->sortOrder() == max_sort_order) || /* Item is already on bottom. */
|
||||
(move_top && item->sortOrder() == 0) || /* Item is already on top. */
|
||||
(move_bottom && item->sortOrder() == max_sort_order) || /* Item is already on bottom. */
|
||||
max_sort_order <= 0) { /* We only have 1 item, nothing to sort. */
|
||||
return;
|
||||
}
|
||||
@ -2201,20 +2190,52 @@ void DatabaseQueries::moveFeed(Feed* feed, bool move_top, bool move_bottom, int
|
||||
move_index = max_sort_order;
|
||||
}
|
||||
|
||||
int move_low = qMin(move_index, feed->sortOrder());
|
||||
int move_high = qMax(move_index, feed->sortOrder());
|
||||
int move_low = qMin(move_index, item->sortOrder());
|
||||
int move_high = qMax(move_index, item->sortOrder());
|
||||
QString parent_field, table_name;
|
||||
|
||||
if (feed->sortOrder() > move_index) {
|
||||
q.prepare(QSL("UPDATE Feeds SET ordr = ordr + 1 "
|
||||
"WHERE account_id = :account_id AND category = :category AND ordr < :move_high AND ordr >= :move_low;"));
|
||||
switch (item->kind()) {
|
||||
case RootItem::Kind::Feed:
|
||||
parent_field = QSL("category");
|
||||
table_name = QSL("Feeds");
|
||||
break;
|
||||
|
||||
case RootItem::Kind::Category:
|
||||
parent_field = QSL("parent_id");
|
||||
table_name = QSL("Categories");
|
||||
break;
|
||||
|
||||
case RootItem::Kind::ServiceRoot:
|
||||
table_name = QSL("Accounts");
|
||||
break;
|
||||
}
|
||||
|
||||
if (item->kind() == RootItem::Kind::ServiceRoot) {
|
||||
if (item->sortOrder() > move_index) {
|
||||
q.prepare(QSL("UPDATE Accounts SET ordr = ordr + 1 "
|
||||
"WHERE ordr < :move_high AND ordr >= :move_low;"));
|
||||
}
|
||||
else {
|
||||
q.prepare(QSL("UPDATE Accounts SET ordr = ordr - 1 "
|
||||
"WHERE ordr > :move_low AND ordr <= :move_high;"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
q.prepare(QSL("UPDATE Feeds SET ordr = ordr - 1 "
|
||||
"WHERE account_id = :account_id AND category = :category AND ordr > :move_low AND ordr <= :move_high;"));
|
||||
if (item->sortOrder() > move_index) {
|
||||
q.prepare(QSL("UPDATE %1 SET ordr = ordr + 1 "
|
||||
"WHERE account_id = :account_id AND %2 = :category AND ordr < :move_high AND ordr >= :move_low;")
|
||||
.arg(table_name, parent_field));
|
||||
}
|
||||
else {
|
||||
q.prepare(QSL("UPDATE %1 SET ordr = ordr - 1 "
|
||||
"WHERE account_id = :account_id AND %2 = :category AND ordr > :move_low AND ordr <= :move_high;")
|
||||
.arg(table_name, parent_field));
|
||||
}
|
||||
|
||||
q.bindValue(QSL(":account_id"), item->getParentServiceRoot()->accountId());
|
||||
q.bindValue(QSL(":category"), item->parent()->id());
|
||||
}
|
||||
|
||||
q.bindValue(QSL(":account_id"), feed->getParentServiceRoot()->accountId());
|
||||
q.bindValue(QSL(":category"), feed->parent()->id());
|
||||
q.bindValue(QSL(":move_low"), move_low);
|
||||
q.bindValue(QSL(":move_high"), move_high);
|
||||
|
||||
@ -2222,8 +2243,8 @@ void DatabaseQueries::moveFeed(Feed* feed, bool move_top, bool move_bottom, int
|
||||
throw ApplicationException(q.lastError().text());
|
||||
}
|
||||
|
||||
q.prepare(QSL("UPDATE Feeds SET ordr = :ordr WHERE id = :id;"));
|
||||
q.bindValue(QSL(":id"), feed->id());
|
||||
q.prepare(QSL("UPDATE %1 SET ordr = :ordr WHERE id = :id;").arg(table_name));
|
||||
q.bindValue(QSL(":id"), item->kind() == RootItem::Kind::ServiceRoot ? item->toServiceRoot()->accountId() : item->id());
|
||||
q.bindValue(QSL(":ordr"), move_index);
|
||||
|
||||
if (!q.exec()) {
|
||||
@ -2231,22 +2252,22 @@ void DatabaseQueries::moveFeed(Feed* feed, bool move_top, bool move_bottom, int
|
||||
}
|
||||
|
||||
// Fix live sort orders.
|
||||
if (feed->sortOrder() > move_index) {
|
||||
if (item->sortOrder() > move_index) {
|
||||
boolinq::from(neighbors).where([=](RootItem* it) {
|
||||
return it->kind() == RootItem::Kind::Feed && it->sortOrder() < move_high && it->sortOrder() >= move_low;
|
||||
return it->kind() == item->kind() && it->sortOrder() < move_high && it->sortOrder() >= move_low;
|
||||
}).for_each([](RootItem* it) {
|
||||
it->setSortOrder(it->sortOrder() + 1);
|
||||
});
|
||||
}
|
||||
else {
|
||||
boolinq::from(neighbors).where([=](RootItem* it) {
|
||||
return it->kind() == RootItem::Kind::Feed && it->sortOrder() > move_low && it->sortOrder() <= move_high;
|
||||
return it->kind() == item->kind() && it->sortOrder() > move_low && it->sortOrder() <= move_high;
|
||||
}).for_each([](RootItem* it) {
|
||||
it->setSortOrder(it->sortOrder() - 1);
|
||||
});
|
||||
}
|
||||
|
||||
feed->setSortOrder(move_index);
|
||||
item->setSortOrder(move_index);
|
||||
}
|
||||
|
||||
MessageFilter* DatabaseQueries::addMessageFilter(const QSqlDatabase& db, const QString& title,
|
||||
|
@ -136,7 +136,6 @@ class DatabaseQueries {
|
||||
|
||||
// Item order methods.
|
||||
static void moveItem(RootItem* item, bool move_top, bool move_bottom, int move_index, const QSqlDatabase& db);
|
||||
static void moveFeed(Feed* feed, bool move_top, bool move_bottom, int move_index, const QSqlDatabase& db);
|
||||
|
||||
// Message filters operators.
|
||||
static bool purgeLeftoverMessageFilterAssignments(const QSqlDatabase& db, int account_id);
|
||||
|
@ -621,10 +621,10 @@ void FormMain::setupIcons() {
|
||||
m_ui->m_actionAddCategoryIntoSelectedItem->setIcon(icon_theme_factory->fromTheme(QSL("folder")));
|
||||
m_ui->m_actionMessageFilters->setIcon(icon_theme_factory->fromTheme(QSL("view-list-details")));
|
||||
|
||||
m_ui->m_actionFeedMoveUp->setIcon(icon_theme_factory->fromTheme(QSL("arrow-up")));
|
||||
m_ui->m_actionFeedMoveDown->setIcon(icon_theme_factory->fromTheme(QSL("arrow-down")));
|
||||
m_ui->m_actionFeedMoveTop->setIcon(icon_theme_factory->fromTheme(QSL("arrow-up-double")));
|
||||
m_ui->m_actionFeedMoveBottom->setIcon(icon_theme_factory->fromTheme(QSL("arrow-down-double")));
|
||||
m_ui->m_actionFeedMoveUp->setIcon(icon_theme_factory->fromTheme(QSL("arrow-up"), QSL("go-up")));
|
||||
m_ui->m_actionFeedMoveDown->setIcon(icon_theme_factory->fromTheme(QSL("arrow-down"), QSL("go-down")));
|
||||
m_ui->m_actionFeedMoveTop->setIcon(icon_theme_factory->fromTheme(QSL("arrow-up-double"), QSL("go-up")));
|
||||
m_ui->m_actionFeedMoveBottom->setIcon(icon_theme_factory->fromTheme(QSL("arrow-down-double"), QSL("go-down")));
|
||||
|
||||
// Tabs & web browser.
|
||||
m_ui->m_actionTabNewWebBrowser->setIcon(icon_theme_factory->fromTheme(QSL("tab-new")));
|
||||
|
@ -483,6 +483,15 @@ QMenu* FeedsView::initializeContextMenuService(RootItem* clicked_item) {
|
||||
m_contextMenuService->addAction(qApp->mainForm()->m_ui->m_actionAddFeedIntoSelectedItem);
|
||||
}
|
||||
|
||||
if (!qApp->settings()->value(GROUP(Feeds),
|
||||
SETTING(Feeds::SortAlphabetically)).toBool()) {
|
||||
m_contextMenuService->addSeparator();
|
||||
m_contextMenuService->addAction(qApp->mainForm()->m_ui->m_actionFeedMoveUp);
|
||||
m_contextMenuService->addAction(qApp->mainForm()->m_ui->m_actionFeedMoveDown);
|
||||
m_contextMenuService->addAction(qApp->mainForm()->m_ui->m_actionFeedMoveTop);
|
||||
m_contextMenuService->addAction(qApp->mainForm()->m_ui->m_actionFeedMoveBottom);
|
||||
}
|
||||
|
||||
if (!specific_actions.isEmpty()) {
|
||||
m_contextMenuService->addSeparator();
|
||||
m_contextMenuService->addActions(specific_actions);
|
||||
@ -683,6 +692,15 @@ QMenu* FeedsView::initializeContextMenuCategories(RootItem* clicked_item) {
|
||||
m_contextMenuCategories->addAction(qApp->mainForm()->m_ui->m_actionAddFeedIntoSelectedItem);
|
||||
}
|
||||
|
||||
if (!qApp->settings()->value(GROUP(Feeds),
|
||||
SETTING(Feeds::SortAlphabetically)).toBool()) {
|
||||
m_contextMenuCategories->addSeparator();
|
||||
m_contextMenuCategories->addAction(qApp->mainForm()->m_ui->m_actionFeedMoveUp);
|
||||
m_contextMenuCategories->addAction(qApp->mainForm()->m_ui->m_actionFeedMoveDown);
|
||||
m_contextMenuCategories->addAction(qApp->mainForm()->m_ui->m_actionFeedMoveTop);
|
||||
m_contextMenuCategories->addAction(qApp->mainForm()->m_ui->m_actionFeedMoveBottom);
|
||||
}
|
||||
|
||||
if (!specific_actions.isEmpty()) {
|
||||
m_contextMenuCategories->addSeparator();
|
||||
m_contextMenuCategories->addActions(specific_actions);
|
||||
|
Loading…
Reference in New Issue
Block a user