2 * SPDX-FileCopyrightText: 2006-2009 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2006 Gregor Kališnik <gregor@podnapisi.net>
5 * SPDX-License-Identifier: GPL-2.0-or-later
11 #include "dolphin_export.h"
12 #include "dolphintabwidget.h"
13 #include "tooltips/tooltipmanager.h"
15 #include "config-dolphin.h"
17 #include <KIO/StatJob>
18 #include <kio/fileundomanager.h>
19 #include <kparts/part.h>
28 typedef KIO::FileUndoManager::CommandType CommandType
;
30 class DolphinItemListView
;
32 class KItemListContainer
;
36 class VersionControlObserver
;
39 class QGraphicsSceneDragDropEvent
;
42 class QRegularExpression
;
45 * @short Represents a view for the directory content.
47 * View modes for icons, compact and details are supported. It's
57 class DOLPHIN_EXPORT DolphinView
: public QWidget
63 * Defines the view mode for a directory. The
64 * view mode is automatically updated if the directory itself
65 * defines a view mode (see class ViewProperties for details).
69 * The items are shown as icons with a name-label below.
74 * The icon, the name and the size of the items are
75 * shown per default as a table.
80 * The items are shown as icons with the name-label aligned
87 * @param url Specifies the content which should be shown.
88 * @param parent Parent widget of the view.
90 DolphinView(const QUrl
&url
, QWidget
*parent
);
92 ~DolphinView() override
;
95 * Returns the current active URL, where all actions are applied.
96 * The URL navigator is synchronized with this URL.
101 * If \a active is true, the view will marked as active. The active
102 * view is defined as view where all actions are applied to.
104 void setActive(bool active
);
105 bool isActive() const;
108 * Changes the view mode for the current directory to \a mode.
109 * If the view properties should be remembered for each directory
110 * (GeneralSettings::globalViewProps() returns false), then the
111 * changed view mode will be stored automatically.
113 void setViewMode(Mode mode
);
114 Mode
viewMode() const;
117 * Enables or disables a mode for quick and easy selection of items.
119 void setSelectionModeEnabled(bool enabled
);
120 bool selectionMode() const;
123 * Turns on the file preview for the all files of the current directory,
124 * if \a show is true.
125 * If the view properties should be remembered for each directory
126 * (GeneralSettings::globalViewProps() returns false), then the
127 * preview setting will be stored automatically.
129 void setPreviewsShown(bool show
);
130 bool previewsShown() const;
133 * Shows all hidden files of the current directory,
134 * if \a show is true.
135 * If the view properties should be remembered for each directory
136 * (GeneralSettings::globalViewProps() returns false), then the
137 * show hidden file setting will be stored automatically.
139 void setHiddenFilesShown(bool show
);
140 bool hiddenFilesShown() const;
143 * Turns on sorting by groups if \a enable is true.
145 void setGroupedSorting(bool grouped
);
146 bool groupedSorting() const;
149 * Returns the items of the view.
151 KFileItemList
items() const;
154 * @return The number of items. itemsCount() is faster in comparison
155 * to items().count().
157 int itemsCount() const;
160 * Returns the selected items. The list is empty if no item has been
163 KFileItemList
selectedItems() const;
166 * Returns the number of selected items (this is faster than
167 * invoking selectedItems().count()).
169 int selectedItemsCount() const;
172 * Marks the items indicated by \p urls to get selected after the
173 * directory DolphinView::url() has been loaded. Note that nothing
174 * gets selected if no loading of a directory has been triggered
175 * by DolphinView::setUrl() or DolphinView::reload().
177 void markUrlsAsSelected(const QList
<QUrl
> &urls
);
180 * Marks the item indicated by \p url to be scrolled to and as the
181 * current item after directory DolphinView::url() has been loaded.
183 void markUrlAsCurrent(const QUrl
&url
);
186 * All items that match the regular expression \a regexp will get selected
187 * if \a enabled is true and deselected if \a enabled is false.
189 * Note that to match the whole string the pattern should be anchored:
190 * - you can anchor the pattern with QRegularExpression::anchoredPattern()
191 * - if you use QRegularExpresssion::wildcardToRegularExpression(), don't use
192 * QRegularExpression::anchoredPattern() as the former already returns an
195 void selectItems(const QRegularExpression
®exp
, bool enabled
);
198 * Sets the zoom level to \a level. It is assured that the used
199 * level is adjusted to be inside the range ZoomLevelInfo::minimumLevel() and
200 * ZoomLevelInfo::maximumLevel().
202 void setZoomLevel(int level
);
203 int zoomLevel() const;
206 * Resets the view's icon size to the default value
208 void resetZoomLevel();
211 * Updates the view properties of the current URL to the
212 * sorting given by \a role.
214 void setSortRole(const QByteArray
&role
);
215 QByteArray
sortRole() const;
218 * Updates the view properties of the current URL to the
219 * sort order given by \a order.
221 void setSortOrder(Qt::SortOrder order
);
222 Qt::SortOrder
sortOrder() const;
225 * Updates the view properties of the current URL to the
226 * grouping given by \a role.
228 void setGroupRole(const QByteArray
&role
);
229 QByteArray
groupRole() const;
232 * Updates the view properties of the current URL to the
233 * sort order given by \a order.
235 void setGroupOrder(Qt::SortOrder order
);
236 Qt::SortOrder
groupOrder() const;
238 /** Sets a separate sorting with folders first (true) or a mixed sorting of files and folders (false). */
239 void setSortFoldersFirst(bool foldersFirst
);
240 bool sortFoldersFirst() const;
242 /** Sets a separate sorting with hidden files and folders last (true) or not (false). */
243 void setSortHiddenLast(bool hiddenLast
);
244 bool sortHiddenLast() const;
246 /** Sets the additional information which should be shown for the items. */
247 void setVisibleRoles(const QList
<QByteArray
> &roles
);
249 /** Returns the additional information which should be shown for the items. */
250 QList
<QByteArray
> visibleRoles() const;
253 * Refreshes the view to get synchronized with the settings (e.g. icons size,
259 * Saves the current settings (e.g. icons size, font, ..).
261 void writeSettings();
264 * Filters the currently shown items by \a nameFilter. All items
265 * which contain the given filter string will be shown.
267 void setNameFilter(const QString
&nameFilter
);
268 QString
nameFilter() const;
271 * Filters the currently shown items by \a filters. All items
272 * whose content-type matches those given by the list of filters
275 void setMimeTypeFilters(const QStringList
&filters
);
276 QStringList
mimeTypeFilters() const;
279 * Tells the view to generate an updated status bar text. The result
280 * is returned through the statusBarTextChanged(QString statusBarText) signal.
281 * It will carry a textual representation of the state of the current
282 * folder or selected items, suitable for use in the status bar.
283 * Any pending requests of status bar text are killed.
285 void requestStatusBarText();
288 * Returns the version control actions that are provided for the items \p items.
289 * Usually the actions are presented in the context menu.
291 QList
<QAction
*> versionControlActions(const KFileItemList
&items
) const;
294 * Returns the state of the paste action:
295 * first is whether the action should be enabled
296 * second is the text for the action
298 QPair
<bool, QString
> pasteInfo() const;
301 * If \a tabsForFiles is true, the signal tabRequested() will also
302 * emitted also for files. Per default tabs for files is disabled
303 * and hence the signal tabRequested() will only be emitted for
306 void setTabsForFilesEnabled(bool tabsForFiles
);
307 bool isTabsForFilesEnabled() const;
310 * Returns true if the current view allows folders to be expanded,
311 * i.e. presents a hierarchical view to the user.
313 bool itemsExpandable() const;
316 * @returns true if the @p item is one of the items() of this view and
317 * is currently expanded. false otherwise.
318 * Only directories in view modes that allow expanding can ever be expanded.
320 bool isExpanded(const KFileItem
&item
) const;
323 * Restores the view state (current item, contents position, details view expansion state)
325 void restoreState(QDataStream
&stream
);
328 * Saves the view state (current item, contents position, details view expansion state)
330 void saveState(QDataStream
&stream
);
333 * Returns the root item which represents the current URL.
335 KFileItem
rootItem() const;
338 * Sets a context that is used for remembering the view-properties.
339 * Per default the context is empty and the path of the currently set URL
340 * is used for remembering the view-properties. Setting a custom context
341 * makes sense if specific types of URLs (e.g. search-URLs) should
342 * share common view-properties.
344 void setViewPropertiesContext(const QString
&context
);
345 QString
viewPropertiesContext() const;
348 * Checks if the given \a item can be opened as folder (e.g. archives).
349 * This function will also adjust the \a url (e.g. change the protocol).
350 * @return a valid and adjusted url if the item can be opened as folder,
351 * otherwise return an empty url.
353 static QUrl
openItemAsFolderUrl(const KFileItem
&item
, const bool browseThroughArchives
= true);
356 * Hides tooltip displayed over element.
358 void hideToolTip(const ToolTipManager::HideBehavior behavior
= ToolTipManager::HideBehavior::Later
);
361 * Check if the space key should be handled as a normal key, even if it's
362 * used as a keyboard shortcut.
366 bool handleSpaceAsNormalKey() const;
368 /** Activates the view if the item list container gets focus. */
369 bool eventFilter(QObject
*watched
, QEvent
*event
) override
;
372 * Returns whether the folder represented by the current URL is writable.
374 bool isFolderWritable() const;
377 * @returns the height of the scrollbar at the bottom of the view or zero if no such scroll bar is visible.
379 int horizontalScrollBarHeight() const;
382 * Set the offset for any view items that small statusbar would otherwise
383 * cover. For example, in compact view this is used to make sure no
384 * item is covered by statusbar.
386 void setStatusBarOffset(int offset
);
393 * Changes the directory to \a url. If the current directory is equal to
394 * \a url, nothing will be done (use DolphinView::reload() instead).
396 void setUrl(const QUrl
&url
);
400 * @see DolphinView::selectedItems()
405 * Inverts the current selection: selected items get unselected,
406 * unselected items get selected.
407 * @see DolphinView::selectedItems()
409 void invertSelection();
411 void clearSelection();
414 * Triggers the renaming of the currently selected items, where
415 * the user must input a new name for the items.
417 void renameSelectedItems();
420 * Moves all selected items to the trash.
422 void trashSelectedItems();
425 * Deletes all selected items.
427 void deleteSelectedItems();
430 * Copies all selected items to the clipboard and marks
433 void cutSelectedItemsToClipboard();
435 /** Copies all selected items to the clipboard. */
436 void copySelectedItemsToClipboard();
439 * Copies all selected items to @p destinationUrl.
441 void copySelectedItems(const KFileItemList
&selection
, const QUrl
&destinationUrl
);
444 * Moves all selected items to @p destinationUrl.
446 void moveSelectedItems(const KFileItemList
&selection
, const QUrl
&destinationUrl
);
448 /** Pastes the clipboard data to this view. */
452 * Pastes the clipboard data into the currently selected
453 * folder. If the current selection is not exactly one folder, no
454 * paste operation is done.
456 void pasteIntoFolder();
459 * Copies the path of the first selected KFileItem into Clipboard.
461 void copyPathToClipboard();
464 * Creates duplicates of selected items, appending "copy"
467 void duplicateSelectedItems();
470 * Handles a drop of @p dropEvent onto widget @p dropWidget and destination @p destUrl
472 void dropUrls(const QUrl
&destUrl
, QDropEvent
*dropEvent
, QWidget
*dropWidget
);
477 * Applies the state that has been restored by restoreViewState()
480 void updateViewState();
484 * Is emitted if the view has been activated by e. g. a mouse click.
488 /** Is emitted if the URL of the view has been changed to \a url. */
489 void urlChanged(const QUrl
&url
);
492 * Is emitted when clicking on an item with the left mouse button.
494 void itemActivated(const KFileItem
&item
);
497 * Is emitted when clicking on a file with the middle mouse button.
498 * @note: This will not be emitted for folders or file archives that will/can be opened like folders.
500 void fileMiddleClickActivated(const KFileItem
&item
);
503 * Is emitted when multiple items have been activated by e. g.
504 * context menu open with.
506 void itemsActivated(const KFileItemList
&items
);
509 * Is emitted if items have been added or deleted.
511 void itemCountChanged();
514 * Is emitted if a new tab should be opened for the URL \a url.
516 void tabRequested(const QUrl
&url
);
519 * Is emitted if a new tab should be opened for the URL \a url and set as active.
521 void activeTabRequested(const QUrl
&url
);
524 * Is emitted if a new window should be opened for the URL \a url.
526 void windowRequested(const QUrl
&url
);
529 * Is emitted if the view mode (IconsView, DetailsView,
530 * PreviewsView) has been changed.
532 void modeChanged(DolphinView::Mode current
, DolphinView::Mode previous
);
534 /** Is emitted if the 'show preview' property has been changed. */
535 void previewsShownChanged(bool shown
);
537 /** Is emitted if the 'show hidden files' property has been changed. */
538 void hiddenFilesShownChanged(bool shown
);
540 /** Is emitted if the 'grouped sorting' property has been changed. */
541 void groupedSortingChanged(bool groupedSorting
);
543 /** Is emitted in reaction to a requestStatusBarText() call.
544 * @see requestStatusBarText() */
545 void statusBarTextChanged(QString statusBarText
);
547 /** Is emitted if the sorting by name, size or date has been changed. */
548 void sortRoleChanged(const QByteArray
&role
);
550 /** Is emitted if the sort order (ascending or descending) has been changed. */
551 void sortOrderChanged(Qt::SortOrder order
);
553 /** Is emitted if the grouping by name, size or date has been changed. */
554 void groupRoleChanged(const QByteArray
&role
);
556 /** Is emitted if the group order (ascending or descending) has been changed. */
557 void groupOrderChanged(Qt::SortOrder order
);
560 * Is emitted if the sorting of files and folders (separate with folders
561 * first or mixed) has been changed.
563 void sortFoldersFirstChanged(bool foldersFirst
);
566 * Is emitted if the sorting of hidden files has been changed.
568 void sortHiddenLastChanged(bool hiddenLast
);
570 /** Is emitted if the additional information shown for this view has been changed. */
571 void visibleRolesChanged(const QList
<QByteArray
> ¤t
, const QList
<QByteArray
> &previous
);
573 /** Is emitted if the zoom level has been changed by zooming in or out. */
574 void zoomLevelChanged(int current
, int previous
);
577 * Is emitted if information of an item is requested to be shown e. g. in the panel.
578 * If item is null, no item information request is pending.
580 void requestItemInfo(const KFileItem
&item
);
583 * Is emitted whenever the selection has been changed.
585 void selectionChanged(const KFileItemList
&selection
);
588 * Is emitted if a context menu is requested for the item \a item,
589 * which is part of \a url. If the item is null, the context menu
590 * for the URL should be shown.
592 void requestContextMenu(const QPoint
&pos
, const KFileItem
&item
, const KFileItemList
&selectedItems
, const QUrl
&url
);
595 * Is emitted if an information message with the content \a msg
598 void infoMessage(const QString
&msg
);
601 * Is emitted if an error message with the content \a msg
604 void errorMessage(const QString
&message
, const int kioErrorCode
);
607 * Is emitted if an "operation completed" message with the content \a msg
610 void operationCompletedMessage(const QString
&msg
);
613 * Is emitted after DolphinView::setUrl() has been invoked and
614 * the current directory is loaded. If this signal is emitted,
615 * it is assured that the view contains already the correct root
616 * URL and property settings.
618 void directoryLoadingStarted();
621 * Is emitted after the directory triggered by DolphinView::setUrl()
624 void directoryLoadingCompleted();
627 * Is emitted after the directory loading triggered by DolphinView::setUrl()
630 void directoryLoadingCanceled();
633 * Is emitted after DolphinView::setUrl() has been invoked and provides
634 * the information how much percent of the current directory have been loaded.
636 void directoryLoadingProgress(int percent
);
639 * Is emitted if the sorting is done asynchronously and provides the
640 * progress information of the sorting.
642 void directorySortingProgress(int percent
);
645 * Emitted when the file-item-model emits redirection.
646 * Testcase: fish://localhost
648 void redirection(const QUrl
&oldUrl
, const QUrl
&newUrl
);
651 * Is emitted when the URL set by DolphinView::setUrl() represents a file.
652 * In this case no signal errorMessage() will be emitted.
654 void urlIsFileError(const QUrl
&url
);
657 * Is emitted when the write state of the folder has been changed. The application
658 * should disable all actions like "Create New..." that depend on the write
661 void writeStateChanged(bool isFolderWritable
);
664 * Is emitted if the URL should be changed to the previous URL of the
665 * history (e.g. because the "back"-mousebutton has been pressed).
667 void goBackRequested();
670 * Is emitted if the URL should be changed to the next URL of the
671 * history (e.g. because the "next"-mousebutton has been pressed).
673 void goForwardRequested();
676 * Used to request either entering or leaving of selection mode
677 * Entering is typically requested on press and hold.
678 * Leaving by pressing Escape when no item is selected.
680 void selectionModeChangeRequested(bool enabled
);
683 * Is emitted when the user wants to move the focus to another view.
685 void toggleActiveViewRequested();
688 * Is emitted when the user clicks a tag or a link
689 * in the metadata widget of a tooltip.
691 void urlActivated(const QUrl
&url
);
693 void goUpRequested();
695 void fileItemsChanged(const KFileItemList
&changedFileItems
);
698 * Emitted when the current directory of the model was removed.
700 void currentDirectoryRemoved();
703 * Emitted when the view's background is double-clicked.
704 * Used to trigger an user configured action.
706 void doubleClickViewBackground(Qt::MouseButton button
);
709 /** Changes the zoom level if Control is pressed during a wheel event. */
710 void wheelEvent(QWheelEvent
*event
) override
;
712 void hideEvent(QHideEvent
*event
) override
;
713 bool event(QEvent
*event
) override
;
717 * Marks the view as active (DolphinView:isActive() will return true)
718 * and emits the 'activated' signal if it is not already active.
722 void slotItemActivated(int index
);
723 void slotItemsActivated(const KItemSet
&indexes
);
724 void slotItemMiddleClicked(int index
);
725 void slotItemContextMenuRequested(int index
, const QPointF
&pos
);
726 void slotViewContextMenuRequested(const QPointF
&pos
);
727 void slotHeaderContextMenuRequested(const QPointF
&pos
);
728 void slotHeaderColumnWidthChangeFinished(const QByteArray
&role
, qreal current
);
729 void slotSidePaddingWidthChanged(qreal leftPaddingWidth
, qreal rightPaddingWidth
);
730 void slotItemHovered(int index
);
731 void slotItemUnhovered(int index
);
732 void slotItemDropEvent(int index
, QGraphicsSceneDragDropEvent
*event
);
733 void slotModelChanged(KItemModelBase
*current
, KItemModelBase
*previous
);
734 void slotMouseButtonPressed(int itemIndex
, Qt::MouseButtons buttons
);
735 void slotSelectedItemTextPressed(int index
);
736 void slotItemCreatedFromJob(KIO::Job
*, const QUrl
&, const QUrl
&to
);
737 void slotItemLinkCreatedFromJob(KIO::Job
*, const QUrl
&, const QString
&, const QUrl
&to
);
738 void slotIncreaseZoom();
739 void slotDecreaseZoom();
743 * Is called when new items get pasted or dropped.
745 void slotItemCreated(const QUrl
&url
);
747 * Is called after all pasted or dropped items have been copied to destination.
749 void slotJobResult(KJob
*job
);
752 * Emits the signal \a selectionChanged() with a small delay. This is
753 * because getting all file items for the selection can be an expensive
754 * operation. Fast selection changes are collected in this case and
755 * the signal is emitted only after no selection change has been done
756 * within a small delay.
758 void slotSelectionChanged(const KItemSet
¤t
, const KItemSet
&previous
);
761 * Is called by emitDelayedSelectionChangedSignal() and emits the
762 * signal \a selectionChanged() with all selected file items as parameter.
764 void emitSelectionChangedSignal();
767 * Helper method for DolphinView::requestStatusBarText().
768 * Calculates the amount of folders and files and their total size in
769 * response to a KStatJob::result(), then calls emitStatusBarText().
770 * @see requestStatusBarText()
771 * @see emitStatusBarText()
773 void slotStatJobResult(KJob
*job
);
776 * Updates the view properties of the current URL to the
777 * sorting of files and folders (separate with folders first or mixed) given by \a foldersFirst.
779 void updateSortFoldersFirst(bool foldersFirst
);
782 * Updates the view properties of the current URL to the
783 * sorting of hidden files given by \a hiddenLast.
785 void updateSortHiddenLast(bool hiddenLast
);
788 * Indicates in the status bar that the delete operation
789 * of the job \a job has been finished.
791 void slotDeleteFileFinished(KJob
*job
);
794 * Indicates in the status bar that the trash operation
795 * of the job \a job has been finished.
797 void slotTrashFileFinished(KJob
*job
);
800 * Invoked when the rename job is done, for error handling.
802 void slotRenamingResult(KJob
*job
);
805 * Invoked when the file item model has started the loading
806 * of the directory specified by DolphinView::url().
808 void slotDirectoryLoadingStarted();
811 * Invoked when the file item model indicates that the loading of a directory has
812 * been completed. Assures that pasted items and renamed items get selected.
814 void slotDirectoryLoadingCompleted();
817 * Invoked when the file item model indicates that the loading of a directory has
820 void slotDirectoryLoadingCanceled();
823 * Is invoked when items of KFileItemModel have been changed.
825 void slotItemsChanged();
828 * Is invoked when the sort order has been changed by the user by clicking
829 * on a header item. The view properties of the directory will get updated.
831 void slotSortOrderChangedByHeader(Qt::SortOrder current
, Qt::SortOrder previous
);
834 * Is invoked when the sort role has been changed by the user by clicking
835 * on a header item. The view properties of the directory will get updated.
837 void slotSortRoleChangedByHeader(const QByteArray
¤t
, const QByteArray
&previous
);
840 * Is invoked when the visible roles have been changed by the user by dragging
841 * a header item. The view properties of the directory will get updated.
843 void slotVisibleRolesChangedByHeader(const QList
<QByteArray
> ¤t
, const QList
<QByteArray
> &previous
);
845 void slotRoleEditingCanceled();
846 void slotRoleEditingFinished(int index
, const QByteArray
&role
, const QVariant
&value
);
849 * Observes the item with the URL \a url. As soon as the directory
850 * model indicates that the item is available, the item will
851 * get selected and it is assured that the item stays visible.
853 void observeCreatedItem(const QUrl
&url
);
856 * Selects the next item after prev selection deleted/trashed
858 void selectNextItem();
861 * Called when a redirection happens.
862 * Testcase: fish://localhost
864 void slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
);
866 void slotTwoClicksRenamingTimerTimeout();
868 void onDirectoryLoadingCompletedAfterJob();
871 void loadDirectory(const QUrl
&url
, bool reload
= false);
874 * Applies the view properties which are defined by the current URL
875 * to the DolphinView properties. The view properties are read from a
876 * .directory file either in the current directory, or in the
877 * share/apps/dolphin/view_properties/ subfolder of the user's .kde folder.
879 void applyViewProperties();
882 * Applies the given view properties to the DolphinView.
884 void applyViewProperties(const ViewProperties
&props
);
887 * Applies the m_mode property to the corresponding
888 * itemlayout-property of the KItemListView.
890 void applyModeToView();
893 * Changes the current view based on the content of the directory.
895 void applyDynamicView();
897 enum Selection
{ HasSelection
, NoSelection
};
899 * Helper method for DolphinView::requestStatusBarText().
900 * Generates the status bar text from the parameters and
901 * then emits statusBarTextChanged().
902 * @param totalFileSize the sum of the sizes of the files
903 * @param selection if HasSelection is passed, the emitted status bar text will say
904 * that the folders and files which are counted here are selected.
906 void emitStatusBarText(const int folderCount
, const int fileCount
, KIO::filesize_t totalFileSize
, const Selection selection
);
909 * Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
910 * Pastes the clipboard data into the URL \a url.
912 void pasteToUrl(const QUrl
&url
);
915 * Returns a list of URLs for all selected items. The list is
916 * simplified, so that when the URLs are part of different tree
917 * levels, only the parent is returned.
919 QList
<QUrl
> simplifiedSelectedUrls() const;
922 * Returns the MIME data for all selected items.
924 QMimeData
*selectionMimeData() const;
927 * Updates m_isFolderWritable dependent on whether the folder represented by
928 * the current URL is writable. If the state has changed, the signal
929 * writeStateChanged() will be emitted.
931 void updateWritableState();
934 * @return The current URL if no viewproperties-context is given (see
935 * DolphinView::viewPropertiesContext(), otherwise the context
938 QUrl
viewPropertiesUrl() const;
941 * Clears the selection and updates current item and selection according to the parameters
943 * @param current URL to be set as current
944 * @param selected list of selected items
946 void forceUrlsSelection(const QUrl
¤t
, const QList
<QUrl
> &selected
);
948 void abortTwoClicksRenaming();
950 void updatePlaceholderLabel();
952 bool tryShowNameToolTip(QHelpEvent
*event
);
955 void updatePalette();
956 void showLoadingPlaceholder();
960 bool m_assureVisibleCurrentIndex
;
961 bool m_isFolderWritable
;
962 bool m_dragging
; // True if a dragging is done. Required to be able to decide whether a
963 // tooltip may be shown when hovering an item.
964 bool m_selectNextItem
;
966 enum class LoadingState
{ Idle
, Loading
, Canceled
, Completed
};
967 LoadingState m_loadingState
= LoadingState::Idle
;
970 QString m_viewPropertiesContext
;
972 QList
<QByteArray
> m_visibleRoles
;
974 QPointer
<KIO::StatJob
> m_statJobForStatusBarText
;
976 QVBoxLayout
*m_topLayout
;
978 KFileItemModel
*m_model
;
979 DolphinItemListView
*m_view
;
980 KItemListContainer
*m_container
;
982 ToolTipManager
*m_toolTipManager
;
984 QTimer
*m_selectionChangedTimer
;
986 QUrl m_currentItemUrl
; // Used for making the view to remember the current URL after F5
987 bool m_scrollToCurrentItem
; // Used for marking we need to scroll to current item or not
988 QPoint m_restoredContentsPosition
;
990 // Used for tracking the accumulated scroll amount (for zooming with high
991 // resolution scroll wheels)
992 int m_controlWheelAccumulatedDelta
;
994 QList
<QUrl
> m_selectedUrls
; // Used for making the view to remember selections after F5 and file operations
995 bool m_clearSelectionBeforeSelectingNewItems
;
996 bool m_markFirstNewlySelectedItemAsCurrent
;
997 /// Decides whether items created by jobs should automatically be selected.
998 bool m_selectJobCreatedItems
;
1000 VersionControlObserver
*m_versionControlObserver
;
1002 QTimer
*m_twoClicksRenamingTimer
;
1003 QUrl m_twoClicksRenamingItemUrl
;
1004 QLabel
*m_placeholderLabel
;
1005 QTimer
*m_showLoadingPlaceholderTimer
;
1007 /// The information roleIndex of the list column header currently hovered
1008 std::optional
<int> m_hoveredColumnHeaderIndex
;
1010 /// Used for selection mode. @see setSelectionMode()
1011 std::unique_ptr
<QProxyStyle
> m_proxyStyle
;
1014 friend class TestBase
;
1015 friend class DolphinDetailsViewTest
;
1016 friend class DolphinMainWindowTest
;
1017 friend class DolphinPart
; // Accesses m_model
1018 void updateSelectionState();
1021 /// Allow using DolphinView::Mode in QVariant
1022 Q_DECLARE_METATYPE(DolphinView::Mode
)
1024 #endif // DOLPHINVIEW_H