]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
Show the file name as plain text in the rename dialog
[dolphin.git] / src / dolphincontextmenu.cpp
index ab91a9ba60db94d432fc4c7fbd3b9905b920644f..bb26c7aaeda87ba77f9e241cfde6c4961ce90640 100644 (file)
@@ -31,7 +31,6 @@
 #include <kabstractfileitemactionplugin.h>
 #include <KFileItemActions>
 #include <KFileItemListProperties>
-#include <KFilePlacesModel>
 #include <KGlobal>
 #include <KIconLoader>
 #include <KIO/NetAccess>
@@ -50,6 +49,9 @@
 #include <KStandardDirs>
 #include <KToolBar>
 
+#include <panels/places/placesitem.h>
+#include <panels/places/placesitemmodel.h>
+
 #include <QApplication>
 #include <QClipboard>
 #include <QDir>
@@ -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;
 }