]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Get rid of obsolete DolphinPlacesModel
authorPeter Penz <peter.penz19@gmail.com>
Tue, 29 May 2012 11:13:32 +0000 (13:13 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 29 May 2012 11:14:12 +0000 (13:14 +0200)
src/CMakeLists.txt
src/dolphincontextmenu.cpp
src/dolphinmainwindow.cpp
src/dolphinviewcontainer.cpp
src/panels/information/informationpanelcontent.cpp
src/panels/information/informationpanelcontent.h
src/panels/places/placesitemmodel.cpp
src/views/dolphinplacesmodel.cpp [deleted file]
src/views/dolphinplacesmodel.h [deleted file]

index 97b7e305c035018f8f5cfb43c4735ae431b69265..5c1a6dad58cb579ee85731d4bfa0ebe9a6a1bea4 100644 (file)
@@ -58,7 +58,6 @@ set(dolphinprivate_LIB_SRCS
     views/dolphinfileitemlistwidget.cpp
     views/dolphinitemlistview.cpp
     views/dolphinnewfilemenuobserver.cpp
-    views/dolphinplacesmodel.cpp
     views/dolphinremoteencoding.cpp
     views/dolphinview.cpp
     views/dolphinviewactionhandler.cpp
index 670062250a86ba6ea322da1e5a03207d46e2a208..ab91a9ba60db94d432fc4c7fbd3b9905b920644f 100644 (file)
@@ -54,7 +54,6 @@
 #include <QClipboard>
 #include <QDir>
 
-#include "views/dolphinplacesmodel.h"
 #include "views/dolphinview.h"
 #include "views/viewmodecontroller.h"
 
@@ -175,14 +174,6 @@ void DolphinContextMenu::openTrashContextMenu()
     emptyTrashAction->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
     m_popup->addAction(emptyTrashAction);
 
-    QAction* addToPlacesAction = m_popup->addAction(KIcon("bookmark-new"),
-                                                  i18nc("@action:inmenu Add current folder to places", "Add to Places"));
-
-    // Don't show if url is already in places
-    if (placeExists(m_mainWindow->activeViewContainer()->url())) {
-        addToPlacesAction->setVisible(false);
-    }
-
     addCustomActions();
 
     QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties");
@@ -190,14 +181,8 @@ void DolphinContextMenu::openTrashContextMenu()
 
     addShowMenuBarAction();
 
-    QAction *action = m_popup->exec(m_pos);
-    if (action == emptyTrashAction) {
+    if (m_popup->exec(m_pos) == emptyTrashAction) {
         KonqOperations::emptyTrash(m_mainWindow);
-    } else if (action == addToPlacesAction) {
-        const KUrl url = m_mainWindow->activeViewContainer()->url();
-        if (url.isValid()) {
-            DolphinPlacesModel::instance()->addPlace(i18nc("@label", "Trash"), url);
-        }
     }
 }
 
@@ -307,8 +292,8 @@ void DolphinContextMenu::openItemContextMenu()
         if (activatedAction == addToPlacesAction) {
             const KUrl selectedUrl(m_fileInfo.url());
             if (selectedUrl.isValid()) {
-                DolphinPlacesModel::instance()->addPlace(placesName(selectedUrl),
-                                                         selectedUrl);
+                KFilePlacesModel model;
+                model.addPlace(placesName(selectedUrl), selectedUrl);
             }
         } else if (activatedAction == openParentInNewWindowAction) {
             m_command = OpenParentFolderInNewWindow;
@@ -368,7 +353,8 @@ void DolphinContextMenu::openViewportContextMenu()
     if (addToPlacesAction && (action == addToPlacesAction)) {
         const KUrl url = m_mainWindow->activeViewContainer()->url();
         if (url.isValid()) {
-            DolphinPlacesModel::instance()->addPlace(placesName(url), url);
+            KFilePlacesModel model;
+            model.addPlace(placesName(url), url);
         }
     }
 }
@@ -419,13 +405,12 @@ QString DolphinContextMenu::placesName(const KUrl& url) const
 
 bool DolphinContextMenu::placeExists(const KUrl& url) const
 {
-    const KFilePlacesModel* placesModel = DolphinPlacesModel::instance();
-    const int count = placesModel->rowCount();
+    KFilePlacesModel model;
 
+    const int count = model.rowCount();
     for (int i = 0; i < count; ++i) {
-        const QModelIndex index = placesModel->index(i, 0);
-
-        if (url.equals(placesModel->url(index), KUrl::CompareWithoutTrailingSlash)) {
+        const QModelIndex index = model.index(i, 0);
+        if (url.equals(model.url(index), KUrl::CompareWithoutTrailingSlash)) {
             return true;
         }
     }
index 355bc6fd4242de06b4de62fec56d9d5df0c81b09..df1954d07716174239c67ed9a28e3fafa48e834f 100644 (file)
@@ -80,8 +80,6 @@
 #include <KUrlComboBox>
 #include <KToolInvocation>
 
-#include "views/dolphinplacesmodel.h"
-
 #include <QDesktopWidget>
 #include <QDBusMessage>
 #include <QKeyEvent>
@@ -123,10 +121,6 @@ DolphinMainWindow::DolphinMainWindow() :
     m_updateToolBarTimer(0),
     m_lastHandleUrlStatJob(0)
 {
-    DolphinPlacesModel::setModel(new KFilePlacesModel(this));
-    connect(DolphinPlacesModel::instance(), SIGNAL(errorMessage(QString)),
-            this, SLOT(showErrorMessage(QString)));
-
     // Workaround for a X11-issue in combination with KModifierInfo
     // (see DolphinContextMenu::initializeModifierKeyInfo() for
     // more information):
index 9e297364b844c16de36635ab6d8ae6565f4b262a..7c7d7d309173055888e527ed54d0af983e394b3b 100644 (file)
@@ -48,7 +48,6 @@
 #include "filterbar/filterbar.h"
 #include "search/dolphinsearchbox.h"
 #include "statusbar/dolphinstatusbar.h"
-#include "views/dolphinplacesmodel.h"
 #include "views/draganddrophelper.h"
 #include "views/viewmodecontroller.h"
 #include "views/viewproperties.h"
@@ -72,7 +71,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     m_topLayout->setSpacing(0);
     m_topLayout->setMargin(0);
 
-    m_urlNavigator = new KUrlNavigator(DolphinPlacesModel::instance(), url, this);
+    m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
     connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)),
             this, SLOT(dropUrls(KUrl,QDropEvent*)));
     connect(m_urlNavigator, SIGNAL(activated()),
index 1cbe0cd31737943ed0d514bcca2f655de1dc58f3..c535d3d6ad7b0bd0ed2f7481d2f7e4094ea24d3a 100644 (file)
@@ -53,7 +53,6 @@
 #include "filemetadataconfigurationdialog.h"
 #include "phononwidget.h"
 #include "pixmapviewer.h"
-#include "views/dolphinplacesmodel.h"
 
 InformationPanelContent::InformationPanelContent(QWidget* parent) :
     QWidget(parent),
@@ -64,7 +63,8 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
     m_phononWidget(0),
     m_nameLabel(0),
     m_metaDataWidget(0),
-    m_metaDataArea(0)
+    m_metaDataArea(0),
+    m_placesModel(0)
 {
     parent->installEventFilter(this);
 
@@ -136,6 +136,8 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
     layout->addWidget(m_nameLabel);
     layout->addWidget(new KSeparator());
     layout->addWidget(m_metaDataArea);
+
+    m_placesModel = new KFilePlacesModel(this);
 }
 
 InformationPanelContent::~InformationPanelContent()
@@ -346,15 +348,12 @@ void InformationPanelContent::refreshMetaData()
 
 bool InformationPanelContent::applyPlace(const KUrl& url)
 {
-    KFilePlacesModel* placesModel = DolphinPlacesModel::instance();
-    const int count = placesModel->rowCount();
-
+    const int count = m_placesModel->rowCount();
     for (int i = 0; i < count; ++i) {
-        QModelIndex index = placesModel->index(i, 0);
-
-        if (url.equals(placesModel->url(index), KUrl::CompareWithoutTrailingSlash)) {
-            setNameLabelText(placesModel->text(index));
-            m_preview->setPixmap(placesModel->icon(index).pixmap(128, 128));
+        QModelIndex index = m_placesModel->index(i, 0);
+        if (url.equals(m_placesModel->url(index), KUrl::CompareWithoutTrailingSlash)) {
+            setNameLabelText(m_placesModel->text(index));
+            m_preview->setPixmap(m_placesModel->icon(index).pixmap(128, 128));
             return true;
         }
     }
index 0f90c5ea1b7189872f42078d038d8b537da53eb4..234060749e681e9f7e89ee2b7eac4df4f4174f20 100644 (file)
@@ -27,6 +27,7 @@
 
 class KFileItemList;
 class KFileMetaDataWidget;
+class KFilePlacesModel;
 class PhononWidget;
 class PixmapViewer;
 class QPixmap;
@@ -134,6 +135,8 @@ private:
     QLabel* m_nameLabel;
     KFileMetaDataWidget* m_metaDataWidget;
     QScrollArea* m_metaDataArea;
+
+    KFilePlacesModel* m_placesModel;
 };
 
 #endif // INFORMATIONPANELCONTENT_H
index aea26227783bfaadb3f04ed8a746480c55316130..c1a5426af7a0811f7628fbdc5d9a1234b40740b5 100644 (file)
@@ -95,7 +95,7 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
     initializeAvailableDevices();
     loadBookmarks();
 
-    const int syncBookmarksTimeout = 1000;
+    const int syncBookmarksTimeout = 100;
 
     m_saveBookmarksTimer = new QTimer(this);
     m_saveBookmarksTimer->setInterval(syncBookmarksTimeout);
diff --git a/src/views/dolphinplacesmodel.cpp b/src/views/dolphinplacesmodel.cpp
deleted file mode 100644 (file)
index 4b8e6ea..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "dolphinplacesmodel.h"
-
-#include <KFilePlacesModel>
-
-KFilePlacesModel* DolphinPlacesModel::m_filePlacesModel = 0;
-
-KFilePlacesModel* DolphinPlacesModel::instance()
-{
-    return m_filePlacesModel;
-}
-
-void DolphinPlacesModel::setModel(KFilePlacesModel* model)
-{
-    m_filePlacesModel = model;
-}
diff --git a/src/views/dolphinplacesmodel.h b/src/views/dolphinplacesmodel.h
deleted file mode 100644 (file)
index 0f950ca..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef DOLPHIN_PLACES_MODEL_H
-#define DOLPHIN_PLACES_MODEL_H
-
-#include <libdolphin_export.h>
-
-class KFilePlacesModel;
-
-/**
- * @brief Allows global access to the places-model of Dolphin
- *        that is shown in the "Places" panel.
- */
-class LIBDOLPHINPRIVATE_EXPORT DolphinPlacesModel
-{
-public:
-    static KFilePlacesModel* instance();
-
-private:
-    static void setModel(KFilePlacesModel* model);
-    static KFilePlacesModel* m_filePlacesModel;
-
-    friend class DolphinMainWindow; // Sets the model with setModel()
-};
-
-#endif