Performance upgrade for finding index for item.
This commit is contained in:
parent
47ad127fca
commit
f9019ead0d
2 changed files with 22 additions and 4 deletions
|
@ -488,12 +488,31 @@ FeedsModelRecycleBin *FeedsModel::recycleBinForIndex(const QModelIndex &index) c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
|
QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
|
||||||
if (item == NULL || item->kind() == FeedsModelRootItem::RootItem) {
|
if (item == NULL || item->kind() == FeedsModelRootItem::RootItem) {
|
||||||
// Root item lies on invalid index.
|
// Root item lies on invalid index.
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStack<FeedsModelRootItem*> chain;
|
||||||
|
|
||||||
|
while (item->kind() != FeedsModelRootItem::RootItem) {
|
||||||
|
chain.push(item);
|
||||||
|
item = item->parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now, we have complete chain list: parent --- ..... --- parent --- leaf (item).
|
||||||
|
QModelIndex target_index = indexForItem(m_rootItem);
|
||||||
|
|
||||||
|
// We go through the stack and create our target index.
|
||||||
|
while (!chain.isEmpty()) {
|
||||||
|
FeedsModelRootItem *parent_item = chain.pop();
|
||||||
|
target_index = index(parent_item->parent()->childItems().indexOf(parent_item), 0, target_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return target_index;
|
||||||
|
|
||||||
|
/*
|
||||||
QList<QModelIndex> parents;
|
QList<QModelIndex> parents;
|
||||||
|
|
||||||
// Start with root item (which obviously has invalid index).
|
// Start with root item (which obviously has invalid index).
|
||||||
|
@ -527,6 +546,7 @@ QModelIndex FeedsModel::indexForItem(FeedsModelRootItem *item) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_message) {
|
bool FeedsModel::mergeModel(FeedsImportExportModel *model, QString &output_message) {
|
||||||
|
|
|
@ -169,9 +169,7 @@ void FeedMessageViewer::onFeedUpdatesStarted() {
|
||||||
qApp->mainForm()->statusBar()->showProgress(0, tr("Feed update started"));
|
qApp->mainForm()->statusBar()->showProgress(0, tr("Feed update started"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed,
|
void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total) {
|
||||||
int current,
|
|
||||||
int total) {
|
|
||||||
// Some feed got updated.
|
// Some feed got updated.
|
||||||
m_feedsView->updateCountsOfParticularFeed(feed, true);
|
m_feedsView->updateCountsOfParticularFeed(feed, true);
|
||||||
qApp->mainForm()->statusBar()->showProgress((current * 100.0) / total,
|
qApp->mainForm()->statusBar()->showProgress((current * 100.0) / total,
|
||||||
|
|
Loading…
Add table
Reference in a new issue