1 // -*- c++ -*- 2 /* 3 This file is part of the KDE libraries 4 SPDX-FileCopyrightText: 1999 Stephan Kulow <coolo@kde.org> 5 SPDX-FileCopyrightText: 2000, 2001 Carsten Pfeiffer <pfeiffer@kde.org> 6 7 SPDX-License-Identifier: LGPL-2.0-or-later 8 */ 9 #ifndef KDIROPERATOR_H_ 10 #define KDIROPERATOR_H_ 11 12 #include "kiofilewidgets_export.h" 13 #include <kfile.h> 14 15 #include <QStyleOptionViewItem> 16 #include <QUrl> 17 #include <QWidget> 18 19 class QAbstractItemView; 20 class QMenu; 21 class QModelIndex; 22 class QProgressBar; 23 24 class KActionCollection; 25 class KActionMenu; 26 class KConfigGroup; 27 class KFileItemList; 28 class KFilePreviewGenerator; 29 class KPreviewWidgetBase; 30 31 #include <KToggleAction> // SIC TODO KF6: Not used, remove 32 #include <QStack> // SIC TODO KF6: Not used, remove 33 34 // SIC TODO KF6: forward-declaration is enough for these three 35 #include <KCompletion> 36 #include <KDirLister> 37 #include <KFileItem> 38 39 namespace KIO 40 { 41 class CopyJob; 42 class DeleteJob; 43 } 44 45 class KDirOperatorPrivate; 46 47 /** 48 * @class KDirOperator kdiroperator.h <KDirOperator> 49 * 50 * This widget works as a network transparent filebrowser. You specify a URL 51 * to display and this url will be loaded via KDirLister. The user can 52 * browse through directories, highlight and select files, delete or rename 53 * files. 54 * 55 * It supports different views, e.g. a detailed view (see KFileDetailView), 56 * a simple icon view (see KFileIconView), a combination of two views, 57 * separating directories and files ( KCombiView). 58 * 59 * Additionally, a preview view is available (see KFilePreview), which can 60 * show either a simple or detailed view and additionally a preview widget 61 * (see setPreviewWidget()). KImageFilePreview is one implementation 62 * of a preview widget, that displays previews for all supported filetypes 63 * utilizing KIO::PreviewJob. 64 * 65 * Currently, those classes don't support Drag&Drop out of the box -- there 66 * you have to use your own view-classes. You can use some DnD-aware views 67 * from Björn Sahlström <bjorn@kbear.org> until they will be integrated 68 * into this library. See http://devel-home.kde.org/~pfeiffer/DnD-classes.tar.gz 69 * 70 * This widget is the one used in the KFileWidget. 71 * 72 * Basic usage is like this: 73 * \code 74 * KDirOperator *op = new KDirOperator(QUrl("file:///home/gis"), this); 75 * // some signals you might be interested in 76 * connect(op, &KDirOperator::urlEntered, this, [this](const QUrl &url) { slotUrlEntered(url); }); 77 * connect(op, &KDirOperator::fileHighlighted, this, [this](const KFileItem &item) { slotFileHighlighted(item) }); 78 * connect(op, &KDirOperator::fileSelected, this, [this](const KFileItem &item) { slotFileSelected(item) }); 79 * connect(op, &KDirOperator::finishedLoading, this, [this]() { slotLoadingFinished(); }; 80 * 81 * KConfigGroup grp(KSharedConfig::openConfig(),"Your KDiroperator ConfigGroup" ); 82 * op->readConfig( &grp); 83 * op->setView(KFile::Default); 84 * \endcode 85 * 86 * This will create a childwidget of 'this' showing the directory contents 87 * of /home/gis in the default-view. The view is determined by the readConfig() 88 * call, which will read the KDirOperator settings, the user left your program 89 * with (and which you saved with op->writeConfig()). 90 * 91 * @short A widget for displaying files and browsing directories. 92 * @author Stephan Kulow <coolo@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org> 93 */ 94 class KIOFILEWIDGETS_EXPORT KDirOperator : public QWidget 95 { 96 Q_OBJECT 97 98 public: 99 /** 100 * The various action types. These values can be or'd together 101 */ 102 enum ActionType { 103 SortActions = 1, 104 ViewActions = 2, 105 NavActions = 4, 106 FileActions = 8, 107 AllActions = 15, 108 }; 109 110 /** 111 * Constructs the KDirOperator with no initial view. As the views are 112 * configurable, call readConfig() to load the user's configuration 113 * and then setView to explicitly set a view. 114 * 115 * This constructor doesn't start loading the url, setView will do it. 116 */ 117 explicit KDirOperator(const QUrl &urlName = QUrl{}, QWidget *parent = nullptr); 118 /** 119 * Destroys the KDirOperator. 120 */ 121 ~KDirOperator() override; 122 123 /** 124 * Enables/disables showing hidden files. 125 */ 126 virtual void setShowHiddenFiles(bool s); 127 128 /** 129 * @returns true when hidden files are shown or false otherwise. 130 */ 131 bool showHiddenFiles() const; 132 133 /** 134 * Stops loading immediately. You don't need to call this, usually. 135 */ 136 void close(); 137 138 /** 139 * Sets a filter like "*.cpp *.h *.o". Only files matching that filter 140 * will be shown. 141 * 142 * @see KDirLister::setNameFilter 143 * @see nameFilter 144 */ 145 void setNameFilter(const QString &filter); 146 147 /** 148 * @returns the current namefilter. 149 * @see setNameFilter 150 */ 151 QString nameFilter() const; 152 153 /** 154 * Sets a list of MIME types as filter. Only files of those MIME types 155 * will be shown. 156 * 157 * Example: 158 * \code 159 * QStringList filter; 160 * filter << "text/html" << "image/png" << "inode/directory"; 161 * dirOperator->setMimefilter( filter ); 162 * \endcode 163 * 164 * Node: Without the MIME type inode/directory, only files would be shown. 165 * Call updateDir() to apply it. 166 * 167 * @see KDirLister::setMimeFilter 168 * @see mimeFilter 169 */ 170 void setMimeFilter(const QStringList &mimetypes); 171 172 /** 173 * @returns the current MIME type filter. 174 */ 175 QStringList mimeFilter() const; 176 177 /** 178 * Only show the files in a given set of MIME types. 179 * This is useful in specialized applications (while file managers, on 180 * the other hand, want to show all MIME types). Internally uses 181 * KNewFileMenu::setSupportedMimeTypes 182 * 183 * Example: 184 * \code 185 * QStringList mimeTypes; 186 * mimeTypes << "text/html" << "inode/directory"; 187 * dirOperator->setNewFileMenuSupportedMimeTypes(mimeTypes); 188 * \endcode 189 * 190 * Note: If the list is empty, all options will be shown. Otherwise, 191 * without the MIME type inode/directory, only file options will be shown. 192 * 193 * @see KNewFileMenu::setSupportedMimeTypes 194 * @see newFileMenuSupportedMimeTypes 195 * @since 4.5 196 */ 197 void setNewFileMenuSupportedMimeTypes(const QStringList &mime); 198 199 /** 200 * @returns the current Supported Mimes Types. 201 * @since 4.5 202 */ 203 QStringList newFileMenuSupportedMimeTypes() const; 204 205 /** 206 * Setting this to true will make a directory get selected when trying to create a new one that has the same name. 207 * 208 * @since 5.76 209 */ 210 void setNewFileMenuSelectDirWhenAlreadyExist(bool selectOnDirExists); 211 212 /** 213 * Clears both the namefilter and MIME type filter, so that all files and 214 * directories will be shown. Call updateDir() to apply it. 215 * 216 * @see setMimeFilter 217 * @see setNameFilter 218 */ 219 void clearFilter(); 220 221 /** 222 * @returns the current url 223 */ 224 QUrl url() const; 225 226 /** 227 * Sets a new url to list. 228 * @param clearforward specifies whether the "forward" history should be cleared. 229 * @param url the URL to set 230 */ 231 virtual void setUrl(const QUrl &url, bool clearforward); 232 233 /** 234 * Clears the current selection and attempts to set @p url 235 * the current url file. 236 */ 237 void setCurrentItem(const QUrl &url); 238 239 /** 240 * Clears the current selection and attempts to set @p item 241 * as the current item. 242 */ 243 void setCurrentItem(const KFileItem &item); 244 245 /** 246 * Clears the current selection and attempts to set @p urls 247 * the current url files. 248 * @since 4.2 249 */ 250 void setCurrentItems(const QList<QUrl> &urls); 251 252 /** 253 * Clears the current selection and attempts to set @p items 254 * as the current items. 255 * @since 4.2 256 */ 257 void setCurrentItems(const KFileItemList &items); 258 259 /** 260 * Sets a new view to be used for showing and browsing files. 261 * Note: this will read the current url() to fill the view. 262 * 263 * @see KFileTreeView 264 * @see view 265 */ 266 virtual void setView(QAbstractItemView *view); 267 268 /** 269 * @returns the currently used view. 270 * @see setView 271 */ 272 QAbstractItemView *view() const; 273 274 /** 275 * Sets one of the predefined fileviews. 276 * @see KFile::FileView 277 */ 278 virtual void setView(KFile::FileView viewKind); 279 280 /** 281 * Returns the current view mode. 282 * @returns KFile::FileView 283 * @see KFile::FileView 284 * @since 5.0 285 */ 286 KFile::FileView viewMode() const; 287 288 /** 289 * Sets the way to sort files and directories. 290 */ 291 void setSorting(QDir::SortFlags); 292 293 /** 294 * @returns the current way of sorting files and directories 295 */ 296 QDir::SortFlags sorting() const; 297 298 /** 299 * @returns true if we are displaying the root directory of the current url 300 */ 301 bool isRoot() const; 302 303 /** 304 * @returns the object listing the directory 305 */ 306 KDirLister *dirLister() const; 307 308 /** 309 * @returns the progress widget, that is shown during directory listing. 310 * You can for example reparent() it to put it into a statusbar. 311 */ 312 QProgressBar *progressBar() const; 313 314 /** 315 * Sets the listing/selection mode for the views, an OR'ed combination of 316 * @li File 317 * @li Directory 318 * @li Files 319 * @li ExistingOnly 320 * @li LocalOnly 321 * 322 * You cannot mix File and Files of course, as the former means 323 * single-selection mode, the latter multi-selection. 324 */ 325 virtual void setMode(KFile::Modes m); 326 /** 327 * @returns the listing/selection mode. 328 */ 329 KFile::Modes mode() const; 330 331 /** 332 * Sets a preview-widget to be shown next to the file-view. 333 * The ownership of @p w is transferred to KDirOperator, so don't 334 * delete it yourself! 335 */ 336 virtual void setPreviewWidget(KPreviewWidgetBase *w); 337 338 /** 339 * @returns a list of all currently selected items. If there is no view, 340 * or there are no selected items, an empty list is returned. 341 */ 342 KFileItemList selectedItems() const; 343 344 /** 345 * @returns true if @p item is currently selected, or false otherwise. 346 */ 347 bool isSelected(const KFileItem &item) const; 348 349 /** 350 * @returns the number of directories in the currently listed url. 351 * Returns 0 if there is no view. 352 */ 353 int numDirs() const; 354 355 /** 356 * @returns the number of files in the currently listed url. 357 * Returns 0 if there is no view. 358 */ 359 int numFiles() const; 360 361 /** 362 * @returns a KCompletion object, containing all filenames and 363 * directories of the current directory/URL. 364 * You can use it to insert it into a KLineEdit or KComboBox 365 * Note: it will only contain files, after prepareCompletionObjects() 366 * has been called. It will be implicitly called from makeCompletion() 367 * or makeDirCompletion() 368 */ 369 KCompletion *completionObject() const; 370 371 /** 372 * @returns a KCompletion object, containing only all directories of the 373 * current directory/URL. 374 * You can use it to insert it into a KLineEdit or KComboBox 375 * Note: it will only contain directories, after 376 * prepareCompletionObjects() has been called. It will be implicitly 377 * called from makeCompletion() or makeDirCompletion() 378 */ 379 KCompletion *dirCompletionObject() const; 380 381 /** 382 * an accessor to a collection of all available Actions. The actions 383 * are static, they will be there all the time (no need to connect to 384 * the signals KActionCollection::inserted() or removed(). 385 * 386 * There are the following actions: 387 * 388 * @li popupMenu : an ActionMenu presenting a popupmenu with all actions 389 * @li up : changes to the parent directory 390 * @li back : goes back to the previous directory 391 * @li forward : goes forward in the history 392 * @li home : changes to the user's home directory 393 * @li reload : reloads the current directory 394 * @li mkdir : opens a dialog box to create a directory 395 * @li delete : deletes the selected files/directories 396 * @li sorting menu : an ActionMenu containing all sort-options 397 * @li by name : sorts by name 398 * @li by size : sorts by size 399 * @li by date : sorts by date 400 * @li by type : sorts by type 401 * @li descending : reverses the sort order 402 * @li view menu : an ActionMenu containing all actions concerning the view 403 * @li short view : shows a simple fileview 404 * @li detailed view : shows a detailed fileview (dates, permissions ,...) 405 * @li show hidden : shows hidden files 406 * @li preview : shows a preview next to the fileview 407 * @li properties : shows a KPropertiesDialog for the selected files 408 * 409 * The short and detailed view are in an exclusive group. The sort-by 410 * actions are in an exclusive group as well. Also the "separate dirs", 411 * "preview" and "single" actions are in an exclusive group. 412 * 413 * You can e.g. use 414 * \code 415 * actionCollection()->action( "up" )->plug( someToolBar ); 416 * \endcode 417 * to add a button into a toolbar, which makes the dirOperator change to 418 * its parent directory. 419 * 420 * @returns all available Actions 421 */ 422 KActionCollection *actionCollection() const; 423 424 /** 425 * Sets the config object and the to be used group in KDirOperator. This 426 * will be used to store the view's configuration. 427 * If you don't set this, the views cannot save and restore their 428 * configuration. 429 * 430 * Usually you call this right after KDirOperator creation so that the view 431 * instantiation can make use of it already. 432 * 433 * Note that KDirOperator does NOT take ownership of that object (typically 434 * it's KSharedConfig::openConfig() anyway. 435 * 436 * You must not delete the KConfig or KConfigGroup object (and master config object) before 437 * either deleting the KDirOperator or calling setViewConfig(0); or something like that 438 * 439 * @see viewConfig 440 * @see viewConfigGroup 441 */ 442 virtual void setViewConfig(KConfigGroup &configGroup); 443 444 /** 445 * @returns the group set by setViewConfig configuration. 446 */ 447 KConfigGroup *viewConfigGroup() const; 448 449 /** 450 * Reads the default settings for a view, i.e. the default KFile::FileView. 451 * Also reads the sorting and whether hidden files should be shown. 452 * Note: the default view will not be set - you have to call 453 * \code 454 * setView( KFile::Default ) 455 * \endcode 456 * to apply it. 457 * 458 * @see setView 459 * @see setViewConfig 460 * @see writeConfig 461 */ 462 virtual void readConfig(const KConfigGroup &configGroup); 463 464 /** 465 * Saves the current settings like sorting, simple or detailed view. 466 * 467 * @see readConfig 468 * @see setViewConfig 469 */ 470 virtual void writeConfig(KConfigGroup &configGroup); 471 472 /** 473 * This toggles between double/single click file and directory selection mode. 474 * When argument is true, files and directories are highlighted with single click and 475 * selected (executed) with double click. 476 * 477 * NOTE: this currently has no effect. 478 * 479 * The default follows the single/double click system setting. 480 */ 481 void setOnlyDoubleClickSelectsFiles(bool enable); 482 483 /** 484 * @returns whether files (not directories) should only be select()ed by 485 * double-clicks. 486 * @see setOnlyDoubleClickSelectsFiles 487 */ 488 bool onlyDoubleClickSelectsFiles() const; 489 490 /** 491 * Toggles whether setUrl is called on newly created directories. 492 * @since 5.62 493 */ 494 void setFollowNewDirectories(bool enable); 495 496 /** 497 * @returns true if setUrl is called on newly created directories, false 498 * otherwise. Enabled by default. 499 * @since 5.62 500 * @see setFollowNewDirectories 501 */ 502 bool followNewDirectories() const; 503 504 /** 505 * Toggles whether setUrl is called on selected directories when a tree view 506 * is used. 507 * @since 5.62 508 */ 509 void setFollowSelectedDirectories(bool enable); 510 511 /** 512 * @returns whether setUrl is called on selected directories when a tree 513 * view is used. Enabled by default. 514 * @since 5.62 515 */ 516 bool followSelectedDirectories() const; 517 518 #if KIOFILEWIDGETS_BUILD_DEPRECATED_SINCE(5, 78) 519 /** 520 * Creates the given directory/url. If it is a relative path, 521 * it will be completed with the current directory. 522 * If enterDirectory is true, the directory will be entered after a 523 * successful operation. If unsuccessful, a messagebox will be presented 524 * to the user. 525 * @returns true if the directory could be created. 526 */ 527 KIOFILEWIDGETS_DEPRECATED_VERSION(5, 528 78, 529 "Deprecated for lack of usage; use the other" 530 " KDirOperator::mkdir() method instead.") 531 virtual bool mkdir(const QString &directory, bool enterDirectory = true); 532 #endif 533 534 /** 535 * Starts and returns a KIO::DeleteJob to delete the given @p items. 536 * 537 * @param items the list of items to be deleted 538 * @param parent the parent widget used for the confirmation dialog 539 * @param ask specifies whether a confirmation dialog should be shown 540 * @param showProgress passed to the DeleteJob to show a progress dialog 541 */ 542 virtual KIO::DeleteJob *del(const KFileItemList &items, QWidget *parent = nullptr, bool ask = true, bool showProgress = true); 543 544 /** 545 * Clears the forward and backward history. 546 */ 547 void clearHistory(); 548 549 /** 550 * When using the up or back actions to navigate the directory hierarchy, KDirOperator 551 * can highlight the directory that was just left. 552 * 553 * For example: 554 * - starting in /a/b/c/, going up to /a/b, "c" will be highlighted 555 * - starting in /a/b/c, going up (twice) to /a, "b" will be highlighted; 556 * using the back action to go to /a/b/, "c" will be highlighted 557 * - starting in /a, going to "b", then going to "c", using the back action 558 * to go to /a/b/, "c" will be highlighted; using the back action again to go 559 * to /a/, "b" will be highlighted 560 * 561 * @see dirHighlighting. The default is to highlight directories when going back/up. 562 */ 563 virtual void setEnableDirHighlighting(bool enable); 564 565 /** 566 * @returns whether the last directory will be made the current item 567 * (and hence highlighted) when going up or back in the directory hierarchy 568 * 569 * Directories are highlighted by default. 570 */ 571 bool dirHighlighting() const; 572 573 /** 574 * @returns true if we are in directory-only mode, that is, no files are 575 * shown. 576 */ 577 bool dirOnlyMode() const; 578 579 static bool dirOnlyMode(uint mode); 580 581 /** 582 * Sets up the action menu. 583 * @param whichActions is an value of OR'd ActionTypes that controls which actions to show in the action menu 584 */ 585 void setupMenu(int whichActions); 586 587 /** 588 * Reimplemented - allow dropping of files if @p b is true, defaults to true since 5.59 589 * @param b true if the widget should allow dropping of files 590 */ 591 virtual void setAcceptDrops(bool b); 592 593 /** 594 * Sets the options for dropping files. 595 * CURRENTLY NOT IMPLEMENTED 596 */ 597 virtual void setDropOptions(int options); 598 599 /** 600 * Starts and returns a KIO::CopyJob to trash the given @p items. 601 * 602 * @param items the list of items to be trashed 603 * @param parent the parent widget used for the confirmation dialog 604 * @param ask specifies whether a confirmation dialog should be shown 605 * @param showProgress passed to the CopyJob to show a progress dialog 606 */ 607 virtual KIO::CopyJob *trash(const KFileItemList &items, QWidget *parent, bool ask = true, bool showProgress = true); 608 609 /** 610 * Returns the preview generator for the current view. 611 * @since 4.2 612 */ 613 KFilePreviewGenerator *previewGenerator() const; 614 615 /** 616 * Forces the inline previews to be shown or hidden, depending on @p show. 617 * 618 * @param show Whether to show inline previews or not. 619 * @since 4.2 620 */ 621 void setInlinePreviewShown(bool show); 622 623 /** 624 * Returns the position where icons are shown relative to the labels 625 * of file items in the icon view. 626 * @since 4.2.3 627 */ 628 QStyleOptionViewItem::Position decorationPosition() const; 629 630 /** 631 * Sets the position where icons shall be shown relative to the labels 632 * of file items in the icon view. 633 * @since 4.2.3 634 */ 635 void setDecorationPosition(QStyleOptionViewItem::Position position); 636 637 /** 638 * Returns whether the inline previews are shown or not. 639 * @since 4.2 640 */ 641 bool isInlinePreviewShown() const; 642 643 #if KIOFILEWIDGETS_ENABLE_DEPRECATED_SINCE(5, 76) 644 /** 645 * Returns the icon zoom. 646 * @since 4.2 647 */ 648 KIOFILEWIDGETS_DEPRECATED_VERSION(5, 76, "Use KDirOperator::iconSize()") 649 int iconsZoom() const; 650 #endif 651 652 /** 653 * Returns the icon size in pixels, ranged from KIconLoader::SizeSmall (16) to 654 * KIconLoader::SizeEnormous (128). 655 * 656 * @since 5.76 657 */ 658 int iconSize() const; 659 660 /** 661 * If the system is set up to trigger items on single click, if @p isSaving 662 * is true, we will force to double click to accept. 663 * @note this is false by default 664 * @since 4.2 665 */ 666 void setIsSaving(bool isSaving); 667 668 /** 669 * Returns whether KDirOperator will force a double click to accept. 670 * @note this is false by default 671 * @since 4.2 672 */ 673 bool isSaving() const; 674 675 /** 676 * Returns the URL schemes that the file widget should allow navigating to. 677 * 678 * If the returned list is empty, all schemes are supported. 679 * 680 * @sa QFileDialog::supportedSchemes 681 * @since 5.43 682 */ 683 QStringList supportedSchemes() const; 684 685 /** 686 * Call with @c true to add open-with actions to items in the view. 687 * This can be useful when you're attaching an image or text file to 688 * an email or uploading an image to some online service, and need to 689 * check the contents before going forward. 690 * 691 * @since 5.87 692 */ 693 void showOpenWithActions(bool enable); 694 695 protected: 696 /** 697 * A view factory for creating predefined fileviews. Called internally by setView, 698 * but you can also call it directly. Reimplement this if you depend on self defined fileviews. 699 * @param parent is the QWidget to be set as parent 700 * @param viewKind is the predefined view to be set, note: this can be several ones OR:ed together 701 * @returns the created view 702 * @see KFile::FileView 703 * @see setView 704 */ 705 virtual QAbstractItemView *createView(QWidget *parent, KFile::FileView viewKind); 706 707 /** 708 * Sets a custom KDirLister to list directories. 709 * The KDirOperator takes ownership of the given KDirLister. 710 */ 711 virtual void setDirLister(KDirLister *lister); 712 713 void resizeEvent(QResizeEvent *event) override; 714 715 void keyPressEvent(QKeyEvent *event) override; // TODO KF6 REMOVE 716 717 /** 718 * Sets up all the actions. Called from the constructor, you usually 719 * better not call this. 720 */ 721 void setupActions(); 722 723 /** 724 * Updates the sorting-related actions to comply with the current sorting 725 * @see sorting 726 */ 727 void updateSortActions(); 728 729 /** 730 * Updates the view-related actions to comply with the current 731 * KFile::FileView 732 */ 733 void updateViewActions(); 734 735 /** 736 * Sets up the context-menu with all the necessary actions. Called from the 737 * constructor, you usually don't need to call this. 738 */ 739 void setupMenu(); 740 741 /** 742 * Synchronizes the completion objects with the entries of the 743 * currently listed url. 744 * 745 * Automatically called from makeCompletion() and 746 * makeDirCompletion() 747 */ 748 void prepareCompletionObjects(); 749 750 /** 751 * Checks if there support from KIO::PreviewJob for the currently 752 * shown files, taking mimeFilter() and nameFilter() into account 753 * Enables/disables the preview-action accordingly. 754 */ 755 bool checkPreviewSupport(); 756 757 /** 758 * Called upon right-click to activate the popupmenu. 759 */ 760 virtual void activatedMenu(const KFileItem &item, const QPoint &pos); 761 762 void changeEvent(QEvent *event) override; 763 764 bool eventFilter(QObject *watched, QEvent *event) override; 765 766 public Q_SLOTS: 767 /** 768 * Goes one step back in the history and opens that url. 769 */ 770 virtual void back(); 771 772 /** 773 * Goes one step forward in the history and opens that url. 774 */ 775 virtual void forward(); 776 777 /** 778 * Enters the home directory. 779 */ 780 virtual void home(); 781 782 /** 783 * Goes one directory up from the current url. 784 */ 785 virtual void cdUp(); 786 787 /** 788 * to update the view after changing the settings 789 */ 790 void updateDir(); 791 792 /** 793 * Re-reads the current url. 794 */ 795 virtual void rereadDir(); 796 797 /** 798 * Opens a dialog to create a new directory. 799 */ 800 virtual void mkdir(); 801 802 /** 803 * Deletes the currently selected files/directories. 804 */ 805 virtual void deleteSelected(); 806 807 /** 808 * Enables/disables actions that are selection dependent. Call this e.g. 809 * when you are about to show a popup menu using some of KDirOperators 810 * actions. 811 */ 812 void updateSelectionDependentActions(); 813 814 /** 815 * Tries to complete the given string (only completes files). 816 */ 817 QString makeCompletion(const QString &); 818 819 /** 820 * Tries to complete the given string (only completes directories). 821 */ 822 QString makeDirCompletion(const QString &); 823 824 /** 825 * Initiates a rename operation on the currently selected files/directories, 826 * prompting the user to choose a new name(s) for the currently selected items 827 * @since 5.67 828 */ 829 void renameSelected(); 830 831 /** 832 * Trashes the currently selected files/directories. 833 * 834 * This function used to take activation reason and keyboard modifiers, 835 * in order to call deleteSelected() if the user wanted to delete. 836 * Instead, call deleteSelected(). 837 * 838 * FIXME KAction Port: link deleteSelected() up correctly 839 */ 840 virtual void trashSelected(); 841 842 #if KIOFILEWIDGETS_ENABLE_DEPRECATED_SINCE(5, 76) 843 /** 844 * Notifies that the icons size should change. @p value is an int ranged from 0 to 100. 845 * 100 means KIconLoader::SizeEnormous. 846 * @since 4.2 847 */ 848 KIOFILEWIDGETS_DEPRECATED_VERSION(5, 76, "Use KDirOperator::setIconSize(int)") 849 void setIconsZoom(int value); 850 #endif 851 852 /** 853 * Notifies that the icons size should change. @p value is the icon size in pixels, ranged 854 * from KIconLoader::SizeSmall (16) to KIconLoader::SizeEnormous (128). 855 * 856 * @since 5.76 857 */ 858 void setIconSize(int value); 859 860 /** 861 * Set the URL schemes that the file widget should allow navigating to. 862 * 863 * If the returned list is empty, all schemes are supported. Examples for 864 * schemes are @c "file" or @c "ftp". 865 * 866 * @sa QFileDialog::setSupportedSchemes 867 * @since 5.43 868 */ 869 void setSupportedSchemes(const QStringList &schemes); 870 871 protected Q_SLOTS: 872 /** 873 * Restores the normal cursor after showing the busy-cursor. Also hides 874 * the progressbar. 875 */ 876 void resetCursor(); 877 878 /** 879 * Called after setUrl() to load the directory, update the history, 880 * etc. 881 */ 882 void pathChanged(); 883 884 /** 885 * Enters the directory specified by the given @p item. 886 */ 887 virtual void selectDir(const KFileItem &item); 888 889 /** 890 * Emits fileSelected( item ) 891 */ 892 void selectFile(const KFileItem &item); 893 894 /** 895 * Emits fileHighlighted(item) 896 */ 897 void highlightFile(const KFileItem &item); 898 899 /** 900 * Changes sorting to sort by name 901 */ 902 void sortByName(); 903 904 /** 905 * Changes sorting to sort by size 906 */ 907 void sortBySize(); 908 909 /** 910 * Changes sorting to sort by date 911 */ 912 void sortByDate(); 913 914 /** 915 * Changes sorting to sort by date 916 */ 917 void sortByType(); 918 919 /** 920 * Changes sorting to reverse sorting 921 */ 922 void sortReversed(); 923 924 /** 925 * Toggles showing directories first / having them sorted like files. 926 */ 927 void toggleDirsFirst(); 928 929 /** 930 * Toggles case sensitive / case insensitive sorting 931 */ 932 void toggleIgnoreCase(); 933 934 /** 935 * Tries to make the given @p match as current item in the view and emits 936 * completion( match ) 937 */ 938 void slotCompletionMatch(const QString &match); 939 940 Q_SIGNALS: 941 void urlEntered(const QUrl &); 942 void updateInformation(int files, int dirs); 943 void completion(const QString &); 944 void finishedLoading(); 945 946 /** 947 * Emitted whenever the current fileview is changed, either by an explicit 948 * call to setView() or by the user selecting a different view thru 949 * the GUI. 950 */ 951 void viewChanged(QAbstractItemView *newView); 952 953 /** 954 * Emitted when a file is highlighted or generally the selection changes in 955 * multiselection mode. In the latter case, @p item is a null KFileItem. 956 * You can access the selected items with selectedItems(). 957 */ 958 void fileHighlighted(const KFileItem &item); 959 void dirActivated(const KFileItem &item); 960 void fileSelected(const KFileItem &item); 961 /** 962 * Emitted when files are dropped. Dropping files is disabled by 963 * default. You need to enable it with setAcceptDrops() 964 * @param item the item on which the drop occurred or 0. 965 * @param event the drop event itself. 966 * @param urls the urls that where dropped. 967 */ 968 void dropped(const KFileItem &item, QDropEvent *event, const QList<QUrl> &urls); 969 970 /** 971 * Emitted just before the context menu is shown, allows users to 972 * extend the menu with custom actions. 973 * 974 * @param item the file on which the context menu was invoked 975 * @param menu the context menu, pre-populated with the file-management actions 976 * @since 4.2 977 */ 978 void contextMenuAboutToShow(const KFileItem &item, QMenu *menu); 979 980 /** 981 * Will notify that the icon size has changed. Since we save the icon size depending 982 * on the view type (list view or a different kind of view), a call to setView() can 983 * trigger this signal to be emitted. 984 * @since 4.2 985 */ 986 void currentIconSizeChanged(int size); 987 988 /** 989 * Triggered when the user hit Enter/Return 990 * @since 5.57 991 */ 992 void keyEnterReturnPressed(); 993 994 private: 995 friend class KDirOperatorPrivate; 996 std::unique_ptr<KDirOperatorPrivate> d; 997 }; 998 999 #endif 1000