Fixed #149.
This commit is contained in:
parent
4cd04d03db
commit
f73d0eeb8c
@ -12,6 +12,7 @@ Changed:
|
|||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
|
|
||||||
|
▪ 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)
|
||||||
▪ Fixed error in SQL initialization script which led to problems with in-memory SQLite DBs. (bug #140)
|
▪ Fixed error in SQL initialization script which led to problems with in-memory SQLite DBs. (bug #140)
|
||||||
▪ Fixed problem with saving sort column/order for message list. (bug #141)
|
▪ Fixed problem with saving sort column/order for message list. (bug #141)
|
||||||
|
@ -691,6 +691,7 @@ bool FeedsModel::addServiceAccount(ServiceRoot *root, bool freshly_activated) {
|
|||||||
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)));
|
||||||
|
connect(root, SIGNAL(itemExpandStateSaveRequested(RootItem*)), this, SIGNAL(itemExpandStateSaveRequested(RootItem*)));
|
||||||
|
|
||||||
root->start(freshly_activated);
|
root->start(freshly_activated);
|
||||||
return true;
|
return true;
|
||||||
|
@ -212,6 +212,10 @@ class FeedsModel : public QAbstractItemModel {
|
|||||||
// Emitted if any item requested that any view should expand it.
|
// Emitted if any item requested that any view should expand it.
|
||||||
void itemExpandRequested(QList<RootItem*> items, bool expand);
|
void itemExpandRequested(QList<RootItem*> items, bool expand);
|
||||||
|
|
||||||
|
// Emitted if any item requested that its expand states should be explicitly saved.
|
||||||
|
// NOTE: Normally expand states are saved when application quits.
|
||||||
|
void itemExpandStateSaveRequested(RootItem *subtree_root);
|
||||||
|
|
||||||
// Emitted when there is a need of reloading of displayed messages.
|
// Emitted when there is a need of reloading of displayed messages.
|
||||||
void reloadMessageListRequested(bool mark_selected_messages_read);
|
void reloadMessageListRequested(bool mark_selected_messages_read);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ FeedMessageViewer::~FeedMessageViewer() {
|
|||||||
void FeedMessageViewer::saveSize() {
|
void FeedMessageViewer::saveSize() {
|
||||||
Settings *settings = qApp->settings();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
m_feedsView->saveExpandedStates();
|
m_feedsView->saveAllExpandStates();
|
||||||
|
|
||||||
// Store offsets of splitters.
|
// Store offsets of splitters.
|
||||||
settings->setValue(GROUP(GUI), GUI::SplitterFeeds, QString(m_feedSplitter->saveState().toBase64()));
|
settings->setValue(GROUP(GUI), GUI::SplitterFeeds, QString(m_feedSplitter->saveState().toBase64()));
|
||||||
|
@ -57,6 +57,7 @@ FeedsView::FeedsView(QWidget *parent)
|
|||||||
// Connections.
|
// Connections.
|
||||||
connect(m_sourceModel, SIGNAL(requireItemValidationAfterDragDrop(QModelIndex)), this, SLOT(validateItemAfterDragDrop(QModelIndex)));
|
connect(m_sourceModel, SIGNAL(requireItemValidationAfterDragDrop(QModelIndex)), this, SLOT(validateItemAfterDragDrop(QModelIndex)));
|
||||||
connect(m_sourceModel, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)), this, SLOT(onItemExpandRequested(QList<RootItem*>,bool)));
|
connect(m_sourceModel, SIGNAL(itemExpandRequested(QList<RootItem*>,bool)), this, SLOT(onItemExpandRequested(QList<RootItem*>,bool)));
|
||||||
|
connect(m_sourceModel, SIGNAL(itemExpandStateSaveRequested(RootItem*)), this, SLOT(onItemExpandStateSaveRequested(RootItem*)));
|
||||||
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
|
||||||
|
|
||||||
setModel(m_proxyModel);
|
setModel(m_proxyModel);
|
||||||
@ -100,23 +101,29 @@ RootItem *FeedsView::selectedItem() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::saveExpandedStates() {
|
void FeedsView::onItemExpandStateSaveRequested(RootItem *item) {
|
||||||
Settings *settings = qApp->settings();
|
saveExpandStates(item);
|
||||||
QList<RootItem*> expandable_items;
|
}
|
||||||
|
|
||||||
expandable_items.append(sourceModel()->rootItem()->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot));
|
void FeedsView::saveAllExpandStates() {
|
||||||
|
saveExpandStates(sourceModel()->rootItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FeedsView::saveExpandStates(RootItem *item) {
|
||||||
|
Settings *settings = qApp->settings();
|
||||||
|
QList<RootItem*> items = item->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot);
|
||||||
|
|
||||||
// Iterate all categories and save their expand statuses.
|
// Iterate all categories and save their expand statuses.
|
||||||
foreach (RootItem *item, expandable_items) {
|
foreach (RootItem *item, items) {
|
||||||
QString setting_name = item->hashCode();
|
const QString setting_name = item->hashCode();
|
||||||
|
|
||||||
settings->setValue(GROUP(Categories),
|
settings->setValue(GROUP(CategoriesExpandStates),
|
||||||
setting_name,
|
setting_name,
|
||||||
isExpanded(model()->mapFromSource(sourceModel()->indexForItem(item))));
|
isExpanded(model()->mapFromSource(sourceModel()->indexForItem(item))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::loadExpandedStates() {
|
void FeedsView::loadAllExpandStates() {
|
||||||
Settings *settings = qApp->settings();
|
Settings *settings = qApp->settings();
|
||||||
QList<RootItem*> expandable_items;
|
QList<RootItem*> expandable_items;
|
||||||
|
|
||||||
@ -124,10 +131,10 @@ void FeedsView::loadExpandedStates() {
|
|||||||
|
|
||||||
// Iterate all categories and save their expand statuses.
|
// Iterate all categories and save their expand statuses.
|
||||||
foreach (RootItem *item, expandable_items) {
|
foreach (RootItem *item, expandable_items) {
|
||||||
QString setting_name = item->hashCode();
|
const QString setting_name = item->hashCode();
|
||||||
|
|
||||||
setExpanded(model()->mapFromSource(sourceModel()->indexForItem(item)),
|
setExpanded(model()->mapFromSource(sourceModel()->indexForItem(item)),
|
||||||
settings->value(GROUP(Categories), setting_name, item->childCount() > 0).toBool());
|
settings->value(GROUP(CategoriesExpandStates), setting_name, item->childCount() > 0).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
sortByColumn(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnFeeds)).toInt(),
|
sortByColumn(qApp->settings()->value(GROUP(GUI), SETTING(GUI::DefaultSortColumnFeeds)).toInt(),
|
||||||
|
@ -58,8 +58,8 @@ class FeedsView : public QTreeView {
|
|||||||
RootItem *selectedItem() const;
|
RootItem *selectedItem() const;
|
||||||
|
|
||||||
// Saves/loads expand states of all nodes (feeds/categories) of the list to/from settings.
|
// Saves/loads expand states of all nodes (feeds/categories) of the list to/from settings.
|
||||||
void saveExpandedStates();
|
void saveAllExpandStates();
|
||||||
void loadExpandedStates();
|
void loadAllExpandStates();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addFeedIntoSelectedAccount();
|
void addFeedIntoSelectedAccount();
|
||||||
@ -107,6 +107,7 @@ class FeedsView : public QTreeView {
|
|||||||
void saveSortState(int column, Qt::SortOrder order);
|
void saveSortState(int column, Qt::SortOrder order);
|
||||||
void validateItemAfterDragDrop(const QModelIndex &source_index);
|
void validateItemAfterDragDrop(const QModelIndex &source_index);
|
||||||
void onItemExpandRequested(const QList<RootItem*> &items, bool exp);
|
void onItemExpandRequested(const QList<RootItem*> &items, bool exp);
|
||||||
|
void onItemExpandStateSaveRequested(RootItem *item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Initializes context menus.
|
// Initializes context menus.
|
||||||
@ -118,6 +119,8 @@ class FeedsView : public QTreeView {
|
|||||||
// Sets up appearance of this widget.
|
// Sets up appearance of this widget.
|
||||||
void setupAppearance();
|
void setupAppearance();
|
||||||
|
|
||||||
|
void saveExpandStates(RootItem *item);
|
||||||
|
|
||||||
// Handle selections.
|
// Handle selections.
|
||||||
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// Load activated accounts.
|
// Load activated accounts.
|
||||||
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->loadActivatedServiceAccounts();
|
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->loadActivatedServiceAccounts();
|
||||||
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadExpandedStates();
|
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates();
|
||||||
|
|
||||||
// Setup single-instance behavior.
|
// Setup single-instance behavior.
|
||||||
QObject::connect(&application, SIGNAL(messageReceived(QString)), &application, SLOT(processExecutionMessage(QString)));
|
QObject::connect(&application, SIGNAL(messageReceived(QString)), &application, SLOT(processExecutionMessage(QString)));
|
||||||
|
@ -290,7 +290,7 @@ DKEY Browser::QueueTabs = "queue_tabs";
|
|||||||
DVALUE(bool) Browser::QueueTabsDef = true;
|
DVALUE(bool) Browser::QueueTabsDef = true;
|
||||||
|
|
||||||
// Categories.
|
// Categories.
|
||||||
DKEY Categories::ID = "categories_expand_states";
|
DKEY CategoriesExpandStates::ID = "categories_expand_states";
|
||||||
|
|
||||||
Settings::Settings(const QString &file_name, Format format, const SettingsProperties::SettingsType &status, QObject *parent)
|
Settings::Settings(const QString &file_name, Format format, const SettingsProperties::SettingsType &status, QObject *parent)
|
||||||
: QSettings(file_name, format, parent), m_initializationStatus(status) {
|
: QSettings(file_name, format, parent), m_initializationStatus(status) {
|
||||||
|
@ -322,7 +322,7 @@ namespace Browser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Categories.
|
// Categories.
|
||||||
namespace Categories {
|
namespace CategoriesExpandStates {
|
||||||
KEY ID;
|
KEY ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,7 @@ RootItem::~RootItem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString RootItem::hashCode() const {
|
QString RootItem::hashCode() const {
|
||||||
return
|
return QString::number(kind()) + QL1S("-") + QString::number(id());
|
||||||
QString::number(kind()) + QL1S("-") +
|
|
||||||
QString::number(qHash(title())) + QL1S("-") +
|
|
||||||
QString::number(id());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QAction*> RootItem::contextMenu() {
|
QList<QAction*> RootItem::contextMenu() {
|
||||||
|
@ -126,6 +126,10 @@ void ServiceRoot::requestItemExpand(const QList<RootItem *> &items, bool expand)
|
|||||||
emit itemExpandRequested(items, expand);
|
emit itemExpandRequested(items, expand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServiceRoot::requestItemExpandStateSave(RootItem *subtree_root) {
|
||||||
|
emit itemExpandStateSaveRequested(subtree_root);
|
||||||
|
}
|
||||||
|
|
||||||
void ServiceRoot::requestItemReassignment(RootItem *item, RootItem *new_parent) {
|
void ServiceRoot::requestItemReassignment(RootItem *item, RootItem *new_parent) {
|
||||||
emit itemReassignmentRequested(item, new_parent);
|
emit itemReassignmentRequested(item, new_parent);
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,7 @@ class ServiceRoot : public RootItem {
|
|||||||
void requestReloadMessageList(bool mark_selected_messages_read);
|
void requestReloadMessageList(bool mark_selected_messages_read);
|
||||||
void requestFeedReadFilterReload();
|
void requestFeedReadFilterReload();
|
||||||
void requestItemExpand(const QList<RootItem*> &items, bool expand);
|
void requestItemExpand(const QList<RootItem*> &items, bool expand);
|
||||||
|
void requestItemExpandStateSave(RootItem *subtree_root);
|
||||||
void requestItemReassignment(RootItem *item, RootItem *new_parent);
|
void requestItemReassignment(RootItem *item, RootItem *new_parent);
|
||||||
void requestItemRemoval(RootItem *item);
|
void requestItemRemoval(RootItem *item);
|
||||||
|
|
||||||
@ -174,6 +175,7 @@ class ServiceRoot : public RootItem {
|
|||||||
void readFeedsFilterInvalidationRequested();
|
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 itemReassignmentRequested(RootItem *item, RootItem *new_parent);
|
void itemReassignmentRequested(RootItem *item, RootItem *new_parent);
|
||||||
void itemRemovalRequested(RootItem *item);
|
void itemRemovalRequested(RootItem *item);
|
||||||
|
@ -77,6 +77,7 @@ ServiceRoot *StandardServiceEntryPoint::createNewRoot() {
|
|||||||
|
|
||||||
if (query.exec()) {
|
if (query.exec()) {
|
||||||
StandardServiceRoot *root = new StandardServiceRoot();
|
StandardServiceRoot *root = new StandardServiceRoot();
|
||||||
|
root->setId(id_to_assign);
|
||||||
root->setAccountId(id_to_assign);
|
root->setAccountId(id_to_assign);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@ -98,6 +99,7 @@ QList<ServiceRoot*> StandardServiceEntryPoint::initializeSubtree() const {
|
|||||||
if (query.exec()) {
|
if (query.exec()) {
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
StandardServiceRoot *root = new StandardServiceRoot();
|
StandardServiceRoot *root = new StandardServiceRoot();
|
||||||
|
root->setId(query.value(0).toInt());
|
||||||
root->setAccountId(query.value(0).toInt());
|
root->setAccountId(query.value(0).toInt());
|
||||||
roots.append(root);
|
roots.append(root);
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,13 @@ TtRssCategory::TtRssCategory(const QSqlRecord &record) : Category(NULL) {
|
|||||||
TtRssCategory::~TtRssCategory() {
|
TtRssCategory::~TtRssCategory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TtRssCategory::hashCode() const {
|
||||||
|
return
|
||||||
|
QString::number(kind()) + QL1S("-") +
|
||||||
|
QString::number(const_cast<TtRssCategory*>(this)->getParentServiceRoot()->accountId()) + QL1S("-") +
|
||||||
|
QString::number(customId());
|
||||||
|
}
|
||||||
|
|
||||||
TtRssServiceRoot *TtRssCategory::serviceRoot() {
|
TtRssServiceRoot *TtRssCategory::serviceRoot() {
|
||||||
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ class TtRssCategory : public Category {
|
|||||||
explicit TtRssCategory(const QSqlRecord &record);
|
explicit TtRssCategory(const QSqlRecord &record);
|
||||||
virtual ~TtRssCategory();
|
virtual ~TtRssCategory();
|
||||||
|
|
||||||
|
QString hashCode() const;
|
||||||
|
|
||||||
TtRssServiceRoot *serviceRoot();
|
TtRssServiceRoot *serviceRoot();
|
||||||
|
|
||||||
bool markAsReadUnread(ReadStatus status);
|
bool markAsReadUnread(ReadStatus status);
|
||||||
|
@ -50,6 +50,13 @@ TtRssFeed::TtRssFeed(const QSqlRecord &record) : Feed(NULL), m_totalCount(0), m_
|
|||||||
TtRssFeed::~TtRssFeed() {
|
TtRssFeed::~TtRssFeed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TtRssFeed::hashCode() const {
|
||||||
|
return
|
||||||
|
QString::number(kind()) + QL1S("-") +
|
||||||
|
QString::number(const_cast<TtRssFeed*>(this)->getParentServiceRoot()->accountId()) + QL1S("-") +
|
||||||
|
QString::number(customId());
|
||||||
|
}
|
||||||
|
|
||||||
TtRssServiceRoot *TtRssFeed::serviceRoot() {
|
TtRssServiceRoot *TtRssFeed::serviceRoot() {
|
||||||
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ class TtRssFeed : public Feed {
|
|||||||
explicit TtRssFeed(const QSqlRecord &record);
|
explicit TtRssFeed(const QSqlRecord &record);
|
||||||
virtual ~TtRssFeed();
|
virtual ~TtRssFeed();
|
||||||
|
|
||||||
|
QString hashCode() const;
|
||||||
|
|
||||||
TtRssServiceRoot *serviceRoot();
|
TtRssServiceRoot *serviceRoot();
|
||||||
|
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const;
|
||||||
|
@ -581,6 +581,7 @@ void TtRssServiceRoot::syncIn() {
|
|||||||
RootItem *new_tree = feed_cats_response.feedsCategories(true, m_network->url());
|
RootItem *new_tree = feed_cats_response.feedsCategories(true, m_network->url());
|
||||||
|
|
||||||
// Purge old data from SQL and clean all model items.
|
// Purge old data from SQL and clean all model items.
|
||||||
|
requestItemExpandStateSave(this);
|
||||||
removeOldFeedTree(false);
|
removeOldFeedTree(false);
|
||||||
cleanAllItems();
|
cleanAllItems();
|
||||||
|
|
||||||
@ -602,7 +603,17 @@ void TtRssServiceRoot::syncIn() {
|
|||||||
|
|
||||||
itemChanged(all_items);
|
itemChanged(all_items);
|
||||||
requestReloadMessageList(true);
|
requestReloadMessageList(true);
|
||||||
requestItemExpand(all_items, true);
|
|
||||||
|
// Now we must refresh expand states.
|
||||||
|
QList<RootItem*> items_to_expand;
|
||||||
|
|
||||||
|
foreach (RootItem *item, all_items) {
|
||||||
|
if (qApp->settings()->value(GROUP(CategoriesExpandStates), item->hashCode(), item->childCount() > 0).toBool()) {
|
||||||
|
items_to_expand.append(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
requestItemExpand(items_to_expand, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setIcon(original_icon);
|
setIcon(original_icon);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user