Changeset View
Changeset View
Standalone View
Standalone View
find-modules/module_generation/PyKF5/KItemViews.py
- This file was added.
1 | # | ||||
---|---|---|---|---|---|
2 | # Copyright 2017 by Shaheed Haque (srhaque@theiet.org) | ||||
3 | # | ||||
4 | # This program is free software; you can redistribute it and/or modify | ||||
5 | # it under the terms of the GNU General Public License as published by | ||||
6 | # the Free Software Foundation; either version 2 of the License, or | ||||
7 | # (at your option) any later version. | ||||
8 | # | ||||
9 | # This program is distributed in the hope that it will be useful, | ||||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | # GNU General Public License for more details. | ||||
13 | # | ||||
14 | # You should have received a copy of the GNU General Public License | ||||
15 | # along with this program; if not, write to the Free Software | ||||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||||
17 | # 02110-1301 USA. | ||||
18 | # | ||||
19 | """ | ||||
20 | SIP binding customisation for PyKF5.KItemViews. This modules describes: | ||||
21 | | ||||
22 | * Supplementary SIP file generator rules. | ||||
23 | """ | ||||
24 | import rule_helpers | ||||
25 | from templates import PyQt | ||||
26 | import templates.methodcode | ||||
27 | | ||||
28 | | ||||
29 | class FunctionExpander(templates.methodcode.FunctionExpander): | ||||
30 | """ | ||||
31 | Override the use of the protected enum 'QAbstractItemView::CursorAction'. | ||||
32 | """ | ||||
33 | def analyse_function(self, fn, cursor, sip): | ||||
34 | entries = super(FunctionExpander, self).analyse_function(fn, cursor, sip) | ||||
35 | assert entries["parameters"][0].cxx_t == "QAbstractItemView::CursorAction" | ||||
36 | entries["parameters"][0] = PyQt.FunctionParameterHelper("int", None) | ||||
37 | entries["p_types"][0] = "int" | ||||
38 | return entries | ||||
39 | | ||||
40 | | ||||
41 | def function_uses_templates(container, function, sip, matcher): | ||||
42 | sip.setdefault("template", FunctionExpander) | ||||
43 | PyQt.function_uses_templates(container, function, sip, matcher) | ||||
44 | | ||||
45 | | ||||
46 | def module_fix_mapped_types(filename, sip, entry): | ||||
47 | # | ||||
48 | # SIP cannot handle duplicate %MappedTypes. | ||||
49 | # | ||||
50 | rule_helpers.modulecode_delete(filename, sip, entry, "QList<int>", "QVector<int>", "QList<QWidget *>") | ||||
51 | | ||||
52 | | ||||
53 | def function_rules(): | ||||
54 | return [ | ||||
55 | # | ||||
56 | # Rewrite using declaration. | ||||
57 | # | ||||
58 | ["KCategorizedView", "moveCursor", ".*", ".*", ".*", function_uses_templates], | ||||
59 | ] | ||||
60 | | ||||
61 | | ||||
62 | def modulecode(): | ||||
63 | return { | ||||
64 | "KItemViews/KItemViewsmod.sip": { | ||||
65 | "code": module_fix_mapped_types, | ||||
66 | }, | ||||
67 | } |