X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/f23e9496f303995557b744c03178f5dbd9b35016..c8d8556950005dfd96ebdb41d2f43ad90356367c:/src/dolphinviewcontainer.cpp diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 8e00b0afc..df5fe6b15 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -30,12 +30,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -49,8 +47,9 @@ #include "dolphinmainwindow.h" #include "filterbar/filterbar.h" #include "search/dolphinsearchbox.h" -#include "settings/dolphinsettings.h" #include "statusbar/dolphinstatusbar.h" +#include "views/dolphinplacesmodel.h" +#include "views/draganddrophelper.h" #include "views/viewmodecontroller.h" #include "views/viewproperties.h" @@ -71,15 +70,15 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : m_topLayout->setSpacing(0); m_topLayout->setMargin(0); - m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this); - connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl&, QDropEvent*)), - this, SLOT(dropUrls(const KUrl&, QDropEvent*))); + m_urlNavigator = new KUrlNavigator(DolphinPlacesModel::instance(), url, this); + connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)), + this, SLOT(dropUrls(KUrl,QDropEvent*))); connect(m_urlNavigator, SIGNAL(activated()), this, SLOT(activate())); connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)), this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion))); - const GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + const GeneralSettings* settings = GeneralSettings::self(); m_urlNavigator->setUrlEditable(settings->editableUrl()); m_urlNavigator->setShowFullPath(settings->showFullPath()); m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl())); @@ -93,28 +92,28 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus())); m_view = new DolphinView(url, this); - connect(m_view, SIGNAL(urlChanged(const KUrl&)), m_urlNavigator, SLOT(setUrl(const KUrl&))); + connect(m_view, SIGNAL(urlChanged(KUrl)), m_urlNavigator, SLOT(setUrl(KUrl))); connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool))); connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem))); - connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); - connect(m_view, SIGNAL(infoMessage(const QString&)), this, SLOT(showInfoMessage(const QString&))); - connect(m_view, SIGNAL(itemTriggered(KFileItem)), this, SLOT(slotItemTriggered(KFileItem))); - connect(m_view, SIGNAL(redirection(KUrl, KUrl)), this, SLOT(redirect(KUrl, KUrl))); + connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); + connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(showInfoMessage(QString))); + connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem))); + connect(m_view, SIGNAL(redirection(KUrl,KUrl)), this, SLOT(redirect(KUrl,KUrl))); connect(m_view, SIGNAL(startedPathLoading(KUrl)), this, SLOT(slotStartedPathLoading())); connect(m_view, SIGNAL(finishedPathLoading(KUrl)), this, SLOT(slotFinishedPathLoading())); connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate())); connect(m_view, SIGNAL(pathLoadingProgress(int)), this, SLOT(updateProgress(int))); - connect(m_view, SIGNAL(infoMessage(const QString&)), this, SLOT(showInfoMessage(const QString&))); - connect(m_view, SIGNAL(errorMessage(const QString&)), this, SLOT(showErrorMessage(const QString&))); - connect(m_view, SIGNAL(urlIsFileError(const KUrl&)), this, SLOT(openFile(const KUrl&))); - connect(m_view, SIGNAL(selectionChanged(const KFileItemList&)), this, SLOT(delayedStatusBarUpdate())); - connect(m_view, SIGNAL(operationCompletedMessage(const QString&)), this, SLOT(showOperationCompletedMessage(const QString&))); - connect(m_view, SIGNAL(urlAboutToBeChanged(const KUrl&)), this, SLOT(slotViewUrlAboutToBeChanged(const KUrl&))); - - connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(const KUrl&)), - this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(const KUrl&))); - connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)), - this, SLOT(slotUrlNavigatorLocationChanged(const KUrl&))); + connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(showInfoMessage(QString))); + connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString))); + connect(m_view, SIGNAL(urlIsFileError(KUrl)), this, SLOT(openFile(KUrl))); + connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate())); + connect(m_view, SIGNAL(operationCompletedMessage(QString)), this, SLOT(showOperationCompletedMessage(QString))); + connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(KUrl))); + + connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)), + this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl))); + connect(m_urlNavigator, SIGNAL(urlChanged(KUrl)), + this, SLOT(slotUrlNavigatorLocationChanged(KUrl))); connect(m_urlNavigator, SIGNAL(historyChanged()), this, SLOT(slotHistoryChanged())); @@ -135,11 +134,11 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) : // initialize filter bar m_filterBar = new FilterBar(this); m_filterBar->setVisible(settings->filterBar()); - connect(m_filterBar, SIGNAL(filterChanged(const QString&)), - this, SLOT(setNameFilter(const QString&))); + connect(m_filterBar, SIGNAL(filterChanged(QString)), + this, SLOT(setNameFilter(QString))); connect(m_filterBar, SIGNAL(closeRequest()), this, SLOT(closeFilterBar())); - connect(m_view, SIGNAL(urlChanged(const KUrl&)), + connect(m_view, SIGNAL(urlChanged(KUrl)), m_filterBar, SLOT(clear())); m_topLayout->addWidget(m_urlNavigator); @@ -214,14 +213,13 @@ DolphinSearchBox* DolphinViewContainer::searchBox() void DolphinViewContainer::refresh() { - GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - if (settings->modifiedStartupSettings()) { + if (GeneralSettings::modifiedStartupSettings()) { // The startup settings should only get applied if they have been // modified by the user. Otherwise keep the (possibly) different current // settings of the URL navigator and the filterbar. - m_urlNavigator->setUrlEditable(settings->editableUrl()); - m_urlNavigator->setShowFullPath(settings->showFullPath()); - setFilterBarVisible(settings->filterBar()); + m_urlNavigator->setUrlEditable(GeneralSettings::editableUrl()); + m_urlNavigator->setShowFullPath(GeneralSettings::showFullPath()); + setFilterBarVisible(GeneralSettings::filterBar()); } m_view->refresh(); @@ -373,7 +371,7 @@ void DolphinViewContainer::slotFinishedPathLoading() } } -void DolphinViewContainer::slotItemTriggered(const KFileItem& item) +void DolphinViewContainer::slotItemActivated(const KFileItem& item) { KUrl url = item.targetUrl(); @@ -382,9 +380,7 @@ void DolphinViewContainer::slotItemTriggered(const KFileItem& item) return; } - const GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - const bool browseThroughArchives = settings->browseThroughArchives(); - if (browseThroughArchives && item.isFile() && url.isLocalFile()) { + if (GeneralSettings::browseThroughArchives() && item.isFile() && url.isLocalFile()) { // Generic mechanism for redirecting to tar:// when clicking on a tar file, // zip:// when clicking on a zip file, etc. // The .protocol file specifies the mimetype that the kioslave handles. @@ -414,7 +410,7 @@ void DolphinViewContainer::slotItemTriggered(const KFileItem& item) void DolphinViewContainer::openFile(const KUrl& url) { const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url); - slotItemTriggered(item); + slotItemActivated(item); } void DolphinViewContainer::showItemInfo(const KFileItem& item) @@ -428,7 +424,13 @@ void DolphinViewContainer::showItemInfo(const KFileItem& item) m_statusBar->clear(); } } else { - m_statusBar->setMessage(item.getStatusBarInfo(), DolphinStatusBar::Default); + QString message; + if (item.isDir()) { + message = item.text(); + } else { + message = i18nc("@info:status filename (type)", "%1 (%2)", item.text(), item.mimeComment()); + } + m_statusBar->setMessage(message, DolphinStatusBar::Default); } } @@ -531,9 +533,8 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url) void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event) { - Q_UNUSED(destination); - Q_UNUSED(event); - //DragAndDropHelper::instance().dropUrls(KFileItem(), destination, event, this); + const KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, destination); + DragAndDropHelper::dropUrls(destItem, event); } void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl) @@ -559,9 +560,7 @@ void DolphinViewContainer::requestFocus() void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion) { - DolphinSettings& settings = DolphinSettings::instance(); - settings.generalSettings()->setUrlCompletionMode(completion); - settings.save(); + GeneralSettings::setUrlCompletionMode(completion); } void DolphinViewContainer::slotHistoryChanged()