source: trunk/src/gui/util/qcompleter.h@ 1168

Last change on this file since 1168 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QCOMPLETER_H
43#define QCOMPLETER_H
44
45#include <QtCore/qobject.h>
46#include <QtCore/qpoint.h>
47#include <QtCore/qstring.h>
48#include <QtCore/qabstractitemmodel.h>
49#include <QtCore/qrect.h>
50
51QT_BEGIN_HEADER
52
53QT_BEGIN_NAMESPACE
54
55QT_MODULE(Gui)
56
57#ifndef QT_NO_COMPLETER
58
59class QCompleterPrivate;
60class QAbstractItemView;
61class QAbstractProxyModel;
62class QWidget;
63
64class Q_GUI_EXPORT QCompleter : public QObject
65{
66 Q_OBJECT
67 Q_PROPERTY(QString completionPrefix READ completionPrefix WRITE setCompletionPrefix)
68 Q_PROPERTY(ModelSorting modelSorting READ modelSorting WRITE setModelSorting)
69 Q_PROPERTY(CompletionMode completionMode READ completionMode WRITE setCompletionMode)
70 Q_PROPERTY(int completionColumn READ completionColumn WRITE setCompletionColumn)
71 Q_PROPERTY(int completionRole READ completionRole WRITE setCompletionRole)
72 Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems)
73 Q_PROPERTY(Qt::CaseSensitivity caseSensitivity READ caseSensitivity WRITE setCaseSensitivity)
74 Q_PROPERTY(bool wrapAround READ wrapAround WRITE setWrapAround)
75
76public:
77 enum CompletionMode {
78 PopupCompletion,
79 UnfilteredPopupCompletion,
80 InlineCompletion
81 };
82
83 enum ModelSorting {
84 UnsortedModel = 0,
85 CaseSensitivelySortedModel,
86 CaseInsensitivelySortedModel
87 };
88
89 QCompleter(QObject *parent = 0);
90 QCompleter(QAbstractItemModel *model, QObject *parent = 0);
91#ifndef QT_NO_STRINGLISTMODEL
92 QCompleter(const QStringList& completions, QObject *parent = 0);
93#endif
94 ~QCompleter();
95
96 void setWidget(QWidget *widget);
97 QWidget *widget() const;
98
99 void setModel(QAbstractItemModel *c);
100 QAbstractItemModel *model() const;
101
102 void setCompletionMode(CompletionMode mode);
103 CompletionMode completionMode() const;
104
105 QAbstractItemView *popup() const;
106 void setPopup(QAbstractItemView *popup);
107
108 void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity);
109 Qt::CaseSensitivity caseSensitivity() const;
110
111 void setModelSorting(ModelSorting sorting);
112 ModelSorting modelSorting() const;
113
114 void setCompletionColumn(int column);
115 int completionColumn() const;
116
117 void setCompletionRole(int role);
118 int completionRole() const;
119
120 bool wrapAround() const;
121
122 int maxVisibleItems() const;
123 void setMaxVisibleItems(int maxItems);
124
125 int completionCount() const;
126 bool setCurrentRow(int row);
127 int currentRow() const;
128
129 QModelIndex currentIndex() const;
130 QString currentCompletion() const;
131
132 QAbstractItemModel *completionModel() const;
133
134 QString completionPrefix() const;
135
136public Q_SLOTS:
137 void setCompletionPrefix(const QString &prefix);
138 void complete(const QRect& rect = QRect());
139 void setWrapAround(bool wrap);
140
141public:
142 virtual QString pathFromIndex(const QModelIndex &index) const;
143 virtual QStringList splitPath(const QString &path) const;
144
145protected:
146 bool eventFilter(QObject *o, QEvent *e);
147 bool event(QEvent *);
148
149Q_SIGNALS:
150 void activated(const QString &text);
151 void activated(const QModelIndex &index);
152 void highlighted(const QString &text);
153 void highlighted(const QModelIndex &index);
154
155private:
156 Q_DISABLE_COPY(QCompleter)
157 Q_DECLARE_PRIVATE(QCompleter)
158
159 Q_PRIVATE_SLOT(d_func(), void _q_complete(QModelIndex))
160 Q_PRIVATE_SLOT(d_func(), void _q_completionSelected(const QItemSelection&))
161 Q_PRIVATE_SLOT(d_func(), void _q_autoResizePopup())
162 Q_PRIVATE_SLOT(d_func(), void _q_fileSystemModelDirectoryLoaded(const QString&))
163};
164
165#endif // QT_NO_COMPLETER
166
167QT_END_NAMESPACE
168
169QT_END_HEADER
170
171#endif // QCOMPLETER_H
Note: See TracBrowser for help on using the repository browser.