X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/36dfe5795f3e70ad9ac4954544899bf38c919ca7..refs/heads/master:/src/views/dolphinview.h diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index cadf3e754..d50c932df 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -14,7 +14,7 @@ #include "config-dolphin.h" #include -#include +#include #include #include @@ -51,6 +51,8 @@ class QRegularExpression; * - show hidden files * - show previews * - enable grouping + * - grouping order + * - grouping type */ class DOLPHIN_EXPORT DolphinView : public QWidget { @@ -205,12 +207,34 @@ public: */ void resetZoomLevel(); + /** + * Updates the view properties of the current URL to the + * sorting given by \a role. + */ void setSortRole(const QByteArray &role); QByteArray sortRole() const; + /** + * Updates the view properties of the current URL to the + * sort order given by \a order. + */ void setSortOrder(Qt::SortOrder order); Qt::SortOrder sortOrder() const; + /** + * Updates the view properties of the current URL to the + * grouping given by \a role. + */ + void setGroupRole(const QByteArray &role); + QByteArray groupRole() const; + + /** + * Updates the view properties of the current URL to the + * sort order given by \a order. + */ + void setGroupOrder(Qt::SortOrder order); + Qt::SortOrder groupOrder() const; + /** Sets a separate sorting with folders first (true) or a mixed sorting of files and folders (false). */ void setSortFoldersFirst(bool foldersFirst); bool sortFoldersFirst() const; @@ -225,8 +249,6 @@ public: /** Returns the additional information which should be shown for the items. */ QList visibleRoles() const; - void reload(); - /** * Refreshes the view to get synchronized with the settings (e.g. icons size, * font, ...). @@ -335,7 +357,38 @@ public: */ void hideToolTip(const ToolTipManager::HideBehavior behavior = ToolTipManager::HideBehavior::Later); + /** + * Check if the space key should be handled as a normal key, even if it's + * used as a keyboard shortcut. + * + * See BUG 465489 + */ + bool handleSpaceAsNormalKey() const; + + /** Activates the view if the item list container gets focus. */ + bool eventFilter(QObject *watched, QEvent *event) override; + + /** + * Returns whether the folder represented by the current URL is writable. + */ + bool isFolderWritable() const; + + /** + * @returns the height of the scrollbar at the bottom of the view or zero if no such scroll bar is visible. + */ + int horizontalScrollBarHeight() const; + + /** + * Set the offset for any view items that small statusbar would otherwise + * cover. For example, in compact view this is used to make sure no + * item is covered by statusbar. + */ + void setStatusBarOffset(int offset); + public Q_SLOTS: + + void reload(); + /** * Changes the directory to \a url. If the current directory is equal to * \a url, nothing will be done (use DolphinView::reload() instead). @@ -426,9 +479,6 @@ public Q_SLOTS: */ void updateViewState(); - /** Activates the view if the item list container gets focus. */ - bool eventFilter(QObject *watched, QEvent *event) override; - Q_SIGNALS: /** * Is emitted if the view has been activated by e. g. a mouse click. @@ -443,6 +493,12 @@ Q_SIGNALS: */ void itemActivated(const KFileItem &item); + /** + * Is emitted when clicking on a file with the middle mouse button. + * @note: This will not be emitted for folders or file archives that will/can be opened like folders. + */ + void fileMiddleClickActivated(const KFileItem &item); + /** * Is emitted when multiple items have been activated by e. g. * context menu open with. @@ -494,6 +550,12 @@ Q_SIGNALS: /** Is emitted if the sort order (ascending or descending) has been changed. */ void sortOrderChanged(Qt::SortOrder order); + /** Is emitted if the grouping by name, size or date has been changed. */ + void groupRoleChanged(const QByteArray &role); + + /** Is emitted if the group order (ascending or descending) has been changed. */ + void groupOrderChanged(Qt::SortOrder order); + /** * Is emitted if the sorting of files and folders (separate with folders * first or mixed) has been changed. @@ -539,7 +601,7 @@ Q_SIGNALS: * Is emitted if an error message with the content \a msg * should be shown. */ - void errorMessage(const QString &msg); + void errorMessage(const QString &message, const int kioErrorCode); /** * Is emitted if an "operation completed" message with the content \a msg @@ -637,6 +699,12 @@ Q_SIGNALS: */ void currentDirectoryRemoved(); + /** + * Emitted when the view's background is double-clicked. + * Used to trigger an user configured action. + */ + void doubleClickViewBackground(Qt::MouseButton button); + protected: /** Changes the zoom level if Control is pressed during a wheel event. */ void wheelEvent(QWheelEvent *event) override; @@ -658,15 +726,15 @@ private Q_SLOTS: void slotViewContextMenuRequested(const QPointF &pos); void slotHeaderContextMenuRequested(const QPointF &pos); void slotHeaderColumnWidthChangeFinished(const QByteArray &role, qreal current); - void slotSidePaddingWidthChanged(qreal width); + void slotSidePaddingWidthChanged(qreal leftPaddingWidth, qreal rightPaddingWidth); void slotItemHovered(int index); void slotItemUnhovered(int index); void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent *event); void slotModelChanged(KItemModelBase *current, KItemModelBase *previous); void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons); - void slotRenameDialogRenamingFinished(const QList &urls); void slotSelectedItemTextPressed(int index); - void slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to); + void slotItemCreatedFromJob(KIO::Job *, const QUrl &, const QUrl &to); + void slotItemLinkCreatedFromJob(KIO::Job *, const QUrl &, const QString &, const QUrl &to); void slotIncreaseZoom(); void slotDecreaseZoom(); void slotSwipeUp(); @@ -704,18 +772,6 @@ private Q_SLOTS: */ void slotStatJobResult(KJob *job); - /** - * Updates the view properties of the current URL to the - * sorting given by \a role. - */ - void updateSortRole(const QByteArray &role); - - /** - * Updates the view properties of the current URL to the - * sort order given by \a order. - */ - void updateSortOrder(Qt::SortOrder order); - /** * Updates the view properties of the current URL to the * sorting of files and folders (separate with folders first or mixed) given by \a foldersFirst. @@ -809,6 +865,8 @@ private Q_SLOTS: void slotTwoClicksRenamingTimerTimeout(); + void onDirectoryLoadingCompletedAfterJob(); + private: void loadDirectory(const QUrl &url, bool reload = false); @@ -831,6 +889,11 @@ private: */ void applyModeToView(); + /** + * Changes the current view based on the content of the directory. + */ + void applyDynamicView(); + enum Selection { HasSelection, NoSelection }; /** * Helper method for DolphinView::requestStatusBarText(). @@ -863,7 +926,7 @@ private: /** * Updates m_isFolderWritable dependent on whether the folder represented by * the current URL is writable. If the state has changed, the signal - * writeableStateChanged() will be emitted. + * writeStateChanged() will be emitted. */ void updateWritableState(); @@ -886,7 +949,7 @@ private: void updatePlaceholderLabel(); - void tryShowNameToolTip(QHelpEvent *event); + bool tryShowNameToolTip(QHelpEvent *event); private: void updatePalette(); @@ -924,9 +987,15 @@ private: bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not QPoint m_restoredContentsPosition; - QList m_selectedUrls; // Used for making the view to remember selections after F5 + // Used for tracking the accumulated scroll amount (for zooming with high + // resolution scroll wheels) + int m_controlWheelAccumulatedDelta; + + QList m_selectedUrls; // Used for making the view to remember selections after F5 and file operations bool m_clearSelectionBeforeSelectingNewItems; bool m_markFirstNewlySelectedItemAsCurrent; + /// Decides whether items created by jobs should automatically be selected. + bool m_selectJobCreatedItems; VersionControlObserver *m_versionControlObserver; @@ -935,6 +1004,9 @@ private: QLabel *m_placeholderLabel; QTimer *m_showLoadingPlaceholderTimer; + /// The information roleIndex of the list column header currently hovered + std::optional m_hoveredColumnHeaderIndex; + /// Used for selection mode. @see setSelectionMode() std::unique_ptr m_proxyStyle; @@ -943,6 +1015,7 @@ private: friend class DolphinDetailsViewTest; friend class DolphinMainWindowTest; friend class DolphinPart; // Accesses m_model + void updateSelectionState(); }; /// Allow using DolphinView::Mode in QVariant