#include "search/dolphinsearchbox.h"
#include "statusbar/dolphinstatusbar.h"
#include "views/dolphinplacesmodel.h"
+#include "views/draganddrophelper.h"
#include "views/viewmodecontroller.h"
#include "views/viewproperties.h"
connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
m_view = new DolphinView(url, this);
- 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(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(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(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(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(directoryLoadingStarted()), this, SLOT(slotDirectoryLoadingStarted()));
+ connect(m_view, SIGNAL(directoryLoadingCompleted()), this, SLOT(slotDirectoryLoadingCompleted()));
+ connect(m_view, SIGNAL(itemCountChanged()), this, SLOT(delayedStatusBarUpdate()));
+ connect(m_view, SIGNAL(directoryLoadingProgress(int)), this, SLOT(updateDirectoryLoadingProgress(int)));
+ connect(m_view, SIGNAL(directorySortingProgress(int)), this, SLOT(updateDirectorySortingProgress(int)));
+ connect(m_view, SIGNAL(infoMessage(QString)), this, SLOT(showInfoMessage(QString)));
+ connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString)));
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)));
return m_searchBox;
}
-void DolphinViewContainer::refresh()
+void DolphinViewContainer::readSettings()
{
if (GeneralSettings::modifiedStartupSettings()) {
// The startup settings should only get applied if they have been
// settings of the URL navigator and the filterbar.
m_urlNavigator->setUrlEditable(GeneralSettings::editableUrl());
m_urlNavigator->setShowFullPath(GeneralSettings::showFullPath());
+ m_urlNavigator->setHomeUrl(KUrl(GeneralSettings::homeUrl()));
setFilterBarVisible(GeneralSettings::filterBar());
}
- m_view->refresh();
- m_statusBar->refresh();
+ m_view->readSettings();
+ m_statusBar->readSettings();
}
bool DolphinViewContainer::isFilterBarVisible() const
}
}
-void DolphinViewContainer::updateProgress(int percent)
+void DolphinViewContainer::updateDirectoryLoadingProgress(int percent)
{
if (m_statusBar->progressText().isEmpty()) {
m_statusBar->setProgressText(i18nc("@info:progress", "Loading folder..."));
m_statusBar->setProgress(percent);
}
-void DolphinViewContainer::slotStartedPathLoading()
+void DolphinViewContainer::updateDirectorySortingProgress(int percent)
+{
+ if (m_statusBar->progressText().isEmpty()) {
+ m_statusBar->setProgressText(i18nc("@info:progress", "Sorting..."));
+ }
+ m_statusBar->setProgress(percent);
+}
+
+void DolphinViewContainer::slotDirectoryLoadingStarted()
{
if (isSearchUrl(url())) {
// Search KIO-slaves usually don't provide any progress information. Give
// Trigger an undetermined progress indication. The progress
// information in percent will be triggered by the percent() signal
// of the directory lister later.
- updateProgress(-1);
+ updateDirectoryLoadingProgress(-1);
}
}
-void DolphinViewContainer::slotFinishedPathLoading()
+void DolphinViewContainer::slotDirectoryLoadingCompleted()
{
if (!m_statusBar->progressText().isEmpty()) {
m_statusBar->setProgressText(QString());
m_statusBar->setProgress(100);
}
- if (isSearchUrl(url()) && m_view->items().isEmpty()) {
+ if (isSearchUrl(url()) && m_view->itemsCount() == 0) {
// The dir lister has been completed on a Nepomuk-URI and no items have been found. Instead
// of showing the default status bar information ("0 items") a more helpful information is given:
m_statusBar->setMessage(i18nc("@info:status", "No items found."), DolphinStatusBar::Information);
void DolphinViewContainer::slotItemActivated(const KFileItem& item)
{
+ // It is possible to activate items on inactive views by
+ // drag & drop operations. Assure that activating an item always
+ // results in an active view.
+ m_view->setActive(true);
+
KUrl url = item.targetUrl();
if (item.isDir()) {
item.run();
}
-void DolphinViewContainer::openFile(const KUrl& url)
-{
- const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
- slotItemActivated(item);
-}
-
void DolphinViewContainer::showItemInfo(const KFileItem& item)
{
if (item.isNull()) {
m_statusBar->clear();
}
} else {
- QString message;
- if (item.isDir()) {
- message = item.text();
- } else {
- message = i18nc("@info:status filename (type)", "%1 (%2)", item.text(), item.mimeComment());
- }
+ const QString message = item.isDir() ? item.text() : item.getStatusBarInfo();
m_statusBar->setMessage(message, DolphinStatusBar::Default);
}
}
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
{
- Q_UNUSED(destination);
- Q_UNUSED(event);
- //DragAndDropHelper::instance().dropUrls(KFileItem(), destination, event, this);
+ DragAndDropHelper::dropUrls(KFileItem(), destination, event);
}
void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)