-/***************************************************************************
- * Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
- * Copyright (C) 2010 by Christian Muehlhaeuser <muesli@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 *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2008-2012 Peter Penz <peter.penz19@gmail.com>
+ * SPDX-FileCopyrightText: 2010 Christian Muehlhaeuser <muesli@gmail.com>
+ * SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <kde@broulik.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
#ifndef PLACESPANEL_H
#define PLACESPANEL_H
-#include <kfileplacesview.h>
+#include "panels/panel.h"
+
+#include <QUrl>
+#include <KFilePlacesView>
+
+#include <Solid/SolidNamespace> // Solid::ErrorType
+
+class QTimer;
+namespace Solid
+{
+class StorageAccess;
+}
/**
* @brief Combines bookmarks and mounted devices as list.
Q_OBJECT
public:
- PlacesPanel(QWidget* parent);
- virtual ~PlacesPanel();
+ explicit PlacesPanel(QWidget* parent);
+ ~PlacesPanel() override;
+
+ void setUrl(const QUrl &url); // override
+
+ // for compatibility with Panel, actions that are shown
+ // on the view's context menu
+ QList<QAction*> customContextMenuActions() const;
+ void setCustomContextMenuActions(const QList<QAction*>& actions);
-signals:
- void urlChanged(const KUrl& url, Qt::MouseButtons buttons);
+ void requestTearDown();
+ void proceedWithTearDown();
+
+public Q_SLOTS:
+ void readSettings();
+
+Q_SIGNALS:
+ void errorMessage(const QString& error);
+ void storageTearDownRequested(const QString& mountPath);
+ void storageTearDownExternallyRequested(const QString& mountPath);
+ void storageTearDownSuccessful();
protected:
- virtual void mousePressEvent(QMouseEvent* event);
- virtual void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
+ void showEvent(QShowEvent* event) override;
+ void dragMoveEvent(QDragMoveEvent *event) override;
+ void dragLeaveEvent(QDragLeaveEvent *event) override;
-private slots:
- void slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent);
- void emitExtendedUrlChangedSignal(const KUrl& url);
+private Q_SLOTS:
+ void slotConfigureTrash();
+ void slotDragActivationTimeout();
+ void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent);
+ void slotContextMenuAboutToShow(const QModelIndex &index, QMenu *menu);
+ void slotTearDownRequested(const QModelIndex &index);
+ void slotTearDownRequestedExternally(const QString &udi);
+ void slotTearDownDone(Solid::ErrorType error, const QVariant& errorData);
+ void slotRowsInserted(const QModelIndex &parent, int first, int last);
+ void slotRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
private:
- Qt::MouseButtons m_mouseButtons;
+ void connectDeviceSignals(const QModelIndex &idx);
+
+ QUrl m_url; // only used for initial setUrl
+ QList<QAction*> m_customContextMenuActions;
+
+ QTimer *m_dragActivationTimer = nullptr;
+ QPersistentModelIndex m_pendingDragActivation;
+
+ Solid::StorageAccess *m_deviceToTearDown = nullptr;
+
+ QAction *m_configureTrashAction;
+ QAction *m_lockPanelsAction;
};
#endif // PLACESPANEL_H