Saving/loading of expand states is partially working now.
This commit is contained in:
parent
dad3cc8555
commit
bd3673615d
5 changed files with 31 additions and 18 deletions
|
@ -578,13 +578,21 @@ QList<Feed*> FeedsModel::feedsForItem(RootItem *root) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Category*> FeedsModel::categoriesForItem(RootItem *root) {
|
QList<Category*> FeedsModel::categoriesForItem(RootItem *root) {
|
||||||
QList<RootItem*> children = root->getRecursiveChildren();
|
|
||||||
QList<Category*> categories;
|
QList<Category*> categories;
|
||||||
|
QList<RootItem*> parents;
|
||||||
|
|
||||||
foreach (RootItem *child, children) {
|
parents.append(root);
|
||||||
if (child->kind() == RootItemKind::Category) {
|
|
||||||
categories.append(child->toCategory());
|
while (!parents.isEmpty()) {
|
||||||
|
RootItem *item = parents.takeFirst();
|
||||||
|
|
||||||
|
if (item->kind() == RootItemKind::Category) {
|
||||||
|
// This item is category, add it to the output list and
|
||||||
|
// scan its children.
|
||||||
|
categories.append( item->toCategory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parents.append(item->childItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
return categories;
|
return categories;
|
||||||
|
|
|
@ -91,6 +91,7 @@ QList<RootItem*> RootItem::getRecursiveChildren() {
|
||||||
// Iterate all nested categories.
|
// Iterate all nested categories.
|
||||||
while (!traversable_items.isEmpty()) {
|
while (!traversable_items.isEmpty()) {
|
||||||
RootItem *active_item = traversable_items.takeFirst();
|
RootItem *active_item = traversable_items.takeFirst();
|
||||||
|
children.append(active_item);
|
||||||
|
|
||||||
foreach (RootItem *child, active_item->childItems()) {
|
foreach (RootItem *child, active_item->childItems()) {
|
||||||
if (child->childCount() == 0) {
|
if (child->childCount() == 0) {
|
||||||
|
|
|
@ -31,7 +31,8 @@ namespace RootItemKind {
|
||||||
Root = 1001,
|
Root = 1001,
|
||||||
Bin = 1002,
|
Bin = 1002,
|
||||||
Feed = 1003,
|
Feed = 1003,
|
||||||
Category = 1004
|
Category = 1004,
|
||||||
|
ServiceRoot = 1005
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,27 +109,29 @@ Feed *FeedsView::selectedFeed() const {
|
||||||
void FeedsView::saveExpandedStates() {
|
void FeedsView::saveExpandedStates() {
|
||||||
Settings *settings = qApp->settings();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// TODO: doědlat
|
|
||||||
|
|
||||||
// Iterate all categories and save their expand statuses.
|
// Iterate all categories and save their expand statuses.
|
||||||
/*
|
foreach (Category *category, sourceModel()->allCategories()) {
|
||||||
foreach (Category *category, sourceModel()->allCategories().values()) {
|
QString setting_name = QString::number(qHash(category->title())) + QL1S("-") + QString::number(category->id());
|
||||||
|
|
||||||
settings->setValue(GROUP(Categories),
|
settings->setValue(GROUP(Categories),
|
||||||
QString::number(category->id()),
|
setting_name,
|
||||||
isExpanded(model()->mapFromSource(sourceModel()->indexForItem(category))));
|
isExpanded(model()->mapFromSource(sourceModel()->indexForItem(category))));
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::loadExpandedStates() {
|
void FeedsView::loadExpandedStates() {
|
||||||
Settings *settings = qApp->settings();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// TODO: doědlat
|
// TODO: nastavit všechny service rooty automaticky na expanded
|
||||||
|
// toto obnáší vytvoření metody sourceModel()->serviceRoots()
|
||||||
|
|
||||||
// Iterate all categories and save their expand statuses.
|
// Iterate all categories and save their expand statuses.
|
||||||
/*foreach (Category *category, sourceModel()->allCategories().values()) {
|
foreach (Category *category, sourceModel()->allCategories()) {
|
||||||
|
QString setting_name = QString::number(qHash(category->title())) + QL1S("-") + QString::number(category->id());
|
||||||
|
|
||||||
setExpanded(model()->mapFromSource(sourceModel()->indexForItem(category)),
|
setExpanded(model()->mapFromSource(sourceModel()->indexForItem(category)),
|
||||||
settings->value(GROUP(Categories), QString::number(category->id()), true).toBool());
|
settings->value(GROUP(Categories), setting_name, true).toBool());
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::invalidateReadFeedsFilter(bool set_new_value, bool show_unread_only) {
|
void FeedsView::invalidateReadFeedsFilter(bool set_new_value, bool show_unread_only) {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
|
|
||||||
ServiceRoot::ServiceRoot(FeedsModel *feeds_model, RootItem *parent) : RootItem(parent), m_feedsModel(feeds_model) {
|
ServiceRoot::ServiceRoot(FeedsModel *feeds_model, RootItem *parent) : RootItem(parent), m_feedsModel(feeds_model) {
|
||||||
|
m_kind = RootItemKind::ServiceRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceRoot::~ServiceRoot() {
|
ServiceRoot::~ServiceRoot() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue