Changes to sorting/filtering.

This commit is contained in:
Martin Rotter 2016-01-18 08:04:41 +01:00
parent 8f9d3f7aa4
commit 976d5222ff
12 changed files with 20 additions and 46 deletions

View File

@ -12,9 +12,11 @@ Changed:
▪ Some GUI refinements and fixes.
▪ Added more logging entries.
▪ "Clean all items" now does not clean messages from recycle bins.
Fixed:
▪ Made some rather big changes to sorting/filtering of feeds, which is now dynamic.
▪ Feeds are now (re)sorted when batch update finishes. (bug #150)
▪ Expand status if items in feed list are now persistent when performing sync-in of TT-RSS accounts. (bug #149)
▪ Fixed problem with importing invalid OPML 2.0 files. (bug #145)

View File

@ -177,7 +177,7 @@ void FeedsModel::onFeedUpdatesFinished(const FeedDownloadResults &results) {
}
emit feedsUpdateFinished();
emit sortingRequired();
//emit sortingRequired();
}
void FeedsModel::updateAllFeeds() {
@ -614,10 +614,15 @@ bool FeedsModel::hasAnyFeedNewMessages() const {
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
while (!list.isEmpty()) {
QModelIndex indx = list.takeFirst();
QModelIndex indx_parent = indx.parent();
// Underlying data are changed.
emit dataChanged(index(indx.row(), 0, indx_parent), index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent));
if (indx.isValid()) {
QModelIndex indx_parent = indx.parent();
// Underlying data are changed.
emit dataChanged(index(indx.row(), 0, indx_parent), index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent));
list.append(indx_parent);
}
}
}
@ -663,7 +668,6 @@ bool FeedsModel::addServiceAccount(ServiceRoot *root, bool freshly_activated) {
// Connect.
connect(root, SIGNAL(itemRemovalRequested(RootItem*)), this, SLOT(removeItem(RootItem*)));
connect(root, SIGNAL(itemReassignmentRequested(RootItem*,RootItem*)), this, SLOT(reassignNodeToNewParent(RootItem*,RootItem*)));
connect(root, SIGNAL(readFeedsFilterInvalidationRequested()), this, SIGNAL(readFeedsFilterInvalidationRequested()));
connect(root, SIGNAL(dataChanged(QList<RootItem*>)), this, SLOT(onItemDataChanged(QList<RootItem*>)));
connect(root, SIGNAL(reloadMessageListRequested(bool)), this, SIGNAL(reloadMessageListRequested(bool)));
connect(root, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)), this, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)));

View File

