X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/203449110e1763cbaee332a9b15d171c333e2df4..7f381a34cb37ff4aeb215a8fe91448e5ea27aca0:/src/dolphincontextmenu.cpp diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index ab91a9ba6..bb26c7aae 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -50,6 +49,9 @@ #include #include +#include +#include + #include #include #include @@ -292,8 +294,10 @@ void DolphinContextMenu::openItemContextMenu() if (activatedAction == addToPlacesAction) { const KUrl selectedUrl(m_fileInfo.url()); if (selectedUrl.isValid()) { - KFilePlacesModel model; - model.addPlace(placesName(selectedUrl), selectedUrl); + PlacesItemModel model; + const QString text = selectedUrl.fileName(); + PlacesItem* item = model.createPlacesItem(text, selectedUrl); + model.appendItemToGroup(item); } } else if (activatedAction == openParentInNewWindowAction) { m_command = OpenParentFolderInNewWindow; @@ -351,10 +355,12 @@ void DolphinContextMenu::openViewportContextMenu() QAction* action = m_popup->exec(m_pos); if (addToPlacesAction && (action == addToPlacesAction)) { - const KUrl url = m_mainWindow->activeViewContainer()->url(); - if (url.isValid()) { - KFilePlacesModel model; - model.addPlace(placesName(url), url); + const DolphinViewContainer* container = m_mainWindow->activeViewContainer(); + if (container->url().isValid()) { + PlacesItemModel model; + PlacesItem* item = model.createPlacesItem(container->placesText(), + container->url()); + model.appendItemToGroup(item); } } } @@ -394,26 +400,18 @@ 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 { - KFilePlacesModel model; + PlacesItemModel model; - const int count = model.rowCount(); + const int count = model.count(); for (int i = 0; i < count; ++i) { - const QModelIndex index = model.index(i, 0); - if (url.equals(model.url(index), KUrl::CompareWithoutTrailingSlash)) { + const KUrl placeUrl = model.placesItem(i)->url(); + if (placeUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) { return true; } } + return false; }