~neon/pykde4/master

« back to all changes in this revision

Viewing changes to sip/kdeui/kcompletion.sip

  • Committer: Simon Edwards
  • Date: 2007-09-02 19:43:19 UTC
  • Revision ID: git-v1:6b8df0c7009f6b218f54589a9bc313cd8c4f82b9

Initial drop of PyKDE4 - Python bindings for the KDE API. See the README file
for more info about the current state of PyKDE4.


svn path=/trunk/KDE/kdebindings/python/pykde4/; revision=707731

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
//     Copyright 2007 Jim Bublitz <jbublitz@nwinternet.com>
 
3
//     Earlier copyrights 1998 - 2006 Jim Bublitz also apply
 
4
 
 
5
 
 
6
//                 Generated by preSip
 
7
//            PyKDE4 module kdeui  version KDE 3.92.0
 
8
 
 
9
 
 
10
// This file is part of PyKDE4.
 
11
 
 
12
// PyKDE4 is free software; you can redistribute it and/or modify
 
13
// it under the terms of the GNU Lesser General Public License as
 
14
// published by the Free Software Foundation; either version 2.1 of
 
15
// the License, or (at your option) any later version.
 
16
 
 
17
// PyKDE4 is distributed in the hope that it will be useful,
 
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
// GNU General Public License for more details.
 
21
 
 
22
// You should have received a copy of the GNU General Public License
 
23
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
 
 
25
%ModuleHeaderCode
 
26
//ctscc
 
27
#include <kcombobox.h>
 
28
#include <khistorycombobox.h>
 
29
#include <klineedit.h>
 
30
#include <klistwidgetsearchline.h>
 
31
#include <ktreewidgetsearchline.h>
 
32
#include <krestrictedline.h>
 
33
%End
 
34
 
 
35
 
 
36
class KCompletion : QObject
 
37
{
 
38
%TypeHeaderCode
 
39
#include <kcompletion.h>
 
40
%End
 
41
 
 
42
 
 
43
public:
 
44
 
 
45
    enum CompOrder
 
46
    {
 
47
        Sorted, 
 
48
        Insertion, 
 
49
        Weighted
 
50
    };
 
51
 
 
52
                         KCompletion ();
 
53
    virtual QString      makeCompletion (const QString&);
 
54
    QStringList          substringCompletion (const QString&) const;
 
55
    QString              previousMatch ();
 
56
    QString              nextMatch ();
 
57
    virtual const QString& lastMatch () const;
 
58
    QStringList          items () const;
 
59
    bool                 isEmpty () const;
 
60
    virtual void         setCompletionMode (KGlobalSettings::Completion);
 
61
    KGlobalSettings::Completion completionMode () const;
 
62
    virtual void         setOrder (KCompletion::CompOrder);
 
63
    KCompletion::CompOrder order () const;
 
64
    virtual void         setIgnoreCase (bool);
 
65
    bool                 ignoreCase () const;
 
66
    QStringList          allMatches ();
 
67
    QStringList          allMatches (const QString&);
 
68
//ig     KCompletionMatches   allWeightedMatches ();
 
69
//ig     KCompletionMatches   allWeightedMatches (const QString&);
 
70
    virtual void         setSoundsEnabled (bool);
 
71
    bool                 soundsEnabled () const;
 
72
    bool                 hasMultipleMatches () const;
 
73
 
 
74
public slots:
 
75
    void                 slotMakeCompletion (const QString&);
 
76
    void                 slotPreviousMatch ();
 
77
    void                 slotNextMatch ();
 
78
    void                 insertItems (const QStringList&);
 
79
    virtual void         setItems (const QStringList&);
 
80
    void                 addItem (const QString&);
 
81
    void                 addItem (const QString&, uint);
 
82
    void                 removeItem (const QString&);
 
83
    virtual void         clear ();
 
84
 
 
85
signals:
 
86
    void                 match (const QString&);
 
87
    void                 matches (const QStringList&);
 
88
    void                 multipleMatches ();
 
89
 
 
90
protected:
 
91
    virtual void         postProcessMatch (QString*) const;
 
92
    virtual void         postProcessMatches (QStringList*) const;
 
93
//ig     virtual void         postProcessMatches (KCompletionMatches*) const;
 
94
 
 
95
};  // class KCompletion
 
96
 
 
97
 
 
98
//ig class KCompletionMatches : KCompletionMatchesList;
 
99
 
 
100
 
 
101
class KCompletionBase
 
