From d64bbc333c5014fad116efc98b77cf3268fc07e0 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 13 May 2010 18:23:04 +0000 Subject: [PATCH] Reset the location to the home URL, if a place has been removed (e. g. a DVD has been ejected). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Thanks to Christian Mühlhäuser for the patch! BUG: 231518 svn path=/trunk/KDE/kdebase/apps/; revision=1126336 --- src/panels/places/placespanel.cpp | 20 ++++++++++++++++++++ src/panels/places/placespanel.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index e1e63ba9b..0da932154 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (C) 2008 by Peter Penz * + * Copyright (C) 2010 by Christian Muehlhaeuser * * * * 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 * @@ -18,9 +19,12 @@ ***************************************************************************/ #include "placespanel.h" + +#include "dolphin_generalsettings.h" #include "draganddrophelper.h" #include #include +#include "settings/dolphinsettings.h" PlacesPanel::PlacesPanel(QWidget* parent) : KFilePlacesView(parent), @@ -43,6 +47,22 @@ void PlacesPanel::mousePressEvent(QMouseEvent* event) KFilePlacesView::mousePressEvent(event); } +void PlacesPanel::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) +{ + Q_UNUSED(parent); + + const QModelIndexList indexes = selectedIndexes(); + if (!indexes.isEmpty()) { + const int selectedRow = indexes.first().row(); + if ((start >= selectedRow) && (end <= selectedRow)) { + // The currently selected item is about to be removed, reset view to home URL + const KUrl homeUrl = DolphinSettings::instance().generalSettings()->homeUrl(); + setUrl(homeUrl); + emit urlChanged(homeUrl, Qt::NoButton); + } + } +} + void PlacesPanel::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent) { DragAndDropHelper::instance().dropUrls(KFileItem(), dest, event, parent); diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index 1b6681af8..f39bdec47 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (C) 2008 by Peter Penz * + * Copyright (C) 2010 by Christian Muehlhaeuser * * * * 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 * @@ -38,6 +39,7 @@ signals: protected: virtual void mousePressEvent(QMouseEvent* event); + virtual void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end); private slots: void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent); -- 2.47.3