#include <kdirmodel.h>
#include <kfileitem.h>
-#include <QHeaderView>
-#include <QItemSelectionModel>
-#include <QTreeView>
-#include <QVBoxLayout>
+#include <QtGui/QHeaderView>
+#include <QtGui/QItemSelection>
+#include <QtGui/QTreeView>
+#include <QtGui/QBoxLayout>
TreeViewSidebarPage::TreeViewSidebarPage(QWidget* parent) :
SidebarPage(parent),
m_dirLister = 0;
}
+QSize TreeViewSidebarPage::sizeHint() const
+{
+ QSize size = SidebarPage::sizeHint();
+ size.setWidth(200);
+ return size;
+}
+
void TreeViewSidebarPage::setUrl(const KUrl& url)
{
if (!url.isValid() || (url == SidebarPage::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
m_dirLister->setAutoErrorHandlingEnabled(false, this);
Q_ASSERT(m_dirModel == 0);
- m_dirModel = new KDirModel();
+ m_dirModel = new KDirModel(this);
m_dirModel->setDirLister(m_dirLister);
m_dirModel->setDropsAllowed(KDirModel::DropOnDirectory);
}
const QModelIndex dirModelIndex = m_proxyModel->mapToSource(index);
- KFileItem* item = m_dirModel->itemForIndex(dirModelIndex);
+ KFileItem item = m_dirModel->itemForIndex(dirModelIndex);
- emit changeSelection(KFileItemList());
+ emit changeSelection(QList<KFileItem>());
TreeViewContextMenu contextMenu(this, item);
contextMenu.open();
}
void TreeViewSidebarPage::updateActiveView(const QModelIndex& index)
{
const QModelIndex dirIndex = m_proxyModel->mapToSource(index);
- const KFileItem* item = m_dirModel->itemForIndex(dirIndex);
- if (item != 0) {
- const KUrl& url = item->url();
- emit changeUrl(url);
+ const KFileItem item = m_dirModel->itemForIndex(dirIndex);
+ if (!item.isNull()) {
+ emit changeUrl(item.url());
}
}
{
if (index.isValid()) {
const QModelIndex dirIndex = m_proxyModel->mapToSource(index);
- KFileItem* item = m_dirModel->itemForIndex(dirIndex);
- Q_ASSERT(item != 0);
- if (item->isDir()) {
- emit urlsDropped(urls, item->url());
+ KFileItem item = m_dirModel->itemForIndex(dirIndex);
+ Q_ASSERT(!item.isNull());
+ if (item.isDir()) {
+ emit urlsDropped(urls, item.url());
}
}
}
{
Q_ASSERT(m_dirLister != 0);
- // adjust the root of the tree to the base bookmark
+ // adjust the root of the tree to the base place
KFilePlacesModel* placesModel = DolphinSettings::instance().placesModel();
KUrl baseUrl = placesModel->url(placesModel->closestItem(url));
if (!baseUrl.isValid()) {