]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinview.h
Build with QT_NO_KEYWORDS
[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 protected:
597 /** Changes the zoom level if Control is pressed during a wheel event. */
598 void wheelEvent(QWheelEvent* event) override;
599
600 void hideEvent(QHideEvent* event) override;
601 bool event(QEvent* event) override;
602
603 private Q_SLOTS:
604 /**
605 * Marks the view as active (DolphinView:isActive() will return true)
606 * and emits the 'activated' signal if it is not already active.
607 */
608 void activate();
609
610 void slotItemActivated(int index);
611 void slotItemsActivated(const KItemSet& indexes);
612 void slotItemMiddleClicked(int index);
613 void slotItemContextMenuRequested(int index, const QPointF& pos);
614 void slotViewContextMenuRequested(const QPointF& pos);
615 void slotHeaderContextMenuRequested(const QPointF& pos);
616 void slotHeaderColumnWidthChangeFinished(const QByteArray& role, qreal current);
617 void slotItemHovered(int index);
618 void slotItemUnhovered(int index);
619 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
620 void slotModelChanged(KItemModelBase* current, KItemModelBase* previous);
621 void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons);
622 void slotRenameDialogRenamingFinished(const QList<QUrl>& urls);
623 void slotSelectedItemTextPressed(int index);
624 void slotCopyingDone(KIO::Job *, const QUrl &, const QUrl &to);
625 void slotIncreaseZoom();
626 void slotDecreaseZoom();
627 void slotSwipeUp();
628
629 /*
630 * Is called when new items get pasted or dropped.
631 */
632 void slotItemCreated(const QUrl &url);
633 /*
634 * Is called after all pasted or dropped items have been copied to destination.
635 */
636 void slotJobResult(KJob *job);
637
638 /**
639 * Emits the signal \a selectionChanged() with a small delay. This is
640 * because getting all file items for the selection can be an expensive
641 * operation. Fast selection changes are collected in this case and
642 * the signal is emitted only after no selection change has been done
643 * within a small delay.
644 */
645 void slotSelectionChanged(const KItemSet& current, const KItemSet& previous);
646
647 /**
648 * Is called by emitDelayedSelectionChangedSignal() and emits the
649 * signal \a selectionChanged() with all selected file items as parameter.
650 */
651 void emitSelectionChangedSignal();
652
653 /**
654 * Helper method for DolphinView::requestStatusBarText().
655 * Calculates the amount of folders and files and their total size in
656 * response to a KStatJob::result(), then calls emitStatusBarText().
657 * @see requestStatusBarText()
658 * @see emitStatusBarText()
659 */
660 void slotStatJobResult(KJob *job);
661
662 /**
663 * Updates the view properties of the current URL to the
664 * sorting given by \a role.
665 */
666 void updateSortRole(const QByteArray& role);
667
668 /**
669 * Updates the view properties of the current URL to the
670 * sort order given by \a order.
671 */
672 void updateSortOrder(Qt::SortOrder order);
673
674 /**
675 * Updates the view properties of the current URL to the
676 * sorting of files and folders (separate with folders first or mixed) given by \a foldersFirst.
677 */
678 void updateSortFoldersFirst(bool foldersFirst);
679
680 /**
681 * Indicates in the status bar that the delete operation
682 * of the job \a job has been finished.
683 */
684 void slotDeleteFileFinished(KJob* job);
685
686 /**
687 * Indicates in the status bar that the trash operation
688 * of the job \a job has been finished.
689 */
690 void slotTrashFileFinished(KJob* job);
691
692 /**
693 * Invoked when the rename job is done, for error handling.
694 */
695 void slotRenamingResult(KJob* job);
696
697 /**
698 * Invoked when the file item model has started the loading
699 * of the directory specified by DolphinView::url().
700 */
701 void slotDirectoryLoadingStarted();
702
703 /**
704 * Invoked when the file item model indicates that the loading of a directory has
705 * been completed. Assures that pasted items and renamed items get selected.
706 */
707 void slotDirectoryLoadingCompleted();
708
709 /**
710 * Invoked when the file item model indicates that the loading of a directory has
711 * been canceled.
712 */
713 void slotDirectoryLoadingCanceled();
714
715 /**
716 * Is invoked when items of KFileItemModel have been changed.
717 */
718 void slotItemsChanged();
719
720 /**
721 * Is invoked when the sort order has been changed by the user by clicking
722 * on a header item. The view properties of the directory will get updated.
723 */
724 void slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous);
725
726 /**
727 * Is invoked when the sort role has been changed by the user by clicking
728 * on a header item. The view properties of the directory will get updated.
729 */
730 void slotSortRoleChangedByHeader(const QByteArray& current, const QByteArray& previous);
731
732 /**
733 * Is invoked when the visible roles have been changed by the user by dragging
734 * a header item. The view properties of the directory will get updated.
735 */
736 void slotVisibleRolesChangedByHeader(const QList<QByteArray>& current,
737 const QList<QByteArray>& previous);
738
739 void slotRoleEditingCanceled();
740 void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
741
742 /**
743 * Observes the item with the URL \a url. As soon as the directory
744 * model indicates that the item is available, the item will
745 * get selected and it is assured that the item stays visible.
746 */
747 void observeCreatedItem(const QUrl &url);
748
749 /**
750 * Called when a redirection happens.
751 * Testcase: fish://localhost
752 */
753 void slotDirectoryRedirection(const QUrl& oldUrl, const QUrl& newUrl);
754
755 void slotTwoClicksRenamingTimerTimeout();
756
757 private:
758 void loadDirectory(const QUrl& url, bool reload = false);
759
760 /**
761 * Applies the view properties which are defined by the current URL
762 * to the DolphinView properties. The view properties are read from a
763 * .directory file either in the current directory, or in the
764 * share/apps/dolphin/view_properties/ subfolder of the user's .kde folder.
765 */
766 void applyViewProperties();
767
768 /**
769 * Applies the given view properties to the DolphinView.
770 */
771 void applyViewProperties(const ViewProperties& props);
772
773 /**
774 * Applies the m_mode property to the corresponding
775 * itemlayout-property of the KItemListView.
776 */
777 void applyModeToView();
778
779 enum Selection {
780 HasSelection,
781 NoSelection
782 };
783 /**
784 * Helper method for DolphinView::requestStatusBarText().
785 * Generates the status bar text from the parameters and
786 * then emits statusBarTextChanged().
787 * @param totalFileSize the sum of the sizes of the files
788 * @param selection if HasSelection is passed, the emitted status bar text will say
789 * that the folders and files which are counted here are selected.
790 */
791 void emitStatusBarText(const int folderCount, const int fileCount,
792 KIO::filesize_t totalFileSize, const Selection selection);
793
794 /**
795 * Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
796 * Pastes the clipboard data into the URL \a url.
797 */
798 void pasteToUrl(const QUrl& url);
799
800 /**
801 * Returns a list of URLs for all selected items. The list is
802 * simplified, so that when the URLs are part of different tree
803 * levels, only the parent is returned.
804 */
805 QList<QUrl> simplifiedSelectedUrls() const;
806
807 /**
808 * Returns the MIME data for all selected items.
809 */
810 QMimeData* selectionMimeData() const;
811
812 /**
813 * Updates m_isFolderWritable dependent on whether the folder represented by
814 * the current URL is writable. If the state has changed, the signal
815 * writeableStateChanged() will be emitted.
816 */
817 void updateWritableState();
818
819 /**
820 * @return The current URL if no viewproperties-context is given (see
821 * DolphinView::viewPropertiesContext(), otherwise the context
822 * is returned.
823 */
824 QUrl viewPropertiesUrl() const;
825
826 /**
827 * Clears the selection and updates current item and selection according to the parameters
828 *
829 * @param current URL to be set as current
830 * @param selected list of selected items
831 */
832 void forceUrlsSelection(const QUrl& current, const QList<QUrl>& selected);
833
834 void abortTwoClicksRenaming();
835
836 void updatePlaceholderLabel();
837
838 private:
839 void updatePalette();
840
841 bool m_active;
842 bool m_tabsForFiles;
843 bool m_assureVisibleCurrentIndex;
844 bool m_isFolderWritable;
845 bool m_dragging; // True if a dragging is done. Required to be able to decide whether a
846 // tooltip may be shown when hovering an item.
847 bool m_loading;
848
849 QUrl m_url;
850 QString m_viewPropertiesContext;
851 Mode m_mode;
852 QList<QByteArray> m_visibleRoles;
853
854 QPointer<KIO::StatJob> m_statJobForStatusBarText;
855
856 QVBoxLayout* m_topLayout;
857
858 KFileItemModel* m_model;
859 DolphinItemListView* m_view;
860 KItemListContainer* m_container;
861
862 ToolTipManager* m_toolTipManager;
863
864 QTimer* m_selectionChangedTimer;
865
866 QUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5
867 bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not
868 QPoint m_restoredContentsPosition;
869
870 QList<QUrl> m_selectedUrls; // Used for making the view to remember selections after F5
871 bool m_clearSelectionBeforeSelectingNewItems;
872 bool m_markFirstNewlySelectedItemAsCurrent;
873
874 VersionControlObserver* m_versionControlObserver;
875
876 QTimer* m_twoClicksRenamingTimer;
877 QUrl m_twoClicksRenamingItemUrl;
878 QLabel* m_placeholderLabel;
879
880 // For unit tests
881 friend class TestBase;
882 friend class DolphinDetailsViewTest;
883 friend class DolphinPart; // Accesses m_model
884 };
885
886 /// Allow using DolphinView::Mode in QVariant
887 Q_DECLARE_METATYPE(DolphinView::Mode)
888
889 #endif // DOLPHINVIEW_H