From: Peter Penz Date: Tue, 29 May 2012 11:13:32 +0000 (+0200) Subject: Get rid of obsolete DolphinPlacesModel X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/203449110e1763cbaee332a9b15d171c333e2df4?ds=inline Get rid of obsolete DolphinPlacesModel --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97b7e305c..5c1a6dad5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 670062250..ab91a9ba6 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -54,7 +54,6 @@ #include #include -#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; } } diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 355bc6fd4..df1954d07 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -80,8 +80,6 @@ #include #include -#include "views/dolphinplacesmodel.h" - #include #include #include @@ -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): diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 9e297364b..7c7d7d309 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -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()), diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index 1cbe0cd31..c535d3d6a 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -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; } } diff --git a/src/panels/information/informationpanelcontent.h b/src/panels/information/informationpanelcontent.h index 0f90c5ea1..234060749 100644 --- a/src/panels/information/informationpanelcontent.h +++ b/src/panels/information/informationpanelcontent.h @@ -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 diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index aea262277..c1a5426af 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -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 index 4b8e6ea5e..000000000 --- a/src/views/dolphinplacesmodel.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz * - * * - * 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* 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 index 0f950cabe..000000000 --- a/src/views/dolphinplacesmodel.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz * - * * - * 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 - -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