diff --git a/src/core/defs.h.in b/src/core/defs.h.in index 08b48bb39..04ec38b07 100755 --- a/src/core/defs.h.in +++ b/src/core/defs.h.in @@ -84,6 +84,7 @@ #define APP_CFG_BROWSER "browser" #define APP_CFG_MESSAGES "messages" #define APP_CFG_FEEDS "feeds" +#define APP_CFG_CAT_EXP "categories_expand_states" #if defined(Q_OS_OSX) #define APP_PREFIX "@CMAKE_INSTALL_PREFIX@/@APP_LOW_NAME@.app/Contents/Resources" diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 8fe6e480c..064cd8552 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -73,6 +73,8 @@ FeedMessageViewer::~FeedMessageViewer() { void FeedMessageViewer::saveSize() { Settings *settings = Settings::instance(); + m_feedsView->saveExpandedStates(); + // Store offsets of splitters. settings->setValue(APP_CFG_GUI, "splitter_feeds", @@ -100,6 +102,8 @@ void FeedMessageViewer::loadSize() { Settings *settings = Settings::instance(); int default_msg_section_size = m_messagesView->header()->defaultSectionSize(); + m_feedsView->loadExpandedStates(); + // Restore offsets of splitters. m_feedSplitter->restoreState(QByteArray::fromBase64(settings->value(APP_CFG_GUI, "splitter_feeds").toString().toLocal8Bit())); m_messageSplitter->restoreState(QByteArray::fromBase64(settings->value(APP_CFG_GUI, "splitter_messages").toString().toLocal8Bit())); diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 972c459e8..a7194af1c 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -115,6 +115,29 @@ FeedsModelFeed *FeedsView::isCurrentIndexFeed() const { return m_sourceModel->feedForIndex(current_mapped); } +void FeedsView::saveExpandedStates() { + Settings *settings = Settings::instance(); + + // Iterate all categories and save their expand statuses. + foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) { + settings->setValue(APP_CFG_CAT_EXP, + QString::number(category->id()), + isExpanded(model()->mapFromSource(sourceModel()->indexForItem(category)))); + } +} + +void FeedsView::loadExpandedStates() { + Settings *settings = Settings::instance(); + + // Iterate all categories and save their expand statuses. + foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) { + setExpanded(model()->mapFromSource(sourceModel()->indexForItem(category)), + settings->value(APP_CFG_CAT_EXP, + QString::number(category->id()), + true).toBool()); + } +} + void FeedsView::updateAllFeeds() { if (SystemFactory::instance()->applicationCloseLock()->tryLock()) { emit feedsUpdateRequested(allFeeds()); diff --git a/src/gui/feedsview.h b/src/gui/feedsview.h index 244b0b08e..257623435 100644 --- a/src/gui/feedsview.h +++ b/src/gui/feedsview.h @@ -66,6 +66,9 @@ class FeedsView : public QTreeView { FeedsModelCategory *isCurrentIndexCategory() const; FeedsModelFeed *isCurrentIndexFeed() const; + void saveExpandedStates(); + void loadExpandedStates(); + public slots: // Feed updating. void updateAllFeeds();