+ selModel->setCurrentIndex(index, QItemSelectionModel::Select);
+ }
+ else {
+ // The item with the given URL is not loaded by the model yet. Iterate
+ // backward to the base URL and trigger the loading of the items for
+ // each hierarchy level.
+ connect(m_dirLister, SIGNAL(completed()),
+ this, SLOT(expandSelectionParent()));
+
+ KUrl parentUrl = url.upUrl();
+ while (parentUrl != baseUrl) {
+ m_dirLister->openUrl(parentUrl, true, false);
+ parentUrl = parentUrl.upUrl();
+ }
+ }
+}
+
+void TreeViewSidebarPage::expandSelectionParent()
+{
+ disconnect(m_dirLister, SIGNAL(completed()),
+ this, SLOT(expandSelectionParent()));
+
+ // expand the parent folder of the selected item
+ KFileItem parentItem(S_IFDIR, KFileItem::Unknown, m_selectedUrl.upUrl());
+ QModelIndex index = m_dirModel->indexForItem(parentItem);
+ if (index.isValid()) {