]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinview.h
d1ecf74ba754d4b37356d2ebf4f89866ab326fb3
[dolphin.git] / src / views / dolphinview.h
1 /*
2 * SPDX-FileCopyrightText: 2006-2009 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2006 Gregor Kališnik <gregor@podnapisi.net>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #ifndef DOLPHINVIEW_H
9 #define DOLPHINVIEW_H
10
11 #include "dolphintabwidget.h"
12 #include "dolphin_export.h"
13 #include "tooltips/tooltipmanager.h"
14
15 #include <KFileItem>
16 #include <KIO/Job>
17 #include "config-dolphin.h"
18 #include <kio/fileundomanager.h>
19 #include <kparts/part.h>
20
21 #include <QMimeData>
22 #include <QPointer>
23 #include <QUrl>
24 #include <QWidget>
25
26 typedef KIO::FileUndoManager::CommandType CommandType;
27 class QVBoxLayout;
28 class DolphinItemListView;
29 class KFileItemModel;
30 class KItemListContainer;
31 class KItemModelBase;
32 class KItemSet;
33 class ToolTipManager;
34 class VersionControlObserver;
35 class ViewProperties;
36 class QLabel;
37 class QGraphicsSceneDragDropEvent;
38 class QHelpEvent;
39 class QRegularExpression;
40
41 /**
42 * @short Represents a view for the directory content.
43 *
44 * View modes for icons, compact and details are supported. It's
45 * possible to adjust:
46 * - sort order
47 * - sort type
48 * - show hidden files
49 * - show previews
50 * - enable grouping
51 */
52 class DOLPHIN_EXPORT DolphinView : public QWidget
53 {
54 Q_OBJECT
55
56 public:
57 /**
58 * Defines the view mode for a directory. The
59 * view mode is automatically updated if the directory itself
60 * defines a view mode (see class ViewProperties for details).
61 */
62 enum Mode
63 {
64 /**
65 * The items are shown as icons with a name-label below.
66 */
67 IconsView = 0,
68
69 /**
70 * The icon, the name and the size of the items are
71 * shown per default as a table.
72 */
73 DetailsView,
74
75 /**
76 * The items are shown as icons with the name-label aligned
77 * to the right side.
78 */
79 CompactView
80 };
81
82 /**
83 * @param url Specifies the content which should be shown.
84 * @param parent Parent widget of the view.
85 */
86 DolphinView(const QUrl& url, QWidget* parent);
87
88 ~DolphinView() override;
89
90 /**
91 * Returns the current active URL, where all actions are applied.
92 * The URL navigator is synchronized with this URL.
93 */
94 QUrl url() const;
95
96 /**
97 * If \a active is true, the view will marked as active. The active
98 * view is defined as view where all actions are applied to.
99 */
100 void setActive(bool active);
101 bool isActive() const;
102
103 /**
104 * Changes the view mode for the current directory to \a mode.
105 * If the view properties should be remembered for each directory
106 * (GeneralSettings::globalViewProps() returns false), then the
107 * changed view mode will be stored automatically.
108 */
109 void setMode(Mode mode);
110 Mode mode() const;
111
112 /**
113 * Turns on the file preview for the all files of the current directory,
114 * if \a show is true.
115 * If the view properties should be remembered for each directory
116 * (GeneralSettings::globalViewProps() returns false), then the
117 * preview setting will be stored automatically.
118 */
119 void setPreviewsShown(bool show);
120 bool previewsShown() const;
121
122 /**
123 * Shows all hidden 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 * show hidden file setting will be stored automatically.
128 */
129 void setHiddenFilesShown(bool show);
130 bool hiddenFilesShown() const;
131
132 /**
133 * Turns on sorting by groups if \a enable is true.
134 */
135 void setGroupedSorting(bool grouped);
136 bool groupedSorting() const;
137
138 /**
139 * Returns the items of the view.
140 */
141 KFileItemList items() const;
142
143 /**
144 * @return The number of items. itemsCount() is faster in comparison
145 * to items().count().
146 */
147 int itemsCount() const;
148
149 /**
150 * Returns the selected items. The list is empty if no item has been
151 * selected.
152 */
153 KFileItemList selectedItems() const;
154
155 /**
156 * Returns the number of selected items (this is faster than
157 * invoking selectedItems().count()).
158 */
159 int selectedItemsCount() const;
160
161 /**
162 * Marks the items indicated by \p urls to get selected after the
163 * directory DolphinView::url() has been loaded. Note that nothing
164 * gets selected if no loading of a directory has been triggered
165 * by DolphinView::setUrl() or DolphinView::reload().
166 */
167 void markUrlsAsSelected(const QList<QUrl> &urls);
168
169 /**
170 * Marks the item indicated by \p url to be scrolled to and as the
171 * current item after directory DolphinView::url() has been loaded.
172 */
173 void markUrlAsCurrent(const QUrl& url);
174
175 /**
176 * All items that match the regular expression \a regexp will get selected
177 * if \a enabled is true and deselected if \a enabled is false.
178 *
179 * Note that to match the whole string the pattern should be anchored:
180 * - you can anchor the pattern with QRegularExpression::anchoredPattern()
181 * - if you use QRegularExpresssion::wildcardToRegularExpression(), don't use
182 * QRegularExpression::anchoredPattern() as the former already returns an
183 * anchored pattern
184 */
185 void selectItems(const QRegularExpression &regexp, bool enabled);
186
187 /**
188 * Sets the zoom level to \a level. It is assured that the used
189 * level is adjusted to be inside the range ZoomLevelInfo::minimumLevel() and
190 * ZoomLevelInfo::maximumLevel().
191 */
192 void setZoomLevel(int level);
193 int zoomLevel() const;
194
195 /**
196 * Resets the view's icon size to the default value
197 */
198 void resetZoomLevel();
199
200 void setSortRole(const QByteArray& role);
201 QByteArray sortRole() const;
202
203 void setSortOrder(Qt::SortOrder order);
204 Qt::SortOrder sortOrder() const;
205
206 /** Sets a separate sorting with folders first (true) or a mixed sorting of files and folders (false). */
207 void setSortFoldersFirst(bool foldersFirst);
208 bool sortFoldersFirst() const;
209
210 /** Sets a separate sorting with hidden files and folders last (true) or not (false). */
211 void setSortHiddenLast(bool hiddenLast);
212 bool sortHiddenLast() const;
213
214 /** Sets the additional information which should be shown for the items. */
215 void setVisibleRoles(const QList<QByteArray>& roles);
216
217 /** Returns the additional information which should be shown for the items. */
218 QList<QByteArray> visibleRoles() const;
219
220 void reload();
221
222 /**
223 * Refreshes the view to get synchronized with the settings (e.g. icons size,
224 * font, ...).
225 */
226 void readSettings();
227
228 /**
229 * Saves the current settings (e.g. icons size, font, ..).
230 */
231 void writeSettings();
232
233 /**
234 * Filters the currently shown items by \a nameFilter. All items
235 * which contain the given filter string will be shown.
236 */
237 void setNameFilter(const QString& nameFilter);
238 QString nameFilter() const;
239
240 /**
241 * Filters the currently shown items by \a filters. All items
242 * whose content-type matches those given by the list of filters
243 * will be shown.
244 */
245 void setMimeTypeFilters(const QStringList& filters);
246 QStringList mimeTypeFilters() const;
247
248 /**
249 * Tells the view to generate an updated status bar text. The result
250 * is returned through the statusBarTextChanged(QString statusBarText) signal.
251 * It will carry a textual representation of the state of the current
252 * folder or selected items, suitable for use in the status bar.
253 * Any pending requests of status bar text are killed.
254 */
255 void requestStatusBarText();
256
257 /**
258 * Returns the version control actions that are provided for the items \p items.
259 * Usually the actions are presented in the context menu.
260 */
261 QList<QAction*> versionControlActions(const KFileItemList& items) const;
262
263 /**
264 * Returns the state of the paste action:
265 * first is whether the action should be enabled
266 * second is the text for the action
267 */
268 QPair<bool, QString> pasteInfo() const;
269
270 /**
271 * If \a tabsForFiles is true, the signal tabRequested() will also
272 * emitted also for files. Per default tabs for files is disabled
273 * and hence the signal tabRequested() will only be emitted for
274 * directories.
275 */
276 void setTabsForFilesEnabled(bool tabsForFiles);
277 bool isTabsForFilesEnabled() const;
278
279 /**
280 * Returns true if the current view allows folders to be expanded,
281 * i.e. presents a hierarchical view to the user.
282 */
283 bool itemsExpandable() const;
284
285 /**
286 * Restores the view state (current item, contents position, details view expansion state)
287 */
288 void restoreState(QDataStream& stream);
289
290 /**
291 * Saves the view state (current item, contents position, details view expansion state)
292 */
293 void saveState(QDataStream& stream);
294
295 /**
296 * Returns the root item which represents the current URL.
297 */
298 KFileItem rootItem() const;
299
300 /**
301 * Sets a context that is used for remembering the view-properties.
302 * Per default the context is empty and the path of the currently set URL
303 * is used for remembering the view-properties. Setting a custom context
304 * makes sense if specific types of URLs (e.g. search-URLs) should
305 * share common view-properties.
306 */
307 void setViewPropertiesContext(const QString& context);
308 QString viewPropertiesContext() const;
309
310 /**
311 * Checks if the given \a item can be opened as folder (e.g. archives).
312 * This function will also adjust the \a url (e.g. change the protocol).
313 * @return a valid and adjusted url if the item can be opened as folder,
314 * otherwise return an empty url.
315 */
316 static QUrl openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives = true);
317
318 /**
319 * Hides tooltip displayed over element.
320 */
321 void hideToolTip(const ToolTipManager::HideBehavior behavior = ToolTipManager::HideBehavior::Later);
322
323 public Q_SLOTS:
324 /**
325 * Changes the directory to \a url. If the current directory is equal to
326 * \a url, nothing will be done (use DolphinView::reload() instead).
327 */
328 void setUrl(const QUrl& url);
329
330 /**
331 * Selects all items.
332 * @see DolphinView::selectedItems()
333 */
334 void selectAll();
335
336 /**
337 * Inverts the current selection: selected items get unselected,
338 * unselected items get selected.
339 * @see DolphinView::selectedItems()
340 */
341 void invertSelection();
342
343 void clearSelection();
344
345 /**
346 * Triggers the renaming of the currently selected items, where
347 * the user must input a new name for the items.
348 */
349 void renameSelectedItems();
350
351 /**
352 * Moves all selected items to the trash.
353 */
354 void trashSelectedItems();
355
356 /**
357 * Deletes all selected items.
358 */
359 void deleteSelectedItems();
360
361 /**
362 * Copies all selected items to the clipboard and marks
363 * the items as cut.
364 */
365 void cutSelectedItemsToClipboard();
366
367 /** Copies all selected items to the clipboard. */
368 void copySelectedItemsToClipboard();
369
370 /**
371 * Copies all selected items to @p destinationUrl.
372 */
373 void copySelectedItems(const KFileItemList &selection, const QUrl &destinationUrl);
374
375 /**
376 * Moves all selected items to @p destinationUrl.
377 */
378 void moveSelectedItems(const KFileItemList &selection, const QUrl &destinationUrl);
379
380 /** Pastes the clipboard data to this view. */
381 void paste();
382
383 /**
384 * Pastes the clipboard data into the currently selected
385 * folder. If the current selection is not exactly one folder, no
386 * paste operation is done.
387 */
388 void pasteIntoFolder();
389
390 /**
391 * Copies the path of the first selected KFileItem into Clipboard.
392 */
393 void copyPathToClipboard();
394
395 /**
396 * Creates duplicates of selected items, appending "copy"
397 * to the end.
398 */
399 void duplicateSelectedItems();
400
401 /**
402 * Handles a drop of @p dropEvent onto widget @p dropWidget and destination @p destUrl
403 */
404 void dropUrls(const QUrl &destUrl, QDropEvent *dropEvent, QWidget *dropWidget);
405
406 void stopLoading();
407
408 /**
409 * Applies the state that has been restored by restoreViewState()
410 * to the view.
411 */
412 void updateViewState();
413
414 /** Activates the view if the item list container gets focus. */
415 bool eventFilter(QObject* watched, QEvent* event) override;
416
417 Q_SIGNALS:
418 /**
419 * Is emitted if the view has been activated by e. g. a mouse click.
420 */
421 void activated();
422
423 /** Is emitted if the URL of the view has been changed to \a url. */
424 void urlChanged(const QUrl& url);
425
426 /**
427 * Is emitted when clicking on an item with the left mouse button.
428 */
429 void itemActivated(const KFileItem &item);
430
431 /**
432 * Is emitted when multiple items have been activated by e. g.
433 * context menu open with.
434 */
435 void itemsActivated(const KFileItemList &items);
436
437 /**
438 * Is emitted if items have been added or deleted.
439 */
440 void itemCountChanged();
441
442 /**
443 * Is emitted if a new tab should be opened for the URL \a url.
444 */
445 void tabRequested(const QUrl& url);
446
447 /**
448 * Is emitted if a new tab should be opened for the URL \a url and set as active.
449 */
450 void activeTabRequested(const QUrl &url);
451
452 /**
453 * Is emitted if a new window should be opened for the URL \a url.
454 */
455 void windowRequested(const QUrl &url);
456
457 /**
458 * Is emitted if the view mode (IconsView, DetailsView,
459 * PreviewsView) has been changed.
460 */
461 void modeChanged(DolphinView::Mode current, DolphinView::Mode previous);
462
463 /** Is emitted if the 'show preview' property has been changed. */
464 void previewsShownChanged(bool shown);
465
466 /** Is emitted if the 'show hidden files' property has been changed. */
467 void hiddenFilesShownChanged(bool shown);
468
469 /** Is emitted if the 'grouped sorting' property has been changed. */
470 void groupedSortingChanged(bool groupedSorting);
471
472 /** Is emitted in reaction to a requestStatusBarText() call.
473 * @see requestStatusBarText() */
474 void statusBarTextChanged(QString statusBarText);
475
476 /** Is emitted if the sorting by name, size or date has been changed. */
477 void sortRoleChanged(const QByteArray& role);
478
479 /** Is emitted if the sort order (ascending or descending) has been changed. */
480 void sortOrderChanged(Qt::SortOrder order);
481
482 /**
483 * Is emitted if the sorting of files and folders (separate with folders
484 * first or mixed) has been changed.
485 */
486 void sortFoldersFirstChanged(bool foldersFirst);
487
488 /**
489 * Is emitted if the sorting of hidden files has been changed.
490 */
491 void sortHiddenLastChanged(bool hiddenLast);
492
493 /** Is emitted if the additional information shown for this view has been changed. */
494 void visibleRolesChanged(const QList<QByteArray>& current,
495 const QList<QByteArray>& previous);
496
497 /** Is emitted if the zoom level has been changed by zooming in or out. */
498 void zoomLevelChanged(int current, int previous);
499
500 /**
501 * Is emitted if information of an item is requested to be shown e. g. in the panel.
502 * If item is null, no item information request is pending.
503 */
504 void requestItemInfo(const KFileItem& item);
505
506 /**
507 * Is emitted whenever the selection has been changed.
508 */
509 void selectionChanged(const KFileItemList& selection);
510
511 /**
512 * Is emitted if a context menu is requested for the item \a item,
513 * which is part of \a url. If the item is null, the context menu
514 * for the URL should be shown.
515 */
516 void requestContextMenu(const QPoint& pos,
517 const KFileItem& item,
518 const KFileItemList &selectedItems,
519 const QUrl& url);
520
521 /**
522 * Is emitted if an information message with the content \a msg
523 * should be shown.
524 */
525 void infoMessage(const QString& msg);
526
527 /**
528 * Is emitted if an error message with the content \a msg
529 * should be shown.
530 */
531 void errorMessage(const QString& msg);
532
533 /**
534 * Is emitted if an "operation completed" message with the content \a msg
535 * should be shown.
536 */
537 void operationCompletedMessage(const QString& msg);
538
539 /**
540 * Is emitted after DolphinView::setUrl() has been invoked and
541 * the current directory is loaded. If this signal is emitted,
542 * it is assured that the view contains already the correct root
543 * URL and property settings.
544 */
545 void directoryLoadingStarted();
546
547 /**
548 * Is emitted after the directory triggered by DolphinView::setUrl()
549 * has been loaded.
550 */
551 void directoryLoadingCompleted();
552
553 /**
554 * Is emitted after the directory loading triggered by DolphinView::setUrl()
555 * has been canceled.
556 */
557 void directoryLoadingCanceled();
558
559 /**
560 * Is emitted after DolphinView::setUrl() has been invoked and provides
561 * the information how much percent of the current directory have been loaded.
562 */
563 void directoryLoadingProgress(int percent);
564
565 /**
566 * Is emitted if the sorting is done asynchronously and provides the
567 * progress information of the sorting.
568 */
569 void directorySortingProgress(int percent);
570
571 /**
572 * Emitted when the file-item-model emits redirection.
573 * Testcase: fish://localhost
574 */
575 void redirection(const QUrl& oldUrl, const QUrl& newUrl);
576
577 /**
578 * Is emitted when the URL set by DolphinView::setUrl() represents a file.
579 * In this case no signal errorMessage() will be emitted.
580 */
581 void urlIsFileError(const QUrl& url);
582
583 /**
584 * Is emitted when the write state of the folder has been changed. The application
585 * should disable all actions like "Create New..." that depend on the write
586 * state.
587 */
588 void writeStateChanged(bool isFolderWritable);
589
590 /**
591 * Is emitted if the URL should be changed to the previous URL of the
592 * history (e.g. because the "back"-mousebutton has been pressed).
593 */
594 void goBackRequested();
595
596 /**
597 * Is emitted if the URL should be changed to the next URL of the
598 * history (e.g. because the "next"-mousebutton has been pressed).
599 */
600 void goForwardRequested();
601
602 /**
603 * Is emitted when the user wants to move the focus to another view.
604 */
605 void toggleActiveViewRequested();
606
607 /**
608 * Is emitted when the user clicks a tag or a link
609 * in the metadata widget of a tooltip.
610 */
611 void urlActivated(const QUrl& url);
612
613 void goUpRequested();
614
615 void fileItemsChanged(const KFileItemList &changedFileItems);
616
617 protected:
618 /** Changes the zoom level if Control is pressed during a wheel event. */
619 void wheelEvent(QWheelEvent* event) override;
620
621 void hideEvent(QHideEvent* event) override;
622 bool event(QEvent* event) override;
623
624 private Q_SLOTS:
625 /**
626 * Marks the view as active (DolphinView:isActive() will return true)
627 * and emits the 'activated' signal if it is not already active.
628 */
629 void activate();
630
631 void slotItemActivated(int index);
632 void slotItemsActivated(const KItemSet &indexes);
633 void slotItemMiddleClicked(int index);
634 void slotItemContextMenuRequested(int index, const QPointF& pos);
635 void slotViewContextMenuRequested(const QPointF& pos);
636 void slotHeaderContextMenuRequested(const QPointF& pos);
637 void slotHeaderColumnWidthChangeFinished(const QByteArray& role, qreal current);
638 void slotSidePaddingWidthChanged(qreal width);
639 void slotItemHovered(int index);
640 void slotItemUnhovered(int index);
641 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
642 void slotModelChanged(KItemModelBase* current, KItemModelBase* previous);
643 void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
644 void slotRenameDialogRenamingFinished(const QList<QUrl>& urls);
645 void slotSelectedItemTextPressed(int index);
646 void slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to);
647 void slotIncreaseZoom();
648 void slotDecreaseZoom();
649 void slotSwipeUp();
650
651 /*
652 * Is called when new items get pasted or dropped.
653 */
654 void slotItemCreated(const QUrl &url);
655 /*
656 * Is called after all pasted or dropped items have been copied to destination.
657 */
658 void slotJobResult(KJob *job);
659
660 /**
661 * Emits the signal \a selectionChanged() with a small delay. This is
662 * because getting all file items for the selection can be an expensive
663 * operation. Fast selection changes are collected in this case and
664 * the signal is emitted only after no selection change has been done
665 * within a small delay.
666 */
667 void slotSelectionChanged(const KItemSet& current, const KItemSet& previous);
668
669 /**
670 * Is called by emitDelayedSelectionChangedSignal() and emits the
671 * signal \a selectionChanged() with all selected file items as parameter.
672 */
673 void emitSelectionChangedSignal();
674
675 /**
676 * Helper method for DolphinView::requestStatusBarText().
677 * Calculates the amount of folders and files and their total size in
678 * response to a KStatJob::result(), then calls emitStatusBarText().
679 * @see requestStatusBarText()
680 * @see emitStatusBarText()
681 */
682 void slotStatJobResult(KJob *job);
683
684 /**
685 * Updates the view properties of the current URL to the
686 * sorting given by \a role.
687 */
688 void updateSortRole(const QByteArray& role);
689
690 /**
691 * Updates the view properties of the current URL to the
692 * sort order given by \a order.
693 */
694 void updateSortOrder(Qt::SortOrder order);
695
696 /**
697 * Updates the view properties of the current URL to the
698 * sorting of files and folders (separate with folders first or mixed) given by \a foldersFirst.
699 */
700 void updateSortFoldersFirst(bool foldersFirst);
701
702 /**
703 * Updates the view properties of the current URL to the
704 * sorting of hidden files given by \a hiddenLast.
705 */
706 void updateSortHiddenLast(bool hiddenLast);
707
708 /**
709 * Indicates in the status bar that the delete operation
710 * of the job \a job has been finished.
711 */
712 void slotDeleteFileFinished(KJob* job);
713
714 /**
715 * Indicates in the status bar that the trash operation
716 * of the job \a job has been finished.
717 */
718 void slotTrashFileFinished(KJob* job);
719
720 /**
721 * Invoked when the rename job is done, for error handling.
722 */
723 void slotRenamingResult(KJob* job);
724
725 /**
726 * Invoked when the file item model has started the loading
727 * of the directory specified by DolphinView::url().
728 */
729 void slotDirectoryLoadingStarted();
730
731 /**
732 * Invoked when the file item model indicates that the loading of a directory has
733 * been completed. Assures that pasted items and renamed items get selected.
734 */
735 void slotDirectoryLoadingCompleted();
736
737 /**
738 * Invoked when the file item model indicates that the loading of a directory has
739 * been canceled.
740 */
741 void slotDirectoryLoadingCanceled();
742
743 /**
744 * Is invoked when items of KFileItemModel have been changed.
745 */
746 void slotItemsChanged();
747
748 /**
749 * Is invoked when the sort order has been changed by the user by clicking
750 * on a header item. The view properties of the directory will get updated.
751 */
752 void slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous);
753
754 /**
755 * Is invoked when the sort role has been changed by the user by clicking
756 * on a header item. The view properties of the directory will get updated.
757 */
758 void slotSortRoleChangedByHeader(const QByteArray& current, const QByteArray& previous);
759
760 /**
761 * Is invoked when the visible roles have been changed by the user by dragging
762 * a header item. The view properties of the directory will get updated.
763 */
764 void slotVisibleRolesChangedByHeader(const QList<QByteArray>& current,
765 const QList<QByteArray>& previous);
766
767 void slotRoleEditingCanceled();
768 void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
769
770 /**
771 * Observes the item with the URL \a url. As soon as the directory
772 * model indicates that the item is available, the item will
773 * get selected and it is assured that the item stays visible.
774 */
775 void observeCreatedItem(const QUrl &url);
776
777 /**
778 * Called when a redirection happens.
779 * Testcase: fish://localhost
780 */
781 void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
782
783 void slotTwoClicksRenamingTimerTimeout();
784
785 private:
786 void loadDirectory(const QUrl& url, bool reload = false);
787
788 /**
789 * Applies the view properties which are defined by the current URL
790 * to the DolphinView properties. The view properties are read from a
791 * .directory file either in the current directory, or in the
792 * share/apps/dolphin/view_properties/ subfolder of the user's .kde folder.
793 */
794 void applyViewProperties();
795
796 /**
797 * Applies the given view properties to the DolphinView.
798 */
799 void applyViewProperties(const ViewProperties& props);
800
801 /**
802 * Applies the m_mode property to the corresponding
803 * itemlayout-property of the KItemListView.
804 */
805 void applyModeToView();
806
807 enum Selection {
808 HasSelection,
809 NoSelection
810 };
811 /**
812 * Helper method for DolphinView::requestStatusBarText().
813 * Generates the status bar text from the parameters and
814 * then emits statusBarTextChanged().
815 * @param totalFileSize the sum of the sizes of the files
816 * @param selection if HasSelection is passed, the emitted status bar text will say
817 * that the folders and files which are counted here are selected.
818 */
819 void emitStatusBarText(const int folderCount, const int fileCount,
820 KIO::filesize_t totalFileSize, const Selection selection);
821
822 /**
823 * Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
824 * Pastes the clipboard data into the URL \a url.
825 */
826 void pasteToUrl(const QUrl& url);
827
828 /**
829 * Returns a list of URLs for all selected items. The list is
830 * simplified, so that when the URLs are part of different tree
831 * levels, only the parent is returned.
832 */
833 QList<QUrl> simplifiedSelectedUrls() const;
834
835 /**
836 * Returns the MIME data for all selected items.
837 */
838 QMimeData* selectionMimeData() const;
839
840 /**
841 * Updates m_isFolderWritable dependent on whether the folder represented by
842 * the current URL is writable. If the state has changed, the signal
843 * writeableStateChanged() will be emitted.
844 */
845 void updateWritableState();
846
847 /**
848 * @return The current URL if no viewproperties-context is given (see
849 * DolphinView::viewPropertiesContext(), otherwise the context
850 * is returned.
851 */
852 QUrl viewPropertiesUrl() const;
853
854 /**
855 * Clears the selection and updates current item and selection according to the parameters
856 *
857 * @param current URL to be set as current
858 * @param selected list of selected items
859 */
860 void forceUrlsSelection(const QUrl& current, const QList<QUrl>& selected);
861
862 void abortTwoClicksRenaming();
863
864 void updatePlaceholderLabel();
865
866 void tryShowNameToolTip(QHelpEvent* event);
867
868 private:
869 void updatePalette();
870 void showLoadingPlaceholder();
871
872 bool m_active;
873 bool m_tabsForFiles;
874 bool m_assureVisibleCurrentIndex;
875 bool m_isFolderWritable;
876 bool m_dragging; // True if a dragging is done. Required to be able to decide whether a
877 // tooltip may be shown when hovering an item.
878
879 enum class LoadingState {
880 Idle,
881 Loading,
882 Canceled,
883 Completed
884 };
885 LoadingState m_loadingState = LoadingState::Idle;
886
887 QUrl m_url;
888 QString m_viewPropertiesContext;
889 Mode m_mode;
890 QList<QByteArray> m_visibleRoles;
891
892 QPointer<KIO::StatJob> m_statJobForStatusBarText;
893
894 QVBoxLayout* m_topLayout;
895
896 KFileItemModel* m_model;
897 DolphinItemListView* m_view;
898 KItemListContainer* m_container;
899
900 ToolTipManager* m_toolTipManager;
901
902 QTimer* m_selectionChangedTimer;
903
904 QUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5
905 bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not
906 QPoint m_restoredContentsPosition;
907
908 QList<QUrl> m_selectedUrls; // Used for making the view to remember selections after F5
909 bool m_clearSelectionBeforeSelectingNewItems;
910 bool m_markFirstNewlySelectedItemAsCurrent;
911
912 VersionControlObserver* m_versionControlObserver;
913
914 QTimer* m_twoClicksRenamingTimer;
915 QUrl m_twoClicksRenamingItemUrl;
916 QLabel* m_placeholderLabel;
917 QTimer* m_showLoadingPlaceholderTimer;
918
919 // For unit tests
920 friend class TestBase;
921 friend class DolphinDetailsViewTest;
922 friend class DolphinMainWindowTest;
923 friend class DolphinPart; // Accesses m_model
924 };
925
926 /// Allow using DolphinView::Mode in QVariant
927 Q_DECLARE_METATYPE(DolphinView::Mode)
928
929 #endif // DOLPHINVIEW_H