diff options
Diffstat (limited to 'src/panels/places')
| -rw-r--r-- | src/panels/places/placesitemmodel.cpp | 59 | ||||
| -rw-r--r-- | src/panels/places/placesitemmodel.h | 10 | ||||
| -rw-r--r-- | src/panels/places/placespanel.cpp | 48 | ||||
| -rw-r--r-- | src/panels/places/placespanel.h | 4 |
4 files changed, 37 insertions, 84 deletions
diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 7e313482d..f7fe5587c 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -120,11 +120,6 @@ void PlacesItemModel::setHiddenItemsShown(bool show) } } } - -#ifdef PLACESITEMMODEL_DEBUG - qCDebug(DolphinDebug) << "Changed visibility of hidden items"; - showModelState(); -#endif } bool PlacesItemModel::hiddenItemsShown() const @@ -169,10 +164,6 @@ void PlacesItemModel::insertSortedItem(PlacesItem* item) void PlacesItemModel::onItemInserted(int index) { KStandardItemModel::onItemInserted(index); -#ifdef PLACESITEMMODEL_DEBUG - qCDebug(DolphinDebug) << "Inserted item" << index; - showModelState(); -#endif } void PlacesItemModel::onItemRemoved(int index, KStandardItem* removedItem) @@ -180,10 +171,6 @@ void PlacesItemModel::onItemRemoved(int index, KStandardItem* removedItem) m_indexMap.removeAt(index); KStandardItemModel::onItemRemoved(index, removedItem); -#ifdef PLACESITEMMODEL_DEBUG - qCDebug(DolphinDebug) << "Removed item" << index; - showModelState(); -#endif } void PlacesItemModel::onItemChanged(int index, const QSet<QByteArray>& changedRoles) @@ -635,11 +622,6 @@ void PlacesItemModel::loadBookmarks() addItemFromSourceModel(sourceIndex); } } - -#ifdef PLACESITEMMODEL_DEBUG - qCDebug(DolphinDebug) << "Loaded bookmarks"; - showModelState(); -#endif } void PlacesItemModel::clear() { @@ -786,44 +768,3 @@ PlacesItem *PlacesItemModel::itemFromBookmark(const KBookmark &bookmark) const return nullptr; } -#ifdef PLACESITEMMODEL_DEBUG -void PlacesItemModel::showModelState() -{ - qCDebug(DolphinDebug) << "================================="; - qCDebug(DolphinDebug) << "Model:"; - qCDebug(DolphinDebug) << "hidden-index model-index text"; - int modelIndex = 0; - for (int i = 0; i < m_bookmarkedItems.count(); ++i) { - if (m_bookmarkedItems[i]) { - qCDebug(DolphinDebug) << i << "(Hidden) " << " " << m_bookmarkedItems[i]->dataValue("text").toString(); - } else { - if (item(modelIndex)) { - qCDebug(DolphinDebug) << i << " " << modelIndex << " " << item(modelIndex)->dataValue("text").toString(); - } else { - qCDebug(DolphinDebug) << i << " " << modelIndex << " " << "(not available yet)"; - } - ++modelIndex; - } - } - - qCDebug(DolphinDebug); - qCDebug(DolphinDebug) << "Bookmarks:"; - - int bookmarkIndex = 0; - KBookmarkGroup root = m_bookmarkManager->root(); - KBookmark bookmark = root.first(); - while (!bookmark.isNull()) { - const QString udi = bookmark.metaDataItem("UDI"); - const QString text = udi.isEmpty() ? bookmark.text() : udi; - if (bookmark.metaDataItem("IsHidden") == QLatin1String("true")) { - qCDebug(DolphinDebug) << bookmarkIndex << "(Hidden)" << text; - } else { - qCDebug(DolphinDebug) << bookmarkIndex << " " << text; - } - - bookmark = root.next(bookmark); - ++bookmarkIndex; - } -} -#endif - diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h index a2086efc5..c4ff7e2dd 100644 --- a/src/panels/places/placesitemmodel.h +++ b/src/panels/places/placesitemmodel.h @@ -32,17 +32,13 @@ #include <QUrl> class KBookmark; -class KBookmarkManager; class PlacesItem; class QAction; -// #define PLACESITEMMODEL_DEBUG - /** * @brief Model for maintaining the bookmarks of the places panel. * - * It is compatible to the KFilePlacesModel from kdelibs but adds - * the ability to have groups for places. + * It is based on KFilePlacesModel from KIO. */ class PlacesItemModel: public KStandardItemModel { @@ -204,10 +200,6 @@ private: */ void insertSortedItem(PlacesItem* item); -#ifdef PLACESITEMMODEL_DEBUG - void showModelState(); -#endif - PlacesItem *itemFromBookmark(const KBookmark &bookmark) const; void addItemFromSourceModel(const QModelIndex &index); diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 00d8735c3..7b4900f7c 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -38,22 +38,19 @@ #include "trash/dolphintrash.h" #include "views/draganddrophelper.h" -#include <KDirNotify> -#include <KFileItem> #include <KFilePlacesModel> #include <KIO/DropJob> #include <KIO/EmptyTrashJob> #include <KIO/Job> -#include <KIO/JobUiDelegate> #include <KIconLoader> -#include <KJobWidgets> #include <KLocalizedString> -#include <KMessageBox> -#include <KNotification> +#include <KMountPoint> +#include <KPropertiesDialog> #include <QGraphicsSceneDragDropEvent> #include <QIcon> #include <QMenu> +#include <QMimeData> #include <QVBoxLayout> PlacesPanel::PlacesPanel(QWidget* parent) : @@ -174,6 +171,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) QAction* editAction = nullptr; QAction* teardownAction = nullptr; QAction* ejectAction = nullptr; + QAction* mountAction = nullptr; const bool isDevice = !item->udi().isEmpty(); const bool isTrash = (item->url().scheme() == QLatin1String("trash")); @@ -186,11 +184,25 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) teardownAction = m_model->teardownAction(index); if (teardownAction) { + // Disable teardown option for root and home partitions + bool teardownEnabled = item->url() != QUrl::fromLocalFile(QDir::rootPath()); + if (teardownEnabled) { + KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(QDir::homePath()); + if (mountPoint && item->url() == QUrl::fromLocalFile(mountPoint->mountPoint())) { + teardownEnabled = false; + } + } + teardownAction->setEnabled(teardownEnabled); + teardownAction->setParent(&menu); menu.addAction(teardownAction); } - if (teardownAction || ejectAction) { + if (item->storageSetupNeeded()) { + mountAction = menu.addAction(QIcon::fromTheme(QStringLiteral("media-mount")), i18nc("@action:inmenu", "Mount")); + } + + if (teardownAction || ejectAction || mountAction) { menu.addSeparator(); } } else { @@ -201,14 +213,18 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) } } - QAction* openInNewWindowAction = menu.addAction(QIcon::fromTheme("window-new"), i18nc("@item:inmenu", "Open in New Window")); - QAction* openInNewTabAction = menu.addAction(QIcon::fromTheme("tab-new"), i18nc("@item:inmenu", "Open in New Tab")); + QAction* openInNewWindowAction = menu.addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@item:inmenu", "Open in New Window")); + QAction* openInNewTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@item:inmenu", "Open in New Tab")); + QAction* propertiesAction = nullptr; + if (item->url().isLocalFile()) { + propertiesAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18nc("@action:inmenu", "Properties")); + } if (!isDevice && !isTrash) { menu.addSeparator(); } if (!isDevice) { - editAction = menu.addAction(QIcon::fromTheme("document-properties"), i18nc("@item:inmenu", "Edit...")); + editAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-entry")), i18nc("@item:inmenu", "Edit...")); } QAction* removeAction = nullptr; @@ -216,7 +232,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) removeAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@item:inmenu", "Remove")); } - QAction* hideAction = menu.addAction(i18nc("@item:inmenu", "Hide")); + QAction* hideAction = menu.addAction(QIcon::fromTheme(QStringLiteral("hint")), i18nc("@item:inmenu", "Hide")); hideAction->setCheckable(true); hideAction->setChecked(item->isHidden()); @@ -248,10 +264,16 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) // TriggerItem does set up the storage first and then it will // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton. triggerItem(index, Qt::MiddleButton); + } else if (action == mountAction) { + m_model->requestStorageSetup(index); } else if (action == teardownAction) { m_model->requestTearDown(index); } else if (action == ejectAction) { m_model->requestEject(index); + } else if (action == propertiesAction) { + KPropertiesDialog* dialog = new KPropertiesDialog(item->url(), this); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); } } } @@ -267,7 +289,7 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) QAction* showAllAction = nullptr; if (m_model->hiddenCount() > 0) { - showAllAction = menu.addAction(i18nc("@item:inmenu", "Show All Entries")); + showAllAction = menu.addAction(QIcon::fromTheme(QStringLiteral("visibility")), i18nc("@item:inmenu", "Show All Entries")); showAllAction->setCheckable(true); showAllAction->setChecked(m_model->hiddenItemsShown()); } @@ -334,7 +356,7 @@ QAction *PlacesPanel::buildGroupContextMenu(QMenu *menu, int index) } KFilePlacesModel::GroupType groupType = m_model->groupType(index); - QAction *hideGroupAction = menu->addAction(i18nc("@item:inmenu", "Hide Section '%1'", m_model->item(index)->group())); + QAction *hideGroupAction = menu->addAction(QIcon::fromTheme(QStringLiteral("hint")), i18nc("@item:inmenu", "Hide Section '%1'", m_model->item(index)->group())); hideGroupAction->setCheckable(true); hideGroupAction->setChecked(m_model->isGroupHidden(groupType)); diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index d62697940..c6f959d23 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -23,16 +23,14 @@ #include "panels/panel.h" -#include <QMimeData> #include <QUrl> class KItemListController; -class PlacesItem; class PlacesItemModel; class PlacesView; class QGraphicsSceneDragDropEvent; -class KJob; class QMenu; +class QMimeData; /** * @brief Combines bookmarks and mounted devices as list. */ |
