work on man. sort, now can move bottom/top for feed

This commit is contained in:
Martin Rotter 2022-03-14 14:06:29 +01:00
parent 73f6e602ac
commit c03e31a26a
5 changed files with 18 additions and 2 deletions

View File

@ -107,7 +107,7 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel {
bool restoreAllBins();
bool emptyAllBins();
void changeSortOrder(RootItem* item, bool move_top, bool move_bottom, int new_sort_order);
void changeSortOrder(RootItem* item, bool move_top, bool move_bottom, int new_sort_order = {});
// Feeds operations.
bool markItemRead(RootItem* item, RootItem::ReadStatus read);

View File

@ -2166,7 +2166,7 @@ void DatabaseQueries::moveFeed(Feed* feed, bool move_top, bool move_bottom, int
return it->kind() == RootItem::Kind::Feed ? it->sortOrder() : 0;
}).max();
if (feed->sortOrder() == move_index || /* Item is already sorted OK. */
if ((!move_top && !move_bottom && feed->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. */

View File

@ -901,6 +901,10 @@ void FormMain::createConnections() {
tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::moveSelectedItemUp);
connect(m_ui->m_actionFeedMoveDown, &QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::moveSelectedItemDown);
connect(m_ui->m_actionFeedMoveTop, &QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::moveSelectedItemTop);
connect(m_ui->m_actionFeedMoveBottom, &QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::moveSelectedItemBottom);
}
void FormMain::backupDatabaseSettings() {

View File

@ -293,6 +293,16 @@ void FeedsView::moveSelectedItemUp() {
m_proxyModel->invalidate();
}
void FeedsView::moveSelectedItemTop() {
m_sourceModel->changeSortOrder(selectedItem(), true, false);
m_proxyModel->invalidate();
}
void FeedsView::moveSelectedItemBottom() {
m_sourceModel->changeSortOrder(selectedItem(), false, true);
m_proxyModel->invalidate();
}
void FeedsView::moveSelectedItemDown() {
m_sourceModel->changeSortOrder(selectedItem(), false, false, selectedItem()->sortOrder() + 1);
m_proxyModel->invalidate();

View File

@ -68,6 +68,8 @@ class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
// Sort order manipulations.
void moveSelectedItemUp();
void moveSelectedItemTop();
void moveSelectedItemBottom();
void moveSelectedItemDown();
// Selects next/previous item (feed/category) in the list.