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 | 18 | ||||
| -rw-r--r-- | src/panels/places/placespanel.h | 4 |
4 files changed, 12 insertions, 79 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..8d7f29384 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -38,22 +38,17 @@ #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 <QGraphicsSceneDragDropEvent> #include <QIcon> #include <QMenu> +#include <QMimeData> #include <QVBoxLayout> PlacesPanel::PlacesPanel(QWidget* parent) : @@ -174,6 +169,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")); @@ -190,7 +186,11 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) 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 { @@ -208,7 +208,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) } if (!isDevice) { - editAction = menu.addAction(QIcon::fromTheme("document-properties"), i18nc("@item:inmenu", "Edit...")); + editAction = menu.addAction(QIcon::fromTheme("edit-entry"), i18nc("@item:inmenu", "Edit...")); } QAction* removeAction = nullptr; @@ -248,6 +248,8 @@ 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) { 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. */ |
