Changeset View
Changeset View
Standalone View
Standalone View
src/trash/dolphintrash.h
- This file was copied from src/panels/places/placesitemsignalhandler.cpp.
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> * | 2 | * Copyright (C) 2018 by Roman Inflianskas <infroma@gmail.com> * | ||
3 | * * | 3 | * * | ||
4 | * This program is free software; you can redistribute it and/or modify * | 4 | * This program is free software; you can redistribute it and/or modify * | ||
5 | * it under the terms of the GNU General Public License as published by * | 5 | * it under the terms of the GNU General Public License as published by * | ||
6 | * the Free Software Foundation; either version 2 of the License, or * | 6 | * the Free Software Foundation; either version 2 of the License, or * | ||
7 | * (at your option) any later version. * | 7 | * (at your option) any later version. * | ||
8 | * * | 8 | * * | ||
9 | * This program is distributed in the hope that it will be useful, * | 9 | * This program is distributed in the hope that it will be useful, * | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
12 | * GNU General Public License for more details. * | 12 | * GNU General Public License for more details. * | ||
13 | * * | 13 | * * | ||
14 | * You should have received a copy of the GNU General Public License * | 14 | * You should have received a copy of the GNU General Public License * | ||
15 | * along with this program; if not, write to the * | 15 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | #include "placesitemsignalhandler.h" | 20 | #ifndef DOLPHINTRASH_H | ||
21 | #define DOLPHINTRASH_H | ||||
21 | 22 | | |||
22 | #include "placesitem.h" | 23 | #include <QWidget> | ||
23 | 24 | | |||
24 | PlacesItemSignalHandler::PlacesItemSignalHandler(PlacesItem* item, | 25 | #include <KIO/EmptyTrashJob> | ||
25 | QObject* parent) : | 26 | #include <KIOWidgets/KDirLister> | ||
26 | QObject(parent), | | |||
27 | m_item(item) | | |||
28 | { | | |||
29 | } | | |||
30 | 27 | | |||
31 | PlacesItemSignalHandler::~PlacesItemSignalHandler() | 28 | class Trash: public QObject | ||
32 | { | 29 | { | ||
33 | } | 30 | Q_OBJECT | ||
34 | 31 | | |||
35 | void PlacesItemSignalHandler::onAccessibilityChanged() | 32 | public: | ||
36 | { | 33 | // delete copy and move constructors and assign operators | ||
37 | if (m_item) { | 34 | Trash(Trash const&) = delete; | ||
38 | m_item->onAccessibilityChanged(); | 35 | Trash(Trash&&) = delete; | ||
39 | } | 36 | Trash& operator=(Trash const&) = delete; | ||
40 | } | 37 | Trash& operator=(Trash &&) = delete; | ||
41 | 38 | | |||
42 | void PlacesItemSignalHandler::onTrashDirListerCompleted() | 39 | static Trash& instance(); | ||
43 | { | 40 | KIO::Job* empty(QWidget *window) const; | ||
44 | if (m_item) { | 41 | bool isEmpty() const; | ||
45 | m_item->onTrashDirListerCompleted(); | | |||
46 | } | | |||
47 | } | | |||
48 | 42 | | |||
49 | void PlacesItemSignalHandler::onTearDownRequested(const QString& udi) | 43 | signals: | ||
50 | { | 44 | void emptinessChanged(bool isEmpty); | ||
51 | Q_UNUSED(udi) | 45 | | ||
52 | if (m_item) { | 46 | protected: | ||
53 | Solid::StorageAccess *tmp = m_item->device().as<Solid::StorageAccess>(); | 47 | Trash(); | ||
54 | if (tmp) { | 48 | ~Trash(); | ||
55 | QString mountPath = tmp->filePath(); | 49 | | ||
56 | emit tearDownExternallyRequested(mountPath); | 50 | private: | ||
57 | } | 51 | KDirLister *m_trashDirLister; | ||
58 | } | 52 | | ||
59 | } | 53 | void watchEmptinessChanged(); | ||
54 | }; | ||||
60 | 55 | | |||
56 | #endif // DOLPHINTRASH_H |