Changeset View
Changeset View
Standalone View
Standalone View
src/views/dolphinview.h
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
42 | class KItemListContainer; | 42 | class KItemListContainer; | ||
43 | class KItemModelBase; | 43 | class KItemModelBase; | ||
44 | class KItemSet; | 44 | class KItemSet; | ||
45 | class ToolTipManager; | 45 | class ToolTipManager; | ||
46 | class VersionControlObserver; | 46 | class VersionControlObserver; | ||
47 | class ViewProperties; | 47 | class ViewProperties; | ||
48 | class QGraphicsSceneDragDropEvent; | 48 | class QGraphicsSceneDragDropEvent; | ||
49 | class QRegExp; | 49 | class QRegExp; | ||
50 | class KItemListSelectionManager; | ||||
50 | 51 | | |||
51 | /** | 52 | /** | ||
52 | * @short Represents a view for the directory content. | 53 | * @short Represents a view for the directory content. | ||
53 | * | 54 | * | ||
54 | * View modes for icons, compact and details are supported. It's | 55 | * View modes for icons, compact and details are supported. It's | ||
55 | * possible to adjust: | 56 | * possible to adjust: | ||
56 | * - sort order | 57 | * - sort order | ||
57 | * - sort type | 58 | * - sort type | ||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 67 | public: | |||
163 | KFileItemList selectedItems() const; | 164 | KFileItemList selectedItems() const; | ||
164 | 165 | | |||
165 | /** | 166 | /** | ||
166 | * Returns the number of selected items (this is faster than | 167 | * Returns the number of selected items (this is faster than | ||
167 | * invoking selectedItems().count()). | 168 | * invoking selectedItems().count()). | ||
168 | */ | 169 | */ | ||
169 | int selectedItemsCount() const; | 170 | int selectedItemsCount() const; | ||
170 | 171 | | |||
172 | KItemListSelectionManager* selectionManager() const; | ||||
173 | | ||||
174 | DolphinItemListView* listView() const; | ||||
175 | | ||||
171 | /** | 176 | /** | ||
172 | * Marks the items indicated by \p urls to get selected after the | 177 | * Marks the items indicated by \p urls to get selected after the | ||
173 | * directory DolphinView::url() has been loaded. Note that nothing | 178 | * directory DolphinView::url() has been loaded. Note that nothing | ||
174 | * gets selected if no loading of a directory has been triggered | 179 | * gets selected if no loading of a directory has been triggered | ||
175 | * by DolphinView::setUrl() or DolphinView::reload(). | 180 | * by DolphinView::setUrl() or DolphinView::reload(). | ||
176 | */ | 181 | */ | ||
177 | void markUrlsAsSelected(const QList<QUrl> &urls); | 182 | void markUrlsAsSelected(const QList<QUrl> &urls); | ||
178 | 183 | | |||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Line(s) | |||||
312 | */ | 317 | */ | ||
313 | static QUrl openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives = true); | 318 | static QUrl openItemAsFolderUrl(const KFileItem& item, const bool browseThroughArchives = true); | ||
314 | 319 | | |||
315 | /** | 320 | /** | ||
316 | * Hides tooltip displayed over element. | 321 | * Hides tooltip displayed over element. | ||
317 | */ | 322 | */ | ||
318 | void hideToolTip(const ToolTipManager::HideBehavior behavior = ToolTipManager::HideBehavior::Later); | 323 | void hideToolTip(const ToolTipManager::HideBehavior behavior = ToolTipManager::HideBehavior::Later); | ||
319 | 324 | | |||
325 | /** | ||||
326 | * Call this before pasting into the view | ||||
327 | */ | ||||
328 | void prepareToPaste(); | ||||
329 | | ||||
330 | /** | ||||
331 | * Clears the selection and updates current item and selection according to the parameters | ||||
332 | * | ||||
333 | * @param current URL to be set as current | ||||
334 | * @param selected list of selected items | ||||
335 | */ | ||||
336 | void forceUrlsSelection(const QUrl& current, const QList<QUrl>& selected); | ||||
337 | | ||||
320 | public slots: | 338 | public slots: | ||
321 | /** | 339 | /** | ||
322 | * Changes the directory to \a url. If the current directory is equal to | 340 | * Changes the directory to \a url. If the current directory is equal to | ||
323 | * \a url, nothing will be done (use DolphinView::reload() instead). | 341 | * \a url, nothing will be done (use DolphinView::reload() instead). | ||
324 | */ | 342 | */ | ||
325 | void setUrl(const QUrl& url); | 343 | void setUrl(const QUrl& url); | ||
326 | 344 | | |||
327 | /** | 345 | /** | ||
328 | * Selects all items. | 346 | * Selects all items. | ||
329 | * @see DolphinView::selectedItems() | 347 | * @see DolphinView::selectedItems() | ||
330 | */ | 348 | */ | ||
331 | void selectAll(); | 349 | void selectAll(); | ||
332 | 350 | | |||
333 | /** | 351 | /** | ||
334 | * Inverts the current selection: selected items get unselected, | 352 | * Inverts the current selection: selected items get unselected, | ||
335 | * unselected items get selected. | 353 | * unselected items get selected. | ||
336 | * @see DolphinView::selectedItems() | 354 | * @see DolphinView::selectedItems() | ||
337 | */ | 355 | */ | ||
338 | void invertSelection(); | 356 | void invertSelection(); | ||
339 | 357 | | |||
340 | void clearSelection(); | 358 | void clearSelection(); | ||
341 | 359 | | |||
342 | /** | 360 | /** | ||
343 | * Triggers the renaming of the currently selected items, where | 361 | * Handles a drop of @p dropEvent onto widget @p dropWidget and destination @p destUrl | ||
344 | * the user must input a new name for the items. | | |||
345 | */ | | |||
346 | void renameSelectedItems(); | | |||
347 | | ||||
348 | /** | | |||
349 | * Moves all selected items to the trash. | | |||
350 | */ | 362 | */ | ||
351 | void trashSelectedItems(); | 363 | void dropUrls(const QUrl &destUrl, QDropEvent *dropEvent, QWidget *dropWidget); | ||
352 | 364 | | |||
353 | /** | 365 | void stopLoading(); | ||
354 | * Deletes all selected items. | | |||
355 | */ | | |||
356 | void deleteSelectedItems(); | | |||
357 | 366 | | |||
358 | /** | 367 | /** | ||
359 | * Copies all selected items to the clipboard and marks | 368 | * Applies the state that has been restored by restoreViewState() | ||
360 | * the items as cut. | 369 | * to the view. | ||
361 | */ | 370 | */ | ||
362 | void cutSelectedItems(); | 371 | void updateViewState(); | ||
363 | | ||||
364 | /** Copies all selected items to the clipboard. */ | | |||
365 | void copySelectedItems(); | | |||
366 | 372 | | |||
367 | /** Pastes the clipboard data to this view. */ | 373 | /** Activates the view if the item list container gets focus. */ | ||
368 | void paste(); | 374 | bool eventFilter(QObject* watched, QEvent* event) override; | ||
369 | 375 | | |||
370 | /** | 376 | /** | ||
371 | * Pastes the clipboard data into the currently selected | 377 | * Indicates in the status bar that the delete operation | ||
372 | * folder. If the current selection is not exactly one folder, no | 378 | * of the job \a job has been finished. | ||
373 | * paste operation is done. | | |||
374 | */ | 379 | */ | ||
375 | void pasteIntoFolder(); | 380 | void slotDeleteFileFinished(KJob* job); | ||
376 | 381 | | |||
377 | /** | 382 | /** | ||
378 | * Creates duplicates of selected items, appending "copy" | 383 | * Indicates in the status bar that the trash operation | ||
379 | * to the end. | 384 | * of the job \a job has been finished. | ||
380 | */ | 385 | */ | ||
381 | void duplicateSelectedItems(); | 386 | void slotTrashFileFinished(KJob* job); | ||
382 | 387 | | |||
383 | /** | 388 | /* | ||
384 | * Handles a drop of @p dropEvent onto widget @p dropWidget and destination @p destUrl | 389 | * Is called when new items get pasted or dropped. | ||
385 | */ | 390 | */ | ||
386 | void dropUrls(const QUrl &destUrl, QDropEvent *dropEvent, QWidget *dropWidget); | 391 | void slotItemCreated(const QUrl &url); | ||
387 | 392 | /* | |||
388 | void stopLoading(); | 393 | * Is called after all pasted or dropped items have been copied to destination. | ||
389 | | ||||
390 | /** | | |||
391 | * Applies the state that has been restored by restoreViewState() | | |||
392 | * to the view. | | |||
393 | */ | 394 | */ | ||
394 | void updateViewState(); | 395 | void slotPasteJobResult(KJob *job); | ||
395 | 396 | | |||
396 | /** Activates the view if the item list container gets focus. */ | 397 | void slotRoleEditingCanceled(); | ||
397 | bool eventFilter(QObject* watched, QEvent* event) override; | 398 | void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value); | ||
399 | void slotRenameDialogRenamingFinished(const QList<QUrl>& urls); | ||||
398 | 400 | | |||
399 | signals: | 401 | signals: | ||
400 | /** | 402 | /** | ||
401 | * Is emitted if the view has been activated by e. g. a mouse click. | 403 | * Is emitted if the view has been activated by e. g. a mouse click. | ||
402 | */ | 404 | */ | ||
403 | void activated(); | 405 | void activated(); | ||
404 | 406 | | |||
405 | /** Is emitted if the URL of the view has been changed to \a url. */ | 407 | /** Is emitted if the URL of the view has been changed to \a url. */ | ||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | |||||
569 | void toggleActiveViewRequested(); | 571 | void toggleActiveViewRequested(); | ||
570 | 572 | | |||
571 | /** | 573 | /** | ||
572 | * Is emitted when the user clicks a tag or a link | 574 | * Is emitted when the user clicks a tag or a link | ||
573 | * in the metadata widget of a tooltip. | 575 | * in the metadata widget of a tooltip. | ||
574 | */ | 576 | */ | ||
575 | void urlActivated(const QUrl& url); | 577 | void urlActivated(const QUrl& url); | ||
576 | 578 | | |||
579 | /** | ||||
580 | * Request that the selected items renaming process is launched | ||||
581 | */ | ||||
582 | void requestRenameSelectedItems(); | ||||
583 | | ||||
577 | protected: | 584 | protected: | ||
578 | /** Changes the zoom level if Control is pressed during a wheel event. */ | 585 | /** Changes the zoom level if Control is pressed during a wheel event. */ | ||
579 | void wheelEvent(QWheelEvent* event) override; | 586 | void wheelEvent(QWheelEvent* event) override; | ||
580 | 587 | | |||
581 | void hideEvent(QHideEvent* event) override; | 588 | void hideEvent(QHideEvent* event) override; | ||
582 | bool event(QEvent* event) override; | 589 | bool event(QEvent* event) override; | ||
583 | 590 | | |||
584 | private slots: | 591 | private slots: | ||
Show All 10 Lines | |||||
595 | void slotViewContextMenuRequested(const QPointF& pos); | 602 | void slotViewContextMenuRequested(const QPointF& pos); | ||
596 | void slotHeaderContextMenuRequested(const QPointF& pos); | 603 | void slotHeaderContextMenuRequested(const QPointF& pos); | ||
597 | void slotHeaderColumnWidthChangeFinished(const QByteArray& role, qreal current); | 604 | void slotHeaderColumnWidthChangeFinished(const QByteArray& role, qreal current); | ||
598 | void slotItemHovered(int index); | 605 | void slotItemHovered(int index); | ||
599 | void slotItemUnhovered(int index); | 606 | void slotItemUnhovered(int index); | ||
600 | void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); | 607 | void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); | ||
601 | void slotModelChanged(KItemModelBase* current, KItemModelBase* previous); | 608 | void slotModelChanged(KItemModelBase* current, KItemModelBase* previous); | ||
602 | void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons); | 609 | void slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons); | ||
603 | void slotRenameDialogRenamingFinished(const QList<QUrl>& urls); | | |||
604 | void slotSelectedItemTextPressed(int index); | 610 | void slotSelectedItemTextPressed(int index); | ||
605 | 611 | | |||
606 | /* | | |||
607 | * Is called when new items get pasted or dropped. | | |||
608 | */ | | |||
609 | void slotItemCreated(const QUrl &url); | | |||
610 | /* | | |||
611 | * Is called after all pasted or dropped items have been copied to destination. | | |||
612 | */ | | |||
613 | void slotPasteJobResult(KJob *job); | | |||
614 | | ||||
615 | /** | 612 | /** | ||
616 | * Emits the signal \a selectionChanged() with a small delay. This is | 613 | * Emits the signal \a selectionChanged() with a small delay. This is | ||
617 | * because getting all file items for the selection can be an expensive | 614 | * because getting all file items for the selection can be an expensive | ||
618 | * operation. Fast selection changes are collected in this case and | 615 | * operation. Fast selection changes are collected in this case and | ||
619 | * the signal is emitted only after no selection change has been done | 616 | * the signal is emitted only after no selection change has been done | ||
620 | * within a small delay. | 617 | * within a small delay. | ||
621 | */ | 618 | */ | ||
622 | void slotSelectionChanged(const KItemSet& current, const KItemSet& previous); | 619 | void slotSelectionChanged(const KItemSet& current, const KItemSet& previous); | ||
Show All 18 Lines | |||||
641 | 638 | | |||
642 | /** | 639 | /** | ||
643 | * Updates the view properties of the current URL to the | 640 | * Updates the view properties of the current URL to the | ||
644 | * sorting of files and folders (separate with folders first or mixed) given by \a foldersFirst. | 641 | * sorting of files and folders (separate with folders first or mixed) given by \a foldersFirst. | ||
645 | */ | 642 | */ | ||
646 | void updateSortFoldersFirst(bool foldersFirst); | 643 | void updateSortFoldersFirst(bool foldersFirst); | ||
647 | 644 | | |||
648 | /** | 645 | /** | ||
649 | * Indicates in the status bar that the delete operation | | |||
650 | * of the job \a job has been finished. | | |||
651 | */ | | |||
652 | void slotDeleteFileFinished(KJob* job); | | |||
653 | | ||||
654 | /** | | |||
655 | * Indicates in the status bar that the trash operation | | |||
656 | * of the job \a job has been finished. | | |||
657 | */ | | |||
658 | void slotTrashFileFinished(KJob* job); | | |||
659 | | ||||
660 | /** | | |||
661 | * Invoked when the rename job is done, for error handling. | 646 | * Invoked when the rename job is done, for error handling. | ||
662 | */ | 647 | */ | ||
663 | void slotRenamingResult(KJob* job); | 648 | void slotRenamingResult(KJob* job); | ||
664 | 649 | | |||
665 | /** | 650 | /** | ||
666 | * Invoked when the file item model has started the loading | 651 | * Invoked when the file item model has started the loading | ||
667 | * of the directory specified by DolphinView::url(). | 652 | * of the directory specified by DolphinView::url(). | ||
668 | */ | 653 | */ | ||
669 | void slotDirectoryLoadingStarted(); | 654 | void slotDirectoryLoadingStarted(); | ||
670 | 655 | | |||
671 | /** | 656 | /** | ||
672 | * Invoked when the file item model indicates that the loading of a directory has | 657 | * Invoked when the file item model indicates that the loading of a directory has | ||
673 | * been completed. Assures that pasted items and renamed items get selected. | 658 | * been completed. Assures that pasted items and renamed items get selected. | ||
674 | */ | 659 | */ | ||
675 | void slotDirectoryLoadingCompleted(); | 660 | void slotDirectoryLoadingCompleted(); | ||
676 | 661 | | |||
677 | /** | 662 | /** | ||
678 | * Is invoked when items of KFileItemModel have been changed. | | |||
679 | */ | | |||
680 | void slotItemsChanged(); | | |||
681 | | ||||
682 | /** | | |||
683 | * Is invoked when the sort order has been changed by the user by clicking | 663 | * Is invoked when the sort order has been changed by the user by clicking | ||
684 | * on a header item. The view properties of the directory will get updated. | 664 | * on a header item. The view properties of the directory will get updated. | ||
685 | */ | 665 | */ | ||
686 | void slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous); | 666 | void slotSortOrderChangedByHeader(Qt::SortOrder current, Qt::SortOrder previous); | ||
687 | 667 | | |||
688 | /** | 668 | /** | ||
689 | * Is invoked when the sort role has been changed by the user by clicking | 669 | * Is invoked when the sort role has been changed by the user by clicking | ||
690 | * on a header item. The view properties of the directory will get updated. | 670 | * on a header item. The view properties of the directory will get updated. | ||
691 | */ | 671 | */ | ||
692 | void slotSortRoleChangedByHeader(const QByteArray& current, const QByteArray& previous); | 672 | void slotSortRoleChangedByHeader(const QByteArray& current, const QByteArray& previous); | ||
693 | 673 | | |||
694 | /** | 674 | /** | ||
695 | * Is invoked when the visible roles have been changed by the user by dragging | 675 | * Is invoked when the visible roles have been changed by the user by dragging | ||
696 | * a header item. The view properties of the directory will get updated. | 676 | * a header item. The view properties of the directory will get updated. | ||
697 | */ | 677 | */ | ||
698 | void slotVisibleRolesChangedByHeader(const QList<QByteArray>& current, | 678 | void slotVisibleRolesChangedByHeader(const QList<QByteArray>& current, | ||
699 | const QList<QByteArray>& previous); | 679 | const QList<QByteArray>& previous); | ||
700 | 680 | | |||
701 | void slotRoleEditingCanceled(); | | |||
702 | void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value); | | |||
703 | | ||||
704 | /** | 681 | /** | ||
705 | * Observes the item with the URL \a url. As soon as the directory | 682 | * Observes the item with the URL \a url. As soon as the directory | ||
706 | * model indicates that the item is available, the item will | 683 | * model indicates that the item is available, the item will | ||
707 | * get selected and it is assured that the item stays visible. | 684 | * get selected and it is assured that the item stays visible. | ||
708 | */ | 685 | */ | ||
709 | void observeCreatedItem(const QUrl &url); | 686 | void observeCreatedItem(const QUrl &url); | ||
710 | 687 | | |||
711 | /** | 688 | /** | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 706 | private: | |||
775 | 752 | | |||
776 | /** | 753 | /** | ||
777 | * @return The current URL if no viewproperties-context is given (see | 754 | * @return The current URL if no viewproperties-context is given (see | ||
778 | * DolphinView::viewPropertiesContext(), otherwise the context | 755 | * DolphinView::viewPropertiesContext(), otherwise the context | ||
779 | * is returned. | 756 | * is returned. | ||
780 | */ | 757 | */ | ||
781 | QUrl viewPropertiesUrl() const; | 758 | QUrl viewPropertiesUrl() const; | ||
782 | 759 | | |||
783 | /** | | |||
784 | * Clears the selection and updates current item and selection according to the parameters | | |||
785 | * | | |||
786 | * @param current URL to be set as current | | |||
787 | * @param selected list of selected items | | |||
788 | */ | | |||
789 | void forceUrlsSelection(const QUrl& current, const QList<QUrl>& selected); | | |||
790 | | ||||
791 | void abortTwoClicksRenaming(); | 760 | void abortTwoClicksRenaming(); | ||
792 | 761 | | |||
793 | private: | 762 | private: | ||
794 | void updatePalette(); | 763 | void updatePalette(); | ||
795 | 764 | | |||
796 | bool m_active; | 765 | bool m_active; | ||
797 | bool m_tabsForFiles; | 766 | bool m_tabsForFiles; | ||
798 | bool m_assureVisibleCurrentIndex; | | |||
799 | bool m_isFolderWritable; | 767 | bool m_isFolderWritable; | ||
800 | bool m_dragging; // True if a dragging is done. Required to be able to decide whether a | 768 | bool m_dragging; // True if a dragging is done. Required to be able to decide whether a | ||
801 | // tooltip may be shown when hovering an item. | 769 | // tooltip may be shown when hovering an item. | ||
802 | 770 | | |||
803 | QUrl m_url; | 771 | QUrl m_url; | ||
804 | QString m_viewPropertiesContext; | 772 | QString m_viewPropertiesContext; | ||
805 | Mode m_mode; | 773 | Mode m_mode; | ||
806 | QList<QByteArray> m_visibleRoles; | 774 | QList<QByteArray> m_visibleRoles; | ||
Show All 34 Lines |