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