Qt 4.8
qcompleter.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 
52 
54 
55 QT_MODULE(Gui)
56 
57 #ifndef QT_NO_COMPLETER
58 
59 class QCompleterPrivate;
60 class QAbstractItemView;
62 class QWidget;
63 
65 {
66  Q_OBJECT
74  bool wrapAround;
75 
76 public:
80  InlineCompletion
81  };
82 
83  enum ModelSorting {
84  UnsortedModel = 0,
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:
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 
168 
170 
171 #endif // QCOMPLETER_H
CompletionMode
This enum specifies how completions are provided to the user.
Definition: qcompleter.h:77
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
int completionColumn
the column in the model in which completions are searched for.
Definition: qcompleter.h:70
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QCompleter class provides completions based on an item model.
Definition: qcompleter.h:64
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_SIGNALS
Definition: qobjectdefs.h:72
CompletionMode completionMode
how the completions are provided to the user
Definition: qcompleter.h:69
ModelSorting
This enum specifies how the items in the model are sorted.
Definition: qcompleter.h:83
Qt::CaseSensitivity caseSensitivity
the case sensitivity of the matching
Definition: qcompleter.h:73
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int completionRole
the item role to be used to query the contents of items for matching.
Definition: qcompleter.h:71
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
int maxVisibleItems
the maximum allowed size on screen of the completer, measured in items
Definition: qcompleter.h:72
The QAbstractItemModel class provides the abstract interface for item model classes.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting...
bool wrapAround
the completions wrap around when navigating through items
Definition: qcompleter.h:74
CaseSensitivity
Definition: qnamespace.h:1451
The QAbstractItemView class provides the basic functionality for item view classes.
QString completionPrefix
the completion prefix used to provide completions.
Definition: qcompleter.h:67
The QItemSelection class manages information about selected items in a model.
The QModelIndex class is used to locate data in a data model.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
quint16 index
ModelSorting modelSorting
the way the model is sorted
Definition: qcompleter.h:68
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
#define text
Definition: qobjectdefs.h:80