File: kdirselectdialog.h

package info (click to toggle)
kde4libs 4%3A4.14.2-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,316 kB
  • sloc: cpp: 761,810; xml: 12,344; ansic: 6,295; java: 4,060; perl: 2,938; yacc: 2,507; python: 1,207; sh: 1,179; ruby: 337; lex: 278; makefile: 29
file content (128 lines) | stat: -rw-r--r-- 4,347 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
  Copyright (C) 2001 Michael Jarrett <michaelj@corel.com>
  Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
  Copyright (C) 2009 Shaun Reich <shaun.reich@kdemail.net>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License version 2 as published by the Free Software Foundation.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public License
  along with this library; see the file COPYING.LIB.  If not, write to
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA 02110-1301, USA.
*/

#ifndef KDIRSELECTDIALOG_H
#define KDIRSELECTDIALOG_H

#include <kfile_export.h>

#include <kdialog.h>
#include <kurl.h>

class QAbstractItemView;

/**
 * A pretty dialog for a KDirSelect control for selecting directories.
 * @author Michael Jarrett <michaelj@corel.com>
 * @see KFileDialog
 */
class KFILE_EXPORT KDirSelectDialog : public KDialog
{
    Q_OBJECT

public:
    /**
     * Creates a new directory selection dialog.
     * @internal use the static selectDirectory function
     * @param startDir the directory, initially shown
     * @param localOnly unused. You can only select paths below the startDir
     * @param parent the parent for the dialog, usually 0L
     */
    explicit KDirSelectDialog(const KUrl& startDir = KUrl(),
                              bool localOnly = false,
                              QWidget *parent = 0L);

    /**
     * Destroys the directory selection dialog.
     */
    ~KDirSelectDialog();

    /**
     * Returns the currently selected URL, or an empty one if no item is selected.
     *
     * If the URL entered in the combobox is valid and exists, it is returned.
     * Otherwise, the URL selected in the treeview is returned instead.
     */
    KUrl url() const;

    /**
     * Returns a pointer to the view which is used for displaying the directories.
     */
    QAbstractItemView* view() const;

    /**
     * Returns whether only local directories can be selected.
     */
    bool localOnly() const;

    /**
     * Creates a KDirSelectDialog, and returns the result.
     * @param startDir the directory, initially shown
     * The tree will display this directory and subdirectories of it.
     * @param localOnly unused. You can only select paths below the startDir
     * @param parent the parent widget to use for the dialog, or NULL to create a parent-less dialog
     * @param caption the caption to use for the dialog, or QString() for the default caption
     * @return The URL selected, or an empty URL if the user canceled
     * or no URL was selected.
     *
     * NOTE: if you use this method and nothing else from libkfile,
     * then you can use KFileDialog::getExistingDirectory (if localOnly was true)
     * or KFileDialog::getExistingDirectoryUrl (if localOnly was false),
     * and then you can link to libkio only instead of libkfile.
     */
    static KUrl selectDirectory( const KUrl& startDir = KUrl(),
                                 bool localOnly = false, QWidget *parent = 0L,
                                 const QString& caption = QString());

    /**
     * @return The path for the root node
     */
    KUrl startDir() const;

public Q_SLOTS:
    /**
     * Sets the current @p url in the dialog.
     */
    void setCurrentUrl( const KUrl& url );

protected:
    virtual void accept();

    /**
     * Reimplemented for saving the dialog geometry.
     */
    virtual void hideEvent( QHideEvent *event );

private:
    class Private;
    Private* const d;

    Q_PRIVATE_SLOT( d, void slotCurrentChanged() )
    Q_PRIVATE_SLOT( d, void slotExpand(const QModelIndex&) )
    Q_PRIVATE_SLOT( d, void slotUrlActivated(const QString&) )
    Q_PRIVATE_SLOT( d, void slotComboTextChanged(const QString&) )
    Q_PRIVATE_SLOT( d, void slotContextMenuRequested(const QPoint&) )
    Q_PRIVATE_SLOT( d, void slotNewFolder() )
    Q_PRIVATE_SLOT( d, void slotMoveToTrash() )
    Q_PRIVATE_SLOT( d, void slotDelete() )
    Q_PRIVATE_SLOT( d, void slotProperties() )
};

#endif