#include "dolphinsettings.h"
TreeViewSidebarPage::TreeViewSidebarPage(QWidget* parent) :
- SidebarPage(parent),
- m_dirLister(0),
- m_dirModel(0),
- m_proxyModel(0),
- m_treeView(0)
+ SidebarPage(parent),
+ m_dirLister(0),
+ m_dirModel(0),
+ m_proxyModel(0),
+ m_treeView(0)
{
m_dirLister = new KDirLister();
m_dirLister->setDirOnlyMode(true);
m_url = url;
// adjust the root of the tree to the base bookmark
- KFilePlacesModel *placesModel = DolphinSettings::instance().placesModel();
- const KUrl baseUrl = placesModel->url(placesModel->closestItem(url));
+ KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
+ KUrl baseUrl = placesModel->url(placesModel->closestItem(url));
+ if (!baseUrl.isValid()) {
+ // it's possible that no closest item is available and hence an
+ // empty URL is returned
+ baseUrl = url;
+ }
+
if (m_dirLister->url() != baseUrl) {
m_dirLister->stop();
m_dirLister->openUrl(baseUrl);
const QModelIndex proxyIndex = m_proxyModel->mapFromSource(index);
m_treeView->scrollTo(proxyIndex);
selModel->setCurrentIndex(proxyIndex, QItemSelectionModel::Select);
- }
- else {
+ } 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.