102
{
 
103
%TypeHeaderCode
 
104
#include <kcompletion.h>
 
105
%End
 
106
 
 
107
 
 
108
public:
 
109
 
 
110
    enum KeyBindingType
 
111
    {
 
112
        TextCompletion, 
 
113
        PrevCompletionMatch, 
 
114
        NextCompletionMatch, 
 
115
        SubstringCompletion
 
116
    };
 
117
 
 
118
    typedef QMap<KCompletionBase::KeyBindingType, KShortcut> KeyBindingMap;
 
119
                         KCompletionBase ();
 
120
    KCompletion*         completionObject (bool = 1);
 
121
    virtual void         setCompletionObject (KCompletion*, bool = 1);
 
122
    virtual void         setHandleSignals (bool);
 
123
    bool                 isCompletionObjectAutoDeleted () const;
 
124
    void                 setAutoDeleteCompletionObject (bool);
 
125
    void                 setEnableSignals (bool);
 
126
    bool                 handleSignals () const;
 
127
    bool                 emitSignals () const;
 
128
    virtual void         setCompletionMode (KGlobalSettings::Completion);
 
129
    KGlobalSettings::Completion completionMode () const;
 
130
    bool                 setKeyBinding (KCompletionBase::KeyBindingType, const KShortcut&);
 
131
    KShortcut            getKeyBinding (KCompletionBase::KeyBindingType) const;
 
132
    void                 useGlobalKeyBindings ();
 
133
    virtual void         setCompletedText (const QString&)  = 0;
 
134
    virtual void         setCompletedItems (const QStringList&, bool = 1)  = 0;
 
135
    KCompletion*         compObj () const;
 
136
 
 
137
protected:
 
138
    KCompletionBase::KeyBindingMap getKeyBindings () const;
 
139
    void                 setDelegate (KCompletionBase*);
 
140
    KCompletionBase*     delegate () const;
 
141
 
 
142
protected:
 
143
//igx     virtual void         virtual_hook (int, void*);
 
144
 
 
145
// Subclasses for KCompletionBase
 
146
 
 
147
public:
 
148
%ConvertToSubClassCode
 
149
 
 
150
    if (dynamic_cast<KComboBox*>(sipCpp))
 
151
    {
 
152
        sipClass = sipClass_KComboBox;
 
153
        if (dynamic_cast<KHistoryComboBox*>(sipCpp))
 
154
            sipClass = sipClass_KHistoryComboBox;
 
155
    }
 
156
    else if (dynamic_cast<KLineEdit*>(sipCpp))
 
157
    {
 
158
        sipClass = sipClass_KLineEdit;
 
159
        if (dynamic_cast<KListWidgetSearchLine*>(sipCpp))
 
160
            sipClass = sipClass_KListWidgetSearchLine;
 
161
        else if (dynamic_cast<KTreeWidgetSearchLine*>(sipCpp))
 
162
            sipClass = sipClass_KTreeWidgetSearchLine;
 
163
        else if (dynamic_cast<KRestrictedLine*>(sipCpp))
 
164
            sipClass = sipClass_KRestrictedLine;
 
165
    }
 
166
    else
 
167
        sipClass = NULL;
 
168
%End
 
169
 
 
170
 
 
171
};  // class KCompletionBase
 
172
 
 
173
//ig typedef KSortableList<QString> KCompletionMatchesList;
 
174
 
 
175
 
 
176
%MappedType QMap<KCompletionBase::KeyBindingType,KShortcut>
 
177
{
 
178
%TypeHeaderCode
 
179
#include <qmap.h>
 
180
%End
 
181
 
 
182
%ConvertFromTypeCode
 
183
    // Create the dictionary.
 
184
    PyObject *d = PyDict_New();
 
185
 
 
186
    if (!d)
 
187
        return NULL;
 
188
 
 
189
    // Set the dictionary elements.
 
190
    QMap<KCompletionBase::KeyBindingType, KShortcut>::const_iterator i = sipCpp->constBegin();
 
191
 
 
192
    while (i != sipCpp->constEnd())
 
193
    {
 
194
        KShortcut *t = new KShortcut(i.value());
 
195
 
 
196
        PyObject *kobj = PyInt_FromLong((int)i.key());
 
197
        PyObject *tobj = sipConvertFromNewInstance(t, sipClass_KShortcut, sipTransferObj);
 
198
 
 
199
        if (kobj == NULL || tobj == NULL || PyDict_SetItem(d, kobj, tobj) < 0)
 
200
        {
 
201
            Py_DECREF(d);
 
202
 
 
203
            if (kobj)
 
204
                Py_DECREF(kobj);
 
205
 
 
206
            if (tobj)
 
207
                Py_DECREF(tobj);
 
208
            else
 
209
                delete t;
 
210
 
 
211
            return NULL;
 
212
        }
 
213
 
 
214
        Py_DECREF(kobj);
 
215
        Py_DECREF(tobj);
 
216
 
 
217
        ++i;
 
218
    }
 
219
 
 
220
    return d;
 
221
%End
 
222
 
 
223
%ConvertToTypeCode
 
224
    PyObject *kobj, *tobj;
 
225
#if PY_VERSION_HEX >= 0x02050000
 
226
    Py_ssize_t i = 0;
 
227
#else
 
228
    int i = 0;
 
229
#endif
 
230
 
 
231
    // Check the type if that is all that is required.
 
232
    if (sipIsErr == NULL)
 
233
    {
 
234
        if (!PyDict_Check(sipPy))
 
235
            return 0;
 
236
 
 
237
        while (PyDict_Next(sipPy, &i, &kobj, &tobj))
 
238
            if (!sipCanConvertToInstance(tobj, sipClass_KShortcut, SIP_NOT_NONE))
 
239
                return 0;
 
240
 
 
241
        return 1;
 
242
    }
 
243
 
 
244
    QMap<KCompletionBase::KeyBindingType, KShortcut> *qm = new QMap<KCompletionBase::KeyBindingType, KShortcut>;
 
245
 
 
246
    while (PyDict_Next(sipPy, &i, &kobj, &tobj))
 
247
    {
 
248
        int state;
 
249
        int k = PyInt_AsLong(kobj);
 
250
        KShortcut *t = reinterpret_cast<KShortcut *>(sipConvertToInstance(tobj, sipClass_KShortcut, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
 
251
 
 
252
        if (*sipIsErr)
 
253
        {
 
254
            sipReleaseInstance(t, sipClass_KShortcut, state);
 
255
 
 
256
            delete qm;
 
257
            return 0;
 
258
        }
 
259
 
 
260
        qm->insert((KCompletionBase::KeyBindingType)k, *t);
 
261
 
 
262
        sipReleaseInstance(t, sipClass_KShortcut, state);
 
263
    }
 
264
 
 
265
    *sipCppPtr = qm;
 
266
 
 
267
    return sipGetState(sipTransferObj);
 
268
%End
 
269
};
 
270
 
 
271