File indexing completed on 2025-01-12 12:26:23
0001 /* 0002 Copyright (C) 2001 Michael Jarrett <michaelj@corel.com> 0003 Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org> 0004 Copyright (C) 2009 Shaun Reich <shaun.reich@kdemail.net> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Library General Public 0008 License version 2 as published by the Free Software Foundation. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KDIRSELECTDIALOG_H 0022 #define KDIRSELECTDIALOG_H 0023 0024 #include <kdelibs4support_export.h> 0025 0026 #include <QDialog> 0027 #include <QUrl> 0028 0029 class QAbstractItemView; 0030 0031 /** 0032 * A pretty dialog for a KDirSelect control for selecting directories. 0033 * @author Michael Jarrett <michaelj@corel.com> 0034 * @deprecated since 5.0, use QFileDialog::getExistingDirectoryUrl instead. 0035 */ 0036 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KDirSelectDialog : public QDialog 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 /** 0042 * Creates a new directory selection dialog. 0043 * @internal use the static selectDirectory function 0044 * @param startDir the directory, initially shown 0045 * @param localOnly unused. You can only select paths below the startDir 0046 * @param parent the parent for the dialog, usually 0L 0047 */ 0048 KDELIBS4SUPPORT_DEPRECATED explicit KDirSelectDialog(const QUrl &startDir = QUrl(), 0049 bool localOnly = false, 0050 QWidget *parent = nullptr); 0051 0052 /** 0053 * Destroys the directory selection dialog. 0054 */ 0055 ~KDirSelectDialog() override; 0056 0057 /** 0058 * Returns the currently selected URL, or an empty one if no item is selected. 0059 * 0060 * If the URL entered in the combobox is valid and exists, it is returned. 0061 * Otherwise, the URL selected in the treeview is returned instead. 0062 */ 0063 QUrl url() const; 0064 0065 /** 0066 * Returns a pointer to the view which is used for displaying the directories. 0067 */ 0068 QAbstractItemView *view() const; 0069 0070 /** 0071 * Returns whether only local directories can be selected. 0072 */ 0073 bool localOnly() const; 0074 0075 /** 0076 * Creates a KDirSelectDialog, and returns the result. 0077 * @param startDir the directory, initially shown 0078 * The tree will display this directory and subdirectories of it. 0079 * @param localOnly unused. You can only select paths below the startDir 0080 * @param parent the parent widget to use for the dialog, or NULL to create a parent-less dialog 0081 * @param caption the caption to use for the dialog, or QString() for the default caption 0082 * @return The URL selected, or an empty URL if the user canceled 0083 * or no URL was selected. 0084 * 0085 * @deprecated since 5.0, use QFileDialog::getExistingDirectory (if localOnly was true) 0086 * or QFileDialog::getExistingDirectoryUrl (if localOnly was false) instead. 0087 */ 0088 static KDELIBS4SUPPORT_DEPRECATED QUrl selectDirectory(const QUrl &startDir = QUrl(), 0089 bool localOnly = false, QWidget *parent = nullptr, 0090 const QString &caption = QString()); 0091 0092 /** 0093 * @return The path for the root node 0094 */ 0095 QUrl startDir() const; 0096 0097 public Q_SLOTS: 0098 /** 0099 * Sets the current @p url in the dialog. 0100 */ 0101 void setCurrentUrl(const QUrl &url); 0102 0103 protected: 0104 void accept() override; 0105 0106 /** 0107 * Reimplemented for saving the dialog geometry. 0108 */ 0109 void hideEvent(QHideEvent *event) override; 0110 0111 private: 0112 class Private; 0113 Private *const d; 0114 0115 Q_PRIVATE_SLOT(d, void slotCurrentChanged()) 0116 Q_PRIVATE_SLOT(d, void slotExpand(const QModelIndex &)) 0117 Q_PRIVATE_SLOT(d, void slotUrlActivated(const QString &)) 0118 Q_PRIVATE_SLOT(d, void slotComboTextChanged(const QString &)) 0119 Q_PRIVATE_SLOT(d, void slotContextMenuRequested(const QPoint &)) 0120 Q_PRIVATE_SLOT(d, void slotNewFolder()) 0121 Q_PRIVATE_SLOT(d, void slotMoveToTrash()) 0122 Q_PRIVATE_SLOT(d, void slotDelete()) 0123 Q_PRIVATE_SLOT(d, void slotProperties()) 0124 }; 0125 0126 #endif