+}
+
+TreeViewSidebarPage::~TreeViewSidebarPage()
+{
+ delete m_dirLister;
+ m_dirLister = 0;
+}
+
+QSize TreeViewSidebarPage::sizeHint() const
+{
+ return QSize(200, 400);
+}
+
+void TreeViewSidebarPage::setUrl(const KUrl& url)
+{
+ if (!url.isValid() || (url == SidebarPage::url())) {
+ return;
+ }
+
+ SidebarPage::setUrl(url);
+ if (m_dirLister != 0) {
+ loadTree(url);
+ }
+}
+
+void TreeViewSidebarPage::showEvent(QShowEvent* event)
+{
+ if (event->spontaneous()) {
+ SidebarPage::showEvent(event);
+ return;
+ }
+
+ if (m_dirLister == 0) {
+ // Postpone the creating of the dir lister to the first show event.
+ // This assures that no performance and memory overhead is given when the TreeView is not
+ // used at all (see TreeViewSidebarPage::setUrl()).
+ m_dirLister = new KDirLister();
+ m_dirLister->setDirOnlyMode(true);
+ m_dirLister->setAutoUpdate(true);
+ m_dirLister->setMainWindow(this);
+ m_dirLister->setDelayedMimeTypes(true);
+ m_dirLister->setAutoErrorHandlingEnabled(false, this);
+
+ connect(m_dirLister, SIGNAL(completed()),
+ this, SLOT(triggerLoadSubTree()));
+
+ Q_ASSERT(m_dolphinModel == 0);
+ m_dolphinModel = new DolphinModel(this);
+ m_dolphinModel->setDirLister(m_dirLister);
+ m_dolphinModel->setDropsAllowed(DolphinModel::DropOnDirectory);
+ connect(m_dolphinModel, SIGNAL(expand(const QModelIndex&)),
+ this, SLOT(triggerExpanding()));
+
+ Q_ASSERT(m_proxyModel == 0);
+ m_proxyModel = new DolphinSortFilterProxyModel(this);
+ m_proxyModel->setSourceModel(m_dolphinModel);
+
+ Q_ASSERT(m_treeView == 0);
+ m_treeView = new SidebarTreeView(this);
+ m_treeView->setModel(m_proxyModel);
+ m_proxyModel->setSorting(DolphinView::SortByName);
+ m_proxyModel->setSortOrder(Qt::AscendingOrder);
+
+ connect(m_treeView, SIGNAL(clicked(const QModelIndex&)),
+ this, SLOT(updateActiveView(const QModelIndex&)));
+ connect(m_treeView, SIGNAL(urlsDropped(const KUrl::List&, const QModelIndex&)),
+ this, SLOT(dropUrls(const KUrl::List&, const QModelIndex&)));
+
+ QVBoxLayout* layout = new QVBoxLayout(this);
+ layout->setMargin(0);
+ layout->addWidget(m_treeView);
+ }
+
+ loadTree(url());
+ SidebarPage::showEvent(event);
+}