#include <KRun>
#include "dolphin_generalsettings.h"
-#include "dolphinmainwindow.h"
#include "filterbar/filterbar.h"
#include "search/dolphinsearchbox.h"
#include "statusbar/dolphinstatusbar.h"
-#include "views/dolphinplacesmodel.h"
#include "views/draganddrophelper.h"
#include "views/viewmodecontroller.h"
#include "views/viewproperties.h"
m_filterBar(0),
m_statusBar(0),
m_statusBarTimer(0),
- m_statusBarTimestamp()
+ m_statusBarTimestamp(),
+ m_autoGrabFocus(true)
{
hide();
m_topLayout->setSpacing(0);
m_topLayout->setMargin(0);
- m_urlNavigator = new KUrlNavigator(DolphinPlacesModel::instance(), url, this);
+ m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)),
this, SLOT(dropUrls(KUrl,QDropEvent*)));
connect(m_urlNavigator, SIGNAL(activated()),
m_searchBox = new DolphinSearchBox(this);
m_searchBox->hide();
connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
- connect(m_searchBox, SIGNAL(search(QString)), this, SLOT(startSearching(QString)));
+ connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
m_messageWidget = new KMessageWidget(this);
connect(m_view, SIGNAL(selectionChanged(KFileItemList)), this, SLOT(delayedStatusBarUpdate()));
connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)), this, SLOT(slotViewUrlAboutToBeChanged(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(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString)));
connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(KUrl)),
this, SLOT(slotUrlNavigatorLocationAboutToBeChanged(KUrl)));
m_statusBar = new DolphinStatusBar(this);
m_statusBar->setUrl(m_view->url());
m_statusBar->setZoomLevel(m_view->zoomLevel());
- connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl)));
- connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int)));
- connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading()));
- connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int)));
+ connect(m_view, SIGNAL(urlChanged(KUrl)), m_statusBar, SLOT(setUrl(KUrl)));
+ connect(m_view, SIGNAL(zoomLevelChanged(int,int)), m_statusBar, SLOT(setZoomLevel(int)));
+ connect(m_view, SIGNAL(infoMessage(QString)), m_statusBar, SLOT(setText(QString)));
+ connect(m_view, SIGNAL(operationCompletedMessage(QString)), m_statusBar, SLOT(setText(QString)));
+ connect(m_statusBar, SIGNAL(stopPressed()), this, SLOT(stopDirectoryLoading()));
+ connect(m_statusBar, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotStatusBarZoomLevelChanged(int)));
m_statusBarTimer = new QTimer(this);
m_statusBarTimer->setSingleShot(true);
return m_view->isActive();
}
+void DolphinViewContainer::setAutoGrabFocus(bool grab)
+{
+ m_autoGrabFocus = grab;
+}
+
+bool DolphinViewContainer::autoGrabFocus() const
+{
+ return m_autoGrabFocus;
+}
+
const DolphinStatusBar* DolphinViewContainer::statusBar() const
{
return m_statusBar;
return m_view;
}
-const DolphinSearchBox* DolphinViewContainer::searchBox() const
-{
- return m_searchBox;
-}
-
-DolphinSearchBox* DolphinViewContainer::searchBox()
-{
- return m_searchBox;
-}
-
void DolphinViewContainer::showMessage(const QString& msg, MessageType type)
{
if (msg.isEmpty()) {
m_searchBox->setSearchPath(url);
}
} else {
+ m_view->setViewPropertiesContext(QString());
+
// Restore the URL for the URL navigator. If Dolphin has been
// started with a search-URL, the home URL is used as fallback.
const KUrl url = m_searchBox->searchPath();
}
}
}
-
- emit searchModeChanged(enabled);
}
bool DolphinViewContainer::isSearchModeEnabled() const
return m_searchBox->isVisible();
}
+QString DolphinViewContainer::placesText() const
+{
+ QString text;
+
+ if (isSearchModeEnabled()) {
+ text = m_searchBox->searchPath().fileName() + QLatin1String(": ") + m_searchBox->text();
+ } else {
+ text = url().fileName();
+ if (text.isEmpty()) {
+ text = url().host();
+ }
+ }
+
+ return text;
+}
+
void DolphinViewContainer::setUrl(const KUrl& newUrl)
{
if (newUrl != m_urlNavigator->locationUrl()) {
setSearchModeEnabled(isSearchUrl(url));
m_view->setUrl(url);
- if (isActive() && !isSearchUrl(url)) {
+ if (m_autoGrabFocus && isActive() && !isSearchUrl(url)) {
// When an URL has been entered, the view should get the focus.
// The focus must be requested asynchronously, as changing the URL might create
// a new view widget.
}
}
-void DolphinViewContainer::startSearching(const QString &text)
+void DolphinViewContainer::startSearching()
{
- Q_UNUSED(text);
const KUrl url = m_searchBox->urlForSearching();
if (url.isValid() && !url.isEmpty()) {
+ m_view->setViewPropertiesContext("search");
m_urlNavigator->setLocationUrl(url);
}
}
showMessage(msg, Error);
}
-void DolphinViewContainer::showInfoMessage(const QString& msg)
-{
- showMessage(msg, Information);
-}
-
bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
{
const QString protocol = url.protocol();