2020-08-25 17:07:38 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2018-03-19 08:57:24 +00:00
|
|
|
|
|
|
|
#ifndef DOLPHINPLACESMODELSINGLETON_H
|
|
|
|
#define DOLPHINPLACESMODELSINGLETON_H
|
|
|
|
|
|
|
|
#include <QScopedPointer>
|
2023-02-03 17:14:53 +00:00
|
|
|
#include <QString>
|
2018-03-19 08:57:24 +00:00
|
|
|
|
2021-12-16 18:29:22 +00:00
|
|
|
#include <KFilePlacesModel>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Dolphin's special-cased KFilePlacesModel
|
|
|
|
*
|
|
|
|
* It returns the trash's icon based on whether
|
|
|
|
* it is full or not.
|
|
|
|
*/
|
|
|
|
class DolphinPlacesModel : public KFilePlacesModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-09-29 07:29:16 +00:00
|
|
|
explicit DolphinPlacesModel(QObject *parent = nullptr);
|
2021-12-16 18:29:22 +00:00
|
|
|
~DolphinPlacesModel() override;
|
|
|
|
|
2022-01-28 18:40:11 +00:00
|
|
|
bool panelsLocked() const;
|
|
|
|
void setPanelsLocked(bool locked);
|
|
|
|
|
2022-04-07 19:41:43 +00:00
|
|
|
QStringList mimeTypes() const override;
|
|
|
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
|
|
|
|
2021-12-16 18:29:22 +00:00
|
|
|
protected:
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void slotTrashEmptinessChanged(bool isEmpty);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool isTrash(const QModelIndex &index) const;
|
|
|
|
|
|
|
|
bool m_isEmpty = false;
|
2022-01-28 18:40:11 +00:00
|
|
|
bool m_panelsLocked = true; // common-case, panels are locked
|
2021-12-16 18:29:22 +00:00
|
|
|
};
|
2018-03-19 08:57:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Provides a global KFilePlacesModel instance.
|
|
|
|
*/
|
|
|
|
class DolphinPlacesModelSingleton
|
|
|
|
{
|
|
|
|
public:
|
2023-02-03 17:14:53 +00:00
|
|
|
static DolphinPlacesModelSingleton &instance();
|
2018-03-19 08:57:24 +00:00
|
|
|
|
2022-01-28 18:39:07 +00:00
|
|
|
DolphinPlacesModel *placesModel() const;
|
2018-03-19 08:57:24 +00:00
|
|
|
|
2023-02-03 17:14:53 +00:00
|
|
|
DolphinPlacesModelSingleton(const DolphinPlacesModelSingleton &) = delete;
|
|
|
|
DolphinPlacesModelSingleton &operator=(const DolphinPlacesModelSingleton &) = delete;
|
2018-03-19 08:57:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DolphinPlacesModelSingleton();
|
|
|
|
|
2022-01-28 18:39:07 +00:00
|
|
|
QScopedPointer<DolphinPlacesModel> m_placesModel;
|
2018-03-19 08:57:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOLPHINPLACESMODELSINGLETON_H
|