m_statusBar(0),
m_statusBarTimer(0),
m_statusBarTimestamp(),
- m_autoGrabFocus(true)
+ m_autoGrabFocus(true),
+ m_dropDestination(),
+ m_dropEvent(0)
#ifdef KActivities_FOUND
, m_activityResourceInstance(0)
#endif
m_searchBox = new DolphinSearchBox(this);
m_searchBox->hide();
+ connect(m_searchBox, SIGNAL(activated()), this, SLOT(activate()));
connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
connect(m_searchBox, SIGNAL(searchRequest()), this, SLOT(startSearching()));
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(urlChanged(KUrl)), m_messageWidget, SLOT(hide()));
connect(m_view, SIGNAL(writeStateChanged(bool)), this, SIGNAL(writeStateChanged(bool)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(showItemInfo(KFileItem)));
connect(m_view, SIGNAL(itemActivated(KFileItem)), this, SLOT(slotItemActivated(KFileItem)));
connect(m_filterBar, SIGNAL(focusViewRequest()),
this, SLOT(requestFocus()));
connect(m_view, SIGNAL(urlChanged(KUrl)),
- m_filterBar, SLOT(clear()));
+ m_filterBar, SLOT(slotUrlChanged()));
m_topLayout->addWidget(m_urlNavigator);
m_topLayout->addWidget(m_searchBox);
void DolphinViewContainer::setActive(bool active)
{
+ m_searchBox->setActive(active);
m_urlNavigator->setActive(active);
m_view->setActive(active);
}
if (isSearchUrl(url()) && m_view->itemsCount() == 0) {
- // The dir lister has been completed on a Nepomuk-URI and no items have been found. Instead
+ // The dir lister has been completed on a Baloo-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->setText(i18nc("@info:status", "No items found."));
} else {
// results in an active view.
m_view->setActive(true);
- KUrl url = item.targetUrl();
-
- if (item.isDir()) {
+ const KUrl& url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
+ if (!url.isEmpty()) {
m_view->setUrl(url);
return;
}
- if (GeneralSettings::browseThroughArchives() && item.isFile() && url.isLocalFile()) {
- // Generic mechanism for redirecting to tar:/<path>/ when clicking on a tar file,
- // zip:/<path>/ when clicking on a zip file, etc.
- // The .protocol file specifies the mimetype that the kioslave handles.
- // Note that we don't use mimetype inheritance since we don't want to
- // open OpenDocument files as zip folders...
- const QString protocol = KProtocolManager::protocolForArchiveMimetype(item.mimetype());
- if (!protocol.isEmpty()) {
- url.setProtocol(protocol);
- m_view->setUrl(url);
- return;
- }
- }
-
- if (item.mimetype() == QLatin1String("application/x-desktop")) {
- // Redirect to the URL in Type=Link desktop files
- KDesktopFile desktopFile(url.toLocalFile());
- if (desktopFile.hasLinkType()) {
- url = desktopFile.readUrl();
- m_view->setUrl(url);
- return;
- }
- }
-
item.run();
}
if (item.isNull()) {
m_statusBar->resetToDefaultText();
} else {
- const QString text = item.isDir() ? item.text() : item.getStatusBarInfo();
- m_statusBar->setText(text);
+ m_statusBar->setText(item.getStatusBarInfo());
}
}
void DolphinViewContainer::closeFilterBar()
{
- m_filterBar->hide();
- m_filterBar->clear();
+ m_filterBar->closeFilterBar();
m_view->setFocus();
emit showFilterBarChanged(false);
}
void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
{
+ m_dropDestination = destination;
+
+ const QMimeData* mimeData = event->mimeData();
+ QMimeData* mimeDataCopy = new QMimeData;
+ foreach (const QString& format, mimeData->formats()) {
+ mimeDataCopy->setData(format, mimeData->data(format));
+ }
+
+ m_dropEvent.reset(new QDropEvent(event->pos(),
+ event->possibleActions(),
+ mimeDataCopy,
+ event->mouseButtons(),
+ event->keyboardModifiers()));
+
+ QTimer::singleShot(0, this, SLOT(dropUrlsDelayed()));
+}
+
+void DolphinViewContainer::dropUrlsDelayed()
+{
+ if (m_dropEvent.isNull()) {
+ return;
+ }
+
QString error;
- DragAndDropHelper::dropUrls(KFileItem(), destination, event, error);
+ DragAndDropHelper::dropUrls(KFileItem(), m_dropDestination, m_dropEvent.data(), error);
if (!error.isEmpty()) {
showMessage(error, Error);
}
+
+ delete m_dropEvent->mimeData();
+ m_dropEvent.reset();
}
void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
{
const QString protocol = url.protocol();
- return protocol.contains("search") || (protocol == QLatin1String("nepomuk"));
+ return protocol.contains("search");
}
void DolphinViewContainer::saveViewState()