1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.widgets.completer;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.abstractitemmodel;
19 import qt.core.coreevent;
20 import qt.core.namespace;
21 import qt.core.object;
22 import qt.core.rect;
23 import qt.core.string;
24 import qt.core.stringlist;
25 import qt.helpers;
26 import qt.widgets.abstractitemview;
27 import qt.widgets.widget;
28 
29 /+ QT_REQUIRE_CONFIG(completer); +/
30 
31 
32 extern(C++, class) struct QCompleterPrivate;
33 /+ class QAbstractItemView;
34 class QAbstractProxyModel;
35 class QWidget; +/
36 
37 class /+ Q_WIDGETS_EXPORT +/ QCompleter : QObject
38 {
39     mixin(Q_OBJECT);
40     /+ Q_PROPERTY(QString completionPrefix READ completionPrefix WRITE setCompletionPrefix)
41     Q_PROPERTY(ModelSorting modelSorting READ modelSorting WRITE setModelSorting)
42     Q_PROPERTY(Qt::MatchFlags filterMode READ filterMode WRITE setFilterMode)
43     Q_PROPERTY(CompletionMode completionMode READ completionMode WRITE setCompletionMode)
44     Q_PROPERTY(int completionColumn READ completionColumn WRITE setCompletionColumn)
45     Q_PROPERTY(int completionRole READ completionRole WRITE setCompletionRole)
46     Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems)
47     Q_PROPERTY(Qt::CaseSensitivity caseSensitivity READ caseSensitivity WRITE setCaseSensitivity)
48     Q_PROPERTY(bool wrapAround READ wrapAround WRITE setWrapAround) +/
49 
50 public:
51     enum CompletionMode {
52         PopupCompletion,
53         UnfilteredPopupCompletion,
54         InlineCompletion
55     }
56     /+ Q_ENUM(CompletionMode) +/
57 
58     enum ModelSorting {
59         UnsortedModel = 0,
60         CaseSensitivelySortedModel,
61         CaseInsensitivelySortedModel
62     }
63     /+ Q_ENUM(ModelSorting) +/
64 
65     this(QObject parent = null);
66     this(QAbstractItemModel model, QObject parent = null);
67 /+ #if QT_CONFIG(stringlistmodel) +/
68     this(ref const(QStringList) completions, QObject parent = null);
69 /+ #endif +/
70     ~this();
71 
72     final void setWidget(QWidget widget);
73     final QWidget widget() const;
74 
75     final void setModel(QAbstractItemModel c);
76     final QAbstractItemModel model() const;
77 
78     final void setCompletionMode(CompletionMode mode);
79     final CompletionMode completionMode() const;
80 
81     final void setFilterMode(/+ Qt:: +/qt.core.namespace.MatchFlags filterMode);
82     final /+ Qt:: +/qt.core.namespace.MatchFlags filterMode() const;
83 
84     final QAbstractItemView popup() const;
85     final void setPopup(QAbstractItemView popup);
86 
87     final void setCaseSensitivity(/+ Qt:: +/qt.core.namespace.CaseSensitivity caseSensitivity);
88     final /+ Qt:: +/qt.core.namespace.CaseSensitivity caseSensitivity() const;
89 
90     final void setModelSorting(ModelSorting sorting);
91     final ModelSorting modelSorting() const;
92 
93     final void setCompletionColumn(int column);
94     final int  completionColumn() const;
95 
96     final void setCompletionRole(int role);
97     final int  completionRole() const;
98 
99     final bool wrapAround() const;
100 
101     final int maxVisibleItems() const;
102     final void setMaxVisibleItems(int maxItems);
103 
104     final int completionCount() const;
105     final bool setCurrentRow(int row);
106     final int currentRow() const;
107 
108     final QModelIndex currentIndex() const;
109     final QString currentCompletion() const;
110 
111     final QAbstractItemModel completionModel() const;
112 
113     final QString completionPrefix() const;
114 
115 public /+ Q_SLOTS +/:
116     @QSlot final void setCompletionPrefix(ref const(QString) prefix);
117     @QSlot final void complete(ref const(QRect) rect = globalInitVar!QRect);
118     @QSlot final void setWrapAround(bool wrap);
119 
120 public:
121     /+ virtual +/ QString pathFromIndex(ref const(QModelIndex) index) const;
122     /+ virtual +/ QStringList splitPath(ref const(QString) path) const;
123 
124 protected:
125     override bool eventFilter(QObject o, QEvent e);
126     override bool event(QEvent );
127 
128 /+ Q_SIGNALS +/public:
129     @QSignal final void activated(ref const(QString) text);
130     @QSignal final void activated(ref const(QModelIndex) index);
131     @QSignal final void highlighted(ref const(QString) text);
132     @QSignal final void highlighted(ref const(QModelIndex) index);
133 
134 private:
135     /+ Q_DISABLE_COPY(QCompleter) +/
136     /+ Q_DECLARE_PRIVATE(QCompleter) +/
137 
138     /+ Q_PRIVATE_SLOT(d_func(), void _q_complete(QModelIndex))
139     Q_PRIVATE_SLOT(d_func(), void _q_completionSelected(const QItemSelection&))
140     Q_PRIVATE_SLOT(d_func(), void _q_autoResizePopup())
141     Q_PRIVATE_SLOT(d_func(), void _q_fileSystemModelDirectoryLoaded(const QString&)) +/
142 }
143