X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/95ac842f2973b64380a93fbe5e46e94646bf5a38..a124f2ada3bc3f36862dd2e207ceb68672610929:/src/treeviewsidebarpage.cpp diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp index d5f5f4053..6cf2ede18 100644 --- a/src/treeviewsidebarpage.cpp +++ b/src/treeviewsidebarpage.cpp @@ -19,17 +19,22 @@ #include "treeviewsidebarpage.h" +#include "dolphindropcontroller.h" #include "dolphinmodel.h" #include "dolphinsortfilterproxymodel.h" #include "dolphinview.h" #include "dolphinsettings.h" #include "dolphin_folderspanelsettings.h" +#include "dolphin_generalsettings.h" +#include "folderexpander.h" +#include "renamedialog.h" #include "sidebartreeview.h" #include "treeviewcontextmenu.h" #include #include #include +#include #include #include @@ -49,6 +54,7 @@ TreeViewSidebarPage::TreeViewSidebarPage(QWidget* parent) : m_treeView(0), m_leafDir() { + setLayoutDirection(Qt::LeftToRight); } TreeViewSidebarPage::~TreeViewSidebarPage() @@ -81,6 +87,28 @@ bool TreeViewSidebarPage::showHiddenFiles() const return FoldersPanelSettings::showHiddenFiles(); } + +void TreeViewSidebarPage::rename(const KFileItem& item) +{ + if (DolphinSettings::instance().generalSettings()->renameInline()) { + const QModelIndex dirIndex = m_dolphinModel->indexForItem(item); + const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex); + m_treeView->edit(proxyIndex); + } else { + KFileItemList items; + items.append(item); + RenameDialog dialog(this, items); + if (dialog.exec() == QDialog::Accepted) { + const QString& newName = dialog.newName(); + if (!newName.isEmpty()) { + KUrl newUrl = item.url(); + newUrl.setFileName(newName); + KonqOperations::rename(this, item.url(), newUrl); + } + } + } +} + void TreeViewSidebarPage::setUrl(const KUrl& url) { if (!url.isValid() || (url == SidebarPage::url())) { @@ -132,11 +160,13 @@ void TreeViewSidebarPage::showEvent(QShowEvent* event) m_treeView->setModel(m_proxyModel); m_proxyModel->setSorting(DolphinView::SortByName); m_proxyModel->setSortOrder(Qt::AscendingOrder); + + new FolderExpander(m_treeView, m_proxyModel); 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&))); + connect(m_treeView, SIGNAL(urlsDropped(const QModelIndex&, QDropEvent*)), + this, SLOT(dropUrls(const QModelIndex&, QDropEvent*))); connect(m_treeView, SIGNAL(pressed(const QModelIndex&)), this, SLOT(updateMouseButtons())); @@ -174,15 +204,14 @@ void TreeViewSidebarPage::updateActiveView(const QModelIndex& index) } } -void TreeViewSidebarPage::dropUrls(const KUrl::List& urls, - const QModelIndex& index) +void TreeViewSidebarPage::dropUrls(const QModelIndex& index, QDropEvent* event) { if (index.isValid()) { const QModelIndex dirIndex = m_proxyModel->mapToSource(index); KFileItem item = m_dolphinModel->itemForIndex(dirIndex); Q_ASSERT(!item.isNull()); if (item.isDir()) { - emit urlsDropped(urls, item.url()); + DolphinDropController::dropUrls(item, item.url(), event, this); } } }