Changeset View
Changeset View
Standalone View
Standalone View
src/panels/places/placespanel.cpp
Show All 38 Lines | |||||
39 | #include "views/draganddrophelper.h" | 39 | #include "views/draganddrophelper.h" | ||
40 | 40 | | |||
41 | #include <KFilePlacesModel> | 41 | #include <KFilePlacesModel> | ||
42 | #include <KIO/DropJob> | 42 | #include <KIO/DropJob> | ||
43 | #include <KIO/EmptyTrashJob> | 43 | #include <KIO/EmptyTrashJob> | ||
44 | #include <KIO/Job> | 44 | #include <KIO/Job> | ||
45 | #include <KIconLoader> | 45 | #include <KIconLoader> | ||
46 | #include <KLocalizedString> | 46 | #include <KLocalizedString> | ||
47 | #include <KMountPoint> | ||||
47 | 48 | | |||
48 | #include <QGraphicsSceneDragDropEvent> | 49 | #include <QGraphicsSceneDragDropEvent> | ||
49 | #include <QIcon> | 50 | #include <QIcon> | ||
50 | #include <QMenu> | 51 | #include <QMenu> | ||
51 | #include <QMimeData> | 52 | #include <QMimeData> | ||
52 | #include <QVBoxLayout> | 53 | #include <QVBoxLayout> | ||
53 | 54 | | |||
54 | PlacesPanel::PlacesPanel(QWidget* parent) : | 55 | PlacesPanel::PlacesPanel(QWidget* parent) : | ||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Line(s) | 176 | if (isDevice) { | |||
176 | ejectAction = m_model->ejectAction(index); | 177 | ejectAction = m_model->ejectAction(index); | ||
177 | if (ejectAction) { | 178 | if (ejectAction) { | ||
178 | ejectAction->setParent(&menu); | 179 | ejectAction->setParent(&menu); | ||
179 | menu.addAction(ejectAction); | 180 | menu.addAction(ejectAction); | ||
180 | } | 181 | } | ||
181 | 182 | | |||
182 | teardownAction = m_model->teardownAction(index); | 183 | teardownAction = m_model->teardownAction(index); | ||
183 | if (teardownAction) { | 184 | if (teardownAction) { | ||
185 | KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByPath(QDir::homePath()); | ||||
elvisangelaccio: Please use a descriptive name for the variable (e.g. `mountPoint`). | |||||
Small optimization: we could do the mount points lookup (which isn't a trivial operation) only if we are sure item->url() is not the root path. elvisangelaccio: Small optimization: we could do the mount points lookup (which isn't a trivial operation) only… | |||||
186 | if (item->url() == QUrl::fromLocalFile(QDir::rootPath()) || | ||||
187 | (mp && item->url() == QUrl::fromLocalFile(mp->mountPoint()))) { | ||||
188 | // Disable teardown option for root and home paritions | ||||
189 | teardownAction->setEnabled(false); | ||||
190 | } | ||||
184 | teardownAction->setParent(&menu); | 191 | teardownAction->setParent(&menu); | ||
185 | menu.addAction(teardownAction); | 192 | menu.addAction(teardownAction); | ||
We should not hardcode "/home" here, but derive it from the user home directory. bruns: We should not hardcode "/home" here, but derive it from the user home directory. | |||||
186 | } | 193 | } | ||
187 | 194 | | |||
188 | if (teardownAction || ejectAction) { | 195 | if (teardownAction || ejectAction) { | ||
189 | menu.addSeparator(); | 196 | menu.addSeparator(); | ||
190 | } | 197 | } | ||
191 | } else { | 198 | } else { | ||
192 | if (isTrash) { | 199 | if (isTrash) { | ||
193 | emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash")); | 200 | emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash")); | ||
▲ Show 20 Lines • Show All 323 Lines • Show Last 20 Lines |
Please use a descriptive name for the variable (e.g. mountPoint).