Warning, file /system/dolphin/src/views/dolphinview.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2006-2009 Peter Penz <peter.penz19@gmail.com> 0003 * SPDX-FileCopyrightText: 2006 Gregor Kališnik <gregor@podnapisi.net> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef DOLPHINVIEW_H 0009 #define DOLPHINVIEW_H 0010 0011 #include "dolphin_export.h" 0012 #include "dolphintabwidget.h" 0013 #include "tooltips/tooltipmanager.h" 0014 0015 #include "config-dolphin.h" 0016 #include <KFileItem> 0017 #include <KIO/StatJob> 0018 #include <kio/fileundomanager.h> 0019 #include <kparts/part.h> 0020 0021 #include <QMimeData> 0022 #include <QPointer> 0023 #include <QUrl> 0024 #include <QWidget> 0025 0026 #include <memory> 0027 0028 typedef KIO::FileUndoManager::CommandType CommandType; 0029 class QVBoxLayout; 0030 class DolphinItemListView; 0031 class KFileItemModel; 0032 class KItemListContainer; 0033 class KItemModelBase; 0034 class KItemSet; 0035 class ToolTipManager; 0036 class VersionControlObserver; 0037 class ViewProperties; 0038 class QLabel; 0039 class QGraphicsSceneDragDropEvent; 0040 class QHelpEvent; 0041 class QProxyStyle; 0042 class QRegularExpression; 0043 0044 /** 0045 * @short Represents a view for the directory content. 0046 * 0047 * View modes for icons, compact and details are supported. It's 0048 * possible to adjust: 0049 * - sort order 0050 * - sort type 0051 * - show hidden files 0052 * - show previews 0053 * - enable grouping 0054 */ 0055 class DOLPHIN_EXPORT DolphinView : public QWidget 0056 { 0057 Q_OBJECT 0058 0059 public: 0060 /** 0061 * Defines the view mode for a directory. The 0062 * view mode is automatically updated if the directory itself 0063 * defines a view mode (see class ViewProperties for details). 0064 */ 0065 enum Mode { 0066 /** 0067 * The items are shown as icons with a name-label below. 0068 */ 0069 IconsView = 0, 0070 0071 /** 0072 * The icon, the name and the size of the items are 0073 * shown per default as a table. 0074 */ 0075 DetailsView, 0076 0077 /** 0078 * The items are shown as icons with the name-label aligned 0079 * to the right side. 0080 */ 0081 CompactView 0082 }; 0083 0084 /** 0085 * @param url Specifies the content which should be shown. 0086 * @param parent Parent widget of the view. 0087 */ 0088 DolphinView(const QUrl &url, QWidget *parent); 0089 0090 ~DolphinView() override; 0091 0092 /** 0093 * Returns the current active URL, where all actions are applied. 0094 * The URL navigator is synchronized with this URL. 0095 */ 0096 QUrl url() const; 0097 0098 /** 0099 * If \a active is true, the view will marked as active. The active 0100 * view is defined as view where all actions are applied to. 0101 */ 0102 void setActive(bool active); 0103 bool isActive() const; 0104 0105 /** 0106 * Changes the view mode for the current directory to \a mode. 0107 * If the view properties should be remembered for each directory 0108 * (GeneralSettings::globalViewProps() returns false), then the 0109 * changed view mode will be stored automatically. 0110 */ 0111 void setViewMode(Mode mode); 0112 Mode viewMode() const; 0113 0114 /** 0115 * Enables or disables a mode for quick and easy selection of items. 0116 */ 0117 void setSelectionModeEnabled(bool enabled); 0118 bool selectionMode() const; 0119 0120 /** 0121 * Turns on the file preview for the all files of the current directory, 0122 * if \a show is true. 0123 * If the view properties should be remembered for each directory 0124 * (GeneralSettings::globalViewProps() returns false), then the 0125 * preview setting will be stored automatically. 0126 */ 0127 void setPreviewsShown(bool show); 0128 bool previewsShown() const; 0129 0130 /** 0131 * Shows all hidden files of the current directory, 0132 * if \a show is true. 0133 * If the view properties should be remembered for each directory 0134 * (GeneralSettings::globalViewProps() returns false), then the 0135 * show hidden file setting will be stored automatically. 0136 */ 0137 void setHiddenFilesShown(bool show); 0138 bool hiddenFilesShown() const; 0139 0140 /** 0141 * Turns on sorting by groups if \a enable is true. 0142 */ 0143 void setGroupedSorting(bool grouped); 0144 bool groupedSorting() const; 0145 0146 /** 0147 * Returns the items of the view. 0148 */ 0149 KFileItemList items() const; 0150 0151 /** 0152 * @return The number of items. itemsCount() is faster in comparison 0153 * to items().count(). 0154 */ 0155 int itemsCount() const; 0156 0157 /** 0158 * Returns the selected items. The list is empty if no item has been 0159 * selected. 0160 */ 0161 KFileItemList selectedItems() const; 0162 0163 /** 0164 * Returns the number of selected items (this is faster than 0165 * invoking selectedItems().count()). 0166 */ 0167 int selectedItemsCount() const; 0168 0169 /** 0170 * Marks the items indicated by \p urls to get selected after the 0171 * directory DolphinView::url() has been loaded. Note that nothing 0172 * gets selected if no loading of a directory has been triggered 0173 * by DolphinView::setUrl() or DolphinView::reload(). 0174 */ 0175 void markUrlsAsSelected(const QList<QUrl> &urls); 0176 0177 /** 0178 * Marks the item indicated by \p url to be scrolled to and as the 0179 * current item after directory DolphinView::url() has been loaded. 0180 */ 0181 void markUrlAsCurrent(const QUrl &url); 0182 0183 /** 0184 * All items that match the regular expression \a regexp will get selected 0185 * if \a enabled is true and deselected if \a enabled is false. 0186 * 0187 * Note that to match the whole string the pattern should be anchored: 0188 * - you can anchor the pattern with QRegularExpression::anchoredPattern() 0189 * - if you use QRegularExpresssion::wildcardToRegularExpression(), don't use 0190 * QRegularExpression::anchoredPattern() as the former already returns an 0191 * anchored pattern 0192 */ 0193 void selectItems(const QRegularExpression ®exp, bool enabled); 0194 0195 /** 0196 * Sets the zoom level to \a level. It is assured that the used 0197 * level is adjusted to be inside the range ZoomLevelInfo::minimumLevel() and 0198 * ZoomLevelInfo::maximumLevel(). 0199 */ 0200 void setZoomLevel(int level); 0201 int zoomLevel() const; 0202 0203 /** 0204 * Resets the view's icon size to the default value 0205 */ 0206 void resetZoomLevel(); 0207 0208 /** 0209 * Updates the view properties of the current URL to the 0210 * sorting given by \a role. 0211 */ 0212 void setSortRole(const QByteArray &role); 0213 QByteArray sortRole() const; 0214 0215 /** 0216 * Updates the view properties of the current URL to the 0217 * sort order given by \a order. 0218 */ 0219 void setSortOrder(Qt::SortOrder order); 0220 Qt::SortOrder sortOrder() const; 0221 0222 /** Sets a separate sorting with folders first (true) or a mixed sorting of files and folders (false). */ 0223 void setSortFoldersFirst(bool foldersFirst); 0224 bool sortFoldersFirst() const; 0225 0226 /** Sets a separate sorting with hidden files and folders last (true) or not (false). */ 0227 void setSortHiddenLast(bool hiddenLast); 0228 bool sortHiddenLast() const; 0229 0230 /** Sets the additional information which should be shown for the items. */ 0231 void setVisibleRoles(const QList<QByteArray> &roles); 0232 0233 /** Returns the additional information which should be shown for the items. */ 0234 QList<QByteArray> visibleRoles() const; 0235 0236 /** 0237 * Refreshes the view to get synchronized with the settings (e.g. icons size, 0238 * font, ...). 0239 */ 0240 void readSettings(); 0241 0242 /** 0243 * Saves the current settings (e.g. icons size, font, ..). 0244 */ 0245 void writeSettings(); 0246 0247 /** 0248 * Filters the currently shown items by \a nameFilter. All items 0249 * which contain the given filter string will be shown. 0250 */ 0251 void setNameFilter(const QString &nameFilter); 0252 QString nameFilter() const; 0253 0254 /** 0255 * Filters the currently shown items by \a filters. All items 0256 * whose content-type matches those given by the list of filters 0257 * will be shown. 0258 */ 0259 void setMimeTypeFilters(const QStringList &filters); 0260 QStringList mimeTypeFilters() const; 0261 0262 /** 0263 * Tells the view to generate an updated status bar text. The result 0264 * is returned through the statusBarTextChanged(QString statusBarText) signal. 0265 * It will carry a textual representation of the state of the current 0266 * folder or selected items, suitable for use in the status bar. 0267 * Any pending requests of status bar text are killed. 0268 */ 0269 void requestStatusBarText(); 0270 0271 /** 0272 * Returns the version control actions that are provided for the items \p items. 0273 * Usually the actions are presented in the context menu. 0274 */ 0275 QList<QAction *> versionControlActions(const KFileItemList &items) const; 0276 0277 /** 0278 * Returns the state of the paste action: 0279 * first is whether the action should be enabled 0280 * second is the text for the action 0281 */ 0282 QPair<bool, QString> pasteInfo() const; 0283 0284 /** 0285 * If \a tabsForFiles is true, the signal tabRequested() will also 0286 * emitted also for files. Per default tabs for files is disabled 0287 * and hence the signal tabRequested() will only be emitted for 0288 * directories. 0289 */ 0290 void setTabsForFilesEnabled(bool tabsForFiles); 0291 bool isTabsForFilesEnabled() const; 0292 0293 /** 0294 * Returns true if the current view allows folders to be expanded, 0295 * i.e. presents a hierarchical view to the user. 0296 */ 0297 bool itemsExpandable() const; 0298 0299 /** 0300 * @returns true if the @p item is one of the items() of this view and 0301 * is currently expanded. false otherwise. 0302 * Only directories in view modes that allow expanding can ever be expanded. 0303 */ 0304 bool isExpanded(const KFileItem &item) const; 0305 0306 /** 0307 * Restores the view state (current item, contents position, details view expansion state) 0308 */ 0309 void restoreState(QDataStream &stream); 0310 0311 /** 0312 * Saves the view state (current item, contents position, details view expansion state) 0313 */ 0314 void saveState(QDataStream &stream); 0315 0316 /** 0317 * Returns the root item which represents the current URL. 0318 */ 0319 KFileItem rootItem() const; 0320 0321 /** 0322 * Sets a context that is used for remembering the view-properties. 0323 * Per default the context is empty and the path of the currently set URL 0324 * is used for remembering the view-properties. Setting a custom context 0325 * makes sense if specific types of URLs (e.g. search-URLs) should 0326 * share common view-properties. 0327 */ 0328 void setViewPropertiesContext(const QString &context); 0329 QString viewPropertiesContext() const; 0330 0331 /** 0332 * Checks if the given \a item can be opened as folder (e.g. archives). 0333 * This function will also adjust the \a url (e.g. change the protocol). 0334 * @return a valid and adjusted url if the item can be opened as folder, 0335 * otherwise return an empty url. 0336 */ 0337 static QUrl openItemAsFolderUrl(const KFileItem &item, const bool browseThroughArchives = true); 0338 0339 /** 0340 * Hides tooltip displayed over element. 0341 */ 0342 void hideToolTip(const ToolTipManager::HideBehavior behavior = ToolTipManager::HideBehavior::Later); 0343 0344 /** 0345 * Check if the space key should be handled as a normal key, even if it's 0346 * used as a keyboard shortcut. 0347 * 0348 * See BUG 465489 0349 */ 0350 bool handleSpaceAsNormalKey() const; 0351 0352 /** Activates the view if the item list container gets focus. */ 0353 bool eventFilter(QObject *watched, QEvent *event) override; 0354 0355 /** 0356 * Returns whether the folder represented by the current URL is writable. 0357 */ 0358 bool isFolderWritable() const; 0359 0360 public Q_SLOTS: 0361 0362 void reload(); 0363 0364 /** 0365 * Changes the directory to \a url. If the current directory is equal to 0366 * \a url, nothing will be done (use DolphinView::reload() instead). 0367 */ 0368 void setUrl(const QUrl &url); 0369 0370 /** 0371 * Selects all items. 0372 * @see DolphinView::selectedItems() 0373 */ 0374 void selectAll(); 0375 0376 /** 0377 * Inverts the current selection: selected items get unselected, 0378 * unselected items get selected. 0379 * @see DolphinView::selectedItems() 0380 */ 0381 void invertSelection(); 0382 0383 void clearSelection(); 0384 0385 /** 0386 * Triggers the renaming of the currently selected items, where 0387 * the user must input a new name for the items. 0388 */ 0389 void renameSelectedItems(); 0390 0391 /** 0392 * Moves all selected items to the trash. 0393 */ 0394 void trashSelectedItems(); 0395 0396 /** 0397 * Deletes all selected items. 0398 */ 0399 void deleteSelectedItems(); 0400 0401 /** 0402 * Copies all selected items to the clipboard and marks 0403 * the items as cut. 0404 */ 0405 void cutSelectedItemsToClipboard(); 0406 0407 /** Copies all selected items to the clipboard. */ 0408 void copySelectedItemsToClipboard(); 0409 0410 /** 0411 * Copies all selected items to @p destinationUrl. 0412 */ 0413 void copySelectedItems(const KFileItemList &selection, const QUrl &destinationUrl); 0414 0415 /** 0416 * Moves all selected items to @p destinationUrl. 0417 */ 0418 void moveSelectedItems(const KFileItemList &selection, const QUrl &destinationUrl); 0419 0420 /** Pastes the clipboard data to this view. */ 0421 void paste(); 0422 0423 /** 0424 * Pastes the clipboard data into the currently selected 0425 * folder. If the current selection is not exactly one folder, no 0426 * paste operation is done. 0427 */ 0428 void pasteIntoFolder(); 0429 0430 /** 0431 * Copies the path of the first selected KFileItem into Clipboard. 0432 */ 0433 void copyPathToClipboard(); 0434 0435 /** 0436 * Creates duplicates of selected items, appending "copy" 0437 * to the end. 0438 */ 0439 void duplicateSelectedItems(); 0440 0441 /** 0442 * Handles a drop of @p dropEvent onto widget @p dropWidget and destination @p destUrl 0443 */ 0444 void dropUrls(const QUrl &destUrl, QDropEvent *dropEvent, QWidget *dropWidget); 0445 0446 void stopLoading(); 0447 0448 /** 0449 * Applies the state that has been restored by restoreViewState() 0450 * to the view. 0451 */ 0452 void updateViewState(); 0453 0454 Q_SIGNALS: 0455 /** 0456 * Is emitted if the view has been activated by e. g. a mouse click. 0457 */ 0458 void activated(); 0459 0460 /** Is emitted if the URL of the view has been changed to \a url. */ 0461 void urlChanged(const QUrl &url); 0462 0463 /** 0464 * Is emitted when clicking on an item with the left mouse button. 0465 */ 0466 void itemActivated(const KFileItem &item); 0467 0468 /** 0469 * Is emitted when clicking on a file with the middle mouse button. 0470 * @note: This will not be emitted for folders or file archives that will/can be opened like folders. 0471 */ 0472 void fileMiddleClickActivated(const KFileItem &item); 0473 0474 /** 0475 * Is emitted when multiple items have been activated by e. g. 0476 * context menu open with. 0477 */ 0478 void itemsActivated(const KFileItemList &items); 0479 0480 /** 0481 * Is emitted if items have been added or deleted. 0482 */ 0483 void itemCountChanged(); 0484 0485 /** 0486 * Is emitted if a new tab should be opened for the URL \a url. 0487 */ 0488 void tabRequested(const QUrl &url); 0489 0490 /** 0491 * Is emitted if a new tab should be opened for the URL \a url and set as active. 0492 */ 0493 void activeTabRequested(const QUrl &url); 0494 0495 /** 0496 * Is emitted if a new window should be opened for the URL \a url. 0497 */ 0498 void windowRequested(const QUrl &url); 0499 0500 /** 0501 * Is emitted if the view mode (IconsView, DetailsView, 0502 * PreviewsView) has been changed. 0503 */ 0504 void modeChanged(DolphinView::Mode current, DolphinView::Mode previous); 0505 0506 /** Is emitted if the 'show preview' property has been changed. */ 0507 void previewsShownChanged(bool shown); 0508 0509 /** Is emitted if the 'show hidden files' property has been changed. */ 0510 void hiddenFilesShownChanged(bool shown); 0511 0512 /** Is emitted if the 'grouped sorting' property has been changed. */ 0513 void groupedSortingChanged(bool groupedSorting); 0514 0515 /** Is emitted in reaction to a requestStatusBarText() call. 0516 * @see requestStatusBarText() */ 0517 void statusBarTextChanged(QString statusBarText); 0518 0519 /** Is emitted if the sorting by name, size or date has been changed. */ 0520 void sortRoleChanged(const QByteArray &role); 0521 0522 /** Is emitted if the sort order (ascending or descending) has been changed. */ 0523 void sortOrderChanged(Qt::SortOrder order); 0524 0525 /** 0526 * Is emitted if the sorting of files and folders (separate with folders 0527 * first or mixed) has been changed. 0528 */ 0529 void sortFoldersFirstChanged(bool foldersFirst); 0530 0531 /** 0532 * Is emitted if the sorting of hidden files has been changed. 0533 */ 0534 void sortHiddenLastChanged(bool hiddenLast); 0535 0536 /** Is emitted if the additional information shown for this view has been changed. */ 0537 void visibleRolesChanged(const QList<QByteArray> ¤t, const QList<QByteArray> &previous); 0538 0539 /** Is emitted if the zoom level has been changed by zooming in or out. */ 0540 void zoomLevelChanged(int current, int previous); 0541 0542 /** 0543 * Is emitted if information of an item is requested to be shown e. g. in the panel. 0544 * If item is null, no item information request is pending. 0545 */ 0546 void requestItemInfo(const KFileItem &item); 0547 0548 /** 0549 * Is emitted whenever the selection has been changed. 0550 */ 0551 void selectionChanged(const KFileItemList &selection); 0552 0553 /** 0554 * Is emitted if a context menu is requested for the item \a item, 0555 * which is part of \a url. If the item is null, the context menu 0556 * for the URL should be shown. 0557 */ 0558 void requestContextMenu(const QPoint &pos, const KFileItem &item, const KFileItemList &selectedItems, const QUrl &url); 0559 0560 /** 0561 * Is emitted if an information message with the content \a msg 0562 * should be shown. 0563 */ 0564 void infoMessage(const QString &msg); 0565 0566 /** 0567 * Is emitted if an error message with the content \a msg 0568 * should be shown. 0569 */ 0570 void errorMessage(const QString &msg); 0571 0572 /** 0573 * Is emitted if an "operation completed" message with the content \a msg 0574 * should be shown. 0575 */ 0576 void operationCompletedMessage(const QString &msg); 0577 0578 /** 0579 * Is emitted after DolphinView::setUrl() has been invoked and 0580 * the current directory is loaded. If this signal is emitted, 0581 * it is assured that the view contains already the correct root 0582 * URL and property settings. 0583 */ 0584 void directoryLoadingStarted(); 0585 0586 /** 0587 * Is emitted after the directory triggered by DolphinView::setUrl() 0588 * has been loaded. 0589 */ 0590 void directoryLoadingCompleted(); 0591 0592 /** 0593 * Is emitted after the directory loading triggered by DolphinView::setUrl() 0594 * has been canceled. 0595 */ 0596 void directoryLoadingCanceled(); 0597 0598 /** 0599 * Is emitted after DolphinView::setUrl() has been invoked and provides 0600 * the information how much percent of the current directory have been loaded. 0601 */ 0602 void directoryLoadingProgress(int percent); 0603 0604 /** 0605 * Is emitted if the sorting is done asynchronously and provides the 0606 * progress information of the sorting. 0607 */ 0608 void directorySortingProgress(int percent); 0609 0610 /** 0611 * Emitted when the file-item-model emits redirection. 0612 * Testcase: fish://localhost 0613 */ 0614 void redirection(const QUrl &oldUrl, const QUrl &newUrl); 0615 0616 /** 0617 * Is emitted when the URL set by DolphinView::setUrl() represents a file. 0618 * In this case no signal errorMessage() will be emitted. 0619 */ 0620 void urlIsFileError(const QUrl &url); 0621 0622 /** 0623 * Is emitted when the write state of the folder has been changed. The application 0624 * should disable all actions like "Create New..." that depend on the write 0625 * state. 0626 */ 0627 void writeStateChanged(bool isFolderWritable); 0628 0629 /** 0630 * Is emitted if the URL should be changed to the previous URL of the 0631 * history (e.g. because the "back"-mousebutton has been pressed). 0632 */ 0633 void goBackRequested(); 0634 0635 /** 0636 * Is emitted if the URL should be changed to the next URL of the 0637 * history (e.g. because the "next"-mousebutton has been pressed). 0638 */ 0639 void goForwardRequested(); 0640 0641 /** 0642 * Used to request either entering or leaving of selection mode 0643 * Entering is typically requested on press and hold. 0644 * Leaving by pressing Escape when no item is selected. 0645 */ 0646 void selectionModeChangeRequested(bool enabled); 0647 0648 /** 0649 * Is emitted when the user wants to move the focus to another view. 0650 */ 0651 void toggleActiveViewRequested(); 0652 0653 /** 0654 * Is emitted when the user clicks a tag or a link 0655 * in the metadata widget of a tooltip. 0656 */ 0657 void urlActivated(const QUrl &url); 0658 0659 void goUpRequested(); 0660 0661 void fileItemsChanged(const KFileItemList &changedFileItems); 0662 0663 /** 0664 * Emitted when the current directory of the model was removed. 0665 */ 0666 void currentDirectoryRemoved(); 0667 0668 protected: 0669 /** Changes the zoom level if Control is pressed during a wheel event. */ 0670 void wheelEvent(QWheelEvent *event) override; 0671 0672 void hideEvent(QHideEvent *event) override; 0673 bool event(QEvent *event) override; 0674 0675 private Q_SLOTS: 0676 /** 0677 * Marks the view as active (DolphinView:isActive() will return true) 0678 * and emits the 'activated' signal if it is not already active. 0679 */ 0680 void activate(); 0681 0682 void slotItemActivated(int index); 0683 void slotItemsActivated(const KItemSet &indexes); 0684 void slotItemMiddleClicked(int index); 0685 void slotItemContextMenuRequested(int index, const QPointF &pos); 0686 void slotViewContextMenuRequested(const QPointF &pos); 0687 void slotHeaderContextMenuRequested(const QPointF &pos); 0688 void slotHeaderColumnWidthChangeFinished(const QByteArray &role, qreal current); 0689 void slotSidePaddingWidthChanged(qreal width); 0690 void slotItemHovered(int index); 0691 void slotItemUnhovered(int index); 0692 void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent *event); 0693 void slotModelChanged(KItemModelBase *current, KItemModelBase *previous); 0694 void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons); 0695 void slotRenameDialogRenamingFinished(const QList<QUrl> &urls); 0696 void slotSelectedItemTextPressed(int index); 0697 void slotItemCreatedFromJob(KIO::Job *, const QUrl &, const QUrl &to); 0698 void slotItemLinkCreatedFromJob(KIO::Job *, const QUrl &, const QString &, const QUrl &to); 0699 void slotIncreaseZoom(); 0700 void slotDecreaseZoom(); 0701 void slotSwipeUp(); 0702 0703 /* 0704 * Is called when new items get pasted or dropped. 0705 */ 0706 void slotItemCreated(const QUrl &url); 0707 /* 0708 * Is called after all pasted or dropped items have been copied to destination. 0709 */ 0710 void slotJobResult(KJob *job); 0711 0712 /** 0713 * Emits the signal \a selectionChanged() with a small delay. This is 0714 * because getting all file items for the selection can be an expensive 0715 * operation. Fast selection changes are collected in this case and 0716 * the signal is emitted only after no selection change has been done 0717 * within a small delay. 0718 */ 0719 void slotSelectionChanged(const KItemSet ¤t, const KItemSet &previous); 0720 0721 /** 0722 * Is called by emitDelayedSelectionChangedSignal() and emits the 0723 * signal \a selectionChanged() with all selected file items as parameter. 0724 */ 0725 void emitSelectionChangedSignal(); 0726 0727 /** 0728 * Helper method for DolphinView::requestStatusBarText(). 0729 * Calculates the amount of folders and files and their total size in 0730 * response to a KStatJob::result(), then calls emitStatusBarText(). 0731 * @see requestStatusBarText() 0732 * @see emitStatusBarText() 0733 */ 0734 void slotStatJobResult(KJob *job); 0735 0736 /** 0737 * Updates the view properties of the current URL to the 0738 * sorting of files and folders (separate with folders first or mixed) given by \a foldersFirst. 0739 */ 0740 void updateSortFoldersFirst(bool foldersFirst); 0741 0742 /** 0743 * Updates the view properties of the current URL to the 0744 * sorting of hidden files given by \a hiddenLast. 0745 */ 0746 void updateSortHiddenLast(bool hiddenLast); 0747 0748 /** 0749 * Indicates in the status bar that the delete operation 0750 * of the job \a job has been finished. 0751 */ 0752 void slotDeleteFileFinished(KJob *job); 0753 0754 /** 0755 * Indicates in the status bar that the trash operation 0756 * of the job \a job has been finished. 0757 */ 0758 void slotTrashFileFinished(KJob *job); 0759 0760 /** 0761 * Invoked when the rename job is done, for error handling. 0762 */ 0763 void slotRenamingResult(KJob *job); 0764 0765 /** 0766 * Invoked when the file item model has started the loading 0767 * of the directory specified by DolphinView::url(). 0768 */ 0769 void slotDirectoryLoadingStarted(); 0770 0771 /** 0772 * Invoked when the file item model indicates that the loading of a directory has 0773 * been completed. Assures that pasted items and renamed items get selected. 0774 */ 0775 void slotDirectoryLoadingCompleted(); 0776 0777 /** 0778 * Invoked when the file item model indicates that the loading of a directory has 0779 * been canceled. 0780 */ 0781 void slotDirectoryLoadingCanceled(); 0782 0783 /** 0784 * Is invoked when items of KFileItemModel have been changed. 0785 */ 0786 void slotItemsChanged(); 0787 0788 /** 0789 * Is invoked when the sort order has been changed by the user by clicking 0790 * on a header item. The view properties of the directory will get updated. 0791 */ 0792 void slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous); 0793 0794 /** 0795 * Is invoked when the sort role has been changed by the user by clicking 0796 * on a header item. The view properties of the directory will get updated. 0797 */ 0798 void slotSortRoleChangedByHeader(const QByteArray ¤t, const QByteArray &previous); 0799 0800 /** 0801 * Is invoked when the visible roles have been changed by the user by dragging 0802 * a header item. The view properties of the directory will get updated. 0803 */ 0804 void slotVisibleRolesChangedByHeader(const QList<QByteArray> ¤t, const QList<QByteArray> &previous); 0805 0806 void slotRoleEditingCanceled(); 0807 void slotRoleEditingFinished(int index, const QByteArray &role, const QVariant &value); 0808 0809 /** 0810 * Observes the item with the URL \a url. As soon as the directory 0811 * model indicates that the item is available, the item will 0812 * get selected and it is assured that the item stays visible. 0813 */ 0814 void observeCreatedItem(const QUrl &url); 0815 0816 /** 0817 * Selects the next item after prev selection deleted/trashed 0818 */ 0819 void selectNextItem(); 0820 0821 /** 0822 * Called when a redirection happens. 0823 * Testcase: fish://localhost 0824 */ 0825 void slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl); 0826 0827 void slotTwoClicksRenamingTimerTimeout(); 0828 0829 void onDirectoryLoadingCompletedAfterJob(); 0830 0831 private: 0832 void loadDirectory(const QUrl &url, bool reload = false); 0833 0834 /** 0835 * Applies the view properties which are defined by the current URL 0836 * to the DolphinView properties. The view properties are read from a 0837 * .directory file either in the current directory, or in the 0838 * share/apps/dolphin/view_properties/ subfolder of the user's .kde folder. 0839 */ 0840 void applyViewProperties(); 0841 0842 /** 0843 * Applies the given view properties to the DolphinView. 0844 */ 0845 void applyViewProperties(const ViewProperties &props); 0846 0847 /** 0848 * Applies the m_mode property to the corresponding 0849 * itemlayout-property of the KItemListView. 0850 */ 0851 void applyModeToView(); 0852 0853 enum Selection { HasSelection, NoSelection }; 0854 /** 0855 * Helper method for DolphinView::requestStatusBarText(). 0856 * Generates the status bar text from the parameters and 0857 * then emits statusBarTextChanged(). 0858 * @param totalFileSize the sum of the sizes of the files 0859 * @param selection if HasSelection is passed, the emitted status bar text will say 0860 * that the folders and files which are counted here are selected. 0861 */ 0862 void emitStatusBarText(const int folderCount, const int fileCount, KIO::filesize_t totalFileSize, const Selection selection); 0863 0864 /** 0865 * Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder(). 0866 * Pastes the clipboard data into the URL \a url. 0867 */ 0868 void pasteToUrl(const QUrl &url); 0869 0870 /** 0871 * Returns a list of URLs for all selected items. The list is 0872 * simplified, so that when the URLs are part of different tree 0873 * levels, only the parent is returned. 0874 */ 0875 QList<QUrl> simplifiedSelectedUrls() const; 0876 0877 /** 0878 * Returns the MIME data for all selected items. 0879 */ 0880 QMimeData *selectionMimeData() const; 0881 0882 /** 0883 * Updates m_isFolderWritable dependent on whether the folder represented by 0884 * the current URL is writable. If the state has changed, the signal 0885 * writeStateChanged() will be emitted. 0886 */ 0887 void updateWritableState(); 0888 0889 /** 0890 * @return The current URL if no viewproperties-context is given (see 0891 * DolphinView::viewPropertiesContext(), otherwise the context 0892 * is returned. 0893 */ 0894 QUrl viewPropertiesUrl() const; 0895 0896 /** 0897 * Clears the selection and updates current item and selection according to the parameters 0898 * 0899 * @param current URL to be set as current 0900 * @param selected list of selected items 0901 */ 0902 void forceUrlsSelection(const QUrl ¤t, const QList<QUrl> &selected); 0903 0904 void abortTwoClicksRenaming(); 0905 0906 void updatePlaceholderLabel(); 0907 0908 bool tryShowNameToolTip(QHelpEvent *event); 0909 0910 private: 0911 void updatePalette(); 0912 void showLoadingPlaceholder(); 0913 0914 bool m_active; 0915 bool m_tabsForFiles; 0916 bool m_assureVisibleCurrentIndex; 0917 bool m_isFolderWritable; 0918 bool m_dragging; // True if a dragging is done. Required to be able to decide whether a 0919 // tooltip may be shown when hovering an item. 0920 bool m_selectNextItem; 0921 0922 enum class LoadingState { Idle, Loading, Canceled, Completed }; 0923 LoadingState m_loadingState = LoadingState::Idle; 0924 0925 QUrl m_url; 0926 QString m_viewPropertiesContext; 0927 Mode m_mode; 0928 QList<QByteArray> m_visibleRoles; 0929 0930 QPointer<KIO::StatJob> m_statJobForStatusBarText; 0931 0932 QVBoxLayout *m_topLayout; 0933 0934 KFileItemModel *m_model; 0935 DolphinItemListView *m_view; 0936 KItemListContainer *m_container; 0937 0938 ToolTipManager *m_toolTipManager; 0939 0940 QTimer *m_selectionChangedTimer; 0941 0942 QUrl m_currentItemUrl; // Used for making the view to remember the current URL after F5 0943 bool m_scrollToCurrentItem; // Used for marking we need to scroll to current item or not 0944 QPoint m_restoredContentsPosition; 0945 0946 // Used for tracking the accumulated scroll amount (for zooming with high 0947 // resolution scroll wheels) 0948 int m_controlWheelAccumulatedDelta; 0949 0950 QList<QUrl> m_selectedUrls; // Used for making the view to remember selections after F5 and file operations 0951 bool m_clearSelectionBeforeSelectingNewItems; 0952 bool m_markFirstNewlySelectedItemAsCurrent; 0953 /// Decides whether items created by jobs should automatically be selected. 0954 bool m_selectJobCreatedItems; 0955 0956 VersionControlObserver *m_versionControlObserver; 0957 0958 QTimer *m_twoClicksRenamingTimer; 0959 QUrl m_twoClicksRenamingItemUrl; 0960 QLabel *m_placeholderLabel; 0961 QTimer *m_showLoadingPlaceholderTimer; 0962 0963 /// The information roleIndex of the list column header currently hovered 0964 std::optional<int> m_hoveredColumnHeaderIndex; 0965 0966 /// Used for selection mode. @see setSelectionMode() 0967 std::unique_ptr<QProxyStyle> m_proxyStyle; 0968 0969 // For unit tests 0970 friend class TestBase; 0971 friend class DolphinDetailsViewTest; 0972 friend class DolphinMainWindowTest; 0973 friend class DolphinPart; // Accesses m_model 0974 void updateSelectionState(); 0975 }; 0976 0977 /// Allow using DolphinView::Mode in QVariant 0978 Q_DECLARE_METATYPE(DolphinView::Mode) 0979 0980 #endif // DOLPHINVIEW_H