@ -197,10 +197,6 @@ class FeedsModel : public QAbstractItemModel {
// Update of feeds is finished.
void feedsUpdateFinished();
// Counts of unread messages are changed in some feeds,
// notify view about this shit.
void readFeedsFilterInvalidationRequested();
// Emitted when model requests update of some feeds.
void feedsUpdateRequested(const QList<Feed*> feeds);

View File

@ -37,10 +37,8 @@ FeedsProxyModel::FeedsProxyModel(QObject *parent)
setFilterCaseSensitivity(Qt::CaseInsensitive);
setFilterKeyColumn(-1);
setFilterRole(Qt::EditRole);
setDynamicSortFilter(false);
setDynamicSortFilter(true);
setSourceModel(m_sourceModel);
connect(m_sourceModel, SIGNAL(readFeedsFilterInvalidationRequested()), this, SLOT(invalidateReadFeedsFilter()));
}
FeedsProxyModel::~FeedsProxyModel() {

View File

@ -186,7 +186,6 @@ bool RecycleBin::restore() {
parent_root->updateCounts(true);
parent_root->itemChanged(parent_root->getSubTree());
parent_root->requestReloadMessageList(true);
parent_root->requestFeedReadFilterReload();
return true;
}
else {

View File

@ -89,21 +89,13 @@ QList<Message> RootItem::undeletedMessages() const {
bool RootItem::cleanMessages(bool clear_only_read) {
bool result = true;
RecycleBin *bin = NULL;
foreach (RootItem *child, m_childItems) {
if (child->kind() == RootItemKind::Bin) {
bin = qobject_cast<RecycleBin*>(child);
}
else {
if (child->kind() != RootItemKind::Bin) {
result &= child->cleanMessages(clear_only_read);
}
}
if (bin != NULL) {
result &= bin->cleanMessages(clear_only_read);
}
return result;
}

View File

@ -118,10 +118,6 @@ void ServiceRoot::requestReloadMessageList(bool mark_selected_messages_read) {
emit reloadMessageListRequested(mark_selected_messages_read);
}
void ServiceRoot::requestFeedReadFilterReload() {
emit readFeedsFilterInvalidationRequested();
}
void ServiceRoot::requestItemExpand(const QList<RootItem*> &items, bool expand) {
emit itemExpandRequested(items, expand);
}

View File

@ -154,7 +154,6 @@ class ServiceRoot : public RootItem {
// Obvious methods to wrap signals.
void itemChanged(const QList<RootItem*> &items);
void requestReloadMessageList(bool mark_selected_messages_read);
void requestFeedReadFilterReload();
void requestItemExpand(const QList<RootItem*> &items, bool expand);
void requestItemExpandStateSave(RootItem *subtree_root);
void requestItemReassignment(RootItem *item, RootItem *new_parent);
@ -172,7 +171,6 @@ class ServiceRoot : public RootItem {
signals:
// Emitted if data in any item belonging to this root are changed.
void dataChanged(QList<RootItem*> items);
void readFeedsFilterInvalidationRequested();
void reloadMessageListRequested(bool mark_selected_messages_read);
void itemExpandRequested(QList<RootItem*> items, bool expand);
void itemExpandStateSaveRequested(RootItem *subtree_root);

View File

@ -742,10 +742,6 @@ int StandardFeed::updateMessages(const QList<Message> &messages) {
else {
updateCounts(true);
serviceRoot()->itemChanged(QList<RootItem*>() << this);
if (updated_messages > 0) {
serviceRoot()->requestFeedReadFilterReload();
}
}
return updated_messages;

View File

@ -192,18 +192,22 @@ bool StandardServiceRoot::markFeedsReadUnread(QList<Feed*> items, ReadStatus rea
bool StandardServiceRoot::cleanFeeds(QList<Feed*> items, bool clean_read_only) {
QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
QSqlQuery query_delete_msg(db_handle);
int account_id = accountId();
query_delete_msg.setForwardOnly(true);
if (clean_read_only) {
query_delete_msg.prepare(QString("UPDATE Messages SET is_deleted = :deleted "
"WHERE feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0 AND is_read = 1;").arg(textualFeedIds(items).join(QSL(", "))));
"WHERE feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0 AND is_read = 1 AND account_id = :account_id;")
.arg(textualFeedIds(items).join(QSL(", "))));
}
else {
query_delete_msg.prepare(QString("UPDATE Messages SET is_deleted = :deleted "
"WHERE feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0;").arg(textualFeedIds(items).join(QSL(", "))));
"WHERE feed IN (%1) AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id;")
.arg(textualFeedIds(items).join(QSL(", "))));
}
query_delete_msg.bindValue(QSL(":deleted"), 1);
query_delete_msg.bindValue(QSL(":account_id"), account_id);
if (query_delete_msg.exec()) {
// Messages are cleared, now inform model about need to reload data.
@ -222,8 +226,7 @@ bool StandardServiceRoot::cleanFeeds(QList<Feed*> items, bool clean_read_only) {
return true;
}
else {
QString aa = query_delete_msg.lastError().text();
qDebug("Cleaning of feeds failed: '%s'.", qPrintable(query_delete_msg.lastError().text()));
return false;
}
}
@ -497,7 +500,6 @@ bool StandardServiceRoot::onAfterSetMessagesRead(RootItem *selected_item, const
selected_item->updateCounts(false);
itemChanged(QList<RootItem*>() << selected_item);
requestFeedReadFilterReload();
return true;
}
@ -538,8 +540,6 @@ bool StandardServiceRoot::onAfterMessagesDelete(RootItem *selected_item, const Q
itemChanged(QList<RootItem*>() << selected_item << m_recycleBin);
}
requestFeedReadFilterReload();
return true;
}
@ -556,6 +556,5 @@ bool StandardServiceRoot::onAfterMessagesRestoredFromBin(RootItem *selected_item
updateCounts(true);
itemChanged(getSubTree());
requestFeedReadFilterReload();
return true;
}

View File

@ -387,10 +387,6 @@ int TtRssFeed::updateMessages(const QList<Message> &messages) {
updateCounts(true);
serviceRoot()->itemChanged(QList<RootItem*>() << this);
if (updated_messages > 0) {
serviceRoot()->requestFeedReadFilterReload();
}
}
return updated_messages;

View File

@ -222,7 +222,6 @@ bool TtRssServiceRoot::onAfterSetMessagesRead(RootItem *selected_item, const QLi
selected_item->updateCounts(false);
itemChanged(QList<RootItem*>() << selected_item);
requestFeedReadFilterReload();
return true;
}
@ -272,7 +271,6 @@ bool TtRssServiceRoot::onAfterMessagesDelete(RootItem *selected_item, const QLis
itemChanged(QList<RootItem*>() << selected_item << m_recycleBin);
}
requestFeedReadFilterReload();
return true;
}