diff options
| author | Peter Penz <[email protected]> | 2007-06-07 21:10:48 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2007-06-07 21:10:48 +0000 |
| commit | be9746e87bb6a42e641dbf36c528a60fb564420a (patch) | |
| tree | 678e044f977b702685aa7267957b797f623efbb3 /src/dolphinview.cpp | |
| parent | 5de9950182b5a1b0b99e4cc51e48d4d83b6bef24 (diff) | |
First big step to make it possible that the DolphinView can be embedded as KPart into Konqueror (discussed with David Faure). A lot of refactoring of the DolphinView has been done:
- The DolphinView does not contain the URL navigator, the filterbar and the statusbar anymore. Those widgets have been moved to DolphinViewContainer.
- The DolphinView does not contain any reference to the main window anymore.
Currently there are some minor regressions (the statusbar shows less informations, renaming has been deactivated), but they will get fixed during the next days. Also still a lot of interface cleanups must be done, but let's just do it step by step...
svn path=/trunk/KDE/kdebase/apps/; revision=672692
Diffstat (limited to 'src/dolphinview.cpp')
| -rw-r--r-- | src/dolphinview.cpp | 617 |
1 files changed, 178 insertions, 439 deletions
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 16f06f271..8d3bf1e2f 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -20,17 +20,17 @@ #include "dolphinview.h" -#include <QtGui/QApplication> -#include <QtGui/QClipboard> -#include <QtGui/QKeyEvent> -#include <QtGui/QItemSelection> -#include <QtGui/QBoxLayout> -#include <QtCore/QTimer> -#include <QtGui/QScrollBar> +#include <QApplication> +#include <QClipboard> +#include <QKeyEvent> +#include <QItemSelection> +#include <QBoxLayout> +#include <QTimer> +#include <QScrollBar> #include <kdirmodel.h> +#include <kdirlister.h> #include <kfileitemdelegate.h> -#include <kfileplacesmodel.h> #include <kglobalsettings.h> #include <klocale.h> #include <kiconeffect.h> @@ -44,109 +44,55 @@ #include "dolphincolumnview.h" #include "dolphincontroller.h" -#include "dolphinstatusbar.h" -#include "dolphinmainwindow.h" -#include "dolphindirlister.h" #include "dolphinsortfilterproxymodel.h" #include "dolphindetailsview.h" #include "dolphiniconsview.h" -#include "dolphincontextmenu.h" #include "dolphinitemcategorizer.h" -#include "filterbar.h" #include "renamedialog.h" -#include "kurlnavigator.h" #include "viewproperties.h" #include "dolphinsettings.h" #include "dolphin_generalsettings.h" -DolphinView::DolphinView(DolphinMainWindow* mainWindow, - QWidget* parent, +DolphinView::DolphinView(QWidget* parent, const KUrl& url, + KDirLister* dirLister, + KDirModel* dirModel, + DolphinSortFilterProxyModel* proxyModel, Mode mode, bool showHiddenFiles) : QWidget(parent), - m_showProgress(false), + m_active(true), m_blockContentsMovedSignal(false), m_initializeColumnView(false), m_mode(mode), - m_iconSize(0), - m_folderCount(0), - m_fileCount(0), - m_mainWindow(mainWindow), m_topLayout(0), - m_urlNavigator(0), m_controller(0), m_iconsView(0), m_detailsView(0), m_columnView(0), m_fileItemDelegate(0), - m_filterBar(0), - m_statusBar(0), - m_dirModel(0), - m_dirLister(0), - m_proxyModel(0) + m_dirModel(dirModel), + m_dirLister(dirLister), + m_proxyModel(proxyModel) { - hide(); setFocusPolicy(Qt::StrongFocus); m_topLayout = new QVBoxLayout(this); m_topLayout->setSpacing(0); m_topLayout->setMargin(0); - connect(m_mainWindow, SIGNAL(activeViewChanged()), - this, SLOT(updateActivationState())); - QClipboard* clipboard = QApplication::clipboard(); connect(clipboard, SIGNAL(dataChanged()), this, SLOT(updateCutItems())); - m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this); - - const GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - m_urlNavigator->setUrlEditable(settings->editableUrl()); - m_urlNavigator->setHomeUrl(settings->homeUrl()); - - connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)), - this, SLOT(changeDirectory(const KUrl&))); - connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&)), - this, SLOT(dropUrls(const KUrl::List&, const KUrl&))); - connect(m_urlNavigator, SIGNAL(activated()), - this, SLOT(requestActivation())); - connect(this, SIGNAL(contentsMoved(int, int)), - m_urlNavigator, SLOT(savePosition(int, int))); - - m_statusBar = new DolphinStatusBar(this); - - m_dirLister = new DolphinDirLister(); - m_dirLister->setAutoUpdate(true); - m_dirLister->setMainWindow(this); - m_dirLister->setShowingDotFiles(showHiddenFiles); - m_dirLister->setDelayedMimeTypes(true); - - connect(m_dirLister, SIGNAL(clear()), - this, SLOT(updateStatusBar())); - connect(m_dirLister, SIGNAL(percent(int)), - this, SLOT(updateProgress(int))); - connect(m_dirLister, SIGNAL(deleteItem(KFileItem*)), - this, SLOT(updateStatusBar())); connect(m_dirLister, SIGNAL(completed()), - this, SLOT(updateItemCount())); + this, SLOT(restoreContentsPos())); connect(m_dirLister, SIGNAL(completed()), this, SLOT(updateCutItems())); connect(m_dirLister, SIGNAL(newItems(const KFileItemList&)), this, SLOT(generatePreviews(const KFileItemList&))); - connect(m_dirLister, SIGNAL(infoMessage(const QString&)), - this, SLOT(showInfoMessage(const QString&))); - connect(m_dirLister, SIGNAL(errorMessage(const QString&)), - this, SLOT(showErrorMessage(const QString&))); - - m_dirModel = new KDirModel(); - m_dirModel->setDirLister(m_dirLister); - m_dirModel->setDropsAllowed(KDirModel::DropOnDirectory); - - m_proxyModel = new DolphinSortFilterProxyModel(this); - m_proxyModel->setSourceModel(m_dirModel); m_controller = new DolphinController(this); + m_controller->setUrl(url); connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)), this, SLOT(openContextMenu(const QPoint&))); connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const QModelIndex&, QWidget*)), @@ -158,44 +104,23 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow, connect(m_controller, SIGNAL(itemTriggered(const QModelIndex&)), this, SLOT(triggerItem(const QModelIndex&))); connect(m_controller, SIGNAL(activated()), - this, SLOT(requestActivation())); + this, SLOT(activate())); connect(m_controller, SIGNAL(itemEntered(const QModelIndex&)), this, SLOT(showHoverInformation(const QModelIndex&))); connect(m_controller, SIGNAL(viewportEntered()), this, SLOT(clearHoverInformation())); createView(); - - m_iconSize = K3Icon::SizeMedium; - - m_filterBar = new FilterBar(this); - m_filterBar->setVisible(settings->filterBar()); - connect(m_filterBar, SIGNAL(filterChanged(const QString&)), - this, SLOT(changeNameFilter(const QString&))); - connect(m_filterBar, SIGNAL(closeRequest()), - this, SLOT(closeFilterBar())); - - m_topLayout->addWidget(m_urlNavigator); m_topLayout->addWidget(itemView()); - m_topLayout->addWidget(m_filterBar); - m_topLayout->addWidget(m_statusBar); } DolphinView::~DolphinView() { - delete m_dirLister; - m_dirLister = 0; -} - -void DolphinView::setUrl(const KUrl& url) -{ - m_urlNavigator->setUrl(url); - m_controller->setUrl(url); } const KUrl& DolphinView::url() const { - return m_urlNavigator->url(); + return m_controller->url(); } KUrl DolphinView::rootUrl() const @@ -203,9 +128,37 @@ KUrl DolphinView::rootUrl() const return isColumnViewActive() ? m_dirLister->url() : url(); } +void DolphinView::setActive(bool active) +{ + if (active == m_active) { + return; + } + + m_active = active; + + QColor color = KGlobalSettings::baseColor(); + if (active) { + emit urlChanged(url()); + emit selectionChanged(selectedItems()); + } else { + color.setAlpha(0); + } + + QWidget* viewport = itemView()->viewport(); + QPalette palette; + palette.setColor(viewport->backgroundRole(), color); + viewport->setPalette(palette); + + update(); + + if (active) { + emit activated(); + } +} + bool DolphinView::isActive() const { - return m_mainWindow->activeView() == this; + return m_active; } void DolphinView::setMode(Mode mode) @@ -221,14 +174,16 @@ void DolphinView::setMode(Mode mode) // to go back to the root URL of the column view automatically. // Otherwise there it would not be possible to turn off the column view // without focusing the first column. - setUrl(m_dirLister->url()); + // TODO: reactivate again after DolphinView/DolphinViewController split works + //setUrl(m_dirLister->url()); + //m_controller->setUrl(m_dirLister->url()); } - ViewProperties props(m_urlNavigator->url()); + ViewProperties props(url()); props.setViewMode(m_mode); createView(); - startDirLister(m_urlNavigator->url()); + startDirLister(url()); emit modeChanged(); } @@ -240,13 +195,13 @@ DolphinView::Mode DolphinView::mode() const void DolphinView::setShowPreview(bool show) { - ViewProperties props(m_urlNavigator->url()); + ViewProperties props(url()); props.setShowPreview(show); m_controller->setShowPreview(show); emit showPreviewChanged(); - startDirLister(m_urlNavigator->url(), true); + startDirLister(url(), true); } bool DolphinView::showPreview() const @@ -260,13 +215,13 @@ void DolphinView::setShowHiddenFiles(bool show) return; } - ViewProperties props(m_urlNavigator->url()); + ViewProperties props(url()); props.setShowHiddenFiles(show); m_dirLister->setShowingDotFiles(show); emit showHiddenFilesChanged(); - startDirLister(m_urlNavigator->url(), true); + startDirLister(url(), true); } bool DolphinView::showHiddenFiles() const @@ -290,7 +245,7 @@ void DolphinView::setCategorizedSorting(bool categorized) delete categorizer; } - ViewProperties props(m_urlNavigator->url()); + ViewProperties props(url()); props.setCategorizedSorting(categorized); props.save(); @@ -314,7 +269,9 @@ bool DolphinView::supportsCategorizedSorting() const void DolphinView::renameSelectedItems() { - DolphinView* view = mainWindow()->activeView(); + // TODO: temporary deactivate due to DolphinView/DolphinViewController split + + /*DolphinView* view = 0; //mainWindow()->activeView(); const KUrl::List urls = selectedUrls(); if (urls.count() > 1) { // More than one item has been selected for renaming. Open @@ -379,7 +336,7 @@ void DolphinView::renameSelectedItems() newUrl.setFileName(newName); m_mainWindow->rename(oldUrl, newUrl); } - } + }*/ } void DolphinView::selectAll() @@ -392,11 +349,6 @@ void DolphinView::invertSelection() selectAll(QItemSelectionModel::Toggle); } -DolphinStatusBar* DolphinView::statusBar() const -{ - return m_statusBar; -} - int DolphinView::contentsX() const { return itemView()->horizontalScrollBar()->value(); @@ -407,16 +359,6 @@ int DolphinView::contentsY() const return itemView()->verticalScrollBar()->value(); } -bool DolphinView::isFilterBarVisible() const -{ - return m_filterBar->isVisible(); -} - -bool DolphinView::isUrlEditable() const -{ - return m_urlNavigator->isUrlEditable(); -} - void DolphinView::zoomIn() { m_controller->triggerZoomIn(); @@ -463,14 +405,14 @@ Qt::SortOrder DolphinView::sortOrder() const void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation info) { - ViewProperties props(m_urlNavigator->url()); + ViewProperties props(url()); props.setAdditionalInfo(info); m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation); m_fileItemDelegate->setAdditionalInformation(info); emit additionalInfoChanged(info); - startDirLister(m_urlNavigator->url(), true); + startDirLister(url(), true); } KFileItemDelegate::AdditionalInformation DolphinView::additionalInfo() const @@ -478,31 +420,6 @@ KFileItemDelegate::AdditionalInformation DolphinView::additionalInfo() const return m_fileItemDelegate->additionalInformation(); } -void DolphinView::goBack() -{ - m_urlNavigator->goBack(); -} - -void DolphinView::goForward() -{ - m_urlNavigator->goForward(); -} - -void DolphinView::goUp() -{ - m_urlNavigator->goUp(); -} - -void DolphinView::goHome() -{ - m_urlNavigator->goHome(); -} - -void DolphinView::setUrlEditable(bool editable) -{ - m_urlNavigator->setUrlEditable(editable); -} - bool DolphinView::hasSelection() const { return itemView()->selectionModel()->hasSelection(); @@ -571,9 +488,7 @@ void DolphinView::rename(const KUrl& source, const QString& newName) KUrl dest(source.upUrl()); dest.addPath(newName); - const bool destExists = KIO::NetAccess::exists(dest, - false, - mainWindow()->activeView()); + const bool destExists = KIO::NetAccess::exists(dest, false, this); if (destExists) { // the destination already exists, hence ask the user // how to proceed... @@ -607,21 +522,22 @@ void DolphinView::rename(const KUrl& source, const QString& newName) const QString destFileName = dest.fileName(); if (ok) { - m_statusBar->setMessage(i18n("Renamed file '%1' to '%2'.", source.fileName(), destFileName), - DolphinStatusBar::OperationCompleted); + // XYDZ + //m_statusBar->setMessage(i18n("Renamed file '%1' to '%2'.", source.fileName(), destFileName), + // DolphinStatusBar::OperationCompleted); KonqOperations::rename(this, source, destFileName); } else { - m_statusBar->setMessage(i18n("Renaming of file '%1' to '%2' failed.", source.fileName(), destFileName), - DolphinStatusBar::Error); + // XYDZ + //m_statusBar->setMessage(i18n("Renaming of file '%1' to '%2' failed.", source.fileName(), destFileName), + // DolphinStatusBar::Error); } } void DolphinView::reload() { - const KUrl& url = m_urlNavigator->url(); - changeDirectory(url); - startDirLister(url, true); + setUrl(url()); + startDirLister(url(), true); } void DolphinView::refresh() @@ -633,97 +549,11 @@ void DolphinView::refresh() void DolphinView::mouseReleaseEvent(QMouseEvent* event) { QWidget::mouseReleaseEvent(event); - mainWindow()->setActiveView(this); + setActive(true);; } - -DolphinMainWindow* DolphinView::mainWindow() const +void DolphinView::activate() { - return m_mainWindow; -} - -void DolphinView::changeDirectory(const KUrl& url) -{ - if (!isActive()) { - requestActivation(); - } - - const ViewProperties props(url); - - const Mode mode = props.viewMode(); - bool changeMode = (m_mode != mode); - if (changeMode && isColumnViewActive()) { - // The column view is active. Only change the - // mode if the current URL is no child of the column view. - if (m_dirLister->url().isParentOf(url)) { - changeMode = false; - } - } - - if (changeMode) { - m_mode = mode; - createView(); - emit modeChanged(); - - if (m_mode == ColumnView) { - // The mode has been changed to the Column View. When starting the dir - // lister with DolphinView::startDirLister() it is important to give a - // hint that the dir lister may not keep the current directory - // although this is the default for showing a hierarchy. - m_initializeColumnView = true; - } - } - - const bool showHiddenFiles = props.showHiddenFiles(); - if (showHiddenFiles != m_dirLister->showingDotFiles()) { - m_dirLister->setShowingDotFiles(showHiddenFiles); - emit showHiddenFilesChanged(); - } - - const bool categorized = props.categorizedSorting(); - if (categorized != categorizedSorting()) { - if (supportsCategorizedSorting()) { - Q_ASSERT(m_iconsView != 0); - if (categorized) { - Q_ASSERT(m_iconsView->itemCategorizer() == 0); - m_iconsView->setItemCategorizer(new DolphinItemCategorizer()); - } else { - KItemCategorizer* categorizer = m_iconsView->itemCategorizer(); - m_iconsView->setItemCategorizer(0); - delete categorizer; - } - } - emit categorizedSortingChanged(); - } - - const DolphinView::Sorting sorting = props.sorting(); - if (sorting != m_proxyModel->sorting()) { - m_proxyModel->setSorting(sorting); - emit sortingChanged(sorting); - } - - const Qt::SortOrder sortOrder = props.sortOrder(); - if (sortOrder != m_proxyModel->sortOrder()) { - m_proxyModel->setSortOrder(sortOrder); - emit sortOrderChanged(sortOrder); - } - - KFileItemDelegate::AdditionalInformation info = props.additionalInfo(); - if (info != m_fileItemDelegate->additionalInformation()) { - m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation); - m_fileItemDelegate->setAdditionalInformation(info); - emit additionalInfoChanged(info); - } - - const bool showPreview = props.showPreview(); - if (showPreview != m_controller->showPreview()) { - m_controller->setShowPreview(showPreview); - emit showPreviewChanged(); - } - - startDirLister(url); - emit urlChanged(url); - - m_statusBar->clear(); + setActive(true); } void DolphinView::triggerItem(const QModelIndex& index) @@ -782,44 +612,6 @@ void DolphinView::triggerItem(const QModelIndex& index) } } -void DolphinView::updateProgress(int percent) -{ - if (m_showProgress) { - m_statusBar->setProgress(percent); - } -} - -void DolphinView::updateItemCount() -{ - if (m_showProgress) { - m_statusBar->setProgressText(QString()); - m_statusBar->setProgress(100); - m_showProgress = false; - } - - KFileItemList items(m_dirLister->items()); - KFileItemList::const_iterator it = items.begin(); - const KFileItemList::const_iterator end = items.end(); - - m_fileCount = 0; - m_folderCount = 0; - - while (it != end) { - KFileItem* item = *it; - if (item->isDir()) { - ++m_folderCount; - } else { - ++m_fileCount; - } - ++it; - } - - updateStatusBar(); - - m_blockContentsMovedSignal = false; - QTimer::singleShot(0, this, SLOT(restoreContentsPos())); -} - void DolphinView::generatePreviews(const KFileItemList& items) { if (m_controller->showPreview()) { @@ -859,60 +651,50 @@ void DolphinView::showPreview(const KFileItem& item, const QPixmap& pixmap) void DolphinView::restoreContentsPos() { - KUrl currentUrl = m_urlNavigator->url(); - if (!currentUrl.isEmpty()) { + m_blockContentsMovedSignal = false; + if (!url().isEmpty()) { QAbstractItemView* view = itemView(); - // TODO: view->setCurrentItem(m_urlNavigator->currentFileName()); - QPoint pos = m_urlNavigator->savedPosition(); + // TODO #1: view->setCurrentItem(m_urlNavigator->currentFileName()); + // TODO #2: temporary deactivated due to DolphinView/DolphinViewController split + //QPoint pos = m_urlNavigator->savedPosition(); + QPoint pos(0, 0); view->horizontalScrollBar()->setValue(pos.x()); view->verticalScrollBar()->setValue(pos.y()); } } -void DolphinView::showInfoMessage(const QString& msg) -{ - m_statusBar->setMessage(msg, DolphinStatusBar::Information); -} - -void DolphinView::showErrorMessage(const QString& msg) -{ - m_statusBar->setMessage(msg, DolphinStatusBar::Error); -} - void DolphinView::emitSelectionChangedSignal() { emit selectionChanged(DolphinView::selectedItems()); } -void DolphinView::closeFilterBar() -{ - m_filterBar->hide(); - emit showFilterBarChanged(false); -} - void DolphinView::startDirLister(const KUrl& url, bool reload) { if (!url.isValid()) { - const QString location(url.pathOrUrl()); - if (location.isEmpty()) { - m_statusBar->setMessage(i18n("The location is empty."), DolphinStatusBar::Error); - } else { - m_statusBar->setMessage(i18n("The location '%1' is invalid.", location), - DolphinStatusBar::Error); - } + // TODO: temporary deactivated due to DolphinView/DolphinViewController split + + //const QString location(url.pathOrUrl()); + //if (location.isEmpty()) { + // m_statusBar->setMessage(i18n("The location is empty."), DolphinStatusBar::Error); + //} else { + // m_statusBar->setMessage(i18n("The location '%1' is invalid.", location), + // DolphinStatusBar::Error); + //} return; } // Only show the directory loading progress if the status bar does // not contain another progress information. This means that // the directory loading progress information has the lowest priority. - const QString progressText(m_statusBar->progressText()); - m_showProgress = progressText.isEmpty() || - (progressText == i18n("Loading folder...")); - if (m_showProgress) { - m_statusBar->setProgressText(i18n("Loading folder...")); - m_statusBar->setProgress(0); - } + + // TODO: temporary deactivated due to DolphinView/DolphinViewController split + //const QString progressText(m_statusBar->progressText()); + //m_showProgress = progressText.isEmpty() || + // (progressText == i18n("Loading folder...")); + //if (m_showProgress) { + // m_statusBar->setProgressText(i18n("Loading folder...")); + // m_statusBar->setProgress(0); + //} m_cutItemsCache.clear(); m_blockContentsMovedSignal = true; @@ -956,91 +738,92 @@ void DolphinView::startDirLister(const KUrl& url, bool reload) } } -QString DolphinView::defaultStatusBarText() const -{ - return KIO::itemsSummaryString(m_fileCount + m_folderCount, - m_fileCount, - m_folderCount, - 0, false); -} - -QString DolphinView::selectionStatusBarText() const +void DolphinView::setUrl(const KUrl& url) { - QString text; - const KFileItemList list = selectedItems(); - if (list.isEmpty()) { - // when an item is triggered, it is temporary selected but selectedItems() - // will return an empty list - return QString(); + if (m_controller->url() == url) { + return; } - int fileCount = 0; - int folderCount = 0; - KIO::filesize_t byteSize = 0; - KFileItemList::const_iterator it = list.begin(); - const KFileItemList::const_iterator end = list.end(); - while (it != end) { - KFileItem* item = *it; - if (item->isDir()) { - ++folderCount; - } else { - ++fileCount; - byteSize += item->size(); + m_controller->setUrl(url); + + const ViewProperties props(url); + + const Mode mode = props.viewMode(); + bool changeMode = (m_mode != mode); + if (changeMode && isColumnViewActive()) { + // The column view is active. Only change the + // mode if the current URL is no child of the column view. + if (m_dirLister->url().isParentOf(url)) { + changeMode = false; } - ++it; } - if (folderCount > 0) { - text = i18np("1 Folder selected", "%1 Folders selected", folderCount); - if (fileCount > 0) { - text += ", "; + if (changeMode) { + m_mode = mode; + createView(); + emit modeChanged(); + + if (m_mode == ColumnView) { + // The mode has been changed to the Column View. When starting the dir + // lister with DolphinView::startDirLister() it is important to give a + // hint that the dir lister may not keep the current directory + // although this is the default for showing a hierarchy. + m_initializeColumnView = true; } } - if (fileCount > 0) { - const QString sizeText(KIO::convertSize(byteSize)); - text += i18np("1 File selected (%2)", "%1 Files selected (%2)", fileCount, sizeText); + const bool showHiddenFiles = props.showHiddenFiles(); + if (showHiddenFiles != m_dirLister->showingDotFiles()) { + m_dirLister->setShowingDotFiles(showHiddenFiles); + emit showHiddenFilesChanged(); } - return text; -} + const bool categorized = props.categorizedSorting(); + if (categorized != categorizedSorting()) { + if (supportsCategorizedSorting()) { + Q_ASSERT(m_iconsView != 0); + if (categorized) { + Q_ASSERT(m_iconsView->itemCategorizer() == 0); + m_iconsView->setItemCategorizer(new DolphinItemCategorizer()); + } else { + KItemCategorizer* categorizer = m_iconsView->itemCategorizer(); + m_iconsView->setItemCategorizer(0); + delete categorizer; + } + } + emit categorizedSortingChanged(); + } -void DolphinView::showFilterBar(bool show) -{ - Q_ASSERT(m_filterBar != 0); - if (show) { - m_filterBar->show(); - } else { - m_filterBar->hide(); + const DolphinView::Sorting sorting = props.sorting(); + if (sorting != m_proxyModel->sorting()) { + m_proxyModel->setSorting(sorting); + emit sortingChanged(sorting); } -} -void DolphinView::updateStatusBar() -{ - // As the item count information is less important - // in comparison with other messages, it should only - // be shown if: - // - the status bar is empty or - // - shows already the item count information or - // - shows only a not very important information - // - if any progress is given don't show the item count info at all - const QString msg(m_statusBar->message()); - const bool updateStatusBarMsg = (msg.isEmpty() || - (msg == m_statusBar->defaultText()) || - (m_statusBar->type() == DolphinStatusBar::Information)) && - (m_statusBar->progress() == 100); + const Qt::SortOrder sortOrder = props.sortOrder(); + if (sortOrder != m_proxyModel->sortOrder()) { + m_proxyModel->setSortOrder(sortOrder); + emit sortOrderChanged(sortOrder); + } - const QString text(hasSelection() ? selectionStatusBarText() : defaultStatusBarText()); - m_statusBar->setDefaultText(text); + KFileItemDelegate::AdditionalInformation info = props.additionalInfo(); + if (info != m_fileItemDelegate->additionalInformation()) { + m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation); + m_fileItemDelegate->setAdditionalInformation(info); + emit additionalInfoChanged(info); + } - if (updateStatusBarMsg) { - m_statusBar->setMessage(text, DolphinStatusBar::Default); + const bool showPreview = props.showPreview(); + if (showPreview != m_controller->showPreview()) { + m_controller->setShowPreview(showPreview); + emit showPreviewChanged(); } -} -void DolphinView::requestActivation() -{ - m_mainWindow->setActiveView(this); + startDirLister(url); + emit urlChanged(url); + + // TODO: temporary deactivated due to DolphinView/DolphinViewController split + //m_statusBar->clear(); } void DolphinView::changeSelection(const KFileItemList& selection) @@ -1049,7 +832,7 @@ void DolphinView::changeSelection(const KFileItemList& selection) if (selection.isEmpty()) { return; } - KUrl baseUrl = url(); + const KUrl& baseUrl = url(); KUrl url; QItemSelection new_selection; foreach(KFileItem* item, selection) { @@ -1064,31 +847,6 @@ void DolphinView::changeSelection(const KFileItemList& selection) | QItemSelectionModel::Current); } -void DolphinView::changeNameFilter(const QString& nameFilter) -{ - // The name filter of KDirLister does a 'hard' filtering, which - // means that only the items are shown where the names match - // exactly the filter. This is non-transparent for the user, which - // just wants to have a 'soft' filtering: does the name contain - // the filter string? - QString adjustedFilter(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 -} - void DolphinView::openContextMenu(const QPoint& pos) { KFileItem* item = 0; @@ -1098,8 +856,7 @@ void DolphinView::openContextMenu(const QPoint& pos) item = fileItem(index); } - DolphinContextMenu contextMenu(m_mainWindow, item, url()); - contextMenu.open(); + emit requestContextMenu(item, url()); } void DolphinView::dropUrls(const KUrl::List& urls, @@ -1122,15 +879,15 @@ void DolphinView::dropUrls(const KUrl::List& urls, return; } - const KUrl& destination = (directory == 0) ? url() : - directory->url(); + const KUrl& destination = (directory == 0) ? + url() : directory->url(); dropUrls(urls, destination); } void DolphinView::dropUrls(const KUrl::List& urls, const KUrl& destination) { - m_mainWindow->dropUrls(urls, destination); + emit urlsDropped(urls, destination); } void DolphinView::updateSorting(DolphinView::Sorting sorting) @@ -1160,26 +917,6 @@ void DolphinView::emitContentsMoved() } } -void DolphinView::updateActivationState() -{ - m_urlNavigator->setActive(isActive()); - - QColor color = KGlobalSettings::baseColor(); - if (isActive()) { - emit urlChanged(url()); - emit selectionChanged(selectedItems()); - } else { - color.setAlpha(0); - } - - QWidget* viewport = itemView()->viewport(); - QPalette palette; - palette.setColor(viewport->backgroundRole(), color); - viewport->setPalette(palette); - - update(); -} - void DolphinView::updateCutItems() { // restore the icons of all previously selected items to the @@ -1207,14 +944,16 @@ void DolphinView::showHoverInformation(const QModelIndex& index) const KFileItem* item = fileItem(index); if (item != 0) { - m_statusBar->setMessage(item->getStatusBarInfo(), DolphinStatusBar::Default); + // TODO: temporary deactivated due to DolphinView/DolphinViewController split + //m_statusBar->setMessage(item->getStatusBarInfo(), DolphinStatusBar::Default); emit requestItemInfo(item->url()); } } void DolphinView::clearHoverInformation() { - m_statusBar->clear(); + // TODO: temporary deactivated due to DolphinView/DolphinViewController split + //m_statusBar->clear(); emit requestItemInfo(KUrl()); } |
