|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
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 |
|
51 QT_BEGIN_HEADER |
|
52 |
|
53 QT_BEGIN_NAMESPACE |
|
54 |
|
55 QT_MODULE(Gui) |
|
56 |
|
57 #ifndef QT_NO_COMPLETER |
|
58 |
|
59 class QCompleterPrivate; |
|
60 class QAbstractItemView; |
|
61 class QAbstractProxyModel; |
|
62 class QWidget; |
|
63 |
|
64 class 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 |
|
76 public: |
|
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 |
|
136 public Q_SLOTS: |
|
137 void setCompletionPrefix(const QString &prefix); |
|
138 void complete(const QRect& rect = QRect()); |
|
139 void setWrapAround(bool wrap); |
|
140 |
|
141 public: |
|
142 virtual QString pathFromIndex(const QModelIndex &index) const; |
|
143 virtual QStringList splitPath(const QString &path) const; |
|
144 |
|
145 protected: |
|
146 bool eventFilter(QObject *o, QEvent *e); |
|
147 bool event(QEvent *); |
|
148 |
|
149 Q_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 |
|
155 private: |
|
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 }; |
|
163 |
|
164 #endif // QT_NO_COMPLETER |
|
165 |
|
166 QT_END_NAMESPACE |
|
167 |
|
168 QT_END_HEADER |
|
169 |
|
170 #endif // QCOMPLETER_H |