KDELibs4Support

kdirselectdialog.h
1 /*
2  Copyright (C) 2001 Michael Jarrett <[email protected]>
3  Copyright (C) 2001 Carsten Pfeiffer <[email protected]>
4  Copyright (C) 2009 Shaun Reich <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef KDIRSELECTDIALOG_H
22 #define KDIRSELECTDIALOG_H
23 
24 #include <kdelibs4support_export.h>
25 
26 #include <QDialog>
27 #include <QUrl>
28 
29 class QAbstractItemView;
30 
31 /**
32  * A pretty dialog for a KDirSelect control for selecting directories.
33  * @author Michael Jarrett <[email protected]>
34  * @deprecated since 5.0, use QFileDialog::getExistingDirectoryUrl instead.
35  */
36 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KDirSelectDialog : public QDialog
37 {
38  Q_OBJECT
39 
40 public:
41  /**
42  * Creates a new directory selection dialog.
43  * @internal use the static selectDirectory function
44  * @param startDir the directory, initially shown
45  * @param localOnly unused. You can only select paths below the startDir
46  * @param parent the parent for the dialog, usually 0L
47  */
48  KDELIBS4SUPPORT_DEPRECATED explicit KDirSelectDialog(const QUrl &startDir = QUrl(),
49  bool localOnly = false,
50  QWidget *parent = nullptr);
51 
52  /**
53  * Destroys the directory selection dialog.
54  */
55  ~KDirSelectDialog() override;
56 
57  /**
58  * Returns the currently selected URL, or an empty one if no item is selected.
59  *
60  * If the URL entered in the combobox is valid and exists, it is returned.
61  * Otherwise, the URL selected in the treeview is returned instead.
62  */
63  QUrl url() const;
64 
65  /**
66  * Returns a pointer to the view which is used for displaying the directories.
67  */
68  QAbstractItemView *view() const;
69 
70  /**
71  * Returns whether only local directories can be selected.
72  */
73  bool localOnly() const;
74 
75  /**
76  * Creates a KDirSelectDialog, and returns the result.
77  * @param startDir the directory, initially shown
78  * The tree will display this directory and subdirectories of it.
79  * @param localOnly unused. You can only select paths below the startDir
80  * @param parent the parent widget to use for the dialog, or NULL to create a parent-less dialog
81  * @param caption the caption to use for the dialog, or QString() for the default caption
82  * @return The URL selected, or an empty URL if the user canceled
83  * or no URL was selected.
84  *
85  * @deprecated since 5.0, use QFileDialog::getExistingDirectory (if localOnly was true)
86  * or QFileDialog::getExistingDirectoryUrl (if localOnly was false) instead.
87  */
88  static KDELIBS4SUPPORT_DEPRECATED QUrl selectDirectory(const QUrl &startDir = QUrl(),
89  bool localOnly = false, QWidget *parent = nullptr,
90  const QString &caption = QString());
91 
92  /**
93  * @return The path for the root node
94  */
95  QUrl startDir() const;
96 
97 public Q_SLOTS:
98  /**
99  * Sets the current @p url in the dialog.
100  */
101  void setCurrentUrl(const QUrl &url);
102 
103 protected:
104  void accept() override;
105 
106  /**
107  * Reimplemented for saving the dialog geometry.
108  */
109  void hideEvent(QHideEvent *event) override;
110 
111 private:
112  class Private;
113  Private *const d;
114 
115  Q_PRIVATE_SLOT(d, void slotCurrentChanged())
116  Q_PRIVATE_SLOT(d, void slotExpand(const QModelIndex &))
117  Q_PRIVATE_SLOT(d, void slotUrlActivated(const QString &))
118  Q_PRIVATE_SLOT(d, void slotComboTextChanged(const QString &))
119  Q_PRIVATE_SLOT(d, void slotContextMenuRequested(const QPoint &))
120  Q_PRIVATE_SLOT(d, void slotNewFolder())
121  Q_PRIVATE_SLOT(d, void slotMoveToTrash())
122  Q_PRIVATE_SLOT(d, void slotDelete())
123  Q_PRIVATE_SLOT(d, void slotProperties())
124 };
125 
126 #endif
Q_SLOTSQ_SLOTS
QString caption()
Returns a text for the window caption.
Definition: kglobal.cpp:175
virtual void hideEvent(QHideEvent *event)
virtual void accept()
A pretty dialog for a KDirSelect control for selecting directories.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 28 2023 03:54:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.