mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Provide a default name when adding a search query to the places panel
BUG: 300430 FIXED-IN: 4.9.0
This commit is contained in:
parent
12215d6f0f
commit
a2674f5184
|
@ -295,8 +295,8 @@ void DolphinContextMenu::openItemContextMenu()
|
|||
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) {
|
||||
|
@ -355,10 +355,11 @@ void DolphinContextMenu::openViewportContextMenu()
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -399,15 +400,6 @@ void DolphinContextMenu::addShowMenuBarAction()
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -130,11 +130,6 @@ private:
|
|||
*/
|
||||
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();
|
||||
|
|
|
@ -316,6 +316,22 @@ 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()) {
|
||||
|
|
|
@ -117,6 +117,12 @@ public:
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue