]>
cloud.milkyroute.net Git - dolphin.git/blob - src/panels/places/placespanel.cpp
1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2010 by Christian Muehlhaeuser <muesli@gmail.com> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "placespanel.h"
23 #include "dolphin_generalsettings.h"
24 #include "draganddrophelper.h"
25 #include <kfileitem.h>
26 #include <konq_operations.h>
27 #include "settings/dolphinsettings.h"
29 PlacesPanel::PlacesPanel(QWidget
* parent
) :
30 KFilePlacesView(parent
),
31 m_mouseButtons(Qt::NoButton
)
33 setDropOnPlaceEnabled(true);
34 connect(this, SIGNAL(urlsDropped(const KUrl
&, QDropEvent
*, QWidget
*)),
35 this, SLOT(slotUrlsDropped(const KUrl
&, QDropEvent
*, QWidget
*)));
36 connect(this, SIGNAL(urlChanged(const KUrl
&)),
37 this, SLOT(emitExtendedUrlChangedSignal(const KUrl
&)));
40 PlacesPanel::~PlacesPanel()
44 void PlacesPanel::mousePressEvent(QMouseEvent
* event
)
46 m_mouseButtons
= event
->buttons();
47 KFilePlacesView::mousePressEvent(event
);
50 void PlacesPanel::rowsAboutToBeRemoved(const QModelIndex
& parent
, int start
, int end
)
54 const QModelIndexList indexes
= selectedIndexes();
55 if (!indexes
.isEmpty()) {
56 const int selectedRow
= indexes
.first().row();
57 if ((start
>= selectedRow
) && (end
<= selectedRow
)) {
58 // The currently selected item is about to be removed, reset view to home URL
59 const KUrl homeUrl
= DolphinSettings::instance().generalSettings()->homeUrl();
61 emit
urlChanged(homeUrl
, Qt::NoButton
);
66 void PlacesPanel::slotUrlsDropped(const KUrl
& dest
, QDropEvent
* event
, QWidget
* parent
)
68 DragAndDropHelper::instance().dropUrls(KFileItem(), dest
, event
, parent
);
71 void PlacesPanel::emitExtendedUrlChangedSignal(const KUrl
& url
)
73 emit
urlChanged(url
, m_mouseButtons
);
76 #include "placespanel.moc"