summaryrefslogtreecommitdiffstats
path: root/tdeio/tdefile/kdirselectdialog.h
blob: 746064c68febf344ce817d6008e0b72dc5c4ad93 (plain)
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
129
130
131
/*
  Copyright (C) 2001 Michael Jarrett <michaelj@corel.com>
  Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>

  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 <kdialogbase.h>
#include <kurl.h>

class TQPopupMenu;
class TQVBoxLayout;
class TDEConfig;
class KFileTreeBranch;
class KFileTreeView;
class KFileTreeViewItem;
class KToggleAction;

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

public:
    /**
     * The constructor. Creates a dialog to select a directory (url).
     * @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
     * @param name the TQObject::name
     * @param modal if the dialog is modal or not
     */
    KDirSelectDialog(const TQString& startDir = TQString::null,
                     bool localOnly = false,
                     TQWidget *parent = 0L,
                     const char *name = 0, bool modal = false);

    /**
     */
    ~KDirSelectDialog();

    /**
     * Returns the currently-selected URL, or a blank URL if none is selected.
     * @return The currently-selected URL, if one was selected.
     */
    KURL url() const;

    KFileTreeView * view() const { return m_treeView; }

    bool localOnly() const { return m_localOnly; }

    /**
     * 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 TQString::null for the default caption
     * @return The URL selected, or an empty URL if the user canceled
     * or no URL was selected.
     */
    static KURL selectDirectory( const TQString& startDir = TQString::null,
                                 bool localOnly = false, TQWidget *parent = 0L,
                                 const TQString& caption = TQString::null);

    /**
     * @return The path for the root node
     */
    TQString startDir() const { return m_startDir; }

public slots:
    void setCurrentURL( const KURL& url );

protected slots:
    virtual void slotUser1();

protected:
    virtual void accept();

    // Layouts protected so that subclassing is easy
    TQVBoxLayout *m_mainLayout;
    TQString m_startDir;

private slots:
    void slotCurrentChanged();
    void slotURLActivated( const TQString& );
    void slotNextDirToList( KFileTreeViewItem *dirItem );
    void slotComboTextChanged( const TQString& text );
    void slotContextMenu( KListView *, TQListViewItem *, const TQPoint & );
    void slotShowHiddenFoldersToggled();
    void slotMkdir();

private:
    void readConfig( TDEConfig *config, const TQString& group );
    void saveConfig( TDEConfig *config, const TQString& group );
    void openNextDir( KFileTreeViewItem *parent );
    KFileTreeBranch * createBranch( const KURL& url );

    KFileTreeView *m_treeView;
    TQPopupMenu *m_contextMenu;
    KToggleAction *m_showHiddenFolders;
    bool m_localOnly;

protected:
    virtual void virtual_hook( int id, void* data );
private:
    class KDirSelectDialogPrivate;
    KDirSelectDialogPrivate *d;
};

#endif