X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/9c7ccd477a32ad52ff0126024ffbad0f6ea164b5..093efca22dfd247f06e2a669ad968300e71ef08d:/src/dolphinviewcontainer.cpp diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 514e9e7b3..a2902afd7 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -41,6 +40,7 @@ #include #include +#include "dolphinmodel.h" #include "dolphincolumnview.h" #include "dolphincontroller.h" #include "dolphinstatusbar.h" @@ -50,7 +50,6 @@ #include "dolphindetailsview.h" #include "dolphiniconsview.h" #include "dolphincontextmenu.h" -#include "dolphinitemcategorizer.h" #include "filterbar.h" #include "renamedialog.h" #include "kurlnavigator.h" @@ -71,7 +70,6 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, m_view(0), m_filterBar(0), m_statusBar(0), - m_dirModel(0), m_dirLister(0), m_proxyModel(0) { @@ -81,10 +79,6 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, m_topLayout->setSpacing(0); m_topLayout->setMargin(0); - QClipboard* clipboard = QApplication::clipboard(); - connect(clipboard, SIGNAL(dataChanged()), - this, SLOT(updateCutItems())); - m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this); connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&)), m_mainWindow, SLOT(dropUrls(const KUrl::List&, const KUrl&))); @@ -100,12 +94,13 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, m_dirLister->setMainWindow(this); m_dirLister->setDelayedMimeTypes(true); - m_dirModel = new KDirModel(); - m_dirModel->setDirLister(m_dirLister); - m_dirModel->setDropsAllowed(KDirModel::DropOnDirectory); + m_dolphinModel = new DolphinModel(); + m_dolphinModel->setDirLister(m_dirLister); + m_dolphinModel->setDropsAllowed(DolphinModel::DropOnDirectory); + m_proxyModel = new DolphinSortFilterProxyModel(this); - m_proxyModel->setSourceModel(m_dirModel); + m_proxyModel->setSourceModel(m_dolphinModel); connect(m_dirLister, SIGNAL(clear()), this, SLOT(updateStatusBar())); @@ -123,7 +118,7 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, m_view = new DolphinView(this, url, m_dirLister, - m_dirModel, + m_dolphinModel, m_proxyModel); connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_urlNavigator, SLOT(setUrl(const KUrl&))); @@ -141,9 +136,11 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, this, SLOT(showInfoMessage(const QString&))); connect(m_view, SIGNAL(itemTriggered(KFileItem)), this, SLOT(slotItemTriggered(KFileItem))); + connect(m_view, SIGNAL(startedPathLoading(const KUrl&)), + this, SLOT(saveRootUrl(const KUrl&))); connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)), - m_view, SLOT(setUrl(const KUrl&))); + this, SLOT(restoreView(const KUrl&))); m_statusBar = new DolphinStatusBar(this, url); connect(m_view, SIGNAL(urlChanged(const KUrl&)), @@ -272,8 +269,8 @@ bool DolphinViewContainer::isUrlEditable() const KFileItem DolphinViewContainer::fileItem(const QModelIndex& index) const { - const QModelIndex dirModelIndex = m_proxyModel->mapToSource(index); - return m_dirModel->itemForIndex(dirModelIndex); + const QModelIndex dolphinModelIndex = m_proxyModel->mapToSource(index); + return m_dolphinModel->itemForIndex(dolphinModelIndex); } void DolphinViewContainer::updateProgress(int percent) @@ -353,6 +350,21 @@ void DolphinViewContainer::closeFilterBar() QString DolphinViewContainer::defaultStatusBarText() const { + int m_fileCount = 0; + int m_folderCount = 0; + + for (int i = 0; i < m_proxyModel->rowCount(); i++) + { + if (m_dolphinModel->itemForIndex(m_proxyModel->mapToSource(m_proxyModel->index(i, m_proxyModel->sortColumn()))).isDir()) + { + m_folderCount++; + } + else + { + m_fileCount++; + } + } + return KIO::itemsSummaryString(m_fileCount + m_folderCount, m_fileCount, m_folderCount, @@ -440,18 +452,10 @@ void DolphinViewContainer::changeNameFilter(const QString& nameFilter) adjustedFilter.insert(0, '*'); adjustedFilter.append('*'); - // Use the ProxyModel to filter: - // This code is #ifdefed as setNameFilter behaves - // slightly different than the QSortFilterProxyModel - // as it will not remove directories. I will ask - // our beloved usability experts for input - // -- z. -#if 0 m_dirLister->setNameFilter(adjustedFilter); m_dirLister->emitChanges(); -#else - m_proxyModel->setFilterRegExp(nameFilter); -#endif + + updateStatusBar(); } void DolphinViewContainer::openContextMenu(const KFileItem& item, @@ -479,6 +483,17 @@ void DolphinViewContainer::activate() setActive(true); } +void DolphinViewContainer::restoreView(const KUrl& url) +{ + m_view->updateView(url, m_urlNavigator->savedRootUrl()); +} + +void DolphinViewContainer::saveRootUrl(const KUrl& url) +{ + Q_UNUSED(url); + m_urlNavigator->saveRootUrl(m_view->rootUrl()); +} + void DolphinViewContainer::slotItemTriggered(const KFileItem& item) { // Prefer the local path over the URL.