const KUrl selectedUrl(m_fileInfo.url());
if (selectedUrl.isValid()) {
PlacesItemModel model;
- PlacesItem* item = model.createPlacesItem(placesName(selectedUrl),
- selectedUrl);
+ const QString text = m_mainWindow->activeViewContainer()->placesText();
+ PlacesItem* item = model.createPlacesItem(text, selectedUrl);
model.appendItemToGroup(item);
}
} else if (activatedAction == openParentInNewWindowAction) {
QAction* action = m_popup->exec(m_pos);
if (addToPlacesAction && (action == addToPlacesAction)) {
- const KUrl url = m_mainWindow->activeViewContainer()->url();
- if (url.isValid()) {
+ const DolphinViewContainer* container = m_mainWindow->activeViewContainer();
+ if (container->url().isValid()) {
PlacesItemModel model;
- PlacesItem* item = model.createPlacesItem(placesName(url), url);
+ PlacesItem* item = model.createPlacesItem(container->placesText(),
+ container->url());
model.appendItemToGroup(item);
}
}
}
}
-QString DolphinContextMenu::placesName(const KUrl& url) const
-{
- QString name = url.fileName();
- if (name.isEmpty()) {
- name = url.host();
- }
- return name;
-}
-
bool DolphinContextMenu::placeExists(const KUrl& url) const
{
PlacesItemModel model;
*/
void addShowMenuBarAction();
- /**
- * Returns a name for adding the URL \a url to the Places panel.
- */
- QString placesName(const KUrl& url) const;
-
bool placeExists(const KUrl& url) const;
QAction* createPasteAction();
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()) {
void setSearchModeEnabled(bool enabled);
bool isSearchModeEnabled() const;
+ /**
+ * @return Text that should be used for the current URL when creating
+ * a new place.
+ */
+ QString placesText() const;
+
public slots:
/**
* Sets the current active URL, where all actions are applied. The