~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/dialogs/qfiledialog_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the dialog module of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QFILEDIALOG_P_H
 
30
#define QFILEDIALOG_P_H
 
31
 
 
32
//
 
33
//  W A R N I N G
 
34
//  -------------
 
35
//
 
36
// This file is not part of the Qt API.  It exists purely as an
 
37
// implementation detail.  This header file may change from version to
 
38
// version without notice, or even be removed.
 
39
//
 
40
// We mean it.
 
41
//
 
42
 
 
43
#include <private/qdialog_p.h>
 
44
#include <qitemselectionmodel.h>
 
45
#include <qabstractitemview.h>
 
46
#include <qtoolbutton.h>
 
47
 
 
48
class QListView;
 
49
class QTreeView;
 
50
class QDirModel;
 
51
class QComboBox;
 
52
class QAction;
 
53
class QPushButton;
 
54
class QFileDialogLineEdit;
 
55
class QGridLayout;
 
56
class QLabel;
 
57
 
 
58
class QFileDialogPrivate : public QDialogPrivate
 
59
{
 
60
    Q_DECLARE_PUBLIC(QFileDialog)
 
61
public:
 
62
    QFileDialogPrivate();
 
63
 
 
64
    // private slots
 
65
    void reload();
 
66
    void navigateToPrevious();
 
67
    void navigateToParent();
 
68
    void enterDirectory(const QModelIndex &index);
 
69
    void enterDirectory(const QString &path);
 
70
    void enterDirectory();
 
71
    void showList();
 
72
    void showDetails();
 
73
    void showHidden();
 
74
    void useFilter(const QString &filter);
 
75
    void updateFileName(const QItemSelection &selection);
 
76
    void autoCompleteFileName(const QString &text);
 
77
    void autoCompleteDirectory(const QString &text);
 
78
    void showContextMenu(const QPoint &pos);
 
79
    void createDirectory();
 
80
    void renameCurrent();
 
81
    void deleteCurrent();
 
82
    void sortByName();
 
83
    void sortBySize();
 
84
    void sortByDate();
 
85
    void setUnsorted();
 
86
    void currentChanged(const QModelIndex &index);
 
87
 
 
88
    // setup
 
89
    void setup(const QString &directory, const QStringList &nameFilter);
 
90
    void setupActions();
 
91
    void setupListView(const QModelIndex &index, QGridLayout *grid);
 
92
    void setupTreeView(const QModelIndex &index, QGridLayout *grid);
 
93
    void setupToolButtons(const QModelIndex &index, QGridLayout *grid);
 
94
    void setupWidgets(QGridLayout *grid);
 
95
 
 
96
    // other
 
97
    void updateButtons(const QModelIndex &index);
 
98
    void setRootIndex(const QModelIndex &index);
 
99
    QModelIndex rootIndex() const;
 
100
    void setDirSorting(QDir::SortFlags sort);
 
101
    void setDirFilter(QDir::Filters filter);
 
102
    QDir::Filters filterForMode(QFileDialog::FileMode mode);
 
103
    QAbstractItemView::SelectionMode selectionMode(QFileDialog::FileMode mode);
 
104
    QModelIndex matchDir(const QString &text, const QModelIndex &first) const;
 
105
    QModelIndex matchName(const QString &name, const QModelIndex &first) const;
 
106
 
 
107
    // inlined stuff
 
108
    inline QString tr(const char *text) const { return QObject::tr(text); }
 
109
    inline QString toNative(const QString &path) const
 
110
        { return QDir::convertSeparators(path); }
 
111
    inline QString toInternal(const QString &path) const
 
112
        {
 
113
#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX)
 
114
            QString n(path);
 
115
            for (int i = 0; i < (int)n.length(); ++i)
 
116
                if (n[i] == '\\') n[i] = '/';
 
117
            return n;
 
118
#else // the compile should optimize away this
 
119
            return path;
 
120
#endif
 
121
        }
 
122
    inline QFileDialog::ViewMode viewMode() const
 
123
        { return (listModeButton->isDown() ? QFileDialog::List : QFileDialog::Detail); }
 
124
 
 
125
    // static stuff
 
126
    static QString encodeFileName(const QString &filename);
 
127
    static QString workingDirectory(const QString &path, bool encode = true);
 
128
    static QString initialSelection(const QString &path, bool encode = true);
 
129
 
 
130
    // data
 
131
    QDirModel *model;
 
132
    QItemSelectionModel *selections;
 
133
    QListView *listView;
 
134
    QTreeView *treeView;
 
135
    
 
136
    QFileDialog::FileMode fileMode;
 
137
    QFileDialog::AcceptMode acceptMode;
 
138
    bool confirmOverwrite;
 
139
    QString defaultSuffix;
 
140
 
 
141
    QList<QPersistentModelIndex> history;
 
142
 
 
143
    QComboBox *lookInCombo;
 
144
    QFileDialogLineEdit *fileNameEdit;
 
145
    QFileDialogLineEdit *lookInEdit;
 
146
    QComboBox *fileTypeCombo;
 
147
 
 
148
    QAction *openAction;
 
149
    QAction *renameAction;
 
150
    QAction *deleteAction;
 
151
 
 
152
    QAction *reloadAction;
 
153
    QAction *sortByNameAction;
 
154
    QAction *sortBySizeAction;
 
155
    QAction *sortByDateAction;
 
156
    QAction *unsortedAction;
 
157
    QAction *showHiddenAction;
 
158
 
 
159
    QPushButton *acceptButton;
 
160
    QPushButton *rejectButton;
 
161
 
 
162
    QToolButton *backButton;
 
163
    QToolButton *toParentButton;
 
164
    QToolButton *newFolderButton;
 
165
    QToolButton *detailModeButton;
 
166
    QToolButton *listModeButton;
 
167
 
 
168
    QLabel *lookInLabel;
 
169
    QLabel *fileNameLabel;
 
170
    QLabel *fileTypeLabel;
 
171
};
 
172
 
 
173
struct QFileDialogArgs
 
174
{
 
175
    QFileDialogArgs() : parent(0), mode(QFileDialog::AnyFile) {}
 
176
 
 
177
    QWidget *parent;
 
178
    QString caption;
 
179
    QString directory;
 
180
    QString selection;
 
181
    QString filter;
 
182
    QFileDialog::FileMode mode;
 
183
    QFileDialog::Options options;
 
184
};
 
185
 
 
186
#endif // QFILEDIALOG_P_H