Changes to sorting/filtering.
This commit is contained in:
		
							parent
							
								
									8f9d3f7aa4
								
							
						
					
					
						commit
						976d5222ff
					
				
					 12 changed files with 20 additions and 46 deletions
				
			
		| 
						 | 
					@ -12,9 +12,11 @@ Changed:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
▪ Some GUI refinements and fixes.
 | 
					▪ Some GUI refinements and fixes.
 | 
				
			||||||
▪ Added more logging entries.
 | 
					▪ Added more logging entries.
 | 
				
			||||||
 | 
					▪ "Clean all items" now does not clean messages from recycle bins.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Fixed:
 | 
					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)
 | 
					▪ 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)
 | 
					▪ 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)
 | 
					▪ Fixed problem with importing invalid OPML 2.0 files. (bug #145)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -177,7 +177,7 @@ void FeedsModel::onFeedUpdatesFinished(const FeedDownloadResults &results) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  emit feedsUpdateFinished();
 | 
					  emit feedsUpdateFinished();
 | 
				
			||||||
  emit sortingRequired();
 | 
					  //emit sortingRequired();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void FeedsModel::updateAllFeeds() {
 | 
					void FeedsModel::updateAllFeeds() {
 | 
				
			||||||
| 
						 | 
					@ -614,10 +614,15 @@ bool FeedsModel::hasAnyFeedNewMessages() const {
 | 
				
			||||||
void FeedsModel::reloadChangedLayout(QModelIndexList list) {
 | 
					void FeedsModel::reloadChangedLayout(QModelIndexList list) {
 | 
				
			||||||
  while (!list.isEmpty()) {
 | 
					  while (!list.isEmpty()) {
 | 
				
			||||||
    QModelIndex indx = list.takeFirst();
 | 
					    QModelIndex indx = list.takeFirst();
 | 
				
			||||||
    QModelIndex indx_parent = indx.parent();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Underlying data are changed.
 | 
					    if (indx.isValid()) {
 | 
				
			||||||
    emit dataChanged(index(indx.row(), 0, indx_parent), index(indx.row(), FDS_MODEL_COUNTS_INDEX, indx_parent));
 | 
					      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.
 | 
				
			||||||
  connect(root, SIGNAL(itemRemovalRequested(RootItem*)), this, SLOT(removeItem(RootItem*)));
 | 
					  connect(root, SIGNAL(itemRemovalRequested(RootItem*)), this, SLOT(removeItem(RootItem*)));
 | 
				
			||||||
  connect(root, SIGNAL(itemReassignmentRequested(RootItem*,RootItem*)), this, SLOT(reassignNodeToNewParent(RootItem*,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(dataChanged(QList<RootItem*>)), this, SLOT(onItemDataChanged(QList<RootItem*>)));
 | 
				
			||||||
  connect(root, SIGNAL(reloadMessageListRequested(bool)), this, SIGNAL(reloadMessageListRequested(bool)));
 | 
					  connect(root, SIGNAL(reloadMessageListRequested(bool)), this, SIGNAL(reloadMessageListRequested(bool)));
 | 
				
			||||||
  connect(root, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)), this, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)));
 | 
					  connect(root, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)), this, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -197,10 +197,6 @@ class FeedsModel : public QAbstractItemModel {
 | 
				
			||||||
    // Update of feeds is finished.
 | 
					    // Update of feeds is finished.
 | 
				
			||||||
    void feedsUpdateFinished();
 | 
					    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.
 | 
					    // Emitted when model requests update of some feeds.
 | 
				
			||||||
    void feedsUpdateRequested(const QList<Feed*> feeds);
 | 
					    void feedsUpdateRequested(const QList<Feed*> feeds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,10 +37,8 @@ FeedsProxyModel::FeedsProxyModel(QObject *parent)
 | 
				
			||||||
  setFilterCaseSensitivity(Qt::CaseInsensitive);
 | 
					  setFilterCaseSensitivity(Qt::CaseInsensitive);
 | 
				
			||||||
  setFilterKeyColumn(-1);
 | 
					  setFilterKeyColumn(-1);
 | 
				
			||||||
  setFilterRole(Qt::EditRole);
 | 
					  setFilterRole(Qt::EditRole);
 | 
				
			||||||
  setDynamicSortFilter(false);
 | 
					  setDynamicSortFilter(true);
 | 
				
			||||||
  setSourceModel(m_sourceModel);
 | 
					  setSourceModel(m_sourceModel);
 | 
				
			||||||
 | 
					 | 
				
			||||||
  connect(m_sourceModel, SIGNAL(readFeedsFilterInvalidationRequested()), this, SLOT(invalidateReadFeedsFilter()));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FeedsProxyModel::~FeedsProxyModel() {
 | 
					FeedsProxyModel::~FeedsProxyModel() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -186,7 +186,6 @@ bool RecycleBin::restore() {
 | 
				
			||||||
    parent_root->updateCounts(true);
 | 
					    parent_root->updateCounts(true);
 | 
				
			||||||
    parent_root->itemChanged(parent_root->getSubTree());
 | 
					    parent_root->itemChanged(parent_root->getSubTree());
 | 
				
			||||||
    parent_root->requestReloadMessageList(true);
 | 
					    parent_root->requestReloadMessageList(true);
 | 
				
			||||||
    parent_root->requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else {
 | 
					  else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,21 +89,13 @@ QList<Message> RootItem::undeletedMessages() const {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool RootItem::cleanMessages(bool clear_only_read) {
 | 
					bool RootItem::cleanMessages(bool clear_only_read) {
 | 
				
			||||||
  bool result = true;
 | 
					  bool result = true;
 | 
				
			||||||
  RecycleBin *bin = NULL;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  foreach (RootItem *child, m_childItems) {
 | 
					  foreach (RootItem *child, m_childItems) {
 | 
				
			||||||
    if (child->kind() == RootItemKind::Bin) {
 | 
					    if (child->kind() != RootItemKind::Bin) {
 | 
				
			||||||
      bin = qobject_cast<RecycleBin*>(child);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
      result &= child->cleanMessages(clear_only_read);
 | 
					      result &= child->cleanMessages(clear_only_read);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (bin != NULL) {
 | 
					 | 
				
			||||||
    result &= bin->cleanMessages(clear_only_read);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return result;
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,10 +118,6 @@ void ServiceRoot::requestReloadMessageList(bool mark_selected_messages_read) {
 | 
				
			||||||
  emit reloadMessageListRequested(mark_selected_messages_read);
 | 
					  emit reloadMessageListRequested(mark_selected_messages_read);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ServiceRoot::requestFeedReadFilterReload() {
 | 
					 | 
				
			||||||
  emit readFeedsFilterInvalidationRequested();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ServiceRoot::requestItemExpand(const QList<RootItem*> &items, bool expand) {
 | 
					void ServiceRoot::requestItemExpand(const QList<RootItem*> &items, bool expand) {
 | 
				
			||||||
  emit itemExpandRequested(items, expand);
 | 
					  emit itemExpandRequested(items, expand);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -154,7 +154,6 @@ class ServiceRoot : public RootItem {
 | 
				
			||||||
    // Obvious methods to wrap signals.
 | 
					    // Obvious methods to wrap signals.
 | 
				
			||||||
    void itemChanged(const QList<RootItem*> &items);
 | 
					    void itemChanged(const QList<RootItem*> &items);
 | 
				
			||||||
    void requestReloadMessageList(bool mark_selected_messages_read);
 | 
					    void requestReloadMessageList(bool mark_selected_messages_read);
 | 
				
			||||||
    void requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
    void requestItemExpand(const QList<RootItem*> &items, bool expand);
 | 
					    void requestItemExpand(const QList<RootItem*> &items, bool expand);
 | 
				
			||||||
    void requestItemExpandStateSave(RootItem *subtree_root);
 | 
					    void requestItemExpandStateSave(RootItem *subtree_root);
 | 
				
			||||||
    void requestItemReassignment(RootItem *item, RootItem *new_parent);
 | 
					    void requestItemReassignment(RootItem *item, RootItem *new_parent);
 | 
				
			||||||
| 
						 | 
					@ -172,7 +171,6 @@ class ServiceRoot : public RootItem {
 | 
				
			||||||
  signals:
 | 
					  signals:
 | 
				
			||||||
    // Emitted if data in any item belonging to this root are changed.
 | 
					    // Emitted if data in any item belonging to this root are changed.
 | 
				
			||||||
    void dataChanged(QList<RootItem*> items);
 | 
					    void dataChanged(QList<RootItem*> items);
 | 
				
			||||||
    void readFeedsFilterInvalidationRequested();
 | 
					 | 
				
			||||||
    void reloadMessageListRequested(bool mark_selected_messages_read);
 | 
					    void reloadMessageListRequested(bool mark_selected_messages_read);
 | 
				
			||||||
    void itemExpandRequested(QList<RootItem*> items, bool expand);
 | 
					    void itemExpandRequested(QList<RootItem*> items, bool expand);
 | 
				
			||||||
    void itemExpandStateSaveRequested(RootItem *subtree_root);
 | 
					    void itemExpandStateSaveRequested(RootItem *subtree_root);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -742,10 +742,6 @@ int StandardFeed::updateMessages(const QList<Message> &messages) {
 | 
				
			||||||
  else {
 | 
					  else {
 | 
				
			||||||
    updateCounts(true);
 | 
					    updateCounts(true);
 | 
				
			||||||
    serviceRoot()->itemChanged(QList<RootItem*>() << this);
 | 
					    serviceRoot()->itemChanged(QList<RootItem*>() << this);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (updated_messages > 0) {
 | 
					 | 
				
			||||||
      serviceRoot()->requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return updated_messages;
 | 
					  return updated_messages;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -192,18 +192,22 @@ bool StandardServiceRoot::markFeedsReadUnread(QList<Feed*> items, ReadStatus rea
 | 
				
			||||||
bool StandardServiceRoot::cleanFeeds(QList<Feed*> items, bool clean_read_only) {
 | 
					bool StandardServiceRoot::cleanFeeds(QList<Feed*> items, bool clean_read_only) {
 | 
				
			||||||
  QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
 | 
					  QSqlDatabase db_handle = qApp->database()->connection(metaObject()->className(), DatabaseFactory::FromSettings);
 | 
				
			||||||
  QSqlQuery query_delete_msg(db_handle);
 | 
					  QSqlQuery query_delete_msg(db_handle);
 | 
				
			||||||
 | 
					  int account_id = accountId();
 | 
				
			||||||
  query_delete_msg.setForwardOnly(true);
 | 
					  query_delete_msg.setForwardOnly(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (clean_read_only) {
 | 
					  if (clean_read_only) {
 | 
				
			||||||
    query_delete_msg.prepare(QString("UPDATE Messages SET is_deleted = :deleted "
 | 
					    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 {
 | 
					  else {
 | 
				
			||||||
    query_delete_msg.prepare(QString("UPDATE Messages SET is_deleted = :deleted "
 | 
					    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(":deleted"), 1);
 | 
				
			||||||
 | 
					  query_delete_msg.bindValue(QSL(":account_id"), account_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (query_delete_msg.exec()) {
 | 
					  if (query_delete_msg.exec()) {
 | 
				
			||||||
    // Messages are cleared, now inform model about need to reload data.
 | 
					    // 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;
 | 
					    return true;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else {
 | 
					  else {
 | 
				
			||||||
    QString aa = query_delete_msg.lastError().text();
 | 
					    qDebug("Cleaning of feeds failed: '%s'.", qPrintable(query_delete_msg.lastError().text()));
 | 
				
			||||||
 | 
					 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -497,7 +500,6 @@ bool StandardServiceRoot::onAfterSetMessagesRead(RootItem *selected_item, const
 | 
				
			||||||
  selected_item->updateCounts(false);
 | 
					  selected_item->updateCounts(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  itemChanged(QList<RootItem*>() << selected_item);
 | 
					  itemChanged(QList<RootItem*>() << selected_item);
 | 
				
			||||||
  requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -538,8 +540,6 @@ bool StandardServiceRoot::onAfterMessagesDelete(RootItem *selected_item, const Q
 | 
				
			||||||
    itemChanged(QList<RootItem*>() << selected_item << m_recycleBin);
 | 
					    itemChanged(QList<RootItem*>() << selected_item << m_recycleBin);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -556,6 +556,5 @@ bool StandardServiceRoot::onAfterMessagesRestoredFromBin(RootItem *selected_item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  updateCounts(true);
 | 
					  updateCounts(true);
 | 
				
			||||||
  itemChanged(getSubTree());
 | 
					  itemChanged(getSubTree());
 | 
				
			||||||
  requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -387,10 +387,6 @@ int TtRssFeed::updateMessages(const QList<Message> &messages) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    updateCounts(true);
 | 
					    updateCounts(true);
 | 
				
			||||||
    serviceRoot()->itemChanged(QList<RootItem*>() << this);
 | 
					    serviceRoot()->itemChanged(QList<RootItem*>() << this);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (updated_messages > 0) {
 | 
					 | 
				
			||||||
      serviceRoot()->requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return updated_messages;
 | 
					  return updated_messages;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -222,7 +222,6 @@ bool TtRssServiceRoot::onAfterSetMessagesRead(RootItem *selected_item, const QLi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  selected_item->updateCounts(false);
 | 
					  selected_item->updateCounts(false);
 | 
				
			||||||
  itemChanged(QList<RootItem*>() << selected_item);
 | 
					  itemChanged(QList<RootItem*>() << selected_item);
 | 
				
			||||||
  requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -272,7 +271,6 @@ bool TtRssServiceRoot::onAfterMessagesDelete(RootItem *selected_item, const QLis
 | 
				
			||||||
    itemChanged(QList<RootItem*>() << selected_item << m_recycleBin);
 | 
					    itemChanged(QList<RootItem*>() << selected_item << m_recycleBin);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  requestFeedReadFilterReload();
 | 
					 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue