fix #918
This commit is contained in:
parent
e33599b862
commit
7868342a80
@ -455,6 +455,18 @@ void FeedsModel::changeSortOrder(RootItem* item, bool move_top, bool move_bottom
|
||||
DatabaseQueries::moveItem(item, move_top, move_bottom, new_sort_order, db);
|
||||
}
|
||||
|
||||
void FeedsModel::sortDirectDescendants(RootItem* item, RootItem::Kind kind_to_sort) {
|
||||
auto childs = item->childItems(kind_to_sort);
|
||||
|
||||
std::sort(childs.begin(), childs.end(), [](RootItem* lhs, RootItem* rhs) {
|
||||
return lhs->title().compare(rhs->title(), Qt::CaseSensitivity::CaseInsensitive) < 0;
|
||||
});
|
||||
|
||||
for (RootItem* it : childs) {
|
||||
changeSortOrder(it, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
void FeedsModel::loadActivatedServiceAccounts() {
|
||||
auto serv = qApp->feedReader()->feedServices();
|
||||
|
||||
|
@ -107,6 +107,10 @@ class RSSGUARD_DLLSPEC FeedsModel : public QAbstractItemModel {
|
||||
|
||||
void changeSortOrder(RootItem* item, bool move_top, bool move_bottom, int new_sort_order = {});
|
||||
|
||||
// Takes direct descendants (but only categories or feeds)
|
||||
// and rearranges them alphabetically.
|
||||
void sortDirectDescendants(RootItem* item, RootItem::Kind kind_to_sort);
|
||||
|
||||
// Feeds operations.
|
||||
bool markItemRead(RootItem* item, RootItem::ReadStatus read);
|
||||
bool markItemCleared(RootItem* item, bool clean_read_only);
|
||||
|
@ -480,6 +480,8 @@ void FormMain::updateFeedButtonsAvailability() {
|
||||
const bool service_selected = anything_selected && selected_item->kind() == RootItem::Kind::ServiceRoot;
|
||||
const bool manual_feed_sort = !m_ui->m_actionSortFeedsAlphabetically->isChecked();
|
||||
|
||||
m_ui->m_actionRearrangeFeeds->setEnabled(manual_feed_sort && (service_selected || category_selected));
|
||||
m_ui->m_actionRearrangeCategories->setEnabled(manual_feed_sort && (service_selected || category_selected));
|
||||
m_ui->m_actionStopRunningItemsUpdate->setEnabled(is_update_running);
|
||||
m_ui->m_actionBackupDatabaseSettings->setEnabled(!critical_action_running);
|
||||
m_ui->m_actionCleanupDatabase->setEnabled(!critical_action_running);
|
||||
@ -892,6 +894,15 @@ void FormMain::createConnections() {
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->feedsView(),
|
||||
&FeedsView::updateSelectedItems);
|
||||
connect(m_ui->m_actionRearrangeCategories,
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->feedsView(),
|
||||
&FeedsView::rearrangeCategoriesOfSelectedItem);
|
||||
connect(m_ui->m_actionRearrangeFeeds,
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->feedsView(),
|
||||
&FeedsView::rearrangeFeedsOfSelectedItem);
|
||||
|
||||
connect(m_ui->m_actionUpdateAllItems, &QAction::triggered, qApp->feedReader(), &FeedReader::updateAllFeeds);
|
||||
connect(m_ui->m_actionUpdateSelectedItemsWithCustomTimers,
|
||||
&QAction::triggered,
|
||||
|
13
src/librssguard/gui/dialogs/formmain.ui
Normal file → Executable file
13
src/librssguard/gui/dialogs/formmain.ui
Normal file → Executable file
@ -128,6 +128,9 @@
|
||||
<addaction name="m_actionDeleteSelectedItem"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionSortFeedsAlphabetically"/>
|
||||
<addaction name="m_actionRearrangeCategories"/>
|
||||
<addaction name="m_actionRearrangeFeeds"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionShowOnlyUnreadItems"/>
|
||||
<addaction name="m_actionAutoExpandItemsWhenSelected"/>
|
||||
<addaction name="m_actionShowTreeBranches"/>
|
||||
@ -918,6 +921,16 @@
|
||||
<string>Scroll &down browser</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionRearrangeCategories">
|
||||
<property name="text">
|
||||
<string>Rearrange &subcategories alphabetically</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionRearrangeFeeds">
|
||||
<property name="text">
|
||||
<string>Rearrange &feeds alphabetically</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -315,6 +315,16 @@ void FeedsView::moveSelectedItemDown() {
|
||||
m_proxyModel->invalidate();
|
||||
}
|
||||
|
||||
void FeedsView::rearrangeCategoriesOfSelectedItem() {
|
||||
m_sourceModel->sortDirectDescendants(selectedItem(), RootItem::Kind::Category);
|
||||
m_proxyModel->invalidate();
|
||||
}
|
||||
|
||||
void FeedsView::rearrangeFeedsOfSelectedItem() {
|
||||
m_sourceModel->sortDirectDescendants(selectedItem(), RootItem::Kind::Feed);
|
||||
m_proxyModel->invalidate();
|
||||
}
|
||||
|
||||
void FeedsView::markSelectedItemReadStatus(RootItem::ReadStatus read) {
|
||||
m_sourceModel->markItemRead(selectedItem(), read);
|
||||
}
|
||||
@ -469,6 +479,8 @@ QMenu* FeedsView::initializeContextMenuService(RootItem* clicked_item) {
|
||||
qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode,
|
||||
qApp->mainForm()->m_ui->m_actionExpandCollapseItem,
|
||||
qApp->mainForm()->m_ui->m_actionExpandCollapseItemRecursively,
|
||||
qApp->mainForm()->m_ui->m_actionRearrangeCategories,
|
||||
qApp->mainForm()->m_ui->m_actionRearrangeFeeds,
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsRead,
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsUnread,
|
||||
qApp->mainForm()->m_ui->m_actionDeleteSelectedItem});
|
||||
@ -691,6 +703,8 @@ QMenu* FeedsView::initializeContextMenuCategories(RootItem* clicked_item) {
|
||||
qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode,
|
||||
qApp->mainForm()->m_ui->m_actionExpandCollapseItem,
|
||||
qApp->mainForm()->m_ui->m_actionExpandCollapseItemRecursively,
|
||||
qApp->mainForm()->m_ui->m_actionRearrangeCategories,
|
||||
qApp->mainForm()->m_ui->m_actionRearrangeFeeds,
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsRead,
|
||||
qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsUnread,
|
||||
qApp->mainForm()->m_ui->m_actionDeleteSelectedItem});
|
||||
|
@ -72,6 +72,8 @@ class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
|
||||
void moveSelectedItemTop();
|
||||
void moveSelectedItemBottom();
|
||||
void moveSelectedItemDown();
|
||||
void rearrangeCategoriesOfSelectedItem();
|
||||
void rearrangeFeedsOfSelectedItem();
|
||||
|
||||
// Selects next/previous item (feed/category) in the list.
|
||||
void selectNextItem();
|
||||
|
@ -639,3 +639,13 @@ RootItem::Kind operator|(RootItem::Kind a, RootItem::Kind b) {
|
||||
RootItem::Kind operator&(RootItem::Kind a, RootItem::Kind b) {
|
||||
return static_cast<RootItem::Kind>(static_cast<int>(a) & static_cast<int>(b));
|
||||
}
|
||||
|
||||
QList<RootItem*> RootItem::childItems(Kind kind) const {
|
||||
auto linq = boolinq::from(m_childItems)
|
||||
.where([=](RootItem* it) {
|
||||
return it->kind() == kind;
|
||||
})
|
||||
.toStdList();
|
||||
|
||||
return FROM_STD_LIST(QList<RootItem*>, linq);
|
||||
}
|
||||
|
@ -112,6 +112,8 @@ class RSSGUARD_DLLSPEC RootItem : public QObject {
|
||||
RootItem* child(int row);
|
||||
int childCount() const;
|
||||
void appendChild(RootItem* child);
|
||||
|
||||
QList<RootItem*> childItems(RootItem::Kind kind) const;
|
||||
QList<RootItem*> childItems() const;
|
||||
QList<RootItem*>& childItems();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user