##// END OF EJS Templates
reorganized SVN tree into branches, tags and trunk...
ezust -
r0:2978a919fc4e
parent child
Show More
This diff has been collapsed as it changes many lines, (504 lines changed) Show them Hide them
@@ -0,0 +1,504
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 2.1, February 1999
3
4 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 [This is the first released version of the Lesser GPL. It also counts
10 as the successor of the GNU Library Public License, version 2, hence
11 the version number 2.1.]
12
13 Preamble
14
15 The licenses for most software are designed to take away your
16 freedom to share and change it. By contrast, the GNU General Public
17 Licenses are intended to guarantee your freedom to share and change
18 free software--to make sure the software is free for all its users.
19
20 This license, the Lesser General Public License, applies to some
21 specially designated software packages--typically libraries--of the
22 Free Software Foundation and other authors who decide to use it. You
23 can use it too, but we suggest you first think carefully about whether
24 this license or the ordinary General Public License is the better
25 strategy to use in any particular case, based on the explanations below.
26
27 When we speak of free software, we are referring to freedom of use,
28 not price. Our General Public Licenses are designed to make sure that
29 you have the freedom to distribute copies of free software (and charge
30 for this service if you wish); that you receive source code or can get
31 it if you want it; that you can change the software and use pieces of
32 it in new free programs; and that you are informed that you can do
33 these things.
34
35 To protect your rights, we need to make restrictions that forbid
36 distributors to deny you these rights or to ask you to surrender these
37 rights. These restrictions translate to certain responsibilities for
38 you if you distribute copies of the library or if you modify it.
39
40 For example, if you distribute copies of the library, whether gratis
41 or for a fee, you must give the recipients all the rights that we gave
42 you. You must make sure that they, too, receive or can get the source
43 code. If you link other code with the library, you must provide
44 complete object files to the recipients, so that they can relink them
45 with the library after making changes to the library and recompiling
46 it. And you must show them these terms so they know their rights.
47
48 We protect your rights with a two-step method: (1) we copyright the
49 library, and (2) we offer you this license, which gives you legal
50 permission to copy, distribute and/or modify the library.
51
52 To protect each distributor, we want to make it very clear that
53 there is no warranty for the free library. Also, if the library is
54 modified by someone else and passed on, the recipients should know
55 that what they have is not the original version, so that the original
56 author's reputation will not be affected by problems that might be
57 introduced by others.
58
59 Finally, software patents pose a constant threat to the existence of
60 any free program. We wish to make sure that a company cannot
61 effectively restrict the users of a free program by obtaining a
62 restrictive license from a patent holder. Therefore, we insist that
63 any patent license obtained for a version of the library must be
64 consistent with the full freedom of use specified in this license.
65
66 Most GNU software, including some libraries, is covered by the
67 ordinary GNU General Public License. This license, the GNU Lesser
68 General Public License, applies to certain designated libraries, and
69 is quite different from the ordinary General Public License. We use
70 this license for certain libraries in order to permit linking those
71 libraries into non-free programs.
72
73 When a program is linked with a library, whether statically or using
74 a shared library, the combination of the two is legally speaking a
75 combined work, a derivative of the original library. The ordinary
76 General Public License therefore permits such linking only if the
77 entire combination fits its criteria of freedom. The Lesser General
78 Public License permits more lax criteria for linking other code with
79 the library.
80
81 We call this license the "Lesser" General Public License because it
82 does Less to protect the user's freedom than the ordinary General
83 Public License. It also provides other free software developers Less
84 of an advantage over competing non-free programs. These disadvantages
85 are the reason we use the ordinary General Public License for many
86 libraries. However, the Lesser license provides advantages in certain
87 special circumstances.
88
89 For example, on rare occasions, there may be a special need to
90 encourage the widest possible use of a certain library, so that it becomes
91 a de-facto standard. To achieve this, non-free programs must be
92 allowed to use the library. A more frequent case is that a free
93 library does the same job as widely used non-free libraries. In this
94 case, there is little to gain by limiting the free library to free
95 software only, so we use the Lesser General Public License.
96
97 In other cases, permission to use a particular library in non-free
98 programs enables a greater number of people to use a large body of
99 free software. For example, permission to use the GNU C Library in
100 non-free programs enables many more people to use the whole GNU
101 operating system, as well as its variant, the GNU/Linux operating
102 system.
103
104 Although the Lesser General Public License is Less protective of the
105 users' freedom, it does ensure that the user of a program that is
106 linked with the Library has the freedom and the wherewithal to run
107 that program using a modified version of the Library.
108
109 The precise terms and conditions for copying, distribution and
110 modification follow. Pay close attention to the difference between a
111 "work based on the library" and a "work that uses the library". The
112 former contains code derived from the library, whereas the latter must
113 be combined with the library in order to run.
114
115 GNU LESSER GENERAL PUBLIC LICENSE
116 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
118 0. This License Agreement applies to any software library or other
119 program which contains a notice placed by the copyright holder or
120 other authorized party saying it may be distributed under the terms of
121 this Lesser General Public License (also called "this License").
122 Each licensee is addressed as "you".
123
124 A "library" means a collection of software functions and/or data
125 prepared so as to be conveniently linked with application programs
126 (which use some of those functions and data) to form executables.
127
128 The "Library", below, refers to any such software library or work
129 which has been distributed under these terms. A "work based on the
130 Library" means either the Library or any derivative work under
131 copyright law: that is to say, a work containing the Library or a
132 portion of it, either verbatim or with modifications and/or translated
133 straightforwardly into another language. (Hereinafter, translation is
134 included without limitation in the term "modification".)
135
136 "Source code" for a work means the preferred form of the work for
137 making modifications to it. For a library, complete source code means
138 all the source code for all modules it contains, plus any associated
139 interface definition files, plus the scripts used to control compilation
140 and installation of the library.
141
142 Activities other than copying, distribution and modification are not
143 covered by this License; they are outside its scope. The act of
144 running a program using the Library is not restricted, and output from
145 such a program is covered only if its contents constitute a work based
146 on the Library (independent of the use of the Library in a tool for
147 writing it). Whether that is true depends on what the Library does
148 and what the program that uses the Library does.
149
150 1. You may copy and distribute verbatim copies of the Library's
151 complete source code as you receive it, in any medium, provided that
152 you conspicuously and appropriately publish on each copy an
153 appropriate copyright notice and disclaimer of warranty; keep intact
154 all the notices that refer to this License and to the absence of any
155 warranty; and distribute a copy of this License along with the
156 Library.
157
158 You may charge a fee for the physical act of transferring a copy,
159 and you may at your option offer warranty protection in exchange for a
160 fee.
161
162 2. You may modify your copy or copies of the Library or any portion
163 of it, thus forming a work based on the Library, and copy and
164 distribute such modifications or work under the terms of Section 1
165 above, provided that you also meet all of these conditions:
166
167 a) The modified work must itself be a software library.
168
169 b) You must cause the files modified to carry prominent notices
170 stating that you changed the files and the date of any change.
171
172 c) You must cause the whole of the work to be licensed at no
173 charge to all third parties under the terms of this License.
174
175 d) If a facility in the modified Library refers to a function or a
176 table of data to be supplied by an application program that uses
177 the facility, other than as an argument passed when the facility
178 is invoked, then you must make a good faith effort to ensure that,
179 in the event an application does not supply such function or
180 table, the facility still operates, and performs whatever part of
181 its purpose remains meaningful.
182
183 (For example, a function in a library to compute square roots has
184 a purpose that is entirely well-defined independent of the
185 application. Therefore, Subsection 2d requires that any
186 application-supplied function or table used by this function must
187 be optional: if the application does not supply it, the square
188 root function must still compute square roots.)
189
190 These requirements apply to the modified work as a whole. If
191 identifiable sections of that work are not derived from the Library,
192 and can be reasonably considered independent and separate works in
193 themselves, then this License, and its terms, do not apply to those
194 sections when you distribute them as separate works. But when you
195 distribute the same sections as part of a whole which is a work based
196 on the Library, the distribution of the whole must be on the terms of
197 this License, whose permissions for other licensees extend to the
198 entire whole, and thus to each and every part regardless of who wrote
199 it.
200
201 Thus, it is not the intent of this section to claim rights or contest
202 your rights to work written entirely by you; rather, the intent is to
203 exercise the right to control the distribution of derivative or
204 collective works based on the Library.
205
206 In addition, mere aggregation of another work not based on the Library
207 with the Library (or with a work based on the Library) on a volume of
208 a storage or distribution medium does not bring the other work under
209 the scope of this License.
210
211 3. You may opt to apply the terms of the ordinary GNU General Public
212 License instead of this License to a given copy of the Library. To do
213 this, you must alter all the notices that refer to this License, so
214 that they refer to the ordinary GNU General Public License, version 2,
215 instead of to this License. (If a newer version than version 2 of the
216 ordinary GNU General Public License has appeared, then you can specify
217 that version instead if you wish.) Do not make any other change in
218 these notices.
219
220 Once this change is made in a given copy, it is irreversible for
221 that copy, so the ordinary GNU General Public License applies to all
222 subsequent copies and derivative works made from that copy.
223
224 This option is useful when you wish to copy part of the code of
225 the Library into a program that is not a library.
226
227 4. You may copy and distribute the Library (or a portion or
228 derivative of it, under Section 2) in object code or executable form
229 under the terms of Sections 1 and 2 above provided that you accompany
230 it with the complete corresponding machine-readable source code, which
231 must be distributed under the terms of Sections 1 and 2 above on a
232 medium customarily used for software interchange.
233
234 If distribution of object code is made by offering access to copy
235 from a designated place, then offering equivalent access to copy the
236 source code from the same place satisfies the requirement to
237 distribute the source code, even though third parties are not
238 compelled to copy the source along with the object code.
239
240 5. A program that contains no derivative of any portion of the
241 Library, but is designed to work with the Library by being compiled or
242 linked with it, is called a "work that uses the Library". Such a
243 work, in isolation, is not a derivative work of the Library, and
244 therefore falls outside the scope of this License.
245
246 However, linking a "work that uses the Library" with the Library
247 creates an executable that is a derivative of the Library (because it
248 contains portions of the Library), rather than a "work that uses the
249 library". The executable is therefore covered by this License.
250 Section 6 states terms for distribution of such executables.
251
252 When a "work that uses the Library" uses material from a header file
253 that is part of the Library, the object code for the work may be a
254 derivative work of the Library even though the source code is not.
255 Whether this is true is especially significant if the work can be
256 linked without the Library, or if the work is itself a library. The
257 threshold for this to be true is not precisely defined by law.
258
259 If such an object file uses only numerical parameters, data
260 structure layouts and accessors, and small macros and small inline
261 functions (ten lines or less in length), then the use of the object
262 file is unrestricted, regardless of whether it is legally a derivative
263 work. (Executables containing this object code plus portions of the
264 Library will still fall under Section 6.)
265
266 Otherwise, if the work is a derivative of the Library, you may
267 distribute the object code for the work under the terms of Section 6.
268 Any executables containing that work also fall under Section 6,
269 whether or not they are linked directly with the Library itself.
270
271 6. As an exception to the Sections above, you may also combine or
272 link a "work that uses the Library" with the Library to produce a
273 work containing portions of the Library, and distribute that work
274 under terms of your choice, provided that the terms permit
275 modification of the work for the customer's own use and reverse
276 engineering for debugging such modifications.
277
278 You must give prominent notice with each copy of the work that the
279 Library is used in it and that the Library and its use are covered by
280 this License. You must supply a copy of this License. If the work
281 during execution displays copyright notices, you must include the
282 copyright notice for the Library among them, as well as a reference
283 directing the user to the copy of this License. Also, you must do one
284 of these things:
285
286 a) Accompany the work with the complete corresponding
287 machine-readable source code for the Library including whatever
288 changes were used in the work (which must be distributed under
289 Sections 1 and 2 above); and, if the work is an executable linked
290 with the Library, with the complete machine-readable "work that
291 uses the Library", as object code and/or source code, so that the
292 user can modify the Library and then relink to produce a modified
293 executable containing the modified Library. (It is understood
294 that the user who changes the contents of definitions files in the
295 Library will not necessarily be able to recompile the application
296 to use the modified definitions.)
297
298 b) Use a suitable shared library mechanism for linking with the
299 Library. A suitable mechanism is one that (1) uses at run time a
300 copy of the library already present on the user's computer system,
301 rather than copying library functions into the executable, and (2)
302 will operate properly with a modified version of the library, if
303 the user installs one, as long as the modified version is
304 interface-compatible with the version that the work was made with.
305
306 c) Accompany the work with a written offer, valid for at
307 least three years, to give the same user the materials
308 specified in Subsection 6a, above, for a charge no more
309 than the cost of performing this distribution.
310
311 d) If distribution of the work is made by offering access to copy
312 from a designated place, offer equivalent access to copy the above
313 specified materials from the same place.
314
315 e) Verify that the user has already received a copy of these
316 materials or that you have already sent this user a copy.
317
318 For an executable, the required form of the "work that uses the
319 Library" must include any data and utility programs needed for
320 reproducing the executable from it. However, as a special exception,
321 the materials to be distributed need not include anything that is
322 normally distributed (in either source or binary form) with the major
323 components (compiler, kernel, and so on) of the operating system on
324 which the executable runs, unless that component itself accompanies
325 the executable.
326
327 It may happen that this requirement contradicts the license
328 restrictions of other proprietary libraries that do not normally
329 accompany the operating system. Such a contradiction means you cannot
330 use both them and the Library together in an executable that you
331 distribute.
332
333 7. You may place library facilities that are a work based on the
334 Library side-by-side in a single library together with other library
335 facilities not covered by this License, and distribute such a combined
336 library, provided that the separate distribution of the work based on
337 the Library and of the other library facilities is otherwise
338 permitted, and provided that you do these two things:
339
340 a) Accompany the combined library with a copy of the same work
341 based on the Library, uncombined with any other library
342 facilities. This must be distributed under the terms of the
343 Sections above.
344
345 b) Give prominent notice with the combined library of the fact
346 that part of it is a work based on the Library, and explaining
347 where to find the accompanying uncombined form of the same work.
348
349 8. You may not copy, modify, sublicense, link with, or distribute
350 the Library except as expressly provided under this License. Any
351 attempt otherwise to copy, modify, sublicense, link with, or
352 distribute the Library is void, and will automatically terminate your
353 rights under this License. However, parties who have received copies,
354 or rights, from you under this License will not have their licenses
355 terminated so long as such parties remain in full compliance.
356
357 9. You are not required to accept this License, since you have not
358 signed it. However, nothing else grants you permission to modify or
359 distribute the Library or its derivative works. These actions are
360 prohibited by law if you do not accept this License. Therefore, by
361 modifying or distributing the Library (or any work based on the
362 Library), you indicate your acceptance of this License to do so, and
363 all its terms and conditions for copying, distributing or modifying
364 the Library or works based on it.
365
366 10. Each time you redistribute the Library (or any work based on the
367 Library), the recipient automatically receives a license from the
368 original licensor to copy, distribute, link with or modify the Library
369 subject to these terms and conditions. You may not impose any further
370 restrictions on the recipients' exercise of the rights granted herein.
371 You are not responsible for enforcing compliance by third parties with
372 this License.
373
374 11. If, as a consequence of a court judgment or allegation of patent
375 infringement or for any other reason (not limited to patent issues),
376 conditions are imposed on you (whether by court order, agreement or
377 otherwise) that contradict the conditions of this License, they do not
378 excuse you from the conditions of this License. If you cannot
379 distribute so as to satisfy simultaneously your obligations under this
380 License and any other pertinent obligations, then as a consequence you
381 may not distribute the Library at all. For example, if a patent
382 license would not permit royalty-free redistribution of the Library by
383 all those who receive copies directly or indirectly through you, then
384 the only way you could satisfy both it and this License would be to
385 refrain entirely from distribution of the Library.
386
387 If any portion of this section is held invalid or unenforceable under any
388 particular circumstance, the balance of the section is intended to apply,
389 and the section as a whole is intended to apply in other circumstances.
390
391 It is not the purpose of this section to induce you to infringe any
392 patents or other property right claims or to contest validity of any
393 such claims; this section has the sole purpose of protecting the
394 integrity of the free software distribution system which is
395 implemented by public license practices. Many people have made
396 generous contributions to the wide range of software distributed
397 through that system in reliance on consistent application of that
398 system; it is up to the author/donor to decide if he or she is willing
399 to distribute software through any other system and a licensee cannot
400 impose that choice.
401
402 This section is intended to make thoroughly clear what is believed to
403 be a consequence of the rest of this License.
404
405 12. If the distribution and/or use of the Library is restricted in
406 certain countries either by patents or by copyrighted interfaces, the
407 original copyright holder who places the Library under this License may add
408 an explicit geographical distribution limitation excluding those countries,
409 so that distribution is permitted only in or among countries not thus
410 excluded. In such case, this License incorporates the limitation as if
411 written in the body of this License.
412
413 13. The Free Software Foundation may publish revised and/or new
414 versions of the Lesser General Public License from time to time.
415 Such new versions will be similar in spirit to the present version,
416 but may differ in detail to address new problems or concerns.
417
418 Each version is given a distinguishing version number. If the Library
419 specifies a version number of this License which applies to it and
420 "any later version", you have the option of following the terms and
421 conditions either of that version or of any later version published by
422 the Free Software Foundation. If the Library does not specify a
423 license version number, you may choose any version ever published by
424 the Free Software Foundation.
425
426 14. If you wish to incorporate parts of the Library into other free
427 programs whose distribution conditions are incompatible with these,
428 write to the author to ask for permission. For software which is
429 copyrighted by the Free Software Foundation, write to the Free
430 Software Foundation; we sometimes make exceptions for this. Our
431 decision will be guided by the two goals of preserving the free status
432 of all derivatives of our free software and of promoting the sharing
433 and reuse of software generally.
434
435 NO WARRANTY
436
437 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438 WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439 EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440 OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445 THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
447 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449 AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450 FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452 LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454 FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456 DAMAGES.
457
458 END OF TERMS AND CONDITIONS
459
460 How to Apply These Terms to Your New Libraries
461
462 If you develop a new library, and you want it to be of the greatest
463 possible use to the public, we recommend making it free software that
464 everyone can redistribute and change. You can do so by permitting
465 redistribution under these terms (or, alternatively, under the terms of the
466 ordinary General Public License).
467
468 To apply these terms, attach the following notices to the library. It is
469 safest to attach them to the start of each source file to most effectively
470 convey the exclusion of warranty; and each file should have at least the
471 "copyright" line and a pointer to where the full notice is found.
472
473 <one line to give the library's name and a brief idea of what it does.>
474 Copyright (C) <year> <name of author>
475
476 This library is free software; you can redistribute it and/or
477 modify it under the terms of the GNU Lesser General Public
478 License as published by the Free Software Foundation; either
479 version 2.1 of the License, or (at your option) any later version.
480
481 This library is distributed in the hope that it will be useful,
482 but WITHOUT ANY WARRANTY; without even the implied warranty of
483 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 Lesser General Public License for more details.
485
486 You should have received a copy of the GNU Lesser General Public
487 License along with this library; if not, write to the Free Software
488 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489
490 Also add information on how to contact you by electronic and paper mail.
491
492 You should also get your employer (if you work as a programmer) or your
493 school, if any, to sign a "copyright disclaimer" for the library, if
494 necessary. Here is a sample; alter the names:
495
496 Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498
499 <signature of Ty Coon>, 1 April 1990
500 Ty Coon, President of Vice
501
502 That's all there is to it!
503
504
@@ -0,0 +1,4
1 TEMPLATE = subdirs
2
3 CONFIG += ordered
4 SUBDIRS = src extensions tests examples
@@ -0,0 +1,18
1 PythonQt
2 --------
3
4 PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://www.trolltech.com).
5 It offers an easy way to embedd the Python scripting language into
6 your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x.
7
8 Licensing
9 ---------
10 PythonQt is distributed under the LGPL license.
11
12 Documentation
13 -------------
14
15 More documentation is available at:
16
17 http://pythonqt.sourceforge.net/
18
@@ -0,0 +1,1
1 doxygen doc.cfg No newline at end of file
This diff has been collapsed as it changes many lines, (1098 lines changed) Show them Hide them
@@ -0,0 +1,1098
1 # Doxyfile 1.3.5
2
3 # This file describes the settings to be used by the documentation system
4 # doxygen (www.doxygen.org) for a project
5 #
6 # All text after a hash (#) is considered a comment and will be ignored
7 # The format is:
8 # TAG = value [value, ...]
9 # For lists items can also be appended using:
10 # TAG += value [value, ...]
11 # Values that contain spaces should be placed between quotes (" ")
12
13 #---------------------------------------------------------------------------
14 # Project related configuration options
15 #---------------------------------------------------------------------------
16
17 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded
18 # by quotes) that should identify the project.
19
20 PROJECT_NAME = PythonQt
21
22 # The PROJECT_NUMBER tag can be used to enter a project or revision number.
23 # This could be handy for archiving the generated documentation or
24 # if some version control system is used.
25
26 PROJECT_NUMBER = 1.0
27
28 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
29 # base path where the generated documentation will be put.
30 # If a relative path is entered, it will be relative to the location
31 # where doxygen was started. If left blank the current directory will be used.
32
33 OUTPUT_DIRECTORY = .
34
35 # The OUTPUT_LANGUAGE tag is used to specify the language in which all
36 # documentation generated by doxygen is written. Doxygen will use this
37 # information to generate all constant output in the proper language.
38 # The default language is English, other supported languages are:
39 # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch,
40 # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en
41 # (Japanese with English messages), Korean, Norwegian, Polish, Portuguese,
42 # Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
43
44 OUTPUT_LANGUAGE = English
45
46 # This tag can be used to specify the encoding used in the generated output.
47 # The encoding is not always determined by the language that is chosen,
48 # but also whether or not the output is meant for Windows or non-Windows users.
49 # In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES
50 # forces the Windows encoding (this is the default for the Windows binary),
51 # whereas setting the tag to NO uses a Unix-style encoding (the default for
52 # all platforms other than Windows).
53
54 USE_WINDOWS_ENCODING = NO
55
56 # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
57 # include brief member descriptions after the members that are listed in
58 # the file and class documentation (similar to JavaDoc).
59 # Set to NO to disable this.
60
61 BRIEF_MEMBER_DESC = YES
62
63 # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
64 # the brief description of a member or function before the detailed description.
65 # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
66 # brief descriptions will be completely suppressed.
67
68 REPEAT_BRIEF = YES
69
70 # This tag implements a quasi-intelligent brief description abbreviator
71 # that is used to form the text in various listings. Each string
72 # in this list, if found as the leading text of the brief description, will be
73 # stripped from the text and the result after processing the whole list, is used
74 # as the annotated text. Otherwise, the brief description is used as-is. If left
75 # blank, the following values are used ("$name" is automatically replaced with the
76 # name of the entity): "The $name class" "The $name widget" "The $name file"
77 # "is" "provides" "specifies" "contains" "represents" "a" "an" "the"
78
79 ABBREVIATE_BRIEF =
80
81 # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
82 # Doxygen will generate a detailed section even if there is only a brief
83 # description.
84
85 ALWAYS_DETAILED_SEC = NO
86
87 # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
88 # members of a class in the documentation of that class as if those members were
89 # ordinary class members. Constructors, destructors and assignment operators of
90 # the base classes will not be shown.
91
92 INLINE_INHERITED_MEMB = NO
93
94 # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
95 # path before files name in the file list and in the header files. If set
96 # to NO the shortest path that makes the file name unique will be used.
97
98 FULL_PATH_NAMES = NO
99
100 # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
101 # can be used to strip a user-defined part of the path. Stripping is
102 # only done if one of the specified strings matches the left-hand part of
103 # the path. It is allowed to use relative paths in the argument list.
104
105 STRIP_FROM_PATH =
106
107 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
108 # (but less readable) file names. This can be useful is your file systems
109 # doesn't support long names like on DOS, Mac, or CD-ROM.
110
111 SHORT_NAMES = NO
112
113 # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
114 # will interpret the first line (until the first dot) of a JavaDoc-style
115 # comment as the brief description. If set to NO, the JavaDoc
116 # comments will behave just like the Qt-style comments (thus requiring an
117 # explicit @brief command for a brief description.
118
119 JAVADOC_AUTOBRIEF = NO
120
121 # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
122 # treat a multi-line C++ special comment block (i.e. a block of //! or ///
123 # comments) as a brief description. This used to be the default behaviour.
124 # The new default is to treat a multi-line C++ comment block as a detailed
125 # description. Set this tag to YES if you prefer the old behaviour instead.
126
127 MULTILINE_CPP_IS_BRIEF = NO
128
129 # If the DETAILS_AT_TOP tag is set to YES then Doxygen
130 # will output the detailed description near the top, like JavaDoc.
131 # If set to NO, the detailed description appears after the member
132 # documentation.
133
134 DETAILS_AT_TOP = NO
135
136 # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
137 # member inherits the documentation from any documented member that it
138 # re-implements.
139
140 INHERIT_DOCS = YES
141
142 # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
143 # tag is set to YES, then doxygen will reuse the documentation of the first
144 # member in the group (if any) for the other members of the group. By default
145 # all members of a group must be documented explicitly.
146
147 DISTRIBUTE_GROUP_DOC = NO
148
149 # The TAB_SIZE tag can be used to set the number of spaces in a tab.
150 # Doxygen uses this value to replace tabs by spaces in code fragments.
151
152 TAB_SIZE = 4
153
154 # This tag can be used to specify a number of aliases that acts
155 # as commands in the documentation. An alias has the form "name=value".
156 # For example adding "sideeffect=\par Side Effects:\n" will allow you to
157 # put the command \sideeffect (or @sideeffect) in the documentation, which
158 # will result in a user-defined paragraph with heading "Side Effects:".
159 # You can put \n's in the value part of an alias to insert newlines.
160
161 ALIASES =
162
163 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
164 # only. Doxygen will then generate output that is more tailored for C.
165 # For instance, some of the names that are used will be different. The list
166 # of all members will be omitted, etc.
167
168 OPTIMIZE_OUTPUT_FOR_C = NO
169
170 # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
171 # only. Doxygen will then generate output that is more tailored for Java.
172 # For instance, namespaces will be presented as packages, qualified scopes
173 # will look different, etc.
174
175 OPTIMIZE_OUTPUT_JAVA = NO
176
177 # Set the SUBGROUPING tag to YES (the default) to allow class member groups of
178 # the same type (for instance a group of public functions) to be put as a
179 # subgroup of that type (e.g. under the Public Functions section). Set it to
180 # NO to prevent subgrouping. Alternatively, this can be done per class using
181 # the \nosubgrouping command.
182
183 SUBGROUPING = YES
184
185 #---------------------------------------------------------------------------
186 # Build related configuration options
187 #---------------------------------------------------------------------------
188
189 # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
190 # documentation are documented, even if no documentation was available.
191 # Private class members and static file members will be hidden unless
192 # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
193
194 EXTRACT_ALL = YES
195
196 # If the EXTRACT_PRIVATE tag is set to YES all private members of a class
197 # will be included in the documentation.
198
199 EXTRACT_PRIVATE = NO
200
201 # If the EXTRACT_STATIC tag is set to YES all static members of a file
202 # will be included in the documentation.
203
204 EXTRACT_STATIC = YES
205
206 # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
207 # defined locally in source files will be included in the documentation.
208 # If set to NO only classes defined in header files are included.
209
210 EXTRACT_LOCAL_CLASSES = YES
211
212 # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
213 # undocumented members of documented classes, files or namespaces.
214 # If set to NO (the default) these members will be included in the
215 # various overviews, but no documentation section is generated.
216 # This option has no effect if EXTRACT_ALL is enabled.
217
218 HIDE_UNDOC_MEMBERS = NO
219
220 # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
221 # undocumented classes that are normally visible in the class hierarchy.
222 # If set to NO (the default) these classes will be included in the various
223 # overviews. This option has no effect if EXTRACT_ALL is enabled.
224
225 HIDE_UNDOC_CLASSES = NO
226
227 # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
228 # friend (class|struct|union) declarations.
229 # If set to NO (the default) these declarations will be included in the
230 # documentation.
231
232 HIDE_FRIEND_COMPOUNDS = NO
233
234 # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
235 # documentation blocks found inside the body of a function.
236 # If set to NO (the default) these blocks will be appended to the
237 # function's detailed documentation block.
238
239 HIDE_IN_BODY_DOCS = NO
240
241 # The INTERNAL_DOCS tag determines if documentation
242 # that is typed after a \internal command is included. If the tag is set
243 # to NO (the default) then the documentation will be excluded.
244 # Set it to YES to include the internal documentation.
245
246 INTERNAL_DOCS = NO
247
248 # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
249 # file names in lower-case letters. If set to YES upper-case letters are also
250 # allowed. This is useful if you have classes or files whose names only differ
251 # in case and if your file system supports case sensitive file names. Windows
252 # users are advised to set this option to NO.
253
254 CASE_SENSE_NAMES = YES
255
256 # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
257 # will show members with their full class and namespace scopes in the
258 # documentation. If set to YES the scope will be hidden.
259
260 HIDE_SCOPE_NAMES = NO
261
262 # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
263 # will put a list of the files that are included by a file in the documentation
264 # of that file.
265
266 SHOW_INCLUDE_FILES = YES
267
268 # If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
269 # is inserted in the documentation for inline members.
270
271 INLINE_INFO = YES
272
273 # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
274 # will sort the (detailed) documentation of file and class members
275 # alphabetically by member name. If set to NO the members will appear in
276 # declaration order.
277
278 SORT_MEMBER_DOCS = YES
279
280 # The GENERATE_TODOLIST tag can be used to enable (YES) or
281 # disable (NO) the todo list. This list is created by putting \todo
282 # commands in the documentation.
283
284 GENERATE_TODOLIST = NO
285
286 # The GENERATE_TESTLIST tag can be used to enable (YES) or
287 # disable (NO) the test list. This list is created by putting \test
288 # commands in the documentation.
289
290 GENERATE_TESTLIST = NO
291
292 # The GENERATE_BUGLIST tag can be used to enable (YES) or
293 # disable (NO) the bug list. This list is created by putting \bug
294 # commands in the documentation.
295
296 GENERATE_BUGLIST = YES
297
298 # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
299 # disable (NO) the deprecated list. This list is created by putting
300 # \deprecated commands in the documentation.
301
302 GENERATE_DEPRECATEDLIST= YES
303
304 # The ENABLED_SECTIONS tag can be used to enable conditional
305 # documentation sections, marked by \if sectionname ... \endif.
306
307 ENABLED_SECTIONS = sourceonly
308
309 # The MAX_INITIALIZER_LINES tag determines the maximum number of lines
310 # the initial value of a variable or define consists of for it to appear in
311 # the documentation. If the initializer consists of more lines than specified
312 # here it will be hidden. Use a value of 0 to hide initializers completely.
313 # The appearance of the initializer of individual variables and defines in the
314 # documentation can be controlled using \showinitializer or \hideinitializer
315 # command in the documentation regardless of this setting.
316
317 MAX_INITIALIZER_LINES = 30
318
319 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated
320 # at the bottom of the documentation of classes and structs. If set to YES the
321 # list will mention the files that were used to generate the documentation.
322
323 SHOW_USED_FILES = YES
324
325 #---------------------------------------------------------------------------
326 # configuration options related to warning and progress messages
327 #---------------------------------------------------------------------------
328
329 # The QUIET tag can be used to turn on/off the messages that are generated
330 # by doxygen. Possible values are YES and NO. If left blank NO is used.
331
332 QUIET = YES
333
334 # The WARNINGS tag can be used to turn on/off the warning messages that are
335 # generated by doxygen. Possible values are YES and NO. If left blank
336 # NO is used.
337
338 WARNINGS = YES
339
340 # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
341 # for undocumented members. If EXTRACT_ALL is set to YES then this flag will
342 # automatically be disabled.
343
344 WARN_IF_UNDOCUMENTED = YES
345
346 # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
347 # potential errors in the documentation, such as not documenting some
348 # parameters in a documented function, or documenting parameters that
349 # don't exist or using markup commands wrongly.
350
351 WARN_IF_DOC_ERROR = YES
352
353 # The WARN_FORMAT tag determines the format of the warning messages that
354 # doxygen can produce. The string should contain the $file, $line, and $text
355 # tags, which will be replaced by the file and line number from which the
356 # warning originated and the warning text.
357
358 WARN_FORMAT = "$file:$line: $text"
359
360 # The WARN_LOGFILE tag can be used to specify a file to which warning
361 # and error messages should be written. If left blank the output is written
362 # to stderr.
363
364 WARN_LOGFILE = doxygen.log
365
366 #---------------------------------------------------------------------------
367 # configuration options related to the input files
368 #---------------------------------------------------------------------------
369
370 # The INPUT tag can be used to specify the files and/or directories that contain
371 # documented source files. You may enter file names like "myfile.cpp" or
372 # directories like "/usr/src/myproject". Separate the files or directories
373 # with spaces.
374
375 INPUT = ../src
376
377 # If the value of the INPUT tag contains directories, you can use the
378 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
379 # and *.h) to filter out the source-files in the directories. If left
380 # blank the following patterns are tested:
381 # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
382 # *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
383
384 FILE_PATTERNS = *.h
385
386 # The RECURSIVE tag can be used to turn specify whether or not subdirectories
387 # should be searched for input files as well. Possible values are YES and NO.
388 # If left blank NO is used.
389
390 RECURSIVE = NO
391
392 # The EXCLUDE tag can be used to specify files and/or directories that should
393 # excluded from the INPUT source files. This way you can easily exclude a
394 # subdirectory from a directory tree whose root is specified with the INPUT tag.
395
396 EXCLUDE =
397
398 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
399 # that are symbolic links (a Unix filesystem feature) are excluded from the input.
400
401 EXCLUDE_SYMLINKS = NO
402
403 # If the value of the INPUT tag contains directories, you can use the
404 # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
405 # certain files from those directories.
406
407 EXCLUDE_PATTERNS =
408
409 # The EXAMPLE_PATH tag can be used to specify one or more files or
410 # directories that contain example code fragments that are included (see
411 # the \include command).
412
413 EXAMPLE_PATH =
414
415 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
416 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
417 # and *.h) to filter out the source-files in the directories. If left
418 # blank all files are included.
419
420 EXAMPLE_PATTERNS =
421
422 # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
423 # searched for input files to be used with the \include or \dontinclude
424 # commands irrespective of the value of the RECURSIVE tag.
425 # Possible values are YES and NO. If left blank NO is used.
426
427 EXAMPLE_RECURSIVE = NO
428
429 # The IMAGE_PATH tag can be used to specify one or more files or
430 # directories that contain image that are included in the documentation (see
431 # the \image command).
432
433 IMAGE_PATH =
434
435 # The INPUT_FILTER tag can be used to specify a program that doxygen should
436 # invoke to filter for each input file. Doxygen will invoke the filter program
437 # by executing (via popen()) the command <filter> <input-file>, where <filter>
438 # is the value of the INPUT_FILTER tag, and <input-file> is the name of an
439 # input file. Doxygen will then use the output that the filter program writes
440 # to standard output.
441
442 INPUT_FILTER =
443
444 # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
445 # INPUT_FILTER) will be used to filter the input files when producing source
446 # files to browse (i.e. when SOURCE_BROWSER is set to YES).
447
448 FILTER_SOURCE_FILES = NO
449
450 #---------------------------------------------------------------------------
451 # configuration options related to source browsing
452 #---------------------------------------------------------------------------
453
454 # If the SOURCE_BROWSER tag is set to YES then a list of source files will
455 # be generated. Documented entities will be cross-referenced with these sources.
456 # Note: To get rid of all source code in the generated output, make sure also
457 # VERBATIM_HEADERS is set to NO.
458
459 SOURCE_BROWSER = YES
460
461 # Setting the INLINE_SOURCES tag to YES will include the body
462 # of functions and classes directly in the documentation.
463
464 INLINE_SOURCES = YES
465
466 # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
467 # doxygen to hide any special comment blocks from generated source code
468 # fragments. Normal C and C++ comments will always remain visible.
469
470 STRIP_CODE_COMMENTS = YES
471
472 # If the REFERENCED_BY_RELATION tag is set to YES (the default)
473 # then for each documented function all documented
474 # functions referencing it will be listed.
475
476 REFERENCED_BY_RELATION = YES
477
478 # If the REFERENCES_RELATION tag is set to YES (the default)
479 # then for each documented function all documented entities
480 # called/used by that function will be listed.
481
482 REFERENCES_RELATION = YES
483
484 # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
485 # will generate a verbatim copy of the header file for each class for
486 # which an include is specified. Set to NO to disable this.
487
488 VERBATIM_HEADERS = YES
489
490 #---------------------------------------------------------------------------
491 # configuration options related to the alphabetical class index
492 #---------------------------------------------------------------------------
493
494 # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
495 # of all compounds will be generated. Enable this if the project
496 # contains a lot of classes, structs, unions or interfaces.
497
498 ALPHABETICAL_INDEX = YES
499
500 # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
501 # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
502 # in which this list will be split (can be a number in the range [1..20])
503
504 COLS_IN_ALPHA_INDEX = 5
505
506 # In case all classes in a project start with a common prefix, all
507 # classes will be put under the same header in the alphabetical index.
508 # The IGNORE_PREFIX tag can be used to specify one or more prefixes that
509 # should be ignored while generating the index headers.
510
511 IGNORE_PREFIX = PythonQt
512
513 #---------------------------------------------------------------------------
514 # configuration options related to the HTML output
515 #---------------------------------------------------------------------------
516
517 # If the GENERATE_HTML tag is set to YES (the default) Doxygen will
518 # generate HTML output.
519
520 GENERATE_HTML = YES
521
522 # The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
523 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
524 # put in front of it. If left blank `html' will be used as the default path.
525
526 HTML_OUTPUT = html
527
528 # The HTML_FILE_EXTENSION tag can be used to specify the file extension for
529 # each generated HTML page (for example: .htm,.php,.asp). If it is left blank
530 # doxygen will generate files with .html extension.
531
532 HTML_FILE_EXTENSION = .html
533
534 # The HTML_HEADER tag can be used to specify a personal HTML header for
535 # each generated HTML page. If it is left blank doxygen will generate a
536 # standard header.
537
538 HTML_HEADER = header.html
539
540 # The HTML_FOOTER tag can be used to specify a personal HTML footer for
541 # each generated HTML page. If it is left blank doxygen will generate a
542 # standard footer.
543
544 HTML_FOOTER =
545
546 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading
547 # style sheet that is used by each HTML page. It can be used to
548 # fine-tune the look of the HTML output. If the tag is left blank doxygen
549 # will generate a default style sheet. Note that doxygen will try to copy
550 # the style sheet file to the HTML output directory, so don't put your own
551 # stylesheet in the HTML output directory as well, or it will be erased!
552
553 HTML_STYLESHEET =
554
555 # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
556 # files or namespaces will be aligned in HTML using tables. If set to
557 # NO a bullet list will be used.
558
559 HTML_ALIGN_MEMBERS = YES
560
561 # If the GENERATE_HTMLHELP tag is set to YES, additional index files
562 # will be generated that can be used as input for tools like the
563 # Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
564 # of the generated HTML documentation.
565
566 GENERATE_HTMLHELP = NO
567
568 # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
569 # be used to specify the file name of the resulting .chm file. You
570 # can add a path in front of the file if the result should not be
571 # written to the html output directory.
572
573 CHM_FILE =
574
575 # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
576 # be used to specify the location (absolute path including file name) of
577 # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
578 # the HTML help compiler on the generated index.hhp.
579
580 HHC_LOCATION =
581
582 # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
583 # controls if a separate .chi index file is generated (YES) or that
584 # it should be included in the master .chm file (NO).
585
586 GENERATE_CHI = NO
587
588 # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
589 # controls whether a binary table of contents is generated (YES) or a
590 # normal table of contents (NO) in the .chm file.
591
592 BINARY_TOC = NO
593
594 # The TOC_EXPAND flag can be set to YES to add extra items for group members
595 # to the contents of the HTML help documentation and to the tree view.
596
597 TOC_EXPAND = NO
598
599 # The DISABLE_INDEX tag can be used to turn on/off the condensed index at
600 # top of each HTML page. The value NO (the default) enables the index and
601 # the value YES disables it.
602
603 DISABLE_INDEX = NO
604
605 # This tag can be used to set the number of enum values (range [1..20])
606 # that doxygen will group on one line in the generated HTML documentation.
607
608 ENUM_VALUES_PER_LINE = 4
609
610 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
611 # generated containing a tree-like index structure (just like the one that
612 # is generated for HTML Help). For this to work a browser that supports
613 # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
614 # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
615 # probably better off using the HTML help feature.
616
617 GENERATE_TREEVIEW = NO
618
619 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
620 # used to set the initial width (in pixels) of the frame in which the tree
621 # is shown.
622
623 TREEVIEW_WIDTH = 250
624
625 #---------------------------------------------------------------------------
626 # configuration options related to the LaTeX output
627 #---------------------------------------------------------------------------
628
629 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
630 # generate Latex output.
631
632 GENERATE_LATEX = NO
633
634 # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
635 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
636 # put in front of it. If left blank `latex' will be used as the default path.
637
638 LATEX_OUTPUT = latex
639
640 # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
641 # invoked. If left blank `latex' will be used as the default command name.
642
643 LATEX_CMD_NAME = latex
644
645 # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
646 # generate index for LaTeX. If left blank `makeindex' will be used as the
647 # default command name.
648
649 MAKEINDEX_CMD_NAME = makeindex
650
651 # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
652 # LaTeX documents. This may be useful for small projects and may help to
653 # save some trees in general.
654
655 COMPACT_LATEX = NO
656
657 # The PAPER_TYPE tag can be used to set the paper type that is used
658 # by the printer. Possible values are: a4, a4wide, letter, legal and
659 # executive. If left blank a4wide will be used.
660
661 PAPER_TYPE = a4wide
662
663 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
664 # packages that should be included in the LaTeX output.
665
666 EXTRA_PACKAGES =
667
668 # The LATEX_HEADER tag can be used to specify a personal LaTeX header for
669 # the generated latex document. The header should contain everything until
670 # the first chapter. If it is left blank doxygen will generate a
671 # standard header. Notice: only use this tag if you know what you are doing!
672
673 LATEX_HEADER =
674
675 # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
676 # is prepared for conversion to pdf (using ps2pdf). The pdf file will
677 # contain links (just like the HTML output) instead of page references
678 # This makes the output suitable for online browsing using a pdf viewer.
679
680 PDF_HYPERLINKS = NO
681
682 # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
683 # plain latex in the generated Makefile. Set this option to YES to get a
684 # higher quality PDF documentation.
685
686 USE_PDFLATEX = NO
687
688 # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
689 # command to the generated LaTeX files. This will instruct LaTeX to keep
690 # running if errors occur, instead of asking the user for help.
691 # This option is also used when generating formulas in HTML.
692
693 LATEX_BATCHMODE = NO
694
695 # If LATEX_HIDE_INDICES is set to YES then doxygen will not
696 # include the index chapters (such as File Index, Compound Index, etc.)
697 # in the output.
698
699 LATEX_HIDE_INDICES = NO
700
701 #---------------------------------------------------------------------------
702 # configuration options related to the RTF output
703 #---------------------------------------------------------------------------
704
705 # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
706 # The RTF output is optimized for Word 97 and may not look very pretty with
707 # other RTF readers or editors.
708
709 GENERATE_RTF = NO
710
711 # The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
712 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
713 # put in front of it. If left blank `rtf' will be used as the default path.
714
715 RTF_OUTPUT = rtf
716
717 # If the COMPACT_RTF tag is set to YES Doxygen generates more compact
718 # RTF documents. This may be useful for small projects and may help to
719 # save some trees in general.
720
721 COMPACT_RTF = NO
722
723 # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
724 # will contain hyperlink fields. The RTF file will
725 # contain links (just like the HTML output) instead of page references.
726 # This makes the output suitable for online browsing using WORD or other
727 # programs which support those fields.
728 # Note: wordpad (write) and others do not support links.
729
730 RTF_HYPERLINKS = NO
731
732 # Load stylesheet definitions from file. Syntax is similar to doxygen's
733 # config file, i.e. a series of assignments. You only have to provide
734 # replacements, missing definitions are set to their default value.
735
736 RTF_STYLESHEET_FILE =
737
738 # Set optional variables used in the generation of an rtf document.
739 # Syntax is similar to doxygen's config file.
740
741 RTF_EXTENSIONS_FILE =
742
743 #---------------------------------------------------------------------------
744 # configuration options related to the man page output
745 #---------------------------------------------------------------------------
746
747 # If the GENERATE_MAN tag is set to YES (the default) Doxygen will
748 # generate man pages
749
750 GENERATE_MAN = NO
751
752 # The MAN_OUTPUT tag is used to specify where the man pages will be put.
753 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
754 # put in front of it. If left blank `man' will be used as the default path.
755
756 MAN_OUTPUT = man
757
758 # The MAN_EXTENSION tag determines the extension that is added to
759 # the generated man pages (default is the subroutine's section .3)
760
761 MAN_EXTENSION = .3
762
763 # If the MAN_LINKS tag is set to YES and Doxygen generates man output,
764 # then it will generate one additional man file for each entity
765 # documented in the real man page(s). These additional files
766 # only source the real man page, but without them the man command
767 # would be unable to find the correct page. The default is NO.
768
769 MAN_LINKS = NO
770
771 #---------------------------------------------------------------------------
772 # configuration options related to the XML output
773 #---------------------------------------------------------------------------
774
775 # If the GENERATE_XML tag is set to YES Doxygen will
776 # generate an XML file that captures the structure of
777 # the code including all documentation.
778
779 GENERATE_XML = NO
780
781 # The XML_OUTPUT tag is used to specify where the XML pages will be put.
782 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
783 # put in front of it. If left blank `xml' will be used as the default path.
784
785 XML_OUTPUT = xml
786
787 # The XML_SCHEMA tag can be used to specify an XML schema,
788 # which can be used by a validating XML parser to check the
789 # syntax of the XML files.
790
791 XML_SCHEMA =
792
793 # The XML_DTD tag can be used to specify an XML DTD,
794 # which can be used by a validating XML parser to check the
795 # syntax of the XML files.
796
797 XML_DTD =
798
799 # If the XML_PROGRAMLISTING tag is set to YES Doxygen will
800 # dump the program listings (including syntax highlighting
801 # and cross-referencing information) to the XML output. Note that
802 # enabling this will significantly increase the size of the XML output.
803
804 XML_PROGRAMLISTING = YES
805
806 #---------------------------------------------------------------------------
807 # configuration options for the AutoGen Definitions output
808 #---------------------------------------------------------------------------
809
810 # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
811 # generate an AutoGen Definitions (see autogen.sf.net) file
812 # that captures the structure of the code including all
813 # documentation. Note that this feature is still experimental
814 # and incomplete at the moment.
815
816 GENERATE_AUTOGEN_DEF = NO
817
818 #---------------------------------------------------------------------------
819 # configuration options related to the Perl module output
820 #---------------------------------------------------------------------------
821
822 # If the GENERATE_PERLMOD tag is set to YES Doxygen will
823 # generate a Perl module file that captures the structure of
824 # the code including all documentation. Note that this
825 # feature is still experimental and incomplete at the
826 # moment.
827
828 GENERATE_PERLMOD = NO
829
830 # If the PERLMOD_LATEX tag is set to YES Doxygen will generate
831 # the necessary Makefile rules, Perl scripts and LaTeX code to be able
832 # to generate PDF and DVI output from the Perl module output.
833
834 PERLMOD_LATEX = NO
835
836 # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
837 # nicely formatted so it can be parsed by a human reader. This is useful
838 # if you want to understand what is going on. On the other hand, if this
839 # tag is set to NO the size of the Perl module output will be much smaller
840 # and Perl will parse it just the same.
841
842 PERLMOD_PRETTY = YES
843
844 # The names of the make variables in the generated doxyrules.make file
845 # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
846 # This is useful so different doxyrules.make files included by the same
847 # Makefile don't overwrite each other's variables.
848
849 PERLMOD_MAKEVAR_PREFIX =
850
851 #---------------------------------------------------------------------------
852 # Configuration options related to the preprocessor
853 #---------------------------------------------------------------------------
854
855 # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
856 # evaluate all C-preprocessor directives found in the sources and include
857 # files.
858
859 ENABLE_PREPROCESSING = YES
860
861 # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
862 # names in the source code. If set to NO (the default) only conditional
863 # compilation will be performed. Macro expansion can be done in a controlled
864 # way by setting EXPAND_ONLY_PREDEF to YES.
865
866 MACRO_EXPANSION = YES
867
868 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
869 # then the macro expansion is limited to the macros specified with the
870 # PREDEFINED and EXPAND_AS_PREDEFINED tags.
871
872 EXPAND_ONLY_PREDEF = YES
873
874 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
875 # in the INCLUDE_PATH (see below) will be search if a #include is found.
876
877 SEARCH_INCLUDES = YES
878
879 # The INCLUDE_PATH tag can be used to specify one or more directories that
880 # contain include files that are not input files but should be processed by
881 # the preprocessor.
882
883 INCLUDE_PATH = $(QTDIR)/include
884
885 # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
886 # patterns (like *.h and *.hpp) to filter out the header-files in the
887 # directories. If left blank, the patterns specified with FILE_PATTERNS will
888 # be used.
889
890 INCLUDE_FILE_PATTERNS = *.h
891
892 # The PREDEFINED tag can be used to specify one or more macro names that
893 # are defined before the preprocessor is started (similar to the -D option of
894 # gcc). The argument of the tag is a list of macros of the form: name
895 # or name=definition (no spaces). If the definition and the = are
896 # omitted =1 is assumed.
897
898 PREDEFINED =
899
900 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
901 # this tag can be used to specify a list of macro names that should be expanded.
902 # The macro definition that is found in the sources will be used.
903 # Use the PREDEFINED tag if you want to use a different macro definition.
904
905 EXPAND_AS_DEFINED =
906
907 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
908 # doxygen's preprocessor will remove all function-like macros that are alone
909 # on a line, have an all uppercase name, and do not end with a semicolon. Such
910 # function macros are typically used for boiler-plate code, and will confuse the
911 # parser if not removed.
912
913 SKIP_FUNCTION_MACROS = YES
914
915 #---------------------------------------------------------------------------
916 # Configuration::addtions related to external references
917 #---------------------------------------------------------------------------
918
919 # The TAGFILES option can be used to specify one or more tagfiles.
920 # Optionally an initial location of the external documentation
921 # can be added for each tagfile. The format of a tag file without
922 # this location is as follows:
923 # TAGFILES = file1 file2 ...
924 # Adding location for the tag files is done as follows:
925 # TAGFILES = file1=loc1 "file2 = loc2" ...
926 # where "loc1" and "loc2" can be relative or absolute paths or
927 # URLs. If a location is present for each tag, the installdox tool
928 # does not have to be run to correct the links.
929 # Note that each tag file must have a unique name
930 # (where the name does NOT include the path)
931 # If a tag file is not located in the directory in which doxygen
932 # is run, you must also specify the path to the tagfile here.
933
934 TAGFILES =
935
936 # When a file name is specified after GENERATE_TAGFILE, doxygen will create
937 # a tag file that is based on the input files it reads.
938
939 GENERATE_TAGFILE =
940
941 # If the ALLEXTERNALS tag is set to YES all external classes will be listed
942 # in the class index. If set to NO only the inherited external classes
943 # will be listed.
944
945 ALLEXTERNALS = NO
946
947 # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
948 # in the modules index. If set to NO, only the current project's groups will
949 # be listed.
950
951 EXTERNAL_GROUPS = YES
952
953 # The PERL_PATH should be the absolute path and name of the perl script
954 # interpreter (i.e. the result of `which perl').
955
956 PERL_PATH = /usr/bin/perl
957
958 #---------------------------------------------------------------------------
959 # Configuration options related to the dot tool
960 #---------------------------------------------------------------------------
961
962 # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
963 # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or
964 # super classes. Setting the tag to NO turns the diagrams off. Note that this
965 # option is superseded by the HAVE_DOT option below. This is only a fallback. It is
966 # recommended to install and use dot, since it yields more powerful graphs.
967
968 CLASS_DIAGRAMS = YES
969
970 # If set to YES, the inheritance and collaboration graphs will hide
971 # inheritance and usage relations if the target is undocumented
972 # or is not a class.
973
974 HIDE_UNDOC_RELATIONS = YES
975
976 # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
977 # available from the path. This tool is part of Graphviz, a graph visualization
978 # toolkit from AT&T and Lucent Bell Labs. The other options in this section
979 # have no effect if this option is set to NO (the default)
980
981 HAVE_DOT = NO
982
983 # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
984 # will generate a graph for each documented class showing the direct and
985 # indirect inheritance relations. Setting this tag to YES will force the
986 # the CLASS_DIAGRAMS tag to NO.
987
988 CLASS_GRAPH = YES
989
990 # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
991 # will generate a graph for each documented class showing the direct and
992 # indirect implementation dependencies (inheritance, containment, and
993 # class references variables) of the class with other documented classes.
994
995 COLLABORATION_GRAPH = YES
996
997 # If the UML_LOOK tag is set to YES doxygen will generate inheritance and
998 # collaboration diagrams in a style similar to the OMG's Unified Modeling
999 # Language.
1000
1001 UML_LOOK = NO
1002
1003 # If set to YES, the inheritance and collaboration graphs will show the
1004 # relations between templates and their instances.
1005
1006 TEMPLATE_RELATIONS = NO
1007
1008 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
1009 # tags are set to YES then doxygen will generate a graph for each documented
1010 # file showing the direct and indirect include dependencies of the file with
1011 # other documented files.
1012
1013 INCLUDE_GRAPH = YES
1014
1015 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
1016 # HAVE_DOT tags are set to YES then doxygen will generate a graph for each
1017 # documented header file showing the documented files that directly or
1018 # indirectly include this file.
1019
1020 INCLUDED_BY_GRAPH = YES
1021
1022 # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
1023 # generate a call dependency graph for every global function or class method.
1024 # Note that enabling this option will significantly increase the time of a run.
1025 # So in most cases it will be better to enable call graphs for selected
1026 # functions only using the \callgraph command.
1027
1028 CALL_GRAPH = NO
1029
1030 # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
1031 # will graphical hierarchy of all classes instead of a textual one.
1032
1033 GRAPHICAL_HIERARCHY = YES
1034
1035 # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
1036 # generated by dot. Possible values are png, jpg, or gif
1037 # If left blank png will be used.
1038
1039 DOT_IMAGE_FORMAT = png
1040
1041 # The tag DOT_PATH can be used to specify the path where the dot tool can be
1042 # found. If left blank, it is assumed the dot tool can be found on the path.
1043
1044 DOT_PATH =
1045
1046 # The DOTFILE_DIRS tag can be used to specify one or more directories that
1047 # contain dot files that are included in the documentation (see the
1048 # \dotfile command).
1049
1050 DOTFILE_DIRS =
1051
1052 # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
1053 # (in pixels) of the graphs generated by dot. If a graph becomes larger than
1054 # this value, doxygen will try to truncate the graph, so that it fits within
1055 # the specified constraint. Beware that most browsers cannot cope with very
1056 # large images.
1057
1058 MAX_DOT_GRAPH_WIDTH = 1024
1059
1060 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
1061 # (in pixels) of the graphs generated by dot. If a graph becomes larger than
1062 # this value, doxygen will try to truncate the graph, so that it fits within
1063 # the specified constraint. Beware that most browsers cannot cope with very
1064 # large images.
1065
1066 MAX_DOT_GRAPH_HEIGHT = 1024
1067
1068 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
1069 # graphs generated by dot. A depth value of 3 means that only nodes reachable
1070 # from the root by following a path via at most 3 edges will be shown. Nodes that
1071 # lay further from the root node will be omitted. Note that setting this option to
1072 # 1 or 2 may greatly reduce the computation time needed for large code bases. Also
1073 # note that a graph may be further truncated if the graph's image dimensions are
1074 # not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT).
1075 # If 0 is used for the depth value (the default), the graph is not depth-constrained.
1076
1077 MAX_DOT_GRAPH_DEPTH = 0
1078
1079 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
1080 # generate a legend page explaining the meaning of the various boxes and
1081 # arrows in the dot generated graphs.
1082
1083 GENERATE_LEGEND = YES
1084
1085 # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
1086 # remove the intermediate dot files that are used to generate
1087 # the various graphs.
1088
1089 DOT_CLEANUP = YES
1090
1091 #---------------------------------------------------------------------------
1092 # Configuration::addtions related to the search engine
1093 #---------------------------------------------------------------------------
1094
1095 # The SEARCHENGINE tag specifies whether or not a search engine should be
1096 # used. If set to NO the values of all tags below this one will be ignored.
1097
1098 SEARCHENGINE = NO
@@ -0,0 +1,7
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>$title</title>
4 <link href="$relpath$doxygen.css" rel="stylesheet" type="text/css">
5 <link href="$relpath$tabs.css" rel="stylesheet" type="text/css">
6 </head><body>
7 <div style="float:right;"> <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=181737&amp;type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a></div>
@@ -0,0 +1,43
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file CustomObjects.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2007-4
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "CustomObjects.h"
43
@@ -0,0 +1,149
1 #ifndef _PYCUSTOMOBJECTS_H
2 #define _PYCUSTOMOBJECTS_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file CustomObjects.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2007-4
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQt.h"
46 #include "PythonQtCppWrapperFactory.h"
47 #include <QObject>
48
49
50 // declare our own custom object
51 class CustomObject {
52 public:
53 CustomObject() {}
54 CustomObject(const QString& first, const QString& last) { _firstName = first; _lastName = last; }
55
56 QString _firstName;
57 QString _lastName;
58
59 };
60
61
62 // add a decorator that allows to access the CustomObject from PythonQt
63 class CustomObjectWrapper : public QObject {
64
65 Q_OBJECT
66
67 public slots:
68 // add a constructor
69 CustomObject* new_CustomObject(const QString& first, const QString& last) { return new CustomObject(first, last); }
70
71 // add a destructor
72 void delete_CustomObject(CustomObject* o) { delete o; }
73
74 // add access methods
75 QString firstName(CustomObject* o) { return o->_firstName; }
76
77 QString lastName(CustomObject* o) { return o->_lastName; }
78
79 void setFirstName(CustomObject* o, const QString& name) { o->_firstName = name; }
80
81 void setLastName(CustomObject* o, const QString& name) { o->_lastName = name; }
82
83 };
84
85
86 //------------------------------------------------------------------------------------------------
87 // alternative: we create a wrapper factory, which creates a wrapper object for each CPP instance:
88 //------------------------------------------------------------------------------------------------
89
90 // declare our own custom object
91 class CustomObject2 {
92 public:
93 CustomObject2() {}
94 CustomObject2(const QString& first, const QString& last) { _firstName = first; _lastName = last; }
95
96 QString _firstName;
97 QString _lastName;
98
99 };
100
101
102 // add a decorator that allows to access the CustomObject from PythonQt
103 class CustomObject2Wrapper : public QObject {
104
105 Q_OBJECT
106
107 public:
108 CustomObject2Wrapper(CustomObject2* obj) { _ptr = obj; }
109
110 public slots:
111 // add access methods
112 QString firstName() { return _ptr->_firstName; }
113
114 QString lastName() { return _ptr->_lastName; }
115
116 void setFirstName(const QString& name) { _ptr->_firstName = name; }
117
118 void setLastName(const QString& name) { _ptr->_lastName = name; }
119
120 private:
121 CustomObject2* _ptr;
122 };
123
124 // additional constructor/destructor for CustomObject2 (optional)
125 class CustomObject2Constructor : public QObject {
126
127 Q_OBJECT
128
129 public slots:
130 // add a constructor
131 CustomObject2* new_CustomObject2(const QString& first, const QString& last) { return new CustomObject2(first, last); }
132
133 // add a destructor
134 void delete_CustomObject2(CustomObject2* o) { delete o; }
135 };
136
137 // a factory that can create wrappers for CustomObject2
138 class CustomFactory : public PythonQtCppWrapperFactory
139 {
140 public:
141 virtual QObject* create(const QByteArray& name, void *ptr) {
142 if (name == "CustomObject2") {
143 return new CustomObject2Wrapper((CustomObject2*)ptr);
144 }
145 return NULL;
146 }
147 };
148
149 #endif
@@ -0,0 +1,2
1 "%MEVIS_LIB%\make\win32\createDsp.bat" PyCPPWrapperExample
2
@@ -0,0 +1,22
1 # --------- PyCPPWrapperExample profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6
7 TARGET = PyCPPWrapperExample
8 TEMPLATE = app
9
10 DESTDIR = ../../lib
11
12 include ( ../../build/common.prf )
13 include ( ../../build/PythonQt.prf )
14
15 HEADERS += \
16 CustomObjects.h
17
18 SOURCES += \
19 main.cpp \
20 CustomObjects.cpp
21
22 RESOURCES += PyCPPWrapperExample.qrc
@@ -0,0 +1,5
1 <!DOCTYPE RCC><RCC version="1.0">
2 <qresource>
3 <file>example.py</file>
4 </qresource>
5 </RCC>
@@ -0,0 +1,38
1 from PythonQt import *
2
3 print "alternative 1 : CustomObject wrapped by decorators"
4
5 # create a new object
6 custom = CustomObject("John","Doe")
7
8 # print the object (to see how it is wrapped)
9 print custom
10
11 # print the methods available
12 print dir(custom)
13
14 # set a name
15 custom.setFirstName("Mike")
16 custom.setLastName("Michels")
17
18 # get the name
19 print custom.firstName() + " " + custom.lastName();
20
21 print
22 print "alternative 2 : CustomObject2 wrapped by factory"
23
24 # create a new object
25 custom2 = CustomObject2("John","Doe")
26
27 # print the object (to see how it is wrapped)
28 print custom2
29
30 # print the methods available
31 print dir(custom2)
32
33 # set a name
34 custom2.setFirstName("Mike")
35 custom2.setLastName("Michels")
36
37 # get the name
38 print custom2.firstName() + " " + custom2.lastName();
@@ -0,0 +1,86
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PyGuiExample.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2007-04
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include "gui/PythonQtScriptingConsole.h"
44 #include "CustomObjects.h"
45
46 #include <QApplication>
47
48 int main( int argc, char **argv )
49 {
50 QApplication qapp(argc, argv);
51
52 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
53
54 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
55 PythonQtScriptingConsole console(NULL, mainContext);
56
57 // -----------------------------------------------------------------
58 // Alternative 1: make CustomObject known and use decorators for wrapping:
59 // -----------------------------------------------------------------
60
61 // register the new object as a known classname
62 PythonQt::self()->registerCPPClassNames(QStringList() << "CustomObject");
63 // add a decorator which can access CustomObject instances
64 PythonQt::self()->addDecorators(new CustomObjectWrapper());
65
66 // -----------------------------------------------------------------
67 // Alternative 2: make CustomObject2 known and use a wrapper factory for wrapping:
68 // -----------------------------------------------------------------
69
70 // add a factory that can handle pointers to CustomObject2
71 PythonQt::self()->addWrapperFactory(new CustomFactory());
72
73 // the following is optional and only needed if you want a constructor:
74 // register the new object as a known classname
75 PythonQt::self()->registerCPPClassNames(QStringList() << "CustomObject2");
76 // add a constructor for CustomObject2
77 PythonQt::self()->addClassDecorators(new CustomObject2Constructor());
78
79 mainContext.evalFile(":example.py");
80
81 console.appendCommandPrompt();
82 console.show();
83
84 return qapp.exec();
85 }
86
@@ -0,0 +1,43
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file CustomObject.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2007-4
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "CustomObject.h"
43
@@ -0,0 +1,85
1 #ifndef _PYCUSTOMOBJECT_H
2 #define _PYCUSTOMOBJECT_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file CustomObject.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2007-4
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQt.h"
46 #include <QObject>
47
48
49 // declare our own copyable custom object
50 class CustomObject {
51 public:
52 CustomObject() {}
53 CustomObject(const QString& first, const QString& last) { _firstName = first; _lastName = last; }
54
55 QString _firstName;
56 QString _lastName;
57
58 };
59
60 // register it to the meta type system
61 Q_DECLARE_METATYPE(CustomObject)
62
63 // add a wrapper that allows to access the CustomObject from PythonQt
64 class CustomObjectWrapper : public QObject {
65
66 Q_OBJECT
67
68 public slots:
69 // add a constructor
70 QVariant new_CustomObject(const QString& first, const QString& last) { return qVariantFromValue(CustomObject(first, last)); }
71
72 // add access methods
73
74 QString firstName(CustomObject* o) { return o->_firstName; }
75
76 QString lastName(CustomObject* o) { return o->_lastName; }
77
78 void setFirstName(CustomObject* o, const QString& name) { o->_firstName = name; }
79
80 void setLastName(CustomObject* o, const QString& name) { o->_lastName = name; }
81
82 };
83
84
85 #endif
@@ -0,0 +1,2
1 "%MEVIS_LIB%\make\win32\createDsp.bat" PyCustomMetaTypeExample
2
@@ -0,0 +1,23
1 # --------- PyCustomMetaTypeExample profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6
7 TARGET = PyCustomMetaTypeExample
8 TEMPLATE = app
9
10 DESTDIR = ../../lib
11
12 include ( ../../build/common.prf )
13 include ( ../../build/PythonQt.prf )
14
15
16 HEADERS += \
17 CustomObject.h
18
19 SOURCES += \
20 main.cpp \
21 CustomObject.cpp
22
23 RESOURCES += PyCustomMetaTypeExample.qrc
@@ -0,0 +1,5
1 <!DOCTYPE RCC><RCC version="1.0">
2 <qresource>
3 <file>example.py</file>
4 </qresource>
5 </RCC>
@@ -0,0 +1,14
1 from PythonQt import *
2
3 # create a new object
4 custom = CustomObject("John","Doe")
5
6 # print the methods available
7 print dir(custom)
8
9 # set a name
10 custom.setFirstName("Mike")
11 custom.setLastName("Michels")
12
13 # get the name
14 print custom.firstName() + " " + custom.lastName();
@@ -0,0 +1,69
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PyGuiExample.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2007-04
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include "gui/PythonQtScriptingConsole.h"
44 #include "CustomObject.h"
45
46 #include <QApplication>
47
48 int main( int argc, char **argv )
49 {
50 QApplication qapp(argc, argv);
51
52 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
53
54 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
55 PythonQtScriptingConsole console(NULL, mainContext);
56
57 // register the type with QMetaType
58 qRegisterMetaType<CustomObject>("CustomObject");
59 // add a wrapper object for the new variant type
60 PythonQt::self()->addVariantWrapper("CustomObject", new CustomObjectWrapper());
61
62 mainContext.evalFile(":example.py");
63
64 console.appendCommandPrompt();
65 console.show();
66
67 return qapp.exec();
68 }
69
@@ -0,0 +1,2
1 "%MEVIS_LIB%\make\win32\createDsp.bat" PyDecoratorsExample
2
@@ -0,0 +1,23
1 # --------- PyGuiExample profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6
7 TARGET = PyDecoratorsExample
8 TEMPLATE = app
9
10 DESTDIR = ../../lib
11
12 include ( ../../build/common.prf )
13 include ( ../../build/PythonQt.prf )
14
15
16 HEADERS += \
17 PyExampleDecorators.h
18
19 SOURCES += \
20 main.cpp \
21 PyExampleDecorators.cpp
22
23 RESOURCES += PyDecoratorsExample.qrc
@@ -0,0 +1,5
1 <!DOCTYPE RCC><RCC version="1.0">
2 <qresource>
3 <file>example.py</file>
4 </qresource>
5 </RCC>
@@ -0,0 +1,43
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PyExampleObject.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-10
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PyExampleDecorators.h"
43
@@ -0,0 +1,95
1 #ifndef _PYEXAMPLEDECORATORS_H
2 #define _PYEXAMPLEDECORATORS_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PyExampleDecorators.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2007-4
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQt.h"
46 #include <QDebug>
47 #include <QObject>
48 #include <QPushButton>
49
50 // an example CPP object
51 class YourCPPObject {
52 public:
53 YourCPPObject(int arg1, float arg2) { a = arg1; b = arg2; }
54
55 float doSomething(int arg1) { return arg1*a*b; };
56
57 private:
58
59 int a;
60 float b;
61 };
62
63 // an example decorator
64 class PyExampleDecorators : public QObject
65 {
66 Q_OBJECT
67
68 public slots:
69 // add a constructor to QSize variant that takes a QPoint
70 QVariant new_QSize(const QPoint& p) { return QSize(p.x(), p.y()); }
71
72 // add a constructor for QPushButton that takes a text and a parent widget
73 QPushButton* new_QPushButton(const QString& text, QWidget* parent=NULL) { return new QPushButton(text, parent); }
74
75 // add a constructor for a CPP object
76 YourCPPObject* new_YourCPPObject(int arg1, float arg2) { return new YourCPPObject(arg1, arg2); }
77
78 // add a destructor for a CPP object
79 void delete_YourCPPObject(YourCPPObject* obj) { delete obj; }
80
81 // add a static method to QWidget
82 QWidget* static_QWidget_mouseGrabber() { return QWidget::mouseGrabber(); }
83
84 // add an additional slot to QWidget (make move() callable, which is not declared as a slot in QWidget)
85 void move(QWidget* w, const QPoint& p) { w->move(p); }
86
87 // add an additional slot to QWidget, overloading the above move method
88 void move(QWidget* w, int x, int y) { w->move(x,y); }
89
90 // add a method to your own CPP object
91 int doSomething(YourCPPObject* obj, int arg1) { return obj->doSomething(arg1); }
92 };
93
94
95 #endif
@@ -0,0 +1,28
1 from PythonQt import *
2
3 # call our new constructor of QSize
4 size = QSize(QPoint(1,2));
5
6 # call our new QPushButton constructor
7 button = QPushButton("sometext");
8
9 # call the move slot (overload1)
10 button.move(QPoint(0,0))
11
12 # call the move slot (overload2)
13 button.move(0,0)
14
15 # call the static method
16 print QWidget.mouseGrabber();
17
18 # create a CPP object via constructor
19 yourCpp = YourCPPObject(2,11.5)
20
21 # call the wrapped method on CPP object
22 print yourCpp.doSomething(3);
23
24 # show slots available on yourCpp
25 print dir(yourCpp)
26
27 # destructor will be called:
28 yourCpp = None
@@ -0,0 +1,68
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PyGuiExample.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2007-04
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include "gui/PythonQtScriptingConsole.h"
44 #include "PyExampleDecorators.h"
45
46 #include <QApplication>
47
48 int main( int argc, char **argv )
49 {
50 QApplication qapp(argc, argv);
51
52 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
53
54 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
55 PythonQtScriptingConsole console(NULL, mainContext);
56
57 PythonQt::self()->addDecorators(new PyExampleDecorators());
58 PythonQt::self()->registerClass(&QPushButton::staticMetaObject);
59 PythonQt::self()->registerCPPClassNames(QStringList() << "YourCPPObject");
60
61 mainContext.evalFile(":example.py");
62
63 console.appendCommandPrompt();
64 console.show();
65
66 return qapp.exec();
67 }
68
@@ -0,0 +1,26
1 from PythonQt import *
2
3 # set the title of the group box, accessing the title property
4 box.title = 'PythonQt Example'
5
6 # set the html content of the QTextBrowser
7 box.browser.html = 'Hello <b>Qt</b>!'
8
9 # set the title of the button
10 box.button1.text = 'Append Text'
11
12 # set the text of the line edit
13 box.edit.text = '42'
14
15 # define our own python method that appends the text from the line edit
16 # to the text browser
17 def appendLine():
18 box.browser.append(box.edit.text)
19
20 # connect the button's clicked signal to our python method
21 box.button1.connect('clicked()', appendLine)
22 # connect the lineedit's returnPressed signal to our python method
23 box.edit.connect('returnPressed()', appendLine)
24
25 # show the window
26 box.show()
@@ -0,0 +1,2
1 "%MEVIS_LIB%\make\win32\createDsp.bat" PyGettingStarted
2
@@ -0,0 +1,20
1 # --------- PyScriptingConsole profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6
7 TARGET = PyGettingStarted
8 TEMPLATE = app
9
10 DESTDIR = ../../lib
11
12 CONFIG += console
13
14 include ( ../../build/common.prf )
15 include ( ../../build/PythonQt.prf )
16
17 SOURCES += \
18 main.cpp
19
20 RESOURCES += PyGettingStarted.qrc
@@ -0,0 +1,5
1 <!DOCTYPE RCC><RCC version="1.0">
2 <qresource>
3 <file>GettingStarted.py</file>
4 </qresource>
5 </RCC>
@@ -0,0 +1,90
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtTests.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include <QApplication>
44 #include <QTextBrowser>
45 #include <QLayout>
46 #include <QGroupBox>
47 #include <QPushButton>
48 #include <QLineEdit>
49
50 int main( int argc, char **argv )
51 {
52 QApplication qapp(argc, argv);
53
54 // init PythonQt and Python
55 PythonQt::init();
56
57 // get the __main__ python module
58 PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
59
60 // evaluate a simple python script and receive the result a qvariant:
61 QVariant result = mainModule.evalScript("19*2+4", Py_eval_input);
62
63 // create a small Qt GUI
64 QVBoxLayout* vbox = new QVBoxLayout;
65 QGroupBox* box = new QGroupBox;
66 QTextBrowser* browser = new QTextBrowser(box);
67 QLineEdit* edit = new QLineEdit(box);
68 QPushButton* button = new QPushButton(box);
69 button->setObjectName("button1");
70 edit->setObjectName("edit");
71 browser->setObjectName("browser");
72 vbox->addWidget(browser);
73 vbox->addWidget(edit);
74 vbox->addWidget(button);
75 box->setLayout(vbox);
76
77 // make the groupbox to the python under the name "box"
78 mainModule.addObject("box", box);
79
80 // evaluate the python script which is defined in the resources
81 mainModule.evalFile(":GettingStarted.py");
82
83 // define a python method that appends the passed text to the browser
84 mainModule.evalScript("def appendText(text):\n box.browser.append(text)");
85 // shows how to call the method with a text that will be append to the browser
86 mainModule.call("appendText", QVariantList() << "The ultimate answer is ");
87
88 return qapp.exec();
89 }
90
@@ -0,0 +1,2
1 "%MEVIS_LIB%\make\win32\createDsp.bat" PyGuiExample
2
@@ -0,0 +1,19
1 # --------- PyGuiExample profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6
7 TARGET = PyGuiExample
8 TEMPLATE = app
9
10 DESTDIR = ../../lib
11
12 include ( ../../build/common.prf )
13 include ( ../../build/PythonQt.prf )
14 include ( ../../build/PythonQtGui.prf )
15
16 SOURCES += \
17 main.cpp
18
19 RESOURCES += PyGuiExample.qrc
@@ -0,0 +1,5
1 <!DOCTYPE RCC><RCC version="1.0">
2 <qresource>
3 <file>example.py</file>
4 </qresource>
5 </RCC>
@@ -0,0 +1,15
1 from PythonQt import *
2
3 group = QGroupBox()
4 box = QVBoxLayout(group)
5 push1 = QPushButton(group)
6 box.addWidget(push1)
7 push2 = QPushButton(group)
8 box.addWidget(push2)
9 check = QCheckBox(group)
10 check.text = 'check me'
11 group.title = 'my title'
12 push1.text = 'press me'
13 push2.text = 'press me2'
14 box.addWidget(check)
15 group.show()
@@ -0,0 +1,68
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PyGuiExample.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2007-04
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include "PythonQtGui.h"
44 #include "gui/PythonQtScriptingConsole.h"
45
46 #include <QApplication>
47 #include <QWidget>
48 #include <QMainWindow>
49 #include <QPushButton>
50 #include <QLayout>
51
52
53 int main( int argc, char **argv )
54 {
55 QApplication qapp(argc, argv);
56
57 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
58 PythonQtGui::init();
59
60 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
61 PythonQtScriptingConsole console(NULL, mainContext);
62
63 mainContext.evalFile(":example.py");
64
65 console.show();
66 return qapp.exec();
67 }
68
@@ -0,0 +1,87
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PyExampleObject.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-10
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PyExampleObject.h"
43 #include <QMessageBox>
44 #include <QDir>
45
46 PyExampleObject::PyExampleObject():QObject(NULL)
47 {
48 }
49
50 PyObject* PyExampleObject::getMainModule() {
51 return PythonQt::self()->getMainModule();
52 }
53
54 void PyExampleObject::showInformation(const QString& str)
55 {
56 QMessageBox::information ( NULL, "Test", str);
57 }
58
59 QStringList PyExampleObject::readDirectory(const QString& dir)
60 {
61 QDir d(dir);
62 return d.entryList();
63 }
64
65 QMainWindow* PyExampleObject::createWindow()
66 {
67 QMainWindow* m = new QMainWindow();
68 QPushButton* b = new QPushButton(m);
69 b->setObjectName("button1");
70
71 m->show();
72 return m;
73 }
74
75 QObject* PyExampleObject::findChild(QObject* o, const QString& name)
76 {
77 return qFindChild<QObject*>(o, name);
78 }
79
80 QVariantMap PyExampleObject::testMap()
81 {
82 QVariantMap m;
83 m.insert("a", QStringList() << "test1" << "test2");
84 m.insert("b", 12);
85 m.insert("c", 12.);
86 return m;
87 }
@@ -0,0 +1,79
1 #ifndef _PYEXAMPLEOBJECT_H
2 #define _PYEXAMPLEOBJECT_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PyExampleObject.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-10
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQt.h"
46
47 #include <QObject>
48 #include <QStringList>
49 #include <QMainWindow>
50 #include <QPushButton>
51 #include <QVariant>
52 #include <QLayout>
53
54
55 class PyExampleObject : public QObject {
56
57 Q_OBJECT
58
59 public:
60 PyExampleObject();
61
62 public slots:
63
64 //! example for passing a PyObject directly from Qt to Python (without extra mashalling)
65 PyObject* getMainModule();
66
67 void showInformation(const QString& str);
68
69 QStringList readDirectory(const QString& dir);
70
71 QMainWindow* createWindow();
72
73 QObject* findChild(QObject* o, const QString& name);
74
75 QVariantMap testMap();
76
77 };
78
79 #endif
@@ -0,0 +1,2
1 "%MEVIS_LIB%\make\win32\createDsp.bat" PyScriptingConsole
2
@@ -0,0 +1,23
1 # --------- PyScriptingConsole profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6
7 TARGET = PyScriptingConsole
8 TEMPLATE = app
9
10 DESTDIR = ../../lib
11
12 include ( ../../build/common.prf )
13 include ( ../../build/PythonQt.prf )
14 include ( ../../build/PythonQtGui.prf )
15
16 HEADERS += \
17 PyExampleObject.h
18
19 SOURCES += \
20 PyExampleObject.cpp \
21 main.cpp
22
23 RESOURCES += PyScriptingConsole.qrc
@@ -0,0 +1,5
1 <!DOCTYPE RCC><RCC version="1.0">
2 <qresource>
3 <file>example.py</file>
4 </qresource>
5 </RCC>
@@ -0,0 +1,15
1 from PythonQt import *
2
3 group = QGroupBox()
4 box = QVBoxLayout(group)
5 push1 = QPushButton(group)
6 box.addWidget(push1)
7 push2 = QPushButton(group)
8 box.addWidget(push2)
9 check = QCheckBox(group)
10 check.text = 'check me'
11 group.title = 'my title'
12 push1.text = 'press me'
13 push2.text = 'press me2'
14 box.addWidget(check)
15 group.show()
@@ -0,0 +1,73
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtTests.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include "PythonQtGui.h"
44 #include "PyExampleObject.h"
45 #include "gui/PythonQtScriptingConsole.h"
46
47 #include <QApplication>
48 #include <QWidget>
49 #include <QMainWindow>
50 #include <QPushButton>
51 #include <QLayout>
52
53
54 int main( int argc, char **argv )
55 {
56 QApplication qapp(argc, argv);
57
58 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
59 PythonQtGui::init();
60
61 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
62 PythonQtScriptingConsole console(NULL, mainContext);
63
64 // add a QObject to the namespace of the main python context
65 PyExampleObject example;
66 mainContext.addObject("example", &example);
67
68 mainContext.evalFile(":example.py");
69
70 console.show();
71 return qapp.exec();
72 }
73
@@ -0,0 +1,7
1 TEMPLATE = subdirs
2 SUBDIRS = PyGettingStarted \
3 PyCPPWrapperExample \
4 PyCustomMetaTypeExample \
5 PyGuiExample \
6 PyDecoratorsExample \
7 PyScriptingConsole
@@ -0,0 +1,2
1 "%MEVIS_LIB%\make\win32\createDsp.bat" PythonQtGui
2
@@ -0,0 +1,216
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtGui.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2007-04
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtGui.h"
43 #include "PythonQt.h"
44 #include <QUiLoader>
45 #include <QLayout>
46 #include <QAction>
47 #include <QActionGroup>
48
49 #include <QtGui/QtGui>
50
51 void PythonQtGui::init()
52 {
53 PythonQt::self()->addConstructorHandler(new PythonQtUiLoaderConstructorHandler);
54 PythonQt::self()->addInstanceDecorators(new PythonQtUiDecorators());
55 PythonQt::self()->addClassDecorators(new PythonQtUiConstructors());
56
57 PythonQt::self()->registerClass(&QAction::staticMetaObject);
58 PythonQt::self()->registerClass(&QActionGroup::staticMetaObject);
59
60 PythonQt::self()->registerClass(&QCheckBox::staticMetaObject);
61 PythonQt::self()->registerClass(&QComboBox::staticMetaObject);
62 PythonQt::self()->registerClass(&QDateTimeEdit::staticMetaObject);
63 PythonQt::self()->registerClass(&QDateEdit::staticMetaObject);
64 PythonQt::self()->registerClass(&QTimeEdit::staticMetaObject);
65 PythonQt::self()->registerClass(&QDial::staticMetaObject);
66 PythonQt::self()->registerClass(&QDialog::staticMetaObject);
67 PythonQt::self()->registerClass(&QDockWidget::staticMetaObject);
68 PythonQt::self()->registerClass(&QFrame::staticMetaObject);
69 PythonQt::self()->registerClass(&QGroupBox::staticMetaObject);
70 PythonQt::self()->registerClass(&QLCDNumber::staticMetaObject);
71 PythonQt::self()->registerClass(&QLabel::staticMetaObject);
72 PythonQt::self()->registerClass(&QLineEdit::staticMetaObject);
73 PythonQt::self()->registerClass(&QListView::staticMetaObject);
74 PythonQt::self()->registerClass(&QListWidget::staticMetaObject);
75 PythonQt::self()->registerClass(&QMainWindow::staticMetaObject);
76 PythonQt::self()->registerClass(&QMenu::staticMetaObject);
77 PythonQt::self()->registerClass(&QMenuBar::staticMetaObject);
78 PythonQt::self()->registerClass(&QProgressBar::staticMetaObject);
79 PythonQt::self()->registerClass(&QPushButton::staticMetaObject);
80 PythonQt::self()->registerClass(&QRadioButton::staticMetaObject);
81 PythonQt::self()->registerClass(&QScrollBar::staticMetaObject);
82 PythonQt::self()->registerClass(&QSlider::staticMetaObject);
83 PythonQt::self()->registerClass(&QSpinBox::staticMetaObject);
84 PythonQt::self()->registerClass(&QDoubleSpinBox::staticMetaObject);
85 PythonQt::self()->registerClass(&QTabWidget::staticMetaObject);
86 PythonQt::self()->registerClass(&QTableView::staticMetaObject);
87 PythonQt::self()->registerClass(&QTableWidget::staticMetaObject);
88 PythonQt::self()->registerClass(&QTextBrowser::staticMetaObject);
89 PythonQt::self()->registerClass(&QTextEdit::staticMetaObject);
90 PythonQt::self()->registerClass(&QToolBar::staticMetaObject);
91 PythonQt::self()->registerClass(&QToolBox::staticMetaObject);
92 PythonQt::self()->registerClass(&QToolButton::staticMetaObject);
93 PythonQt::self()->registerClass(&QTreeView::staticMetaObject);
94 PythonQt::self()->registerClass(&QTreeWidget::staticMetaObject);
95 PythonQt::self()->registerClass(&QWidget::staticMetaObject);
96 PythonQt::self()->registerClass(&QWorkspace::staticMetaObject);
97 PythonQt::self()->registerClass(&QSplitter::staticMetaObject);
98 PythonQt::self()->registerClass(&QStackedWidget::staticMetaObject);
99 PythonQt::self()->registerClass(&QStatusBar::staticMetaObject);
100 PythonQt::self()->registerClass(&QDialogButtonBox::staticMetaObject);
101 PythonQt::self()->registerClass(&QFontComboBox::staticMetaObject);
102 PythonQt::self()->registerClass(&QCalendarWidget::staticMetaObject);
103 PythonQt::self()->registerClass(&QHBoxLayout::staticMetaObject);
104 PythonQt::self()->registerClass(&QStackedLayout::staticMetaObject);
105 PythonQt::self()->registerClass(&QVBoxLayout::staticMetaObject);
106 }
107
108 bool PythonQt_inherits(const QMetaObject* self, const QMetaObject* parent) {
109 const QMetaObject* m = self;
110 while (m) {
111 if (m==parent) {
112 return true;
113 };
114 m = m->superClass();
115 }
116 return false;
117 }
118
119 QObject* PythonQtUiLoaderConstructorHandler::create(const QMetaObject* meta, PyObject *args, PyObject *kw, QString& error)
120 {
121 if (!PythonQt_inherits(meta, &QLayout::staticMetaObject) &&
122 !PythonQt_inherits(meta, &QWidget::staticMetaObject) &&
123 !PythonQt_inherits(meta, &QAction::staticMetaObject) &&
124 !PythonQt_inherits(meta, &QActionGroup::staticMetaObject)) return NULL;
125
126 static QUiLoader* loader = NULL;
127 if (!loader) {
128 loader = new QUiLoader();
129 }
130 int argc = PyTuple_Size(args);
131 QObject* parent = NULL;
132 if (argc == 1) {
133 PyObject* arg1 = PyTuple_GET_ITEM(args, 0);
134 if (arg1 && arg1->ob_type == &PythonQtWrapper_Type) {
135 parent = ((PythonQtWrapper*)arg1)->_obj;
136 } else {
137 error = QString("constructor ") + meta->className() + " requires a QObject as parent";
138 return NULL;
139 }
140 } else if (argc!=0) {
141 error = QString("constructor ") + meta->className() + " called with too many arguments";
142 return NULL;
143 }
144
145 if (PythonQt_inherits(meta, &QLayout::staticMetaObject)) {
146 return loader->createLayout(meta->className(), parent);
147 }
148 if (PythonQt_inherits(meta, &QWidget::staticMetaObject)) {
149 if (!parent || parent->isWidgetType()) {
150 return loader->createWidget(meta->className(), (QWidget*)parent);
151 } else {
152 error = QString("constructor ") + meta->className() + " requires a QWidget as parent";
153 return NULL;
154 }
155 }
156 if (PythonQt_inherits(meta, &QAction::staticMetaObject)) {
157 return loader->createAction(parent);
158 }
159 if (PythonQt_inherits(meta, &QActionGroup::staticMetaObject)) {
160 return loader->createActionGroup(parent);
161 }
162 return NULL;
163 }
164
165
166 void PythonQtUiDecorators::addWidget(QLayout* l, QWidget* w)
167 {
168 l->addWidget(w);
169 }
170
171 QLayout* PythonQtUiDecorators::layout(QWidget* w)
172 {
173 return w->layout();
174 }
175
176 void PythonQtUiDecorators::setLayout(QWidget* w, QLayout* l)
177 {
178 w->setLayout(l);
179 }
180
181 void PythonQtUiDecorators::setCentralWidget(QMainWindow* main, QWidget* w)
182 {
183 main->setCentralWidget(w);
184 }
185
186 void PythonQtUiDecorators::setMenuBar(QMainWindow* main, QMenuBar* w)
187 {
188 main->setMenuBar(w);
189 }
190
191 void PythonQtUiDecorators::addAction(QMenuBar* bar, QAction* action)
192 {
193 bar->addAction(action);
194 }
195
196 QAction* PythonQtUiDecorators::addMenu(QMenuBar* bar, QMenu* menu)
197 {
198 return bar->addMenu(menu);
199 }
200
201 QMenu* PythonQtUiDecorators::addMenu(QMenuBar* bar, const QString& name)
202 {
203 return bar->addMenu(name);
204 }
205
206 QAction* PythonQtUiDecorators::addAction(QMenu* m, const QString& name)
207 {
208 return m->addAction(name);
209 }
210
211 // --------------------------------------------------------------------
212
213 QWidget* PythonQtUiConstructors::new_QWidget(QWidget* parent)
214 {
215 return new QWidget(parent);
216 }
@@ -0,0 +1,100
1 #ifndef _PYTHONQTGUI_H
2 #define _PYTHONQTGUI_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtGUI.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2007-04
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQtGuiSystem.h"
46 #include "PythonQtMetaObjectWrapper.h"
47
48 #include <QObject>
49
50 class QWidget;
51 class QLayout;
52 class QMainWindow;
53 class QMenuBar;
54 class QWidget;
55 class QAction;
56 class QMenu;
57
58 class PYTHONQTGUI_EXPORT PythonQtGui
59 {
60 public:
61 //! init the Qt GUI extensions
62 static void init();
63 };
64
65 class PythonQtUiLoaderConstructorHandler : public PythonQtConstructorHandler {
66 public:
67 virtual QObject* create(const QMetaObject* meta, PyObject *args, PyObject *kw, QString& error);
68 };
69
70 class PythonQtUiConstructors : public QObject
71 {
72 Q_OBJECT
73
74 public slots:
75 QWidget* new_QWidget(QWidget* parent=NULL);
76
77 };
78
79 class PythonQtUiDecorators : public QObject
80 {
81 Q_OBJECT
82
83 public slots:
84 void addWidget(QLayout* l, QWidget* w);
85
86 QLayout* layout(QWidget* w);
87 void setLayout(QWidget* w, QLayout* l);
88
89 void setCentralWidget(QMainWindow* main, QWidget* w);
90 void setMenuBar(QMainWindow* main, QMenuBar* w);
91
92 void addAction(QMenuBar* bar, QAction* action);
93 QAction* addMenu(QMenuBar* bar, QMenu* menu);
94 QMenu* addMenu(QMenuBar* bar, const QString& name);
95
96 QAction* addAction(QMenu* bar, const QString& name);
97
98 };
99
100 #endif
@@ -0,0 +1,26
1 # --------- PythonQtGui profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6
7 TARGET = PythonQtGui
8 TEMPLATE = lib
9
10 DESTDIR = ../../lib
11 DLLDESTDIR = ../../lib
12
13 include ( ../../build/common.prf )
14 include ( ../../build/PythonQt.prf )
15
16 CONFIG += dll qt uitools
17
18 DEFINES += PYTHONQTGUI_EXPORTS
19
20 HEADERS += \
21 PythonQtGui.h \
22 PythonQtGuiSystem.h \
23
24 SOURCES += \
25 PythonQtGui.cpp
26
@@ -0,0 +1,56
1 #ifndef _PYTHONQTGUISYSTEM_
2 #define _PYTHONQTGUISYSTEM_
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtGuiSystem.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #ifdef WIN32
46 #ifdef PYTHONQTGUI_EXPORTS
47 #define PYTHONQTGUI_EXPORT __declspec(dllexport)
48 #else
49 #define PYTHONQTGUI_EXPORT __declspec(dllimport)
50 #endif
51 #else
52 #define PYTHONQTGUI_EXPORT
53 #endif
54
55 #endif
56
@@ -0,0 +1,2
1 TEMPLATE = subdirs
2 SUBDIRS = PythonQtGui
This diff has been collapsed as it changes many lines, (946 lines changed) Show them Hide them
@@ -0,0 +1,946
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQt.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include "PythonQtImporter.h"
44 #include "PythonQtClassInfo.h"
45 #include "PythonQtMethodInfo.h"
46 #include "PythonQtSignalReceiver.h"
47 #include "PythonQtConversion.h"
48 #include "PythonQtStdOut.h"
49 #include "PythonQtCppWrapperFactory.h"
50 #include "PythonQtVariants.h"
51 #include "PythonQtStdDecorators.h"
52 #include <pydebug.h>
53
54 PythonQt* PythonQt::_self = NULL;
55
56
57 void PythonQt::init(int flags)
58 {
59 if (!_self) {
60 _self = new PythonQt(flags);
61 }
62
63 PythonQtMethodInfo::addParameterTypeAlias("QObjectList", "QList<QObject*>");
64 qRegisterMetaType<QList<QObject*> >("QList<void*>");
65
66 PythonQt::self()->addDecorators(new PythonQtStdDecorators());
67
68 PythonQt::priv()->addVariantWrapper("QBitArray", new PythonQtQBitArrayWrapper);
69 PythonQt::priv()->addVariantWrapper("QDate", new PythonQtQDateWrapper);
70 PythonQt::priv()->addVariantWrapper("QTime", new PythonQtQTimeWrapper);
71 PythonQt::priv()->addVariantWrapper("QDateTime", new PythonQtQDateTimeWrapper);
72 PythonQt::priv()->addVariantWrapper("QUrl", new PythonQtQUrlWrapper);
73 PythonQt::priv()->addVariantWrapper("QLocale", new PythonQtQLocaleWrapper);
74 PythonQt::priv()->addVariantWrapper("QRect", new PythonQtQRectWrapper);
75 PythonQt::priv()->addVariantWrapper("QRectF", new PythonQtQRectFWrapper);
76 PythonQt::priv()->addVariantWrapper("QSize", new PythonQtQSizeWrapper);
77 PythonQt::priv()->addVariantWrapper("QSizeF", new PythonQtQSizeFWrapper);
78 PythonQt::priv()->addVariantWrapper("QLine", new PythonQtQLineWrapper);
79 PythonQt::priv()->addVariantWrapper("QLineF", new PythonQtQLineFWrapper);
80 PythonQt::priv()->addVariantWrapper("QPoint", new PythonQtQPointWrapper);
81 PythonQt::priv()->addVariantWrapper("QPointF", new PythonQtQPointFWrapper);
82 PythonQt::priv()->addVariantWrapper("QRegExp", new PythonQtQRegExpWrapper);
83 PythonQt::priv()->addVariantWrapper("QFont", new PythonQtQFontWrapper);
84 PythonQt::priv()->addVariantWrapper("QPixmap", new PythonQtQPixmapWrapper);
85 PythonQt::priv()->addVariantWrapper("QBrush", new PythonQtQBrushWrapper);
86 PythonQt::priv()->addVariantWrapper("QColor", new PythonQtQColorWrapper);
87 PythonQt::priv()->addVariantWrapper("QPalette", new PythonQtQPaletteWrapper);
88 PythonQt::priv()->addVariantWrapper("QIcon", new PythonQtQIconWrapper);
89 PythonQt::priv()->addVariantWrapper("QImage", new PythonQtQImageWrapper);
90 PythonQt::priv()->addVariantWrapper("QPolygon", new PythonQtQPolygonWrapper);
91 PythonQt::priv()->addVariantWrapper("QRegion", new PythonQtQRegionWrapper);
92 PythonQt::priv()->addVariantWrapper("QBitmap", new PythonQtQBitmapWrapper);
93 PythonQt::priv()->addVariantWrapper("QCursor", new PythonQtQCursorWrapper);
94 PythonQt::priv()->addVariantWrapper("QSizePolicy", new PythonQtQSizePolicyWrapper);
95 PythonQt::priv()->addVariantWrapper("QKeySequence", new PythonQtQKeySequenceWrapper);
96 PythonQt::priv()->addVariantWrapper("QPen", new PythonQtQPenWrapper);
97 PythonQt::priv()->addVariantWrapper("QTextLength", new PythonQtQTextLengthWrapper);
98 PythonQt::priv()->addVariantWrapper("QTextFormat", new PythonQtQTextFormatWrapper);
99 PythonQt::priv()->addVariantWrapper("QMatrix", new PythonQtQMatrixWrapper);
100
101 }
102
103 void PythonQt::cleanup()
104 {
105 if (_self) {
106 delete _self;
107 _self = NULL;
108 }
109 }
110
111 PythonQt::PythonQt(int flags)
112 {
113 _p = new PythonQtPrivate;
114 _p->_initFlags = flags;
115
116 _p->_PythonQtObjectPtr_metaId = qRegisterMetaType<PythonQtObjectPtr>("PythonQtObjectPtr");
117
118 Py_SetProgramName("PythonQt");
119 if (flags & IgnoreSiteModule) {
120 // this prevents the automatic importing of Python site files
121 Py_NoSiteFlag = 1;
122 }
123 Py_Initialize();
124
125 // add our own python object types for qt object slots
126 if (PyType_Ready(&PythonQtSlotFunction_Type) < 0) {
127 std::cerr << "could not initialize PythonQtSlotFunction_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
128 }
129 Py_INCREF(&PythonQtSlotFunction_Type);
130
131 // add our own python object types for qt objects
132 if (PyType_Ready(&PythonQtWrapper_Type) < 0) {
133 std::cerr << "could not initialize PythonQtWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
134 }
135 Py_INCREF(&PythonQtWrapper_Type);
136
137 // add our own python object types for qt objects
138 if (PyType_Ready(&PythonQtVariantWrapper_Type) < 0) {
139 std::cerr << "could not initialize PythonQtVariantWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
140 }
141 Py_INCREF(&PythonQtVariantWrapper_Type);
142
143 // add our own python object types for qt objects
144 if (PyType_Ready(&PythonQtMetaObjectWrapper_Type) < 0) {
145 std::cerr << "could not initialize PythonQtMetaObjectWrapper_Type" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
146 }
147 Py_INCREF(&PythonQtMetaObjectWrapper_Type);
148
149 // add our own python object types for redirection of stdout
150 if (PyType_Ready(&PythonQtStdOutRedirectType) < 0) {
151 std::cerr << "could not initialize PythonQtStdOutRedirectType" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
152 }
153 Py_INCREF(&PythonQtStdOutRedirectType);
154
155 initPythonQtModule(flags & RedirectStdOut);
156
157 }
158
159 PythonQt::~PythonQt() {
160 delete _p;
161 _p = NULL;
162 }
163
164 PythonQtPrivate::~PythonQtPrivate() {
165 {
166 QHashIterator<QByteArray, PythonQtClassInfo *> i(_knownQtClasses);
167 while (i.hasNext()) {
168 delete i.next().value();
169 }
170 }
171 {
172 QHashIterator<QByteArray, PythonQtClassInfo *> i(_knownQtWrapperClasses);
173 while (i.hasNext()) {
174 delete i.next().value();
175 }
176 }
177 {
178 QHashIterator<int , QPair<PythonQtClassInfo*, QObject*> > i(_knownVariantWrappers);
179 while (i.hasNext()) {
180 delete i.next().value().first;
181 }
182 }
183 {
184 QHashIterator<QByteArray, PythonQtSlotInfo *> i(_constructorSlots);
185 while (i.hasNext()) {
186 delete i.next().value();
187 }
188 }
189 {
190 QHashIterator<QByteArray, PythonQtSlotInfo *> i(_destructorSlots);
191 while (i.hasNext()) {
192 delete i.next().value();
193 }
194 }
195 PythonQtConv::global_valueStorage.clear();
196 PythonQtConv::global_ptrStorage.clear();
197 PythonQtConv::global_variantStorage.clear();
198
199 PythonQtMethodInfo::cleanupCachedMethodInfos();
200
201 delete _qtNamespace;
202 }
203
204 PythonQtImportFileInterface* PythonQt::importInterface()
205 {
206 return _self->_p->_importInterface;
207 }
208
209 void PythonQt::registerClass(const QMetaObject* metaobject)
210 {
211 _p->registerClass(metaobject);
212 }
213
214 void PythonQtPrivate::registerClass(const QMetaObject* metaobject)
215 {
216 // we register all classes in the hierarchy
217 const QMetaObject* m = metaobject;
218 while (m) {
219 PythonQtClassInfo* info = _knownQtClasses.value(m->className());
220 if (!info) {
221 info = new PythonQtClassInfo(m);
222 _knownQtClasses.insert(m->className(), info);
223 PyModule_AddObject(_pythonQtModule, m->className(), (PyObject*)createNewPythonQtMetaObjectWrapper(info));
224 }
225 m = m->superClass();
226 }
227 }
228
229 bool PythonQtPrivate::isEnumType(const QMetaObject* meta, const QByteArray& name) {
230 int i = meta?meta->indexOfEnumerator(name.constData()):-1;
231 if (i!=-1) {
232 return true;
233 } else {
234 // look for scope
235 int scopePos = name.indexOf("::");
236 if (scopePos != -1) {
237 // slit into scope and enum name
238 QByteArray enumScope = name.mid(0,scopePos);
239 QByteArray enumName = name.mid(scopePos+2);
240 if (enumScope == "Qt") {
241 // special qt namespace case
242 return isEnumType(&staticQtMetaObject, enumName);
243 } else {
244 // look for known classes as scope
245 // TODO: Q_GADGETS are not yet handled
246 PythonQtClassInfo* info = _knownQtClasses.value(enumScope);
247 if (info) {
248 return isEnumType(info->metaObject(), enumName);
249 }
250 }
251 }
252 }
253 return false;
254 }
255
256 PyObject* PythonQtPrivate::wrapQObject(QObject* obj)
257 {
258 if (!obj) {
259 Py_INCREF(Py_None);
260 return Py_None;
261 }
262 PythonQtWrapper* wrap = _wrappedObjects.value(obj);
263 if (!wrap) {
264 // smuggling it in...
265 PythonQtClassInfo* classInfo = _knownQtClasses.value(obj->metaObject()->className());
266 if (!classInfo) {
267 registerClass(obj->metaObject());
268 classInfo = _knownQtClasses.value(obj->metaObject()->className());
269 }
270 wrap = createNewPythonQtWrapper(obj, classInfo);
271 // insert destroyed handler
272 connect(obj, SIGNAL(destroyed(QObject*)), this, SLOT(wrappedObjectDestroyed(QObject*)));
273 // mlabDebugConst("MLABPython","new qobject wrapper added " << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1());
274 } else {
275 Py_INCREF(wrap);
276 // mlabDebugConst("MLABPython","qobject wrapper reused " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1());
277 }
278 return (PyObject*)wrap;
279 }
280
281 PyObject* PythonQtPrivate::wrapPtr(void* ptr, const QByteArray& name)
282 {
283 if (!ptr) {
284 Py_INCREF(Py_None);
285 return Py_None;
286 }
287 PythonQtWrapper* wrap = _wrappedObjects.value(ptr);
288 if (!wrap) {
289 PythonQtClassInfo* info = _knownQtClasses.value(name);
290 if (!info) {
291 // we do not know the metaobject yet, but we might know it by it's name:
292 if (_knownQObjectClassNames.find(name)!=_knownQObjectClassNames.end()) {
293 // yes, we know it, so we can convert to QObject
294 QObject* qptr = (QObject*)ptr;
295 registerClass(qptr->metaObject());
296 info = _knownQtClasses.value(qptr->metaObject()->className());
297 }
298 }
299 if (info) {
300 QObject* qptr = (QObject*)ptr;
301 // if the object is a derived object, we want to switch the class info to the one of the derived class:
302 if (name!=(qptr->metaObject()->className())) {
303 registerClass(qptr->metaObject());
304 info = _knownQtClasses.value(qptr->metaObject()->className());
305 }
306 wrap = createNewPythonQtWrapper(qptr, info);
307 // insert destroyed handler
308 connect(qptr, SIGNAL(destroyed(QObject*)), this, SLOT(wrappedObjectDestroyed(QObject*)));
309 // mlabDebugConst("MLABPython","new qobject wrapper added " << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1());
310 } else {
311 // maybe it is a PyObject, which we can return directly
312 if (name == "PyObject") {
313 PyObject* p = (PyObject*)ptr;
314 Py_INCREF(p);
315 return p;
316 }
317 // not a known QObject, so try our wrapper factory:
318 QObject* wrapper = NULL;
319 for (int i=0; i<_cppWrapperFactories.size(); i++) {
320 wrapper = _cppWrapperFactories.at(i)->create(name, ptr);
321 if (wrapper) {
322 break;
323 }
324 }
325 PythonQtClassInfo* info = _knownQtWrapperClasses.value(name);
326 if (!info) {
327 info = new PythonQtClassInfo(wrapper?wrapper->metaObject():&QObject::staticQtMetaObject, name);
328 _knownQtWrapperClasses.insert(name, info);
329 PyModule_AddObject(_pythonQtModule, name, (PyObject*)createNewPythonQtMetaObjectWrapper(info));
330 } else {
331 if (wrapper && (info->metaObject() != wrapper->metaObject())) {
332 info->setMetaObject(wrapper->metaObject());
333 }
334 }
335 wrap = createNewPythonQtWrapper(wrapper, info, ptr);
336 // mlabDebugConst("MLABPython","new c++ wrapper added " << wrap->_wrappedPtr << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1());
337 }
338 } else {
339 Py_INCREF(wrap);
340 //mlabDebugConst("MLABPython","c++ wrapper reused " << wrap->_wrappedPtr << " " << wrap->_obj->className() << " " << wrap->_info->wrappedClassName().latin1());
341 }
342 return (PyObject*)wrap;
343 }
344
345 void PythonQt::registerCPPClassNames(const QStringList& names)
346 {
347 foreach ( QString n, names) {
348 QByteArray name = n.toLatin1();
349 PythonQtClassInfo* info = _p->_knownQtWrapperClasses.value(name);
350 if (!info) {
351 info = new PythonQtClassInfo(&QObject::staticMetaObject, name);
352 _p->_knownQtWrapperClasses.insert(name, info);
353 PyModule_AddObject(_p->_pythonQtModule, name.data(), (PyObject*)_p->createNewPythonQtMetaObjectWrapper(info));
354 }
355 }
356 }
357
358 PythonQtWrapper* PythonQtPrivate::createNewPythonQtWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr) {
359 PythonQtWrapper* result;
360 result = (PythonQtWrapper *)PythonQtWrapper_Type.tp_new(&PythonQtWrapper_Type,
361 NULL, NULL);
362
363 result->_obj = obj;
364 result->_info = info;
365 result->_wrappedPtr = wrappedPtr;
366 result->_ownedByPythonQt = false;
367
368 if (wrappedPtr) {
369 _wrappedObjects.insert(wrappedPtr, result);
370 } else {
371 _wrappedObjects.insert(obj, result);
372 }
373 return result;
374 }
375
376 PythonQtVariantWrapper* PythonQtPrivate::createNewPythonQtVariantWrapper(const QVariant& variant) {
377 PythonQtVariantWrapper* result;
378 result = (PythonQtVariantWrapper *)PythonQtVariantWrapper_Type.tp_new(&PythonQtVariantWrapper_Type,
379 NULL, NULL);
380
381 *result->_variant = variant;
382 QPair<PythonQtClassInfo*, QObject*> pair = _knownVariantWrappers.value(variant.userType());
383 result->_wrapper = pair.second;
384 result->_info = pair.first;
385 return result;
386 }
387
388 PythonQtMetaObjectWrapper* PythonQtPrivate::createNewPythonQtMetaObjectWrapper(PythonQtClassInfo* info) {
389 PythonQtMetaObjectWrapper* result;
390 result = (PythonQtMetaObjectWrapper *)PythonQtMetaObjectWrapper_Type.tp_new(&PythonQtMetaObjectWrapper_Type,
391 NULL, NULL);
392 result->_info = info;
393 return result;
394 }
395
396
397 PythonQtSignalReceiver* PythonQt::getSignalReceiver(QObject* obj)
398 {
399 PythonQtSignalReceiver* r = _p->_signalReceivers[obj];
400 if (!r) {
401 r = new PythonQtSignalReceiver(obj);
402 _p->_signalReceivers.insert(obj, r);
403 // insert destroyed handler
404 connect(obj, SIGNAL(destroyed(QObject*)), _p ,SLOT(destroyedSignalEmitter(QObject*)));
405 }
406 return r;
407 }
408
409 bool PythonQt::addSignalHandler(QObject* obj, const char* signal, PyObject* module, const QString& objectname)
410 {
411 bool flag = false;
412 PythonQtObjectPtr callable = lookupCallable(module, objectname);
413 if (callable) {
414 PythonQtSignalReceiver* r = getSignalReceiver(obj);
415 flag = r->addSignalHandler(signal, callable);
416 if (!flag) {
417 // signal not found
418 }
419 } else {
420 // callable not found
421 }
422 return flag;
423 }
424
425 bool PythonQt::addSignalHandler(QObject* obj, const char* signal, PyObject* receiver)
426 {
427 bool flag = false;
428 PythonQtSignalReceiver* r = getSignalReceiver(obj);
429 if (r) {
430 flag = r->addSignalHandler(signal, receiver);
431 }
432 return flag;
433 }
434
435 bool PythonQt::removeSignalHandler(QObject* obj, const char* signal, PyObject* module, const QString& objectname)
436 {
437 bool flag = false;
438 PythonQtObjectPtr callable = lookupCallable(module, objectname);
439 if (callable) {
440 PythonQtSignalReceiver* r = _p->_signalReceivers[obj];
441 if (r) {
442 flag = r->removeSignalHandler(signal, callable);
443 }
444 } else {
445 // callable not found
446 }
447 return flag;
448 }
449
450 bool PythonQt::removeSignalHandler(QObject* obj, const char* signal, PyObject* receiver)
451 {
452 bool flag = false;
453 PythonQtSignalReceiver* r = _p->_signalReceivers[obj];
454 if (r) {
455 flag = r->removeSignalHandler(signal, receiver);
456 }
457 return flag;
458 }
459
460 PythonQtObjectPtr PythonQt::lookupCallable(PyObject* module, const QString& name)
461 {
462 PythonQtObjectPtr p = lookupObject(module, name);
463 if (p) {
464 if (PyCallable_Check(p)) {
465 return p;
466 }
467 }
468 PyErr_Clear();
469 return NULL;
470 }
471
472 PythonQtObjectPtr PythonQt::lookupObject(PyObject* module, const QString& name)
473 {
474 QStringList l = name.split('.');
475 PythonQtObjectPtr p = module;
476 PythonQtObjectPtr prev;
477 QString s;
478 QByteArray b;
479 for (QStringList::ConstIterator i = l.begin(); i!=l.end() && p; ++i) {
480 prev = p;
481 b = (*i).toLatin1();
482 p.setNewRef(PyObject_GetAttrString(p, b.data()));
483 }
484 PyErr_Clear();
485 return p;
486 }
487
488 PythonQtObjectPtr PythonQt::getMainModule() {
489 //both borrowed
490 PythonQtObjectPtr dict = PyImport_GetModuleDict();
491 return PyDict_GetItemString(dict, "__main__");
492 }
493
494 QVariant PythonQt::evalCode(PyObject* module, PyObject* pycode) {
495 QVariant result;
496 if (pycode) {
497 PyObject* r = PyEval_EvalCode((PyCodeObject*)pycode, PyModule_GetDict((PyObject*)module) , PyModule_GetDict((PyObject*)module));
498 if (r) {
499 result = PythonQtConv::PyObjToQVariant(r);
500 Py_DECREF(r);
501 } else {
502 handleError();
503 }
504 } else {
505 handleError();
506 }
507 return result;
508 }
509
510 QVariant PythonQt::evalScript(PyObject* module, const QString& script, int start)
511 {
512 QVariant result;
513 PythonQtObjectPtr p;
514 p.setNewRef(PyRun_String(script.toLatin1().data(), start, PyModule_GetDict(module), PyModule_GetDict(module)));
515 if (p) {
516 result = PythonQtConv::PyObjToQVariant(p);
517 } else {
518 handleError();
519 }
520 return result;
521 }
522
523 void PythonQt::evalFile(PyObject* module, const QString& filename)
524 {
525 PythonQtObjectPtr code = parseFile(filename);
526 if (code) {
527 evalCode(module, code);
528 } else {
529 handleError();
530 }
531 }
532
533 PythonQtObjectPtr PythonQt::parseFile(const QString& filename)
534 {
535 PythonQtObjectPtr p;
536 p.setNewRef(PythonQtImport::getCodeFromPyc(filename));
537 if (!p) {
538 handleError();
539 }
540 return p;
541 }
542
543 void PythonQt::addObject(PyObject* module, const QString& name, QObject* object)
544 {
545 PyModule_AddObject(module, name.toLatin1().data(), _p->wrapQObject(object));
546 }
547
548 void PythonQt::addVariable(PyObject* module, const QString& name, const QVariant& v)
549 {
550 PyModule_AddObject(module, name.toLatin1().data(), PythonQtConv::QVariantToPyObject(v));
551 }
552
553 void PythonQt::removeVariable(PyObject* module, const QString& name)
554 {
555 PyObject_DelAttrString(module, name.toLatin1().data());
556 }
557
558 QVariant PythonQt::getVariable(PyObject* module, const QString& objectname)
559 {
560 QVariant result;
561 PythonQtObjectPtr obj = lookupObject(module, objectname);
562 if (obj) {
563 result = PythonQtConv::PyObjToQVariant(obj);
564 }
565 return result;
566 }
567
568 QStringList PythonQt::introspection(PyObject* module, const QString& objectname, PythonQt::ObjectType type)
569 {
570 QStringList results;
571
572 PythonQtObjectPtr object;
573 if (objectname.isEmpty()) {
574 object = module;
575 } else {
576 object = lookupObject(module, objectname);
577 if (!object && type == CallOverloads) {
578 PyObject* dict = lookupObject(module, "__builtins__");
579 if (dict) {
580 object = PyDict_GetItemString(dict, objectname.toLatin1().constData());
581 }
582 }
583 }
584
585 if (object) {
586 if (type == CallOverloads) {
587 if (PythonQtSlotFunction_Check(object)) {
588 PythonQtSlotFunctionObject* o = (PythonQtSlotFunctionObject*)object.object();
589 PythonQtSlotInfo* info = o->m_ml;
590
591 while (info) {
592 results << info->fullSignature(info->isInstanceDecorator() || o->m_self->ob_type == &PythonQtVariantWrapper_Type);
593 info = info->nextInfo();
594 }
595 } else if (object->ob_type == &PythonQtMetaObjectWrapper_Type) {
596 PythonQtMetaObjectWrapper* o = (PythonQtMetaObjectWrapper*)object.object();
597 PythonQtSlotInfo* info = o->_info->constructors();
598
599 while (info) {
600 results << info->fullSignature(false);
601 info = info->nextInfo();
602 }
603 } else {
604 //TODO: use pydoc!
605 PyObject* doc = PyObject_GetAttrString(object, "__doc__");
606 if (doc) {
607 results << PyString_AsString(doc);
608 Py_DECREF(doc);
609 }
610 }
611 } else {
612 PyObject* keys = PyObject_Dir(object);
613 if (keys) {
614 int count = PyList_Size(keys);
615 PyObject* key;
616 PyObject* value;
617 QString keystr;
618 for (int i = 0;i<count;i++) {
619 key = PyList_GetItem(keys,i);
620 value = PyObject_GetAttr(object, key);
621 if (!value) continue;
622 keystr = PyString_AsString(key);
623 static const QString underscoreStr("__tmp");
624 if (!keystr.startsWith(underscoreStr)) {
625 switch (type) {
626 case Anything:
627 results << keystr;
628 break;
629 case Class:
630 if (value->ob_type == &PyClass_Type) {
631 results << keystr;
632 }
633 break;
634 case Variable:
635 if (value->ob_type != &PyClass_Type
636 && value->ob_type != &PyCFunction_Type
637 && value->ob_type != &PyFunction_Type
638 && value->ob_type != &PyModule_Type
639 ) {
640 results << keystr;
641 }
642 break;
643 case Function:
644 if (value->ob_type == &PyFunction_Type ||
645 value->ob_type == &PyMethod_Type
646 ) {
647 results << keystr;
648 }
649 break;
650 case Module:
651 if (value->ob_type == &PyModule_Type) {
652 results << keystr;
653 }
654 break;
655 default:
656 std::cerr << "PythonQt: introspection: unknown case" << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
657 }
658 }
659 Py_DECREF(value);
660 }
661 Py_DECREF(keys);
662 }
663 }
664 }
665 return results;
666 }
667
668 QVariant PythonQt::call(PyObject* module, const QString& name, const QVariantList& args)
669 {
670 QVariant r;
671
672 PythonQtObjectPtr callable = lookupCallable(module, name);
673 if (callable) {
674 PythonQtObjectPtr pargs;
675 int count = args.size();
676 if (count>0) {
677 pargs.setNewRef(PyTuple_New(count));
678 }
679 bool err = false;
680 // transform QVariants to Python
681 for (int i = 0; i < count; i++) {
682 PyObject* arg = PythonQtConv::QVariantToPyObject(args.at(i));
683 if (arg) {
684 // steals reference, no unref
685 PyTuple_SetItem(pargs, i,arg);
686 } else {
687 err = true;
688 break;
689 }
690 }
691
692 if (!err) {
693 PyErr_Clear();
694 PythonQtObjectPtr result;
695 result.setNewRef(PyObject_CallObject(callable, pargs));
696 if (result) {
697 // ok
698 r = PythonQtConv::PyObjToQVariant(result);
699 } else {
700 PythonQt::self()->handleError();
701 }
702 }
703 }
704 return r;
705 }
706
707 void PythonQt::addInstanceDecorators(QObject* o)
708 {
709 _p->addDecorators(o, true, false);
710 }
711
712 void PythonQt::addClassDecorators(QObject* o)
713 {
714 _p->addDecorators(o, false, true);
715 }
716
717 void PythonQt::addDecorators(QObject* o)
718 {
719 _p->addDecorators(o, true, true);
720 }
721
722 void PythonQt::registerQObjectClassNames(const QStringList& names)
723 {
724 _p->registerQObjectClassNames(names);
725 }
726
727 void PythonQt::setImporter(PythonQtImportFileInterface* importInterface)
728 {
729 static bool first = true;
730 if (first) {
731 first = false;
732 _p->_importInterface = importInterface;
733 PythonQtImport::init();
734 }
735 }
736
737 void PythonQt::setImporterIgnorePaths(const QStringList& paths)
738 {
739 _p->_importIgnorePaths = paths;
740 }
741
742 const QStringList& PythonQt::getImporterIgnorePaths()
743 {
744 return _p->_importIgnorePaths;
745 }
746
747 void PythonQt::addWrapperFactory(PythonQtCppWrapperFactory* factory)
748 {
749 _p->_cppWrapperFactories.append(factory);
750 }
751
752 void PythonQt::addConstructorHandler(PythonQtConstructorHandler* factory)
753 {
754 _p->_constructorHandlers.append(factory);
755 }
756
757 const QList<PythonQtConstructorHandler*>& PythonQt::constructorHandlers()
758 {
759 return _p->_constructorHandlers;
760 };
761
762 //---------------------------------------------------------------------------------------------------
763 PythonQtPrivate::PythonQtPrivate()
764 {
765 _importInterface = NULL;
766 }
767
768 void PythonQtPrivate::addDecorators(QObject* o, bool instanceDeco, bool classDeco)
769 {
770 o->setParent(this);
771 int numMethods = o->metaObject()->methodCount();
772 for (int i = 0; i < numMethods; i++) {
773 QMetaMethod m = o->metaObject()->method(i);
774 if ((m.methodType() == QMetaMethod::Method ||
775 m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) {
776 const PythonQtMethodInfo* info = PythonQtMethodInfo::getCachedMethodInfo(m);
777 if (qstrncmp(m.signature(), "new_", 4)==0) {
778 if (!classDeco) continue;
779 // either it returns a * or a QVariant and the name starts with "new_"
780 bool isVariantReturn = info->parameters().at(0).typeId == PythonQtMethodInfo::Variant;
781 if ((info->parameters().at(0).isPointer || isVariantReturn)) {
782 QByteArray signature = m.signature();
783 QByteArray nameOfClass = signature.mid(4, signature.indexOf('(')-4);
784 PythonQtSlotInfo* prev = _constructorSlots.value(nameOfClass);
785 PythonQtSlotInfo* newSlot = new PythonQtSlotInfo(m, i, o, PythonQtSlotInfo::ClassDecorator);
786 if (prev) {
787 newSlot->setNextInfo(prev->nextInfo());
788 prev->setNextInfo(newSlot);
789 } else {
790 _constructorSlots.insert(nameOfClass, newSlot);
791 }
792 }
793 } else if (qstrncmp(m.signature(), "delete_", 7)==0) {
794 if (!classDeco) continue;
795 QByteArray signature = m.signature();
796 QByteArray nameOfClass = signature.mid(7, signature.indexOf('(')-7);
797 PythonQtSlotInfo* newSlot = new PythonQtSlotInfo(m, i, o, PythonQtSlotInfo::ClassDecorator);
798 _destructorSlots.insert(nameOfClass, newSlot);
799 } else if (qstrncmp(m.signature(), "static_", 7)==0) {
800 if (!classDeco) continue;
801 QByteArray signature = m.signature();
802 QByteArray nameOfClass = signature.mid(signature.indexOf('_')+1);
803 nameOfClass = nameOfClass.mid(0, nameOfClass.indexOf('_'));
804 PythonQtSlotInfo* slotCopy = new PythonQtSlotInfo(m, i, o, PythonQtSlotInfo::ClassDecorator);
805 _knownQtDecoratorSlots.insert(nameOfClass, slotCopy);
806 } else {
807 if (!instanceDeco) continue;
808 if (info->parameters().count()>1) {
809 PythonQtMethodInfo::ParameterInfo p = info->parameters().at(1);
810 if (p.isPointer) {
811 PythonQtSlotInfo* slotCopy = new PythonQtSlotInfo(m, i, o, PythonQtSlotInfo::InstanceDecorator);
812 _knownQtDecoratorSlots.insert(p.name, slotCopy);
813 }
814 }
815 }
816 }
817 }
818 }
819
820 void PythonQtPrivate::registerQObjectClassNames(const QStringList& names)
821 {
822 foreach(QString name, names) {
823 _knownQObjectClassNames.insert(name.toLatin1(), true);
824 }
825 }
826
827 QList<PythonQtSlotInfo*> PythonQtPrivate::getDecoratorSlots(const QByteArray& className)
828 {
829 return _knownQtDecoratorSlots.values(className);
830 }
831
832 void PythonQtPrivate::wrappedObjectDestroyed(QObject* obj)
833 {
834 // mlabDebugConst("MLABPython","PyWrapper QObject destroyed " << o << " " << o->name() << " " << o->className());
835 PythonQtWrapper* wrap = _wrappedObjects[obj];
836 if (wrap) {
837 _wrappedObjects.remove(obj);
838 // remove the pointer but keep the wrapper alive in python
839 wrap->_obj = NULL;
840 }
841 }
842
843 void PythonQtPrivate::destroyedSignalEmitter(QObject* obj)
844 {
845 _signalReceivers.take(obj);
846 }
847
848 bool PythonQt::handleError()
849 {
850 bool flag = false;
851 if (PyErr_Occurred()) {
852
853 // currently we just print the error and the stderr handler parses the errors
854 PyErr_Print();
855
856 /*
857 // EXTRA: the format of the ptype and ptraceback is not really documented, so I use PyErr_Print() above
858 PyObject *ptype;
859 PyObject *pvalue;
860 PyObject *ptraceback;
861 PyErr_Fetch( &ptype, &pvalue, &ptraceback);
862
863 Py_XDECREF(ptype);
864 Py_XDECREF(pvalue);
865 Py_XDECREF(ptraceback);
866 */
867 PyErr_Clear();
868 flag = true;
869 }
870 return flag;
871 }
872
873 void PythonQt::overwriteSysPath(const QStringList& paths)
874 {
875 PythonQtObjectPtr sys;
876 sys.setNewRef(PyImport_ImportModule("sys"));
877 PyModule_AddObject(sys, "path", PythonQtConv::QStringListToPyList(paths));
878 }
879
880 void PythonQt::setModuleImportPath(PyObject* module, const QStringList& paths)
881 {
882 PyModule_AddObject(module, "__path__", PythonQtConv::QStringListToPyList(paths));
883 }
884
885 void PythonQt::stdOutRedirectCB(const QString& str)
886 {
887 emit PythonQt::self()->pythonStdOut(str);
888 }
889
890 void PythonQt::stdErrRedirectCB(const QString& str)
891 {
892 emit PythonQt::self()->pythonStdErr(str);
893 }
894
895
896
897 static PyMethodDef PythonQtMethods[] = {
898 {NULL, NULL, 0, NULL}
899 };
900
901 void PythonQt::initPythonQtModule(bool redirectStdOut)
902 {
903 _p->_pythonQtModule.setNewRef(Py_InitModule("PythonQt", PythonQtMethods));
904 _p->_qtNamespace = new PythonQtClassInfo(&staticQtMetaObject);
905 PyModule_AddObject(_p->_pythonQtModule, "Qt", (PyObject*)_p->createNewPythonQtMetaObjectWrapper(_p->_qtNamespace));
906
907 if (redirectStdOut) {
908 PythonQtObjectPtr sys;
909 PythonQtObjectPtr out;
910 PythonQtObjectPtr err;
911 sys.setNewRef(PyImport_ImportModule("sys"));
912 // create a redirection object for stdout and stderr
913 out = PythonQtStdOutRedirectType.tp_new(&PythonQtStdOutRedirectType,NULL, NULL);
914 ((PythonQtStdOutRedirect*)out.object())->_cb = stdOutRedirectCB;
915 err = PythonQtStdOutRedirectType.tp_new(&PythonQtStdOutRedirectType,NULL, NULL);
916 ((PythonQtStdOutRedirect*)err.object())->_cb = stdErrRedirectCB;
917 // replace the built in file objects with our own objects
918 PyModule_AddObject(sys, "stdout", out);
919 PyModule_AddObject(sys, "stderr", err);
920 }
921 }
922
923 void PythonQt::addVariantWrapper(const char* typeName, QObject* wrapper)
924 {
925 _p->addVariantWrapper(typeName, wrapper);
926 }
927
928
929 void PythonQtPrivate::addVariantWrapper(const char* typeName, QObject* wrapper)
930 {
931 int type = QMetaType::type(typeName);
932 PythonQtClassInfo* info = new PythonQtClassInfo(wrapper->metaObject(), typeName);
933 _knownVariantWrappers.insert(type, qMakePair(info, wrapper));
934 addDecorators(wrapper, false, true);
935 PyModule_AddObject(_pythonQtModule, typeName, (PyObject*)createNewPythonQtMetaObjectWrapper(info));
936 }
937
938 PyObject* PythonQt::helpCalled(PythonQtClassInfo* info)
939 {
940 if (_p->_initFlags & ExternalHelp) {
941 emit pythonHelpRequest(QByteArray(info->className()));
942 return Py_BuildValue("");
943 } else {
944 return PyString_FromString(info->help().toLatin1().data());
945 }
946 }
@@ -0,0 +1,436
1 #ifndef _PYTHONQT_H
2 #define _PYTHONQT_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQt.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQtSystem.h"
46 #include "PythonQtWrapper.h"
47 #include "PythonQtVariantWrapper.h"
48 #include "PythonQtMetaObjectWrapper.h"
49 #include "PythonQtSlot.h"
50 #include "PythonQtObjectPtr.h"
51 #include <QObject>
52 #include <QVariant>
53 #include <QList>
54 #include <QHash>
55 #include <QByteArray>
56 #include <QStringList>
57 #include <QtDebug>
58 #include <iostream>
59
60
61 class PythonQtClassInfo;
62 class PythonQtPrivate;
63 class PythonQtMethodInfo;
64 class PythonQtSignalReceiver;
65 class PythonQtImportFileInterface;
66 class PythonQtCppWrapperFactory;
67 class PythonQtConstructorHandler;
68
69 //! the main interface to the Python Qt binding, realized as a singleton
70 class PYTHONQT_EXPORT PythonQt : public QObject {
71
72 Q_OBJECT
73
74 public:
75 enum InitFlags {
76 RedirectStdOut = 1, //!<< sets if the std out/err is redirected to pythonStdOut() and pythonStdErr() signals
77 IgnoreSiteModule = 2, //!<< sets if Python should ignore the site module
78 ExternalHelp = 4 //!<< sets if help() calls on PythonQt modules are forwarded to the pythonHelpRequest() signal
79 };
80
81 //! initialize the python qt binding (flags are a or combination of InitFlags)
82 static void init(int flags = IgnoreSiteModule | RedirectStdOut);
83
84 //! cleanup
85 static void cleanup();
86
87 //! get the singleton instance
88 static PythonQt* self() { return _self; }
89
90 //-----------------------------------------------------------------------------
91 // Public API:
92
93 //! defines the object types for introspection
94 enum ObjectType {
95 Class,
96 Function,
97 Variable,
98 Module,
99 Anything,
100 CallOverloads
101 };
102
103 //! overwrite the python sys path (call this directly after PythonQt::init() if you want to change the std python sys path)
104 void overwriteSysPath(const QStringList& paths);
105
106 //! sets the __path__ list of a module to the given list (important for local imports)
107 void setModuleImportPath(PyObject* module, const QStringList& paths);
108
109 //! get the __main__ module of python
110 PythonQtObjectPtr getMainModule();
111
112 //! registers a QObject derived class to PythonQt (this is implicitly called by addObject as well)
113 //! All added metaobjects will be visible under the className in the PythonQt module as MetaObjectWrappers and the enums
114 //! and constructors (added by addConstructors) will be available.
115 /* Since Qt4 does not offer a way to detect if a given classname is derived from QObject and thus has a QMetaObject,
116 you MUST register all your QObject derived classes here when you want them to be detected in signal and slot calls */
117 void registerClass(const QMetaObject* metaobject);
118
119 //! as an alternative to registerClass, you can tell PythonQt the names of QObject derived classes
120 //! and it will register the classes when it first sees a pointer to such a derived class
121 void registerQObjectClassNames(const QStringList& names);
122
123 //! this will register CPP classnames as known CPP classes (NOT QObjects) and make their MetaObjectWrapper available in
124 //! the PythonQt module. In combination with addConstuctors(), this can be used to create CPP objects from PythonQt
125 void registerCPPClassNames(const QStringList& names);
126
127 //! parses the given file and returns the python code object, this can then be used to call evalCode()
128 PythonQtObjectPtr parseFile(const QString& filename);
129
130 //! evaluates the given code and returns the result value (use Py_Compile etc. to create pycode from string)
131 //! If pycode is NULL, a python error is printed.
132 QVariant evalCode(PyObject* module, PyObject* pycode);
133
134 //! evaluates the given script code and returns the result value
135 QVariant evalScript(PyObject* module, const QString& script, int start = Py_file_input);
136
137 //! evaluates the given script code from file
138 void evalFile(PyObject* module, const QString& filename);
139
140 //@{ Signal handlers
141
142 //! add a signal handler to the given \c signal of \c obj and connect it to a callable \c objectname in module
143 bool addSignalHandler(QObject* obj, const char* signal, PyObject* module, const QString& objectname);
144
145 //! remove a signal handler from the given \c signal of \c obj
146 bool removeSignalHandler(QObject* obj, const char* signal, PyObject* module, const QString& objectname);
147
148 //! add a signal handler to the given \c signal of \c obj and connect it to a callable \c receiver
149 bool addSignalHandler(QObject* obj, const char* signal, PyObject* receiver);
150
151 //! remove a signal handler from the given \c signal of \c obj
152 bool removeSignalHandler(QObject* obj, const char* signal, PyObject* receiver);
153
154 //@}
155
156 //@{ Variable access
157
158 //! add the given \c object to the \c module as a variable with \c name (it can be removed via clearVariable)
159 void addObject(PyObject* module, const QString& name, QObject* object);
160
161 //! add the given variable to the module
162 void addVariable(PyObject* module, const QString& name, const QVariant& v);
163
164 //! remove the given variable
165 void removeVariable(PyObject* module, const QString& name);
166
167 //! get the variable with the \c name of the \c module, returns an invalid QVariant on error
168 QVariant getVariable(PyObject* module, const QString& name);
169
170 //! read vars etc. in scope of a module, optional looking inside of an object \c objectname
171 QStringList introspection(PyObject* module, const QString& objectname, ObjectType type);
172
173 //! returns the found callable object or NULL
174 //! @return new reference
175 PythonQtObjectPtr lookupCallable(PyObject* module, const QString& name);
176
177 //@}
178
179 //@{ Calling of python callables
180
181 //! call the given python method, returns the result converted to a QVariant
182 QVariant call(PyObject* module, const QString& callable, const QVariantList& args);
183
184 //@}
185
186 //@{ Decorations, constructors, wrappers...
187
188
189 //! add an object whose slots will be used as decorator slots for
190 //! other QObjects or CPP classes. The slots need to follow the
191 //! convention that the first argument is a pointer to the wrapped object.
192 //! (ownership is passed to PythonQt)
193 /*!
194 Example:
195
196 A slot with the signature
197
198 \code
199 bool doSomething(QWidget* w, int a)
200 \endcode
201
202 will extend QWidget instances (and derived classes) with a "bool doSomething(int a)" slot
203 that will be called with the concrete instance as first argument.
204 So in Python you can now e.g. call
205
206 \code
207 someWidget.doSomething(12)
208 \endcode
209
210 without QWidget really having this method. This allows to easily make normal methods
211 of Qt classes callable by forwarding them with such decorator slots
212 or to make CPP classes (which are not derived from QObject) callable from Python.
213 */
214 void addInstanceDecorators(QObject* o);
215
216 //! add an object whose slots will be used as decorator slots for
217 //! class objects (ownership is passed to PythonQt)
218 /*!
219 The slots need to follow the following convention:
220 - SomeClass* new_SomeClass(...)
221 - QVariant new_SomeClass(...)
222 - void delete_SomeClass(SomeClass*)
223 - ... static_SomeClass_someName(...)
224
225 This will add:
226 - a constructor
227 - a constructor which generates a QVariant
228 - a destructor (only useful for CPP objects)
229 - a static decorator slot which will be available on the MetaObject (visible in PythonQt module)
230
231 */
232 void addClassDecorators(QObject* o);
233
234 //! this will add the object both as class and instance decorator (ownership is passed to PythonQt)
235 void addDecorators(QObject* o);
236
237 //! add a wrapper object for the given QMetaType typeName, also does an addClassDecorators() to add constructors for variants
238 //! (ownership of wrapper is passed to PythonQt)
239 /*! Make sure that you have done a qRegisterMetaType first, if typeName is a user type!
240
241 This will add a wrapper object that is used to make calls to the given classname \c typeName.
242 All slots that take a pointer to typeName as the first argument will be callable from Python on
243 a variant object that contains such a type.
244 */
245 void addVariantWrapper(const char* typeName, QObject* wrapper);
246
247 //! add the given factory to PythonQt (ownership stays with caller)
248 void addWrapperFactory(PythonQtCppWrapperFactory* factory);
249
250 //! add the given constructor handler to PythonQt (ownership stays with caller)
251 void addConstructorHandler(PythonQtConstructorHandler* handler);
252
253 //! get list of constructor handlers
254 const QList<PythonQtConstructorHandler*>& constructorHandlers();
255
256 //@}
257
258 //@{ Custom importer (to replace internal import implementation of python)
259
260 //! replace the internal import implementation and use the supplied interface to load files (both py and pyc files)
261 //! (this method should be called directly after initialization of init() and before calling overwriteSysPath().
262 //! It can only be called once, further calls will be ignored silently. (ownership stays with caller)
263 void setImporter(PythonQtImportFileInterface* importInterface);
264
265 //! set paths that the importer should ignore
266 void setImporterIgnorePaths(const QStringList& paths);
267
268 //! get paths that the importer should ignore
269 const QStringList& getImporterIgnorePaths();
270
271 //@}
272
273 //! get access to internal data (should not be used on the public API, but is used by some C functions)
274 static PythonQtPrivate* priv() { return _self->_p; }
275
276 //! get access to the file importer (if set)
277 static PythonQtImportFileInterface* importInterface();
278
279 //! handle a python error, call this when a python function fails. If no error occurred, it returns false.
280 //! The error is currently just output to the python stderr, future version might implement better trace printing
281 bool handleError();
282
283 signals:
284 //! emitted when python outputs something to stdout (and redirection is turned on)
285 void pythonStdOut(const QString& str);
286 //! emitted when python outputs something to stderr (and redirection is turned on)
287 void pythonStdErr(const QString& str);
288
289 //! emitted when help() is called on a PythonQt object and \c ExternalHelp is enabled
290 void pythonHelpRequest(const QByteArray& cppClassName);
291
292
293 public:
294 //! called by internal help methods
295 PyObject* helpCalled(PythonQtClassInfo* info);
296
297 //! returns the found object or NULL
298 //! @return new reference
299 PythonQtObjectPtr lookupObject(PyObject* module, const QString& name);
300
301 private:
302 void initPythonQtModule(bool redirectStdOut);
303
304 //! callback for stdout redirection, emits pythonStdOut signal
305 static void stdOutRedirectCB(const QString& str);
306 //! callback for stderr redirection, emits pythonStdErr signal
307 static void stdErrRedirectCB(const QString& str);
308
309 //! get (and create if not available) the signal receiver of that QObject, signal receiver is made child of the passed \c obj
310 PythonQtSignalReceiver* getSignalReceiver(QObject* obj);
311
312 PythonQt(int flags);
313 ~PythonQt();
314
315 static PythonQt* _self;
316
317 PythonQtPrivate* _p;
318
319 };
320
321 //! internal PythonQt details
322 class PythonQtPrivate : public QObject {
323
324 Q_OBJECT
325
326 public:
327 PythonQtPrivate();
328 ~PythonQtPrivate();
329
330 //! returns if the id is the id for PythonQtObjectPtr
331 bool isPythonQtObjectPtrMetaId(int id) { return _PythonQtObjectPtr_metaId == id; }
332
333 //! remove the wrapper ptr again
334 void removeWrapperPointer(void* obj) { _wrappedObjects.take(obj); }
335
336 //! wrap the given QObject into a Python object (or return existing wrapper!)
337 PyObject* wrapQObject(QObject* obj);
338
339 //! wrap the given ptr into a Python object (or return existing wrapper!) if there is a known QObject of that name or a known wrapper in the factory
340 PyObject* wrapPtr(void* ptr, const QByteArray& name);
341
342 //! registers a QObject derived class to PythonQt (this is implicitly called by addObject as well)
343 /* Since Qt4 does not offer a way to detect if a given classname is derived from QObject and thus has a QMetaObject,
344 you MUST register all your QObject derived classes here when you want them to be detected in signal and slot calls */
345 void registerClass(const QMetaObject* metaobject);
346
347 //! as an alternative to registerClass, you can tell PythonQt the names of QObject derived classes
348 //! and it will register the classes when it first sees a pointer to such a derived class
349 void registerQObjectClassNames(const QStringList& names);
350
351 //! add a decorator object
352 void addDecorators(QObject* o, bool instanceDeco, bool classDeco);
353
354 //! add a wrapper object for the given qvariant, also does an addConstructors() to add constructors for variants
355 void addVariantWrapper(const char* typeName, QObject* wrapper);
356
357 //! get list of all slots that are available as decorator slots
358 QList<PythonQtSlotInfo*> getDecoratorSlots(const QByteArray& className);
359
360 //! check if the enum is either part of the \c meta class or contains a scope and is
361 //! an enum of another known metaobject (and as last resort, of the Qt namespace)
362 bool isEnumType(const QMetaObject* meta, const QByteArray& name);
363
364 //! helper method that creates a PythonQtMetaObjectWrapper object
365 PythonQtMetaObjectWrapper* createNewPythonQtMetaObjectWrapper(PythonQtClassInfo* info);
366
367 //! helper method that creates a PythonQtWrapper object and registers it in the object map
368 PythonQtWrapper* createNewPythonQtWrapper(QObject* obj, PythonQtClassInfo* info, void* wrappedPtr = NULL);
369
370 //! helper method that creates a PythonQtVariantWrapper object
371 PythonQtVariantWrapper* createNewPythonQtVariantWrapper(const QVariant& variant);
372
373 //! get the class info for a meta object (if available)
374 PythonQtClassInfo* getClassInfo(const QMetaObject* meta) { return _knownQtClasses.value(meta->className()); }
375
376 //! get the constructor slot for the given classname
377 PythonQtSlotInfo* getConstructorSlot(const QByteArray& className) { return _constructorSlots.value(className); }
378
379 //! get the destructor slot for the given classname
380 PythonQtSlotInfo* getDestructorSlot(const QByteArray& className) { return _destructorSlots.value(className); }
381
382 protected slots:
383 //! called when a wrapped QObject is destroyed
384 void wrappedObjectDestroyed(QObject* obj);
385
386 //! called when a signal emitting QObject is destroyed to remove the signal handler from the hash map
387 void destroyedSignalEmitter(QObject* obj);
388
389 private:
390
391 //! stores pointer to PyObject mapping of wrapped QObjects AND C++ objects
392 QHash<void* , PythonQtWrapper *> _wrappedObjects;
393
394 //! stores the meta info of known Qt classes
395 QHash<QByteArray, PythonQtClassInfo *> _knownQtClasses;
396
397 //! stores the meta info of known Qt classes
398 QHash<QByteArray, PythonQtClassInfo *> _knownQtWrapperClasses;
399
400 //! stores the meta info of known Qt C++ wrapper classes
401 QMultiHash<QByteArray, PythonQtSlotInfo *> _knownQtDecoratorSlots;
402
403 //! names of qobject derived classes that can be casted to qobject savely
404 QHash<QByteArray, bool> _knownQObjectClassNames;
405
406 //! stores signal receivers for QObjects
407 QHash<QObject* , PythonQtSignalReceiver *> _signalReceivers;
408
409 //! the PythonQt python module
410 PythonQtObjectPtr _pythonQtModule;
411
412 //! the importer interface (if set)
413 PythonQtImportFileInterface* _importInterface;
414
415 QStringList _importIgnorePaths;
416
417 //! the cpp object wrapper factories
418 QList<PythonQtCppWrapperFactory*> _cppWrapperFactories;
419
420 //! the cpp object wrapper factories
421 QList<PythonQtConstructorHandler*> _constructorHandlers;
422
423 QHash<QByteArray , PythonQtSlotInfo *> _constructorSlots;
424 QHash<QByteArray , PythonQtSlotInfo *> _destructorSlots;
425
426 QHash<int , QPair<PythonQtClassInfo*, QObject*> > _knownVariantWrappers;
427
428 PythonQtClassInfo* _qtNamespace;
429
430 int _initFlags;
431 int _PythonQtObjectPtr_metaId;
432
433 friend class PythonQt;
434 };
435
436 #endif
@@ -0,0 +1,404
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQt.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtClassInfo.h"
43 #include "PythonQtMethodInfo.h"
44 #include "PythonQt.h"
45 #include <QMetaMethod>
46
47 QHash<QByteArray, int> PythonQtMethodInfo::_parameterTypeDict;
48
49 PythonQtClassInfo::PythonQtClassInfo(const QMetaObject* meta, const QByteArray& wrappedClassName) {
50 _meta = meta;
51 _wrappedClassName = wrappedClassName;
52 _constructors = NULL;
53 }
54
55 PythonQtClassInfo::~PythonQtClassInfo()
56 {
57 QHashIterator<QByteArray, PythonQtMemberInfo> i(_cachedMembers);
58 while (i.hasNext()) {
59 PythonQtMemberInfo member = i.next().value();
60 if (member._type== PythonQtMemberInfo::Slot) {
61 PythonQtSlotInfo* info = member._slot;
62 while (info) {
63 PythonQtSlotInfo* next = info->nextInfo();
64 delete info;
65 info = next;
66 }
67 }
68 }
69 }
70
71 int PythonQtClassInfo::findCharOffset(const char* sigStart, char someChar)
72 {
73 const char* sigEnd = sigStart;
74 char c;
75 do {
76 c = *sigEnd++;
77 } while (c!=someChar && c!=0);
78 return sigEnd-sigStart-1;
79 }
80
81 PythonQtMemberInfo PythonQtClassInfo::member(const char* memberName)
82 {
83 PythonQtMemberInfo info = _cachedMembers.value(memberName);
84 if (info._type != PythonQtMemberInfo::Invalid) {
85 return info;
86 } else {
87 bool found = false;
88 const char* attributeName = memberName;
89 bool nameMapped = false;
90 // look for properties
91 int i = _meta->indexOfProperty(attributeName);
92 if (i==-1) {
93 // try to map name to objectName
94 if (qstrcmp(attributeName, "name")==0) {
95 attributeName = "objectName";
96 nameMapped = true;
97 i = _meta->indexOfProperty(attributeName);
98 }
99 }
100 if (i!=-1) {
101 PythonQtMemberInfo newInfo(_meta->property(i));
102 _cachedMembers.insert(attributeName, newInfo);
103 if (nameMapped) {
104 _cachedMembers.insert(memberName, newInfo);
105 }
106 #ifdef PYTHONQT_DEBUG
107 std::cout << "caching property " << memberName << " on " << _meta->className() << std::endl;
108 #endif
109 found = true;
110 } else {
111 int memberNameLen = strlen(memberName);
112 // if it is not a property, look for slots
113 PythonQtSlotInfo* tail = NULL;
114 int numMethods = _meta->methodCount();
115 for (int i = 0; i < numMethods; i++) {
116 QMetaMethod m = _meta->method(i);
117 if ((m.methodType() == QMetaMethod::Method ||
118 m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) {
119
120 const char* sigStart = m.signature();
121 // find the first '('
122 int offset = findCharOffset(sigStart, '(');
123
124 // check if same length and same name
125 if (memberNameLen == offset && qstrncmp(memberName, sigStart, offset)==0) {
126 found = true;
127 PythonQtSlotInfo* info = new PythonQtSlotInfo(m, i);
128 if (tail) {
129 tail->setNextInfo(info);
130 } else {
131 PythonQtMemberInfo newInfo(info);
132 _cachedMembers.insert(memberName, newInfo);
133 }
134 tail = info;
135 }
136 }
137 }
138
139 // look for decorators
140 if (!_wrappedClassName.isEmpty()) {
141 tail = findDecoratorSlots(_wrappedClassName.constData(), memberName, memberNameLen, tail, found);
142 }
143 const QMetaObject* meta = _meta;
144 while (meta) {
145 tail = findDecoratorSlots(meta->className(), memberName, memberNameLen, tail, found);
146 meta = meta->superClass();
147 }
148
149 }
150 if (!found) {
151 // look for enum values
152 int enumCount = _meta->enumeratorCount();
153 for (i=0;i<enumCount; i++) {
154 QMetaEnum e = _meta->enumerator(i);
155 for (int j=0; j < e.keyCount(); j++) {
156 if (qstrcmp(e.key(j), attributeName)==0) {
157 PythonQtMemberInfo newInfo(e.value(j));
158 _cachedMembers.insert(memberName, newInfo);
159 #ifdef PYTHONQT_DEBUG
160 std::cout << "caching enum " << memberName << " on " << _meta->className() << std::endl;
161 #endif
162 found = true;
163 }
164 }
165 }
166 }
167 return _cachedMembers.value(memberName);
168 }
169 }
170
171 PythonQtSlotInfo* PythonQtClassInfo::findDecoratorSlots(const char* classname, const char* memberName, int memberNameLen, PythonQtSlotInfo* tail, bool& found)
172 {
173 QListIterator<PythonQtSlotInfo*> it(PythonQt::priv()->getDecoratorSlots(classname));
174 while (it.hasNext()) {
175
176 PythonQtSlotInfo* infoOrig = it.next();
177
178 const char* sigStart = infoOrig->metaMethod()->signature();
179 if (qstrncmp("static_", sigStart, 7)==0) {
180 sigStart += 7;
181 sigStart += findCharOffset(sigStart, '_')+1;
182 }
183 int offset = findCharOffset(sigStart, '(');
184 if (memberNameLen == offset && qstrncmp(memberName, sigStart, offset)==0) {
185 //make a copy, otherwise we will have trouble on overloads!
186 PythonQtSlotInfo* info = new PythonQtSlotInfo(*infoOrig);
187 found = true;
188 if (tail) {
189 tail->setNextInfo(info);
190 } else {
191 PythonQtMemberInfo newInfo(info);
192 _cachedMembers.insert(memberName, newInfo);
193 }
194 tail = info;
195 }
196 }
197 return tail;
198 }
199
200
201 QStringList PythonQtClassInfo::memberList(bool metaOnly)
202 {
203 QStringList l;
204 QString h;
205 if (_wrappedClassName.isEmpty()) {
206 int i;
207 int numProperties = _meta->propertyCount();
208 for (i = 0; i < numProperties; i++) {
209 QMetaProperty p = _meta->property(i);
210 l << QString(p.name());
211 }
212 }
213
214 if (!metaOnly) {
215 int numMethods = _meta->methodCount();
216 bool skipQObj = !_wrappedClassName.isEmpty();
217 for (int i = skipQObj?QObject::staticMetaObject.methodCount():0; i < numMethods; i++) {
218 QMetaMethod m = _meta->method(i);
219 if ((m.methodType() == QMetaMethod::Method ||
220 m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) {
221 QByteArray signa(m.signature());
222 if (signa.startsWith("new_")) continue;
223 if (signa.startsWith("delete_")) continue;
224 if (signa.startsWith("static_")) continue;
225 PythonQtSlotInfo slot(m, i);
226 l << slot.slotName();
227 }
228 }
229 }
230 // look for decorators
231 QList<const char*> names;
232 if (!_wrappedClassName.isEmpty()) {
233 names << _wrappedClassName.constData();
234 }
235 const QMetaObject* meta = _meta;
236 while (meta) {
237 if (meta==&QObject::staticMetaObject && !_wrappedClassName.isEmpty()) break;
238 names << meta->className();
239 meta = meta->superClass();
240 }
241
242 QListIterator<const char*> nameIt(names);
243 while (nameIt.hasNext()) {
244 QListIterator<PythonQtSlotInfo*> it(PythonQt::priv()->getDecoratorSlots(nameIt.next()));
245 while (it.hasNext()) {
246 PythonQtSlotInfo* slot = it.next();
247 if (metaOnly) {
248 if (slot->isClassDecorator()) {
249 QByteArray first = slot->slotName();
250 if (first.startsWith("static_")) {
251 int idx = first.indexOf('_');
252 idx = first.indexOf('_', idx+1);
253 first = first.mid(idx+1);
254 }
255 l << first;
256 }
257 } else {
258 l << slot->slotName();
259 }
260 }
261 }
262
263 if (_meta->enumeratorCount()) {
264 for (int i = 0; i<_meta->enumeratorCount(); i++) {
265 QMetaEnum e = _meta->enumerator(i);
266 for (int j=0; j < e.keyCount(); j++) {
267 l << QString(e.key(j));
268 }
269 }
270 }
271 return l;
272 }
273
274 const char* PythonQtClassInfo::className()
275 {
276 if (!_wrappedClassName.isEmpty()) {
277 return _wrappedClassName.constData();
278 } else {
279 return _meta->className();
280 }
281 }
282
283 bool PythonQtClassInfo::inherits(const char* name)
284 {
285 const QMetaObject* m = _meta;
286 while (m) {
287 if (strcmp(name, m->className())==0) {
288 return true;
289 }
290 m = m->superClass();
291 }
292 return false;
293 }
294
295 const QByteArray& PythonQtClassInfo::wrappedCPPClassName()
296 {
297 return _wrappedClassName;
298 }
299
300 QString PythonQtClassInfo::help()
301 {
302 QString h;
303 bool isVariant = QMetaType::type(className())!=QMetaType::Void;
304 h += QString("--- ") + QString(className()) + QString(" ---\n");
305
306 if (_wrappedClassName.isEmpty()) {
307 h += "Properties:\n";
308
309 int i;
310 int numProperties = _meta->propertyCount();
311 for (i = 0; i < numProperties; i++) {
312 QMetaProperty p = _meta->property(i);
313 h += QString(p.name()) + " (" + QString(p.typeName()) + " )\n";
314 }
315 }
316
317 if (constructors()) {
318 h += "Constructors:\n";
319 PythonQtSlotInfo* constr = constructors();
320 while (constr) {
321 h += constr->fullSignature(false) + "\n";
322 constr = constr->nextInfo();
323 }
324 }
325
326 h += "Slots:\n";
327 h += "QString help()\n";
328 h += "QString className()\n";
329
330 int numMethods = _meta->methodCount();
331 for (int i = isVariant?QObject::staticMetaObject.methodCount():0; i < numMethods; i++) {
332 QMetaMethod m = _meta->method(i);
333 if ((m.methodType() == QMetaMethod::Method ||
334 m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) {
335 QByteArray signa(m.signature());
336 if (signa.startsWith("new_")) continue;
337 if (signa.startsWith("delete_")) continue;
338 if (signa.startsWith("static_")) continue;
339 PythonQtSlotInfo slot(m, i);
340 h += slot.fullSignature(isVariant)+ "\n";
341 }
342 }
343 // look for decorators
344 QList<const char*> names;
345 if (!_wrappedClassName.isEmpty()) {
346 names << _wrappedClassName.constData();
347 }
348 const QMetaObject* meta = _meta;
349 while (meta) {
350 names << meta->className();
351 meta = meta->superClass();
352 if (isVariant && meta==&QObject::staticMetaObject) break;
353 }
354
355 QListIterator<const char*> nameIt(names);
356 while (nameIt.hasNext()) {
357 QListIterator<PythonQtSlotInfo*> it(PythonQt::priv()->getDecoratorSlots(nameIt.next()));
358 while (it.hasNext()) {
359 PythonQtSlotInfo* slot = it.next();
360 h += slot->fullSignature(slot->isInstanceDecorator()) + "\n";
361 }
362 }
363
364 if (_meta->enumeratorCount()) {
365 h += "Enums:\n";
366 for (int i = 0; i<_meta->enumeratorCount(); i++) {
367 QMetaEnum e = _meta->enumerator(i);
368 h += QString(e.name()) + " {";
369 for (int j=0; j < e.keyCount(); j++) {
370 if (j) { h+= ", "; }
371 h += e.key(j);
372 }
373 h += " }\n";
374 }
375 }
376
377 if (_wrappedClassName.isEmpty()) {
378 int numMethods = _meta->methodCount();
379 if (numMethods>0) {
380 h += "Signals:\n";
381 for (int i = isVariant?QObject::staticMetaObject.methodCount():0; i < numMethods; i++) {
382 QMetaMethod m = _meta->method(i);
383 if (m.methodType() == QMetaMethod::Signal) {
384 h += QString(m.signature()) + "\n";
385 }
386 }
387 }
388 }
389 return h;
390 }
391
392 PythonQtSlotInfo* PythonQtClassInfo::constructors()
393 {
394 if (!_constructors) {
395 _constructors = PythonQt::priv()->getConstructorSlot(!_wrappedClassName.isEmpty()?_wrappedClassName:QByteArray(_meta->className()));
396 }
397 return _constructors;
398 }
399
400 void PythonQtClassInfo::setMetaObject(const QMetaObject* meta)
401 {
402 _meta = meta;
403 _cachedMembers.clear();
404 }
@@ -0,0 +1,127
1 #ifndef _PYTHONQTCLASSINFO_H
2 #define _PYTHONQTCLASSINFO_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 #include <QMetaObject>
37 #include <QMetaMethod>
38 #include <QHash>
39 #include <QByteArray>
40 #include <QList>
41
42 class PythonQtSlotInfo;
43
44 struct PythonQtMemberInfo {
45 enum Type {
46 Invalid, Slot, EnumValue, Property
47 };
48
49 PythonQtMemberInfo() { _type = Invalid; }
50
51 PythonQtMemberInfo(PythonQtSlotInfo* info) {
52 _type = Slot;
53 _slot = info;
54 _enumValue = 0;
55 }
56
57 PythonQtMemberInfo(unsigned int enumValue) {
58 _type = EnumValue;
59 _slot = NULL;
60 _enumValue = enumValue;
61 }
62
63 PythonQtMemberInfo(const QMetaProperty& prop) {
64 _type = Property;
65 _slot = NULL;
66 _enumValue = 0;
67 _property = prop;
68 }
69
70 PythonQtSlotInfo* _slot;
71 unsigned int _enumValue;
72 QMetaProperty _property;
73 Type _type;
74 };
75
76 //! a class that stores all required information about a Qt object (and an optional associated C++ class name)
77 /*! for fast lookup of slots when calling the object from Python
78 */
79 class PythonQtClassInfo {
80
81 public:
82 PythonQtClassInfo(const QMetaObject* meta, const QByteArray& wrappedClassName = QByteArray());
83
84 ~PythonQtClassInfo();
85
86 //! get the Python method definition for a given slot name (without return type and signature)
87 PythonQtMemberInfo member(const char* member);
88
89 PythonQtSlotInfo* constructors();
90
91 //! get the Qt classname
92 const char* className();
93
94 //! get the classname of the wrapped C++ class
95 const QByteArray& wrappedCPPClassName();
96
97 //! returns if the object is a CPP wrapper
98 bool isCPPWrapper() { return !_wrappedClassName.isEmpty(); }
99
100 //! get the meta object
101 const QMetaObject* metaObject() { return _meta; }
102
103 //! set the meta object, this will reset the caching
104 void setMetaObject(const QMetaObject* meta);
105
106 //! returns if the meta object inherits the given classname
107 bool inherits(const char* name);
108
109 //! get help string for the metaobject
110 QString help();
111
112 //! get list of all members
113 QStringList memberList(bool metaOnly = false);
114
115 private:
116 PythonQtSlotInfo* findDecoratorSlots(const char* classname, const char* memberName, int memberNameLen, PythonQtSlotInfo* tail, bool &found);
117 int findCharOffset(const char* sigStart, char someChar);
118 QHash<QByteArray, PythonQtMemberInfo> _cachedMembers;
119 PythonQtSlotInfo* _constructors;
120 const QMetaObject* _meta;
121 QByteArray _wrappedClassName;
122 };
123
124 //---------------------------------------------------------------
125
126
127 #endif
This diff has been collapsed as it changes many lines, (1012 lines changed) Show them Hide them
@@ -0,0 +1,1012
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtConversion.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtConversion.h"
43 #include "PythonQtVariants.h"
44 #include "PythonQtVariantWrapper.h"
45 #include <QDateTime>
46 #include <QTime>
47 #include <QDate>
48
49 PythonQtValueStorage<qint64, 128> PythonQtConv::global_valueStorage;
50 PythonQtValueStorage<void*, 128> PythonQtConv::global_ptrStorage;
51 PythonQtValueStorage<QVariant, 32> PythonQtConv::global_variantStorage;
52
53
54 PyObject* PythonQtConv::GetPyBool(bool val)
55 {
56 PyObject* r = val?Py_True:Py_False;
57 Py_INCREF(r);
58 return r;
59 }
60
61 PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::ParameterInfo& info, void* data) {
62 if (info.typeId == QMetaType::Void) {
63 Py_INCREF(Py_None);
64 return Py_None;
65 } else {
66 if (info.isPointer && (info.typeId == PythonQtMethodInfo::Unknown)) {
67 // try to convert the pointer to a Python Object
68 PyObject* pyObj = PythonQt::priv()->wrapPtr(*((void**)data), info.name);
69 if (pyObj) {
70 return pyObj;
71 } else {
72 std::cerr << "unknown pointer type " << info.name.data() << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
73 Py_INCREF(Py_None);
74 return Py_None;
75 }
76 } else if (info.isPointer && (info.typeId == QMetaType::Char)) {
77 // a char ptr will probably be a null terminated string, so we support that:
78 return PyString_FromString(*((char**)data));
79 } else {
80 if (info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) {
81 if (info.name.startsWith("QList<")) {
82 QByteArray innerType = info.name.mid(6,info.name.length()-7);
83 if (innerType.endsWith("*")) {
84 innerType.truncate(innerType.length()-1);
85 return ConvertQListWithPointersToPython((QList<void*>*)data, innerType);
86 }
87 }
88 }
89 // handle values that are not yet handled and not pointers
90 return ConvertQtValueToPythonInternal(info.typeId, data);
91 }
92 }
93 }
94
95 PyObject* PythonQtConv::ConvertQtValueToPythonInternal(int type, void* data) {
96 switch (type) {
97 case QMetaType::Void:
98 Py_INCREF(Py_None);
99 return Py_None;
100 case QMetaType::Char:
101 return PyInt_FromLong(*((char*)data));
102 case QMetaType::UChar:
103 return PyInt_FromLong(*((unsigned char*)data));
104 case QMetaType::Short:
105 return PyInt_FromLong(*((short*)data));
106 case QMetaType::UShort:
107 return PyInt_FromLong(*((unsigned short*)data));
108 case QMetaType::Long:
109 return PyInt_FromLong(*((long*)data));
110 case QMetaType::ULong:
111 // does not fit into simple int of python
112 return PyLong_FromUnsignedLong(*((unsigned long*)data));
113 case QMetaType::Bool:
114 return PythonQtConv::GetPyBool(*((bool*)data));
115 case QMetaType::Int:
116 return PyInt_FromLong(*((int*)data));
117 case QMetaType::UInt:
118 return PyInt_FromLong(*((unsigned int*)data));
119 case QMetaType::QChar:
120 return PyInt_FromLong(*((short*)data));
121 case QMetaType::Float:
122 return PyFloat_FromDouble(*((float*)data));
123 case QMetaType::Double:
124 return PyFloat_FromDouble(*((double*)data));
125 case QMetaType::LongLong:
126 return PyLong_FromLongLong(*((qint64*)data));
127 case QMetaType::ULongLong:
128 return PyLong_FromUnsignedLongLong(*((quint64*)data));
129 case QMetaType::QByteArray: {
130 QByteArray* v = (QByteArray*) data;
131 return PyString_FromStringAndSize(*v, v->size());
132 }
133 case QMetaType::QVariantMap:
134 return PythonQtConv::QVariantMapToPyObject(*((QVariantMap*)data));
135 case QMetaType::QVariantList:
136 return PythonQtConv::QVariantListToPyObject(*((QVariantList*)data));
137 case QMetaType::QString:
138 return PythonQtConv::QStringToPyObject(*((QString*)data));
139 case QMetaType::QStringList:
140 return PythonQtConv::QStringListToPyObject(*((QStringList*)data));
141
142 case PythonQtMethodInfo::Variant:
143 return PythonQtConv::QVariantToPyObject(*((QVariant*)data));
144 case QMetaType::QObjectStar:
145 case QMetaType::QWidgetStar:
146 return PythonQt::priv()->wrapQObject(*((QObject**)data));
147
148 // the following cases could be handled by the default case, but it is faster to do it with
149 // direct casts:
150 case QMetaType::QDate:
151 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QDate*)data)));
152 case QMetaType::QTime:
153 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QTime*)data)));
154 case QMetaType::QDateTime:
155 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QDateTime*)data)));
156 case QMetaType::QRect:
157 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QRect*)data)));
158 case QMetaType::QSize:
159 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QSize*)data)));
160 case QMetaType::QPoint:
161 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QPoint*)data)));
162 case QMetaType::QColor:
163 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QColor*)data)));
164 case QMetaType::QPixmap:
165 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QPixmap*)data)));
166 case QMetaType::QUrl:
167 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QUrl*)data)));
168 case QMetaType::QRectF:
169 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QRectF*)data)));
170 case QMetaType::QSizeF:
171 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QSizeF*)data)));
172 case QMetaType::QLine:
173 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QLine*)data)));
174 case QMetaType::QLineF:
175 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QLineF*)data)));
176 case QMetaType::QPointF:
177 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QPointF*)data)));
178 case QMetaType::QRegExp:
179 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QRegExp*)data)));
180 case QMetaType::QBitArray:
181 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QBitArray*)data)));
182 case QMetaType::QLocale:
183 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QLocale*)data)));
184 case QMetaType::QFont:
185 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QFont*)data)));
186 case QMetaType::QBrush:
187 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QBrush*)data)));
188 case QMetaType::QPalette:
189 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QPalette*)data)));
190 case QMetaType::QIcon:
191 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(qVariantFromValue(*((QIcon*)data)));
192 case QMetaType::QImage:
193 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QImage*)data)));
194 case QMetaType::QPolygon:
195 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QPolygon*)data)));
196 case QMetaType::QRegion:
197 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QRegion*)data)));
198 case QMetaType::QBitmap:
199 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(qVariantFromValue(*((QBitmap*)data)));
200 case QMetaType::QCursor:
201 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QCursor*)data)));
202 case QMetaType::QSizePolicy:
203 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(QVariant(*((QSizePolicy*)data)));
204 case QMetaType::QKeySequence:
205 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(qVariantFromValue(*((QKeySequence*)data)));
206 case QMetaType::QPen:
207 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(qVariantFromValue(*((QPen*)data)));
208 case QMetaType::QTextLength:
209 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(qVariantFromValue(*((QTextLength*)data)));
210 case QMetaType::QTextFormat:
211 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(qVariantFromValue(*((QTextFormat*)data)));
212 case QMetaType::QMatrix:
213 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(qVariantFromValue(*((QMatrix*)data)));
214 default:
215 if (PythonQt::priv()->isPythonQtObjectPtrMetaId(type)) {
216 PyObject* o = ((PythonQtObjectPtr*)data)->object();
217 Py_INCREF(o);
218 return o;
219 } else {
220 if (type != PythonQtMethodInfo::Unknown) {
221 QVariant v(type, data);
222 if (v.isValid()) {
223 return (PyObject*)PythonQt::priv()->createNewPythonQtVariantWrapper(v);
224 }
225 }
226 std::cerr << "Unknown type that can not be converted to Python: " << type << ", in " << __FILE__ << ":" << __LINE__ << std::endl;
227 }
228 }
229 Py_INCREF(Py_None);
230 return Py_None;
231 }
232
233 void* PythonQtConv::CreateQtReturnValue(const PythonQtMethodInfo::ParameterInfo& info) {
234 void* ptr = NULL;
235 if (info.isPointer) {
236 PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, NULL, ptr);
237 } else {
238 switch (info.typeId) {
239 case QMetaType::Char:
240 case QMetaType::UChar:
241 case QMetaType::Short:
242 case QMetaType::UShort:
243 case QMetaType::Long:
244 case QMetaType::ULong:
245 case QMetaType::Bool:
246 case QMetaType::Int:
247 case QMetaType::UInt:
248 case QMetaType::QChar:
249 case QMetaType::Float:
250 case QMetaType::Double:
251 PythonQtValueStorage_ADD_VALUE(global_valueStorage, long, 0, ptr);
252 break;
253 case PythonQtMethodInfo::Variant:
254 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, 0, ptr);
255 // return the ptr to the variant
256 break;
257 default:
258 if (info.typeId == PythonQtMethodInfo::Unknown) {
259 // check if we have a QList of pointers, which we can circumvent with a QList<void*>
260 if (info.name.startsWith("QList<")) {
261 QByteArray innerType = info.name.mid(6,info.name.length()-7);
262 if (innerType.endsWith("*")) {
263 static int id = QMetaType::type("QList<void*>");
264 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant::Type(id), ptr);
265 // return the constData pointer that will be filled with the result value later on
266 ptr = (void*)((QVariant*)ptr)->constData();
267 }
268 }
269 }
270
271 if (!ptr) {
272 // everything else is stored in a QVariant...
273 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant::Type(info.typeId), ptr);
274 // return the constData pointer that will be filled with the result value later on
275 ptr = (void*)((QVariant*)ptr)->constData();
276 }
277 }
278 }
279 return ptr;
280 }
281
282 void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& info, PyObject* obj, bool strict, const QMetaObject* meta)
283 {
284 bool ok;
285 void* ptr = NULL;
286 if (info.isPointer) {
287 if (obj->ob_type == &PythonQtWrapper_Type) {
288 PythonQtWrapper* wrap = (PythonQtWrapper*)obj;
289 // c++ wrapper, check if the class names of the c++ objects match
290 if (wrap->_info->isCPPWrapper()) {
291 //TODO: we could support inheritance on cpp wrappers as well
292 if (wrap->_info->wrappedCPPClassName() == info.name) {
293 PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, wrap->_wrappedPtr, ptr);
294 } else {
295 // not matching
296 }
297 } else {
298 if (wrap->_info->inherits(info.name)) {
299 PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, wrap->_obj, ptr);
300 } else {
301 // not matching
302 }
303 }
304 } else
305 if (info.typeId == QMetaType::Char || info.typeId == QMetaType::UChar) {
306 QString str = PyObjGetString(obj, strict, ok);
307 if (ok) {
308 void* ptr2 = NULL;
309 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant(str.toUtf8()), ptr2);
310 PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, (((QByteArray*)((QVariant*)ptr2)->constData())->data()), ptr);
311 }
312 } else if (info.name == "PyObject") {
313 // handle low level PyObject directly
314 PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, obj, ptr);
315 } else if (obj == Py_None) {
316 // None is treated as a NULL ptr
317 PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, NULL, ptr);
318 } else {
319 // if we are not strict, we try if we are passed a 0 integer
320 if (!strict) {
321 bool ok;
322 int value = PyObjGetInt(obj, true, ok);
323 if (ok && value==0) {
324 PythonQtValueStorage_ADD_VALUE(global_ptrStorage, void*, NULL, ptr);
325 }
326 }
327 // EXTRA: we could support pointers to other simple types, but this would not make sense in most situations
328 }
329
330 } else {
331 // not a pointer
332 switch (info.typeId) {
333 case QMetaType::Char:
334 {
335 int val = PyObjGetInt(obj, strict, ok);
336 if (ok) {
337 PythonQtValueStorage_ADD_VALUE(global_valueStorage, char, val, ptr);
338 }
339 }
340 break;
341 case QMetaType::UChar:
342 {
343 int val = PyObjGetInt(obj, strict, ok);
344 if (ok) {
345 PythonQtValueStorage_ADD_VALUE(global_valueStorage, unsigned char, val, ptr);
346 }
347 }
348 break;
349 case QMetaType::Short:
350 {
351 int val = PyObjGetInt(obj, strict, ok);
352 if (ok) {
353 PythonQtValueStorage_ADD_VALUE(global_valueStorage, short, val, ptr);
354 }
355 }
356 break;
357 case QMetaType::UShort:
358 {
359 int val = PyObjGetInt(obj, strict, ok);
360 if (ok) {
361 PythonQtValueStorage_ADD_VALUE(global_valueStorage, unsigned short, val, ptr);
362 }
363 }
364 break;
365 case QMetaType::Long:
366 {
367 long val = (long)PyObjGetLongLong(obj, strict, ok);
368 if (ok) {
369 PythonQtValueStorage_ADD_VALUE(global_valueStorage, long, val, ptr);
370 }
371 }
372 break;
373 case QMetaType::ULong:
374 {
375 unsigned long val = (unsigned long)PyObjGetLongLong(obj, strict, ok);
376 if (ok) {
377 PythonQtValueStorage_ADD_VALUE(global_valueStorage, unsigned long, val, ptr);
378 }
379 }
380 break;
381 case QMetaType::Bool:
382 {
383 bool val = PyObjGetBool(obj, strict, ok);
384 if (ok) {
385 PythonQtValueStorage_ADD_VALUE(global_valueStorage, bool, val, ptr);
386 }
387 }
388 break;
389 case QMetaType::Int:
390 {
391 int val = PyObjGetInt(obj, strict, ok);
392 if (ok) {
393 PythonQtValueStorage_ADD_VALUE(global_valueStorage, int, val, ptr);
394 }
395 }
396 break;
397 case QMetaType::UInt:
398 {
399 unsigned int val = (unsigned int)PyObjGetLongLong(obj, strict, ok);
400 if (ok) {
401 PythonQtValueStorage_ADD_VALUE(global_valueStorage, unsigned int, val, ptr);
402 }
403 }
404 break;
405 case QMetaType::QChar:
406 {
407 int val = PyObjGetInt(obj, strict, ok);
408 if (ok) {
409 PythonQtValueStorage_ADD_VALUE(global_valueStorage, short, val, ptr);
410 }
411 }
412 break;
413 case QMetaType::Float:
414 {
415 float val = (float)PyObjGetDouble(obj, strict, ok);
416 if (ok) {
417 PythonQtValueStorage_ADD_VALUE(global_valueStorage, float, val, ptr);
418 }
419 }
420 break;
421 case QMetaType::Double:
422 {
423 double val = (double)PyObjGetDouble(obj, strict, ok);
424 if (ok) {
425 PythonQtValueStorage_ADD_VALUE(global_valueStorage, double, val, ptr);
426 }
427 }
428 break;
429 case QMetaType::LongLong:
430 {
431 qint64 val = PyObjGetLongLong(obj, strict, ok);
432 if (ok) {
433 PythonQtValueStorage_ADD_VALUE(global_valueStorage, qint64, val, ptr);
434 }
435 }
436 break;
437 case QMetaType::ULongLong:
438 {
439 quint64 val = PyObjGetULongLong(obj, strict, ok);
440 if (ok) {
441 PythonQtValueStorage_ADD_VALUE(global_valueStorage, quint64, val, ptr);
442 }
443 }
444 break;
445 case QMetaType::QByteArray:
446 {
447 QByteArray bytes = PyObjGetBytes(obj, strict, ok);
448 if (ok) {
449 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant(bytes), ptr);
450 ptr = (void*)((QVariant*)ptr)->constData();
451 }
452 }
453 break;
454 case QMetaType::QString:
455 {
456 QString str = PyObjGetString(obj, strict, ok);
457 if (ok) {
458 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant(str), ptr);
459 ptr = (void*)((QVariant*)ptr)->constData();
460 }
461 }
462 break;
463 case QMetaType::QStringList:
464 {
465 QStringList l = PyObjToStringList(obj, strict, ok);
466 if (ok) {
467 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant(l), ptr);
468 ptr = (void*)((QVariant*)ptr)->constData();
469 }
470 }
471 break;
472
473 case PythonQtMethodInfo::Variant:
474 {
475 QVariant v = PyObjToQVariant(obj);
476 if (v.isValid()) {
477 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, v, ptr);
478 }
479 }
480 break;
481 default:
482 {
483 if (info.typeId == PythonQtMethodInfo::Unknown) {
484 // check for enum case
485 if (PythonQt::priv()->isEnumType(meta, info.name)) {
486 unsigned int val = (unsigned int)PyObjGetLongLong(obj, strict, ok);
487 if (ok) {
488 PythonQtValueStorage_ADD_VALUE(global_valueStorage, unsigned int, val, ptr);
489 return ptr;
490 }
491 }
492 }
493 if (info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) {
494 // check for QList<AnyPtr*> case, where we will use a QList<void*> QVariant
495 if (info.name.startsWith("QList<")) {
496 QByteArray innerType = info.name.mid(6,info.name.length()-7);
497 if (innerType.endsWith("*")) {
498 innerType.truncate(innerType.length()-1);
499 static int id = QMetaType::type("QList<void*>");
500 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, QVariant::Type(id), ptr);
501 ptr = (void*)((QVariant*)ptr)->constData();
502 ok = ConvertPythonListToQListOfType(obj, (QList<void*>*)ptr, innerType, strict);
503 if (ok) {
504 return ptr;
505 } else {
506 return NULL;
507 }
508 }
509 }
510 }
511
512 // for all other types, we use the same qvariant conversion and pass out the constData of the variant:
513 QVariant v = PyObjToQVariant(obj, info.typeId);
514 if (v.isValid()) {
515 PythonQtValueStorage_ADD_VALUE(global_variantStorage, QVariant, v, ptr);
516 ptr = (void*)((QVariant*)ptr)->constData();
517 }
518 }
519 }
520 }
521 return ptr;
522 }
523
524
525 QStringList PythonQtConv::PyObjToStringList(PyObject* val, bool strict, bool& ok) {
526 QStringList v;
527 ok = false;
528 // if we are strict, we do not want to convert a string to a stringlist
529 // (strings in python are detected to be sequences)
530 if (strict &&
531 (val->ob_type == &PyString_Type ||
532 PyUnicode_Check(val))) {
533 ok = false;
534 return v;
535 }
536 if (PySequence_Check(val)) {
537 int count = PySequence_Size(val);
538 for (int i = 0;i<count;i++) {
539 PyObject* value = PySequence_GetItem(val,i);
540 v.append(PyObjGetString(value,false,ok));
541 }
542 ok = true;
543 }
544 return v;
545 }
546
547 QString PythonQtConv::PyObjGetRepresentation(PyObject* val)
548 {
549 QString r;
550 PyObject* str = PyObject_Repr(val);
551 if (str) {
552 r = QString(PyString_AS_STRING(str));
553 Py_DECREF(str);
554 }
555 return r;
556 }
557
558 QString PythonQtConv::PyObjGetString(PyObject* val, bool strict, bool& ok) {
559 QString r;
560 ok = true;
561 if (val->ob_type == &PyString_Type) {
562 r = QString(PyString_AS_STRING(val));
563 } else if (PyUnicode_Check(val)) {
564 #ifdef WIN32
565 r = QString::fromUtf16(PyUnicode_AS_UNICODE(val));
566 #else
567 PyObject *ptmp = PyUnicode_AsUTF8String(val);
568 if(ptmp) {
569 r = QString::fromUtf8(PyString_AS_STRING(ptmp));
570 Py_DECREF(ptmp);
571 }
572 #endif
573 } else if (!strict) {
574 // EXTRA: could also use _Unicode, but why should we?
575 PyObject* str = PyObject_Str(val);
576 if (str) {
577 r = QString(PyString_AS_STRING(str));
578 Py_DECREF(str);
579 } else {
580 ok = false;
581 }
582 } else {
583 ok = false;
584 }
585 return r;
586 }
587
588 QByteArray PythonQtConv::PyObjGetBytes(PyObject* val, bool strict, bool& ok) {
589 QByteArray r;
590 ok = true;
591 if (val->ob_type == &PyString_Type) {
592 long size = PyString_GET_SIZE(val);
593 r = QByteArray(PyString_AS_STRING(val), size);
594 } else {
595 ok = false;
596 }
597 return r;
598 }
599
600 bool PythonQtConv::PyObjGetBool(PyObject* val, bool strict, bool &ok) {
601 bool d = false;
602 ok = false;
603 if (val == Py_False) {
604 d = false;
605 ok = true;
606 } else if (val == Py_True) {
607 d = true;
608 ok = true;
609 } else if (!strict) {
610 d = PyObjGetInt(val, false, ok)!=0;
611 ok = true;
612 }
613 return d;
614 }
615
616 int PythonQtConv::PyObjGetInt(PyObject* val, bool strict, bool &ok) {
617 int d = 0;
618 ok = true;
619 if (val->ob_type == &PyInt_Type) {
620 d = PyInt_AS_LONG(val);
621 } else if (!strict) {
622 if (val->ob_type == &PyFloat_Type) {
623 d = floor(PyFloat_AS_DOUBLE(val));
624 } else if (val->ob_type == &PyLong_Type) {
625 // handle error on overflow!
626 d = PyLong_AsLong(val);
627 } else if (val == Py_False) {
628 d = 0;
629 } else if (val == Py_True) {
630 d = 1;
631 } else {
632 ok = false;
633 }
634 } else {
635 ok = false;
636 }
637 return d;
638 }
639
640 qint64 PythonQtConv::PyObjGetLongLong(PyObject* val, bool strict, bool &ok) {
641 qint64 d = 0;
642 ok = true;
643 if (val->ob_type == &PyInt_Type) {
644 d = PyInt_AS_LONG(val);
645 } else if (val->ob_type == &PyLong_Type) {
646 d = PyLong_AsLongLong(val);
647 } else if (!strict) {
648 if (val->ob_type == &PyFloat_Type) {
649 d = floor(PyFloat_AS_DOUBLE(val));
650 } else if (val == Py_False) {
651 d = 0;
652 } else if (val == Py_True) {
653 d = 1;
654 } else {
655 ok = false;
656 }
657 } else {
658 ok = false;
659 }
660 return d;
661 }
662
663 quint64 PythonQtConv::PyObjGetULongLong(PyObject* val, bool strict, bool &ok) {
664 quint64 d = 0;
665 ok = true;
666 if (val->ob_type == &PyInt_Type) {
667 d = PyInt_AS_LONG(val);
668 } else if (val->ob_type == &PyLong_Type) {
669 d = PyLong_AsLongLong(val);
670 } else if (!strict) {
671 if (val->ob_type == &PyFloat_Type) {
672 d = floor(PyFloat_AS_DOUBLE(val));
673 } else if (val == Py_False) {
674 d = 0;
675 } else if (val == Py_True) {
676 d = 1;
677 } else {
678 ok = false;
679 }
680 } else {
681 ok = false;
682 }
683 return d;
684 }
685
686 double PythonQtConv::PyObjGetDouble(PyObject* val, bool strict, bool &ok) {
687 double d = 0;
688 ok = true;
689 if (val->ob_type == &PyFloat_Type) {
690 d = PyFloat_AS_DOUBLE(val);
691 } else if (!strict) {
692 if (val->ob_type == &PyInt_Type) {
693 d = PyInt_AS_LONG(val);
694 } else if (val->ob_type == &PyLong_Type) {
695 d = PyLong_AsLong(val);
696 } else if (val == Py_False) {
697 d = 0;
698 } else if (val == Py_True) {
699 d = 1;
700 } else {
701 ok = false;
702 }
703 } else {
704 ok = false;
705 }
706 return d;
707 }
708
709 QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
710 {
711 QVariant v;
712 bool ok = true;
713
714 if (type==-1) {
715 // no special type requested
716 if (val->ob_type==&PyString_Type || val->ob_type==&PyUnicode_Type) {
717 type = QVariant::String;
718 } else if (val->ob_type==&PyInt_Type) {
719 type = QVariant::Int;
720 } else if (val->ob_type==&PyLong_Type) {
721 type = QVariant::LongLong;
722 } else if (val->ob_type==&PyFloat_Type) {
723 type = QVariant::Double;
724 } else if (val == Py_False || val == Py_True) {
725 type = QVariant::Bool;
726 } else if (val->ob_type == &PythonQtWrapper_Type) {
727 PythonQtWrapper* wrap = (PythonQtWrapper*)val;
728 // c++ wrapper, check if the class names of the c++ objects match
729 if (wrap->_info->isCPPWrapper()) {
730 // is this worth anything? we loose the knowledge of the cpp object type
731 v = qVariantFromValue(wrap->_wrappedPtr);
732 } else {
733 v = qVariantFromValue(wrap->_obj);
734 }
735 return v;
736 } else if (val->ob_type==&PyDict_Type) {
737 type = QVariant::Map;
738 } else if (val->ob_type==&PyList_Type || val->ob_type==&PyTuple_Type || PySequence_Check(val)) {
739 type = QVariant::List;
740 } else if (val == Py_None) {
741 // none is invalid
742 type = QVariant::Invalid;
743 } else if (val->ob_type == &PythonQtVariantWrapper_Type) {
744 PythonQtVariantWrapper* varWrap = (PythonQtVariantWrapper*)val;
745 if (varWrap->_variant->userType() == type) {
746 v = *varWrap->_variant;
747 return v;
748 }
749 } else {
750 // this used to be:
751 // type = QVariant::String;
752 // but now we want to transport the Python Objects directly:
753 PythonQtObjectPtr o(val);
754 v = qVariantFromValue(o);
755 return v;
756 }
757 }
758 // special type request:
759 switch (type) {
760 case QVariant::Invalid:
761 return v;
762 break;
763 case QVariant::Int:
764 {
765 int d = PyObjGetInt(val, false, ok);
766 if (ok) return QVariant(d);
767 }
768 break;
769 case QVariant::UInt:
770 {
771 int d = PyObjGetInt(val, false,ok);
772 if (ok) v = QVariant((unsigned int)d);
773 }
774 break;
775 case QVariant::Bool:
776 {
777 int d = PyObjGetBool(val,false,ok);
778 if (ok) v = QVariant((bool)(d!=0));
779 }
780 break;
781 case QVariant::Double:
782 {
783 double d = PyObjGetDouble(val,false,ok);
784 if (ok) v = QVariant(d);
785 break;
786 }
787 case QMetaType::Float:
788 {
789 float d = (float) PyObjGetDouble(val,false,ok);
790 if (ok) v = qVariantFromValue(d);
791 break;
792 }
793 case QMetaType::Long:
794 {
795 long d = (long) PyObjGetLongLong(val,false,ok);
796 if (ok) v = qVariantFromValue(d);
797 break;
798 }
799 case QMetaType::ULong:
800 {
801 unsigned long d = (unsigned long) PyObjGetLongLong(val,false,ok);
802 if (ok) v = qVariantFromValue(d);
803 break;
804 }
805 case QMetaType::Short:
806 {
807 short d = (short) PyObjGetInt(val,false,ok);
808 if (ok) v = qVariantFromValue(d);
809 break;
810 }
811 case QMetaType::UShort:
812 {
813 unsigned short d = (unsigned short) PyObjGetInt(val,false,ok);
814 if (ok) v = qVariantFromValue(d);
815 break;
816 }
817 case QMetaType::Char:
818 {
819 char d = (char) PyObjGetInt(val,false,ok);
820 if (ok) v = qVariantFromValue(d);
821 break;
822 }
823 case QMetaType::UChar:
824 {
825 unsigned char d = (unsigned char) PyObjGetInt(val,false,ok);
826 if (ok) v = qVariantFromValue(d);
827 break;
828 }
829
830 case QVariant::ByteArray:
831 case QVariant::String:
832 {
833 bool ok;
834 v = QVariant(PyObjGetString(val, false, ok));
835 }
836 break;
837
838 // these are important for MeVisLab
839 case QVariant::Map:
840 {
841 if (PyMapping_Check(val)) {
842 QMap<QString,QVariant> map;
843 PyObject* items = PyMapping_Items(val);
844 if (items) {
845 int count = PyList_Size(items);
846 PyObject* value;
847 PyObject* key;
848 PyObject* tuple;
849 for (int i = 0;i<count;i++) {
850 tuple = PyList_GetItem(items,i);
851 key = PyTuple_GetItem(tuple, 0);
852 value = PyTuple_GetItem(tuple, 1);
853 map.insert(PyObjGetString(key), PyObjToQVariant(value,-1));
854 }
855 Py_DECREF(items);
856 v = map;
857 }
858 }
859 }
860 break;
861 case QVariant::List:
862 if (PySequence_Check(val)) {
863 QVariantList list;
864 int count = PySequence_Size(val);
865 PyObject* value;
866 for (int i = 0;i<count;i++) {
867 value = PySequence_GetItem(val,i);
868 list.append(PyObjToQVariant(value, -1));
869 }
870 v = list;
871 }
872 break;
873 case QVariant::StringList:
874 {
875 bool ok;
876 QStringList l = PyObjToStringList(val, false, ok);
877 if (ok) {
878 v = l;
879 }
880 }
881 break;
882
883 default:
884 if (val->ob_type == &PythonQtVariantWrapper_Type) {
885 PythonQtVariantWrapper* varWrap = (PythonQtVariantWrapper*)val;
886 if (varWrap->_variant->userType() == type) {
887 v = *varWrap->_variant;
888 }
889 } else {
890 v = QVariant();
891 }
892 }
893 return v;
894 }
895
896 PyObject* PythonQtConv::QStringToPyObject(const QString& str)
897 {
898 if (str.isNull()) {
899 return PyString_FromString("");
900 } else {
901 #ifdef WIN32
902 // return PyString_FromString(str.toLatin1().data());
903 return PyUnicode_FromUnicode(str.utf16(), str.length());
904 #else
905 return PyUnicode_DecodeUTF16((const char*)str.utf16(), str.length()*2, NULL, NULL);
906 #endif
907 }
908 }
909
910 PyObject* PythonQtConv::QStringListToPyObject(const QStringList& list)
911 {
912 PyObject* result = PyTuple_New(list.count());
913 int i = 0;
914 QString str;
915 foreach (str, list) {
916 PyTuple_SET_ITEM(result, i, PythonQtConv::QStringToPyObject(str));
917 i++;
918 }
919 // why is the error state bad after this?
920 PyErr_Clear();
921 return result;
922 }
923
924 PyObject* PythonQtConv::QStringListToPyList(const QStringList& list)
925 {
926 PyObject* result = PyList_New(list.count());
927 int i = 0;
928 for (QStringList::ConstIterator it = list.begin(); it!=list.end(); ++it) {
929 PyList_SET_ITEM(result, i, PythonQtConv::QStringToPyObject(*it));
930 i++;
931 }
932 return result;
933 }
934
935 PyObject* PythonQtConv::QVariantToPyObject(const QVariant& v)
936 {
937 return ConvertQtValueToPythonInternal(v.userType(), (void*)v.constData());
938 }
939
940 PyObject* PythonQtConv::QVariantMapToPyObject(const QVariantMap& m) {
941 PyObject* result = PyDict_New();
942 QVariantMap::const_iterator t = m.constBegin();
943 PyObject* key;
944 PyObject* val;
945 for (;t!=m.end();t++) {
946 key = QStringToPyObject(t.key());
947 val = QVariantToPyObject(t.value());
948 PyDict_SetItem(result, key, val);
949 Py_DECREF(key);
950 Py_DECREF(val);
951 }
952 return result;
953 }
954
955 PyObject* PythonQtConv::QVariantListToPyObject(const QVariantList& l) {
956 PyObject* result = PyTuple_New(l.count());
957 int i = 0;
958 QVariant v;
959 foreach (v, l) {
960 PyTuple_SET_ITEM(result, i, PythonQtConv::QVariantToPyObject(v));
961 i++;
962 }
963 // why is the error state bad after this?
964 PyErr_Clear();
965 return result;
966 }
967
968 PyObject* PythonQtConv::ConvertQListWithPointersToPython(QList<void*>* list, const QByteArray& type)
969 {
970 PyObject* result = PyTuple_New(list->count());
971 int i = 0;
972 foreach (void* value, *list) {
973 PyTuple_SET_ITEM(result, i, PythonQt::priv()->wrapPtr(value, type));
974 i++;
975 }
976 return result;
977 }
978
979 bool PythonQtConv::ConvertPythonListToQListOfType(PyObject* obj, QList<void*>* list, const QByteArray& type, bool strict)
980 {
981 bool result = false;
982 if (PySequence_Check(obj)) {
983 result = true;
984 int count = PySequence_Size(obj);
985 PyObject* value;
986 for (int i = 0;i<count;i++) {
987 value = PySequence_GetItem(obj,i);
988 if (value->ob_type == &PythonQtWrapper_Type) {
989 PythonQtWrapper* wrap = (PythonQtWrapper*)value;
990 // c++ wrapper, check if the class names of the c++ objects match
991 if (wrap->_info->isCPPWrapper()) {
992 //TODO: we could support inheritance on cpp wrappers as well
993 if (wrap->_info->wrappedCPPClassName() == type) {
994 list->append(wrap->_wrappedPtr);
995 } else {
996 result = false;
997 break;
998 }
999 } else {
1000 if (wrap->_info->inherits(type)) {
1001 list->append((void*)wrap->_obj);
1002 } else {
1003 result = false;
1004 break;
1005 }
1006 }
1007 }
1008 }
1009 }
1010 return result;
1011 }
1012
@@ -0,0 +1,127
1 #ifndef _PYTHONQTCONVERSION_H
2 #define _PYTHONQTCONVERSION_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtConversion.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQt.h"
46 #include "PythonQtMisc.h"
47 #include "PythonQtClassInfo.h"
48 #include "PythonQtMethodInfo.h"
49
50 #include <QWidget>
51
52 //! a static class that offers methods for type conversion
53 class PythonQtConv {
54
55 public:
56
57 //! get a ref counted True or False Python object
58 static PyObject* GetPyBool(bool val);
59
60 //! converts the Qt parameter given in \c data, interpreting it as a \c info parameter, into a Python object,
61 static PyObject* ConvertQtValueToPython(const PythonQtMethodInfo::ParameterInfo& info, void* data);
62
63 //! convert python object to Qt (according to the given parameter) and if the conversion should be strict, the meta object is passed in for enum resolving
64 static void* ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& info, PyObject* obj, bool strict, const QMetaObject* meta);
65
66 //! creates a data storage for the passed parameter type and returns a void pointer to be set as arg[0] of qt_metacall
67 static void* CreateQtReturnValue(const PythonQtMethodInfo::ParameterInfo& info);
68
69 //! converts QString to Python string (unicode!)
70 static PyObject* QStringToPyObject(const QString& str);
71
72 //! converts QStringList to Python tuple
73 static PyObject* QStringListToPyObject(const QStringList& list);
74
75 //! converts QStringList to Python list
76 static PyObject* QStringListToPyList(const QStringList& list);
77
78 //! get string representation of py object
79 static QString PyObjGetRepresentation(PyObject* val);
80
81 //! get string value from py object
82 static QString PyObjGetString(PyObject* val) { bool ok; QString s = PyObjGetString(val, false, ok); return s; }
83 //! get string value from py object
84 static QString PyObjGetString(PyObject* val, bool strict, bool &ok);
85 //! get bytes from py object
86 static QByteArray PyObjGetBytes(PyObject* val, bool strict, bool &ok);
87 //! get int from py object
88 static int PyObjGetInt(PyObject* val, bool strict, bool &ok);
89 //! get int64 from py object
90 static qint64 PyObjGetLongLong(PyObject* val, bool strict, bool &ok);
91 //! get int64 from py object
92 static quint64 PyObjGetULongLong(PyObject* val, bool strict, bool &ok);
93 //! get double from py object
94 static double PyObjGetDouble(PyObject* val, bool strict, bool &ok);
95 //! get bool from py object
96 static bool PyObjGetBool(PyObject* val, bool strict, bool &ok);
97
98 //! create a string list from python sequence
99 static QStringList PyObjToStringList(PyObject* val, bool strict, bool& ok);
100
101 //! convert python object to qvariant, if type is given it will try to create a qvariant of that type, otherwise
102 //! it will guess from the python type
103 static QVariant PyObjToQVariant(PyObject* val, int type = -1);
104
105 //! convert QVariant from PyObject
106 static PyObject* QVariantToPyObject(const QVariant& v);
107
108 static PyObject* QVariantMapToPyObject(const QVariantMap& m);
109 static PyObject* QVariantListToPyObject(const QVariantList& l);
110
111 public:
112
113 static PythonQtValueStorage<qint64, 128> global_valueStorage;
114 static PythonQtValueStorage<void*, 128> global_ptrStorage;
115 static PythonQtValueStorage<QVariant, 32> global_variantStorage;
116
117 protected:
118 //! converts the Qt parameter given in \c data, interpreting it as a \c type registered qvariant/meta type, into a Python object,
119 static PyObject* ConvertQtValueToPythonInternal(int type, void* data);
120
121 //! converts the list of pointers of given type to Python
122 static PyObject* ConvertQListWithPointersToPython(QList<void*>* list, const QByteArray& type);
123 //! tries to convert the python object to a QList of pointers to \c type objects, returns true on success
124 static bool ConvertPythonListToQListOfType(PyObject* obj, QList<void*>* list, const QByteArray& type, bool strict);
125 };
126
127 #endif
@@ -0,0 +1,61
1 #ifndef _PYTHONQTCPPWRAPPERFACTORY_H
2 #define _PYTHONQTCPPWRAPPERFACTORY_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtCppWrapperFactory.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-06
42 */
43 //----------------------------------------------------------------------------------
44
45 //! Factory interface for C++ classes that can be wrapped by QObject objects
46 /*! To create your own factory, derive PythonQtCppWrapperFactory and implement
47 the create() method.
48 A factory can be added to PythonQt by PythonQt::addCppWrapperFactory().
49 */
50 class PYTHONQT_EXPORT PythonQtCppWrapperFactory
51 {
52 public:
53 PythonQtCppWrapperFactory() {};
54 virtual ~PythonQtCppWrapperFactory() {};
55
56 //! create a wrapper for the given object
57 virtual QObject* create(const QByteArray& name, void *ptr) = 0;
58
59 };
60
61 #endif No newline at end of file
@@ -0,0 +1,462
1 #ifndef _PYTHONQTDOC_H
2 #define _PYTHONQTDOC_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtDoc.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-10
42 */
43 //----------------------------------------------------------------------------------
44
45 /*!
46 \if USE_GLOBAL_DOXYGEN_DOC
47 \page PythonQtPage PythonQt Overview
48 \else
49 \mainpage PythonQt Overview
50 \endif
51
52 \section Introduction
53
54 \b PythonQt is a dynamic Python (http://www.python.org) binding for Qt (http://www.trolltech.com).
55 It offers an easy way to embedd the Python scripting language into
56 your Qt applications. It makes heavy use of the QMetaObject system and thus requires Qt4.x.
57
58 In contrast to <a href="http://www.riverbankcomputing.co.uk/pyqt/">PyQt</a> , PythonQt is \b not a complete
59 Python wrapper around the complete Qt functionality. So if you are looking for a way to
60 write complete applications in Python using the Qt GUI, you should use PyQt.
61
62 If you are looking for a simple way to embed the Python language into your Qt Application
63 and to script parts of your application via Python, PythonQt is the way to go!
64
65 PythonQt is a stable library that was developed to make the Image Processing and Visualization platform MeVisLab (http://www.mevislab.de)
66 scriptable from Python.
67
68 \section Licensing
69
70 PythonQt is distributed under the LGPL license.
71
72 \section Download
73
74 PythonQt is hosted on SourceForge at http://sourceforge.net/projects/pythonqt , you can access it via SVN
75 or download a tarball.
76
77 \section Features
78
79 - Access all \b slots, \b properties, children and registered enums of any QObject derived class from Python
80 - Connecting Qt Signals to Python functions (both from within Python and from C++)
81 - Wrapping of C++ objects (which are not derived from QObject) via PythonQtCPPWrapperFactory
82 - Extending C++ and QObject derived classes with additional slots, static methods and constructors (see Decorators)
83 - StdOut/Err redirection to Qt signals instead of cout
84 - Interface for creating your own \c import replacement, so that Python scripts can be e.g. signed/verified before they are executed (PythonQtImportInterface)
85 - Mapping of plain-old-datatypes and ALL QVariant types to and from Python
86 - Support for wrapping of user QVariant types which are registerd via QMetaType
87 - Support for Qt namespace (with all enumerators)
88 - All PythonQt wrapped objects support the dir() statement, so that you can see easily which attributes a QObject, CPP object or QVariant has
89 - No preprocessing/wrapping tool needs to be started, PythonQt can script any QObject without prior knowledge about it (except for the MetaObject information from the \b moc)
90
91 \section Non-Features
92
93 Features that PythonQt does NOT support (and will not support):
94
95 - you can not derive from QObjects inside of Python, this would require wrapper generation like PyQt does
96 - you can only script QObject derived classes, for normal C++ classes you need to create a PythonQtCPPWrapperFactory and adequate wrapper classes or add decorator slots
97 - you can not access normal member functions of QObjects, only slots and properties, because the \b moc does not store normal member functions in the MetaObject system
98
99 \section Interface
100
101 The main interface to PythonQt is the PythonQt singleton.
102 PythonQt needs to be initialized via PythonQt::init() once.
103 Afterwards you communicate with the singleton via PythonQt::self().
104 PythonQt offers a default binding for the complete QWidget set, which
105 needs to be enabled via PythonQtGui::init().
106
107
108 \section Datatype Datatype Mapping
109
110 The following table shows the mapping between Python and Qt objects:
111 <table>
112 <tr><th>Qt/C++</th><th>Python</th></tr>
113 <tr><td>bool</td><td>bool</td></tr>
114 <tr><td>double</td><td>float</td></tr>
115 <tr><td>float</td><td>float</td></tr>
116 <tr><td>char/uchar,int/uint,short,ushort,QChar</td><td>integer</td></tr>
117 <tr><td>long</td><td>integer</td></tr>
118 <tr><td>ulong,longlong,ulonglong</td><td>long</td></tr>
119 <tr><td>QString</td><td>unicode string</td></tr>
120 <tr><td>QByteArray</td><td>str</td></tr>
121 <tr><td>char*</td><td>str</td></tr>
122 <tr><td>QStringList</td><td>tuple of unicode strings</td></tr>
123 <tr><td>QVariantList</td><td>tuple of objects</td></tr>
124 <tr><td>QVariantMap</td><td>dict of objects</td></tr>
125 <tr><td>QVariant</td><td>depends on type, see below</td></tr>
126 <tr><td>QSize, QRect and all other standard Qt QVariants</td><td>variant wrapper that supports complete API of the respective Qt classes</td></tr>
127 <tr><td>OwnRegisteredMetaType</td><td>variant wrapper, optionally with a wrapper provided by addVariantWrapper()</td></tr>
128 <tr><td>EnumType</td><td>integer (all enums that are known via the moc and the Qt namespace are supported)</td></tr>
129 <tr><td>QObject (and derived classes)</td><td>QObject wrapper</td></tr>
130 <tr><td>C++ object</td><td>CPP wrapper, either wrapped via PythonQtCPPWrapperFactory or just decorated with decorators</td></tr>
131 <tr><td>PyObject</td><td>PyObject</td></tr>
132 </table>
133
134 PyObject is passed as simple pointer, which allows to pass/return any Python Object directly to/from
135 a Qt slot.
136 QVariants are mapped recursively as given above, e.g. a dictionary can
137 contain lists of dictionaries of doubles.
138 For example a QVariant of type "String" is mapped to a python unicode string.
139 All Qt QVariant types are implemented, PythonQt supports the complete Qt API for these object.
140
141 \section QObject QObject Wrapping
142
143 All classes derived from QObject are automatically wrapped with a python wrapper class
144 when they become visible to the Python interpreter. This can happen via
145 - the PythonQt::addObject() method
146 - when a Qt \b slot returns a QObject derived object to python
147 - when a Qt \b signal contains a QObject and is connected to a python function
148
149 It is important that you call PythonQt::registerClass() for any QObject derived class
150 that may become visible to Python, except when you add it via PythonQt::addObject().
151 This will register the complete parent hierachy of the registered class, so that
152 when you register e.g. a QPushButton, QWidget will be registered as well (and all intermediate
153 parents).
154
155 From Python, you can talk to the returned QObjects in a natural way by calling
156 their slots and receiving the return values. You can also read/write all
157 properties of the objects as if they where normal python properties.
158
159 In addition to this, the wrapped objects support
160 - className() - returns a string that reprents the classname of the QObject
161 - help() - shows all properties, slots, enums, decorator slots and constructors of the object, in a printable form
162 - connect(signal, function) - connect the signal of the given object to a python function
163 - connect(signal, qobject, slot) - connect the signal of the given object to a slot of another QObject
164 - disconnect(signal, function) - disconnect the signal of the given object from a python function
165 - disconnect(signal, qobject, slot) - disconnect the signal of the given object from a slot of another QObject
166 - children() - returns the children of the object
167 - setParent(QObject) - set the parent
168 - QObject* parent() - get the parent
169
170 The below example shows how to connect signals in Python:
171
172 \code
173 # define a signal handler function
174 def someFunction(flag):
175 print flag
176
177 # button1 is a QPushButton that has been added to Python via addObject()
178 # connect the clicked signal to a python function:
179 button1.connect("clicked(bool)", someFunction)
180
181 \endcode
182
183 \section CPP CPP Wrapping
184
185 You can create dedicated wrapper QObject for any C++ class. This is done by deriving from PythonQtCPPWrapperFactory
186 and adding your factory via addWrapperFactory(). Whenever PythonQt encounters a CPP pointer (e.g. on a slot or signal)
187 and it does not known it as a QObject derived class, it will create a generic CPP wrapper. So even unknown C++ objects
188 can be passed through Python. If the wrapper factory supports the CPP class, a QObject wrapper will be created for each
189 instance that enters Python. An alternative to a complete wrapper via the wrapper factory are decorators, see \ref Decorators
190
191 \section MetaObject Meta Object/Class access
192
193 For each known CPP class, QObject derived class and QVariant type, PythonQt provides a Meta class. These meta classes are visible
194 inside of the "PythonQt" python module.
195
196 A Meta class supports:
197
198 - access to all declared enum values
199 - constructors
200 - static decorator slots
201 - help() and className()
202
203 From within Python, you can import the module "PythonQt" to access these meta objects and the Qt namespace.
204
205 \code
206 from PythonQt import *
207
208 # namespace access:
209 print Qt.AlignLeft
210
211 # constructors
212 a = QSize(12,13)
213 b = QFont()
214
215 # static method
216 QDate.currentDate()
217
218 # enum value
219 QFont.UltraCondensed
220
221 \endcode
222
223 \section Decorators Decorator slots
224
225 PythonQt introduces a new generic approach to extend any wrapped QObject or CPP object with
226
227 - constructors
228 - destructors (for CPP objects)
229 - additional slots
230 - static slots (callable on both the Meta object and the instances)
231
232 The idea behind decorators is that we wanted to make it as easy as possible to extend
233 wrapped objects. Since we already have an implementation for invoking any Qt Slot from
234 Python, it looked promising to use this approach for the extension of wrapped objects as well.
235 This avoids that the PythonQt user needs to care about how Python arguments are mapped from/to
236 Qt when he wants to create static methods, constructors and additional member functions.
237
238 The basic idea about decorators is to create a QObject derived class that implements slots
239 which take one of the above roles (e.g. constructor, destructor etc.) via a naming convention.
240 These slots are then assigned to other classes via the naming convention.
241
242 - QVariant new_SomeClassName(...) - defines a constructor for "SomeClassName" that returns a QVariant
243 - SomeClassName* new_SomeClassName(...) - defines a constructor for "SomeClassName" that returns a new object of type SomeClassName (where SomeClassName can be any CPP class, not just QObject classes)
244 - void delete_SomeClassName(SomeClassName* o) - defines a destructor, which should delete the passed in object o
245 - anything static_SomeClassName_someMethodName(...) - defines a static method that is callable on instances and the meta class
246 - anything someMethodName(SomeClassName* o, ...) - defines a slot that will be available on SomeClassName instances (and derived instances). When such a slot is called the first argument is the pointer to the instance and the rest of the arguments can be used to make a call on the instance.
247
248 The below example shows all kinds of decorators in action:
249
250 \code
251
252 // an example CPP object
253 class YourCPPObject {
254 public:
255 YourCPPObject(int arg1, float arg2) { a = arg1; b = arg2; }
256
257 float doSomething(int arg1) { return arg1*a*b; };
258
259 private:
260
261 int a;
262 float b;
263 };
264
265 // an example decorator
266 class ExampleDecorator : public QObject
267 {
268 Q_OBJECT
269
270 public slots:
271 // add a constructor to QSize variant that takes a QPoint
272 QVariant new_QSize(const QPoint& p) { return QSize(p.x(), p.y()); }
273
274 // add a constructor for QPushButton that takes a text and a parent widget
275 QPushButton* new_QPushButton(const QString& text, QWidget* parent=NULL) { return new QPushButton(text, parent); }
276
277 // add a constructor for a CPP object
278 YourCPPObject* new_YourCPPObject(int arg1, float arg2) { return new YourCPPObject(arg1, arg2); }
279
280 // add a destructor for a CPP object
281 void delete_YourCPPObject(YourCPPObject* obj) { delete obj; }
282
283 // add a static method to QWidget
284 QWidget* static_QWidget_mouseGrabber() { return QWidget::mouseGrabber(); }
285
286 // add an additional slot to QWidget (make move() callable, which is not declared as a slot in QWidget)
287 void move(QWidget* w, const QPoint& p) { w->move(p); }
288
289 // add an additional slot to QWidget, overloading the above move method
290 void move(QWidget* w, int x, int y) { w->move(x,y); }
291
292 // add a method to your own CPP object
293 int doSomething(YourCPPObject* obj, int arg1) { return obj->doSomething(arg1); }
294 };
295
296 ...
297
298 PythonQt::self()->addDecorators(new ExampleDecorator());
299 PythonQt::self()->registerClass(&QPushButton::staticMetaObject);
300 PythonQt::self()->registerCPPClassNames(QStringList() << "YourCPPObject");
301
302 \endcode
303
304 After you have registered an instance of the above ExampleDecorator, you can do the following from Python
305 (all these calls are mapped to the above decorator slots):
306
307 \code
308 from PythonQt import *
309
310 # call our new constructor of QSize
311 size = QSize(QPoint(1,2));
312
313 # call our new QPushButton constructor
314 button = QPushButton("sometext");
315
316 # call the move slot (overload1)
317 button.move(QPoint(0,0))
318
319 # call the move slot (overload2)
320 button.move(0,0)
321
322 # call the static method
323 grabber = QWidget.mouseWrapper();
324
325 # create a CPP object via constructor
326 yourCpp = YourCPPObject(1,11.5)
327
328 # call the wrapped method on CPP object
329 print yourCpp.doSomething(1);
330
331 # destructor will be called:
332 yourCpp = None
333
334 \endcode
335
336 \section Building
337
338 PythonQt requires at least Qt 4.2.2 (or higher) and Python 2.3, 2.4 or 2.5 on Windows, Linux and MacOS X.
339 To compile PythonQt, you will need a python developer installation which includes Python's header files and
340 the python2x.[lib | dll | so | dynlib].
341 The build scripts a currently set to use Python 2.5.
342 You may need to tweak the \b build/python.prf file to set the correct Python includes and libs on your system.
343
344 \subsection Windows
345
346 On Windows, the (non-source) Python Windows installer can be used.
347 Make sure that you use the same compiler, the current Python distribution is built
348 with Visual Studio 2003. If you want to use another compiler, you will need to build
349 Python yourself, using your compiler.
350
351 To build PythonQt, you need to set the environment variable \b PYTHON_PATH to point to the root
352 dir of the python installation and \b PYTHON_LIB to point to
353 the directory where the python lib file is located.
354
355 When using the prebuild Python installer, this will be:
356
357 \code
358 > set PYTHON_PATH = c:\Python25
359 > set PYTHON_LIB = c:\Python25\libs
360 \endcode
361
362 When using the python sources, this will be something like:
363
364 \code
365 > set PYTHON_PATH = c:\yourDir\Python-2.5.1\
366 > set PYTHON_LIB = c:\yourDir\Python-2.5.1\PCbuild8\Win32
367 \endcode
368
369 To build all, do the following (after setting the above variables):
370
371 \code
372 > cd PythonQtRoot
373 > vcvars32
374 > qmake
375 > nmake
376 \endcode
377
378 This should build everything. If Python can not be linked or include files can not be found,
379 you probably need to tweak \b build/python.prf
380
381 The tests and examples are located in PythonQt/lib.
382
383 \subsection Linux
384
385 On Linux, you need to install a Python-dev package.
386 If Python can not be linked or include files can not be found,
387 you probably need to tweak \b build/python.prf
388
389 To build PythonQt, just do a:
390
391 \code
392 > cd PythonQtRoot
393 > qmake
394 > make all
395 \endcode
396
397 The tests and examples are located in PythonQt/lib.
398 You should add PythonQt/lib to your LD_LIBRARY_PATH so that the runtime
399 linker can find the *.so files.
400
401 \subsection MacOsX
402
403 On Mac, Python is installed as a Framework, so you should not need to install it.
404 To build PythonQt, just do a:
405
406 \code
407 > cd PythonQtRoot
408 > qmake
409 > make all
410 \endcode
411
412 \section Tests
413
414 There is a unit test that tests most features of PythonQt, see the \b tests subdirectory for details.
415
416 \section Examples
417
418 Examples are available in the \b examples directory. The PyScriptingConsole implements a simple
419 interactive scripting console that shows how to script a simple application.
420
421 The following shows how to integrate PythonQt into you Qt application:
422
423 \code
424 #include "PythonQt.h"
425 #include <QApplication>
426 ...
427
428 int main( int argc, char **argv )
429 {
430
431 QApplication qapp(argc, argv);
432
433 // init PythonQt and Python itself
434 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
435
436 // get a smart pointer to the __main__ module of the Python interpreter
437 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
438
439 // add a QObject as variable of name "example" to the namespace of the __main__ module
440 PyExampleObject example;
441 PythonQt::self()->addObject(mainContext, "example", &example);
442
443 // register all other QObjects that you want to script and that are returned by your API
444 PythonQt::self()->registerClass(&QMainWindow::staticMetaObject);
445 PythonQt::self()->registerClass(&QPushButton::staticMetaObject);
446 ...
447
448 // do something
449 PythonQt::self()->runScript(mainContext, "print example\n");
450 PythonQt::self()->runScript(mainContext, "def multiply(a,b):\n return a*b;\n");
451 QVariantList args;
452 args << 42 << 47;
453 QVariant result = PythonQt::self()->call(mainContext,"multiply", args);
454 ...
455 \endcode
456
457
458 \section TODOs
459
460 - add more information on how to distribute an application that uses PythonQt, including the Python distribution
461
462 */
@@ -0,0 +1,68
1 #ifndef _PYTHONQTIMPORTFILEINTERFACE_H
2 #define _PYTHONQTIMPORTFILEINTERFACE_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtImportFileInterface.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include <QDateTime>
46 #include <QString>
47 #include <QByteArray>
48
49 //! defines an abstract interface to file access for the Python import statement
50 class PythonQtImportFileInterface {
51
52 public:
53 //! read the given file as byte array, without doing any linefeed translations
54 virtual QByteArray readFileAsBytes(const QString& filename) = 0;
55
56 //! read a source file, expects a readable Python text file with translated line feeds.
57 //! If the file can not be load OR it can not be verified, ok is set to false
58 virtual QByteArray readSourceFile(const QString& filename, bool& ok) = 0;
59
60 //! returns if the file exists
61 virtual bool exists(const QString& filename) = 0;
62
63 //! get the last modified data of a file
64 virtual QDateTime lastModifiedDate(const QString& filename) = 0;
65
66 };
67
68 #endif No newline at end of file
This diff has been collapsed as it changes many lines, (788 lines changed) Show them Hide them
@@ -0,0 +1,788
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtImporter.h
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 // This module was inspired by the zipimport.c module of the original
41 // Python distribution. Most of the functions are identical or slightly
42 // modified to do all the loading of Python files via an external file interface.
43 // In contrast to zipimport.c, this module also writes *.pyc files
44 // automatically if it has write access/is not inside of a zip file.
45 //----------------------------------------------------------------------------------
46
47 #include "PythonQtImporter.h"
48 #include "PythonQtImportFileInterface.h"
49 #include "PythonQt.h"
50 #include <QFile>
51 #include <QFileInfo>
52
53 #define IS_SOURCE 0x0
54 #define IS_BYTECODE 0x1
55 #define IS_PACKAGE 0x2
56
57 struct st_mlab_searchorder {
58 char suffix[14];
59 int type;
60 };
61
62 /* mlab_searchorder defines how we search for a module in the Zip
63 archive: we first search for a package __init__, then for
64 non-package .pyc, .pyo and .py entries. The .pyc and .pyo entries
65 are swapped by initmlabimport() if we run in optimized mode. Also,
66 '/' is replaced by SEP there. */
67 struct st_mlab_searchorder mlab_searchorder[] = {
68 {"/__init__.pyc", IS_PACKAGE | IS_BYTECODE},
69 {"/__init__.pyo", IS_PACKAGE | IS_BYTECODE},
70 {"/__init__.py", IS_PACKAGE | IS_SOURCE},
71 {".pyc", IS_BYTECODE},
72 {".pyo", IS_BYTECODE},
73 {".py", IS_SOURCE},
74 {"", 0}
75 };
76
77 extern PyTypeObject PythonQtImporter_Type;
78 PyObject *PythonQtImportError;
79
80 QString PythonQtImport::getSubName(const QString& str)
81 {
82 int idx = str.lastIndexOf('.');
83 if (idx!=-1) {
84 return str.mid(idx+1);
85 } else {
86 return str;
87 }
88 }
89
90 PythonQtImport::module_info PythonQtImport::getModuleInfo(PythonQtImporter* self, const QString& fullname)
91 {
92 QString subname;
93 struct st_mlab_searchorder *zso;
94
95 subname = getSubName(fullname);
96 QString path = *self->_path + "/" + subname;
97
98 QString test;
99 for (zso = mlab_searchorder; *zso->suffix; zso++) {
100 test = path + zso->suffix;
101 if (PythonQt::importInterface()->exists(test)) {
102 if (zso->type & IS_PACKAGE)
103 return MI_PACKAGE;
104 else
105 return MI_MODULE;
106 }
107 }
108 return MI_NOT_FOUND;
109 }
110
111
112 /* PythonQtImporter.__init__
113 Just store the path argument
114 */
115 int PythonQtImporter_init(PythonQtImporter *self, PyObject *args, PyObject *kwds)
116 {
117 self->_path = NULL;
118
119 const char* path;
120 if (!PyArg_ParseTuple(args, "s",
121 &path))
122 return -1;
123
124 if (PythonQt::importInterface()->exists(path)) {
125 //qDebug("path %s", path);
126 QString p(path);
127 const QStringList& ignorePaths = PythonQt::self()->getImporterIgnorePaths();
128 foreach(QString a, ignorePaths) {
129 if (a==p) {
130 PyErr_SetString(PythonQtImportError,
131 "path ignored");
132 return -1;
133 }
134 }
135
136 self->_path = new QString(p);
137
138 //mlabDebugConst("MLABPython", "PythonQtImporter init: " << *self->_path);
139
140 return 0;
141 } else {
142 PyErr_SetString(PythonQtImportError,
143 "path does not exist error");
144 return -1;
145 }
146 }
147
148 void
149 PythonQtImporter_dealloc(PythonQtImporter *self)
150 {
151 // free the stored path
152 if (self->_path) delete self->_path;
153 // free ourself
154 self->ob_type->tp_free((PyObject *)self);
155 }
156
157
158 /* Check whether we can satisfy the import of the module named by
159 'fullname'. Return self if we can, None if we can't. */
160 PyObject *
161 PythonQtImporter_find_module(PyObject *obj, PyObject *args)
162 {
163 PythonQtImporter *self = (PythonQtImporter *)obj;
164 PyObject *path = NULL;
165 char *fullname;
166
167 if (!PyArg_ParseTuple(args, "s|O:PythonQtImporter.find_module",
168 &fullname, &path))
169 return NULL;
170
171 // mlabDebugConst("MLABPython", "FindModule " << fullname << " in " << *self->_path);
172
173 PythonQtImport::module_info info = PythonQtImport::getModuleInfo(self, fullname);
174 if (info == PythonQtImport::MI_MODULE || info == PythonQtImport::MI_PACKAGE) {
175 Py_INCREF(self);
176 return (PyObject *)self;
177 } else {
178 Py_INCREF(Py_None);
179 return Py_None;
180 }
181 }
182
183 /* Load and return the module named by 'fullname'. */
184 PyObject *
185 PythonQtImporter_load_module(PyObject *obj, PyObject *args)
186 {
187 PythonQtImporter *self = (PythonQtImporter *)obj;
188 PyObject *code, *mod, *dict;
189 char *fullname;
190 QString modpath;
191 int ispackage;
192
193 if (!PyArg_ParseTuple(args, "s:PythonQtImporter.load_module",
194 &fullname))
195 return NULL;
196
197 code = PythonQtImport::getModuleCode(self, fullname, &ispackage, modpath);
198 if (code == NULL)
199 return NULL;
200
201 mod = PyImport_AddModule(fullname);
202 if (mod == NULL) {
203 Py_DECREF(code);
204 return NULL;
205 }
206 dict = PyModule_GetDict(mod);
207
208 if (PyDict_SetItemString(dict, "__loader__", (PyObject *)self) != 0)
209 goto error;
210
211 if (ispackage) {
212 PyObject *pkgpath, *fullpath;
213 QString subname = PythonQtImport::getSubName(fullname);
214 int err;
215
216 fullpath = PyString_FromFormat("%s%c%s",
217 self->_path->toLatin1().constData(),
218 SEP,
219 subname.toLatin1().constData());
220 if (fullpath == NULL)
221 goto error;
222
223 pkgpath = Py_BuildValue("[O]", fullpath);
224 Py_DECREF(fullpath);
225 if (pkgpath == NULL)
226 goto error;
227 err = PyDict_SetItemString(dict, "__path__", pkgpath);
228 Py_DECREF(pkgpath);
229 if (err != 0)
230 goto error;
231 }
232 mod = PyImport_ExecCodeModuleEx(fullname, code, (char*)modpath.toLatin1().data());
233 Py_DECREF(code);
234 if (Py_VerboseFlag)
235 PySys_WriteStderr("import %s # loaded from %s\n",
236 fullname, modpath);
237 return mod;
238 error:
239 Py_DECREF(code);
240 Py_DECREF(mod);
241 return NULL;
242 }
243
244
245 PyObject *
246 PythonQtImporter_get_data(PyObject *obj, PyObject *args)
247 {
248 // EXTRA, NOT YET IMPLEMENTED
249 return NULL;
250 }
251
252 PyObject *
253 PythonQtImporter_get_code(PyObject *obj, PyObject *args)
254 {
255 PythonQtImporter *self = (PythonQtImporter *)obj;
256 char *fullname;
257
258 if (!PyArg_ParseTuple(args, "s:PythonQtImporter.get_code", &fullname))
259 return NULL;
260
261 QString notused;
262 return PythonQtImport::getModuleCode(self, fullname, NULL, notused);
263 }
264
265 PyObject *
266 PythonQtImporter_get_source(PyObject *obj, PyObject *args)
267 {
268 // EXTRA, NOT YET IMPLEMENTED
269 /*
270 PythonQtImporter *self = (PythonQtImporter *)obj;
271 PyObject *toc_entry;
272 char *fullname, *subname, path[MAXPATHLEN+1];
273 int len;
274 enum module_info mi;
275
276 if (!PyArg_ParseTuple(args, "s:PythonQtImporter.get_source", &fullname))
277 return NULL;
278
279 mi = get_module_info(self, fullname);
280 if (mi == MI_ERROR)
281 return NULL;
282 if (mi == MI_NOT_FOUND) {
283 PyErr_Format(PythonQtImportError, "can't find module '%.200s'",
284 fullname);
285 return NULL;
286 }
287 subname = get_subname(fullname);
288
289 len = make_filename(PyString_AsString(self->prefix), subname, path);
290 if (len < 0)
291 return NULL;
292
293 if (mi == MI_PACKAGE) {
294 path[len] = SEP;
295 strcpy(path + len + 1, "__init__.py");
296 }
297 else
298 strcpy(path + len, ".py");
299
300 toc_entry = PyDict_GetItemString(self->files, path);
301 if (toc_entry != NULL)
302 return get_data(PyString_AsString(self->archive), toc_entry);
303
304 Py_INCREF(Py_None);
305 return Py_None;
306 */
307 return NULL;
308 }
309
310 PyDoc_STRVAR(doc_find_module,
311 "find_module(fullname, path=None) -> self or None.\n\
312 \n\
313 Search for a module specified by 'fullname'. 'fullname' must be the\n\
314 fully qualified (dotted) module name. It returns the PythonQtImporter\n\
315 instance itself if the module was found, or None if it wasn't.\n\
316 The optional 'path' argument is ignored -- it's there for compatibility\n\
317 with the importer protocol.");
318
319 PyDoc_STRVAR(doc_load_module,
320 "load_module(fullname) -> module.\n\
321 \n\
322 Load the module specified by 'fullname'. 'fullname' must be the\n\
323 fully qualified (dotted) module name. It returns the imported\n\
324 module, or raises PythonQtImportError if it wasn't found.");
325
326 PyDoc_STRVAR(doc_get_data,
327 "get_data(pathname) -> string with file data.\n\
328 \n\
329 Return the data associated with 'pathname'. Raise IOError if\n\
330 the file wasn't found.");
331
332 PyDoc_STRVAR(doc_get_code,
333 "get_code(fullname) -> code object.\n\
334 \n\
335 Return the code object for the specified module. Raise PythonQtImportError\n\
336 is the module couldn't be found.");
337
338 PyDoc_STRVAR(doc_get_source,
339 "get_source(fullname) -> source string.\n\
340 \n\
341 Return the source code for the specified module. Raise PythonQtImportError\n\
342 is the module couldn't be found, return None if the archive does\n\
343 contain the module, but has no source for it.");
344
345 PyMethodDef PythonQtImporter_methods[] = {
346 {"find_module", PythonQtImporter_find_module, METH_VARARGS,
347 doc_find_module},
348 {"load_module", PythonQtImporter_load_module, METH_VARARGS,
349 doc_load_module},
350 {"get_data", PythonQtImporter_get_data, METH_VARARGS,
351 doc_get_data},
352 {"get_code", PythonQtImporter_get_code, METH_VARARGS,
353 doc_get_code},
354 {"get_source", PythonQtImporter_get_source, METH_VARARGS,
355 doc_get_source},
356 {NULL, NULL} /* sentinel */
357 };
358
359
360 PyDoc_STRVAR(PythonQtImporter_doc,
361 "PythonQtImporter(path) -> PythonQtImporter object\n\
362 \n\
363 Create a new PythonQtImporter instance. 'path' must be a valid path on disk/or inside of a zip file known to MeVisLab\n\
364 . Every path is accepted.");
365
366 #define DEFERRED_ADDRESS(ADDR) 0
367
368 PyTypeObject PythonQtImporter_Type = {
369 PyObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type))
370 0,
371 "PythonQtImport.PythonQtImporter",
372 sizeof(PythonQtImporter),
373 0, /* tp_itemsize */
374 (destructor)PythonQtImporter_dealloc, /* tp_dealloc */
375 0, /* tp_print */
376 0, /* tp_getattr */
377 0, /* tp_setattr */
378 0, /* tp_compare */
379 0, /* tp_repr */
380 0, /* tp_as_number */
381 0, /* tp_as_sequence */
382 0, /* tp_as_mapping */
383 0, /* tp_hash */
384 0, /* tp_call */
385 0, /* tp_str */
386 PyObject_GenericGetAttr, /* tp_getattro */
387 0, /* tp_setattro */
388 0, /* tp_as_buffer */
389 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE , /* tp_flags */
390 PythonQtImporter_doc, /* tp_doc */
391 0, /* tp_traverse */
392 0, /* tp_clear */
393 0, /* tp_richcompare */
394 0, /* tp_weaklistoffset */
395 0, /* tp_iter */
396 0, /* tp_iternext */
397 PythonQtImporter_methods, /* tp_methods */
398 0, /* tp_members */
399 0, /* tp_getset */
400 0, /* tp_base */
401 0, /* tp_dict */
402 0, /* tp_descr_get */
403 0, /* tp_descr_set */
404 0, /* tp_dictoffset */
405 (initproc)PythonQtImporter_init, /* tp_init */
406 PyType_GenericAlloc, /* tp_alloc */
407 PyType_GenericNew, /* tp_new */
408 PyObject_Del, /* tp_free */
409 };
410
411
412 /* Given a buffer, return the long that is represented by the first
413 4 bytes, encoded as little endian. This partially reimplements
414 marshal.c:r_long() */
415 long
416 PythonQtImport::getLong(unsigned char *buf)
417 {
418 long x;
419 x = buf[0];
420 x |= (long)buf[1] << 8;
421 x |= (long)buf[2] << 16;
422 x |= (long)buf[3] << 24;
423 #if SIZEOF_LONG > 4
424 /* Sign extension for 64-bit machines */
425 x |= -(x & 0x80000000L);
426 #endif
427 return x;
428 }
429
430 FILE *
431 open_exclusive(const QString& filename)
432 {
433 #if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC)
434 /* Use O_EXCL to avoid a race condition when another process tries to
435 write the same file. When that happens, our open() call fails,
436 which is just fine (since it's only a cache).
437 XXX If the file exists and is writable but the directory is not
438 writable, the file will never be written. Oh well.
439 */
440 QFile::remove(filename);
441
442 int fd;
443 int flags = O_EXCL|O_CREAT|O_WRONLY|O_TRUNC;
444 #ifdef O_BINARY
445 flags |= O_BINARY; /* necessary for Windows */
446 #endif
447 #ifdef WIN32
448 fd = _wopen(filename.ucs2(), flags, 0666);
449 #else
450 fd = open(filename.local8Bit(), flags, 0666);
451 #endif
452 if (fd < 0)
453 return NULL;
454 return fdopen(fd, "wb");
455 #else
456 /* Best we can do -- on Windows this can't happen anyway */
457 return fopen(filename.toLocal8Bit().constData(), "wb");
458 #endif
459 }
460
461
462 void PythonQtImport::writeCompiledModule(PyCodeObject *co, const QString& filename, long mtime)
463 {
464 FILE *fp;
465
466 fp = open_exclusive(filename);
467 if (fp == NULL) {
468 if (Py_VerboseFlag)
469 PySys_WriteStderr(
470 "# can't create %s\n", filename.toLatin1().constData());
471 return;
472 }
473 #if PY_VERSION_HEX < 0x02040000
474 PyMarshal_WriteLongToFile(PyImport_GetMagicNumber(), fp);
475 #else
476 PyMarshal_WriteLongToFile(PyImport_GetMagicNumber(), fp, Py_MARSHAL_VERSION);
477 #endif
478 /* First write a 0 for mtime */
479 #if PY_VERSION_HEX < 0x02040000
480 PyMarshal_WriteLongToFile(0L, fp);
481 #else
482 PyMarshal_WriteLongToFile(0L, fp, Py_MARSHAL_VERSION);
483 #endif
484 #if PY_VERSION_HEX < 0x02040000
485 PyMarshal_WriteObjectToFile((PyObject *)co, fp);
486 #else
487 PyMarshal_WriteObjectToFile((PyObject *)co, fp, Py_MARSHAL_VERSION);
488 #endif
489 if (ferror(fp)) {
490 if (Py_VerboseFlag)
491 PySys_WriteStderr("# can't write %s\n", filename.toLatin1().constData());
492 /* Don't keep partial file */
493 fclose(fp);
494 QFile::remove(filename);
495 return;
496 }
497 /* Now write the true mtime */
498 fseek(fp, 4L, 0);
499 #if PY_VERSION_HEX < 0x02040000
500 PyMarshal_WriteLongToFile(mtime, fp);
501 #else
502 PyMarshal_WriteLongToFile(mtime, fp, Py_MARSHAL_VERSION);
503 #endif
504 fflush(fp);
505 fclose(fp);
506 if (Py_VerboseFlag)
507 PySys_WriteStderr("# wrote %s\n", filename.toLatin1().constData());
508 //#ifdef macintosh
509 // PyMac_setfiletype(cpathname, 'Pyth', 'PYC ');
510 //#endif
511 }
512
513 /* Given the contents of a .py[co] file in a buffer, unmarshal the data
514 and return the code object. Return None if it the magic word doesn't
515 match (we do this instead of raising an exception as we fall back
516 to .py if available and we don't want to mask other errors).
517 Returns a new reference. */
518 PyObject *
519 PythonQtImport::unmarshalCode(const QString& path, const QByteArray& data, time_t mtime)
520 {
521 PyObject *code;
522 // ugly cast, but Python API is not const safe
523 char *buf = (char*) data.constData();
524 int size = data.size();
525
526 if (size <= 9) {
527 PySys_WriteStderr("# %s has bad pyc data\n",
528 path.toLatin1().constData());
529 Py_INCREF(Py_None);
530 return Py_None;
531 }
532
533 if (getLong((unsigned char *)buf) != PyImport_GetMagicNumber()) {
534 if (Py_VerboseFlag)
535 PySys_WriteStderr("# %s has bad magic\n",
536 path.toLatin1().constData());
537 Py_INCREF(Py_None);
538 return Py_None;
539 }
540
541 if (mtime != 0 && !(getLong((unsigned char *)buf + 4) == mtime)) {
542 if (Py_VerboseFlag)
543 PySys_WriteStderr("# %s has bad mtime\n",
544 path.toLatin1().constData());
545 Py_INCREF(Py_None);
546 return Py_None;
547 }
548
549 code = PyMarshal_ReadObjectFromString(buf + 8, size - 8);
550 if (code == NULL)
551 return NULL;
552 if (!PyCode_Check(code)) {
553 Py_DECREF(code);
554 PyErr_Format(PyExc_TypeError,
555 "compiled module %.200s is not a code object",
556 path.toLatin1().constData());
557 return NULL;
558 }
559 return code;
560 }
561
562
563 /* Given a string buffer containing Python source code, compile it
564 return and return a code object as a new reference. */
565 PyObject *
566 PythonQtImport::compileSource(const QString& path, const QByteArray& data)
567 {
568 PyObject *code;
569 QByteArray data1 = data;
570 // in qt4, data is null terminated
571 // data1.resize(data.size()+1);
572 // data1.data()[data.size()-1] = 0;
573 code = Py_CompileString(data.data(), path.toLatin1().constData(),
574 Py_file_input);
575 return code;
576 }
577
578
579 /* Return the code object for the module named by 'fullname' from the
580 Zip archive as a new reference. */
581 PyObject *
582 PythonQtImport::getCodeFromData(const QString& path, int isbytecode,int ispackage, time_t mtime)
583 {
584 bool hasImporter = PythonQt::importInterface()!=NULL;
585
586 PyObject *code;
587
588 QByteArray qdata;
589 if (!hasImporter) {
590 QFile file(path);
591 QIODevice::OpenMode flags = QIODevice::ReadOnly;
592 if (!isbytecode) {
593 flags |= QIODevice::Text;
594 }
595 if (!file.open(flags)) {
596 return NULL;
597 }
598 qdata = file.readAll();
599 } else {
600 if (!isbytecode) {
601 // mlabDebugConst("MLABPython", "reading source " << path);
602 bool ok;
603 qdata = PythonQt::importInterface()->readSourceFile(path, ok);
604 if (!ok) {
605 // mlabErrorConst("PythonQtImporter","File could not be verified" << path);
606 return NULL;
607 }
608 if (qdata == " ") {
609 qdata.clear();
610 }
611 } else {
612 qdata = PythonQt::importInterface()->readFileAsBytes(path);
613 }
614 }
615
616 if (isbytecode) {
617 // mlabDebugConst("MLABPython", "reading bytecode " << path);
618 code = unmarshalCode(path, qdata, mtime);
619 }
620 else {
621 // mlabDebugConst("MLABPython", "compiling source " << path);
622 code = compileSource(path, qdata);
623 // save a pyc file if possible
624 QDateTime time;
625 time = hasImporter?PythonQt::importInterface()->lastModifiedDate(path):QFileInfo(path).lastModified();
626 writeCompiledModule((PyCodeObject*)code, path+"c", time.toTime_t());
627 }
628 return code;
629 }
630
631 time_t
632 PythonQtImport::getMTimeOfSource(const QString& path)
633 {
634 time_t mtime = 0;
635 QString path2 = path;
636 path2.truncate(path.length()-1);
637
638 bool hasImporter = PythonQt::importInterface()!=NULL;
639 if (hasImporter) {
640 if (PythonQt::importInterface()->exists(path2)) {
641 mtime = PythonQt::importInterface()->lastModifiedDate(path2).toTime_t();
642 }
643 } else {
644 if (QFile::exists(path2)) {
645 mtime = QFileInfo(path2).lastModified().toTime_t();
646 }
647 }
648 return mtime;
649 }
650
651 /* Get the code object associated with the module specified by
652 'fullname'. */
653 PyObject *
654 PythonQtImport::getModuleCode(PythonQtImporter *self, char *fullname,
655 int *p_ispackage, QString& modpath)
656 {
657 QString subname;
658 struct st_mlab_searchorder *zso;
659
660 subname = getSubName(fullname);
661 QString path = *self->_path + "/" + subname;
662
663 QString test;
664 for (zso = mlab_searchorder; *zso->suffix; zso++) {
665 PyObject *code = NULL;
666 test = path + zso->suffix;
667
668 if (Py_VerboseFlag > 1)
669 PySys_WriteStderr("# trying %s\n",
670 test.toLatin1().constData());
671 if (PythonQt::importInterface()->exists(test)) {
672 time_t mtime = 0;
673 int ispackage = zso->type & IS_PACKAGE;
674 int isbytecode = zso->type & IS_BYTECODE;
675
676 if (isbytecode)
677 mtime = getMTimeOfSource(test);
678 if (p_ispackage != NULL)
679 *p_ispackage = ispackage;
680 code = getCodeFromData(test, isbytecode, ispackage, mtime);
681 if (code == Py_None) {
682 Py_DECREF(code);
683 continue;
684 }
685 if (code != NULL)
686 modpath = test;
687 return code;
688 }
689 }
690 PyErr_Format(PythonQtImportError, "can't find module '%.200s'", fullname);
691
692 return NULL;
693 }
694
695 QString PythonQtImport::replaceExtension(const QString& str, const QString& ext)
696 {
697 QString r;
698 int i = str.lastIndexOf('.');
699 if (i!=-1) {
700 r = str.mid(0,i) + "." + ext;
701 } else {
702 r = str + "." + ext;
703 }
704 return r;
705 }
706
707 PyObject* PythonQtImport::getCodeFromPyc(const QString& file)
708 {
709 bool hasImporter = PythonQt::importInterface()!=NULL;
710
711 PyObject* code;
712 const static QString pycStr("pyc");
713 QString pyc = replaceExtension(file, pycStr);
714 if ((hasImporter && PythonQt::importInterface()->exists(pyc)) ||
715 (!hasImporter && QFile::exists(pyc))) {
716 time_t mtime = 0;
717 mtime = getMTimeOfSource(pyc);
718 code = getCodeFromData(pyc, true, false, mtime);
719 if (code != Py_None && code != NULL) {
720 return code;
721 }
722 if (code) {
723 Py_DECREF(code);
724 }
725 }
726 code = getCodeFromData(file,false,false,0);
727 return code;
728 }
729
730 /* Module init */
731
732 PyDoc_STRVAR(mlabimport_doc,
733 "Imports python files into MeVisLab, completely replaces internal python import");
734
735 void PythonQtImport::init()
736 {
737 PyObject *mod;
738
739 if (PyType_Ready(&PythonQtImporter_Type) < 0)
740 return;
741
742 /* Correct directory separator */
743 mlab_searchorder[0].suffix[0] = SEP;
744 mlab_searchorder[1].suffix[0] = SEP;
745 mlab_searchorder[2].suffix[0] = SEP;
746 if (Py_OptimizeFlag) {
747 /* Reverse *.pyc and *.pyo */
748 struct st_mlab_searchorder tmp;
749 tmp = mlab_searchorder[0];
750 mlab_searchorder[0] = mlab_searchorder[1];
751 mlab_searchorder[1] = tmp;
752 tmp = mlab_searchorder[3];
753 mlab_searchorder[3] = mlab_searchorder[4];
754 mlab_searchorder[4] = tmp;
755 }
756
757 mod = Py_InitModule4("PythonQtImport", NULL, mlabimport_doc,
758 NULL, PYTHON_API_VERSION);
759
760 PythonQtImportError = PyErr_NewException("PythonQtImport.PythonQtImportError",
761 PyExc_ImportError, NULL);
762 if (PythonQtImportError == NULL)
763 return;
764
765 Py_INCREF(PythonQtImportError);
766 if (PyModule_AddObject(mod, "PythonQtImportError",
767 PythonQtImportError) < 0)
768 return;
769
770 Py_INCREF(&PythonQtImporter_Type);
771 if (PyModule_AddObject(mod, "PythonQtImporter",
772 (PyObject *)&PythonQtImporter_Type) < 0)
773 return;
774
775 // set our importer into the path_hooks to handle all path on sys.path
776 PyObject* classobj = PyDict_GetItemString(PyModule_GetDict(mod), "PythonQtImporter");
777 PyObject* path_hooks = PySys_GetObject("path_hooks");
778 PyList_Append(path_hooks, classobj);
779
780 #ifndef WIN32
781 // reload the encodings module, because it might fail to custom import requirements (e.g. encryption).
782 PyObject* modules = PyImport_GetModuleDict();
783 PyObject* encodingsModule = PyDict_GetItemString(modules, "encodings");
784 if (encodingsModule != NULL) {
785 PyImport_ReloadModule(encodingsModule);
786 }
787 #endif
788 }
@@ -0,0 +1,127
1 #ifndef _PYTHONQTIMPORTER_
2 #define _PYTHONQTIMPORTER_
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtImporter.h
39 // \author Florian Link
40 // \author Last changed by $Author: stk $
41 // \date 2004-06
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "Python.h"
46 #include "structmember.h"
47 #include "osdefs.h"
48 #include "marshal.h"
49 #include "compile.h"
50 #include <time.h>
51
52 #include <qobject.h>
53 #include <qstring.h>
54
55
56 //! defines a python object that stores a Qt slot info
57 typedef struct _PythonQtImporter {
58 PyObject_HEAD
59 QString* _path;
60 } PythonQtImporter;
61
62
63 //! implements importing of python files into PythonQt
64 /*! also compiles/marshalls/unmarshalls py/pyc files and handles time stamps correctly
65 */
66 class PythonQtImport
67 {
68 public:
69 enum module_info {
70 MI_ERROR,
71 MI_NOT_FOUND,
72 MI_MODULE,
73 MI_PACKAGE
74 };
75
76 //! initialize
77 static void init();
78
79 //! writes the python code to disk, marshalling and writing the time stamp
80 static void writeCompiledModule(PyCodeObject *co, const QString& filename, long mtime);
81
82 /*! Given the contents of a .py[co] file in a buffer, unmarshal the data
83 and return the code object. Return None if it the magic word doesn't
84 match (we do this instead of raising an exception as we fall back
85 to .py if available and we don't want to mask other errors).
86 Returns a new reference. */
87 static PyObject *unmarshalCode(const QString& path, const QByteArray& data, time_t mtime);
88
89 //! Given a string buffer containing Python source code, compile it
90 //! return and return a code object as a new reference.
91 static PyObject *compileSource(const QString& path, const QByteArray& data);
92
93 //! Return the code object for the module named by 'fullname' from the
94 //! Zip archive as a new reference.
95 static PyObject *getCodeFromData(const QString& path, int isbytecode = 0, int ispackage = 0,
96 time_t mtime = 0);
97
98 //! Get the code object associated with the module specified by
99 //! 'fullname'.
100 static PyObject * getModuleCode(PythonQtImporter *self, char *fullname,
101 int *p_ispackage, QString& modpath);
102
103
104 //! gets the compiled code for the given *.py file if there is a valid pyc file, otherwise compiles the file and writes the pyc
105 static PyObject* getCodeFromPyc(const QString& file);
106
107 //! Return if module exists and is a package or a module
108 static module_info getModuleInfo(PythonQtImporter* self, const QString& fullname);
109
110 //! get the last name of a dot chain (first.second.last)
111 static QString getSubName(const QString& str);
112
113 //! Given a buffer, return the long that is represented by the first
114 //! 4 bytes, encoded as little endian. This partially reimplements
115 //! marshal.c:r_long()
116 static long getLong(unsigned char *buf);
117
118 //! get time stamp of file
119 static time_t getMTimeOfSource(const QString& path);
120
121 //! replace extension of file
122 static QString replaceExtension(const QString& str, const QString& ext);
123
124 };
125
126 #endif
127
@@ -0,0 +1,240
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtMetaObjectWrapper.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtMetaObjectWrapper.h"
43 #include <QObject>
44
45 #include "PythonQt.h"
46 #include "PythonQtSlot.h"
47 #include "PythonQtClassInfo.h"
48 #include "PythonQtConversion.h"
49
50 static void PythonQtMetaObjectWrapper_dealloc(PythonQtMetaObjectWrapper* self)
51 {
52 self->ob_type->tp_free((PyObject*)self);
53 }
54
55 static PyObject* PythonQtMetaObjectWrapper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
56 {
57 PythonQtMetaObjectWrapper *self;
58
59 self = (PythonQtMetaObjectWrapper *)type->tp_alloc(type, 0);
60 if (self != NULL) {
61 self->_info = NULL;
62 }
63 return (PyObject *)self;
64 }
65
66 static int PythonQtMetaObjectWrapper_init(PythonQtMetaObjectWrapper *self, PyObject *args, PyObject *kwds)
67 {
68 return 0;
69 }
70
71 PyObject *PythonQtMetaObjectWrapper_call(PyObject *func, PyObject *args, PyObject *kw) {
72 PythonQtMetaObjectWrapper* wrapper = (PythonQtMetaObjectWrapper*)func;
73 PyObject* result = NULL;
74 QString error;
75 PyObject* err = NULL;
76 if (wrapper->_info->constructors()) {
77 result = PythonQtSlotFunction_CallImpl(NULL, wrapper->_info->constructors(), args, kw);
78 err = PyErr_Occurred();
79 }
80 if (!result) {
81 QObject* v = NULL;
82 QListIterator<PythonQtConstructorHandler*> it(PythonQt::self()->constructorHandlers());
83 while (!v && it.hasNext()) {
84 v = it.next()->create(wrapper->_info->metaObject(), args, kw, error);
85 }
86 if (v) {
87 result = PythonQt::priv()->wrapQObject(v);
88 }
89 }
90 if (result) {
91 // change ownershipflag to be owned by PythonQt
92 if (result->ob_type == &PythonQtWrapper_Type) {
93 ((PythonQtWrapper*)result)->_ownedByPythonQt = true;
94 }
95 } else {
96 if (!wrapper->_info->constructors()) {
97 if (!err) {
98 if (error.isEmpty()) {
99 error = QString("No constructors available for ") + wrapper->_info->className();
100 }
101 PyErr_SetString(PyExc_ValueError, error.toLatin1().data());
102 }
103 }
104 }
105 return result;
106 }
107
108 static PyObject *PythonQtMetaObjectWrapper_classname(PythonQtMetaObjectWrapper* type)
109 {
110 return PyString_FromString((QString("Meta_") + type->_info->className()).toLatin1().data());
111 }
112
113 static PyObject *PythonQtMetaObjectWrapper_help(PythonQtMetaObjectWrapper* type)
114 {
115 return PythonQt::self()->helpCalled(type->_info);
116 }
117
118
119 static PyMethodDef PythonQtMetaObjectWrapper_methods[] = {
120 {"className", (PyCFunction)PythonQtMetaObjectWrapper_classname, METH_NOARGS,
121 "Return the classname of the object"
122 },
123 {"help", (PyCFunction)PythonQtMetaObjectWrapper_help, METH_NOARGS,
124 "Shows the help of available methods for this class"
125 },
126 {NULL} /* Sentinel */
127 };
128
129
130 static PyObject *PythonQtMetaObjectWrapper_getattro(PyObject *obj,PyObject *name)
131 {
132 const char *attributeName;
133 PythonQtMetaObjectWrapper *wt = (PythonQtMetaObjectWrapper *)obj;
134
135 if ((attributeName = PyString_AsString(name)) == NULL) {
136 return NULL;
137 }
138
139 PythonQtMemberInfo member = wt->_info->member(attributeName);
140 if (member._type == PythonQtMemberInfo::EnumValue) {
141 return PyInt_FromLong(member._enumValue);
142 }
143 if (member._type == PythonQtMemberInfo::Slot && member._slot->isClassDecorator()) {
144 return PythonQtSlotFunction_New(member._slot, obj, NULL);
145 }
146
147 // look for the interal methods (className(), help())
148 PyObject* internalMethod = Py_FindMethod( PythonQtMetaObjectWrapper_methods, obj, (char*)attributeName);
149 if (internalMethod) {
150 return internalMethod;
151 }
152 PyErr_Clear();
153
154 if (qstrcmp(attributeName, "__dict__")==0) {
155 QStringList l = wt->_info->memberList(true);
156 PyObject* dict = PyDict_New();
157 foreach (QString name, l) {
158 //PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data());
159 PyDict_SetItemString(dict, name.toLatin1().data(), Py_None);
160 //Py_DECREF(o);
161 }
162 return dict;
163 }
164
165 QString error = QString(wt->_info->className()) + " has no attribute named '" + QString(attributeName) + "'";
166 PyErr_SetString(PyExc_AttributeError, error.toLatin1().data());
167 return NULL;
168 }
169
170 static PyObject * PythonQtMetaObjectWrapper_repr(PyObject * obj)
171 {
172 PythonQtMetaObjectWrapper* wt = (PythonQtMetaObjectWrapper*)obj;
173 if (wt->_info->isCPPWrapper()) {
174 return PyString_FromFormat("%s Class (C++ wrapped by %s)", wt->_info->className(), wt->_info->metaObject()->className());
175 } else {
176 return PyString_FromFormat("%s Class", wt->_info->className());
177 }
178 }
179
180 static int PythonQtMetaObjectWrapper_compare(PyObject * obj1, PyObject * obj2)
181 {
182 if (obj1->ob_type == &PythonQtMetaObjectWrapper_Type &&
183 obj2->ob_type == &PythonQtMetaObjectWrapper_Type) {
184
185 PythonQtMetaObjectWrapper* w1 = (PythonQtMetaObjectWrapper*)obj1;
186 PythonQtMetaObjectWrapper* w2 = (PythonQtMetaObjectWrapper*)obj2;
187 if (w1->_info == w2->_info) {
188 return 0;
189 } else {
190 return -1;
191 }
192 } else {
193 return -1;
194 }
195 }
196
197 PyTypeObject PythonQtMetaObjectWrapper_Type = {
198 PyObject_HEAD_INIT(NULL)
199 0, /*ob_size*/
200 "PythonQt.PythonQtMetaObjectWrapper", /*tp_name*/
201 sizeof(PythonQtMetaObjectWrapper), /*tp_basicsize*/
202 0, /*tp_itemsize*/
203 (destructor)PythonQtMetaObjectWrapper_dealloc, /*tp_dealloc*/
204 0, /*tp_print*/
205 0, /*tp_getattr*/
206 0, /*tp_setattr*/
207 PythonQtMetaObjectWrapper_compare, /*tp_compare*/
208 PythonQtMetaObjectWrapper_repr, /*tp_repr*/
209 0, /*tp_as_number*/
210 0, /*tp_as_sequence*/
211 0, /*tp_as_mapping*/
212 0, /*tp_hash */
213 PythonQtMetaObjectWrapper_call, /*tp_call*/
214 0, /*tp_str*/
215 PythonQtMetaObjectWrapper_getattro, /*tp_getattro*/
216 0, /*tp_setattro*/
217 0, /*tp_as_buffer*/
218 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
219 "PythonQtMetaObjectWrapper object", /* tp_doc */
220 0, /* tp_traverse */
221 0, /* tp_clear */
222 0, /* tp_richcompare */
223 0, /* tp_weaklistoffset */
224 0, /* tp_iter */
225 0, /* tp_iternext */
226 0, /* tp_methods */
227 0, /* tp_members */
228 0, /* tp_getset */
229 0, /* tp_base */
230 0, /* tp_dict */
231 0, /* tp_descr_get */
232 0, /* tp_descr_set */
233 0, /* tp_dictoffset */
234 (initproc)PythonQtMetaObjectWrapper_init, /* tp_init */
235 0, /* tp_alloc */
236 PythonQtMetaObjectWrapper_new, /* tp_new */
237 };
238
239 //-------------------------------------------------------
240
@@ -0,0 +1,76
1 #ifndef _PYTHONQTMETAOBJECTWRAPPER_H
2 #define _PYTHONQTMETAOBJECTWRAPPER_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtMetaObjectWrapper.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include <Python.h>
46
47 #include "structmember.h"
48 #include "methodobject.h"
49 #include "compile.h"
50 #include "eval.h"
51 #include <QString>
52
53 class PythonQtClassInfo;
54 class QObject;
55 struct QMetaObject;
56
57 extern PyTypeObject PythonQtMetaObjectWrapper_Type;
58
59 //---------------------------------------------------------------
60 //! a Python wrapper object for Qt meta objects
61 typedef struct {
62 PyObject_HEAD
63
64 //! the class information (which contains the meta object as well)
65 PythonQtClassInfo* _info;
66
67 } PythonQtMetaObjectWrapper;
68
69 //---------------------------------------------------------------
70 // an abstact class for handling construction of objects
71 class PythonQtConstructorHandler {
72 public:
73 virtual QObject* create(const QMetaObject* meta, PyObject *args, PyObject *kw, QString& error) = 0;
74 };
75
76 #endif No newline at end of file
@@ -0,0 +1,294
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtMethodInfo.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtMethodInfo.h"
43 #include <iostream>
44
45 QHash<QByteArray, PythonQtMethodInfo*> PythonQtMethodInfo::_cachedSignatures;
46 QHash<QByteArray, QByteArray> PythonQtMethodInfo::_parameterNameAliases;
47
48 PythonQtMethodInfo::PythonQtMethodInfo(const QMetaMethod& meta)
49 {
50 #ifdef PYTHONQT_DEBUG
51 QByteArray sig(meta.signature());
52 sig = sig.mid(sig.indexOf('('));
53 QByteArray fullSig = QByteArray(meta.typeName()) + " " + sig;
54 std::cout << "caching " << fullSig.data() << std::endl;
55 #endif
56
57 ParameterInfo type;
58 fillParameterInfo(type, QByteArray(meta.typeName()));
59 _parameters.append(type);
60 QByteArray name;
61 QList<QByteArray> names = meta.parameterTypes();
62 foreach (name, names) {
63 fillParameterInfo(type, name);
64 _parameters.append(type);
65 }
66 }
67
68
69 const PythonQtMethodInfo* PythonQtMethodInfo::getCachedMethodInfo(const QMetaMethod& signal)
70 {
71 QByteArray sig(signal.signature());
72 sig = sig.mid(sig.indexOf('('));
73 QByteArray fullSig = QByteArray(signal.typeName()) + " " + sig;
74 PythonQtMethodInfo* result = _cachedSignatures.value(fullSig);
75 if (!result) {
76 result = new PythonQtMethodInfo(signal);
77 _cachedSignatures.insert(fullSig, result);
78 }
79 return result;
80 }
81
82 void PythonQtMethodInfo::fillParameterInfo(ParameterInfo& type, const QByteArray& orgName)
83 {
84 QByteArray name = orgName;
85
86 int len = name.length();
87 if (len>0) {
88 if (strncmp(name.constData(), "const ", 6)==0) {
89 name = name.mid(6);
90 len -= 6;
91 type.isConst = true;
92 } else {
93 type.isConst = false;
94 }
95 // EXTRA: & references are not yet supported, while const & is removed by moc
96 while (name.at(len-1) == '*') {
97 len--;
98 }
99 if (len!=name.length()) {
100 name = name.left(len);
101 type.isPointer = true;
102 } else {
103 type.isPointer = false;
104 }
105 QByteArray alias = _parameterNameAliases.value(name);
106 if (!alias.isEmpty()) {
107 name = alias;
108 }
109
110 type.typeId = nameToType(name);
111 if (!type.isPointer && type.typeId == Unknown) {
112 type.typeId = QMetaType::type(name.constData());
113 if (type.typeId == QMetaType::Void) {
114 type.typeId = Unknown;
115 }
116 }
117 type.name = name;
118 } else {
119 type.typeId = QMetaType::Void;
120 type.isPointer = false;
121 type.isConst = false;
122 }
123 }
124
125 int PythonQtMethodInfo::nameToType(const char* name)
126 {
127 if (_parameterTypeDict.isEmpty()) {
128 // we could also use QMetaType::nameToType, but that does a string compare search
129 // and does not support QVariant
130
131 // QMetaType names
132 _parameterTypeDict.insert("long", QMetaType::Long);
133 _parameterTypeDict.insert("int", QMetaType::Int);
134 _parameterTypeDict.insert("short", QMetaType::Short);
135 _parameterTypeDict.insert("char", QMetaType::Char);
136 _parameterTypeDict.insert("ulong", QMetaType::ULong);
137 _parameterTypeDict.insert("unsigned long", QMetaType::ULong);
138 _parameterTypeDict.insert("uint", QMetaType::UInt);
139 _parameterTypeDict.insert("unsigned int", QMetaType::UInt);
140 _parameterTypeDict.insert("ushort", QMetaType::UShort);
141 _parameterTypeDict.insert("unsigned short", QMetaType::UShort);
142 _parameterTypeDict.insert("uchar", QMetaType::UChar);
143 _parameterTypeDict.insert("unsigned char", QMetaType::UChar);
144 _parameterTypeDict.insert("bool", QMetaType::Bool);
145 _parameterTypeDict.insert("float", QMetaType::Float);
146 _parameterTypeDict.insert("double", QMetaType::Double);
147 _parameterTypeDict.insert("qreal", QMetaType::Double);
148 _parameterTypeDict.insert("QChar", QMetaType::QChar);
149 _parameterTypeDict.insert("QByteArray", QMetaType::QByteArray);
150 _parameterTypeDict.insert("Q3CString", QMetaType::QByteArray);
151 _parameterTypeDict.insert("QString", QMetaType::QString);
152 _parameterTypeDict.insert("", QMetaType::Void);
153 _parameterTypeDict.insert("void", QMetaType::Void);
154 // QVariant names
155 _parameterTypeDict.insert("Q_LLONG", QMetaType::LongLong);
156 _parameterTypeDict.insert("Q_ULLONG", QMetaType::ULongLong);
157 _parameterTypeDict.insert("qlonglong", QMetaType::LongLong);
158 _parameterTypeDict.insert("qulonglong", QMetaType::ULongLong);
159 _parameterTypeDict.insert("qint64", QMetaType::LongLong);
160 _parameterTypeDict.insert("quint64", QMetaType::ULongLong);
161 _parameterTypeDict.insert("QIconSet", QMetaType::QIcon);
162 _parameterTypeDict.insert("QVariantMap", QMetaType::QVariantMap);
163 _parameterTypeDict.insert("QVariantList", QMetaType::QVariantList);
164 _parameterTypeDict.insert("QMap<QString,QVariant>", QMetaType::QVariantMap);
165 _parameterTypeDict.insert("QList<QVariant>", QMetaType::QVariantList);
166 _parameterTypeDict.insert("QStringList", QMetaType::QStringList);
167 _parameterTypeDict.insert("QBitArray", QMetaType::QBitArray);
168 _parameterTypeDict.insert("QDate", QMetaType::QDate);
169 _parameterTypeDict.insert("QTime", QMetaType::QTime);
170 _parameterTypeDict.insert("QDateTime", QMetaType::QDateTime);
171 _parameterTypeDict.insert("QUrl", QMetaType::QUrl);
172 _parameterTypeDict.insert("QLocale", QMetaType::QLocale);
173 _parameterTypeDict.insert("QRect", QMetaType::QRect);
174 _parameterTypeDict.insert("QRectf", QMetaType::QRectF);
175 _parameterTypeDict.insert("QSize", QMetaType::QSize);
176 _parameterTypeDict.insert("QSizef", QMetaType::QSizeF);
177 _parameterTypeDict.insert("QLine", QMetaType::QLine);
178 _parameterTypeDict.insert("QLinef", QMetaType::QLineF);
179 _parameterTypeDict.insert("QPoint", QMetaType::QPoint);
180 _parameterTypeDict.insert("QPointf", QMetaType::QPointF);
181 _parameterTypeDict.insert("QRegExp", QMetaType::QRegExp);
182 // _parameterTypeDict.insert("QColorGroup", QMetaType::QColorGroup);
183 _parameterTypeDict.insert("QFont", QMetaType::QFont);
184 _parameterTypeDict.insert("QPixmap", QMetaType::QPixmap);
185 _parameterTypeDict.insert("QBrush", QMetaType::QBrush);
186 _parameterTypeDict.insert("QColor", QMetaType::QColor);
187 _parameterTypeDict.insert("QCursor", QMetaType::QCursor);
188 _parameterTypeDict.insert("QPalette", QMetaType::QPalette);
189 _parameterTypeDict.insert("QIcon", QMetaType::QIcon);
190 _parameterTypeDict.insert("QImage", QMetaType::QPolygon);
191 _parameterTypeDict.insert("QRegion", QMetaType::QRegion);
192 _parameterTypeDict.insert("QBitmap", QMetaType::QBitmap);
193 _parameterTypeDict.insert("QSizePolicy", QMetaType::QSizePolicy);
194 _parameterTypeDict.insert("QKeySequence", QMetaType::QKeySequence);
195 _parameterTypeDict.insert("QPen", QMetaType::QPen);
196 _parameterTypeDict.insert("QTextLength", QMetaType::QTextLength);
197 _parameterTypeDict.insert("QTextFormat", QMetaType::QTextFormat);
198 _parameterTypeDict.insert("QMatrix", QMetaType::QMatrix);
199 _parameterTypeDict.insert("QVariant", PythonQtMethodInfo::Variant);
200 // own special types... (none so far, could be e.g. ObjectList
201 }
202 QHash<QByteArray, int>::const_iterator it = _parameterTypeDict.find(name);
203 if (it!=_parameterTypeDict.end()) {
204 return it.value();
205 } else {
206 return PythonQtMethodInfo::Unknown;
207 }
208 }
209
210 void PythonQtMethodInfo::cleanupCachedMethodInfos()
211 {
212 QHashIterator<QByteArray, PythonQtMethodInfo *> i(_cachedSignatures);
213 while (i.hasNext()) {
214 delete i.next().value();
215 }
216 }
217
218 void PythonQtMethodInfo::addParameterTypeAlias(const QByteArray& alias, const QByteArray& name)
219 {
220 _parameterNameAliases.insert(alias, name);
221 }
222
223 //-------------------------------------------------------------------------------------------------
224
225 QString PythonQtSlotInfo::fullSignature(bool skipFirstArg)
226 {
227 QString result = _meta.typeName();
228 QByteArray sig = slotName();
229 QList<QByteArray> names = _meta.parameterNames();
230
231 bool isStatic = false;
232 bool isConstructor = false;
233 bool isDestructor = false;
234
235 if (_type == ClassDecorator) {
236 if (sig.startsWith("new_")) {
237 sig = sig.mid(strlen("new_"));
238 isConstructor = true;
239 } else if (sig.startsWith("delete_")) {
240 sig = sig.mid(strlen("delete_"));
241 isDestructor = true;
242 } else if(sig.startsWith("static_")) {
243 isStatic = true;
244 sig = sig.mid(strlen("static_"));
245 int idx = sig.indexOf("_");
246 if (idx>=0) {
247 sig = sig.mid(idx+1);
248 }
249 }
250 }
251
252 result += QByteArray(" ") + sig;
253 result += "(";
254
255 int lastEntry = _parameters.count()-1;
256 for (int i = skipFirstArg?2:1; i<_parameters.count(); i++) {
257 if (_parameters.at(i).isConst) {
258 result += "const ";
259 }
260 result += _parameters.at(i).name;
261 if (_parameters.at(i).isPointer) {
262 result += "*";
263 }
264 if (!names.at(i-1).isEmpty()) {
265 result += " ";
266 result += names.at(i-1);
267 }
268 if (i!=lastEntry) {
269 result += ", ";
270 }
271 }
272 result += ")";
273
274 if (isStatic) {
275 result = QString("static ") + result;
276 }
277 if (isConstructor) {
278 // result = QString("constructor ") + result;
279 }
280 if (isDestructor) {
281 result = QString("~") + result;
282 }
283 return result;
284 }
285
286
287 QByteArray PythonQtSlotInfo::slotName()
288 {
289 QByteArray sig(_meta.signature());
290 int idx = sig.indexOf('(');
291 sig = sig.left(idx);
292 return sig;
293 }
294
@@ -0,0 +1,173
1 #ifndef _PYTHONQTMETHODINFO_H
2 #define _PYTHONQTMETHODINFO_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtMethodInfo.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include <QByteArray>
46 #include <QHash>
47 #include <QList>
48 #include <QMetaMethod>
49
50 //! stores information about a specific signal/slot/method
51 class PythonQtMethodInfo
52 {
53 public:
54 //! this is a funny type union of QMetaType and QVariant, only god knows
55 //! why QMetaType do not support identical types in Qt4,
56 //! especial the support of Long, Short, Char etc. is missing in QVariant
57 //! and QMetaType does not know anything about most variant types and e.g. LongLong
58 enum ParameterType {
59 Unknown = -1,
60 Variant = -2
61 };
62
63 //! stores the QVariant id (if available) and the name of the type
64 struct ParameterInfo {
65 int typeId; // a mixture from QMetaType and ParameterType
66 QByteArray name;
67 bool isPointer;
68 bool isConst;
69 };
70
71 PythonQtMethodInfo() {};
72 ~PythonQtMethodInfo() {};
73 PythonQtMethodInfo(const QMetaMethod& meta);
74 PythonQtMethodInfo(const PythonQtMethodInfo& other) {
75 _parameters = other._parameters;
76 }
77
78 //! returns the method info of the signature, uses a cache internally to speed up
79 //! multiple requests for the same method
80 static const PythonQtMethodInfo* getCachedMethodInfo(const QMetaMethod& method);
81
82 //! cleanup the cache
83 static void cleanupCachedMethodInfos();
84
85 //! returns the number of parameters (without the return value)
86 int parameterCount() const { return _parameters.size(); };
87
88 //! returns the id for the given type (using an internal dictionary)
89 static int nameToType(const char* name);
90
91 //! get the parameter infos
92 const QList<ParameterInfo>& parameters() const { return _parameters; }
93
94 //! add an alias for a typename, e.g. QObjectList and QList<QObject*>.
95 static void addParameterTypeAlias(const QByteArray& alias, const QByteArray& name);
96
97 protected:
98 static void fillParameterInfo(ParameterInfo& type, const QByteArray& name);
99
100 static QHash<QByteArray, int> _parameterTypeDict;
101 static QHash<QByteArray, QByteArray> _parameterNameAliases;
102
103 //! stores the cached signatures of methods to speedup mapping from Qt to Python types
104 static QHash<QByteArray, PythonQtMethodInfo*> _cachedSignatures;
105
106 QList<ParameterInfo> _parameters;
107 };
108
109 //! stores information about a slot, including a next pointer to overloaded slots
110 class PythonQtSlotInfo : public PythonQtMethodInfo
111 {
112 public:
113 enum Type {
114 MemberSlot, InstanceDecorator, ClassDecorator
115 };
116
117 PythonQtSlotInfo(const PythonQtSlotInfo& info):PythonQtMethodInfo() {
118 _meta = info._meta;
119 _parameters = info._parameters;
120 _slotIndex = info._slotIndex;
121 _next = NULL;
122 _decorator = info._decorator;
123 _type = info._type;
124 }
125
126 PythonQtSlotInfo(const QMetaMethod& meta, int slotIndex, QObject* decorator = NULL, Type type = MemberSlot ):PythonQtMethodInfo()
127 {
128 const PythonQtMethodInfo* info = getCachedMethodInfo(meta);
129 _meta = meta;
130 _parameters = info->parameters();
131 _slotIndex = slotIndex;
132 _next = NULL;
133 _decorator = decorator;
134 _type = type;
135 }
136
137
138 public:
139 const QMetaMethod* metaMethod() const { return &_meta; }
140
141 //! get the index of the slot (needed for qt_metacall)
142 int slotIndex() const { return _slotIndex; }
143
144 //! get next overloaded slot (which has the same name)
145 PythonQtSlotInfo* nextInfo() const { return _next; }
146
147 //! set the next overloaded slot
148 void setNextInfo(PythonQtSlotInfo* next) { _next = next; }
149
150 //! returns if the slot is a decorator slot
151 bool isInstanceDecorator() { return _decorator!=NULL && _type == InstanceDecorator; }
152
153 //! returns if the slot is a constructor slot
154 bool isClassDecorator() { return _decorator!=NULL && _type == ClassDecorator; }
155
156 QObject* decorator() { return _decorator; }
157
158 //! get the full signature including return type
159 QString fullSignature(bool skipFirstArg);
160
161 //! get the short slot name
162 QByteArray slotName();
163
164 private:
165 int _slotIndex;
166 PythonQtSlotInfo* _next;
167 QObject* _decorator;
168 Type _type;
169 QMetaMethod _meta;
170 };
171
172
173 #endif
@@ -0,0 +1,43
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtMisc.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtMisc.h"
43
@@ -0,0 +1,134
1 #ifndef _PYTHONQTMISC_H
2 #define _PYTHONQTMISC_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtMisc.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45
46 #include <QList>
47
48 #define PythonQtValueStorage_ADD_VALUE(store, type, value, ptr) \
49 { type* item = (type*)store.nextValuePtr(); \
50 *item = value; \
51 ptr = (void*)item; \
52 }
53
54 //! stores a position in the PythonQtValueStorage
55 class PythonQtValueStoragePosition {
56
57 public:
58 PythonQtValueStoragePosition() { chunkIdx = 0; chunkOffset = 0; }
59
60 int chunkIdx;
61 int chunkOffset;
62
63 };
64
65 //! a helper class that stores basic C++ value types in chunks
66 template <typename T, int chunkEntries> class PythonQtValueStorage
67 {
68 public:
69 PythonQtValueStorage() {
70 _chunkIdx = 0;
71 _chunkOffset = 0;
72 _currentChunk = new T[chunkEntries];
73 _chunks.append(_currentChunk);
74 };
75
76 //! clear all memory
77 void clear() {
78 T* chunk;
79 foreach(chunk, _chunks) {
80 delete[]chunk;
81 }
82 }
83
84 //! reset the storage to 0 (without freeing memory, thus caching old entries for reuse)
85 void reset() {
86 _chunkIdx = 0;
87 _chunkOffset = 0;
88 _currentChunk = _chunks.at(0);
89 }
90
91 //! get the current position to be restored with setPos
92 void getPos(PythonQtValueStoragePosition & pos) {
93 pos.chunkIdx = _chunkIdx;
94 pos.chunkOffset = _chunkOffset;
95 }
96
97 //! set the current position (without freeing memory, thus caching old entries for reuse)
98 void setPos(const PythonQtValueStoragePosition& pos) {
99 _chunkOffset = pos.chunkOffset;
100 if (_chunkIdx != pos.chunkIdx) {
101 _chunkIdx = pos.chunkIdx;
102 _currentChunk = _chunks.at(_chunkIdx);
103 }
104 }
105
106 //! add one default constructed value and return the pointer to it
107 T* nextValuePtr() {
108 if (_chunkOffset>=chunkEntries) {
109 _chunkIdx++;
110 if (_chunkIdx >= _chunks.size()) {
111 T* newChunk = new T[chunkEntries];
112 _chunks.append(newChunk);
113 _currentChunk = newChunk;
114 } else {
115 _currentChunk = _chunks.at(_chunkIdx);
116 }
117 _chunkOffset = 0;
118 }
119 T* newEntry = _currentChunk + _chunkOffset;
120 _chunkOffset++;
121 return newEntry;
122 };
123
124 private:
125 QList<T*> _chunks;
126
127 int _chunkIdx;
128 int _chunkOffset;
129 T* _currentChunk;
130
131 };
132
133
134 #endif
@@ -0,0 +1,84
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtObjectPtr.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include <PythonQt.h>
43
44 QVariant PythonQtObjectPtr::evalScript(const QString& script, int start)
45 {
46 return PythonQt::self()->evalScript(_object, script, start);
47 }
48
49 void PythonQtObjectPtr::evalFile(const QString& file)
50 {
51 PythonQt::self()->evalFile(_object, file);
52 }
53
54 QVariant PythonQtObjectPtr::evalCode(PyObject* pycode)
55 {
56 return PythonQt::self()->evalCode(_object, pycode);
57 }
58
59 void PythonQtObjectPtr::addObject(const QString& name, QObject* object)
60 {
61 PythonQt::self()->addObject(_object, name, object);
62 }
63
64 void PythonQtObjectPtr::addVariable(const QString& name, const QVariant& v)
65 {
66 PythonQt::self()->addVariable(_object, name, v);
67 }
68
69 void PythonQtObjectPtr::removeVariable(const QString& name)
70 {
71 PythonQt::self()->removeVariable(_object, name);
72 }
73
74 QVariant PythonQtObjectPtr::getVariable(const QString& name)
75 {
76 return PythonQt::self()->getVariable(_object, name);
77 }
78
79
80 QVariant PythonQtObjectPtr::call(const QString& callable, const QVariantList& args)
81 {
82 return PythonQt::self()->call(_object, callable, args);
83 }
84
@@ -0,0 +1,155
1 #ifndef _PYTHONQTOBJECTPTR_H
2 #define _PYTHONQTOBJECTPTR_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtObjectPtr.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include <Python.h>
46 #include "PythonQtSystem.h"
47
48 //! a smart pointer that stores a PyObject pointer and that handles reference counting automatically
49 class PYTHONQT_EXPORT PythonQtObjectPtr
50 {
51 public:
52 PythonQtObjectPtr():_object(NULL) {}
53
54 PythonQtObjectPtr(const PythonQtObjectPtr &p):_object(NULL) {
55 setObject(p.object());
56 }
57
58 PythonQtObjectPtr(PyObject* o) {
59 _object = o;
60 if (o) Py_INCREF(_object);
61 }
62
63 ~PythonQtObjectPtr() { if (_object) Py_DECREF(_object); }
64
65 PythonQtObjectPtr &operator=(const PythonQtObjectPtr &p) {
66 setObject(p.object());
67 return *this;
68 }
69
70 PythonQtObjectPtr &operator=(PyObject* o) {
71 setObject(o);
72 return *this;
73 }
74
75 bool operator==( const PythonQtObjectPtr &p ) const {
76 return object() == p.object();
77 }
78
79 bool operator!= ( const PythonQtObjectPtr& p ) const {
80 return !( *this == p );
81 }
82
83 bool operator==( PyObject* p ) const {
84 return object() == p;
85 }
86
87 bool operator!= ( PyObject* p ) const {
88 return object() != p;
89 }
90
91 bool isNull() const { return !object(); }
92
93 PyObject* operator->() const { return object(); }
94
95 PyObject& operator*() const { return *( object() ); }
96
97 operator PyObject*() const { return object(); }
98
99 //! sets the object and passes the ownership (stealing the reference, in Python slang)
100 void setNewRef(PyObject* o) {
101 if (o != _object) {
102 if (_object) Py_DECREF(_object);
103 _object = o;
104 }
105 }
106
107 PyObject* object() const {
108 return _object;
109 }
110
111 //! evaluates the given script code in the context of this object and returns the result value
112 QVariant evalScript(const QString& script, int start = Py_file_input);
113
114 //! evaluates the given code and returns the result value (use Py_Compile etc. to create pycode from string)
115 //! If pycode is NULL, a python error is printed.
116 QVariant evalCode(PyObject* pycode);
117
118 //! evaluates the given code in the context
119 void evalFile(const QString& filename);
120
121 //! add the given \c object to the \c module as a variable with \c name (it can be removed via clearVariable)
122 void addObject(const QString& name, QObject* object);
123
124 //! add the given variable to the module
125 void addVariable(const QString& name, const QVariant& v);
126
127 //! remove the given variable
128 void removeVariable(const QString& name);
129
130 //! get the variable with the \c name of the \c module, returns an invalid QVariant on error
131 QVariant getVariable(const QString& name);
132
133 //! call the given python object (in the scope of the current object), returns the result converted to a QVariant
134 QVariant call(const QString& callable, const QVariantList& args);
135
136
137 protected:
138
139 void setObject(PyObject* o) {
140 if (o != _object) {
141 if (_object) Py_DECREF(_object);
142 _object = o;
143 if (_object) Py_INCREF(_object);
144 }
145 }
146
147 private:
148 PyObject* _object;
149 };
150
151
152 // register it to the meta type system
153 Q_DECLARE_METATYPE(PythonQtObjectPtr)
154
155 #endif No newline at end of file
@@ -0,0 +1,171
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtSignalReceiver.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtSignalReceiver.h"
43 #include "PythonQtClassInfo.h"
44 #include "PythonQtMethodInfo.h"
45 #include "PythonQtConversion.h"
46 #include <QMetaObject>
47 #include <QMetaMethod>
48
49 void PythonQtSignalTarget::call(void **arguments) const
50 {
51 const PythonQtMethodInfo* m = methodInfo();
52 // paramterCount includes return value:
53 int count = m->parameterCount();
54
55 PyObject* pargs = NULL;
56 if (count>1) {
57 pargs = PyTuple_New(count-1);
58 }
59 bool err = false;
60 // transform Qt values to Python
61 const QList<PythonQtMethodInfo::ParameterInfo>& params = m->parameters();
62 for (int i = 1; i < count; i++) {
63 const PythonQtMethodInfo::ParameterInfo& param = params.at(i);
64 PyObject* arg = PythonQtConv::ConvertQtValueToPython(param, arguments[i]);
65 if (arg) {
66 // steals reference, no unref
67 PyTuple_SetItem(pargs, i-1,arg);
68 } else {
69 err = true;
70 break;
71 }
72 }
73
74 if (!err) {
75 PyErr_Clear();
76 PyObject* result = PyObject_CallObject(_callable, pargs);
77 if (result) {
78 // ok
79 Py_DECREF(result);
80 } else {
81 PythonQt::self()->handleError();
82 }
83 }
84 if (pargs) {
85 // free the arguments again
86 Py_DECREF(pargs);
87 }
88 }
89
90 //------------------------------------------------------------------------------
91
92 PythonQtSignalReceiver::PythonQtSignalReceiver(QObject* obj):PythonQtSignalReceiverBase(obj)
93 {
94 _obj = obj;
95 _slotCount = staticMetaObject.methodOffset();
96 }
97
98 PythonQtSignalReceiver::~PythonQtSignalReceiver()
99 {
100 }
101
102
103 bool PythonQtSignalReceiver::addSignalHandler(const char* signal, PyObject* callable)
104 {
105 bool flag = false;
106 int sigId = getSignalIndex(signal);
107 if (sigId>=0) {
108 // create PythonQtMethodInfo from signal
109 QMetaMethod meta = _obj->metaObject()->method(sigId);
110 const PythonQtMethodInfo* signalInfo = PythonQtMethodInfo::getCachedMethodInfo(meta);
111 PythonQtSignalTarget t(sigId, signalInfo, _slotCount, callable);
112 _targets.append(t);
113 // now connect to ourselves with the new slot id
114 QMetaObject::connect(_obj, sigId, this, _slotCount, Qt::AutoConnection, 0);
115
116 _slotCount++;
117 flag = true;
118 }
119 return flag;
120 }
121
122 bool PythonQtSignalReceiver::removeSignalHandler(const char* signal, PyObject* callable)
123 {
124 bool found = false;
125 int sigId = getSignalIndex(signal);
126 if (sigId>=0) {
127 QMutableListIterator<PythonQtSignalTarget> i(_targets);
128 while (i.hasNext()) {
129 if (i.next().isSame(sigId, callable)) {
130 i.remove();
131 found = true;
132 break;
133 }
134 }
135 }
136 return found;
137 }
138
139 void PythonQtSignalReceiver::removeSignalHandlers()
140 {
141 _targets.clear();
142 }
143
144 int PythonQtSignalReceiver::getSignalIndex(const char* signal)
145 {
146 int sigId = _obj->metaObject()->indexOfSignal(signal+1);
147 if (sigId<0) {
148 QByteArray tmpSig = QMetaObject::normalizedSignature(signal+1);
149 sigId = _obj->metaObject()->indexOfSignal(tmpSig);
150 }
151 return sigId;
152 }
153
154 int PythonQtSignalReceiver::qt_metacall(QMetaObject::Call c, int id, void **arguments)
155 {
156 // mlabDebugConst("PythonQt", "PythonQtSignalReceiver invoke " << _obj->className() << " " << _obj->name() << " " << id);
157 if (c != QMetaObject::InvokeMetaMethod) {
158 QObject::qt_metacall(c, id, arguments);
159 }
160
161 bool found = false;
162 foreach(const PythonQtSignalTarget& t, _targets) {
163 if (t.slotId() == id) {
164 found = true;
165 t.call(arguments);
166 break;
167 }
168 }
169 return 0;
170 }
171
@@ -0,0 +1,133
1 #ifndef _PYTHONQTSIGNALRECEIVER_H
2 #define _PYTHONQTSIGNALRECEIVER_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtSignalReceiver.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQt.h"
46 class PythonQtMethodInfo;
47
48 //! stores information about a signal target
49 /*! copy construction and assignment works fine with the C++ standard behaviour and are thus not implemented
50 */
51 class PythonQtSignalTarget {
52 public:
53 PythonQtSignalTarget() {
54 _signalId = -1;
55 _methodInfo = NULL;
56 _slotId = -1;
57 }
58
59 PythonQtSignalTarget(int signalId,const PythonQtMethodInfo* methodInfo, int slotId, PyObject* callable)
60 {
61 _signalId = signalId;
62 _slotId = slotId;
63 _methodInfo = methodInfo;
64 _callable = callable;
65 };
66
67 ~PythonQtSignalTarget() {
68 };
69
70 //! get the id of the original signal
71 int signalId() const { return _signalId; }
72
73 //! get the id that was assigned to this simulated slot
74 int slotId() const { return _slotId; }
75
76 //! get the signals parameter info
77 const PythonQtMethodInfo* methodInfo() const { return _methodInfo; }
78
79 //! call the python callable with the given arguments (as defined in methodInfo)
80 void call(void **arguments) const;
81
82 //! check if it is the same signal target
83 bool isSame(int signalId, PyObject* callable) const { return callable==_callable && signalId==_signalId; }
84
85 private:
86 int _signalId;
87 int _slotId;
88 const PythonQtMethodInfo* _methodInfo;
89 PythonQtObjectPtr _callable;
90 };
91
92 //! base class for signal receivers
93 /*!
94 */
95 class PythonQtSignalReceiverBase : public QObject {
96 Q_OBJECT
97 public:
98 PythonQtSignalReceiverBase(QObject* obj):QObject(obj) {};
99 };
100
101 //! receives all signals for one QObject
102 /*! we derive from our base but do not declare the QObject macro because we want to reimplement qt_metacall only.
103 */
104 class PythonQtSignalReceiver : public PythonQtSignalReceiverBase {
105
106 public:
107 PythonQtSignalReceiver(QObject* obj);
108 ~PythonQtSignalReceiver();
109
110 //! add a signal handler
111 bool addSignalHandler(const char* signal, PyObject* callable);
112
113 //! remove a signal handler
114 bool removeSignalHandler(const char* signal, PyObject* callable);
115
116 //! remove all signal handlers
117 void removeSignalHandlers();
118
119 //! we implement this method to simulate a number of slots that match the ids in _targets
120 virtual int qt_metacall(QMetaObject::Call c, int id, void **arguments);
121
122 private:
123 //! get the index of the signal
124 int getSignalIndex(const char* signal);
125
126 QObject* _obj;
127 int _slotCount;
128 // linear list may get slow on multiple targets, but I think typically we have many objects and just a few signals
129 QList<PythonQtSignalTarget> _targets;
130 };
131
132
133 #endif
@@ -0,0 +1,450
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtSlot.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include "PythonQtSlot.h"
44 #include "PythonQtWrapper.h"
45 #include "PythonQtClassInfo.h"
46 #include "PythonQtMisc.h"
47 #include "PythonQtConversion.h"
48 #include <iostream>
49
50 #define PYTHONQT_MAX_ARGS 32
51
52
53 PyObject* PythonQtCallSlot(QObject* objectToCall, PyObject* args, bool strict, PythonQtSlotInfo* info, bool isVariantCall, void* firstArgument)
54 {
55 if (isVariantCall && info->isInstanceDecorator()) return NULL;
56
57 static unsigned int recursiveEntry = 0;
58
59 // store the current storage position, so that we can get back to this state after a slot is called
60 // (do this locally, so that we have all positions on the stack
61 PythonQtValueStoragePosition globalValueStoragePos;
62 PythonQtValueStoragePosition globalPtrStoragePos;
63 PythonQtValueStoragePosition globalVariantStoragePos;
64 PythonQtConv::global_valueStorage.getPos(globalValueStoragePos);
65 PythonQtConv::global_ptrStorage.getPos(globalPtrStoragePos);
66 PythonQtConv::global_variantStorage.getPos(globalVariantStoragePos);
67
68 recursiveEntry++;
69
70 // the arguments that are passed to qt_metacall
71 void* argList[PYTHONQT_MAX_ARGS];
72 PyObject* result = NULL;
73 int argc = info->parameterCount();
74 const QList<PythonQtSlotInfo::ParameterInfo>& params = info->parameters();
75
76 bool returnValueIsEnum = false;
77 const PythonQtSlotInfo::ParameterInfo& returnValueParam = params.at(0);
78 // set return argument to NULL
79 argList[0] = NULL;
80
81 if (returnValueParam.typeId != QMetaType::Void) {
82 // extra handling of enum return value
83 if (!returnValueParam.isPointer && returnValueParam.typeId == PythonQtMethodInfo::Unknown) {
84 returnValueIsEnum = PythonQt::priv()->isEnumType(objectToCall->metaObject(), returnValueParam.name);
85 if (returnValueIsEnum) {
86 // create enum return value
87 PythonQtValueStorage_ADD_VALUE(PythonQtConv::global_valueStorage, long, 0, argList[0]);
88 }
89 }
90 if (argList[0]==NULL) {
91 // create empty default value for the return value
92 argList[0] = PythonQtConv::CreateQtReturnValue(returnValueParam);
93 }
94 }
95
96 const QMetaObject* meta = objectToCall?objectToCall->metaObject():NULL;
97 bool ok = true;
98 bool skipFirst = false;
99 if (info->isInstanceDecorator() || isVariantCall) {
100 skipFirst = true;
101 if (!firstArgument) {
102 argList[1] = &objectToCall;
103 } else {
104 // for the variant call we take the ptr to the variant data, for decorators on CPP objects, we take the cpp ptr
105 argList[1] = &firstArgument;
106 }
107 if (ok) {
108 for (int i = 2; i<argc && ok; i++) {
109 const PythonQtSlotInfo::ParameterInfo& param = params.at(i);
110 //std::cout << param.name.data() << " " << param.typeId << (param.isPointer?"*":"") << (param.isConst?" const":"") << std::endl;
111 argList[i] = PythonQtConv::ConvertPythonToQt(param, PyTuple_GET_ITEM(args, i-2), strict, meta);
112 if (argList[i]==NULL) {
113 ok = false;
114 break;
115 }
116 }
117 }
118 } else {
119 for (int i = 1; i<argc && ok; i++) {
120 const PythonQtSlotInfo::ParameterInfo& param = params.at(i);
121 //std::cout << param.name.data() << " " << param.typeId << (param.isPointer?"*":"") << (param.isConst?" const":"") << std::endl;
122 argList[i] = PythonQtConv::ConvertPythonToQt(param, PyTuple_GET_ITEM(args, i-1), strict, meta);
123 if (argList[i]==NULL) {
124 ok = false;
125 break;
126 }
127 }
128 }
129
130 if (ok) {
131 (info->decorator()?info->decorator():objectToCall)->qt_metacall(QMetaObject::InvokeMetaMethod, info->slotIndex(), argList);
132
133 if (argList[0] || returnValueParam.typeId == QMetaType::Void) {
134 if (!returnValueIsEnum) {
135 result = PythonQtConv::ConvertQtValueToPython(returnValueParam, argList[0]);
136 } else {
137 result = PyInt_FromLong(*((unsigned int*)argList[0]));
138 }
139 } else {
140 QString e = QString("Called ") + info->fullSignature(skipFirst) + ", return type is ignored because it is unknown to PythonQt.";
141 PyErr_SetString(PyExc_ValueError, e.toLatin1().data());
142 result = NULL;
143 }
144 }
145 recursiveEntry--;
146
147 // reset the parameter storage position to the stored pos to "pop" the parameter stack
148 PythonQtConv::global_valueStorage.setPos(globalValueStoragePos);
149 PythonQtConv::global_ptrStorage.setPos(globalPtrStoragePos);
150 PythonQtConv::global_variantStorage.setPos(globalVariantStoragePos);
151
152 // NOTE: it is important to only return here, otherwise the stack will not be popped!!!
153 return result;
154 }
155
156 //-----------------------------------------------------------------------------------
157
158 static PythonQtSlotFunctionObject *pythonqtslot_free_list = NULL;
159
160 PyObject *PythonQtSlotFunction_Call(PyObject *func, PyObject *args, PyObject *kw)
161 {
162 PythonQtSlotFunctionObject* f = (PythonQtSlotFunctionObject*)func;
163 PythonQtSlotInfo* info = f->m_ml;
164 if (f->m_self->ob_type == &PythonQtWrapper_Type) {
165 PythonQtWrapper* self = (PythonQtWrapper*) f->m_self;
166 return PythonQtSlotFunction_CallImpl(self->_obj, info, args, kw, false, self->_wrappedPtr);
167 } else if (f->m_self->ob_type == &PythonQtVariantWrapper_Type) {
168 PythonQtVariantWrapper* self = (PythonQtVariantWrapper*) f->m_self;
169 if (!info->isClassDecorator()) {
170 return PythonQtSlotFunction_CallImpl(self->_wrapper, info, args, kw, true, (void*)self->_variant->constData());
171 } else {
172 return PythonQtSlotFunction_CallImpl(NULL, info, args, kw);
173 }
174 } else if (f->m_self->ob_type == &PythonQtMetaObjectWrapper_Type) {
175 return PythonQtSlotFunction_CallImpl(NULL, info, args, kw);
176 } else {
177 return NULL;
178 }
179 }
180
181 PyObject *PythonQtSlotFunction_CallImpl(QObject* objectToCall, PythonQtSlotInfo* info, PyObject *args, PyObject *kw, bool isVariantCall, void* firstArg)
182 {
183 int argc = PyTuple_Size(args);
184
185 #ifdef PYTHONQT_DEBUG
186 std::cout << "called " << info->metaMethod()->typeName() << " " << info->metaMethod()->signature() << std::endl;
187 #endif
188
189 PyObject* r = NULL;
190
191 if (info->nextInfo()) {
192 // overloaded slot call, try on all slots with strict conversion first
193 PythonQtSlotInfo* i = info;
194 while (i && r==NULL) {
195 bool skipFirst = (i->isInstanceDecorator() || isVariantCall);
196 if (i->parameterCount()-1-(skipFirst?1:0) == argc) {
197 PyErr_Clear();
198 r = PythonQtCallSlot(objectToCall, args, true, i, isVariantCall, firstArg);
199 if (PyErr_Occurred()) break;
200 }
201 i = i->nextInfo();
202 }
203 if (!r) {
204 // try on all slots with non-strict conversion
205 i = info;
206 while (i && r==NULL) {
207 bool skipFirst = (i->isInstanceDecorator() || isVariantCall);
208 if (i->parameterCount()-1-(skipFirst?1:0) == argc) {
209 PyErr_Clear();
210 r = PythonQtCallSlot(objectToCall, args, false, i, isVariantCall, firstArg);
211 if (PyErr_Occurred()) break;
212 }
213 i = i->nextInfo();
214 }
215 }
216 if (r==NULL && !PyErr_Occurred()) {
217 QString e = QString("Could not find matching overload for given arguments:\n" + PythonQtConv::PyObjGetString(args) + "\n The following slots are available:\n");
218 PythonQtSlotInfo* i = info;
219 while (i) {
220 bool skipFirst = (i->isInstanceDecorator() || isVariantCall);
221 e += QString(i->fullSignature(skipFirst)) + "\n";
222 i = i->nextInfo();
223 }
224 PyErr_SetString(PyExc_ValueError, e.toLatin1().data());
225 }
226 } else {
227 // simple (non-overloaded) slot call
228 bool skipFirst = (info->isInstanceDecorator() || isVariantCall);
229 if (info->parameterCount()-1-(skipFirst?1:0) == argc) {
230 PyErr_Clear();
231 r = PythonQtCallSlot(objectToCall, args, false, info, isVariantCall, firstArg);
232 if (r==NULL && !PyErr_Occurred()) {
233 QString e = QString("Called ") + info->fullSignature(skipFirst) + " with wrong arguments: " + PythonQtConv::PyObjGetString(args);
234 PyErr_SetString(PyExc_ValueError, e.toLatin1().data());
235 }
236 } else {
237 QString e = QString("Called ") + info->fullSignature(skipFirst) + " with wrong number of arguments: " + PythonQtConv::PyObjGetString(args);
238 PyErr_SetString(PyExc_ValueError, e.toLatin1().data());
239 }
240 }
241
242 return r;
243 }
244
245 PyObject *
246 PythonQtSlotFunction_New(PythonQtSlotInfo *ml, PyObject *self, PyObject *module)
247 {
248 PythonQtSlotFunctionObject *op;
249 op = pythonqtslot_free_list;
250 if (op != NULL) {
251 pythonqtslot_free_list = (PythonQtSlotFunctionObject *)(op->m_self);
252 PyObject_INIT(op, &PythonQtSlotFunction_Type);
253 }
254 else {
255 op = PyObject_GC_New(PythonQtSlotFunctionObject, &PythonQtSlotFunction_Type);
256 if (op == NULL)
257 return NULL;
258 }
259 op->m_ml = ml;
260 Py_XINCREF(self);
261 op->m_self = self;
262 Py_XINCREF(module);
263 op->m_module = module;
264 PyObject_GC_Track(op);
265 return (PyObject *)op;
266 }
267
268 PythonQtSlotInfo*
269 PythonQtSlotFunction_GetSlotInfo(PyObject *op)
270 {
271 if (!PythonQtSlotFunction_Check(op)) {
272 PyErr_BadInternalCall();
273 return NULL;
274 }
275 return ((PythonQtSlotFunctionObject *)op) -> m_ml;
276 }
277
278 PyObject *
279 PythonQtSlotFunction_GetSelf(PyObject *op)
280 {
281 if (!PythonQtSlotFunction_Check(op)) {
282 PyErr_BadInternalCall();
283 return NULL;
284 }
285 return ((PythonQtSlotFunctionObject *)op) -> m_self;
286 }
287
288 /* Methods (the standard built-in methods, that is) */
289
290 static void
291 meth_dealloc(PythonQtSlotFunctionObject *m)
292 {
293 PyObject_GC_UnTrack(m);
294 Py_XDECREF(m->m_self);
295 Py_XDECREF(m->m_module);
296 m->m_self = (PyObject *)pythonqtslot_free_list;
297 pythonqtslot_free_list = m;
298 }
299
300 static PyObject *
301 meth_get__doc__(PythonQtSlotFunctionObject *m, void *closure)
302 {
303 Py_INCREF(Py_None);
304 return Py_None;
305 }
306
307 static PyObject *
308 meth_get__name__(PythonQtSlotFunctionObject *m, void *closure)
309 {
310 return PyString_FromString(m->m_ml->metaMethod()->signature());
311 }
312
313 static int
314 meth_traverse(PythonQtSlotFunctionObject *m, visitproc visit, void *arg)
315 {
316 int err;
317 if (m->m_self != NULL) {
318 err = visit(m->m_self, arg);
319 if (err)
320 return err;
321 }
322 if (m->m_module != NULL) {
323 err = visit(m->m_module, arg);
324 if (err)
325 return err;
326 }
327 return 0;
328 }
329
330 static PyObject *
331 meth_get__self__(PythonQtSlotFunctionObject *m, void *closure)
332 {
333 PyObject *self;
334 if (PyEval_GetRestricted()) {
335 PyErr_SetString(PyExc_RuntimeError,
336 "method.__self__ not accessible in restricted mode");
337 return NULL;
338 }
339 self = m->m_self;
340 if (self == NULL)
341 self = Py_None;
342 Py_INCREF(self);
343 return self;
344 }
345
346 static PyGetSetDef meth_getsets [] = {
347 {"__doc__", (getter)meth_get__doc__, NULL, NULL},
348 {"__name__", (getter)meth_get__name__, NULL, NULL},
349 {"__self__", (getter)meth_get__self__, NULL, NULL},
350 {0}
351 };
352
353 #define OFF(x) offsetof(PythonQtSlotFunctionObject, x)
354
355 static PyMemberDef meth_members[] = {
356 {"__module__", T_OBJECT, OFF(m_module), WRITE_RESTRICTED},
357 {NULL}
358 };
359
360 static PyObject *
361 meth_repr(PythonQtSlotFunctionObject *m)
362 {
363 return PyString_FromFormat("<built-in qt slot %s of %s object at %p>",
364 m->m_ml->metaMethod()->signature(),
365 m->m_self->ob_type->tp_name,
366 m->m_self);
367 }
368
369 static int
370 meth_compare(PythonQtSlotFunctionObject *a, PythonQtSlotFunctionObject *b)
371 {
372 if (a->m_self != b->m_self)
373 return (a->m_self < b->m_self) ? -1 : 1;
374 if (a->m_ml == b->m_ml)
375 return 0;
376 if (strcmp(a->m_ml->metaMethod()->signature(), b->m_ml->metaMethod()->signature()) < 0)
377 return -1;
378 else
379 return 1;
380 }
381
382 static long
383 meth_hash(PythonQtSlotFunctionObject *a)
384 {
385 long x,y;
386 if (a->m_self == NULL)
387 x = 0;
388 else {
389 x = PyObject_Hash(a->m_self);
390 if (x == -1)
391 return -1;
392 }
393 y = _Py_HashPointer((void*)(a->m_ml));
394 if (y == -1)
395 return -1;
396 x ^= y;
397 if (x == -1)
398 x = -2;
399 return x;
400 }
401
402
403 PyTypeObject PythonQtSlotFunction_Type = {
404 PyObject_HEAD_INIT(&PyType_Type)
405 0,
406 "builtin_qt_slot",
407 sizeof(PythonQtSlotFunctionObject),
408 0,
409 (destructor)meth_dealloc, /* tp_dealloc */
410 0, /* tp_print */
411 0, /* tp_getattr */
412 0, /* tp_setattr */
413 (cmpfunc)meth_compare, /* tp_compare */
414 (reprfunc)meth_repr, /* tp_repr */
415 0, /* tp_as_number */
416 0, /* tp_as_sequence */
417 0, /* tp_as_mapping */
418 (hashfunc)meth_hash, /* tp_hash */
419 PythonQtSlotFunction_Call, /* tp_call */
420 0, /* tp_str */
421 PyObject_GenericGetAttr, /* tp_getattro */
422 0, /* tp_setattro */
423 0, /* tp_as_buffer */
424 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
425 0, /* tp_doc */
426 (traverseproc)meth_traverse, /* tp_traverse */
427 0, /* tp_clear */
428 0, /* tp_richcompare */
429 0, /* tp_weaklistoffset */
430 0, /* tp_iter */
431 0, /* tp_iternext */
432 0, /* tp_methods */
433 meth_members, /* tp_members */
434 meth_getsets, /* tp_getset */
435 0, /* tp_base */
436 0, /* tp_dict */
437 };
438
439 /* Clear out the free list */
440
441 void
442 PythonQtSlotFunction_Fini(void)
443 {
444 while (pythonqtslot_free_list) {
445 PythonQtSlotFunctionObject *v = pythonqtslot_free_list;
446 pythonqtslot_free_list = (PythonQtSlotFunctionObject *)(v->m_self);
447 PyObject_GC_Del(v);
448 }
449 }
450
@@ -0,0 +1,79
1 #ifndef _PYTHONQTSLOT_H
2 #define _PYTHONQTSLOT_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtSlot.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "Python.h"
46 #include "structmember.h"
47
48 class PythonQtSlotInfo;
49
50 extern PyTypeObject PythonQtSlotFunction_Type;
51
52 #define PythonQtSlotFunction_Check(op) ((op)->ob_type == &PythonQtSlotFunction_Type)
53
54 PythonQtSlotInfo* PythonQtSlotFunction_GetSlotInfo(PyObject *);
55 PyObject* PythonQtSlotFunction_GetSelf(PyObject *);
56
57 /* Macros for direct access to these values. Type checks are *not*
58 done, so use with care. */
59 #define PythonQtSlotFunction_GET_SELF(func) \
60 (((PythonQtSlotFunctionObject *)func) -> m_self)
61
62 PyObject* PythonQtSlotFunction_Call(PyObject *, PyObject *, PyObject *);
63
64 PyObject *PythonQtSlotFunction_CallImpl(QObject* objectToCall, PythonQtSlotInfo* info, PyObject *args, PyObject *kw, bool isVariantCall=false, void* firstArg=NULL);
65
66
67 PyObject* PythonQtSlotFunction_New(PythonQtSlotInfo *, PyObject *,
68 PyObject *);
69
70 //! defines a python object that stores a Qt slot info
71 typedef struct {
72 PyObject_HEAD
73 PythonQtSlotInfo *m_ml; /* Description of the C function to call */
74 PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */
75 PyObject *m_module; /* The __module__ attribute, can be anything */
76 } PythonQtSlotFunctionObject;
77
78
79 #endif
@@ -0,0 +1,116
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtStdDecorators.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2007-04
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtStdDecorators.h"
43 #include "PythonQt.h"
44 #include "PythonQtClassInfo.h"
45
46
47 bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable)
48 {
49 QByteArray signalTmp("2");
50 signalTmp += signal;
51 if (sender) {
52 return PythonQt::self()->addSignalHandler(sender, signalTmp, callable);
53 } else {
54 return false;
55 }
56 }
57
58 bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot)
59 {
60 bool r = false;
61 if (sender && receiver) {
62 QByteArray signalTmp("2");
63 signalTmp += signal;
64 QByteArray slotTmp("1");
65 slotTmp += slot;
66 if (receiver) {
67 r = QObject::connect(sender, signalTmp, receiver, slotTmp);
68 }
69 }
70 return r;
71 }
72
73 bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, PyObject* callable)
74 {
75 QByteArray signalTmp("2");
76 signalTmp += signal;
77 if (sender) {
78 return PythonQt::self()->removeSignalHandler(sender, signalTmp, callable);
79 } else {
80 return false;
81 }
82 }
83
84 bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot)
85 {
86 bool r = false;
87 if (sender && receiver) {
88 QByteArray signalTmp("2");
89 signalTmp += signal;
90 QByteArray slotTmp("1");
91 slotTmp += slot;
92 if (receiver) {
93 r = QObject::disconnect(sender, signalTmp, receiver, slotTmp);
94 }
95 }
96 return r;
97 }
98
99 QObject* PythonQtStdDecorators::parent(QObject* o) {
100 return o->parent();
101 }
102
103 void PythonQtStdDecorators::setParent(QObject* o, QObject* parent)
104 {
105 o->setParent(parent);
106 }
107
108 QVariantList PythonQtStdDecorators::children(QObject* o)
109 {
110 QVariantList v;
111 QListIterator<QObject*> it(o->children());
112 while (it.hasNext()) {
113 v << qVariantFromValue(it.next());
114 }
115 return v;
116 }
@@ -0,0 +1,87
1 #ifndef _PYTHONQTSTDDECORATORS_H
2 #define _PYTHONQTSTDDECORATORS_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtStdDecorators.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2007-04
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQtSystem.h"
46 #include <Python.h>
47 #include <QObject>
48 #include <QVariantList>
49 #include <QTextDocument>
50 #include <QColor>
51 #include <QDateTime>
52 #include <QDate>
53 #include <QTime>
54
55 class PYTHONQT_EXPORT PythonQtStdDecorators : public QObject
56 {
57 Q_OBJECT
58
59 public slots:
60 // additional constructors
61 QVariant new_QSize(const QSize& o) { QSize a = o; return a; }
62 QVariant new_QSizeF(const QSizeF& o) { QSizeF a = o; return a; }
63 QVariant new_QPoint(const QPoint& o) { QPoint a = o; return a; }
64 QVariant new_QPointF(const QPointF& o) { QPointF a = o; return a; }
65 QVariant new_QRect(const QRect& o) { QRect a = o; return a; }
66 QVariant new_QRectF(const QRectF& o) { QRectF a = o; return a; }
67 QVariant new_QDate(const QDate& o) { QDate a = o; return a; }
68 QVariant new_QDateTime(const QDateTime& o) { QDateTime a = o; return a; }
69 QVariant new_QTime(const QTime& o) { QTime a = o; return a; }
70
71 bool connect(QObject* sender, const QByteArray& signal, PyObject* callable);
72 bool connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot);
73 bool disconnect(QObject* sender, const QByteArray& signal, PyObject* callable);
74 bool disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot);
75
76 QObject* parent(QObject* o);
77 void setParent(QObject* o, QObject* parent);
78
79 QVariantList children(QObject* o);
80
81 QString static_Qt_escape(const QString& s) { return Qt::escape(s); }
82
83 //TODO: add findChild/findChildren/children/...
84 };
85
86
87 #endif
@@ -0,0 +1,128
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtStdOut.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtStdOut.h"
43
44 static PyObject *PythonQtStdOutRedirect_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
45 {
46 PythonQtStdOutRedirect *self;
47 self = (PythonQtStdOutRedirect *)type->tp_alloc(type, 0);
48
49 self->softspace = 0;
50 self->_cb = NULL;
51
52 return (PyObject *)self;
53 }
54
55 static PyObject *PythonQtStdOutRedirect_write(PyObject *self, PyObject *args)
56 {
57 PythonQtStdOutRedirect* s = (PythonQtStdOutRedirect*)self;
58 if (s->_cb) {
59 char *string;
60 if (!PyArg_ParseTuple(args, "s", &string))
61 return NULL;
62
63 if (s->softspace > 0) {
64 (*s->_cb)(QString(""));
65 s->softspace = 0;
66 }
67
68 (*s->_cb)(QString(string));
69 }
70 return Py_BuildValue("");
71 }
72
73
74 static PyMethodDef PythonQtStdOutRedirect_methods[] = {
75 {"write", (PyCFunction)PythonQtStdOutRedirect_write, METH_VARARGS,
76 "redirect the writing to a callback"
77 },
78 {NULL} /* Sentinel */
79 };
80
81 static PyMemberDef PythonQtStdOutRedirect_members[] = {
82 {"softspace", T_INT, offsetof(PythonQtStdOutRedirect, softspace), 0,
83 "soft space flag"
84 },
85 {NULL} /* Sentinel */
86 };
87
88 PyTypeObject PythonQtStdOutRedirectType = {
89 PyObject_HEAD_INIT(NULL)
90 0, /*ob_size*/
91 "PythonQtStdOutRedirect", /*tp_name*/
92 sizeof(PythonQtStdOutRedirect), /*tp_basicsize*/
93 0, /*tp_itemsize*/
94 0, /*tp_dealloc*/
95 0, /*tp_print*/
96 0, /*tp_getattr*/
97 0, /*tp_setattr*/
98 0, /*tp_compare*/
99 0, /*tp_repr*/
100 0, /*tp_as_number*/
101 0, /*tp_as_sequence*/
102 0, /*tp_as_mapping*/
103 0, /*tp_hash */
104 0, /*tp_call*/
105 0, /*tp_str*/
106 0, /*tp_getattro*/
107 0, /*tp_setattro*/
108 0, /*tp_as_buffer*/
109 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
110 "PythonQtStdOutRedirect", /* tp_doc */
111 0, /* tp_traverse */
112 0, /* tp_clear */
113 0, /* tp_richcompare */
114 0, /* tp_weaklistoffset */
115 0, /* tp_iter */
116 0, /* tp_iternext */
117 PythonQtStdOutRedirect_methods, /* tp_methods */
118 PythonQtStdOutRedirect_members, /* tp_members */
119 0, /* tp_getset */
120 0, /* tp_base */
121 0, /* tp_dict */
122 0, /* tp_descr_get */
123 0, /* tp_descr_set */
124 0, /* tp_dictoffset */
125 0, /* tp_init */
126 0, /* tp_alloc */
127 PythonQtStdOutRedirect_new, /* tp_new */
128 };
@@ -0,0 +1,64
1 #ifndef _PYTHONQTSTDOUT_H
2 #define _PYTHONQTSTDOUT_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtStdOut.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45
46
47 #include <Python.h>
48 #include "structmember.h"
49 #include <QString>
50
51 //! declares the type of the stdout redirection class
52 extern PyTypeObject PythonQtStdOutRedirectType;
53
54 //! declares the callback that is called from the write() function
55 typedef void PythonQtOutputChangedCB(const QString& str);
56
57 //! declares the stdout redirection class
58 typedef struct {
59 PyObject_HEAD
60 PythonQtOutputChangedCB* _cb;
61 int softspace;
62 } PythonQtStdOutRedirect;
63
64 #endif
@@ -0,0 +1,56
1 #ifndef _PYTHONQTSYSTEM_
2 #define _PYTHONQTSYSTEM_
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtSystem.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #ifdef WIN32
46 #ifdef PYTHONQT_EXPORTS
47 #define PYTHONQT_EXPORT __declspec(dllexport)
48 #else
49 #define PYTHONQT_EXPORT __declspec(dllimport)
50 #endif
51 #else
52 #define PYTHONQT_EXPORT
53 #endif
54
55 #endif
56
@@ -0,0 +1,256
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtVariantWrapper.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtVariantWrapper.h"
43 #include <QObject>
44 #include <QDate>
45 #include <QDateTime>
46 #include <QTime>
47 #include "PythonQt.h"
48 #include "PythonQtSlot.h"
49 #include "PythonQtClassInfo.h"
50 #include "PythonQtConversion.h"
51
52 static void PythonQtVariantWrapper_dealloc(PythonQtVariantWrapper* self)
53 {
54 if (self->_variant) {
55 delete self->_variant;
56 self->_variant = NULL;
57 }
58 self->ob_type->tp_free((PyObject*)self);
59 }
60
61 static PyObject* PythonQtVariantWrapper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
62 {
63 PythonQtVariantWrapper *self;
64
65 self = (PythonQtVariantWrapper *)type->tp_alloc(type, 0);
66 if (self != NULL) {
67 self->_variant = new QVariant();
68 self->_info = NULL;
69 }
70 return (PyObject *)self;
71 }
72
73 static int PythonQtVariantWrapper_init(PythonQtVariantWrapper *self, PyObject *args, PyObject *kwds)
74 {
75 return 0;
76 }
77
78 static PyObject *PythonQtVariantWrapper_classname(PythonQtVariantWrapper* type)
79 {
80 return PyString_FromString(type->_info->className());
81 }
82
83 static PyObject *PythonQtVariantWrapper_help(PythonQtVariantWrapper* type)
84 {
85 return PythonQt::self()->helpCalled(type->_info);
86 }
87
88
89 static PyMethodDef PythonQtVariantWrapper_methods[] = {
90 {"className", (PyCFunction)PythonQtVariantWrapper_classname, METH_NOARGS,
91 "Return the classname of the object"
92 },
93 {"help", (PyCFunction)PythonQtVariantWrapper_help, METH_NOARGS,
94 "Shows the help of available methods for this class"
95 },
96 {NULL} /* Sentinel */
97 };
98
99
100 static PyObject *PythonQtVariantWrapper_getattro(PyObject *obj,PyObject *name)
101 {
102 const char *attributeName;
103 PythonQtVariantWrapper *wt = (PythonQtVariantWrapper *)obj;
104
105 if ((attributeName = PyString_AsString(name)) == NULL) {
106 return NULL;
107 }
108
109 if (wt->_wrapper && wt->_info) {
110 PythonQtMemberInfo member = wt->_info->member(attributeName);
111 if (member._type == PythonQtMemberInfo::Slot) {
112 return PythonQtSlotFunction_New(member._slot, obj, NULL);
113 } else if (member._type == PythonQtMemberInfo::EnumValue) {
114 return PyInt_FromLong(member._enumValue);
115 }
116 }
117
118 // look for the interal methods (className(), help())
119 PyObject* internalMethod = Py_FindMethod( PythonQtVariantWrapper_methods, obj, (char*)attributeName);
120 if (internalMethod) {
121 return internalMethod;
122 }
123 PyErr_Clear();
124
125 if (qstrcmp(attributeName, "__dict__")==0) {
126 QStringList l = wt->_info->memberList(false);
127 PyObject* dict = PyDict_New();
128 foreach (QString name, l) {
129 //PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data());
130 PyDict_SetItemString(dict, name.toLatin1().data(), Py_None);
131 //Py_DECREF(o);
132 }
133 return dict;
134 }
135
136 QString error = QString(wt->_variant->typeName()) + " has no attribute named '" + QString(attributeName) + "'";
137 PyErr_SetString(PyExc_AttributeError, error.toLatin1().data());
138
139 return NULL;
140 }
141
142 QString qVariantToString(const QVariant& v) {
143 QString r;
144 switch (v.type()) {
145 case QVariant::Size:
146 r = QString::number(v.toSize().width()) + ", " + QString::number(v.toSize().height());
147 break;
148 case QVariant::SizeF:
149 r = QString::number(v.toSizeF().width()) + ", " + QString::number(v.toSizeF().height());
150 break;
151 case QVariant::Point:
152 r = QString::number(v.toPoint().x()) + ", " + QString::number(v.toPoint().y());
153 break;
154 case QVariant::PointF:
155 r = QString::number(v.toPointF().x()) + ", " + QString::number(v.toPointF().y());
156 break;
157 case QVariant::Rect:
158 r = QString::number(v.toRect().x()) + ", " + QString::number(v.toRect().y());
159 r += ", " + QString::number(v.toRect().width()) + ", " + QString::number(v.toRect().height());
160 break;
161 case QVariant::RectF:
162 r = QString::number(v.toRectF().x()) + ", " + QString::number(v.toRectF().y());
163 r += ", " + QString::number(v.toRectF().width()) + ", " + QString::number(v.toRectF().height());
164 break;
165 case QVariant::Date:
166 r = v.toDate().toString(Qt::ISODate);
167 break;
168 case QVariant::DateTime:
169 r = v.toDateTime().toString(Qt::ISODate);
170 break;
171 case QVariant::Time:
172 r = v.toTime().toString(Qt::ISODate);
173 break;
174 //TODO: add more printing for other variant types
175 default:
176 r = v.toString();
177 }
178 return r;
179 }
180
181 static PyObject * PythonQtVariantWrapper_str(PyObject * obj)
182 {
183 PythonQtVariantWrapper* wt = (PythonQtVariantWrapper*)obj;
184 QString val = qVariantToString(*wt->_variant);
185 return PyString_FromFormat("%s", val.toLatin1().constData());
186 }
187
188 static PyObject * PythonQtVariantWrapper_repr(PyObject * obj)
189 {
190 PythonQtVariantWrapper* wt = (PythonQtVariantWrapper*)obj;
191 QString val = qVariantToString(*wt->_variant);
192 return PyString_FromFormat("%s(%s)", wt->_variant->typeName(), val.toLatin1().constData());
193 }
194
195 static int PythonQtVariantWrapper_compare(PyObject * obj1, PyObject * obj2)
196 {
197 if (obj1->ob_type == &PythonQtVariantWrapper_Type &&
198 obj2->ob_type == &PythonQtVariantWrapper_Type) {
199
200 PythonQtVariantWrapper* w1 = (PythonQtVariantWrapper*)obj1;
201 PythonQtVariantWrapper* w2 = (PythonQtVariantWrapper*)obj2;
202 if (*w1->_variant == *w2->_variant) {
203 return 0;
204 } else {
205 return -1;
206 }
207 } else {
208 return -1;
209 }
210 }
211
212
213 PyTypeObject PythonQtVariantWrapper_Type = {
214 PyObject_HEAD_INIT(NULL)
215 0, /*ob_size*/
216 "PythonQt.PythonQtVariantWrapper", /*tp_name*/
217 sizeof(PythonQtVariantWrapper), /*tp_basicsize*/
218 0, /*tp_itemsize*/
219 (destructor)PythonQtVariantWrapper_dealloc, /*tp_dealloc*/
220 0, /*tp_print*/
221 0, /*tp_getattr*/
222 0, /*tp_setattr*/
223 PythonQtVariantWrapper_compare, /*tp_compare*/
224 PythonQtVariantWrapper_repr, /*tp_repr*/
225 0, /*tp_as_number*/
226 0, /*tp_as_sequence*/
227 0, /*tp_as_mapping*/
228 0, /*tp_hash */
229 0, /*tp_call*/
230 PythonQtVariantWrapper_str, /*tp_str*/
231 PythonQtVariantWrapper_getattro, /*tp_getattro*/
232 0, /*tp_setattro*/
233 0, /*tp_as_buffer*/
234 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
235 "PythonQtVariantWrapper object", /* tp_doc */
236 0, /* tp_traverse */
237 0, /* tp_clear */
238 0, /* tp_richcompare */
239 0, /* tp_weaklistoffset */
240 0, /* tp_iter */
241 0, /* tp_iternext */
242 0, /* tp_methods */
243 0, /* tp_members */
244 0, /* tp_getset */
245 0, /* tp_base */
246 0, /* tp_dict */
247 0, /* tp_descr_get */
248 0, /* tp_descr_set */
249 0, /* tp_dictoffset */
250 (initproc)PythonQtVariantWrapper_init, /* tp_init */
251 0, /* tp_alloc */
252 PythonQtVariantWrapper_new, /* tp_new */
253 };
254
255 //-------------------------------------------------------
256
@@ -0,0 +1,72
1 #ifndef _PYTHONQTVARIANTWRAPPER_H
2 #define _PYTHONQTVARIANTWRAPPER_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtVariantWrapper.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include <Python.h>
46
47 #include "structmember.h"
48 #include "methodobject.h"
49 #include "compile.h"
50 #include "eval.h"
51
52 #include <QVariant>
53
54 extern PyTypeObject PythonQtVariantWrapper_Type;
55
56 class PythonQtClassInfo;
57
58 //---------------------------------------------------------------
59 //! a Python wrapper object for Qt variants
60 typedef struct {
61 PyObject_HEAD
62
63 QVariant* _variant;
64
65 PythonQtClassInfo* _info;
66
67 QObject* _wrapper;
68
69 } PythonQtVariantWrapper;
70
71
72 #endif
@@ -0,0 +1,44
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtVariants.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-08
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtVariants.h"
43
44
@@ -0,0 +1,52
1 #ifndef _PYTHONQTVARIANTS_
2 #define _PYTHONQTVARIANTS_
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtVariants.h
39 // \author Florian Link
40 // \author Last changed by $Author: stk $
41 // \date 2006-08
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "Python.h"
46 #include "structmember.h"
47
48
49 #include "wrapper/PythonQtWrappedVariants.h"
50
51 #endif
52
@@ -0,0 +1,376
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtWrapper.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtWrapper.h"
43 #include <QObject>
44 #include "PythonQt.h"
45 #include "PythonQtSlot.h"
46 #include "PythonQtClassInfo.h"
47 #include "PythonQtConversion.h"
48
49 static void PythonQtWrapper_dealloc(PythonQtWrapper* self)
50 {
51 if (self->_wrappedPtr) {
52
53 //mlabDebugConst("Python","c++ wrapper removed " << self->_wrappedPtr << " " << self->_obj->className() << " " << self->_info->wrappedClassName().latin1());
54
55 PythonQt::priv()->removeWrapperPointer(self->_wrappedPtr);
56 // we own our qobject, so we delete it now:
57 delete self->_obj;
58 self->_obj = NULL;
59 if (self->_ownedByPythonQt) {
60 PythonQtSlotInfo* slot = PythonQt::priv()->getDestructorSlot(self->_info->wrappedCPPClassName());
61 if (slot) {
62 void* args[2];
63 args[0] = NULL;
64 args[1] = &self->_wrappedPtr;
65 slot->decorator()->qt_metacall(QMetaObject::InvokeMetaMethod, slot->slotIndex(), args);
66 self->_wrappedPtr = NULL;
67 } else {
68 // TODO: print a warning? we can not destroy that object
69 }
70 }
71 } else if (self->_obj) {
72 //mlabDebugConst("Python","qobject wrapper removed " << self->_obj->className() << " " << self->_info->wrappedClassName().latin1());
73 PythonQt::priv()->removeWrapperPointer(self->_obj);
74 if (self->_ownedByPythonQt) {
75 if (!self->_obj->parent()) {
76 delete self->_obj;
77 self->_obj = NULL;
78 }
79 }
80 }
81 self->ob_type->tp_free((PyObject*)self);
82 }
83
84 static PyObject* PythonQtWrapper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
85 {
86 PythonQtWrapper *self;
87
88 self = (PythonQtWrapper *)type->tp_alloc(type, 0);
89 if (self != NULL) {
90 self->_info = NULL;
91 self->_obj = NULL;
92 self->_wrappedPtr = NULL;
93 self->_ownedByPythonQt = false;
94 }
95 return (PyObject *)self;
96 }
97
98 static int PythonQtWrapper_init(PythonQtWrapper *self, PyObject *args, PyObject *kwds)
99 {
100 return 0;
101 }
102
103 static PyObject *PythonQtWrapper_classname(PythonQtWrapper* type)
104 {
105 return PyString_FromString(type->_info->className());
106 }
107
108 static PyObject *PythonQtWrapper_help(PythonQtWrapper* type)
109 {
110 return PythonQt::self()->helpCalled(type->_info);
111 }
112
113
114 static PyMethodDef PythonQtWrapper_methods[] = {
115 {"className", (PyCFunction)PythonQtWrapper_classname, METH_NOARGS,
116 "Return the classname of the object"
117 },
118 {"help", (PyCFunction)PythonQtWrapper_help, METH_NOARGS,
119 "Shows the help of available methods for this class"
120 },
121 {NULL} /* Sentinel */
122 };
123
124
125 static PyObject *PythonQtWrapper_getattro(PyObject *obj,PyObject *name)
126 {
127 const char *attributeName;
128 PythonQtWrapper *wt = (PythonQtWrapper *)obj;
129
130 if ((attributeName = PyString_AsString(name)) == NULL) {
131 return NULL;
132 }
133
134 if (!wt->_obj && !wt->_wrappedPtr) {
135 QString error = QString("Trying to read attribute '") + attributeName + "' from a destroyed " + wt->_info->className() + " object";
136 PyErr_SetString(PyExc_ValueError, error.toLatin1().data());
137 return NULL;
138 }
139
140 // mlabDebugConst("Python","get " << attributeName);
141
142 // TODO: dynamic properties are missing
143
144 PythonQtMemberInfo member = wt->_info->member(attributeName);
145 switch (member._type) {
146 case PythonQtMemberInfo::Property:
147 if (wt->_obj) {
148 return PythonQtConv::QVariantToPyObject(member._property.read(wt->_obj));
149 }
150 break;
151 case PythonQtMemberInfo::Slot:
152 return PythonQtSlotFunction_New(member._slot, obj, NULL);
153 break;
154 case PythonQtMemberInfo::EnumValue:
155 return PyInt_FromLong(member._enumValue);
156 break;
157 }
158
159 // look for the interal methods (className(), help())
160 PyObject* internalMethod = Py_FindMethod( PythonQtWrapper_methods, obj, (char*)attributeName);
161 if (internalMethod) {
162 return internalMethod;
163 }
164 PyErr_Clear();
165
166 if (wt->_obj) {
167 // look for a child
168 QObjectList children = wt->_obj->children();
169 for (int i = 0; i < children.count(); i++) {
170 QObject *child = children.at(i);
171 if (child->objectName() == attributeName) {
172 return PythonQt::self()->priv()->wrapQObject(child);
173 }
174 }
175 }
176
177 if (qstrcmp(attributeName, "__dict__")==0) {
178 QStringList l = wt->_info->memberList(false);
179 PyObject* dict = PyDict_New();
180 foreach (QString name, l) {
181 //PyObject* o = PyObject_GetAttrString(obj, name.toLatin1().data());
182 PyDict_SetItemString(dict, name.toLatin1().data(), Py_None);
183 //Py_DECREF(o);
184 }
185 // Note: we do not put children into the dict, is would look confusing?!
186 return dict;
187 }
188
189
190 QString error = QString(wt->_info->className()) + " has no attribute named '" + QString(attributeName) + "'";
191 PyErr_SetString(PyExc_AttributeError, error.toLatin1().data());
192 return NULL;
193 }
194
195 static int PythonQtWrapper_setattro(PyObject *obj,PyObject *name,PyObject *value)
196 {
197 QString error;
198 char *attributeName;
199 PythonQtWrapper *wt = (PythonQtWrapper *)obj;
200
201 if ((attributeName = PyString_AsString(name)) == NULL)
202 return -1;
203
204 if (!wt->_obj) {
205 error = QString("Trying to set attribute '") + attributeName + "' on a destroyed " + wt->_info->className() + " object";
206 PyErr_SetString(PyExc_AttributeError, error.toLatin1().data());
207 return -1;
208 }
209
210 PythonQtMemberInfo member = wt->_info->member(attributeName);
211 if (member._type == PythonQtMemberInfo::Property) {
212 QMetaProperty prop = member._property;
213 if (prop.isWritable()) {
214 QVariant v;
215 if (prop.isEnumType()) {
216 // this will give us either a string or an int, everything else will probably be an error
217 v = PythonQtConv::PyObjToQVariant(value);
218 } else {
219 int t = prop.userType();
220 v = PythonQtConv::PyObjToQVariant(value, t);
221 }
222 bool success = false;
223 if (v.isValid()) {
224 success = prop.write(wt->_obj, v);
225 }
226 if (success) {
227 return 0;
228 } else {
229 error = QString("Property '") + attributeName + "' of type '" +
230 prop.typeName() + "' does not accept an object of type "
231 + QString(value->ob_type->tp_name) + " (" + PythonQtConv::PyObjGetRepresentation(value) + ")";
232 }
233 } else {
234 error = QString("Property '") + attributeName + "' of " + wt->_info->className() + " object is not writable";
235 }
236 } else {
237 if (member._type == PythonQtMemberInfo::Slot) {
238 error = QString("Slot '") + attributeName + "' can not be overwritten on " + wt->_info->className() + " object";
239 } else if (member._type == PythonQtMemberInfo::EnumValue) {
240 error = QString("EnumValue '") + attributeName + "' can not be overwritten on " + wt->_info->className() + " object";
241 }
242 }
243
244 PyErr_SetString(PyExc_AttributeError, error.toLatin1().data());
245 return -1;
246 }
247
248 static PyObject * PythonQtWrapper_repr(PyObject * obj)
249 {
250 PythonQtWrapper* wt = (PythonQtWrapper*)obj;
251 if (wt->_wrappedPtr) {
252 if (wt->_obj) {
253 return PyString_FromFormat("%s (C++ Object 0x%x wrapped by %s 0x%x))", wt->_info->className(), wt->_wrappedPtr, wt->_obj->metaObject()->className(), wt->_obj);
254 } else {
255 return PyString_FromFormat("%s (C++ Object 0x%x unwrapped)", wt->_info->className(), wt->_wrappedPtr);
256 }
257 } else {
258 return PyString_FromFormat("%s (QObject 0x%x)", wt->_info->className(), wt->_obj, wt->_wrappedPtr);
259 }
260 }
261
262 static int PythonQtWrapper_compare(PyObject * obj1, PyObject * obj2)
263 {
264 if (obj1->ob_type == &PythonQtWrapper_Type &&
265 obj2->ob_type == &PythonQtWrapper_Type) {
266
267 PythonQtWrapper* w1 = (PythonQtWrapper*)obj1;
268 PythonQtWrapper* w2 = (PythonQtWrapper*)obj2;
269 if (w1->_wrappedPtr != NULL) {
270 if (w1->_wrappedPtr == w1->_wrappedPtr) {
271 return 0;
272 } else {
273 return -1;
274 }
275 } else if (w1->_obj == w2->_obj) {
276 return 0;
277 } else {
278 return -1;
279 }
280 } else {
281 return -1;
282 }
283 }
284
285 static int PythonQtWrapper_nonzero(PyObject *obj)
286 {
287 PythonQtWrapper* wt = (PythonQtWrapper*)obj;
288 return (wt->_wrappedPtr == NULL && wt->_obj == NULL)?0:1;
289 }
290
291 // we override nb_nonzero, so that one can do 'if' expressions to test for a NULL ptr
292 static PyNumberMethods PythonQtWrapper_as_number = {
293 0, /* nb_add */
294 0, /* nb_subtract */
295 0, /* nb_multiply */
296 0, /* nb_divide */
297 0, /* nb_remainder */
298 0, /* nb_divmod */
299 0, /* nb_power */
300 0, /* nb_negative */
301 0, /* nb_positive */
302 0, /* nb_absolute */
303 PythonQtWrapper_nonzero, /* nb_nonzero */
304 0, /* nb_invert */
305 0, /* nb_lshift */
306 0, /* nb_rshift */
307 0, /* nb_and */
308 0, /* nb_xor */
309 0, /* nb_or */
310 0, /* nb_coerce */
311 0, /* nb_int */
312 0, /* nb_long */
313 0, /* nb_float */
314 0, /* nb_oct */
315 0, /* nb_hex */
316 0, /* nb_inplace_add */
317 0, /* nb_inplace_subtract */
318 0, /* nb_inplace_multiply */
319 0, /* nb_inplace_divide */
320 0, /* nb_inplace_remainder */
321 0, /* nb_inplace_power */
322 0, /* nb_inplace_lshift */
323 0, /* nb_inplace_rshift */
324 0, /* nb_inplace_and */
325 0, /* nb_inplace_xor */
326 0, /* nb_inplace_or */
327 0, /* nb_floor_divide */
328 0, /* nb_true_divide */
329 0, /* nb_inplace_floor_divide */
330 0, /* nb_inplace_true_divide */
331 };
332
333 PyTypeObject PythonQtWrapper_Type = {
334 PyObject_HEAD_INIT(NULL)
335 0, /*ob_size*/
336 "PythonQt.PythonQtWrapper", /*tp_name*/
337 sizeof(PythonQtWrapper), /*tp_basicsize*/
338 0, /*tp_itemsize*/
339 (destructor)PythonQtWrapper_dealloc, /*tp_dealloc*/
340 0, /*tp_print*/
341 0, /*tp_getattr*/
342 0, /*tp_setattr*/
343 PythonQtWrapper_compare, /*tp_compare*/
344 PythonQtWrapper_repr, /*tp_repr*/
345 &PythonQtWrapper_as_number, /*tp_as_number*/
346 0, /*tp_as_sequence*/
347 0, /*tp_as_mapping*/
348 0, /*tp_hash */
349 0, /*tp_call*/
350 0, /*tp_str*/
351 PythonQtWrapper_getattro, /*tp_getattro*/
352 PythonQtWrapper_setattro, /*tp_setattro*/
353 0, /*tp_as_buffer*/
354 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
355 "PythonQtWrapper object", /* tp_doc */
356 0, /* tp_traverse */
357 0, /* tp_clear */
358 0, /* tp_richcompare */
359 0, /* tp_weaklistoffset */
360 0, /* tp_iter */
361 0, /* tp_iternext */
362 0, /* tp_methods */
363 0, /* tp_members */
364 0, /* tp_getset */
365 0, /* tp_base */
366 0, /* tp_dict */
367 0, /* tp_descr_get */
368 0, /* tp_descr_set */
369 0, /* tp_dictoffset */
370 (initproc)PythonQtWrapper_init, /* tp_init */
371 0, /* tp_alloc */
372 PythonQtWrapper_new, /* tp_new */
373 };
374
375 //-------------------------------------------------------
376
@@ -0,0 +1,78
1 #ifndef _PYTHONQTWRAPPER_H
2 #define _PYTHONQTWRAPPER_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtWrapper.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include <Python.h>
46
47 #include "PythonQtSystem.h"
48
49 #include "structmember.h"
50 #include "methodobject.h"
51 #include "compile.h"
52 #include "eval.h"
53
54 class PythonQtClassInfo;
55 class QObject;
56
57 extern PYTHONQT_EXPORT PyTypeObject PythonQtWrapper_Type;
58
59 //---------------------------------------------------------------
60 //! a Python wrapper object for Qt objects and C++ objects (that are themselves wrapped by wrapper QObjects)
61 typedef struct {
62 PyObject_HEAD
63
64 //! pointer to the wrapped Qt object or if _wrappedPtr is set, the Qt object that wraps the C++ Ptr
65 QObject* _obj;
66 //! optional C++ object Ptr that is wrapped by the above _obj
67 void* _wrappedPtr;
68
69 //! the class information, this is set even if the _obj or _wrappedPtr is NULL to support typed NULL pointers
70 PythonQtClassInfo* _info;
71
72 //! flag that stores if the object is owned by pythonQt
73 bool _ownedByPythonQt;
74
75 } PythonQtWrapper;
76
77
78 #endif No newline at end of file
This diff has been collapsed as it changes many lines, (564 lines changed) Show them Hide them
@@ -0,0 +1,564
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtScriptingConsole.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-10
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtScriptingConsole.h"
43
44 #include <QMenu>
45 #include <QMouseEvent>
46 #include <QKeyEvent>
47 #include <QApplication>
48 #include <QTextDocumentFragment>
49 #include <QTextBlock>
50 #include <QTextCursor>
51 #include <QDebug>
52 #include <QCompleter>
53 #include <QStringListModel>
54 #include <QScrollBar>
55
56 //-----------------------------------------------------------------------------
57
58 PythonQtScriptingConsole::PythonQtScriptingConsole(QWidget* parent, const PythonQtObjectPtr& context, Qt::WindowFlags windowFlags)
59 : QTextEdit(parent) {
60
61 setWindowFlags(windowFlags);
62
63 _defaultTextCharacterFormat = currentCharFormat();
64 _context = context;
65 _historyPosition = 0;
66
67 _completer = new QCompleter(this);
68 _completer->setWidget(this);
69 QObject::connect(_completer, SIGNAL(activated(const QString&)),
70 this, SLOT(insertCompletion(const QString&)));
71
72 clear();
73
74 connect(PythonQt::self(), SIGNAL(pythonStdOut(const QString&)), this, SLOT(stdOut(const QString&)));
75 connect(PythonQt::self(), SIGNAL(pythonStdErr(const QString&)), this, SLOT(stdErr(const QString&)));
76 }
77
78 //-----------------------------------------------------------------------------
79
80 void PythonQtScriptingConsole::stdOut(const QString& s)
81 {
82 _stdOut += s;
83 int idx;
84 while ((idx = _stdOut.indexOf('\n'))!=-1) {
85 consoleMessage(_stdOut.left(idx));
86 std::cout << _stdOut.left(idx).toLatin1().data() << std::endl;
87 _stdOut = _stdOut.mid(idx+1);
88 }
89 }
90
91 void PythonQtScriptingConsole::stdErr(const QString& s)
92 {
93 _stdErr += s;
94 int idx;
95 while ((idx = _stdErr.indexOf('\n'))!=-1) {
96 consoleMessage(_stdErr.left(idx));
97 std::cout << _stdErr.left(idx).toLatin1().data() << std::endl;
98 _stdErr = _stdErr.mid(idx+1);
99 }
100 }
101
102 void PythonQtScriptingConsole::flushStdOut()
103 {
104 if (!_stdOut.isEmpty()) {
105 stdOut("\n");
106 }
107 if (!_stdErr.isEmpty()) {
108 stdErr("\n");
109 }
110 }
111
112 //-----------------------------------------------------------------------------
113
114 PythonQtScriptingConsole::~PythonQtScriptingConsole() {
115 }
116
117
118
119 //-----------------------------------------------------------------------------
120
121 void PythonQtScriptingConsole::clear() {
122
123 QTextEdit::clear();
124 appendCommandPrompt();
125 }
126
127 //-----------------------------------------------------------------------------
128
129 void PythonQtScriptingConsole::executeLine(bool storeOnly)
130 {
131 QTextCursor textCursor = this->textCursor();
132 textCursor.movePosition(QTextCursor::End);
133
134 // Select the text from the command prompt until the end of the block
135 // and get the selected text.
136 textCursor.setPosition(commandPromptPosition());
137 textCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
138 QString code = textCursor.selectedText();
139
140 // i don't know where this trailing space is coming from, blast it!
141 if (code.endsWith(" ")) {
142 code.truncate(code.length()-1);
143 }
144
145 if (!code.isEmpty()) {
146 // Update the history
147 _history << code;
148 _historyPosition = _history.count();
149 _currentMultiLineCode += code + "\n";
150
151 if (!storeOnly) {
152 executeCode(_currentMultiLineCode);
153 _currentMultiLineCode = "";
154 }
155 }
156 // Insert a new command prompt
157 appendCommandPrompt(storeOnly);
158
159 }
160
161 void PythonQtScriptingConsole::executeCode(const QString& code)
162 {
163 // put visible cursor to the end of the line
164 QTextCursor cursor = QTextEdit::textCursor();
165 cursor.movePosition(QTextCursor::End);
166 setTextCursor(cursor);
167
168 int cursorPosition = this->textCursor().position();
169
170 // evaluate the code
171 _stdOut = "";
172 _stdErr = "";
173 PythonQtObjectPtr p;
174 p.setNewRef(PyRun_String(code.toLatin1().data(), Py_single_input, PyModule_GetDict(_context), PyModule_GetDict(_context)));
175 if (!p) {
176 PythonQt::self()->handleError();
177 }
178
179 flushStdOut();
180
181 bool messageInserted = (this->textCursor().position() != cursorPosition);
182
183 // If a message was inserted, then put another empty line before the command prompt
184 // to improve readability.
185 if (messageInserted) {
186 append(QString());
187 }
188 }
189
190
191 //-----------------------------------------------------------------------------
192
193 void PythonQtScriptingConsole::appendCommandPrompt(bool storeOnly) {
194 if (storeOnly) {
195 _commandPrompt = "...> ";
196 } else {
197 _commandPrompt = "py> ";
198 }
199 append(_commandPrompt);
200
201 QTextCursor cursor = textCursor();
202 cursor.movePosition(QTextCursor::End);
203 setTextCursor(cursor);
204 }
205
206
207
208 //-----------------------------------------------------------------------------
209
210 void PythonQtScriptingConsole::setCurrentFont(const QColor& color, bool bold) {
211
212 QTextCharFormat charFormat(_defaultTextCharacterFormat);
213
214 QFont font(charFormat.font());
215 font.setBold(bold);
216 charFormat.setFont(font);
217
218 QBrush brush(charFormat.foreground());
219 brush.setColor(color);
220 charFormat.setForeground(brush);
221
222 setCurrentCharFormat(charFormat);
223 }
224
225
226
227 //-----------------------------------------------------------------------------
228
229 int PythonQtScriptingConsole::commandPromptPosition() {
230
231 QTextCursor textCursor(this->textCursor());
232 textCursor.movePosition(QTextCursor::End);
233
234 return textCursor.block().position() + _commandPrompt.length();
235 }
236
237
238
239 //-----------------------------------------------------------------------------
240
241 void PythonQtScriptingConsole::insertCompletion(const QString& completion)
242 {
243 QTextCursor tc = textCursor();
244 tc.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor);
245 if (tc.selectedText()==".") {
246 tc.insertText(QString(".") + completion);
247 } else {
248 tc = textCursor();
249 tc.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor);
250 tc.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
251 tc.insertText(completion);
252 setTextCursor(tc);
253 }
254 }
255
256 //-----------------------------------------------------------------------------
257 void PythonQtScriptingConsole::handleTabCompletion()
258 {
259 QTextCursor textCursor = this->textCursor();
260 int pos = textCursor.position();
261 textCursor.setPosition(commandPromptPosition());
262 textCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
263 int startPos = textCursor.selectionStart();
264
265 int offset = pos-startPos;
266 QString text = textCursor.selectedText();
267
268 QString textToComplete;
269 int cur = offset;
270 while (cur--) {
271 QChar c = text.at(cur);
272 if (c.isLetterOrNumber() || c == '.' || c == '_') {
273 textToComplete.prepend(c);
274 } else {
275 break;
276 }
277 }
278
279
280 QString lookup;
281 QString compareText = textToComplete;
282 int dot = compareText.lastIndexOf('.');
283 if (dot!=-1) {
284 lookup = compareText.mid(0, dot);
285 compareText = compareText.mid(dot+1, offset);
286 }
287 if (!lookup.isEmpty() || !compareText.isEmpty()) {
288 compareText = compareText.toLower();
289 QStringList found;
290 QStringList l = PythonQt::self()->introspection(_context, lookup, PythonQt::Anything);
291 foreach (QString n, l) {
292 if (n.toLower().startsWith(compareText)) {
293 found << n;
294 }
295 }
296
297 if (!found.isEmpty()) {
298 _completer->setCompletionPrefix(compareText);
299 _completer->setCompletionMode(QCompleter::PopupCompletion);
300 _completer->setModel(new QStringListModel(found, _completer));
301 _completer->setCaseSensitivity(Qt::CaseInsensitive);
302 QTextCursor c = this->textCursor();
303 c.movePosition(QTextCursor::StartOfWord);
304 QRect cr = cursorRect(c);
305 cr.setWidth(_completer->popup()->sizeHintForColumn(0)
306 + _completer->popup()->verticalScrollBar()->sizeHint().width());
307 cr.translate(0,8);
308 _completer->complete(cr);
309 } else {
310 _completer->popup()->hide();
311 }
312 } else {
313 _completer->popup()->hide();
314 }
315 }
316
317 void PythonQtScriptingConsole::keyPressEvent(QKeyEvent* event) {
318
319 if (_completer && _completer->popup()->isVisible()) {
320 // The following keys are forwarded by the completer to the widget
321 switch (event->key()) {
322 case Qt::Key_Return:
323 if (!_completer->popup()->currentIndex().isValid()) {
324 insertCompletion(_completer->currentCompletion());
325 _completer->popup()->hide();
326 event->accept();
327 }
328 event->ignore();
329 return;
330 break;
331 case Qt::Key_Enter:
332 case Qt::Key_Escape:
333 case Qt::Key_Tab:
334 case Qt::Key_Backtab:
335
336 event->ignore();
337 return; // let the completer do default behavior
338 default:
339 break;
340 }
341 }
342 bool eventHandled = false;
343 QTextCursor textCursor = this->textCursor();
344
345 int key = event->key();
346 switch (key) {
347
348 case Qt::Key_Left:
349
350 // Moving the cursor left is limited to the position
351 // of the command prompt.
352
353 if (textCursor.position() <= commandPromptPosition()) {
354
355 QApplication::beep();
356 eventHandled = true;
357 }
358 break;
359
360 case Qt::Key_Up:
361
362 // Display the previous command in the history
363 if (_historyPosition>0) {
364 _historyPosition--;
365 changeHistory();
366 }
367
368 eventHandled = true;
369 break;
370
371 case Qt::Key_Down:
372
373 // Display the next command in the history
374 if (_historyPosition+1<_history.count()) {
375 _historyPosition++;
376 changeHistory();
377 }
378
379 eventHandled = true;
380 break;
381
382 case Qt::Key_Return:
383
384 executeLine(event->modifiers() & Qt::ShiftModifier);
385 eventHandled = true;
386 break;
387
388 case Qt::Key_Backspace:
389
390 if (textCursor.hasSelection()) {
391
392 cut();
393 eventHandled = true;
394
395 } else {
396
397 // Intercept backspace key event to check if
398 // deleting a character is allowed. It is not
399 // allowed, if the user wants to delete the
400 // command prompt.
401
402 if (textCursor.position() <= commandPromptPosition()) {
403
404 QApplication::beep();
405 eventHandled = true;
406 }
407 }
408 break;
409
410 case Qt::Key_Delete:
411
412 cut();
413 eventHandled = true;
414 break;
415
416 default:
417
418 if (key >= Qt::Key_Space && key <= Qt::Key_division) {
419
420 if (textCursor.hasSelection() && !verifySelectionBeforeDeletion()) {
421
422 // The selection must not be deleted.
423 eventHandled = true;
424
425 } else {
426
427 // The key is an input character, check if the cursor is
428 // behind the last command prompt, else inserting the
429 // character is not allowed.
430
431 int commandPromptPosition = this->commandPromptPosition();
432 if (textCursor.position() < commandPromptPosition) {
433
434 textCursor.setPosition(commandPromptPosition);
435 setTextCursor(textCursor);
436 }
437 }
438 }
439 }
440
441 if (eventHandled) {
442
443 _completer->popup()->hide();
444 event->accept();
445
446 } else {
447
448 QTextEdit::keyPressEvent(event);
449 QString text = event->text();
450 if (!text.isEmpty()) {
451 handleTabCompletion();
452 } else {
453 _completer->popup()->hide();
454 }
455 eventHandled = true;
456 }
457 }
458
459
460
461 //-----------------------------------------------------------------------------
462
463 void PythonQtScriptingConsole::cut() {
464
465 bool deletionAllowed = verifySelectionBeforeDeletion();
466 if (deletionAllowed) {
467 QTextEdit::cut();
468 }
469 }
470
471
472
473 //-----------------------------------------------------------------------------
474
475 bool PythonQtScriptingConsole::verifySelectionBeforeDeletion() {
476
477 bool deletionAllowed = true;
478
479
480 QTextCursor textCursor = this->textCursor();
481
482 int commandPromptPosition = this->commandPromptPosition();
483 int selectionStart = textCursor.selectionStart();
484 int selectionEnd = textCursor.selectionEnd();
485
486 if (textCursor.hasSelection()) {
487
488 // Selected text may only be deleted after the last command prompt.
489 // If the selection is partly after the command prompt set the selection
490 // to the part and deletion is allowed. If the selection occurs before the
491 // last command prompt, then deletion is not allowed.
492
493 if (selectionStart < commandPromptPosition ||
494 selectionEnd < commandPromptPosition) {
495
496 // Assure selectionEnd is bigger than selection start
497 if (selectionStart > selectionEnd) {
498 int tmp = selectionEnd;
499 selectionEnd = selectionStart;
500 selectionStart = tmp;
501 }
502
503 if (selectionEnd < commandPromptPosition) {
504
505 // Selection is completely before command prompt,
506 // so deletion is not allowed.
507 QApplication::beep();
508 deletionAllowed = false;
509
510 } else {
511
512 // The selectionEnd is after the command prompt, so set
513 // the selection start to the commandPromptPosition.
514 selectionStart = commandPromptPosition;
515 textCursor.setPosition(selectionStart);
516 textCursor.setPosition(selectionStart, QTextCursor::KeepAnchor);
517 setTextCursor(textCursor);
518 }
519 }
520
521 } else { // if (hasSelectedText())
522
523 // When there is no selected text, deletion is not allowed before the
524 // command prompt.
525 if (textCursor.position() < commandPromptPosition) {
526
527 QApplication::beep();
528 deletionAllowed = false;
529 }
530 }
531
532 return deletionAllowed;
533 }
534
535
536
537 //-----------------------------------------------------------------------------
538
539 void PythonQtScriptingConsole::changeHistory() {
540
541 // Select the text after the last command prompt ...
542 QTextCursor textCursor = this->textCursor();
543 textCursor.movePosition(QTextCursor::End);
544 textCursor.setPosition(commandPromptPosition(), QTextCursor::KeepAnchor);
545
546 // ... and replace it with the history text.
547 textCursor.insertText(_history.value(_historyPosition));
548
549 textCursor.movePosition(QTextCursor::End);
550 setTextCursor(textCursor);
551 }
552
553
554
555 //-----------------------------------------------------------------------------
556
557 void PythonQtScriptingConsole::consoleMessage(const QString & message) {
558
559 append(QString());
560 insertPlainText(message);
561
562 // Reset all font modifications done by the html string
563 setCurrentCharFormat(_defaultTextCharacterFormat);
564 }
@@ -0,0 +1,136
1 #ifndef _PythonQtScriptingConsole_H
2 #define _PythonQtScriptingConsole_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtScriptingConsole.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-10
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQt.h"
46 #include <QVariant>
47 #include <QTextEdit>
48
49 class QCompleter;
50
51 //-------------------------------------------------------------------------------
52 //! A simple console for python scripting
53 class PYTHONQT_EXPORT PythonQtScriptingConsole : public QTextEdit
54 {
55 Q_OBJECT
56
57 public:
58 PythonQtScriptingConsole(QWidget* parent, const PythonQtObjectPtr& context, Qt::WindowFlags i = 0);
59
60 ~PythonQtScriptingConsole();
61
62 public slots:
63 //! execute current line
64 void executeLine(bool storeOnly);
65
66 //! derived key press event
67 void keyPressEvent (QKeyEvent * e);
68
69 //! output from console
70 void consoleMessage(const QString & message);
71
72 //! get history
73 QStringList history() { return _history; }
74
75 //! set history
76 void setHistory(const QStringList& h) { _history = h; _historyPosition = 0; }
77
78 //! clear the console
79 void clear();
80
81 //! overridden to control which characters a user may delete
82 virtual void cut();
83
84 //! output redirection
85 void stdOut(const QString& s);
86 //! output redirection
87 void stdErr(const QString& s);
88
89 void insertCompletion(const QString&);
90
91 //! Appends a newline and command prompt at the end of the document.
92 void appendCommandPrompt(bool storeOnly = false);
93 protected:
94 //! handle the pressing of tab
95 void handleTabCompletion();
96
97 //! Returns the position of the command prompt
98 int commandPromptPosition();
99
100 //! Returns if deletion is allowed at the current cursor
101 //! (with and without selected text)
102 bool verifySelectionBeforeDeletion();
103
104 //! Sets the current font
105 void setCurrentFont(const QColor& color = QColor(0,0,0), bool bold = false);
106
107 //! change the history according to _historyPos
108 void changeHistory();
109
110 //! flush output that was not yet printed
111 void flushStdOut();
112
113 private:
114 void executeCode(const QString& code);
115
116 PythonQtObjectPtr _context;
117
118 QStringList _history;
119 int _historyPosition;
120
121 QString _clickedAnchor;
122 QString _storageKey;
123 QString _commandPrompt;
124
125 QString _currentMultiLineCode;
126
127 QString _stdOut;
128 QString _stdErr;
129
130 QTextCharFormat _defaultTextCharacterFormat;
131 QCompleter* _completer;
132 };
133
134
135
136 #endif No newline at end of file
@@ -0,0 +1,42
1 DEFINES += PYTHONQT_EXPORTS
2
3 HEADERS += \
4 $$PWD/PythonQt.h \
5 $$PWD/PythonQtStdDecorators.h \
6 $$PWD/PythonQtClassInfo.h \
7 $$PWD/PythonQtImporter.h \
8 $$PWD/PythonQtObjectPtr.h \
9 $$PWD/PythonQtSlot.h \
10 $$PWD/PythonQtStdOut.h \
11 $$PWD/PythonQtMisc.h \
12 $$PWD/PythonQtMethodInfo.h \
13 $$PWD/PythonQtImportFileInterface.h \
14 $$PWD/PythonQtConversion.h \
15 $$PWD/PythonQtSignalReceiver.h \
16 $$PWD/PythonQtWrapper.h \
17 $$PWD/PythonQtMetaObjectWrapper.h \
18 $$PWD/PythonQtCppWrapperFactory.h \
19 $$PWD/PythonQtVariants.h \
20 $$PWD/PythonQtVariantWrapper.h \
21 $$PWD/wrapper/PythonQtWrappedVariants.h \
22 $$PWD/gui/PythonQtScriptingConsole.h \
23 $$PWD/PythonQtSystem.h
24
25 SOURCES += \
26 $$PWD/PythonQtStdDecorators.cpp \
27 $$PWD/PythonQt.cpp \
28 $$PWD/PythonQtClassInfo.cpp \
29 $$PWD/PythonQtImporter.cpp \
30 $$PWD/PythonQtObjectPtr.cpp \
31 $$PWD/PythonQtStdOut.cpp \
32 $$PWD/PythonQtSlot.cpp \
33 $$PWD/PythonQtMisc.cpp \
34 $$PWD/PythonQtMethodInfo.cpp \
35 $$PWD/PythonQtConversion.cpp \
36 $$PWD/PythonQtSignalReceiver.cpp \
37 $$PWD/PythonQtVariants.cpp \
38 $$PWD/PythonQtVariantWrapper.cpp \
39 $$PWD/PythonQtWrapper.cpp \
40 $$PWD/PythonQtMetaObjectWrapper.cpp \
41 $$PWD/gui/PythonQtScriptingConsole.cpp
42
@@ -0,0 +1,18
1 # --------- PythonQt profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6
7 TARGET = PythonQt
8 TEMPLATE = lib
9
10
11 DESTDIR = ../lib
12
13 CONFIG += qt dll
14
15 include ( ../build/common.prf )
16 include ( ../build/python.prf )
17
18 include ( src.pri )
This diff has been collapsed as it changes many lines, (2506 lines changed) Show them Hide them
@@ -0,0 +1,2506
1
2 #include <QBitmap>
3 #include <QPainterPath>
4 #include <QVariant>
5 #include <QObject>
6 /****************************************************************************
7 ** Meta object code from reading C++ file 'qbitarray.h'
8 **
9 ** Created: Thu 12. Apr 14:07:28 2007
10 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
11 **
12 ** WARNING! All changes made in this file will be lost!
13 *****************************************************************************/
14
15 #include "qbitarray.h"
16 class PythonQtQBitArrayWrapper : public QObject {
17 Q_OBJECT
18
19 public:
20 public slots:
21 QVariant new_QBitArray() { return QBitArray(); }
22 QVariant new_QBitArray(int arg0,bool arg1) { return QBitArray(arg0,arg1); }
23 QVariant new_QBitArray(int arg0) { return QBitArray(arg0); }
24 QVariant new_QBitArray(const QBitArray & arg0) { return QBitArray(arg0); }
25 int size(QBitArray* obj) const {return obj->size(); }
26 int count(QBitArray* obj) const {return obj->count(); }
27 int count(QBitArray* obj,bool arg0) const {return obj->count(arg0); }
28 bool isEmpty(QBitArray* obj) const {return obj->isEmpty(); }
29 bool isNull(QBitArray* obj) const {return obj->isNull(); }
30 void resize(QBitArray* obj,int arg0) {obj->resize(arg0); }
31 void detach(QBitArray* obj) {obj->detach(); }
32 bool isDetached(QBitArray* obj) const {return obj->isDetached(); }
33 void clear(QBitArray* obj) {obj->clear(); }
34 bool testBit(QBitArray* obj,int arg0) const {return obj->testBit(arg0); }
35 void setBit(QBitArray* obj,int arg0) {obj->setBit(arg0); }
36 void setBit(QBitArray* obj,int arg0,bool arg1) {obj->setBit(arg0,arg1); }
37 void clearBit(QBitArray* obj,int arg0) {obj->clearBit(arg0); }
38 bool toggleBit(QBitArray* obj,int arg0) {return obj->toggleBit(arg0); }
39 bool at(QBitArray* obj,int arg0) const {return obj->at(arg0); }
40 bool fill(QBitArray* obj,bool arg0,int arg1) {return obj->fill(arg0,arg1); }
41 bool fill(QBitArray* obj,bool arg0) {return obj->fill(arg0); }
42 void fill(QBitArray* obj,bool arg0,int arg1,int arg2) {obj->fill(arg0,arg1,arg2); }
43 void truncate(QBitArray* obj,int arg0) {obj->truncate(arg0); }
44
45 };
46
47 /****************************************************************************
48 ** Meta object code from reading C++ file 'qdatetime.h'
49 **
50 ** Created: Thu 12. Apr 14:07:28 2007
51 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
52 **
53 ** WARNING! All changes made in this file will be lost!
54 *****************************************************************************/
55
56 #include "qdatetime.h"
57 class PythonQtQDateWrapper : public QObject {
58 Q_OBJECT
59
60 public:
61 public slots:
62 QVariant new_QDate() { return QDate(); }
63 QVariant new_QDate(int arg0,int arg1,int arg2) { return QDate(arg0,arg1,arg2); }
64 bool isNull(QDate* obj) const {return obj->isNull(); }
65 bool isValid(QDate* obj) const {return obj->isValid(); }
66 int year(QDate* obj) const {return obj->year(); }
67 int month(QDate* obj) const {return obj->month(); }
68 int day(QDate* obj) const {return obj->day(); }
69 int dayOfWeek(QDate* obj) const {return obj->dayOfWeek(); }
70 int dayOfYear(QDate* obj) const {return obj->dayOfYear(); }
71 int daysInMonth(QDate* obj) const {return obj->daysInMonth(); }
72 int daysInYear(QDate* obj) const {return obj->daysInYear(); }
73 int weekNumber(QDate* obj,int * arg0) const {return obj->weekNumber(arg0); }
74 int weekNumber(QDate* obj) const {return obj->weekNumber(); }
75 QString static_QDate_shortMonthName(int arg0) {return QDate::shortMonthName(arg0); }
76 QString static_QDate_shortDayName(int arg0) {return QDate::shortDayName(arg0); }
77 QString static_QDate_longMonthName(int arg0) {return QDate::longMonthName(arg0); }
78 QString static_QDate_longDayName(int arg0) {return QDate::longDayName(arg0); }
79 QString toString(QDate* obj,Qt::DateFormat arg0) const {return obj->toString(arg0); }
80 QString toString(QDate* obj) const {return obj->toString(); }
81 QString toString(QDate* obj,const QString & arg0) const {return obj->toString(arg0); }
82 bool setYMD(QDate* obj,int arg0,int arg1,int arg2) {return obj->setYMD(arg0,arg1,arg2); }
83 bool setDate(QDate* obj,int arg0,int arg1,int arg2) {return obj->setDate(arg0,arg1,arg2); }
84 QDate addDays(QDate* obj,int arg0) const {return obj->addDays(arg0); }
85 QDate addMonths(QDate* obj,int arg0) const {return obj->addMonths(arg0); }
86 QDate addYears(QDate* obj,int arg0) const {return obj->addYears(arg0); }
87 int daysTo(QDate* obj,const QDate & arg0) const {return obj->daysTo(arg0); }
88 QDate static_QDate_currentDate() {return QDate::currentDate(); }
89 QDate static_QDate_fromString(const QString & arg0,Qt::DateFormat arg1) {return QDate::fromString(arg0,arg1); }
90 QDate static_QDate_fromString(const QString & arg0) {return QDate::fromString(arg0); }
91 QDate static_QDate_fromString(const QString & arg0,const QString & arg1) {return QDate::fromString(arg0,arg1); }
92 bool static_QDate_isValid(int arg0,int arg1,int arg2) {return QDate::isValid(arg0,arg1,arg2); }
93 bool static_QDate_isLeapYear(int arg0) {return QDate::isLeapYear(arg0); }
94 uint static_QDate_gregorianToJulian(int arg0,int arg1,int arg2) {return QDate::gregorianToJulian(arg0,arg1,arg2); }
95 void static_QDate_julianToGregorian(uint arg0,int & arg1,int & arg2,int & arg3) {QDate::julianToGregorian(arg0,arg1,arg2,arg3); }
96 QDate fromJulianDay(QDate* obj,int arg0) {return obj->fromJulianDay(arg0); }
97 int toJulianDay(QDate* obj) const {return obj->toJulianDay(); }
98
99 };
100
101 class PythonQtQTimeWrapper : public QObject {
102 Q_OBJECT
103
104 public:
105 public slots:
106 QVariant new_QTime() { return QTime(); }
107 bool isNull(QTime* obj) const {return obj->isNull(); }
108 bool isValid(QTime* obj) const {return obj->isValid(); }
109 int hour(QTime* obj) const {return obj->hour(); }
110 int minute(QTime* obj) const {return obj->minute(); }
111 int second(QTime* obj) const {return obj->second(); }
112 int msec(QTime* obj) const {return obj->msec(); }
113 QString toString(QTime* obj,Qt::DateFormat arg0) const {return obj->toString(arg0); }
114 QString toString(QTime* obj) const {return obj->toString(); }
115 QString toString(QTime* obj,const QString & arg0) const {return obj->toString(arg0); }
116 bool setHMS(QTime* obj,int arg0,int arg1,int arg2,int arg3) {return obj->setHMS(arg0,arg1,arg2,arg3); }
117 bool setHMS(QTime* obj,int arg0,int arg1,int arg2) {return obj->setHMS(arg0,arg1,arg2); }
118 QTime addSecs(QTime* obj,int arg0) const {return obj->addSecs(arg0); }
119 int secsTo(QTime* obj,const QTime & arg0) const {return obj->secsTo(arg0); }
120 QTime addMSecs(QTime* obj,int arg0) const {return obj->addMSecs(arg0); }
121 int msecsTo(QTime* obj,const QTime & arg0) const {return obj->msecsTo(arg0); }
122 QTime static_QTime_currentTime() {return QTime::currentTime(); }
123 QTime static_QTime_fromString(const QString & arg0,Qt::DateFormat arg1) {return QTime::fromString(arg0,arg1); }
124 QTime static_QTime_fromString(const QString & arg0) {return QTime::fromString(arg0); }
125 QTime static_QTime_fromString(const QString & arg0,const QString & arg1) {return QTime::fromString(arg0,arg1); }
126 bool static_QTime_isValid(int arg0,int arg1,int arg2,int arg3) {return QTime::isValid(arg0,arg1,arg2,arg3); }
127 bool static_QTime_isValid(int arg0,int arg1,int arg2) {return QTime::isValid(arg0,arg1,arg2); }
128 void start(QTime* obj) {obj->start(); }
129 int restart(QTime* obj) {return obj->restart(); }
130 int elapsed(QTime* obj) const {return obj->elapsed(); }
131
132 };
133
134 class PythonQtQDateTimeWrapper : public QObject {
135 Q_OBJECT
136
137 public:
138 public slots:
139 QVariant new_QDateTime() { return QDateTime(); }
140 QVariant new_QDateTime(const QDate & arg0) { return QDateTime(arg0); }
141 QVariant new_QDateTime(const QDate & arg0,const QTime & arg1,Qt::TimeSpec arg2) { return QDateTime(arg0,arg1,arg2); }
142 QVariant new_QDateTime(const QDate & arg0,const QTime & arg1) { return QDateTime(arg0,arg1); }
143 QVariant new_QDateTime(const QDateTime & arg0) { return QDateTime(arg0); }
144 bool isNull(QDateTime* obj) const {return obj->isNull(); }
145 bool isValid(QDateTime* obj) const {return obj->isValid(); }
146 QDate date(QDateTime* obj) const {return obj->date(); }
147 QTime time(QDateTime* obj) const {return obj->time(); }
148 Qt::TimeSpec timeSpec(QDateTime* obj) const {return obj->timeSpec(); }
149 uint toTime_t(QDateTime* obj) const {return obj->toTime_t(); }
150 void setDate(QDateTime* obj,const QDate & arg0) {obj->setDate(arg0); }
151 void setTime(QDateTime* obj,const QTime & arg0) {obj->setTime(arg0); }
152 void setTimeSpec(QDateTime* obj,Qt::TimeSpec arg0) {obj->setTimeSpec(arg0); }
153 void setTime_t(QDateTime* obj,uint arg0) {obj->setTime_t(arg0); }
154 QString toString(QDateTime* obj,Qt::DateFormat arg0) const {return obj->toString(arg0); }
155 QString toString(QDateTime* obj) const {return obj->toString(); }
156 QString toString(QDateTime* obj,const QString & arg0) const {return obj->toString(arg0); }
157 QDateTime addDays(QDateTime* obj,int arg0) const {return obj->addDays(arg0); }
158 QDateTime addMonths(QDateTime* obj,int arg0) const {return obj->addMonths(arg0); }
159 QDateTime addYears(QDateTime* obj,int arg0) const {return obj->addYears(arg0); }
160 QDateTime addSecs(QDateTime* obj,int arg0) const {return obj->addSecs(arg0); }
161 QDateTime addMSecs(QDateTime* obj,qint64 arg0) const {return obj->addMSecs(arg0); }
162 QDateTime toTimeSpec(QDateTime* obj,Qt::TimeSpec arg0) const {return obj->toTimeSpec(arg0); }
163 QDateTime toLocalTime(QDateTime* obj) const {return obj->toLocalTime(); }
164 QDateTime toUTC(QDateTime* obj) const {return obj->toUTC(); }
165 int daysTo(QDateTime* obj,const QDateTime & arg0) const {return obj->daysTo(arg0); }
166 int secsTo(QDateTime* obj,const QDateTime & arg0) const {return obj->secsTo(arg0); }
167 QDateTime static_QDateTime_currentDateTime() {return QDateTime::currentDateTime(); }
168 QDateTime static_QDateTime_fromString(const QString & arg0,Qt::DateFormat arg1) {return QDateTime::fromString(arg0,arg1); }
169 QDateTime static_QDateTime_fromString(const QString & arg0) {return QDateTime::fromString(arg0); }
170 QDateTime static_QDateTime_fromString(const QString & arg0,const QString & arg1) {return QDateTime::fromString(arg0,arg1); }
171 QDateTime static_QDateTime_fromTime_t(uint arg0) {return QDateTime::fromTime_t(arg0); }
172
173 };
174
175 /****************************************************************************
176 ** Meta object code from reading C++ file 'qurl.h'
177 **
178 ** Created: Thu 12. Apr 14:07:28 2007
179 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
180 **
181 ** WARNING! All changes made in this file will be lost!
182 *****************************************************************************/
183
184 #include "qurl.h"
185 class PythonQtQUrlWrapper : public QObject {
186 Q_OBJECT
187
188 public:
189 Q_ENUMS(ParsingMode FormattingOption )
190 enum ParsingMode {TolerantMode = QUrl::TolerantMode,
191 StrictMode = QUrl::StrictMode };
192 enum FormattingOption {None = QUrl::None,
193 RemoveScheme = QUrl::RemoveScheme,
194 RemovePassword = QUrl::RemovePassword,
195 RemoveUserInfo = QUrl::RemoveUserInfo,
196 RemovePort = QUrl::RemovePort,
197 RemoveAuthority = QUrl::RemoveAuthority,
198 RemovePath = QUrl::RemovePath,
199 RemoveQuery = QUrl::RemoveQuery,
200 RemoveFragment = QUrl::RemoveFragment,
201 StripTrailingSlash = QUrl::StripTrailingSlash };
202 Q_DECLARE_FLAGS(FormattingOptions, FormattingOption)
203 public slots:
204 QVariant new_QUrl(const QString & arg0) { return QUrl(arg0); }
205 QVariant new_QUrl(const QString & arg0,ParsingMode arg1) { return QUrl(arg0,(QUrl::ParsingMode)arg1); }
206 QVariant new_QUrl(const QUrl & arg0) { return QUrl(arg0); }
207 void setUrl(QUrl* obj,const QString & arg0) {obj->setUrl(arg0); }
208 void setUrl(QUrl* obj,const QString & arg0,ParsingMode arg1) {obj->setUrl(arg0,(QUrl::ParsingMode)arg1); }
209 void setEncodedUrl(QUrl* obj,const QByteArray & arg0) {obj->setEncodedUrl(arg0); }
210 void setEncodedUrl(QUrl* obj,const QByteArray & arg0,ParsingMode arg1) {obj->setEncodedUrl(arg0,(QUrl::ParsingMode)arg1); }
211 bool isValid(QUrl* obj) const {return obj->isValid(); }
212 bool isEmpty(QUrl* obj) const {return obj->isEmpty(); }
213 void clear(QUrl* obj) {obj->clear(); }
214 void setScheme(QUrl* obj,const QString & arg0) {obj->setScheme(arg0); }
215 QString scheme(QUrl* obj) const {return obj->scheme(); }
216 void setAuthority(QUrl* obj,const QString & arg0) {obj->setAuthority(arg0); }
217 QString authority(QUrl* obj) const {return obj->authority(); }
218 void setUserInfo(QUrl* obj,const QString & arg0) {obj->setUserInfo(arg0); }
219 QString userInfo(QUrl* obj) const {return obj->userInfo(); }
220 void setUserName(QUrl* obj,const QString & arg0) {obj->setUserName(arg0); }
221 QString userName(QUrl* obj) const {return obj->userName(); }
222 void setPassword(QUrl* obj,const QString & arg0) {obj->setPassword(arg0); }
223 QString password(QUrl* obj) const {return obj->password(); }
224 void setHost(QUrl* obj,const QString & arg0) {obj->setHost(arg0); }
225 QString host(QUrl* obj) const {return obj->host(); }
226 void setPort(QUrl* obj,int arg0) {obj->setPort(arg0); }
227 int port(QUrl* obj) const {return obj->port(); }
228 int port(QUrl* obj,int arg0) const {return obj->port(arg0); }
229 void setPath(QUrl* obj,const QString & arg0) {obj->setPath(arg0); }
230 QString path(QUrl* obj) const {return obj->path(); }
231 bool hasQuery(QUrl* obj) const {return obj->hasQuery(); }
232 void setEncodedQuery(QUrl* obj,const QByteArray & arg0) {obj->setEncodedQuery(arg0); }
233 QByteArray encodedQuery(QUrl* obj) const {return obj->encodedQuery(); }
234 void setQueryDelimiters(QUrl* obj,char arg0,char arg1) {obj->setQueryDelimiters(arg0,arg1); }
235 char queryValueDelimiter(QUrl* obj) const {return obj->queryValueDelimiter(); }
236 char queryPairDelimiter(QUrl* obj) const {return obj->queryPairDelimiter(); }
237 void setQueryItems(QUrl* obj,const QList<QPair<QString,QString> > & arg0) {obj->setQueryItems(arg0); }
238 void addQueryItem(QUrl* obj,const QString & arg0,const QString & arg1) {obj->addQueryItem(arg0,arg1); }
239 QList<QPair<QString,QString> > queryItems(QUrl* obj) const {return obj->queryItems(); }
240 bool hasQueryItem(QUrl* obj,const QString & arg0) const {return obj->hasQueryItem(arg0); }
241 QString queryItemValue(QUrl* obj,const QString & arg0) const {return obj->queryItemValue(arg0); }
242 QStringList allQueryItemValues(QUrl* obj,const QString & arg0) const {return obj->allQueryItemValues(arg0); }
243 void removeQueryItem(QUrl* obj,const QString & arg0) {obj->removeQueryItem(arg0); }
244 void removeAllQueryItems(QUrl* obj,const QString & arg0) {obj->removeAllQueryItems(arg0); }
245 void setFragment(QUrl* obj,const QString & arg0) {obj->setFragment(arg0); }
246 QString fragment(QUrl* obj) const {return obj->fragment(); }
247 bool hasFragment(QUrl* obj) const {return obj->hasFragment(); }
248 QUrl resolved(QUrl* obj,const QUrl & arg0) const {return obj->resolved(arg0); }
249 bool isRelative(QUrl* obj) const {return obj->isRelative(); }
250 bool isParentOf(QUrl* obj,const QUrl & arg0) const {return obj->isParentOf(arg0); }
251 QUrl static_QUrl_fromLocalFile(const QString & arg0) {return QUrl::fromLocalFile(arg0); }
252 QString toLocalFile(QUrl* obj) const {return obj->toLocalFile(); }
253 QString toString(QUrl* obj,FormattingOptions arg0) const {return obj->toString((QUrl::FormattingOptions)QFlag(arg0)); }
254 QString toString(QUrl* obj) const {return obj->toString(); }
255 QByteArray toEncoded(QUrl* obj,FormattingOptions arg0) const {return obj->toEncoded((QUrl::FormattingOptions)QFlag(arg0)); }
256 QByteArray toEncoded(QUrl* obj) const {return obj->toEncoded(); }
257 QUrl static_QUrl_fromEncoded(const QByteArray & arg0) {return QUrl::fromEncoded(arg0); }
258 QUrl static_QUrl_fromEncoded(const QByteArray & arg0,ParsingMode arg1) {return QUrl::fromEncoded(arg0,(QUrl::ParsingMode)arg1); }
259 void detach(QUrl* obj) {obj->detach(); }
260 bool isDetached(QUrl* obj) const {return obj->isDetached(); }
261 QString static_QUrl_fromPercentEncoding(const QByteArray & arg0) {return QUrl::fromPercentEncoding(arg0); }
262 QByteArray static_QUrl_toPercentEncoding(const QString & arg0,const QByteArray & arg1,const QByteArray & arg2) {return QUrl::toPercentEncoding(arg0,arg1,arg2); }
263 QByteArray static_QUrl_toPercentEncoding(const QString & arg0,const QByteArray & arg1) {return QUrl::toPercentEncoding(arg0,arg1); }
264 QByteArray static_QUrl_toPercentEncoding(const QString & arg0) {return QUrl::toPercentEncoding(arg0); }
265 QString static_QUrl_fromPunycode(const QByteArray & arg0) {return QUrl::fromPunycode(arg0); }
266 QByteArray static_QUrl_toPunycode(const QString & arg0) {return QUrl::toPunycode(arg0); }
267 QString static_QUrl_fromAce(const QByteArray & arg0) {return QUrl::fromAce(arg0); }
268 QByteArray static_QUrl_toAce(const QString & arg0) {return QUrl::toAce(arg0); }
269 QStringList static_QUrl_idnWhitelist() {return QUrl::idnWhitelist(); }
270 void static_QUrl_setIdnWhitelist(const QStringList & arg0) {QUrl::setIdnWhitelist(arg0); }
271 QString errorString(QUrl* obj) const {return obj->errorString(); }
272
273 };
274
275 /****************************************************************************
276 ** Meta object code from reading C++ file 'qlocale.h'
277 **
278 ** Created: Thu 12. Apr 14:07:28 2007
279 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
280 **
281 ** WARNING! All changes made in this file will be lost!
282 *****************************************************************************/
283
284 #include "qlocale.h"
285 class PythonQtQLocaleWrapper : public QObject {
286 Q_OBJECT
287
288 public:
289 Q_ENUMS(Language Country FormatType NumberOption )
290 enum Language {C = QLocale::C,
291 Abkhazian = QLocale::Abkhazian,
292 Afan = QLocale::Afan,
293 Afar = QLocale::Afar,
294 Afrikaans = QLocale::Afrikaans,
295 Albanian = QLocale::Albanian,
296 Amharic = QLocale::Amharic,
297 Arabic = QLocale::Arabic,
298 Armenian = QLocale::Armenian,
299 Assamese = QLocale::Assamese,
300 Aymara = QLocale::Aymara,
301 Azerbaijani = QLocale::Azerbaijani,
302 Bashkir = QLocale::Bashkir,
303 Basque = QLocale::Basque,
304 Bengali = QLocale::Bengali,
305 Bhutani = QLocale::Bhutani,
306 Bihari = QLocale::Bihari,
307 Bislama = QLocale::Bislama,
308 Breton = QLocale::Breton,
309 Bulgarian = QLocale::Bulgarian,
310 Burmese = QLocale::Burmese,
311 Byelorussian = QLocale::Byelorussian,
312 Cambodian = QLocale::Cambodian,
313 Catalan = QLocale::Catalan,
314 Chinese = QLocale::Chinese,
315 Corsican = QLocale::Corsican,
316 Croatian = QLocale::Croatian,
317 Czech = QLocale::Czech,
318 Danish = QLocale::Danish,
319 Dutch = QLocale::Dutch,
320 English = QLocale::English,
321 Esperanto = QLocale::Esperanto,
322 Estonian = QLocale::Estonian,
323 Faroese = QLocale::Faroese,
324 FijiLanguage = QLocale::FijiLanguage,
325 Finnish = QLocale::Finnish,
326 French = QLocale::French,
327 Frisian = QLocale::Frisian,
328 Gaelic = QLocale::Gaelic,
329 Galician = QLocale::Galician,
330 Georgian = QLocale::Georgian,
331 German = QLocale::German,
332 Greek = QLocale::Greek,
333 Greenlandic = QLocale::Greenlandic,
334 Guarani = QLocale::Guarani,
335 Gujarati = QLocale::Gujarati,
336 Hausa = QLocale::Hausa,
337 Hebrew = QLocale::Hebrew,
338 Hindi = QLocale::Hindi,
339 Hungarian = QLocale::Hungarian,
340 Icelandic = QLocale::Icelandic,
341 Indonesian = QLocale::Indonesian,
342 Interlingua = QLocale::Interlingua,
343 Interlingue = QLocale::Interlingue,
344 Inuktitut = QLocale::Inuktitut,
345 Inupiak = QLocale::Inupiak,
346 Irish = QLocale::Irish,
347 Italian = QLocale::Italian,
348 Japanese = QLocale::Japanese,
349 Javanese = QLocale::Javanese,
350 Kannada = QLocale::Kannada,
351 Kashmiri = QLocale::Kashmiri,
352 Kazakh = QLocale::Kazakh,
353 Kinyarwanda = QLocale::Kinyarwanda,
354 Kirghiz = QLocale::Kirghiz,
355 Korean = QLocale::Korean,
356 Kurdish = QLocale::Kurdish,
357 Kurundi = QLocale::Kurundi,
358 Laothian = QLocale::Laothian,
359 Latin = QLocale::Latin,
360 Latvian = QLocale::Latvian,
361 Lingala = QLocale::Lingala,
362 Lithuanian = QLocale::Lithuanian,
363 Macedonian = QLocale::Macedonian,
364 Malagasy = QLocale::Malagasy,
365 Malay = QLocale::Malay,
366 Malayalam = QLocale::Malayalam,
367 Maltese = QLocale::Maltese,
368 Maori = QLocale::Maori,
369 Marathi = QLocale::Marathi,
370 Moldavian = QLocale::Moldavian,
371 Mongolian = QLocale::Mongolian,
372 NauruLanguage = QLocale::NauruLanguage,
373 Nepali = QLocale::Nepali,
374 Norwegian = QLocale::Norwegian,
375 Occitan = QLocale::Occitan,
376 Oriya = QLocale::Oriya,
377 Pashto = QLocale::Pashto,
378 Persian = QLocale::Persian,
379 Polish = QLocale::Polish,
380 Portuguese = QLocale::Portuguese,
381 Punjabi = QLocale::Punjabi,
382 Quechua = QLocale::Quechua,
383 RhaetoRomance = QLocale::RhaetoRomance,
384 Romanian = QLocale::Romanian,
385 Russian = QLocale::Russian,
386 Samoan = QLocale::Samoan,
387 Sangho = QLocale::Sangho,
388 Sanskrit = QLocale::Sanskrit,
389 Serbian = QLocale::Serbian,
390 SerboCroatian = QLocale::SerboCroatian,
391 Sesotho = QLocale::Sesotho,
392 Setswana = QLocale::Setswana,
393 Shona = QLocale::Shona,
394 Sindhi = QLocale::Sindhi,
395 Singhalese = QLocale::Singhalese,
396 Siswati = QLocale::Siswati,
397 Slovak = QLocale::Slovak,
398 Slovenian = QLocale::Slovenian,
399 Somali = QLocale::Somali,
400 Spanish = QLocale::Spanish,
401 Sundanese = QLocale::Sundanese,
402 Swahili = QLocale::Swahili,
403 Swedish = QLocale::Swedish,
404 Tagalog = QLocale::Tagalog,
405 Tajik = QLocale::Tajik,
406 Tamil = QLocale::Tamil,
407 Tatar = QLocale::Tatar,
408 Telugu = QLocale::Telugu,
409 Thai = QLocale::Thai,
410 Tibetan = QLocale::Tibetan,
411 Tigrinya = QLocale::Tigrinya,
412 TongaLanguage = QLocale::TongaLanguage,
413 Tsonga = QLocale::Tsonga,
414 Turkish = QLocale::Turkish,
415 Turkmen = QLocale::Turkmen,
416 Twi = QLocale::Twi,
417 Uigur = QLocale::Uigur,
418 Ukrainian = QLocale::Ukrainian,
419 Urdu = QLocale::Urdu,
420 Uzbek = QLocale::Uzbek,
421 Vietnamese = QLocale::Vietnamese,
422 Volapuk = QLocale::Volapuk,
423 Welsh = QLocale::Welsh,
424 Wolof = QLocale::Wolof,
425 Xhosa = QLocale::Xhosa,
426 Yiddish = QLocale::Yiddish,
427 Yoruba = QLocale::Yoruba,
428 Zhuang = QLocale::Zhuang,
429 Zulu = QLocale::Zulu,
430 Nynorsk = QLocale::Nynorsk,
431 Bosnian = QLocale::Bosnian,
432 Divehi = QLocale::Divehi,
433 Manx = QLocale::Manx,
434 Cornish = QLocale::Cornish,
435 LastLanguage = QLocale::LastLanguage };
436 enum Country {AnyCountry = QLocale::AnyCountry,
437 Afghanistan = QLocale::Afghanistan,
438 Albania = QLocale::Albania,
439 Algeria = QLocale::Algeria,
440 AmericanSamoa = QLocale::AmericanSamoa,
441 Andorra = QLocale::Andorra,
442 Angola = QLocale::Angola,
443 Anguilla = QLocale::Anguilla,
444 Antarctica = QLocale::Antarctica,
445 AntiguaAndBarbuda = QLocale::AntiguaAndBarbuda,
446 Argentina = QLocale::Argentina,
447 Armenia = QLocale::Armenia,
448 Aruba = QLocale::Aruba,
449 Australia = QLocale::Australia,
450 Austria = QLocale::Austria,
451 Azerbaijan = QLocale::Azerbaijan,
452 Bahamas = QLocale::Bahamas,
453 Bahrain = QLocale::Bahrain,
454 Bangladesh = QLocale::Bangladesh,
455 Barbados = QLocale::Barbados,
456 Belarus = QLocale::Belarus,
457 Belgium = QLocale::Belgium,
458 Belize = QLocale::Belize,
459 Benin = QLocale::Benin,
460 Bermuda = QLocale::Bermuda,
461 Bhutan = QLocale::Bhutan,
462 Bolivia = QLocale::Bolivia,
463 BosniaAndHerzegowina = QLocale::BosniaAndHerzegowina,
464 Botswana = QLocale::Botswana,
465 BouvetIsland = QLocale::BouvetIsland,
466 Brazil = QLocale::Brazil,
467 BritishIndianOceanTerritory = QLocale::BritishIndianOceanTerritory,
468 BruneiDarussalam = QLocale::BruneiDarussalam,
469 Bulgaria = QLocale::Bulgaria,
470 BurkinaFaso = QLocale::BurkinaFaso,
471 Burundi = QLocale::Burundi,
472 Cambodia = QLocale::Cambodia,
473 Cameroon = QLocale::Cameroon,
474 Canada = QLocale::Canada,
475 CapeVerde = QLocale::CapeVerde,
476 CaymanIslands = QLocale::CaymanIslands,
477 CentralAfricanRepublic = QLocale::CentralAfricanRepublic,
478 Chad = QLocale::Chad,
479 Chile = QLocale::Chile,
480 China = QLocale::China,
481 ChristmasIsland = QLocale::ChristmasIsland,
482 CocosIslands = QLocale::CocosIslands,
483 Colombia = QLocale::Colombia,
484 Comoros = QLocale::Comoros,
485 DemocraticRepublicOfCongo = QLocale::DemocraticRepublicOfCongo,
486 PeoplesRepublicOfCongo = QLocale::PeoplesRepublicOfCongo,
487 CookIslands = QLocale::CookIslands,
488 CostaRica = QLocale::CostaRica,
489 IvoryCoast = QLocale::IvoryCoast,
490 Croatia = QLocale::Croatia,
491 Cuba = QLocale::Cuba,
492 Cyprus = QLocale::Cyprus,
493 CzechRepublic = QLocale::CzechRepublic,
494 Denmark = QLocale::Denmark,
495 Djibouti = QLocale::Djibouti,
496 Dominica = QLocale::Dominica,
497 DominicanRepublic = QLocale::DominicanRepublic,
498 EastTimor = QLocale::EastTimor,
499 Ecuador = QLocale::Ecuador,
500 Egypt = QLocale::Egypt,
501 ElSalvador = QLocale::ElSalvador,
502 EquatorialGuinea = QLocale::EquatorialGuinea,
503 Eritrea = QLocale::Eritrea,
504 Estonia = QLocale::Estonia,
505 Ethiopia = QLocale::Ethiopia,
506 FalklandIslands = QLocale::FalklandIslands,
507 FaroeIslands = QLocale::FaroeIslands,
508 FijiCountry = QLocale::FijiCountry,
509 Finland = QLocale::Finland,
510 France = QLocale::France,
511 MetropolitanFrance = QLocale::MetropolitanFrance,
512 FrenchGuiana = QLocale::FrenchGuiana,
513 FrenchPolynesia = QLocale::FrenchPolynesia,
514 FrenchSouthernTerritories = QLocale::FrenchSouthernTerritories,
515 Gabon = QLocale::Gabon,
516 Gambia = QLocale::Gambia,
517 Georgia = QLocale::Georgia,
518 Germany = QLocale::Germany,
519 Ghana = QLocale::Ghana,
520 Gibraltar = QLocale::Gibraltar,
521 Greece = QLocale::Greece,
522 Greenland = QLocale::Greenland,
523 Grenada = QLocale::Grenada,
524 Guadeloupe = QLocale::Guadeloupe,
525 Guam = QLocale::Guam,
526 Guatemala = QLocale::Guatemala,
527 Guinea = QLocale::Guinea,
528 GuineaBissau = QLocale::GuineaBissau,
529 Guyana = QLocale::Guyana,
530 Haiti = QLocale::Haiti,
531 HeardAndMcDonaldIslands = QLocale::HeardAndMcDonaldIslands,
532 Honduras = QLocale::Honduras,
533 HongKong = QLocale::HongKong,
534 Hungary = QLocale::Hungary,
535 Iceland = QLocale::Iceland,
536 India = QLocale::India,
537 Indonesia = QLocale::Indonesia,
538 Iran = QLocale::Iran,
539 Iraq = QLocale::Iraq,
540 Ireland = QLocale::Ireland,
541 Israel = QLocale::Israel,
542 Italy = QLocale::Italy,
543 Jamaica = QLocale::Jamaica,
544 Japan = QLocale::Japan,
545 Jordan = QLocale::Jordan,
546 Kazakhstan = QLocale::Kazakhstan,
547 Kenya = QLocale::Kenya,
548 Kiribati = QLocale::Kiribati,
549 DemocraticRepublicOfKorea = QLocale::DemocraticRepublicOfKorea,
550 RepublicOfKorea = QLocale::RepublicOfKorea,
551 Kuwait = QLocale::Kuwait,
552 Kyrgyzstan = QLocale::Kyrgyzstan,
553 Lao = QLocale::Lao,
554 Latvia = QLocale::Latvia,
555 Lebanon = QLocale::Lebanon,
556 Lesotho = QLocale::Lesotho,
557 Liberia = QLocale::Liberia,
558 LibyanArabJamahiriya = QLocale::LibyanArabJamahiriya,
559 Liechtenstein = QLocale::Liechtenstein,
560 Lithuania = QLocale::Lithuania,
561 Luxembourg = QLocale::Luxembourg,
562 Macau = QLocale::Macau,
563 Macedonia = QLocale::Macedonia,
564 Madagascar = QLocale::Madagascar,
565 Malawi = QLocale::Malawi,
566 Malaysia = QLocale::Malaysia,
567 Maldives = QLocale::Maldives,
568 Mali = QLocale::Mali,
569 Malta = QLocale::Malta,
570 MarshallIslands = QLocale::MarshallIslands,
571 Martinique = QLocale::Martinique,
572 Mauritania = QLocale::Mauritania,
573 Mauritius = QLocale::Mauritius,
574 Mayotte = QLocale::Mayotte,
575 Mexico = QLocale::Mexico,
576 Micronesia = QLocale::Micronesia,
577 Moldova = QLocale::Moldova,
578 Monaco = QLocale::Monaco,
579 Mongolia = QLocale::Mongolia,
580 Montserrat = QLocale::Montserrat,
581 Morocco = QLocale::Morocco,
582 Mozambique = QLocale::Mozambique,
583 Myanmar = QLocale::Myanmar,
584 Namibia = QLocale::Namibia,
585 NauruCountry = QLocale::NauruCountry,
586 Nepal = QLocale::Nepal,
587 Netherlands = QLocale::Netherlands,
588 NetherlandsAntilles = QLocale::NetherlandsAntilles,
589 NewCaledonia = QLocale::NewCaledonia,
590 NewZealand = QLocale::NewZealand,
591 Nicaragua = QLocale::Nicaragua,
592 Niger = QLocale::Niger,
593 Nigeria = QLocale::Nigeria,
594 Niue = QLocale::Niue,
595 NorfolkIsland = QLocale::NorfolkIsland,
596 NorthernMarianaIslands = QLocale::NorthernMarianaIslands,
597 Norway = QLocale::Norway,
598 Oman = QLocale::Oman,
599 Pakistan = QLocale::Pakistan,
600 Palau = QLocale::Palau,
601 PalestinianTerritory = QLocale::PalestinianTerritory,
602 Panama = QLocale::Panama,
603 PapuaNewGuinea = QLocale::PapuaNewGuinea,
604 Paraguay = QLocale::Paraguay,
605 Peru = QLocale::Peru,
606 Philippines = QLocale::Philippines,
607 Pitcairn = QLocale::Pitcairn,
608 Poland = QLocale::Poland,
609 Portugal = QLocale::Portugal,
610 PuertoRico = QLocale::PuertoRico,
611 Qatar = QLocale::Qatar,
612 Reunion = QLocale::Reunion,
613 Romania = QLocale::Romania,
614 RussianFederation = QLocale::RussianFederation,
615 Rwanda = QLocale::Rwanda,
616 SaintKittsAndNevis = QLocale::SaintKittsAndNevis,
617 StLucia = QLocale::StLucia,
618 StVincentAndTheGrenadines = QLocale::StVincentAndTheGrenadines,
619 Samoa = QLocale::Samoa,
620 SanMarino = QLocale::SanMarino,
621 SaoTomeAndPrincipe = QLocale::SaoTomeAndPrincipe,
622 SaudiArabia = QLocale::SaudiArabia,
623 Senegal = QLocale::Senegal,
624 Seychelles = QLocale::Seychelles,
625 SierraLeone = QLocale::SierraLeone,
626 Singapore = QLocale::Singapore,
627 Slovakia = QLocale::Slovakia,
628 Slovenia = QLocale::Slovenia,
629 SolomonIslands = QLocale::SolomonIslands,
630 Somalia = QLocale::Somalia,
631 SouthAfrica = QLocale::SouthAfrica,
632 SouthGeorgiaAndTheSouthSandwichIslands = QLocale::SouthGeorgiaAndTheSouthSandwichIslands,
633 Spain = QLocale::Spain,
634 SriLanka = QLocale::SriLanka,
635 StHelena = QLocale::StHelena,
636 StPierreAndMiquelon = QLocale::StPierreAndMiquelon,
637 Sudan = QLocale::Sudan,
638 Suriname = QLocale::Suriname,
639 SvalbardAndJanMayenIslands = QLocale::SvalbardAndJanMayenIslands,
640 Swaziland = QLocale::Swaziland,
641 Sweden = QLocale::Sweden,
642 Switzerland = QLocale::Switzerland,
643 SyrianArabRepublic = QLocale::SyrianArabRepublic,
644 Taiwan = QLocale::Taiwan,
645 Tajikistan = QLocale::Tajikistan,
646 Tanzania = QLocale::Tanzania,
647 Thailand = QLocale::Thailand,
648 Togo = QLocale::Togo,
649 Tokelau = QLocale::Tokelau,
650 TongaCountry = QLocale::TongaCountry,
651 TrinidadAndTobago = QLocale::TrinidadAndTobago,
652 Tunisia = QLocale::Tunisia,
653 Turkey = QLocale::Turkey,
654 Turkmenistan = QLocale::Turkmenistan,
655 TurksAndCaicosIslands = QLocale::TurksAndCaicosIslands,
656 Tuvalu = QLocale::Tuvalu,
657 Uganda = QLocale::Uganda,
658 Ukraine = QLocale::Ukraine,
659 UnitedArabEmirates = QLocale::UnitedArabEmirates,
660 UnitedKingdom = QLocale::UnitedKingdom,
661 UnitedStates = QLocale::UnitedStates,
662 UnitedStatesMinorOutlyingIslands = QLocale::UnitedStatesMinorOutlyingIslands,
663 Uruguay = QLocale::Uruguay,
664 Uzbekistan = QLocale::Uzbekistan,
665 Vanuatu = QLocale::Vanuatu,
666 VaticanCityState = QLocale::VaticanCityState,
667 Venezuela = QLocale::Venezuela,
668 VietNam = QLocale::VietNam,
669 BritishVirginIslands = QLocale::BritishVirginIslands,
670 USVirginIslands = QLocale::USVirginIslands,
671 WallisAndFutunaIslands = QLocale::WallisAndFutunaIslands,
672 WesternSahara = QLocale::WesternSahara,
673 Yemen = QLocale::Yemen,
674 Yugoslavia = QLocale::Yugoslavia,
675 Zambia = QLocale::Zambia,
676 Zimbabwe = QLocale::Zimbabwe,
677 SerbiaAndMontenegro = QLocale::SerbiaAndMontenegro,
678 LastCountry = QLocale::LastCountry };
679 enum FormatType {LongFormat = QLocale::LongFormat,
680 ShortFormat = QLocale::ShortFormat };
681 enum NumberOption {OmitGroupSeparator = QLocale::OmitGroupSeparator,
682 RejectGroupSeparator = QLocale::RejectGroupSeparator };
683 Q_DECLARE_FLAGS(NumberOptions, NumberOption)
684 public slots:
685 QVariant new_QLocale(const QString & arg0) { return QLocale(arg0); }
686 QVariant new_QLocale(Language arg0,Country arg1) { return QLocale((QLocale::Language)arg0,(QLocale::Country)arg1); }
687 QVariant new_QLocale(Language arg0) { return QLocale((QLocale::Language)arg0); }
688 QVariant new_QLocale(const QLocale & arg0) { return QLocale(arg0); }
689 Language language(QLocale* obj) const {return (PythonQtQLocaleWrapper::Language)obj->language(); }
690 Country country(QLocale* obj) const {return (PythonQtQLocaleWrapper::Country)obj->country(); }
691 QString name(QLocale* obj) const {return obj->name(); }
692 short toShort(QLocale* obj,const QString & arg0,bool * arg1,int arg2) const {return obj->toShort(arg0,arg1,arg2); }
693 short toShort(QLocale* obj,const QString & arg0,bool * arg1) const {return obj->toShort(arg0,arg1); }
694 short toShort(QLocale* obj,const QString & arg0) const {return obj->toShort(arg0); }
695 ushort toUShort(QLocale* obj,const QString & arg0,bool * arg1,int arg2) const {return obj->toUShort(arg0,arg1,arg2); }
696 ushort toUShort(QLocale* obj,const QString & arg0,bool * arg1) const {return obj->toUShort(arg0,arg1); }
697 ushort toUShort(QLocale* obj,const QString & arg0) const {return obj->toUShort(arg0); }
698 int toInt(QLocale* obj,const QString & arg0,bool * arg1,int arg2) const {return obj->toInt(arg0,arg1,arg2); }
699 int toInt(QLocale* obj,const QString & arg0,bool * arg1) const {return obj->toInt(arg0,arg1); }
700 int toInt(QLocale* obj,const QString & arg0) const {return obj->toInt(arg0); }
701 uint toUInt(QLocale* obj,const QString & arg0,bool * arg1,int arg2) const {return obj->toUInt(arg0,arg1,arg2); }
702 uint toUInt(QLocale* obj,const QString & arg0,bool * arg1) const {return obj->toUInt(arg0,arg1); }
703 uint toUInt(QLocale* obj,const QString & arg0) const {return obj->toUInt(arg0); }
704 qlonglong toLongLong(QLocale* obj,const QString & arg0,bool * arg1,int arg2) const {return obj->toLongLong(arg0,arg1,arg2); }
705 qlonglong toLongLong(QLocale* obj,const QString & arg0,bool * arg1) const {return obj->toLongLong(arg0,arg1); }
706 qlonglong toLongLong(QLocale* obj,const QString & arg0) const {return obj->toLongLong(arg0); }
707 qlonglong toULongLong(QLocale* obj,const QString & arg0,bool * arg1,int arg2) const {return obj->toULongLong(arg0,arg1,arg2); }
708 qlonglong toULongLong(QLocale* obj,const QString & arg0,bool * arg1) const {return obj->toULongLong(arg0,arg1); }
709 qlonglong toULongLong(QLocale* obj,const QString & arg0) const {return obj->toULongLong(arg0); }
710 float toFloat(QLocale* obj,const QString & arg0,bool * arg1) const {return obj->toFloat(arg0,arg1); }
711 float toFloat(QLocale* obj,const QString & arg0) const {return obj->toFloat(arg0); }
712 double toDouble(QLocale* obj,const QString & arg0,bool * arg1) const {return obj->toDouble(arg0,arg1); }
713 double toDouble(QLocale* obj,const QString & arg0) const {return obj->toDouble(arg0); }
714 QString toString(QLocale* obj,qlonglong arg0) const {return obj->toString(arg0); }
715 QString toString(QLocale* obj,qulonglong arg0) const {return obj->toString(arg0); }
716 QString toString(QLocale* obj,short arg0) const {return obj->toString(arg0); }
717 QString toString(QLocale* obj,ushort arg0) const {return obj->toString(arg0); }
718 QString toString(QLocale* obj,int arg0) const {return obj->toString(arg0); }
719 QString toString(QLocale* obj,uint arg0) const {return obj->toString(arg0); }
720 QString toString(QLocale* obj,double arg0,char arg1,int arg2) const {return obj->toString(arg0,arg1,arg2); }
721 QString toString(QLocale* obj,double arg0,char arg1) const {return obj->toString(arg0,arg1); }
722 QString toString(QLocale* obj,double arg0) const {return obj->toString(arg0); }
723 QString toString(QLocale* obj,float arg0,char arg1,int arg2) const {return obj->toString(arg0,arg1,arg2); }
724 QString toString(QLocale* obj,float arg0,char arg1) const {return obj->toString(arg0,arg1); }
725 QString toString(QLocale* obj,float arg0) const {return obj->toString(arg0); }
726 QString toString(QLocale* obj,const QDate & arg0,const QString & arg1) const {return obj->toString(arg0,arg1); }
727 QString toString(QLocale* obj,const QDate & arg0,FormatType arg1) const {return obj->toString(arg0,(QLocale::FormatType)arg1); }
728 QString toString(QLocale* obj,const QDate & arg0) const {return obj->toString(arg0); }
729 QString toString(QLocale* obj,const QTime & arg0,const QString & arg1) const {return obj->toString(arg0,arg1); }
730 QString toString(QLocale* obj,const QTime & arg0,FormatType arg1) const {return obj->toString(arg0,(QLocale::FormatType)arg1); }
731 QString toString(QLocale* obj,const QTime & arg0) const {return obj->toString(arg0); }
732 QString dateFormat(QLocale* obj,FormatType arg0) const {return obj->dateFormat((QLocale::FormatType)arg0); }
733 QString dateFormat(QLocale* obj) const {return obj->dateFormat(); }
734 QString timeFormat(QLocale* obj,FormatType arg0) const {return obj->timeFormat((QLocale::FormatType)arg0); }
735 QString timeFormat(QLocale* obj) const {return obj->timeFormat(); }
736 QChar decimalPoint(QLocale* obj) const {return obj->decimalPoint(); }
737 QChar groupSeparator(QLocale* obj) const {return obj->groupSeparator(); }
738 QChar percent(QLocale* obj) const {return obj->percent(); }
739 QChar zeroDigit(QLocale* obj) const {return obj->zeroDigit(); }
740 QChar negativeSign(QLocale* obj) const {return obj->negativeSign(); }
741 QChar exponential(QLocale* obj) const {return obj->exponential(); }
742 QString monthName(QLocale* obj,int arg0,FormatType arg1) const {return obj->monthName(arg0,(QLocale::FormatType)arg1); }
743 QString monthName(QLocale* obj,int arg0) const {return obj->monthName(arg0); }
744 QString dayName(QLocale* obj,int arg0,FormatType arg1) const {return obj->dayName(arg0,(QLocale::FormatType)arg1); }
745 QString dayName(QLocale* obj,int arg0) const {return obj->dayName(arg0); }
746 QString static_QLocale_languageToString(Language arg0) {return QLocale::languageToString((QLocale::Language)arg0); }
747 QString static_QLocale_countryToString(Country arg0) {return QLocale::countryToString((QLocale::Country)arg0); }
748 void static_QLocale_setDefault(const QLocale & arg0) {QLocale::setDefault(arg0); }
749 QLocale static_QLocale_c() {return QLocale::c(); }
750 QLocale static_QLocale_system() {return QLocale::system(); }
751 void setNumberOptions(QLocale* obj,NumberOptions arg0) {obj->setNumberOptions((QLocale::NumberOptions)QFlag(arg0)); }
752 NumberOptions numberOptions(QLocale* obj) const {return (PythonQtQLocaleWrapper::NumberOptions)QFlag(obj->numberOptions()); }
753
754 };
755
756 class PythonQtQSystemLocaleWrapper : public QObject {
757 Q_OBJECT
758
759 public:
760 Q_ENUMS(QueryType )
761 enum QueryType {LanguageId = QSystemLocale::LanguageId,
762 CountryId = QSystemLocale::CountryId,
763 DecimalPoint = QSystemLocale::DecimalPoint,
764 GroupSeparator = QSystemLocale::GroupSeparator,
765 ZeroDigit = QSystemLocale::ZeroDigit,
766 NegativeSign = QSystemLocale::NegativeSign,
767 DateFormatLong = QSystemLocale::DateFormatLong,
768 DateFormatShort = QSystemLocale::DateFormatShort,
769 TimeFormatLong = QSystemLocale::TimeFormatLong,
770 TimeFormatShort = QSystemLocale::TimeFormatShort,
771 DayNameLong = QSystemLocale::DayNameLong,
772 DayNameShort = QSystemLocale::DayNameShort,
773 MonthNameLong = QSystemLocale::MonthNameLong,
774 MonthNameShort = QSystemLocale::MonthNameShort,
775 DateToStringLong = QSystemLocale::DateToStringLong,
776 DateToStringShort = QSystemLocale::DateToStringShort,
777 TimeToStringLong = QSystemLocale::TimeToStringLong,
778 TimeToStringShort = QSystemLocale::TimeToStringShort };
779 public slots:
780 void delete_QSystemLocale(QSystemLocale* obj) { delete obj; }
781 QSystemLocale* new_QSystemLocale() { return new QSystemLocale(); }
782 QVariant query(QSystemLocale* obj,QueryType arg0,QVariant arg1) const {return obj->query((QSystemLocale::QueryType)arg0,arg1); }
783 QLocale fallbackLocale(QSystemLocale* obj) const {return obj->fallbackLocale(); }
784
785 };
786
787 /****************************************************************************
788 ** Meta object code from reading C++ file 'qrect.h'
789 **
790 ** Created: Thu 12. Apr 14:07:28 2007
791 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
792 **
793 ** WARNING! All changes made in this file will be lost!
794 *****************************************************************************/
795
796 #include "qrect.h"
797 class PythonQtQRectWrapper : public QObject {
798 Q_OBJECT
799
800 public:
801 public slots:
802 QVariant new_QRect() { return QRect(); }
803 QVariant new_QRect(const QPoint & arg0,const QPoint & arg1) { return QRect(arg0,arg1); }
804 QVariant new_QRect(const QPoint & arg0,const QSize & arg1) { return QRect(arg0,arg1); }
805 QVariant new_QRect(int arg0,int arg1,int arg2,int arg3) { return QRect(arg0,arg1,arg2,arg3); }
806 bool isNull(QRect* obj) const {return obj->isNull(); }
807 bool isEmpty(QRect* obj) const {return obj->isEmpty(); }
808 bool isValid(QRect* obj) const {return obj->isValid(); }
809 int left(QRect* obj) const {return obj->left(); }
810 int top(QRect* obj) const {return obj->top(); }
811 int right(QRect* obj) const {return obj->right(); }
812 int bottom(QRect* obj) const {return obj->bottom(); }
813 QRect normalized(QRect* obj) const {return obj->normalized(); }
814 int x(QRect* obj) const {return obj->x(); }
815 int y(QRect* obj) const {return obj->y(); }
816 void setLeft(QRect* obj,int arg0) {obj->setLeft(arg0); }
817 void setTop(QRect* obj,int arg0) {obj->setTop(arg0); }
818 void setRight(QRect* obj,int arg0) {obj->setRight(arg0); }
819 void setBottom(QRect* obj,int arg0) {obj->setBottom(arg0); }
820 void setX(QRect* obj,int arg0) {obj->setX(arg0); }
821 void setY(QRect* obj,int arg0) {obj->setY(arg0); }
822 void setTopLeft(QRect* obj,const QPoint & arg0) {obj->setTopLeft(arg0); }
823 void setBottomRight(QRect* obj,const QPoint & arg0) {obj->setBottomRight(arg0); }
824 void setTopRight(QRect* obj,const QPoint & arg0) {obj->setTopRight(arg0); }
825 void setBottomLeft(QRect* obj,const QPoint & arg0) {obj->setBottomLeft(arg0); }
826 QPoint topLeft(QRect* obj) const {return obj->topLeft(); }
827 QPoint bottomRight(QRect* obj) const {return obj->bottomRight(); }
828 QPoint topRight(QRect* obj) const {return obj->topRight(); }
829 QPoint bottomLeft(QRect* obj) const {return obj->bottomLeft(); }
830 QPoint center(QRect* obj) const {return obj->center(); }
831 void moveLeft(QRect* obj,int arg0) {obj->moveLeft(arg0); }
832 void moveTop(QRect* obj,int arg0) {obj->moveTop(arg0); }
833 void moveRight(QRect* obj,int arg0) {obj->moveRight(arg0); }
834 void moveBottom(QRect* obj,int arg0) {obj->moveBottom(arg0); }
835 void moveTopLeft(QRect* obj,const QPoint & arg0) {obj->moveTopLeft(arg0); }
836 void moveBottomRight(QRect* obj,const QPoint & arg0) {obj->moveBottomRight(arg0); }
837 void moveTopRight(QRect* obj,const QPoint & arg0) {obj->moveTopRight(arg0); }
838 void moveBottomLeft(QRect* obj,const QPoint & arg0) {obj->moveBottomLeft(arg0); }
839 void moveCenter(QRect* obj,const QPoint & arg0) {obj->moveCenter(arg0); }
840 void translate(QRect* obj,int arg0,int arg1) {obj->translate(arg0,arg1); }
841 void translate(QRect* obj,const QPoint & arg0) {obj->translate(arg0); }
842 QRect translated(QRect* obj,int arg0,int arg1) const {return obj->translated(arg0,arg1); }
843 QRect translated(QRect* obj,const QPoint & arg0) const {return obj->translated(arg0); }
844 void moveTo(QRect* obj,int arg0,int arg1) {obj->moveTo(arg0,arg1); }
845 void moveTo(QRect* obj,const QPoint & arg0) {obj->moveTo(arg0); }
846 void setRect(QRect* obj,int arg0,int arg1,int arg2,int arg3) {obj->setRect(arg0,arg1,arg2,arg3); }
847 void getRect(QRect* obj,int * arg0,int * arg1,int * arg2,int * arg3) const {obj->getRect(arg0,arg1,arg2,arg3); }
848 void setCoords(QRect* obj,int arg0,int arg1,int arg2,int arg3) {obj->setCoords(arg0,arg1,arg2,arg3); }
849 void getCoords(QRect* obj,int * arg0,int * arg1,int * arg2,int * arg3) const {obj->getCoords(arg0,arg1,arg2,arg3); }
850 void adjust(QRect* obj,int arg0,int arg1,int arg2,int arg3) {obj->adjust(arg0,arg1,arg2,arg3); }
851 QRect adjusted(QRect* obj,int arg0,int arg1,int arg2,int arg3) const {return obj->adjusted(arg0,arg1,arg2,arg3); }
852 QSize size(QRect* obj) const {return obj->size(); }
853 int width(QRect* obj) const {return obj->width(); }
854 int height(QRect* obj) const {return obj->height(); }
855 void setWidth(QRect* obj,int arg0) {obj->setWidth(arg0); }
856 void setHeight(QRect* obj,int arg0) {obj->setHeight(arg0); }
857 void setSize(QRect* obj,const QSize & arg0) {obj->setSize(arg0); }
858 bool contains(QRect* obj,const QPoint & arg0,bool arg1) const {return obj->contains(arg0,arg1); }
859 bool contains(QRect* obj,const QPoint & arg0) const {return obj->contains(arg0); }
860 bool contains(QRect* obj,int arg0,int arg1) const {return obj->contains(arg0,arg1); }
861 bool contains(QRect* obj,int arg0,int arg1,bool arg2) const {return obj->contains(arg0,arg1,arg2); }
862 bool contains(QRect* obj,const QRect & arg0,bool arg1) const {return obj->contains(arg0,arg1); }
863 bool contains(QRect* obj,const QRect & arg0) const {return obj->contains(arg0); }
864 QRect unite(QRect* obj,const QRect & arg0) const {return obj->unite(arg0); }
865 QRect united(QRect* obj,const QRect & arg0) const {return obj->united(arg0); }
866 QRect intersect(QRect* obj,const QRect & arg0) const {return obj->intersect(arg0); }
867 QRect intersected(QRect* obj,const QRect & arg0) const {return obj->intersected(arg0); }
868 bool intersects(QRect* obj,const QRect & arg0) const {return obj->intersects(arg0); }
869
870 };
871
872 class PythonQtQRectFWrapper : public QObject {
873 Q_OBJECT
874
875 public:
876 public slots:
877 QVariant new_QRectF() { return QRectF(); }
878 QVariant new_QRectF(const QPointF & arg0,const QSizeF & arg1) { return QRectF(arg0,arg1); }
879 QVariant new_QRectF(qreal arg0,qreal arg1,qreal arg2,qreal arg3) { return QRectF(arg0,arg1,arg2,arg3); }
880 QVariant new_QRectF(const QRect & arg0) { return QRectF(arg0); }
881 bool isNull(QRectF* obj) const {return obj->isNull(); }
882 bool isEmpty(QRectF* obj) const {return obj->isEmpty(); }
883 bool isValid(QRectF* obj) const {return obj->isValid(); }
884 QRectF normalized(QRectF* obj) const {return obj->normalized(); }
885 qreal left(QRectF* obj) const {return obj->left(); }
886 qreal top(QRectF* obj) const {return obj->top(); }
887 qreal right(QRectF* obj) const {return obj->right(); }
888 qreal bottom(QRectF* obj) const {return obj->bottom(); }
889 qreal x(QRectF* obj) const {return obj->x(); }
890 qreal y(QRectF* obj) const {return obj->y(); }
891 void setLeft(QRectF* obj,qreal arg0) {obj->setLeft(arg0); }
892 void setTop(QRectF* obj,qreal arg0) {obj->setTop(arg0); }
893 void setRight(QRectF* obj,qreal arg0) {obj->setRight(arg0); }
894 void setBottom(QRectF* obj,qreal arg0) {obj->setBottom(arg0); }
895 void setX(QRectF* obj,qreal arg0) {obj->setX(arg0); }
896 void setY(QRectF* obj,qreal arg0) {obj->setY(arg0); }
897 QPointF topLeft(QRectF* obj) const {return obj->topLeft(); }
898 QPointF bottomRight(QRectF* obj) const {return obj->bottomRight(); }
899 QPointF topRight(QRectF* obj) const {return obj->topRight(); }
900 QPointF bottomLeft(QRectF* obj) const {return obj->bottomLeft(); }
901 QPointF center(QRectF* obj) const {return obj->center(); }
902 void setTopLeft(QRectF* obj,const QPointF & arg0) {obj->setTopLeft(arg0); }
903 void setBottomRight(QRectF* obj,const QPointF & arg0) {obj->setBottomRight(arg0); }
904 void setTopRight(QRectF* obj,const QPointF & arg0) {obj->setTopRight(arg0); }
905 void setBottomLeft(QRectF* obj,const QPointF & arg0) {obj->setBottomLeft(arg0); }
906 void moveLeft(QRectF* obj,qreal arg0) {obj->moveLeft(arg0); }
907 void moveTop(QRectF* obj,qreal arg0) {obj->moveTop(arg0); }
908 void moveRight(QRectF* obj,qreal arg0) {obj->moveRight(arg0); }
909 void moveBottom(QRectF* obj,qreal arg0) {obj->moveBottom(arg0); }
910 void moveTopLeft(QRectF* obj,const QPointF & arg0) {obj->moveTopLeft(arg0); }
911 void moveBottomRight(QRectF* obj,const QPointF & arg0) {obj->moveBottomRight(arg0); }
912 void moveTopRight(QRectF* obj,const QPointF & arg0) {obj->moveTopRight(arg0); }
913 void moveBottomLeft(QRectF* obj,const QPointF & arg0) {obj->moveBottomLeft(arg0); }
914 void moveCenter(QRectF* obj,const QPointF & arg0) {obj->moveCenter(arg0); }
915 void translate(QRectF* obj,qreal arg0,qreal arg1) {obj->translate(arg0,arg1); }
916 void translate(QRectF* obj,const QPointF & arg0) {obj->translate(arg0); }
917 QRectF translated(QRectF* obj,qreal arg0,qreal arg1) const {return obj->translated(arg0,arg1); }
918 QRectF translated(QRectF* obj,const QPointF & arg0) const {return obj->translated(arg0); }
919 void moveTo(QRectF* obj,qreal arg0,qreal arg1) {obj->moveTo(arg0,arg1); }
920 void moveTo(QRectF* obj,const QPointF & arg0) {obj->moveTo(arg0); }
921 void setRect(QRectF* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3) {obj->setRect(arg0,arg1,arg2,arg3); }
922 void getRect(QRectF* obj,qreal * arg0,qreal * arg1,qreal * arg2,qreal * arg3) const {obj->getRect(arg0,arg1,arg2,arg3); }
923 void setCoords(QRectF* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3) {obj->setCoords(arg0,arg1,arg2,arg3); }
924 void getCoords(QRectF* obj,qreal * arg0,qreal * arg1,qreal * arg2,qreal * arg3) const {obj->getCoords(arg0,arg1,arg2,arg3); }
925 void adjust(QRectF* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3) {obj->adjust(arg0,arg1,arg2,arg3); }
926 QRectF adjusted(QRectF* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3) const {return obj->adjusted(arg0,arg1,arg2,arg3); }
927 QSizeF size(QRectF* obj) const {return obj->size(); }
928 qreal width(QRectF* obj) const {return obj->width(); }
929 qreal height(QRectF* obj) const {return obj->height(); }
930 void setWidth(QRectF* obj,qreal arg0) {obj->setWidth(arg0); }
931 void setHeight(QRectF* obj,qreal arg0) {obj->setHeight(arg0); }
932 void setSize(QRectF* obj,const QSizeF & arg0) {obj->setSize(arg0); }
933 bool contains(QRectF* obj,const QPointF & arg0) const {return obj->contains(arg0); }
934 bool contains(QRectF* obj,qreal arg0,qreal arg1) const {return obj->contains(arg0,arg1); }
935 bool contains(QRectF* obj,const QRectF & arg0) const {return obj->contains(arg0); }
936 QRectF unite(QRectF* obj,const QRectF & arg0) const {return obj->unite(arg0); }
937 QRectF united(QRectF* obj,const QRectF & arg0) const {return obj->united(arg0); }
938 QRectF intersect(QRectF* obj,const QRectF & arg0) const {return obj->intersect(arg0); }
939 QRectF intersected(QRectF* obj,const QRectF & arg0) const {return obj->intersected(arg0); }
940 bool intersects(QRectF* obj,const QRectF & arg0) const {return obj->intersects(arg0); }
941 QRect toRect(QRectF* obj) const {return obj->toRect(); }
942
943 };
944
945 /****************************************************************************
946 ** Meta object code from reading C++ file 'qsize.h'
947 **
948 ** Created: Thu 12. Apr 14:07:28 2007
949 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
950 **
951 ** WARNING! All changes made in this file will be lost!
952 *****************************************************************************/
953
954 #include "qsize.h"
955 class PythonQtQSizeWrapper : public QObject {
956 Q_OBJECT
957
958 public:
959 public slots:
960 QVariant new_QSize() { return QSize(); }
961 QVariant new_QSize(int arg0,int arg1) { return QSize(arg0,arg1); }
962 bool isNull(QSize* obj) const {return obj->isNull(); }
963 bool isEmpty(QSize* obj) const {return obj->isEmpty(); }
964 bool isValid(QSize* obj) const {return obj->isValid(); }
965 int width(QSize* obj) const {return obj->width(); }
966 int height(QSize* obj) const {return obj->height(); }
967 void setWidth(QSize* obj,int arg0) {obj->setWidth(arg0); }
968 void setHeight(QSize* obj,int arg0) {obj->setHeight(arg0); }
969 void transpose(QSize* obj) {obj->transpose(); }
970 void scale(QSize* obj,int arg0,int arg1,Qt::AspectRatioMode arg2) {obj->scale(arg0,arg1,arg2); }
971 void scale(QSize* obj,const QSize & arg0,Qt::AspectRatioMode arg1) {obj->scale(arg0,arg1); }
972 QSize expandedTo(QSize* obj,const QSize & arg0) const {return obj->expandedTo(arg0); }
973 QSize boundedTo(QSize* obj,const QSize & arg0) const {return obj->boundedTo(arg0); }
974 void rwidth(QSize* obj) {obj->rwidth(); }
975 void rheight(QSize* obj) {obj->rheight(); }
976
977 };
978
979 class PythonQtQSizeFWrapper : public QObject {
980 Q_OBJECT
981
982 public:
983 public slots:
984 QVariant new_QSizeF() { return QSizeF(); }
985 QVariant new_QSizeF(const QSize & arg0) { return QSizeF(arg0); }
986 QVariant new_QSizeF(qreal arg0,qreal arg1) { return QSizeF(arg0,arg1); }
987 bool isNull(QSizeF* obj) const {return obj->isNull(); }
988 bool isEmpty(QSizeF* obj) const {return obj->isEmpty(); }
989 bool isValid(QSizeF* obj) const {return obj->isValid(); }
990 qreal width(QSizeF* obj) const {return obj->width(); }
991 qreal height(QSizeF* obj) const {return obj->height(); }
992 void setWidth(QSizeF* obj,qreal arg0) {obj->setWidth(arg0); }
993 void setHeight(QSizeF* obj,qreal arg0) {obj->setHeight(arg0); }
994 void transpose(QSizeF* obj) {obj->transpose(); }
995 void scale(QSizeF* obj,qreal arg0,qreal arg1,Qt::AspectRatioMode arg2) {obj->scale(arg0,arg1,arg2); }
996 void scale(QSizeF* obj,const QSizeF & arg0,Qt::AspectRatioMode arg1) {obj->scale(arg0,arg1); }
997 QSizeF expandedTo(QSizeF* obj,const QSizeF & arg0) const {return obj->expandedTo(arg0); }
998 QSizeF boundedTo(QSizeF* obj,const QSizeF & arg0) const {return obj->boundedTo(arg0); }
999 void rwidth(QSizeF* obj) {obj->rwidth(); }
1000 void rheight(QSizeF* obj) {obj->rheight(); }
1001 QSize toSize(QSizeF* obj) const {return obj->toSize(); }
1002
1003 };
1004
1005 /****************************************************************************
1006 ** Meta object code from reading C++ file 'qline.h'
1007 **
1008 ** Created: Thu 12. Apr 14:07:28 2007
1009 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1010 **
1011 ** WARNING! All changes made in this file will be lost!
1012 *****************************************************************************/
1013
1014 #include "qline.h"
1015 class PythonQtQLineWrapper : public QObject {
1016 Q_OBJECT
1017
1018 public:
1019 public slots:
1020 QVariant new_QLine() { return QLine(); }
1021 QVariant new_QLine(const QPoint & arg0,const QPoint & arg1) { return QLine(arg0,arg1); }
1022 QVariant new_QLine(int arg0,int arg1,int arg2,int arg3) { return QLine(arg0,arg1,arg2,arg3); }
1023 bool isNull(QLine* obj) const {return obj->isNull(); }
1024 QPoint p1(QLine* obj) const {return obj->p1(); }
1025 QPoint p2(QLine* obj) const {return obj->p2(); }
1026 int x1(QLine* obj) const {return obj->x1(); }
1027 int y1(QLine* obj) const {return obj->y1(); }
1028 int x2(QLine* obj) const {return obj->x2(); }
1029 int y2(QLine* obj) const {return obj->y2(); }
1030 int dx(QLine* obj) const {return obj->dx(); }
1031 int dy(QLine* obj) const {return obj->dy(); }
1032 void translate(QLine* obj,const QPoint & arg0) {obj->translate(arg0); }
1033 void translate(QLine* obj,int arg0,int arg1) {obj->translate(arg0,arg1); }
1034
1035 };
1036
1037 class PythonQtQLineFWrapper : public QObject {
1038 Q_OBJECT
1039
1040 public:
1041 Q_ENUMS(IntersectType )
1042 enum IntersectType {NoIntersection = QLineF::NoIntersection,
1043 BoundedIntersection = QLineF::BoundedIntersection,
1044 UnboundedIntersection = QLineF::UnboundedIntersection };
1045 public slots:
1046 QVariant new_QLineF() { return QLineF(); }
1047 QVariant new_QLineF(const QPointF & arg0,const QPointF & arg1) { return QLineF(arg0,arg1); }
1048 QVariant new_QLineF(qreal arg0,qreal arg1,qreal arg2,qreal arg3) { return QLineF(arg0,arg1,arg2,arg3); }
1049 QVariant new_QLineF(const QLine & arg0) { return QLineF(arg0); }
1050 int isNull(QLineF* obj) const {return obj->isNull(); }
1051 QPointF p1(QLineF* obj) const {return obj->p1(); }
1052 QPointF p2(QLineF* obj) const {return obj->p2(); }
1053 qreal x1(QLineF* obj) const {return obj->x1(); }
1054 qreal y1(QLineF* obj) const {return obj->y1(); }
1055 qreal x2(QLineF* obj) const {return obj->x2(); }
1056 qreal y2(QLineF* obj) const {return obj->y2(); }
1057 qreal dx(QLineF* obj) const {return obj->dx(); }
1058 qreal dy(QLineF* obj) const {return obj->dy(); }
1059 qreal length(QLineF* obj) const {return obj->length(); }
1060 void setLength(QLineF* obj,qreal arg0) {obj->setLength(arg0); }
1061 QLineF unitVector(QLineF* obj) const {return obj->unitVector(); }
1062 QLineF normalVector(QLineF* obj) const {return obj->normalVector(); }
1063 IntersectType intersect(QLineF* obj,const QLineF & arg0,QPointF * arg1) const {return (PythonQtQLineFWrapper::IntersectType)obj->intersect(arg0,arg1); }
1064 qreal angle(QLineF* obj,const QLineF & arg0) const {return obj->angle(arg0); }
1065 QPointF pointAt(QLineF* obj,qreal arg0) const {return obj->pointAt(arg0); }
1066 void translate(QLineF* obj,const QPointF & arg0) {obj->translate(arg0); }
1067 void translate(QLineF* obj,qreal arg0,qreal arg1) {obj->translate(arg0,arg1); }
1068 QLine toLine(QLineF* obj) const {return obj->toLine(); }
1069
1070 };
1071
1072 /****************************************************************************
1073 ** Meta object code from reading C++ file 'qpoint.h'
1074 **
1075 ** Created: Thu 12. Apr 14:07:28 2007
1076 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1077 **
1078 ** WARNING! All changes made in this file will be lost!
1079 *****************************************************************************/
1080
1081 #include "qpoint.h"
1082 class PythonQtQPointWrapper : public QObject {
1083 Q_OBJECT
1084
1085 public:
1086 public slots:
1087 QVariant new_QPoint() { return QPoint(); }
1088 QVariant new_QPoint(int arg0,int arg1) { return QPoint(arg0,arg1); }
1089 bool isNull(QPoint* obj) const {return obj->isNull(); }
1090 int x(QPoint* obj) const {return obj->x(); }
1091 int y(QPoint* obj) const {return obj->y(); }
1092 void setX(QPoint* obj,int arg0) {obj->setX(arg0); }
1093 void setY(QPoint* obj,int arg0) {obj->setY(arg0); }
1094 int manhattanLength(QPoint* obj) const {return obj->manhattanLength(); }
1095 void rx(QPoint* obj) {obj->rx(); }
1096 void ry(QPoint* obj) {obj->ry(); }
1097
1098 };
1099
1100 class PythonQtQPointFWrapper : public QObject {
1101 Q_OBJECT
1102
1103 public:
1104 public slots:
1105 QVariant new_QPointF() { return QPointF(); }
1106 QVariant new_QPointF(const QPoint & arg0) { return QPointF(arg0); }
1107 QVariant new_QPointF(qreal arg0,qreal arg1) { return QPointF(arg0,arg1); }
1108 bool isNull(QPointF* obj) const {return obj->isNull(); }
1109 qreal x(QPointF* obj) const {return obj->x(); }
1110 qreal y(QPointF* obj) const {return obj->y(); }
1111 void setX(QPointF* obj,qreal arg0) {obj->setX(arg0); }
1112 void setY(QPointF* obj,qreal arg0) {obj->setY(arg0); }
1113 void rx(QPointF* obj) {obj->rx(); }
1114 void ry(QPointF* obj) {obj->ry(); }
1115 QPoint toPoint(QPointF* obj) const {return obj->toPoint(); }
1116
1117 };
1118
1119 /****************************************************************************
1120 ** Meta object code from reading C++ file 'qregexp.h'
1121 **
1122 ** Created: Thu 12. Apr 14:07:29 2007
1123 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1124 **
1125 ** WARNING! All changes made in this file will be lost!
1126 *****************************************************************************/
1127
1128 #include "qregexp.h"
1129 class PythonQtQRegExpWrapper : public QObject {
1130 Q_OBJECT
1131
1132 public:
1133 Q_ENUMS(PatternSyntax CaretMode )
1134 enum PatternSyntax {RegExp = QRegExp::RegExp,
1135 Wildcard = QRegExp::Wildcard,
1136 FixedString = QRegExp::FixedString,
1137 RegExp2 = QRegExp::RegExp2 };
1138 enum CaretMode {CaretAtZero = QRegExp::CaretAtZero,
1139 CaretAtOffset = QRegExp::CaretAtOffset,
1140 CaretWontMatch = QRegExp::CaretWontMatch };
1141 public slots:
1142 QVariant new_QRegExp() { return QRegExp(); }
1143 QVariant new_QRegExp(const QString & arg0,Qt::CaseSensitivity arg1,PatternSyntax arg2) { return QRegExp(arg0,arg1,(QRegExp::PatternSyntax)arg2); }
1144 QVariant new_QRegExp(const QString & arg0,Qt::CaseSensitivity arg1) { return QRegExp(arg0,arg1); }
1145 QVariant new_QRegExp(const QString & arg0) { return QRegExp(arg0); }
1146 QVariant new_QRegExp(const QRegExp & arg0) { return QRegExp(arg0); }
1147 bool isEmpty(QRegExp* obj) const {return obj->isEmpty(); }
1148 bool isValid(QRegExp* obj) const {return obj->isValid(); }
1149 QString pattern(QRegExp* obj) const {return obj->pattern(); }
1150 void setPattern(QRegExp* obj,const QString & arg0) {obj->setPattern(arg0); }
1151 Qt::CaseSensitivity caseSensitivity(QRegExp* obj) const {return obj->caseSensitivity(); }
1152 void setCaseSensitivity(QRegExp* obj,Qt::CaseSensitivity arg0) {obj->setCaseSensitivity(arg0); }
1153 PatternSyntax patternSyntax(QRegExp* obj) const {return (PythonQtQRegExpWrapper::PatternSyntax)obj->patternSyntax(); }
1154 void setPatternSyntax(QRegExp* obj,PatternSyntax arg0) {obj->setPatternSyntax((QRegExp::PatternSyntax)arg0); }
1155 bool isMinimal(QRegExp* obj) const {return obj->isMinimal(); }
1156 void setMinimal(QRegExp* obj,bool arg0) {obj->setMinimal(arg0); }
1157 bool exactMatch(QRegExp* obj,const QString & arg0) const {return obj->exactMatch(arg0); }
1158 int indexIn(QRegExp* obj,const QString & arg0,int arg1,CaretMode arg2) const {return obj->indexIn(arg0,arg1,(QRegExp::CaretMode)arg2); }
1159 int indexIn(QRegExp* obj,const QString & arg0,int arg1) const {return obj->indexIn(arg0,arg1); }
1160 int indexIn(QRegExp* obj,const QString & arg0) const {return obj->indexIn(arg0); }
1161 int lastIndexIn(QRegExp* obj,const QString & arg0,int arg1,CaretMode arg2) const {return obj->lastIndexIn(arg0,arg1,(QRegExp::CaretMode)arg2); }
1162 int lastIndexIn(QRegExp* obj,const QString & arg0,int arg1) const {return obj->lastIndexIn(arg0,arg1); }
1163 int lastIndexIn(QRegExp* obj,const QString & arg0) const {return obj->lastIndexIn(arg0); }
1164 int matchedLength(QRegExp* obj) const {return obj->matchedLength(); }
1165 int numCaptures(QRegExp* obj) const {return obj->numCaptures(); }
1166 QStringList capturedTexts(QRegExp* obj) {return obj->capturedTexts(); }
1167 QString cap(QRegExp* obj,int arg0) {return obj->cap(arg0); }
1168 QString cap(QRegExp* obj) {return obj->cap(); }
1169 int pos(QRegExp* obj,int arg0) {return obj->pos(arg0); }
1170 int pos(QRegExp* obj) {return obj->pos(); }
1171 QString errorString(QRegExp* obj) {return obj->errorString(); }
1172 QString static_QRegExp_escape(const QString & arg0) {return QRegExp::escape(arg0); }
1173
1174 };
1175
1176 /****************************************************************************
1177 ** Meta object code from reading C++ file 'qfont.h'
1178 **
1179 ** Created: Thu 12. Apr 14:07:29 2007
1180 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1181 **
1182 ** WARNING! All changes made in this file will be lost!
1183 *****************************************************************************/
1184
1185 #include "qfont.h"
1186 class PythonQtQFontWrapper : public QObject {
1187 Q_OBJECT
1188
1189 public:
1190 Q_ENUMS(StyleHint StyleStrategy Weight Style Stretch )
1191 enum StyleHint {Helvetica = QFont::Helvetica,
1192 SansSerif = QFont::SansSerif,
1193 Times = QFont::Times,
1194 Serif = QFont::Serif,
1195 Courier = QFont::Courier,
1196 TypeWriter = QFont::TypeWriter,
1197 OldEnglish = QFont::OldEnglish,
1198 Decorative = QFont::Decorative,
1199 System = QFont::System,
1200 AnyStyle = QFont::AnyStyle };
1201 enum StyleStrategy {PreferDefault = QFont::PreferDefault,
1202 PreferBitmap = QFont::PreferBitmap,
1203 PreferDevice = QFont::PreferDevice,
1204 PreferOutline = QFont::PreferOutline,
1205 ForceOutline = QFont::ForceOutline,
1206 PreferMatch = QFont::PreferMatch,
1207 PreferQuality = QFont::PreferQuality,
1208 PreferAntialias = QFont::PreferAntialias,
1209 NoAntialias = QFont::NoAntialias,
1210 OpenGLCompatible = QFont::OpenGLCompatible,
1211 NoFontMerging = QFont::NoFontMerging };
1212 enum Weight {Light = QFont::Light,
1213 Normal = QFont::Normal,
1214 DemiBold = QFont::DemiBold,
1215 Bold = QFont::Bold,
1216 Black = QFont::Black };
1217 enum Style {StyleNormal = QFont::StyleNormal,
1218 StyleItalic = QFont::StyleItalic,
1219 StyleOblique = QFont::StyleOblique };
1220 enum Stretch {UltraCondensed = QFont::UltraCondensed,
1221 ExtraCondensed = QFont::ExtraCondensed,
1222 Condensed = QFont::Condensed,
1223 SemiCondensed = QFont::SemiCondensed,
1224 Unstretched = QFont::Unstretched,
1225 SemiExpanded = QFont::SemiExpanded,
1226 Expanded = QFont::Expanded,
1227 ExtraExpanded = QFont::ExtraExpanded,
1228 UltraExpanded = QFont::UltraExpanded };
1229 public slots:
1230 QVariant new_QFont() { return QFont(); }
1231 QVariant new_QFont(const QString & arg0,int arg1,int arg2,bool arg3) { return QFont(arg0,arg1,arg2,arg3); }
1232 QVariant new_QFont(const QString & arg0,int arg1,int arg2) { return QFont(arg0,arg1,arg2); }
1233 QVariant new_QFont(const QString & arg0,int arg1) { return QFont(arg0,arg1); }
1234 QVariant new_QFont(const QString & arg0) { return QFont(arg0); }
1235 QVariant new_QFont(const QFont & arg0,QPaintDevice * arg1) { return QFont(arg0,arg1); }
1236 QVariant new_QFont(const QFont & arg0) { return QFont(arg0); }
1237 QString family(QFont* obj) const {return obj->family(); }
1238 void setFamily(QFont* obj,const QString & arg0) {obj->setFamily(arg0); }
1239 int pointSize(QFont* obj) const {return obj->pointSize(); }
1240 void setPointSize(QFont* obj,int arg0) {obj->setPointSize(arg0); }
1241 qreal pointSizeF(QFont* obj) const {return obj->pointSizeF(); }
1242 void setPointSizeF(QFont* obj,qreal arg0) {obj->setPointSizeF(arg0); }
1243 int pixelSize(QFont* obj) const {return obj->pixelSize(); }
1244 void setPixelSize(QFont* obj,int arg0) {obj->setPixelSize(arg0); }
1245 int weight(QFont* obj) const {return obj->weight(); }
1246 void setWeight(QFont* obj,int arg0) {obj->setWeight(arg0); }
1247 bool bold(QFont* obj) const {return obj->bold(); }
1248 void setBold(QFont* obj,bool arg0) {obj->setBold(arg0); }
1249 void setStyle(QFont* obj,Style arg0) {obj->setStyle((QFont::Style)arg0); }
1250 Style style(QFont* obj) const {return (PythonQtQFontWrapper::Style)obj->style(); }
1251 bool italic(QFont* obj) const {return obj->italic(); }
1252 void setItalic(QFont* obj,bool arg0) {obj->setItalic(arg0); }
1253 bool underline(QFont* obj) const {return obj->underline(); }
1254 void setUnderline(QFont* obj,bool arg0) {obj->setUnderline(arg0); }
1255 bool overline(QFont* obj) const {return obj->overline(); }
1256 void setOverline(QFont* obj,bool arg0) {obj->setOverline(arg0); }
1257 bool strikeOut(QFont* obj) const {return obj->strikeOut(); }
1258 void setStrikeOut(QFont* obj,bool arg0) {obj->setStrikeOut(arg0); }
1259 bool fixedPitch(QFont* obj) const {return obj->fixedPitch(); }
1260 void setFixedPitch(QFont* obj,bool arg0) {obj->setFixedPitch(arg0); }
1261 bool kerning(QFont* obj) const {return obj->kerning(); }
1262 void setKerning(QFont* obj,bool arg0) {obj->setKerning(arg0); }
1263 StyleHint styleHint(QFont* obj) const {return (PythonQtQFontWrapper::StyleHint)obj->styleHint(); }
1264 StyleStrategy styleStrategy(QFont* obj) const {return (PythonQtQFontWrapper::StyleStrategy)obj->styleStrategy(); }
1265 void setStyleHint(QFont* obj,StyleHint arg0,StyleStrategy arg1) {obj->setStyleHint((QFont::StyleHint)arg0,(QFont::StyleStrategy)arg1); }
1266 void setStyleHint(QFont* obj,StyleHint arg0) {obj->setStyleHint((QFont::StyleHint)arg0); }
1267 void setStyleStrategy(QFont* obj,StyleStrategy arg0) {obj->setStyleStrategy((QFont::StyleStrategy)arg0); }
1268 int stretch(QFont* obj) const {return obj->stretch(); }
1269 void setStretch(QFont* obj,int arg0) {obj->setStretch(arg0); }
1270 bool rawMode(QFont* obj) const {return obj->rawMode(); }
1271 void setRawMode(QFont* obj,bool arg0) {obj->setRawMode(arg0); }
1272 bool exactMatch(QFont* obj) const {return obj->exactMatch(); }
1273 bool isCopyOf(QFont* obj,const QFont & arg0) const {return obj->isCopyOf(arg0); }
1274 Qt::HANDLE handle(QFont* obj) const {return obj->handle(); }
1275 void setRawName(QFont* obj,const QString & arg0) {obj->setRawName(arg0); }
1276 QString rawName(QFont* obj) const {return obj->rawName(); }
1277 QString key(QFont* obj) const {return obj->key(); }
1278 QString toString(QFont* obj) const {return obj->toString(); }
1279 bool fromString(QFont* obj,const QString & arg0) {return obj->fromString(arg0); }
1280 QString static_QFont_substitute(const QString & arg0) {return QFont::substitute(arg0); }
1281 QStringList static_QFont_substitutes(const QString & arg0) {return QFont::substitutes(arg0); }
1282 QStringList static_QFont_substitutions() {return QFont::substitutions(); }
1283 void static_QFont_insertSubstitution(const QString & arg0,const QString & arg1) {QFont::insertSubstitution(arg0,arg1); }
1284 void static_QFont_insertSubstitutions(const QString & arg0,const QStringList & arg1) {QFont::insertSubstitutions(arg0,arg1); }
1285 void static_QFont_removeSubstitution(const QString & arg0) {QFont::removeSubstitution(arg0); }
1286 void static_QFont_initialize() {QFont::initialize(); }
1287 void static_QFont_cleanup() {QFont::cleanup(); }
1288 void static_QFont_cacheStatistics() {QFont::cacheStatistics(); }
1289 QString defaultFamily(QFont* obj) const {return obj->defaultFamily(); }
1290 QString lastResortFamily(QFont* obj) const {return obj->lastResortFamily(); }
1291 QString lastResortFont(QFont* obj) const {return obj->lastResortFont(); }
1292 QFont resolve(QFont* obj,const QFont & arg0) const {return obj->resolve(arg0); }
1293 uint resolve(QFont* obj) const {return obj->resolve(); }
1294 void resolve(QFont* obj,uint arg0) {obj->resolve(arg0); }
1295
1296 };
1297
1298 /****************************************************************************
1299 ** Meta object code from reading C++ file 'qpixmap.h'
1300 **
1301 ** Created: Thu 12. Apr 14:07:29 2007
1302 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1303 **
1304 ** WARNING! All changes made in this file will be lost!
1305 *****************************************************************************/
1306
1307 #include "qpixmap.h"
1308 class PythonQtQPixmapWrapper : public QObject {
1309 Q_OBJECT
1310
1311 public:
1312 public slots:
1313 QVariant new_QPixmap() { return QPixmap(); }
1314 QVariant new_QPixmap(int arg0,int arg1) { return QPixmap(arg0,arg1); }
1315 QVariant new_QPixmap(const QSize & arg0) { return QPixmap(arg0); }
1316 QVariant new_QPixmap(const QString & arg0,const char * arg1,Qt::ImageConversionFlags arg2) { return QPixmap(arg0,arg1,arg2); }
1317 QVariant new_QPixmap(const QString & arg0,const char * arg1) { return QPixmap(arg0,arg1); }
1318 QVariant new_QPixmap(const QString & arg0) { return QPixmap(arg0); }
1319 QVariant new_QPixmap(const QPixmap & arg0) { return QPixmap(arg0); }
1320 bool isNull(QPixmap* obj) const {return obj->isNull(); }
1321 int devType(QPixmap* obj) const {return obj->devType(); }
1322 int width(QPixmap* obj) const {return obj->width(); }
1323 int height(QPixmap* obj) const {return obj->height(); }
1324 QSize size(QPixmap* obj) const {return obj->size(); }
1325 QRect rect(QPixmap* obj) const {return obj->rect(); }
1326 int depth(QPixmap* obj) const {return obj->depth(); }
1327 int static_QPixmap_defaultDepth() {return QPixmap::defaultDepth(); }
1328 void fill(QPixmap* obj,const QColor & arg0) {obj->fill(arg0); }
1329 void fill(QPixmap* obj) {obj->fill(); }
1330 void fill(QPixmap* obj,const QWidget * arg0,const QPoint & arg1) {obj->fill(arg0,arg1); }
1331 void fill(QPixmap* obj,const QWidget * arg0,int arg1,int arg2) {obj->fill(arg0,arg1,arg2); }
1332 QBitmap mask(QPixmap* obj) const {return obj->mask(); }
1333 void setMask(QPixmap* obj,const QBitmap & arg0) {obj->setMask(arg0); }
1334 QPixmap alphaChannel(QPixmap* obj) const {return obj->alphaChannel(); }
1335 void setAlphaChannel(QPixmap* obj,const QPixmap & arg0) {obj->setAlphaChannel(arg0); }
1336 bool hasAlpha(QPixmap* obj) const {return obj->hasAlpha(); }
1337 bool hasAlphaChannel(QPixmap* obj) const {return obj->hasAlphaChannel(); }
1338 QBitmap createHeuristicMask(QPixmap* obj,bool arg0) const {return obj->createHeuristicMask(arg0); }
1339 QBitmap createHeuristicMask(QPixmap* obj) const {return obj->createHeuristicMask(); }
1340 QBitmap createMaskFromColor(QPixmap* obj,const QColor & arg0) const {return obj->createMaskFromColor(arg0); }
1341 QPixmap static_QPixmap_grabWindow(WId arg0,int arg1,int arg2,int arg3,int arg4) {return QPixmap::grabWindow(arg0,arg1,arg2,arg3,arg4); }
1342 QPixmap static_QPixmap_grabWindow(WId arg0,int arg1,int arg2,int arg3) {return QPixmap::grabWindow(arg0,arg1,arg2,arg3); }
1343 QPixmap static_QPixmap_grabWindow(WId arg0,int arg1,int arg2) {return QPixmap::grabWindow(arg0,arg1,arg2); }
1344 QPixmap static_QPixmap_grabWindow(WId arg0,int arg1) {return QPixmap::grabWindow(arg0,arg1); }
1345 QPixmap static_QPixmap_grabWindow(WId arg0) {return QPixmap::grabWindow(arg0); }
1346 QPixmap static_QPixmap_grabWidget(QWidget * arg0,const QRect & arg1) {return QPixmap::grabWidget(arg0,arg1); }
1347 QPixmap grabWidget(QPixmap* obj,QWidget * arg0,int arg1,int arg2,int arg3,int arg4) {return obj->grabWidget(arg0,arg1,arg2,arg3,arg4); }
1348 QPixmap grabWidget(QPixmap* obj,QWidget * arg0,int arg1,int arg2,int arg3) {return obj->grabWidget(arg0,arg1,arg2,arg3); }
1349 QPixmap grabWidget(QPixmap* obj,QWidget * arg0,int arg1,int arg2) {return obj->grabWidget(arg0,arg1,arg2); }
1350 QPixmap grabWidget(QPixmap* obj,QWidget * arg0,int arg1) {return obj->grabWidget(arg0,arg1); }
1351 QPixmap grabWidget(QPixmap* obj,QWidget * arg0) {return obj->grabWidget(arg0); }
1352 QPixmap scaled(QPixmap* obj,int arg0,int arg1,Qt::AspectRatioMode arg2,Qt::TransformationMode arg3) const {return obj->scaled(arg0,arg1,arg2,arg3); }
1353 QPixmap scaled(QPixmap* obj,int arg0,int arg1,Qt::AspectRatioMode arg2) const {return obj->scaled(arg0,arg1,arg2); }
1354 QPixmap scaled(QPixmap* obj,int arg0,int arg1) const {return obj->scaled(arg0,arg1); }
1355 QPixmap scaled(QPixmap* obj,const QSize & arg0,Qt::AspectRatioMode arg1,Qt::TransformationMode arg2) const {return obj->scaled(arg0,arg1,arg2); }
1356 QPixmap scaled(QPixmap* obj,const QSize & arg0,Qt::AspectRatioMode arg1) const {return obj->scaled(arg0,arg1); }
1357 QPixmap scaled(QPixmap* obj,const QSize & arg0) const {return obj->scaled(arg0); }
1358 QPixmap scaledToWidth(QPixmap* obj,int arg0,Qt::TransformationMode arg1) const {return obj->scaledToWidth(arg0,arg1); }
1359 QPixmap scaledToWidth(QPixmap* obj,int arg0) const {return obj->scaledToWidth(arg0); }
1360 QPixmap scaledToHeight(QPixmap* obj,int arg0,Qt::TransformationMode arg1) const {return obj->scaledToHeight(arg0,arg1); }
1361 QPixmap scaledToHeight(QPixmap* obj,int arg0) const {return obj->scaledToHeight(arg0); }
1362 QPixmap transformed(QPixmap* obj,const QMatrix & arg0,Qt::TransformationMode arg1) const {return obj->transformed(arg0,arg1); }
1363 QPixmap transformed(QPixmap* obj,const QMatrix & arg0) const {return obj->transformed(arg0); }
1364 QMatrix static_QPixmap_trueMatrix(const QMatrix & arg0,int arg1,int arg2) {return QPixmap::trueMatrix(arg0,arg1,arg2); }
1365 QImage toImage(QPixmap* obj) const {return obj->toImage(); }
1366 QPixmap static_QPixmap_fromImage(const QImage & arg0,Qt::ImageConversionFlags arg1) {return QPixmap::fromImage(arg0,arg1); }
1367 QPixmap static_QPixmap_fromImage(const QImage & arg0) {return QPixmap::fromImage(arg0); }
1368 bool load(QPixmap* obj,const QString & arg0,const char * arg1,Qt::ImageConversionFlags arg2) {return obj->load(arg0,arg1,arg2); }
1369 bool load(QPixmap* obj,const QString & arg0,const char * arg1) {return obj->load(arg0,arg1); }
1370 bool load(QPixmap* obj,const QString & arg0) {return obj->load(arg0); }
1371 bool loadFromData(QPixmap* obj,const uchar * arg0,uint arg1,const char * arg2,Qt::ImageConversionFlags arg3) {return obj->loadFromData(arg0,arg1,arg2,arg3); }
1372 bool loadFromData(QPixmap* obj,const uchar * arg0,uint arg1,const char * arg2) {return obj->loadFromData(arg0,arg1,arg2); }
1373 bool loadFromData(QPixmap* obj,const uchar * arg0,uint arg1) {return obj->loadFromData(arg0,arg1); }
1374 bool loadFromData(QPixmap* obj,const QByteArray & arg0,const char * arg1,Qt::ImageConversionFlags arg2) {return obj->loadFromData(arg0,arg1,arg2); }
1375 bool loadFromData(QPixmap* obj,const QByteArray & arg0,const char * arg1) {return obj->loadFromData(arg0,arg1); }
1376 bool loadFromData(QPixmap* obj,const QByteArray & arg0) {return obj->loadFromData(arg0); }
1377 bool save(QPixmap* obj,const QString & arg0,const char * arg1,int arg2) const {return obj->save(arg0,arg1,arg2); }
1378 bool save(QPixmap* obj,const QString & arg0,const char * arg1) const {return obj->save(arg0,arg1); }
1379 bool save(QPixmap* obj,const QString & arg0) const {return obj->save(arg0); }
1380 bool save(QPixmap* obj,QIODevice * arg0,const char * arg1,int arg2) const {return obj->save(arg0,arg1,arg2); }
1381 bool save(QPixmap* obj,QIODevice * arg0,const char * arg1) const {return obj->save(arg0,arg1); }
1382 bool save(QPixmap* obj,QIODevice * arg0) const {return obj->save(arg0); }
1383 QPixmap copy(QPixmap* obj,int arg0,int arg1,int arg2,int arg3) const {return obj->copy(arg0,arg1,arg2,arg3); }
1384 QPixmap copy(QPixmap* obj,const QRect & arg0) const {return obj->copy(arg0); }
1385 QPixmap copy(QPixmap* obj) const {return obj->copy(); }
1386 int serialNumber(QPixmap* obj) const {return obj->serialNumber(); }
1387 bool isDetached(QPixmap* obj) const {return obj->isDetached(); }
1388 void detach(QPixmap* obj) {obj->detach(); }
1389 bool isQBitmap(QPixmap* obj) const {return obj->isQBitmap(); }
1390 QPaintEngine* paintEngine(QPixmap* obj) const {return obj->paintEngine(); }
1391
1392 };
1393
1394 /****************************************************************************
1395 ** Meta object code from reading C++ file 'qbrush.h'
1396 **
1397 ** Created: Thu 12. Apr 14:07:29 2007
1398 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1399 **
1400 ** WARNING! All changes made in this file will be lost!
1401 *****************************************************************************/
1402
1403 #include "qbrush.h"
1404 class PythonQtQBrushWrapper : public QObject {
1405 Q_OBJECT
1406
1407 public:
1408 public slots:
1409 QVariant new_QBrush() { return QBrush(); }
1410 QVariant new_QBrush(Qt::BrushStyle arg0) { return QBrush(arg0); }
1411 QVariant new_QBrush(const QColor & arg0,Qt::BrushStyle arg1) { return QBrush(arg0,arg1); }
1412 QVariant new_QBrush(const QColor & arg0) { return QBrush(arg0); }
1413 QVariant new_QBrush(Qt::GlobalColor arg0,Qt::BrushStyle arg1) { return QBrush(arg0,arg1); }
1414 QVariant new_QBrush(Qt::GlobalColor arg0) { return QBrush(arg0); }
1415 QVariant new_QBrush(const QColor & arg0,const QPixmap & arg1) { return QBrush(arg0,arg1); }
1416 QVariant new_QBrush(Qt::GlobalColor arg0,const QPixmap & arg1) { return QBrush(arg0,arg1); }
1417 QVariant new_QBrush(const QPixmap & arg0) { return QBrush(arg0); }
1418 QVariant new_QBrush(const QImage & arg0) { return QBrush(arg0); }
1419 QVariant new_QBrush(const QBrush & arg0) { return QBrush(arg0); }
1420 QVariant new_QBrush(const QGradient & arg0) { return QBrush(arg0); }
1421 Qt::BrushStyle style(QBrush* obj) const {return obj->style(); }
1422 void setStyle(QBrush* obj,Qt::BrushStyle arg0) {obj->setStyle(arg0); }
1423 void matrix(QBrush* obj) const {obj->matrix(); }
1424 void setMatrix(QBrush* obj,const QMatrix & arg0) {obj->setMatrix(arg0); }
1425 QPixmap texture(QBrush* obj) const {return obj->texture(); }
1426 void setTexture(QBrush* obj,const QPixmap & arg0) {obj->setTexture(arg0); }
1427 QImage textureImage(QBrush* obj) const {return obj->textureImage(); }
1428 void setTextureImage(QBrush* obj,const QImage & arg0) {obj->setTextureImage(arg0); }
1429 void color(QBrush* obj) const {obj->color(); }
1430 void setColor(QBrush* obj,const QColor & arg0) {obj->setColor(arg0); }
1431 void setColor(QBrush* obj,Qt::GlobalColor arg0) {obj->setColor(arg0); }
1432 const QGradient* gradient(QBrush* obj) const {return obj->gradient(); }
1433 bool isOpaque(QBrush* obj) const {return obj->isOpaque(); }
1434
1435 };
1436
1437 class PythonQtQBrushDataWrapper : public QObject {
1438 Q_OBJECT
1439
1440 public:
1441 public slots:
1442 void delete_QBrushData(QBrushData* obj) { delete obj; }
1443
1444 };
1445
1446 class PythonQtQGradientWrapper : public QObject {
1447 Q_OBJECT
1448
1449 public:
1450 Q_ENUMS(Type Spread CoordinateMode )
1451 enum Type {LinearGradient = QGradient::LinearGradient,
1452 RadialGradient = QGradient::RadialGradient,
1453 ConicalGradient = QGradient::ConicalGradient,
1454 NoGradient = QGradient::NoGradient };
1455 enum Spread {PadSpread = QGradient::PadSpread,
1456 ReflectSpread = QGradient::ReflectSpread,
1457 RepeatSpread = QGradient::RepeatSpread };
1458 enum CoordinateMode {LogicalMode = QGradient::LogicalMode,
1459 StretchToDeviceMode = QGradient::StretchToDeviceMode };
1460 public slots:
1461 void delete_QGradient(QGradient* obj) { delete obj; }
1462 QGradient* new_QGradient() { return new QGradient(); }
1463 Type type(QGradient* obj) const {return (PythonQtQGradientWrapper::Type)obj->type(); }
1464 void setSpread(QGradient* obj,Spread arg0) {obj->setSpread((QGradient::Spread)arg0); }
1465 Spread spread(QGradient* obj) const {return (PythonQtQGradientWrapper::Spread)obj->spread(); }
1466 void setColorAt(QGradient* obj,qreal arg0,const QColor & arg1) {obj->setColorAt(arg0,arg1); }
1467 void setStops(QGradient* obj,const QGradientStops & arg0) {obj->setStops(arg0); }
1468 QGradientStops stops(QGradient* obj) const {return obj->stops(); }
1469 CoordinateMode coordinateMode(QGradient* obj) const {return (PythonQtQGradientWrapper::CoordinateMode)obj->coordinateMode(); }
1470 void setCoordinateMode(QGradient* obj,CoordinateMode arg0) {obj->setCoordinateMode((QGradient::CoordinateMode)arg0); }
1471
1472 };
1473
1474 class PythonQtQLinearGradientWrapper : public QObject {
1475 Q_OBJECT
1476
1477 public:
1478 public slots:
1479 void delete_QLinearGradient(QLinearGradient* obj) { delete obj; }
1480 QLinearGradient* new_QLinearGradient() { return new QLinearGradient(); }
1481 QLinearGradient* new_QLinearGradient(const QPointF & arg0,const QPointF & arg1) { return new QLinearGradient(arg0,arg1); }
1482 QLinearGradient* new_QLinearGradient(qreal arg0,qreal arg1,qreal arg2,qreal arg3) { return new QLinearGradient(arg0,arg1,arg2,arg3); }
1483 QPointF start(QLinearGradient* obj) const {return obj->start(); }
1484 void setStart(QLinearGradient* obj,const QPointF & arg0) {obj->setStart(arg0); }
1485 void setStart(QLinearGradient* obj,qreal arg0,qreal arg1) {obj->setStart(arg0,arg1); }
1486 QPointF finalStop(QLinearGradient* obj) const {return obj->finalStop(); }
1487 void setFinalStop(QLinearGradient* obj,const QPointF & arg0) {obj->setFinalStop(arg0); }
1488 void setFinalStop(QLinearGradient* obj,qreal arg0,qreal arg1) {obj->setFinalStop(arg0,arg1); }
1489
1490 };
1491
1492 class PythonQtQRadialGradientWrapper : public QObject {
1493 Q_OBJECT
1494
1495 public:
1496 public slots:
1497 void delete_QRadialGradient(QRadialGradient* obj) { delete obj; }
1498 QRadialGradient* new_QRadialGradient() { return new QRadialGradient(); }
1499 QRadialGradient* new_QRadialGradient(const QPointF & arg0,qreal arg1,const QPointF & arg2) { return new QRadialGradient(arg0,arg1,arg2); }
1500 QRadialGradient* new_QRadialGradient(qreal arg0,qreal arg1,qreal arg2,qreal arg3,qreal arg4) { return new QRadialGradient(arg0,arg1,arg2,arg3,arg4); }
1501 QRadialGradient* new_QRadialGradient(const QPointF & arg0,qreal arg1) { return new QRadialGradient(arg0,arg1); }
1502 QRadialGradient* new_QRadialGradient(qreal arg0,qreal arg1,qreal arg2) { return new QRadialGradient(arg0,arg1,arg2); }
1503 QPointF center(QRadialGradient* obj) const {return obj->center(); }
1504 void setCenter(QRadialGradient* obj,const QPointF & arg0) {obj->setCenter(arg0); }
1505 void setCenter(QRadialGradient* obj,qreal arg0,qreal arg1) {obj->setCenter(arg0,arg1); }
1506 QPointF focalPoint(QRadialGradient* obj) const {return obj->focalPoint(); }
1507 void setFocalPoint(QRadialGradient* obj,const QPointF & arg0) {obj->setFocalPoint(arg0); }
1508 void setFocalPoint(QRadialGradient* obj,qreal arg0,qreal arg1) {obj->setFocalPoint(arg0,arg1); }
1509 qreal radius(QRadialGradient* obj) const {return obj->radius(); }
1510 void setRadius(QRadialGradient* obj,qreal arg0) {obj->setRadius(arg0); }
1511
1512 };
1513
1514 class PythonQtQConicalGradientWrapper : public QObject {
1515 Q_OBJECT
1516
1517 public:
1518 public slots:
1519 void delete_QConicalGradient(QConicalGradient* obj) { delete obj; }
1520 QConicalGradient* new_QConicalGradient() { return new QConicalGradient(); }
1521 QConicalGradient* new_QConicalGradient(const QPointF & arg0,qreal arg1) { return new QConicalGradient(arg0,arg1); }
1522 QConicalGradient* new_QConicalGradient(qreal arg0,qreal arg1,qreal arg2) { return new QConicalGradient(arg0,arg1,arg2); }
1523 QPointF center(QConicalGradient* obj) const {return obj->center(); }
1524 void setCenter(QConicalGradient* obj,const QPointF & arg0) {obj->setCenter(arg0); }
1525 void setCenter(QConicalGradient* obj,qreal arg0,qreal arg1) {obj->setCenter(arg0,arg1); }
1526 qreal angle(QConicalGradient* obj) const {return obj->angle(); }
1527 void setAngle(QConicalGradient* obj,qreal arg0) {obj->setAngle(arg0); }
1528
1529 };
1530
1531 /****************************************************************************
1532 ** Meta object code from reading C++ file 'qcolor.h'
1533 **
1534 ** Created: Thu 12. Apr 14:07:30 2007
1535 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1536 **
1537 ** WARNING! All changes made in this file will be lost!
1538 *****************************************************************************/
1539
1540 #include "qcolor.h"
1541 class PythonQtQColorWrapper : public QObject {
1542 Q_OBJECT
1543
1544 public:
1545 Q_ENUMS(Spec )
1546 enum Spec {Invalid = QColor::Invalid,
1547 Rgb = QColor::Rgb,
1548 Hsv = QColor::Hsv,
1549 Cmyk = QColor::Cmyk };
1550 public slots:
1551 QVariant new_QColor() { return QColor(); }
1552 QVariant new_QColor(Qt::GlobalColor arg0) { return QColor(arg0); }
1553 QVariant new_QColor(int arg0,int arg1,int arg2,int arg3) { return QColor(arg0,arg1,arg2,arg3); }
1554 QVariant new_QColor(int arg0,int arg1,int arg2) { return QColor(arg0,arg1,arg2); }
1555 QVariant new_QColor(QRgb arg0) { return QColor(arg0); }
1556 QVariant new_QColor(const QString & arg0) { return QColor(arg0); }
1557 QVariant new_QColor(const char * arg0) { return QColor(arg0); }
1558 QVariant new_QColor(const QColor & arg0) { return QColor(arg0); }
1559 QVariant new_QColor(Spec arg0) { return QColor((QColor::Spec)arg0); }
1560 bool isValid(QColor* obj) const {return obj->isValid(); }
1561 QString name(QColor* obj) const {return obj->name(); }
1562 void setNamedColor(QColor* obj,const QString & arg0) {obj->setNamedColor(arg0); }
1563 QStringList static_QColor_colorNames() {return QColor::colorNames(); }
1564 Spec spec(QColor* obj) const {return (PythonQtQColorWrapper::Spec)obj->spec(); }
1565 int alpha(QColor* obj) const {return obj->alpha(); }
1566 void setAlpha(QColor* obj,int arg0) {obj->setAlpha(arg0); }
1567 qreal alphaF(QColor* obj) const {return obj->alphaF(); }
1568 void setAlphaF(QColor* obj,qreal arg0) {obj->setAlphaF(arg0); }
1569 int red(QColor* obj) const {return obj->red(); }
1570 int green(QColor* obj) const {return obj->green(); }
1571 int blue(QColor* obj) const {return obj->blue(); }
1572 void setRed(QColor* obj,int arg0) {obj->setRed(arg0); }
1573 void setGreen(QColor* obj,int arg0) {obj->setGreen(arg0); }
1574 void setBlue(QColor* obj,int arg0) {obj->setBlue(arg0); }
1575 qreal redF(QColor* obj) const {return obj->redF(); }
1576 qreal greenF(QColor* obj) const {return obj->greenF(); }
1577 qreal blueF(QColor* obj) const {return obj->blueF(); }
1578 void setRedF(QColor* obj,qreal arg0) {obj->setRedF(arg0); }
1579 void setGreenF(QColor* obj,qreal arg0) {obj->setGreenF(arg0); }
1580 void setBlueF(QColor* obj,qreal arg0) {obj->setBlueF(arg0); }
1581 void getRgb(QColor* obj,int * arg0,int * arg1,int * arg2,int * arg3) const {obj->getRgb(arg0,arg1,arg2,arg3); }
1582 void getRgb(QColor* obj,int * arg0,int * arg1,int * arg2) const {obj->getRgb(arg0,arg1,arg2); }
1583 void setRgb(QColor* obj,int arg0,int arg1,int arg2,int arg3) {obj->setRgb(arg0,arg1,arg2,arg3); }
1584 void setRgb(QColor* obj,int arg0,int arg1,int arg2) {obj->setRgb(arg0,arg1,arg2); }
1585 void getRgbF(QColor* obj,qreal * arg0,qreal * arg1,qreal * arg2,qreal * arg3) const {obj->getRgbF(arg0,arg1,arg2,arg3); }
1586 void getRgbF(QColor* obj,qreal * arg0,qreal * arg1,qreal * arg2) const {obj->getRgbF(arg0,arg1,arg2); }
1587 void setRgbF(QColor* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3) {obj->setRgbF(arg0,arg1,arg2,arg3); }
1588 void setRgbF(QColor* obj,qreal arg0,qreal arg1,qreal arg2) {obj->setRgbF(arg0,arg1,arg2); }
1589 QRgb rgba(QColor* obj) const {return obj->rgba(); }
1590 void setRgba(QColor* obj,QRgb arg0) {obj->setRgba(arg0); }
1591 QRgb rgb(QColor* obj) const {return obj->rgb(); }
1592 void setRgb(QColor* obj,QRgb arg0) {obj->setRgb(arg0); }
1593 int hue(QColor* obj) const {return obj->hue(); }
1594 int saturation(QColor* obj) const {return obj->saturation(); }
1595 int value(QColor* obj) const {return obj->value(); }
1596 qreal hueF(QColor* obj) const {return obj->hueF(); }
1597 qreal saturationF(QColor* obj) const {return obj->saturationF(); }
1598 qreal valueF(QColor* obj) const {return obj->valueF(); }
1599 void getHsv(QColor* obj,int * arg0,int * arg1,int * arg2,int * arg3) const {obj->getHsv(arg0,arg1,arg2,arg3); }
1600 void getHsv(QColor* obj,int * arg0,int * arg1,int * arg2) const {obj->getHsv(arg0,arg1,arg2); }
1601 void setHsv(QColor* obj,int arg0,int arg1,int arg2,int arg3) {obj->setHsv(arg0,arg1,arg2,arg3); }
1602 void setHsv(QColor* obj,int arg0,int arg1,int arg2) {obj->setHsv(arg0,arg1,arg2); }
1603 void getHsvF(QColor* obj,qreal * arg0,qreal * arg1,qreal * arg2,qreal * arg3) const {obj->getHsvF(arg0,arg1,arg2,arg3); }
1604 void getHsvF(QColor* obj,qreal * arg0,qreal * arg1,qreal * arg2) const {obj->getHsvF(arg0,arg1,arg2); }
1605 void setHsvF(QColor* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3) {obj->setHsvF(arg0,arg1,arg2,arg3); }
1606 void setHsvF(QColor* obj,qreal arg0,qreal arg1,qreal arg2) {obj->setHsvF(arg0,arg1,arg2); }
1607 int cyan(QColor* obj) const {return obj->cyan(); }
1608 int magenta(QColor* obj) const {return obj->magenta(); }
1609 int yellow(QColor* obj) const {return obj->yellow(); }
1610 int black(QColor* obj) const {return obj->black(); }
1611 qreal cyanF(QColor* obj) const {return obj->cyanF(); }
1612 qreal magentaF(QColor* obj) const {return obj->magentaF(); }
1613 qreal yellowF(QColor* obj) const {return obj->yellowF(); }
1614 qreal blackF(QColor* obj) const {return obj->blackF(); }
1615 void getCmyk(QColor* obj,int * arg0,int * arg1,int * arg2,int * arg3,int * arg4) {obj->getCmyk(arg0,arg1,arg2,arg3,arg4); }
1616 void getCmyk(QColor* obj,int * arg0,int * arg1,int * arg2,int * arg3) {obj->getCmyk(arg0,arg1,arg2,arg3); }
1617 void setCmyk(QColor* obj,int arg0,int arg1,int arg2,int arg3,int arg4) {obj->setCmyk(arg0,arg1,arg2,arg3,arg4); }
1618 void setCmyk(QColor* obj,int arg0,int arg1,int arg2,int arg3) {obj->setCmyk(arg0,arg1,arg2,arg3); }
1619 void getCmykF(QColor* obj,qreal * arg0,qreal * arg1,qreal * arg2,qreal * arg3,qreal * arg4) {obj->getCmykF(arg0,arg1,arg2,arg3,arg4); }
1620 void getCmykF(QColor* obj,qreal * arg0,qreal * arg1,qreal * arg2,qreal * arg3) {obj->getCmykF(arg0,arg1,arg2,arg3); }
1621 void setCmykF(QColor* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3,qreal arg4) {obj->setCmykF(arg0,arg1,arg2,arg3,arg4); }
1622 void setCmykF(QColor* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3) {obj->setCmykF(arg0,arg1,arg2,arg3); }
1623 QColor toRgb(QColor* obj) const {return obj->toRgb(); }
1624 QColor toHsv(QColor* obj) const {return obj->toHsv(); }
1625 QColor toCmyk(QColor* obj) const {return obj->toCmyk(); }
1626 QColor convertTo(QColor* obj,Spec arg0) const {return obj->convertTo((QColor::Spec)arg0); }
1627 QColor static_QColor_fromRgb(QRgb arg0) {return QColor::fromRgb(arg0); }
1628 QColor static_QColor_fromRgba(QRgb arg0) {return QColor::fromRgba(arg0); }
1629 QColor static_QColor_fromRgb(int arg0,int arg1,int arg2,int arg3) {return QColor::fromRgb(arg0,arg1,arg2,arg3); }
1630 QColor static_QColor_fromRgb(int arg0,int arg1,int arg2) {return QColor::fromRgb(arg0,arg1,arg2); }
1631 QColor static_QColor_fromRgbF(qreal arg0,qreal arg1,qreal arg2,qreal arg3) {return QColor::fromRgbF(arg0,arg1,arg2,arg3); }
1632 QColor static_QColor_fromRgbF(qreal arg0,qreal arg1,qreal arg2) {return QColor::fromRgbF(arg0,arg1,arg2); }
1633 QColor static_QColor_fromHsv(int arg0,int arg1,int arg2,int arg3) {return QColor::fromHsv(arg0,arg1,arg2,arg3); }
1634 QColor static_QColor_fromHsv(int arg0,int arg1,int arg2) {return QColor::fromHsv(arg0,arg1,arg2); }
1635 QColor static_QColor_fromHsvF(qreal arg0,qreal arg1,qreal arg2,qreal arg3) {return QColor::fromHsvF(arg0,arg1,arg2,arg3); }
1636 QColor static_QColor_fromHsvF(qreal arg0,qreal arg1,qreal arg2) {return QColor::fromHsvF(arg0,arg1,arg2); }
1637 QColor static_QColor_fromCmyk(int arg0,int arg1,int arg2,int arg3,int arg4) {return QColor::fromCmyk(arg0,arg1,arg2,arg3,arg4); }
1638 QColor static_QColor_fromCmyk(int arg0,int arg1,int arg2,int arg3) {return QColor::fromCmyk(arg0,arg1,arg2,arg3); }
1639 QColor static_QColor_fromCmykF(qreal arg0,qreal arg1,qreal arg2,qreal arg3,qreal arg4) {return QColor::fromCmykF(arg0,arg1,arg2,arg3,arg4); }
1640 QColor static_QColor_fromCmykF(qreal arg0,qreal arg1,qreal arg2,qreal arg3) {return QColor::fromCmykF(arg0,arg1,arg2,arg3); }
1641 QColor light(QColor* obj,int arg0) const {return obj->light(arg0); }
1642 QColor light(QColor* obj) const {return obj->light(); }
1643 QColor dark(QColor* obj,int arg0) const {return obj->dark(arg0); }
1644 QColor dark(QColor* obj) const {return obj->dark(); }
1645
1646 };
1647
1648 /****************************************************************************
1649 ** Meta object code from reading C++ file 'qpalette.h'
1650 **
1651 ** Created: Thu 12. Apr 14:07:30 2007
1652 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1653 **
1654 ** WARNING! All changes made in this file will be lost!
1655 *****************************************************************************/
1656
1657 #include "qpalette.h"
1658 class PythonQtQPaletteWrapper : public QObject {
1659 Q_OBJECT
1660
1661 public:
1662 Q_ENUMS(ColorGroup ColorRole )
1663 enum ColorGroup {Active = QPalette::Active,
1664 Disabled = QPalette::Disabled,
1665 Inactive = QPalette::Inactive,
1666 NColorGroups = QPalette::NColorGroups,
1667 Current = QPalette::Current,
1668 All = QPalette::All,
1669 Normal = QPalette::Normal };
1670 enum ColorRole {WindowText = QPalette::WindowText,
1671 Button = QPalette::Button,
1672 Light = QPalette::Light,
1673 Midlight = QPalette::Midlight,
1674 Dark = QPalette::Dark,
1675 Mid = QPalette::Mid,
1676 Text = QPalette::Text,
1677 BrightText = QPalette::BrightText,
1678 ButtonText = QPalette::ButtonText,
1679 Base = QPalette::Base,
1680 Window = QPalette::Window,
1681 Shadow = QPalette::Shadow,
1682 Highlight = QPalette::Highlight,
1683 HighlightedText = QPalette::HighlightedText,
1684 Link = QPalette::Link,
1685 LinkVisited = QPalette::LinkVisited,
1686 AlternateBase = QPalette::AlternateBase,
1687 NoRole = QPalette::NoRole,
1688 NColorRoles = QPalette::NColorRoles,
1689 Foreground = QPalette::Foreground,
1690 Background = QPalette::Background };
1691 public slots:
1692 QVariant new_QPalette() { return QPalette(); }
1693 QVariant new_QPalette(const QColor & arg0) { return QPalette(arg0); }
1694 QVariant new_QPalette(Qt::GlobalColor arg0) { return QPalette(arg0); }
1695 QVariant new_QPalette(const QColor & arg0,const QColor & arg1) { return QPalette(arg0,arg1); }
1696 QVariant new_QPalette(const QBrush & arg0,const QBrush & arg1,const QBrush & arg2,const QBrush & arg3,const QBrush & arg4,const QBrush & arg5,const QBrush & arg6,const QBrush & arg7,const QBrush & arg8) { return QPalette(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); }
1697 QVariant new_QPalette(const QColor & arg0,const QColor & arg1,const QColor & arg2,const QColor & arg3,const QColor & arg4,const QColor & arg5,const QColor & arg6) { return QPalette(arg0,arg1,arg2,arg3,arg4,arg5,arg6); }
1698 QVariant new_QPalette(const QPalette & arg0) { return QPalette(arg0); }
1699 ColorGroup currentColorGroup(QPalette* obj) const {return (PythonQtQPaletteWrapper::ColorGroup)obj->currentColorGroup(); }
1700 void setCurrentColorGroup(QPalette* obj,ColorGroup arg0) {obj->setCurrentColorGroup((QPalette::ColorGroup)arg0); }
1701 void color(QPalette* obj,ColorGroup arg0,ColorRole arg1) const {obj->color((QPalette::ColorGroup)arg0,(QPalette::ColorRole)arg1); }
1702 void brush(QPalette* obj,ColorGroup arg0,ColorRole arg1) const {obj->brush((QPalette::ColorGroup)arg0,(QPalette::ColorRole)arg1); }
1703 void setColor(QPalette* obj,ColorGroup arg0,ColorRole arg1,const QColor & arg2) {obj->setColor((QPalette::ColorGroup)arg0,(QPalette::ColorRole)arg1,arg2); }
1704 void setColor(QPalette* obj,ColorRole arg0,const QColor & arg1) {obj->setColor((QPalette::ColorRole)arg0,arg1); }
1705 void setBrush(QPalette* obj,ColorRole arg0,const QBrush & arg1) {obj->setBrush((QPalette::ColorRole)arg0,arg1); }
1706 bool isBrushSet(QPalette* obj,ColorGroup arg0,ColorRole arg1) const {return obj->isBrushSet((QPalette::ColorGroup)arg0,(QPalette::ColorRole)arg1); }
1707 void setBrush(QPalette* obj,ColorGroup arg0,ColorRole arg1,const QBrush & arg2) {obj->setBrush((QPalette::ColorGroup)arg0,(QPalette::ColorRole)arg1,arg2); }
1708 void setColorGroup(QPalette* obj,ColorGroup arg0,const QBrush & arg1,const QBrush & arg2,const QBrush & arg3,const QBrush & arg4,const QBrush & arg5,const QBrush & arg6,const QBrush & arg7,const QBrush & arg8,const QBrush & arg9) {obj->setColorGroup((QPalette::ColorGroup)arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9); }
1709 bool isEqual(QPalette* obj,ColorGroup arg0,ColorGroup arg1) const {return obj->isEqual((QPalette::ColorGroup)arg0,(QPalette::ColorGroup)arg1); }
1710 void color(QPalette* obj,ColorRole arg0) const {obj->color((QPalette::ColorRole)arg0); }
1711 void brush(QPalette* obj,ColorRole arg0) const {obj->brush((QPalette::ColorRole)arg0); }
1712 void foreground(QPalette* obj) const {obj->foreground(); }
1713 void windowText(QPalette* obj) const {obj->windowText(); }
1714 void button(QPalette* obj) const {obj->button(); }
1715 void light(QPalette* obj) const {obj->light(); }
1716 void dark(QPalette* obj) const {obj->dark(); }
1717 void mid(QPalette* obj) const {obj->mid(); }
1718 void text(QPalette* obj) const {obj->text(); }
1719 void base(QPalette* obj) const {obj->base(); }
1720 void alternateBase(QPalette* obj) const {obj->alternateBase(); }
1721 void background(QPalette* obj) const {obj->background(); }
1722 void window(QPalette* obj) const {obj->window(); }
1723 void midlight(QPalette* obj) const {obj->midlight(); }
1724 void brightText(QPalette* obj) const {obj->brightText(); }
1725 void buttonText(QPalette* obj) const {obj->buttonText(); }
1726 void shadow(QPalette* obj) const {obj->shadow(); }
1727 void highlight(QPalette* obj) const {obj->highlight(); }
1728 void highlightedText(QPalette* obj) const {obj->highlightedText(); }
1729 void link(QPalette* obj) const {obj->link(); }
1730 void linkVisited(QPalette* obj) const {obj->linkVisited(); }
1731 bool isCopyOf(QPalette* obj,const QPalette & arg0) const {return obj->isCopyOf(arg0); }
1732 int serialNumber(QPalette* obj) const {return obj->serialNumber(); }
1733 QPalette resolve(QPalette* obj,const QPalette & arg0) const {return obj->resolve(arg0); }
1734 uint resolve(QPalette* obj) const {return obj->resolve(); }
1735 void resolve(QPalette* obj,uint arg0) {obj->resolve(arg0); }
1736
1737 };
1738
1739 /****************************************************************************
1740 ** Meta object code from reading C++ file 'qicon.h'
1741 **
1742 ** Created: Thu 12. Apr 14:07:30 2007
1743 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1744 **
1745 ** WARNING! All changes made in this file will be lost!
1746 *****************************************************************************/
1747
1748 #include "qicon.h"
1749 class PythonQtQIconWrapper : public QObject {
1750 Q_OBJECT
1751
1752 public:
1753 Q_ENUMS(Mode State )
1754 enum Mode {Normal = QIcon::Normal,
1755 Disabled = QIcon::Disabled,
1756 Active = QIcon::Active,
1757 Selected = QIcon::Selected };
1758 enum State {On = QIcon::On,
1759 Off = QIcon::Off };
1760 public slots:
1761 QVariant new_QIcon() { return QIcon(); }
1762 QVariant new_QIcon(const QPixmap & arg0) { return QIcon(arg0); }
1763 QVariant new_QIcon(const QIcon & arg0) { return QIcon(arg0); }
1764 QVariant new_QIcon(const QString & arg0) { return QIcon(arg0); }
1765 QVariant new_QIcon(QIconEngine * arg0) { return QIcon(arg0); }
1766 QPixmap pixmap(QIcon* obj,const QSize & arg0,Mode arg1,State arg2) const {return obj->pixmap(arg0,(QIcon::Mode)arg1,(QIcon::State)arg2); }
1767 QPixmap pixmap(QIcon* obj,const QSize & arg0,Mode arg1) const {return obj->pixmap(arg0,(QIcon::Mode)arg1); }
1768 QPixmap pixmap(QIcon* obj,const QSize & arg0) const {return obj->pixmap(arg0); }
1769 QPixmap pixmap(QIcon* obj,int arg0,int arg1,Mode arg2,State arg3) const {return obj->pixmap(arg0,arg1,(QIcon::Mode)arg2,(QIcon::State)arg3); }
1770 QPixmap pixmap(QIcon* obj,int arg0,int arg1,Mode arg2) const {return obj->pixmap(arg0,arg1,(QIcon::Mode)arg2); }
1771 QPixmap pixmap(QIcon* obj,int arg0,int arg1) const {return obj->pixmap(arg0,arg1); }
1772 QPixmap pixmap(QIcon* obj,int arg0,Mode arg1,State arg2) const {return obj->pixmap(arg0,(QIcon::Mode)arg1,(QIcon::State)arg2); }
1773 QPixmap pixmap(QIcon* obj,int arg0,Mode arg1) const {return obj->pixmap(arg0,(QIcon::Mode)arg1); }
1774 QPixmap pixmap(QIcon* obj,int arg0) const {return obj->pixmap(arg0); }
1775 QSize actualSize(QIcon* obj,const QSize & arg0,Mode arg1,State arg2) const {return obj->actualSize(arg0,(QIcon::Mode)arg1,(QIcon::State)arg2); }
1776 QSize actualSize(QIcon* obj,const QSize & arg0,Mode arg1) const {return obj->actualSize(arg0,(QIcon::Mode)arg1); }
1777 QSize actualSize(QIcon* obj,const QSize & arg0) const {return obj->actualSize(arg0); }
1778 void paint(QIcon* obj,QPainter * arg0,const QRect & arg1,Qt::Alignment arg2,Mode arg3,State arg4) const {obj->paint(arg0,arg1,arg2,(QIcon::Mode)arg3,(QIcon::State)arg4); }
1779 void paint(QIcon* obj,QPainter * arg0,const QRect & arg1,Qt::Alignment arg2,Mode arg3) const {obj->paint(arg0,arg1,arg2,(QIcon::Mode)arg3); }
1780 void paint(QIcon* obj,QPainter * arg0,const QRect & arg1,Qt::Alignment arg2) const {obj->paint(arg0,arg1,arg2); }
1781 void paint(QIcon* obj,QPainter * arg0,const QRect & arg1) const {obj->paint(arg0,arg1); }
1782 void paint(QIcon* obj,QPainter * arg0,int arg1,int arg2,int arg3,int arg4,Qt::Alignment arg5,Mode arg6,State arg7) const {obj->paint(arg0,arg1,arg2,arg3,arg4,arg5,(QIcon::Mode)arg6,(QIcon::State)arg7); }
1783 void paint(QIcon* obj,QPainter * arg0,int arg1,int arg2,int arg3,int arg4,Qt::Alignment arg5,Mode arg6) const {obj->paint(arg0,arg1,arg2,arg3,arg4,arg5,(QIcon::Mode)arg6); }
1784 void paint(QIcon* obj,QPainter * arg0,int arg1,int arg2,int arg3,int arg4,Qt::Alignment arg5) const {obj->paint(arg0,arg1,arg2,arg3,arg4,arg5); }
1785 void paint(QIcon* obj,QPainter * arg0,int arg1,int arg2,int arg3,int arg4) const {obj->paint(arg0,arg1,arg2,arg3,arg4); }
1786 bool isNull(QIcon* obj) const {return obj->isNull(); }
1787 bool isDetached(QIcon* obj) const {return obj->isDetached(); }
1788 int serialNumber(QIcon* obj) const {return obj->serialNumber(); }
1789 void addPixmap(QIcon* obj,const QPixmap & arg0,Mode arg1,State arg2) {obj->addPixmap(arg0,(QIcon::Mode)arg1,(QIcon::State)arg2); }
1790 void addPixmap(QIcon* obj,const QPixmap & arg0,Mode arg1) {obj->addPixmap(arg0,(QIcon::Mode)arg1); }
1791 void addPixmap(QIcon* obj,const QPixmap & arg0) {obj->addPixmap(arg0); }
1792 void addFile(QIcon* obj,const QString & arg0,const QSize & arg1,Mode arg2,State arg3) {obj->addFile(arg0,arg1,(QIcon::Mode)arg2,(QIcon::State)arg3); }
1793 void addFile(QIcon* obj,const QString & arg0,const QSize & arg1,Mode arg2) {obj->addFile(arg0,arg1,(QIcon::Mode)arg2); }
1794 void addFile(QIcon* obj,const QString & arg0,const QSize & arg1) {obj->addFile(arg0,arg1); }
1795 void addFile(QIcon* obj,const QString & arg0) {obj->addFile(arg0); }
1796
1797 };
1798
1799 /****************************************************************************
1800 ** Meta object code from reading C++ file 'qimage.h'
1801 **
1802 ** Created: Thu 12. Apr 14:07:30 2007
1803 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1804 **
1805 ** WARNING! All changes made in this file will be lost!
1806 *****************************************************************************/
1807
1808 #include "qimage.h"
1809 class PythonQtQImageTextKeyLangWrapper : public QObject {
1810 Q_OBJECT
1811
1812 public:
1813 public slots:
1814 void delete_QImageTextKeyLang(QImageTextKeyLang* obj) { delete obj; }
1815 QImageTextKeyLang* new_QImageTextKeyLang(const char * arg0,const char * arg1) { return new QImageTextKeyLang(arg0,arg1); }
1816
1817 };
1818
1819 class PythonQtQImageWrapper : public QObject {
1820 Q_OBJECT
1821
1822 public:
1823 Q_ENUMS(InvertMode Format )
1824 enum InvertMode {InvertRgb = QImage::InvertRgb,
1825 InvertRgba = QImage::InvertRgba };
1826 enum Format {Format_Invalid = QImage::Format_Invalid,
1827 Format_Mono = QImage::Format_Mono,
1828 Format_MonoLSB = QImage::Format_MonoLSB,
1829 Format_Indexed8 = QImage::Format_Indexed8,
1830 Format_RGB32 = QImage::Format_RGB32,
1831 Format_ARGB32 = QImage::Format_ARGB32,
1832 Format_ARGB32_Premultiplied = QImage::Format_ARGB32_Premultiplied,
1833 Format_RGB16 = QImage::Format_RGB16,
1834 NImageFormats = QImage::NImageFormats };
1835 public slots:
1836 QVariant new_QImage() { return QImage(); }
1837 QVariant new_QImage(const QSize & arg0,Format arg1) { return QImage(arg0,(QImage::Format)arg1); }
1838 QVariant new_QImage(int arg0,int arg1,Format arg2) { return QImage(arg0,arg1,(QImage::Format)arg2); }
1839 QVariant new_QImage(uchar * arg0,int arg1,int arg2,Format arg3) { return QImage(arg0,arg1,arg2,(QImage::Format)arg3); }
1840 QVariant new_QImage(const uchar * arg0,int arg1,int arg2,Format arg3) { return QImage(arg0,arg1,arg2,(QImage::Format)arg3); }
1841 QVariant new_QImage(const QString & arg0,const char * arg1) { return QImage(arg0,arg1); }
1842 QVariant new_QImage(const QString & arg0) { return QImage(arg0); }
1843 QVariant new_QImage(const char * arg0,const char * arg1) { return QImage(arg0,arg1); }
1844 QVariant new_QImage(const char * arg0) { return QImage(arg0); }
1845 QVariant new_QImage(const QImage & arg0) { return QImage(arg0); }
1846 bool isNull(QImage* obj) const {return obj->isNull(); }
1847 int devType(QImage* obj) const {return obj->devType(); }
1848 void detach(QImage* obj) {obj->detach(); }
1849 bool isDetached(QImage* obj) const {return obj->isDetached(); }
1850 QImage copy(QImage* obj,const QRect & arg0) const {return obj->copy(arg0); }
1851 QImage copy(QImage* obj) const {return obj->copy(); }
1852 QImage copy(QImage* obj,int arg0,int arg1,int arg2,int arg3) const {return obj->copy(arg0,arg1,arg2,arg3); }
1853 Format format(QImage* obj) const {return (PythonQtQImageWrapper::Format)obj->format(); }
1854 QImage convertToFormat(QImage* obj,Format arg0,Qt::ImageConversionFlags arg1) const {return obj->convertToFormat((QImage::Format)arg0,arg1); }
1855 QImage convertToFormat(QImage* obj,Format arg0) const {return obj->convertToFormat((QImage::Format)arg0); }
1856 QImage convertToFormat(QImage* obj,Format arg0,const QVector<QRgb> & arg1,Qt::ImageConversionFlags arg2) const {return obj->convertToFormat((QImage::Format)arg0,arg1,arg2); }
1857 QImage convertToFormat(QImage* obj,Format arg0,const QVector<QRgb> & arg1) const {return obj->convertToFormat((QImage::Format)arg0,arg1); }
1858 int width(QImage* obj) const {return obj->width(); }
1859 int height(QImage* obj) const {return obj->height(); }
1860 QSize size(QImage* obj) const {return obj->size(); }
1861 QRect rect(QImage* obj) const {return obj->rect(); }
1862 int depth(QImage* obj) const {return obj->depth(); }
1863 int numColors(QImage* obj) const {return obj->numColors(); }
1864 QRgb color(QImage* obj,int arg0) const {return obj->color(arg0); }
1865 void setColor(QImage* obj,int arg0,QRgb arg1) {obj->setColor(arg0,arg1); }
1866 void setNumColors(QImage* obj,int arg0) {obj->setNumColors(arg0); }
1867 bool allGray(QImage* obj) const {return obj->allGray(); }
1868 bool isGrayscale(QImage* obj) const {return obj->isGrayscale(); }
1869 uchar* bits(QImage* obj) {return obj->bits(); }
1870 const uchar* bits(QImage* obj) const {return obj->bits(); }
1871 int numBytes(QImage* obj) const {return obj->numBytes(); }
1872 uchar* scanLine(QImage* obj,int arg0) {return obj->scanLine(arg0); }
1873 const uchar* scanLine(QImage* obj,int arg0) const {return obj->scanLine(arg0); }
1874 int bytesPerLine(QImage* obj) const {return obj->bytesPerLine(); }
1875 bool valid(QImage* obj,int arg0,int arg1) const {return obj->valid(arg0,arg1); }
1876 bool valid(QImage* obj,const QPoint & arg0) const {return obj->valid(arg0); }
1877 int pixelIndex(QImage* obj,int arg0,int arg1) const {return obj->pixelIndex(arg0,arg1); }
1878 int pixelIndex(QImage* obj,const QPoint & arg0) const {return obj->pixelIndex(arg0); }
1879 QRgb pixel(QImage* obj,int arg0,int arg1) const {return obj->pixel(arg0,arg1); }
1880 QRgb pixel(QImage* obj,const QPoint & arg0) const {return obj->pixel(arg0); }
1881 void setPixel(QImage* obj,int arg0,int arg1,uint arg2) {obj->setPixel(arg0,arg1,arg2); }
1882 void setPixel(QImage* obj,const QPoint & arg0,uint arg1) {obj->setPixel(arg0,arg1); }
1883 QVector<QRgb> colorTable(QImage* obj) const {return obj->colorTable(); }
1884 void setColorTable(QImage* obj,const QVector<QRgb> arg0) {obj->setColorTable(arg0); }
1885 void fill(QImage* obj,uint arg0) {obj->fill(arg0); }
1886 bool hasAlphaChannel(QImage* obj) const {return obj->hasAlphaChannel(); }
1887 void setAlphaChannel(QImage* obj,const QImage & arg0) {obj->setAlphaChannel(arg0); }
1888 QImage alphaChannel(QImage* obj) const {return obj->alphaChannel(); }
1889 QImage createAlphaMask(QImage* obj,Qt::ImageConversionFlags arg0) const {return obj->createAlphaMask(arg0); }
1890 QImage createAlphaMask(QImage* obj) const {return obj->createAlphaMask(); }
1891 QImage createHeuristicMask(QImage* obj,bool arg0) const {return obj->createHeuristicMask(arg0); }
1892 QImage createHeuristicMask(QImage* obj) const {return obj->createHeuristicMask(); }
1893 QImage scaled(QImage* obj,int arg0,int arg1,Qt::AspectRatioMode arg2,Qt::TransformationMode arg3) const {return obj->scaled(arg0,arg1,arg2,arg3); }
1894 QImage scaled(QImage* obj,int arg0,int arg1,Qt::AspectRatioMode arg2) const {return obj->scaled(arg0,arg1,arg2); }
1895 QImage scaled(QImage* obj,int arg0,int arg1) const {return obj->scaled(arg0,arg1); }
1896 QImage scaled(QImage* obj,const QSize & arg0,Qt::AspectRatioMode arg1,Qt::TransformationMode arg2) const {return obj->scaled(arg0,arg1,arg2); }
1897 QImage scaled(QImage* obj,const QSize & arg0,Qt::AspectRatioMode arg1) const {return obj->scaled(arg0,arg1); }
1898 QImage scaled(QImage* obj,const QSize & arg0) const {return obj->scaled(arg0); }
1899 QImage scaledToWidth(QImage* obj,int arg0,Qt::TransformationMode arg1) const {return obj->scaledToWidth(arg0,arg1); }
1900 QImage scaledToWidth(QImage* obj,int arg0) const {return obj->scaledToWidth(arg0); }
1901 QImage scaledToHeight(QImage* obj,int arg0,Qt::TransformationMode arg1) const {return obj->scaledToHeight(arg0,arg1); }
1902 QImage scaledToHeight(QImage* obj,int arg0) const {return obj->scaledToHeight(arg0); }
1903 QImage transformed(QImage* obj,const QMatrix & arg0,Qt::TransformationMode arg1) const {return obj->transformed(arg0,arg1); }
1904 QImage transformed(QImage* obj,const QMatrix & arg0) const {return obj->transformed(arg0); }
1905 QMatrix static_QImage_trueMatrix(const QMatrix & arg0,int arg1,int arg2) {return QImage::trueMatrix(arg0,arg1,arg2); }
1906 QImage mirrored(QImage* obj,bool arg0,bool arg1) const {return obj->mirrored(arg0,arg1); }
1907 QImage mirrored(QImage* obj,bool arg0) const {return obj->mirrored(arg0); }
1908 QImage mirrored(QImage* obj) const {return obj->mirrored(); }
1909 QImage rgbSwapped(QImage* obj) const {return obj->rgbSwapped(); }
1910 void invertPixels(QImage* obj,InvertMode arg0) {obj->invertPixels((QImage::InvertMode)arg0); }
1911 void invertPixels(QImage* obj) {obj->invertPixels(); }
1912 bool load(QImage* obj,QIODevice * arg0,const char * arg1) {return obj->load(arg0,arg1); }
1913 bool load(QImage* obj,const QString & arg0,const char * arg1) {return obj->load(arg0,arg1); }
1914 bool load(QImage* obj,const QString & arg0) {return obj->load(arg0); }
1915 bool loadFromData(QImage* obj,const uchar * arg0,int arg1,const char * arg2) {return obj->loadFromData(arg0,arg1,arg2); }
1916 bool loadFromData(QImage* obj,const uchar * arg0,int arg1) {return obj->loadFromData(arg0,arg1); }
1917 bool loadFromData(QImage* obj,const QByteArray & arg0,const char * arg1) {return obj->loadFromData(arg0,arg1); }
1918 bool loadFromData(QImage* obj,const QByteArray & arg0) {return obj->loadFromData(arg0); }
1919 bool save(QImage* obj,const QString & arg0,const char * arg1,int arg2) const {return obj->save(arg0,arg1,arg2); }
1920 bool save(QImage* obj,const QString & arg0,const char * arg1) const {return obj->save(arg0,arg1); }
1921 bool save(QImage* obj,const QString & arg0) const {return obj->save(arg0); }
1922 bool save(QImage* obj,QIODevice * arg0,const char * arg1,int arg2) const {return obj->save(arg0,arg1,arg2); }
1923 bool save(QImage* obj,QIODevice * arg0,const char * arg1) const {return obj->save(arg0,arg1); }
1924 bool save(QImage* obj,QIODevice * arg0) const {return obj->save(arg0); }
1925 QImage static_QImage_fromData(const uchar * arg0,int arg1,const char * arg2) {return QImage::fromData(arg0,arg1,arg2); }
1926 QImage static_QImage_fromData(const uchar * arg0,int arg1) {return QImage::fromData(arg0,arg1); }
1927 QImage static_QImage_fromData(const QByteArray & arg0,const char * arg1) {return QImage::fromData(arg0,arg1); }
1928 QImage static_QImage_fromData(const QByteArray & arg0) {return QImage::fromData(arg0); }
1929 int serialNumber(QImage* obj) const {return obj->serialNumber(); }
1930 QPaintEngine* paintEngine(QImage* obj) const {return obj->paintEngine(); }
1931 int dotsPerMeterX(QImage* obj) const {return obj->dotsPerMeterX(); }
1932 int dotsPerMeterY(QImage* obj) const {return obj->dotsPerMeterY(); }
1933 void setDotsPerMeterX(QImage* obj,int arg0) {obj->setDotsPerMeterX(arg0); }
1934 void setDotsPerMeterY(QImage* obj,int arg0) {obj->setDotsPerMeterY(arg0); }
1935 QPoint offset(QImage* obj) const {return obj->offset(); }
1936 void setOffset(QImage* obj,const QPoint & arg0) {obj->setOffset(arg0); }
1937 QStringList textKeys(QImage* obj) const {return obj->textKeys(); }
1938 QString text(QImage* obj,const QString & arg0) const {return obj->text(arg0); }
1939 QString text(QImage* obj) const {return obj->text(); }
1940 void setText(QImage* obj,const QString & arg0,const QString & arg1) {obj->setText(arg0,arg1); }
1941 QString text(QImage* obj,const char * arg0,const char * arg1) const {return obj->text(arg0,arg1); }
1942 QString text(QImage* obj,const char * arg0) const {return obj->text(arg0); }
1943 QList<QImageTextKeyLang> textList(QImage* obj) const {return obj->textList(); }
1944 QStringList textLanguages(QImage* obj) const {return obj->textLanguages(); }
1945 QString text(QImage* obj,const QImageTextKeyLang & arg0) const {return obj->text(arg0); }
1946 void setText(QImage* obj,const char * arg0,const char * arg1,const QString & arg2) {obj->setText(arg0,arg1,arg2); }
1947
1948 };
1949
1950 /****************************************************************************
1951 ** Meta object code from reading C++ file 'qpolygon.h'
1952 **
1953 ** Created: Thu 12. Apr 14:07:30 2007
1954 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
1955 **
1956 ** WARNING! All changes made in this file will be lost!
1957 *****************************************************************************/
1958
1959 #include "qpolygon.h"
1960 class PythonQtQPolygonWrapper : public QObject {
1961 Q_OBJECT
1962
1963 public:
1964 public slots:
1965 QVariant new_QPolygon() { return QPolygon(); }
1966 QVariant new_QPolygon(int arg0) { return QPolygon(arg0); }
1967 QVariant new_QPolygon(const QPolygon & arg0) { return QPolygon(arg0); }
1968 QVariant new_QPolygon(const QVector<QPoint> & arg0) { return QPolygon(arg0); }
1969 QVariant new_QPolygon(int arg0,const int * arg1) { return QPolygon(arg0,arg1); }
1970 void translate(QPolygon* obj,int arg0,int arg1) {obj->translate(arg0,arg1); }
1971 void translate(QPolygon* obj,const QPoint & arg0) {obj->translate(arg0); }
1972 QRect boundingRect(QPolygon* obj) const {return obj->boundingRect(); }
1973 void point(QPolygon* obj,int arg0,int * arg1,int * arg2) const {obj->point(arg0,arg1,arg2); }
1974 QPoint point(QPolygon* obj,int arg0) const {return obj->point(arg0); }
1975 void setPoint(QPolygon* obj,int arg0,int arg1,int arg2) {obj->setPoint(arg0,arg1,arg2); }
1976 void setPoint(QPolygon* obj,int arg0,const QPoint & arg1) {obj->setPoint(arg0,arg1); }
1977
1978 };
1979
1980 class PythonQtQPolygonFWrapper : public QObject {
1981 Q_OBJECT
1982
1983 public:
1984 public slots:
1985 void delete_QPolygonF(QPolygonF* obj) { delete obj; }
1986 QPolygonF* new_QPolygonF() { return new QPolygonF(); }
1987 QPolygonF* new_QPolygonF(int arg0) { return new QPolygonF(arg0); }
1988 QPolygonF* new_QPolygonF(const QPolygonF & arg0) { return new QPolygonF(arg0); }
1989 QPolygonF* new_QPolygonF(const QVector<QPointF> & arg0) { return new QPolygonF(arg0); }
1990 QPolygonF* new_QPolygonF(const QPolygon & arg0) { return new QPolygonF(arg0); }
1991 void translate(QPolygonF* obj,qreal arg0,qreal arg1) {obj->translate(arg0,arg1); }
1992 void translate(QPolygonF* obj,const QPointF & arg0) {obj->translate(arg0); }
1993 QPolygon toPolygon(QPolygonF* obj) const {return obj->toPolygon(); }
1994 bool isClosed(QPolygonF* obj) const {return obj->isClosed(); }
1995 QRectF boundingRect(QPolygonF* obj) const {return obj->boundingRect(); }
1996
1997 };
1998
1999 /****************************************************************************
2000 ** Meta object code from reading C++ file 'qregion.h'
2001 **
2002 ** Created: Thu 12. Apr 14:07:30 2007
2003 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
2004 **
2005 ** WARNING! All changes made in this file will be lost!
2006 *****************************************************************************/
2007
2008 #include "qregion.h"
2009 class PythonQtQRegionWrapper : public QObject {
2010 Q_OBJECT
2011
2012 public:
2013 Q_ENUMS(RegionType )
2014 enum RegionType {Rectangle = QRegion::Rectangle,
2015 Ellipse = QRegion::Ellipse };
2016 public slots:
2017 QVariant new_QRegion() { return QRegion(); }
2018 QVariant new_QRegion(int arg0,int arg1,int arg2,int arg3,RegionType arg4) { return QRegion(arg0,arg1,arg2,arg3,(QRegion::RegionType)arg4); }
2019 QVariant new_QRegion(int arg0,int arg1,int arg2,int arg3) { return QRegion(arg0,arg1,arg2,arg3); }
2020 QVariant new_QRegion(const QRect & arg0,RegionType arg1) { return QRegion(arg0,(QRegion::RegionType)arg1); }
2021 QVariant new_QRegion(const QRect & arg0) { return QRegion(arg0); }
2022 QVariant new_QRegion(const QPolygon & arg0,Qt::FillRule arg1) { return QRegion(arg0,arg1); }
2023 QVariant new_QRegion(const QPolygon & arg0) { return QRegion(arg0); }
2024 QVariant new_QRegion(const QRegion & arg0) { return QRegion(arg0); }
2025 QVariant new_QRegion(const QBitmap & arg0) { return QRegion(arg0); }
2026 bool isEmpty(QRegion* obj) const {return obj->isEmpty(); }
2027 bool contains(QRegion* obj,const QPoint & arg0) const {return obj->contains(arg0); }
2028 bool contains(QRegion* obj,const QRect & arg0) const {return obj->contains(arg0); }
2029 void translate(QRegion* obj,int arg0,int arg1) {obj->translate(arg0,arg1); }
2030 void translate(QRegion* obj,const QPoint & arg0) {obj->translate(arg0); }
2031 QRegion translated(QRegion* obj,int arg0,int arg1) const {return obj->translated(arg0,arg1); }
2032 QRegion translated(QRegion* obj,const QPoint & arg0) const {return obj->translated(arg0); }
2033 QRegion unite(QRegion* obj,const QRegion & arg0) const {return obj->unite(arg0); }
2034 QRegion intersect(QRegion* obj,const QRegion & arg0) const {return obj->intersect(arg0); }
2035 QRegion subtract(QRegion* obj,const QRegion & arg0) const {return obj->subtract(arg0); }
2036 QRegion eor(QRegion* obj,const QRegion & arg0) const {return obj->eor(arg0); }
2037 QRegion united(QRegion* obj,const QRegion & arg0) const {return obj->united(arg0); }
2038 QRegion intersected(QRegion* obj,const QRegion & arg0) const {return obj->intersected(arg0); }
2039 QRegion subtracted(QRegion* obj,const QRegion & arg0) const {return obj->subtracted(arg0); }
2040 QRegion xored(QRegion* obj,const QRegion & arg0) const {return obj->xored(arg0); }
2041 bool intersects(QRegion* obj,const QRegion & arg0) const {return obj->intersects(arg0); }
2042 bool intersects(QRegion* obj,const QRect & arg0) const {return obj->intersects(arg0); }
2043 QRect boundingRect(QRegion* obj) const {return obj->boundingRect(); }
2044 QVector<QRect> rects(QRegion* obj) const {return obj->rects(); }
2045 void setRects(QRegion* obj,const QRect * arg0,int arg1) {obj->setRects(arg0,arg1); }
2046
2047 };
2048
2049 /****************************************************************************
2050 ** Meta object code from reading C++ file 'qbitmap.h'
2051 **
2052 ** Created: Thu 12. Apr 14:07:31 2007
2053 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
2054 **
2055 ** WARNING! All changes made in this file will be lost!
2056 *****************************************************************************/
2057
2058 #include "qbitmap.h"
2059 class PythonQtQBitmapWrapper : public QObject {
2060 Q_OBJECT
2061
2062 public:
2063 public slots:
2064 QVariant new_QBitmap() { return QBitmap(); }
2065 QVariant new_QBitmap(const QPixmap & arg0) { return QBitmap(arg0); }
2066 QVariant new_QBitmap(int arg0,int arg1) { return QBitmap(arg0,arg1); }
2067 QVariant new_QBitmap(const QSize & arg0) { return QBitmap(arg0); }
2068 QVariant new_QBitmap(const QString & arg0,const char * arg1) { return QBitmap(arg0,arg1); }
2069 QVariant new_QBitmap(const QString & arg0) { return QBitmap(arg0); }
2070 void clear(QBitmap* obj) {obj->clear(); }
2071 QBitmap static_QBitmap_fromImage(const QImage & arg0,Qt::ImageConversionFlags arg1) {return QBitmap::fromImage(arg0,arg1); }
2072 QBitmap static_QBitmap_fromImage(const QImage & arg0) {return QBitmap::fromImage(arg0); }
2073 QBitmap static_QBitmap_fromData(const QSize & arg0,const uchar * arg1,QImage::Format arg2) {return QBitmap::fromData(arg0,arg1,arg2); }
2074 QBitmap static_QBitmap_fromData(const QSize & arg0,const uchar * arg1) {return QBitmap::fromData(arg0,arg1); }
2075 QBitmap transformed(QBitmap* obj,const QMatrix & arg0) const {return obj->transformed(arg0); }
2076
2077 };
2078
2079 /****************************************************************************
2080 ** Meta object code from reading C++ file 'qcursor.h'
2081 **
2082 ** Created: Thu 12. Apr 14:07:31 2007
2083 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
2084 **
2085 ** WARNING! All changes made in this file will be lost!
2086 *****************************************************************************/
2087
2088 #include "qcursor.h"
2089 class PythonQtQCursorWrapper : public QObject {
2090 Q_OBJECT
2091
2092 public:
2093 public slots:
2094 QVariant new_QCursor() { return QCursor(); }
2095 QVariant new_QCursor(Qt::CursorShape arg0) { return QCursor(arg0); }
2096 QVariant new_QCursor(const QBitmap & arg0,const QBitmap & arg1,int arg2,int arg3) { return QCursor(arg0,arg1,arg2,arg3); }
2097 QVariant new_QCursor(const QBitmap & arg0,const QBitmap & arg1,int arg2) { return QCursor(arg0,arg1,arg2); }
2098 QVariant new_QCursor(const QBitmap & arg0,const QBitmap & arg1) { return QCursor(arg0,arg1); }
2099 QVariant new_QCursor(const QPixmap & arg0,int arg1,int arg2) { return QCursor(arg0,arg1,arg2); }
2100 QVariant new_QCursor(const QPixmap & arg0,int arg1) { return QCursor(arg0,arg1); }
2101 QVariant new_QCursor(const QPixmap & arg0) { return QCursor(arg0); }
2102 QVariant new_QCursor(const QCursor & arg0) { return QCursor(arg0); }
2103 Qt::CursorShape shape(QCursor* obj) const {return obj->shape(); }
2104 void setShape(QCursor* obj,Qt::CursorShape arg0) {obj->setShape(arg0); }
2105 const QBitmap* bitmap(QCursor* obj) const {return obj->bitmap(); }
2106 const QBitmap* mask(QCursor* obj) const {return obj->mask(); }
2107 QPixmap pixmap(QCursor* obj) const {return obj->pixmap(); }
2108 QPoint hotSpot(QCursor* obj) const {return obj->hotSpot(); }
2109 QPoint static_QCursor_pos() {return QCursor::pos(); }
2110 void static_QCursor_setPos(int arg0,int arg1) {QCursor::setPos(arg0,arg1); }
2111 void static_QCursor_setPos(const QPoint & arg0) {QCursor::setPos(arg0); }
2112
2113 };
2114
2115 /****************************************************************************
2116 ** Meta object code from reading C++ file 'qsizepolicy.h'
2117 **
2118 ** Created: Thu 12. Apr 14:07:33 2007
2119 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
2120 **
2121 ** WARNING! All changes made in this file will be lost!
2122 *****************************************************************************/
2123
2124 #include "qsizepolicy.h"
2125 class PythonQtQSizePolicyWrapper : public QObject {
2126 Q_OBJECT
2127
2128 public:
2129 Q_ENUMS(PolicyFlag Policy )
2130 enum PolicyFlag {GrowFlag = QSizePolicy::GrowFlag,
2131 ExpandFlag = QSizePolicy::ExpandFlag,
2132 ShrinkFlag = QSizePolicy::ShrinkFlag,
2133 IgnoreFlag = QSizePolicy::IgnoreFlag };
2134 enum Policy {Fixed = QSizePolicy::Fixed,
2135 Minimum = QSizePolicy::Minimum,
2136 Maximum = QSizePolicy::Maximum,
2137 Preferred = QSizePolicy::Preferred,
2138 MinimumExpanding = QSizePolicy::MinimumExpanding,
2139 Expanding = QSizePolicy::Expanding,
2140 Ignored = QSizePolicy::Ignored };
2141 public slots:
2142 QVariant new_QSizePolicy() { return QSizePolicy(); }
2143 Policy horizontalPolicy(QSizePolicy* obj) const {return (PythonQtQSizePolicyWrapper::Policy)obj->horizontalPolicy(); }
2144 Policy verticalPolicy(QSizePolicy* obj) const {return (PythonQtQSizePolicyWrapper::Policy)obj->verticalPolicy(); }
2145 void setHorizontalPolicy(QSizePolicy* obj,Policy arg0) {obj->setHorizontalPolicy((QSizePolicy::Policy)arg0); }
2146 void setVerticalPolicy(QSizePolicy* obj,Policy arg0) {obj->setVerticalPolicy((QSizePolicy::Policy)arg0); }
2147 Qt::Orientations expandingDirections(QSizePolicy* obj) const {return obj->expandingDirections(); }
2148 void setHeightForWidth(QSizePolicy* obj,bool arg0) {obj->setHeightForWidth(arg0); }
2149 bool hasHeightForWidth(QSizePolicy* obj) const {return obj->hasHeightForWidth(); }
2150 int horizontalStretch(QSizePolicy* obj) const {return obj->horizontalStretch(); }
2151 int verticalStretch(QSizePolicy* obj) const {return obj->verticalStretch(); }
2152 void setHorizontalStretch(QSizePolicy* obj,uchar arg0) {obj->setHorizontalStretch(arg0); }
2153 void setVerticalStretch(QSizePolicy* obj,uchar arg0) {obj->setVerticalStretch(arg0); }
2154 void transpose(QSizePolicy* obj) {obj->transpose(); }
2155
2156 };
2157
2158 /****************************************************************************
2159 ** Meta object code from reading C++ file 'qkeysequence.h'
2160 **
2161 ** Created: Thu 12. Apr 14:07:34 2007
2162 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
2163 **
2164 ** WARNING! All changes made in this file will be lost!
2165 *****************************************************************************/
2166
2167 #include "qkeysequence.h"
2168 class PythonQtQKeySequenceWrapper : public QObject {
2169 Q_OBJECT
2170
2171 public:
2172 Q_ENUMS(StandardKey SequenceMatch SequenceFormat )
2173 enum StandardKey {UnknownKey = QKeySequence::UnknownKey,
2174 HelpContents = QKeySequence::HelpContents,
2175 WhatsThis = QKeySequence::WhatsThis,
2176 Open = QKeySequence::Open,
2177 Close = QKeySequence::Close,
2178 Save = QKeySequence::Save,
2179 New = QKeySequence::New,
2180 Delete = QKeySequence::Delete,
2181 Cut = QKeySequence::Cut,
2182 Copy = QKeySequence::Copy,
2183 Paste = QKeySequence::Paste,
2184 Undo = QKeySequence::Undo,
2185 Redo = QKeySequence::Redo,
2186 Back = QKeySequence::Back,
2187 Forward = QKeySequence::Forward,
2188 Refresh = QKeySequence::Refresh,
2189 ZoomIn = QKeySequence::ZoomIn,
2190 ZoomOut = QKeySequence::ZoomOut,
2191 Print = QKeySequence::Print,
2192 AddTab = QKeySequence::AddTab,
2193 NextChild = QKeySequence::NextChild,
2194 PreviousChild = QKeySequence::PreviousChild,
2195 Find = QKeySequence::Find,
2196 FindNext = QKeySequence::FindNext,
2197 FindPrevious = QKeySequence::FindPrevious,
2198 Replace = QKeySequence::Replace,
2199 SelectAll = QKeySequence::SelectAll,
2200 Bold = QKeySequence::Bold,
2201 Italic = QKeySequence::Italic,
2202 Underline = QKeySequence::Underline,
2203 MoveToNextChar = QKeySequence::MoveToNextChar,
2204 MoveToPreviousChar = QKeySequence::MoveToPreviousChar,
2205 MoveToNextWord = QKeySequence::MoveToNextWord,
2206 MoveToPreviousWord = QKeySequence::MoveToPreviousWord,
2207 MoveToNextLine = QKeySequence::MoveToNextLine,
2208 MoveToPreviousLine = QKeySequence::MoveToPreviousLine,
2209 MoveToNextPage = QKeySequence::MoveToNextPage,
2210 MoveToPreviousPage = QKeySequence::MoveToPreviousPage,
2211 MoveToStartOfLine = QKeySequence::MoveToStartOfLine,
2212 MoveToEndOfLine = QKeySequence::MoveToEndOfLine,
2213 MoveToStartOfBlock = QKeySequence::MoveToStartOfBlock,
2214 MoveToEndOfBlock = QKeySequence::MoveToEndOfBlock,
2215 MoveToStartOfDocument = QKeySequence::MoveToStartOfDocument,
2216 MoveToEndOfDocument = QKeySequence::MoveToEndOfDocument,
2217 SelectNextChar = QKeySequence::SelectNextChar,
2218 SelectPreviousChar = QKeySequence::SelectPreviousChar,
2219 SelectNextWord = QKeySequence::SelectNextWord,
2220 SelectPreviousWord = QKeySequence::SelectPreviousWord,
2221 SelectNextLine = QKeySequence::SelectNextLine,
2222 SelectPreviousLine = QKeySequence::SelectPreviousLine,
2223 SelectNextPage = QKeySequence::SelectNextPage,
2224 SelectPreviousPage = QKeySequence::SelectPreviousPage,
2225 SelectStartOfLine = QKeySequence::SelectStartOfLine,
2226 SelectEndOfLine = QKeySequence::SelectEndOfLine,
2227 SelectStartOfBlock = QKeySequence::SelectStartOfBlock,
2228 SelectEndOfBlock = QKeySequence::SelectEndOfBlock,
2229 SelectStartOfDocument = QKeySequence::SelectStartOfDocument,
2230 SelectEndOfDocument = QKeySequence::SelectEndOfDocument,
2231 DeleteStartOfWord = QKeySequence::DeleteStartOfWord,
2232 DeleteEndOfWord = QKeySequence::DeleteEndOfWord,
2233 DeleteEndOfLine = QKeySequence::DeleteEndOfLine };
2234 enum SequenceMatch {NoMatch = QKeySequence::NoMatch,
2235 PartialMatch = QKeySequence::PartialMatch,
2236 ExactMatch = QKeySequence::ExactMatch };
2237 enum SequenceFormat {NativeText = QKeySequence::NativeText,
2238 PortableText = QKeySequence::PortableText };
2239 public slots:
2240 QVariant new_QKeySequence() { return QKeySequence(); }
2241 QVariant new_QKeySequence(const QString & arg0) { return QKeySequence(arg0); }
2242 QVariant new_QKeySequence(int arg0,int arg1,int arg2,int arg3) { return QKeySequence(arg0,arg1,arg2,arg3); }
2243 QVariant new_QKeySequence(int arg0,int arg1,int arg2) { return QKeySequence(arg0,arg1,arg2); }
2244 QVariant new_QKeySequence(int arg0,int arg1) { return QKeySequence(arg0,arg1); }
2245 QVariant new_QKeySequence(int arg0) { return QKeySequence(arg0); }
2246 QVariant new_QKeySequence(const QKeySequence & arg0) { return QKeySequence(arg0); }
2247 QVariant new_QKeySequence(StandardKey arg0) { return QKeySequence((QKeySequence::StandardKey)arg0); }
2248 uint count(QKeySequence* obj) const {return obj->count(); }
2249 bool isEmpty(QKeySequence* obj) const {return obj->isEmpty(); }
2250 QString toString(QKeySequence* obj,SequenceFormat arg0) const {return obj->toString((QKeySequence::SequenceFormat)arg0); }
2251 QString toString(QKeySequence* obj) const {return obj->toString(); }
2252 QKeySequence static_QKeySequence_fromString(const QString & arg0,SequenceFormat arg1) {return QKeySequence::fromString(arg0,(QKeySequence::SequenceFormat)arg1); }
2253 QKeySequence static_QKeySequence_fromString(const QString & arg0) {return QKeySequence::fromString(arg0); }
2254 SequenceMatch matches(QKeySequence* obj,const QKeySequence & arg0) const {return (PythonQtQKeySequenceWrapper::SequenceMatch)obj->matches(arg0); }
2255 QKeySequence static_QKeySequence_mnemonic(const QString & arg0) {return QKeySequence::mnemonic(arg0); }
2256 QList<QKeySequence> static_QKeySequence_keyBindings(StandardKey arg0) {return QKeySequence::keyBindings((QKeySequence::StandardKey)arg0); }
2257 bool isDetached(QKeySequence* obj) const {return obj->isDetached(); }
2258
2259 };
2260
2261 /****************************************************************************
2262 ** Meta object code from reading C++ file 'qpen.h'
2263 **
2264 ** Created: Thu 12. Apr 14:07:35 2007
2265 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
2266 **
2267 ** WARNING! All changes made in this file will be lost!
2268 *****************************************************************************/
2269
2270 #include "qpen.h"
2271 class PythonQtQPenWrapper : public QObject {
2272 Q_OBJECT
2273
2274 public:
2275 public slots:
2276 QVariant new_QPen() { return QPen(); }
2277 QVariant new_QPen(Qt::PenStyle arg0) { return QPen(arg0); }
2278 QVariant new_QPen(const QColor & arg0) { return QPen(arg0); }
2279 QVariant new_QPen(const QBrush & arg0,qreal arg1,Qt::PenStyle arg2,Qt::PenCapStyle arg3,Qt::PenJoinStyle arg4) { return QPen(arg0,arg1,arg2,arg3,arg4); }
2280 QVariant new_QPen(const QBrush & arg0,qreal arg1,Qt::PenStyle arg2,Qt::PenCapStyle arg3) { return QPen(arg0,arg1,arg2,arg3); }
2281 QVariant new_QPen(const QBrush & arg0,qreal arg1,Qt::PenStyle arg2) { return QPen(arg0,arg1,arg2); }
2282 QVariant new_QPen(const QBrush & arg0,qreal arg1) { return QPen(arg0,arg1); }
2283 QVariant new_QPen(const QPen & arg0) { return QPen(arg0); }
2284 Qt::PenStyle style(QPen* obj) const {return obj->style(); }
2285 void setStyle(QPen* obj,Qt::PenStyle arg0) {obj->setStyle(arg0); }
2286 QVector<qreal> dashPattern(QPen* obj) const {return obj->dashPattern(); }
2287 void setDashPattern(QPen* obj,const QVector<qreal> & arg0) {obj->setDashPattern(arg0); }
2288 qreal miterLimit(QPen* obj) const {return obj->miterLimit(); }
2289 void setMiterLimit(QPen* obj,qreal arg0) {obj->setMiterLimit(arg0); }
2290 qreal widthF(QPen* obj) const {return obj->widthF(); }
2291 void setWidthF(QPen* obj,qreal arg0) {obj->setWidthF(arg0); }
2292 int width(QPen* obj) const {return obj->width(); }
2293 void setWidth(QPen* obj,int arg0) {obj->setWidth(arg0); }
2294 QColor color(QPen* obj) const {return obj->color(); }
2295 void setColor(QPen* obj,const QColor & arg0) {obj->setColor(arg0); }
2296 QBrush brush(QPen* obj) const {return obj->brush(); }
2297 void setBrush(QPen* obj,const QBrush & arg0) {obj->setBrush(arg0); }
2298 bool isSolid(QPen* obj) const {return obj->isSolid(); }
2299 Qt::PenCapStyle capStyle(QPen* obj) const {return obj->capStyle(); }
2300 void setCapStyle(QPen* obj,Qt::PenCapStyle arg0) {obj->setCapStyle(arg0); }
2301 Qt::PenJoinStyle joinStyle(QPen* obj) const {return obj->joinStyle(); }
2302 void setJoinStyle(QPen* obj,Qt::PenJoinStyle arg0) {obj->setJoinStyle(arg0); }
2303 bool isDetached(QPen* obj) {return obj->isDetached(); }
2304
2305 };
2306
2307 /****************************************************************************
2308 ** Meta object code from reading C++ file 'qtextformat.h'
2309 **
2310 ** Created: Thu 12. Apr 14:07:35 2007
2311 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
2312 **
2313 ** WARNING! All changes made in this file will be lost!
2314 *****************************************************************************/
2315
2316 #include "qtextformat.h"
2317 class PythonQtQTextLengthWrapper : public QObject {
2318 Q_OBJECT
2319
2320 public:
2321 Q_ENUMS(Type )
2322 enum Type {VariableLength = QTextLength::VariableLength,
2323 FixedLength = QTextLength::FixedLength,
2324 PercentageLength = QTextLength::PercentageLength };
2325 public slots:
2326 QVariant new_QTextLength() { return QTextLength(); }
2327 QVariant new_QTextLength(Type arg0,qreal arg1) { return QTextLength((QTextLength::Type)arg0,arg1); }
2328 Type type(QTextLength* obj) const {return (PythonQtQTextLengthWrapper::Type)obj->type(); }
2329 qreal value(QTextLength* obj,qreal arg0) const {return obj->value(arg0); }
2330 qreal rawValue(QTextLength* obj) const {return obj->rawValue(); }
2331
2332 };
2333
2334 class PythonQtQTextFormatWrapper : public QObject {
2335 Q_OBJECT
2336
2337 public:
2338 Q_ENUMS(FormatType Property ObjectTypes PageBreakFlag )
2339 enum FormatType {InvalidFormat = QTextFormat::InvalidFormat,
2340 BlockFormat = QTextFormat::BlockFormat,
2341 CharFormat = QTextFormat::CharFormat,
2342 ListFormat = QTextFormat::ListFormat,
2343 TableFormat = QTextFormat::TableFormat,
2344 FrameFormat = QTextFormat::FrameFormat,
2345 UserFormat = QTextFormat::UserFormat };
2346 enum Property {ObjectIndex = QTextFormat::ObjectIndex,
2347 CssFloat = QTextFormat::CssFloat,
2348 LayoutDirection = QTextFormat::LayoutDirection,
2349 OutlinePen = QTextFormat::OutlinePen,
2350 BackgroundBrush = QTextFormat::BackgroundBrush,
2351 ForegroundBrush = QTextFormat::ForegroundBrush,
2352 BlockAlignment = QTextFormat::BlockAlignment,
2353 BlockTopMargin = QTextFormat::BlockTopMargin,
2354 BlockBottomMargin = QTextFormat::BlockBottomMargin,
2355 BlockLeftMargin = QTextFormat::BlockLeftMargin,
2356 BlockRightMargin = QTextFormat::BlockRightMargin,
2357 TextIndent = QTextFormat::TextIndent,
2358 BlockIndent = QTextFormat::BlockIndent,
2359 BlockNonBreakableLines = QTextFormat::BlockNonBreakableLines,
2360 BlockTrailingHorizontalRulerWidth = QTextFormat::BlockTrailingHorizontalRulerWidth,
2361 FontFamily = QTextFormat::FontFamily,
2362 FontPointSize = QTextFormat::FontPointSize,
2363 FontSizeAdjustment = QTextFormat::FontSizeAdjustment,
2364 FontSizeIncrement = QTextFormat::FontSizeIncrement,
2365 FontWeight = QTextFormat::FontWeight,
2366 FontItalic = QTextFormat::FontItalic,
2367 FontUnderline = QTextFormat::FontUnderline,
2368 FontOverline = QTextFormat::FontOverline,
2369 FontStrikeOut = QTextFormat::FontStrikeOut,
2370 FontFixedPitch = QTextFormat::FontFixedPitch,
2371 FontPixelSize = QTextFormat::FontPixelSize,
2372 TextUnderlineColor = QTextFormat::TextUnderlineColor,
2373 TextVerticalAlignment = QTextFormat::TextVerticalAlignment,
2374 TextOutline = QTextFormat::TextOutline,
2375 TextUnderlineStyle = QTextFormat::TextUnderlineStyle,
2376 IsAnchor = QTextFormat::IsAnchor,
2377 AnchorHref = QTextFormat::AnchorHref,
2378 AnchorName = QTextFormat::AnchorName,
2379 ObjectType = QTextFormat::ObjectType,
2380 ListStyle = QTextFormat::ListStyle,
2381 ListIndent = QTextFormat::ListIndent,
2382 FrameBorder = QTextFormat::FrameBorder,
2383 FrameMargin = QTextFormat::FrameMargin,
2384 FramePadding = QTextFormat::FramePadding,
2385 FrameWidth = QTextFormat::FrameWidth,
2386 FrameHeight = QTextFormat::FrameHeight,
2387 TableColumns = QTextFormat::TableColumns,
2388 TableColumnWidthConstraints = QTextFormat::TableColumnWidthConstraints,
2389 TableCellSpacing = QTextFormat::TableCellSpacing,
2390 TableCellPadding = QTextFormat::TableCellPadding,
2391 TableHeaderRowCount = QTextFormat::TableHeaderRowCount,
2392 TableCellRowSpan = QTextFormat::TableCellRowSpan,
2393 TableCellColumnSpan = QTextFormat::TableCellColumnSpan,
2394 ImageName = QTextFormat::ImageName,
2395 ImageWidth = QTextFormat::ImageWidth,
2396 ImageHeight = QTextFormat::ImageHeight,
2397 FullWidthSelection = QTextFormat::FullWidthSelection,
2398 PageBreakPolicy = QTextFormat::PageBreakPolicy,
2399 UserProperty = QTextFormat::UserProperty };
2400 enum ObjectTypes {NoObject = QTextFormat::NoObject,
2401 ImageObject = QTextFormat::ImageObject,
2402 TableObject = QTextFormat::TableObject,
2403 UserObject = QTextFormat::UserObject };
2404 enum PageBreakFlag {PageBreak_Auto = QTextFormat::PageBreak_Auto,
2405 PageBreak_AlwaysBefore = QTextFormat::PageBreak_AlwaysBefore,
2406 PageBreak_AlwaysAfter = QTextFormat::PageBreak_AlwaysAfter };
2407 Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)
2408 public slots:
2409 QVariant new_QTextFormat(int arg0) { return QTextFormat(arg0); }
2410 QVariant new_QTextFormat(const QTextFormat & arg0) { return QTextFormat(arg0); }
2411 void merge(QTextFormat* obj,const QTextFormat & arg0) {obj->merge(arg0); }
2412 bool isValid(QTextFormat* obj) const {return obj->isValid(); }
2413 int type(QTextFormat* obj) const {return obj->type(); }
2414 int objectIndex(QTextFormat* obj) const {return obj->objectIndex(); }
2415 void setObjectIndex(QTextFormat* obj,int arg0) {obj->setObjectIndex(arg0); }
2416 QVariant property(QTextFormat* obj,int arg0) const {return obj->property(arg0); }
2417 void setProperty(QTextFormat* obj,int arg0,const QVariant & arg1) {obj->setProperty(arg0,arg1); }
2418 void clearProperty(QTextFormat* obj,int arg0) {obj->clearProperty(arg0); }
2419 bool hasProperty(QTextFormat* obj,int arg0) const {return obj->hasProperty(arg0); }
2420 bool boolProperty(QTextFormat* obj,int arg0) const {return obj->boolProperty(arg0); }
2421 int intProperty(QTextFormat* obj,int arg0) const {return obj->intProperty(arg0); }
2422 qreal doubleProperty(QTextFormat* obj,int arg0) const {return obj->doubleProperty(arg0); }
2423 QString stringProperty(QTextFormat* obj,int arg0) const {return obj->stringProperty(arg0); }
2424 QColor colorProperty(QTextFormat* obj,int arg0) const {return obj->colorProperty(arg0); }
2425 QPen penProperty(QTextFormat* obj,int arg0) const {return obj->penProperty(arg0); }
2426 QBrush brushProperty(QTextFormat* obj,int arg0) const {return obj->brushProperty(arg0); }
2427 QTextLength lengthProperty(QTextFormat* obj,int arg0) const {return obj->lengthProperty(arg0); }
2428 QVector<QTextLength> lengthVectorProperty(QTextFormat* obj,int arg0) const {return obj->lengthVectorProperty(arg0); }
2429 void setProperty(QTextFormat* obj,int arg0,const QVector<QTextLength> & arg1) {obj->setProperty(arg0,arg1); }
2430 QMap<int,QVariant> properties(QTextFormat* obj) const {return obj->properties(); }
2431 void setObjectType(QTextFormat* obj,int arg0) {obj->setObjectType(arg0); }
2432 int objectType(QTextFormat* obj) const {return obj->objectType(); }
2433 bool isCharFormat(QTextFormat* obj) const {return obj->isCharFormat(); }
2434 bool isBlockFormat(QTextFormat* obj) const {return obj->isBlockFormat(); }
2435 bool isListFormat(QTextFormat* obj) const {return obj->isListFormat(); }
2436 bool isFrameFormat(QTextFormat* obj) const {return obj->isFrameFormat(); }
2437 bool isImageFormat(QTextFormat* obj) const {return obj->isImageFormat(); }
2438 bool isTableFormat(QTextFormat* obj) const {return obj->isTableFormat(); }
2439 QTextBlockFormat toBlockFormat(QTextFormat* obj) const {return obj->toBlockFormat(); }
2440 QTextCharFormat toCharFormat(QTextFormat* obj) const {return obj->toCharFormat(); }
2441 QTextListFormat toListFormat(QTextFormat* obj) const {return obj->toListFormat(); }
2442 QTextTableFormat toTableFormat(QTextFormat* obj) const {return obj->toTableFormat(); }
2443 QTextFrameFormat toFrameFormat(QTextFormat* obj) const {return obj->toFrameFormat(); }
2444 QTextImageFormat toImageFormat(QTextFormat* obj) const {return obj->toImageFormat(); }
2445 void setLayoutDirection(QTextFormat* obj,Qt::LayoutDirection arg0) {obj->setLayoutDirection(arg0); }
2446 Qt::LayoutDirection layoutDirection(QTextFormat* obj) const {return obj->layoutDirection(); }
2447 void setBackground(QTextFormat* obj,const QBrush & arg0) {obj->setBackground(arg0); }
2448 QBrush background(QTextFormat* obj) const {return obj->background(); }
2449 void clearBackground(QTextFormat* obj) {obj->clearBackground(); }
2450 void setForeground(QTextFormat* obj,const QBrush & arg0) {obj->setForeground(arg0); }
2451 QBrush foreground(QTextFormat* obj) const {return obj->foreground(); }
2452 void clearForeground(QTextFormat* obj) {obj->clearForeground(); }
2453
2454 };
2455
2456 /****************************************************************************
2457 ** Meta object code from reading C++ file 'qmatrix.h'
2458 **
2459 ** Created: Thu 12. Apr 14:07:35 2007
2460 ** by: The Qt Meta Object Compiler version 59 (Qt 4.2.3)
2461 **
2462 ** WARNING! All changes made in this file will be lost!
2463 *****************************************************************************/
2464
2465 #include "qmatrix.h"
2466 class PythonQtQMatrixWrapper : public QObject {
2467 Q_OBJECT
2468
2469 public:
2470 public slots:
2471 QVariant new_QMatrix() { return QMatrix(); }
2472 QVariant new_QMatrix(qreal arg0,qreal arg1,qreal arg2,qreal arg3,qreal arg4,qreal arg5) { return QMatrix(arg0,arg1,arg2,arg3,arg4,arg5); }
2473 QVariant new_QMatrix(const QMatrix & arg0) { return QMatrix(arg0); }
2474 void setMatrix(QMatrix* obj,qreal arg0,qreal arg1,qreal arg2,qreal arg3,qreal arg4,qreal arg5) {obj->setMatrix(arg0,arg1,arg2,arg3,arg4,arg5); }
2475 qreal m11(QMatrix* obj) const {return obj->m11(); }
2476 qreal m12(QMatrix* obj) const {return obj->m12(); }
2477 qreal m21(QMatrix* obj) const {return obj->m21(); }
2478 qreal m22(QMatrix* obj) const {return obj->m22(); }
2479 qreal dx(QMatrix* obj) const {return obj->dx(); }
2480 qreal dy(QMatrix* obj) const {return obj->dy(); }
2481 void map(QMatrix* obj,int arg0,int arg1,int * arg2,int * arg3) const {obj->map(arg0,arg1,arg2,arg3); }
2482 void map(QMatrix* obj,qreal arg0,qreal arg1,qreal * arg2,qreal * arg3) const {obj->map(arg0,arg1,arg2,arg3); }
2483 QRect mapRect(QMatrix* obj,const QRect & arg0) const {return obj->mapRect(arg0); }
2484 QRectF mapRect(QMatrix* obj,const QRectF & arg0) const {return obj->mapRect(arg0); }
2485 QPoint map(QMatrix* obj,const QPoint & arg0) const {return obj->map(arg0); }
2486 QPointF map(QMatrix* obj,const QPointF & arg0) const {return obj->map(arg0); }
2487 QLine map(QMatrix* obj,const QLine & arg0) const {return obj->map(arg0); }
2488 QLineF map(QMatrix* obj,const QLineF & arg0) const {return obj->map(arg0); }
2489 QPolygonF map(QMatrix* obj,const QPolygonF & arg0) const {return obj->map(arg0); }
2490 QPolygon map(QMatrix* obj,const QPolygon & arg0) const {return obj->map(arg0); }
2491 QRegion map(QMatrix* obj,const QRegion & arg0) const {return obj->map(arg0); }
2492 QPainterPath map(QMatrix* obj,const QPainterPath & arg0) const {return obj->map(arg0); }
2493 QPolygon mapToPolygon(QMatrix* obj,const QRect & arg0) const {return obj->mapToPolygon(arg0); }
2494 void reset(QMatrix* obj) {obj->reset(); }
2495 bool isIdentity(QMatrix* obj) const {return obj->isIdentity(); }
2496 void translate(QMatrix* obj,qreal arg0,qreal arg1) {obj->translate(arg0,arg1); }
2497 void scale(QMatrix* obj,qreal arg0,qreal arg1) {obj->scale(arg0,arg1); }
2498 void shear(QMatrix* obj,qreal arg0,qreal arg1) {obj->shear(arg0,arg1); }
2499 void rotate(QMatrix* obj,qreal arg0) {obj->rotate(arg0); }
2500 bool isInvertible(QMatrix* obj) const {return obj->isInvertible(); }
2501 qreal det(QMatrix* obj) const {return obj->det(); }
2502 QMatrix inverted(QMatrix* obj,bool * arg0) const {return obj->inverted(arg0); }
2503 QMatrix inverted(QMatrix* obj) const {return obj->inverted(); }
2504
2505 };
2506
@@ -0,0 +1,2
1 "%MEVIS_LIB%\make\win32\createDsp.bat" PythonQtTest
2
@@ -0,0 +1,61
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtTests.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQt.h"
43 #include "PythonQtTests.h"
44
45 int main( int argc, char **argv )
46 {
47 QApplication qapp(argc, argv);
48
49 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
50
51 PythonQtTestApi api;
52 QTest::qExec(&api, argc, argv);
53 PythonQtTestSignalHandler signalHandler;
54 QTest::qExec(&signalHandler, argc, argv);
55 PythonQtTestSlotCalling slotCalling;
56 QTest::qExec(&slotCalling, argc, argv);
57
58 PythonQt::cleanup();
59 return 0;
60 }
61
@@ -0,0 +1,325
1 /*
2 *
3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 * 28359 Bremen, Germany or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33 //----------------------------------------------------------------------------------
34 /*!
35 // \file PythonQtTests.cpp
36 // \author Florian Link
37 // \author Last changed by $Author: florian $
38 // \date 2006-05
39 */
40 //----------------------------------------------------------------------------------
41
42 #include "PythonQtTests.h"
43
44 void PythonQtTestSlotCalling::initTestCase()
45 {
46 _helper = new PythonQtTestSlotCallingHelper(this);
47 PythonQtObjectPtr main = PythonQt::self()->getMainModule();
48 PythonQt::self()->addObject(main, "obj", _helper);
49 }
50
51 void PythonQtTestSlotCalling::init() {
52
53 }
54
55 void PythonQtTestSlotCalling::testNoArgSlotCall()
56 {
57 QVERIFY(_helper->runScript("obj.testNoArg(); obj.setPassed();\n"));
58 }
59
60 void PythonQtTestSlotCalling::testOverloadedCall()
61 {
62 QVERIFY(_helper->runScript("obj.overload(False); obj.setPassed();\n", 0));
63 QVERIFY(_helper->runScript("obj.overload(True); obj.setPassed();\n", 0));
64 QVERIFY(_helper->runScript("obj.overload(12.5); obj.setPassed();\n", 1));
65 QVERIFY(_helper->runScript("obj.overload(12); obj.setPassed();\n", 2));
66 QVERIFY(_helper->runScript("obj.overload('test'); obj.setPassed();\n", 3));
67 QVERIFY(_helper->runScript("obj.overload(u'test'); obj.setPassed();\n", 3));
68 QVERIFY(_helper->runScript("obj.overload(('test','test2')); obj.setPassed();\n", 4));
69 QVERIFY(_helper->runScript("obj.overload(obj); obj.setPassed();\n", 5));
70 QVERIFY(_helper->runScript("obj.overload(12,13); obj.setPassed();\n", 6));
71 }
72
73 void PythonQtTestSlotCalling::testPODSlotCalls()
74 {
75 QVERIFY(_helper->runScript("if obj.getBool(False)==False: obj.setPassed();\n"));
76 QVERIFY(_helper->runScript("if obj.getBool(True)==True: obj.setPassed();\n"));
77 QVERIFY(_helper->runScript("if obj.getInt(-42)==-42: obj.setPassed();\n"));
78 QVERIFY(_helper->runScript("if obj.getUInt(42)==42: obj.setPassed();\n"));
79 QVERIFY(_helper->runScript("if obj.getShort(-43)==-43: obj.setPassed();\n"));
80 QVERIFY(_helper->runScript("if obj.getUShort(43)==43: obj.setPassed();\n"));
81 QVERIFY(_helper->runScript("if obj.getChar(-12)==-12: obj.setPassed();\n"));
82 QVERIFY(_helper->runScript("if obj.getUChar(12)==12: obj.setPassed();\n"));
83 QVERIFY(_helper->runScript("if obj.getLong(-256*256*256)==-256*256*256: obj.setPassed();\n"));
84 QVERIFY(_helper->runScript("if obj.getULong(256*256*256)==256*256*256: obj.setPassed();\n"));
85 QVERIFY(_helper->runScript("if obj.getLongLong(-42)==-42: obj.setPassed();\n"));
86 QVERIFY(_helper->runScript("if obj.getULongLong(42)==42: obj.setPassed();\n"));
87 QVERIFY(_helper->runScript("if obj.getQChar(4096)==4096: obj.setPassed();\n"));
88 QVERIFY(_helper->runScript("if obj.getDouble(47.12)==47.12: obj.setPassed();\n"));
89 QVERIFY(_helper->runScript("if abs(obj.getFloat(47.11)-47.11)<0.01: obj.setPassed();\n"));
90 QVERIFY(_helper->runScript("if obj.getQString('testStr')=='testStr': obj.setPassed();\n"));
91 QVERIFY(_helper->runScript("if obj.getQString('')=='': obj.setPassed();\n"));
92 QVERIFY(_helper->runScript("if obj.getQStringList(('test','test2'))==('test','test2'): obj.setPassed();\n"));
93 }
94
95 void PythonQtTestSlotCalling::testQVariantSlotCalls()
96 {
97 QVERIFY(_helper->runScript("if obj.getQVariant(-42)==-42: obj.setPassed();\n"));
98 QVERIFY(_helper->runScript("if obj.getQVariant('testStr')=='testStr': obj.setPassed();\n"));
99 QVERIFY(_helper->runScript("if obj.getQVariant(('test','test2'))==('test','test2'): obj.setPassed();\n"));
100 QVERIFY(_helper->runScript("if obj.getQVariant(('test',12, 47.11))==('test',12, 47.11): obj.setPassed();\n"));
101 QVERIFY(_helper->runScript("if obj.getQVariant({'test':'bla','test2':47.11})=={'test':'bla','test2':47.11}: obj.setPassed();\n"));
102 QEXPECT_FAIL("", "Testing to pass a map and compare with a different map", Continue);
103 QVERIFY(_helper->runScript("if obj.getQVariant({'test':'bla2','test2':47.11})=={'test':'bla','test2':47.11}: obj.setPassed();\n"));
104 QVERIFY(_helper->runScript("if obj.getQVariant(obj)==obj: obj.setPassed();\n"));
105 }
106
107 void PythonQtTestSlotCalling::testObjectSlotCalls()
108 {
109 QVERIFY(_helper->runScript("if obj.getQObject(obj)==obj: obj.setPassed();\n"));
110 QVERIFY(_helper->runScript("if obj.getTestObject(obj)==obj: obj.setPassed();\n"));
111 QVERIFY(_helper->runScript("if obj.getNewObject().className()=='PythonQtTestSlotCallingHelper': obj.setPassed();\n"));
112 QEXPECT_FAIL("", "Testing to pass a QObject when another object was expected", Continue);
113 QVERIFY(_helper->runScript("if obj.getQWidget(obj)==obj: obj.setPassed();\n"));
114 }
115
116 void PythonQtTestSlotCalling::testCppFactory()
117 {
118 PythonQtTestCppFactory* f = new PythonQtTestCppFactory;
119 PythonQt::self()->addInstanceDecorators(new PQCppObjectDecorator);
120 PythonQt::self()->addInstanceDecorators(new PQCppObjectNoWrapDecorator);
121
122 PythonQt::self()->addWrapperFactory(f);
123 QVERIFY(_helper->runScript("if obj.createPQCppObject(12).getHeight()==12: obj.setPassed();\n"));
124 QVERIFY(_helper->runScript("if obj.createPQCppObject(12).getH()==12: obj.setPassed();\n"));
125 QVERIFY(_helper->runScript("pq1 = obj.createPQCppObject(12);\n"
126 "pq2 = obj.createPQCppObject(13);\n"
127 "pq3 = obj.getPQCppObject(pq1);\n"
128 "pq4 = obj.getPQCppObject(pq2);\n"
129 "if pq3.getHeight()==12 and pq4.getHeight()==13: obj.setPassed();\n"
130 ));
131
132 QVERIFY(_helper->runScript("if obj.createPQCppObjectNoWrap(12).getH()==12: obj.setPassed();\n"));
133 }
134
135
136 void PythonQtTestSlotCalling::testMultiArgsSlotCall()
137 {
138 QVERIFY(_helper->runScript("if obj.getMultiArgs(12,47.11,'test')==(12,47.11,'test'): obj.setPassed();\n"));
139 }
140
141 bool PythonQtTestSlotCallingHelper::runScript(const char* script, int expectedOverload)
142 {
143 _called = false;
144 _passed = false;
145 _calledOverload = -1;
146 PyRun_SimpleString(script);
147 return _called && _passed && _calledOverload==expectedOverload;
148 }
149
150
151 void PythonQtTestSignalHandler::initTestCase()
152 {
153 _helper = new PythonQtTestSignalHandlerHelper(this);
154 PythonQtObjectPtr main = PythonQt::self()->getMainModule();
155 PythonQt::self()->addObject(main, "obj", _helper);
156 }
157
158 void PythonQtTestSignalHandler::testSignalHandler()
159 {
160 PythonQtObjectPtr main = PythonQt::self()->getMainModule();
161 PyRun_SimpleString("def testIntSignal(a):\n if a==12: obj.setPassed();\n");
162 QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(intSignal(int)), main, "testIntSignal"));
163 QVERIFY(_helper->emitIntSignal(12));
164
165 PyRun_SimpleString("def testFloatSignal(a):\n if a==12: obj.setPassed();\n");
166 QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(floatSignal(float)), main, "testFloatSignal"));
167 QVERIFY(_helper->emitFloatSignal(12));
168
169 PyRun_SimpleString("def testVariantSignal(a):\n if a==obj.expectedVariant(): obj.setPassed();\n");
170 QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(variantSignal(QVariant)), main, "testVariantSignal"));
171 _helper->setExpectedVariant(QString("Test"));
172 QVERIFY(_helper->emitVariantSignal(QString("Test")));
173 _helper->setExpectedVariant(12);
174 QVERIFY(_helper->emitVariantSignal(12));
175 _helper->setExpectedVariant(QStringList() << "test1" << "test2");
176 QVERIFY(_helper->emitVariantSignal(QStringList() << "test1" << "test2"));
177 _helper->setExpectedVariant(qVariantFromValue((QObject*)_helper));
178 QVERIFY(_helper->emitVariantSignal(qVariantFromValue((QObject*)_helper)));
179
180 PyRun_SimpleString("def testComplexSignal(a,b,l,o):\n if a==12 and b==13 and l==('test1','test2') and o == obj: obj.setPassed();\n");
181 // intentionally not normalized signal:
182 QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(complexSignal( int, float , const QStringList , QObject*)), main, "testComplexSignal"));
183 QVERIFY(_helper->emitComplexSignal(12,13,QStringList() << "test1" << "test2", _helper));
184
185 // try removing the handler
186 QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(complexSignal( int, float , const QStringList , QObject*)), main, "testComplexSignal"));
187 // and emit the signal, which should fail because the handler was removed
188 QVERIFY(!_helper->emitComplexSignal(12,13,QStringList() << "test1" << "test2", _helper));
189
190 QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(intSignal(int)), main, "testIntSignal"));
191 QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(floatSignal(float)), main, "testFloatSignal"));
192 QVERIFY(PythonQt::self()->removeSignalHandler(_helper, SIGNAL(variantSignal(QVariant)), main, "testVariantSignal"));
193
194 }
195
196 void PythonQtTestSignalHandler::testRecursiveSignalHandler()
197 {
198 PythonQtObjectPtr main = PythonQt::self()->getMainModule();
199 PyRun_SimpleString("def testSignal1(a):\n obj.emitSignal2(a);\n");
200 PyRun_SimpleString("def testSignal2(a):\n obj.emitSignal3(float(a));\n");
201 PyRun_SimpleString("def testSignal3(a):\n if a==12: obj.setPassed();\n");
202 QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(signal1(int)), main, "testSignal1"));
203 QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(signal2(const QString&)), main, "testSignal2"));
204 QVERIFY(PythonQt::self()->addSignalHandler(_helper, SIGNAL(signal3(float)), main, "testSignal3"));
205 QVERIFY(_helper->emitSignal1(12));
206 }
207
208
209 void PythonQtTestApi::initTestCase()
210 {
211 _helper = new PythonQtTestApiHelper();
212 PythonQtObjectPtr main = PythonQt::self()->getMainModule();
213 PythonQt::self()->addObject(main, "obj", _helper);
214 }
215
216 bool PythonQtTestApiHelper::call(const QString& function, const QVariantList& args, const QVariant& expectedResult) {
217 _passed = false;
218 QVariant r = PythonQt::self()->call(PythonQt::self()->getMainModule(), function, args);
219 return _passed && expectedResult==r;
220 }
221
222 void PythonQtTestApi::testCall()
223 {
224 PythonQtObjectPtr main = PythonQt::self()->getMainModule();
225
226 QVERIFY(qVariantValue<QObject*>(PythonQt::self()->getVariable(main, "obj"))==_helper);
227
228 PyRun_SimpleString("def testCallNoArgs():\n obj.setPassed();\n");
229 QVERIFY(_helper->call("testCallNoArgs", QVariantList(), QVariant()));
230
231 PyRun_SimpleString("def testCall1(a):\n if a=='test': obj.setPassed();\n return 'test2';\n");
232 QVERIFY(_helper->call("testCall1", QVariantList() << QVariant("test"), QVariant(QString("test2"))));
233
234 PyRun_SimpleString("def testCall2(a, b):\n if a=='test' and b==obj: obj.setPassed();\n return obj;\n");
235 QVariant r = PythonQt::self()->call(PythonQt::self()->getMainModule(), "testCall2", QVariantList() << QVariant("test") << qVariantFromValue((QObject*)_helper));
236 QObject* p = qVariantValue<QObject*>(r);
237 QVERIFY(p==_helper);
238 }
239
240 void PythonQtTestApi::testVariables()
241 {
242 PythonQt::self()->addObject(PythonQt::self()->getMainModule(), "someObject", _helper);
243 QVariant v = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someObject");
244 QObject* p = qVariantValue<QObject*>(v);
245 QVERIFY(p==_helper);
246 // test for unset variable
247 QVariant v2 = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someObject2");
248 QVERIFY(v2==QVariant());
249
250 PythonQt::self()->addVariable(PythonQt::self()->getMainModule(), "someValue", QStringList() << "test1" << "test2");
251 QVariant v3 = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someValue");
252 QVERIFY(v3 == QVariant(QStringList() << "test1" << "test2"));
253
254 QStringList l = PythonQt::self()->introspection(PythonQt::self()->getMainModule(), QString::null, PythonQt::Variable);
255 QSet<QString> s;
256 // check that at least these three variables are set
257 s << "obj" << "someObject" << "someValue";
258 QString a;
259 foreach (a, l) {
260 QVERIFY(s.contains(a));
261 }
262
263 // insert a second time!
264 PythonQt::self()->addObject(PythonQt::self()->getMainModule(), "someObject", _helper);
265 // and remove
266 PythonQt::self()->removeVariable(PythonQt::self()->getMainModule(), "someObject");
267 // we expect to find no variable
268 QVariant v4 = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someObject");
269 QVERIFY(v4==QVariant());
270 }
271
272 void PythonQtTestApi::testImporter()
273 {
274 PythonQt::self()->setImporter(_helper);
275 PythonQt::self()->overwriteSysPath(QStringList() << "c:\\test");
276 PyRun_SimpleString("import bla\n");
277 }
278
279 QByteArray PythonQtTestApiHelper::readFileAsBytes(const QString& filename)
280 {
281 QByteArray b;
282 return b;
283 }
284
285 QByteArray PythonQtTestApiHelper::readSourceFile(const QString& filename, bool& ok)
286 {
287 QByteArray b;
288 ok = true;
289 return b;
290 }
291
292 bool PythonQtTestApiHelper::exists(const QString& filename)
293 {
294 return true;
295 }
296
297 QDateTime PythonQtTestApiHelper::lastModifiedDate(const QString& filename) {
298 return QDateTime::currentDateTime();
299 }
300
301
302 void PythonQtTestApi::testRedirect()
303 {
304 connect(PythonQt::self(), SIGNAL(pythonStdOut(const QString&)), _helper, SLOT(stdOut(const QString&)));
305 connect(PythonQt::self(), SIGNAL(pythonStdErr(const QString&)), _helper, SLOT(stdErr(const QString&)));
306 PyRun_SimpleString("print 'test'\n");
307 }
308
309 void PythonQtTestApiHelper::stdOut(const QString& s)
310 {
311 qDebug() << s;
312 }
313
314 void PythonQtTestApiHelper::stdErr(const QString& s)
315 {
316 qDebug() << s;
317 }
318
319 QObject* PythonQtTestCppFactory::create(const QByteArray& name, void *ptr)
320 {
321 if (name == "PQCppObject") {
322 return new PQCppObjectWrapper(ptr);
323 }
324 return NULL;
325 }
@@ -0,0 +1,332
1 #ifndef _PYTHONQTTESTS_H
2 #define _PYTHONQTTESTS_H
3
4 /*
5 *
6 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36 //----------------------------------------------------------------------------------
37 /*!
38 // \file PythonQtTests.h
39 // \author Florian Link
40 // \author Last changed by $Author: florian $
41 // \date 2006-05
42 */
43 //----------------------------------------------------------------------------------
44
45 #include "PythonQt.h"
46 #include <QtTest/QtTest>
47 #include <QVariant>
48 #include "PythonQtImportFileInterface.h"
49 #include "PythonQtCppWrapperFactory.h"
50
51 class PythonQtTestSlotCallingHelper;
52 class PythonQtTestApiHelper;
53 class QWidget;
54
55 //! test the PythonQt api
56 class PythonQtTestApi : public QObject
57 {
58 Q_OBJECT
59
60 private slots:
61 void initTestCase();
62 void testCall();
63 void testVariables();
64 void testRedirect();
65 void testImporter();
66
67 private:
68 PythonQtTestApiHelper* _helper;
69
70 };
71
72 //! test the PythonQt api (helper)
73 class PythonQtTestApiHelper : public QObject , public PythonQtImportFileInterface
74 {
75 Q_OBJECT
76 public:
77 PythonQtTestApiHelper() {
78 };
79
80 bool call(const QString& function, const QVariantList& args, const QVariant& expectedResult);
81
82 virtual QByteArray readFileAsBytes(const QString& filename);
83
84 virtual QByteArray readSourceFile(const QString& filename, bool& ok);
85
86 virtual bool exists(const QString& filename);
87
88 virtual QDateTime lastModifiedDate(const QString& filename);
89
90 public slots:
91
92 //! call to set that the test has passed (from Python!)
93 void setPassed() { _passed = true; }
94
95 void stdOut(const QString&);
96 void stdErr(const QString&);
97
98 private:
99 bool _passed;
100 };
101
102 // test implementation of the wrapper factory
103 class PythonQtTestCppFactory : public PythonQtCppWrapperFactory
104 {
105 public:
106 virtual QObject* create(const QByteArray& name, void *ptr);
107 };
108
109 //! an cpp object to be wrapped
110 class PQCppObject {
111
112 public:
113 PQCppObject(int h) { _height = h; }
114
115 int getHeight() { return _height; }
116 void setHeight(int h) { _height = h; }
117
118 private:
119 int _height;
120 };
121
122 //! an qobject that wraps the existing cpp object
123 class PQCppObjectWrapper : public QObject {
124 Q_OBJECT
125 public:
126 PQCppObjectWrapper(void* ptr) {
127 _ptr = (PQCppObject*)ptr;
128 }
129
130 public slots:
131 int getHeight() { return _ptr->getHeight(); }
132 void setHeight(int h) { _ptr->setHeight(h); }
133
134 private:
135 PQCppObject* _ptr;
136 };
137
138 class PQCppObjectDecorator : public QObject {
139 Q_OBJECT
140 public slots:
141 int getH(PQCppObject* obj) { return obj->getHeight(); }
142
143 };
144
145 //! an cpp object to be wrapped by decorators only
146 class PQCppObjectNoWrap {
147
148 public:
149 PQCppObjectNoWrap(int h) { _height = h; }
150
151 int getHeight() { return _height; }
152 void setHeight(int h) { _height = h; }
153
154 private:
155 int _height;
156 };
157
158 class PQCppObjectNoWrapDecorator : public QObject {
159 Q_OBJECT
160 public slots:
161 int getH(PQCppObjectNoWrap* obj) { return obj->getHeight(); }
162
163 };
164
165
166 //! test the calling of slots
167 class PythonQtTestSlotCalling : public QObject
168 {
169 Q_OBJECT
170
171 private slots:
172 void initTestCase();
173 void init();
174
175 void testNoArgSlotCall();
176 void testPODSlotCalls();
177 void testQVariantSlotCalls();
178 void testObjectSlotCalls();
179 void testMultiArgsSlotCall();
180
181 void testOverloadedCall();
182
183 void testCppFactory();
184
185 private:
186 PythonQtTestSlotCallingHelper* _helper;
187
188 };
189
190 //! helper class for slot calling test
191 class PythonQtTestSlotCallingHelper : public QObject
192 {
193 Q_OBJECT
194 public:
195 PythonQtTestSlotCallingHelper(PythonQtTestSlotCalling* test) {
196 _test = test;
197 };
198
199 bool runScript(const char* script, int expectedOverload = -1);
200
201 public slots:
202
203 //! call to set that the test has passed (from Python!)
204 void setPassed() { _passed = true; }
205
206 //! no arguments, no return value:
207 void testNoArg() { _called = true; }
208
209 //! overload test!
210 void overload(bool a) { _calledOverload = 0; _called = true; }
211 void overload(float a) { _calledOverload = 1; _called = true;}
212 void overload(int a) { _calledOverload = 2; _called = true;}
213 void overload(const QString& str) { _calledOverload = 3; _called = true;}
214 void overload(const QStringList& str) { _calledOverload = 4; _called = true;}
215 void overload(QObject* str) { _calledOverload = 5; _called = true;}
216 void overload(float a, int b) { _calledOverload = 6; _called = true;}
217
218 //! POD values:
219 int getInt(int a) { _called = true; return a; }
220 unsigned int getUInt(unsigned int a) { _called = true; return a; }
221 bool getBool(bool a) { _called = true; return a; }
222 char getChar(char a) { _called = true; return a; }
223 unsigned char getUChar(unsigned char a) { _called = true; return a; }
224 long getLong(long a) { _called = true; return a; }
225 unsigned long getULong(unsigned long a) { _called = true; return a; }
226 short getShort(short a) { _called = true; return a; }
227 unsigned short getUShort(unsigned short a) { _called = true; return a; }
228 QChar getQChar(QChar a) { _called = true; return a; }
229 qint64 getLongLong(qint64 a) { _called = true; return a; }
230 quint64 getULongLong(quint64 a) { _called = true; return a; }
231 double getDouble(double d) { _called = true; return d; }
232 float getFloat(float d) { _called = true; return d; }
233
234 //! important qt types:
235 QString getQString(const QString& s) { _called = true; return s; }
236 QStringList getQStringList(const QStringList& l) { _called = true; return l; }
237 QVariant getQVariant(const QVariant& var) { _called = true; return var; }
238
239 //! testing pointer passing
240 PythonQtTestSlotCallingHelper* getTestObject(PythonQtTestSlotCallingHelper* obj) { _called = true; return obj; }
241 //! testing inheritance checking
242 QObject* getQObject(QObject* obj) { _called = true; return obj; }
243 QWidget* getQWidget(QWidget* obj) { _called = true; return obj; }
244 //! testing if an object that was not wrapped is wrapped earlier is wrapped correctly
245 QObject* getNewObject() { _called = true; return new PythonQtTestSlotCallingHelper(NULL); }
246
247 QVariantList getMultiArgs(int a, double b, const QString& str) { _called = true; return (QVariantList() << a << b << str); }
248 // more exotic, not yet tested
249 //void setByteArray(QByteArray array) { qDebug() << array.data(); }
250 //void setCharPtr(char* data) { qDebug() << data; }
251
252 //! cpp wrapper factory test
253 PQCppObject* createPQCppObject(int h) { _called = true; return new PQCppObject(h); }
254
255 //! cpp wrapper factory test
256 PQCppObject* getPQCppObject(PQCppObject* p) { _called = true; return p; }
257
258 //! cpp wrapper factory test
259 PQCppObjectNoWrap* createPQCppObjectNoWrap(int h) { _called = true; return new PQCppObjectNoWrap(h); }
260
261 //! cpp wrapper factory test
262 PQCppObjectNoWrap* getPQCppObjectNoWrap(PQCppObjectNoWrap* p) { _called = true; return p; }
263
264 private:
265 bool _passed;
266 bool _called;
267 int _calledOverload;
268 PythonQtTestSlotCalling* _test;
269 };
270
271 class PythonQtTestSignalHandlerHelper;
272
273 //! test the connection of signals to python
274 class PythonQtTestSignalHandler : public QObject
275 {
276 Q_OBJECT
277
278 private slots:
279 void initTestCase();
280
281 void testSignalHandler();
282 void testRecursiveSignalHandler();
283
284 private:
285 PythonQtTestSignalHandlerHelper* _helper;
286
287 };
288
289 //! helper class for signal testing
290 class PythonQtTestSignalHandlerHelper : public QObject
291 {
292 Q_OBJECT
293
294 public:
295 PythonQtTestSignalHandlerHelper(PythonQtTestSignalHandler* test) {
296 _test = test;
297 };
298
299 public slots:
300 void setPassed() { _passed = true; }
301
302 bool emitIntSignal(int a) { _passed = false; emit intSignal(a); return _passed; };
303 bool emitFloatSignal(float a) { _passed = false; emit floatSignal(a); return _passed; };
304
305 bool emitVariantSignal(const QVariant& v) { _passed = false; emit variantSignal(v); return _passed; };
306 QVariant expectedVariant() { return _v; }
307 void setExpectedVariant(const QVariant& v) { _v = v; }
308
309 bool emitComplexSignal(int a, float b, const QStringList& l, QObject* obj) { _passed = false; emit complexSignal(a,b,l,obj); return _passed; };
310
311 bool emitSignal1(int a) { _passed = false; emit signal1(a); return _passed; };
312 bool emitSignal2(const QString& s) { _passed = false; emit signal2(s); return _passed; };
313 bool emitSignal3(float a) { _passed = false; emit signal3(a); return _passed; };
314
315 signals:
316 void intSignal(int);
317 void floatSignal(float);
318 void variantSignal(const QVariant& v);
319 void complexSignal(int a, float b, const QStringList& l, QObject* obj);
320
321 void signal1(int);
322 void signal2(const QString&);
323 void signal3(float);
324
325 private:
326 bool _passed;
327 QVariant _v;
328
329 PythonQtTestSignalHandler* _test;
330 };
331
332 #endif
@@ -0,0 +1,19
1 # --------- PythonQtTest profile -------------------
2 # Last changed by $Author: florian $
3 # $Id: PythonQt.pro 35381 2006-03-16 13:05:52Z florian $
4 # $Source$
5 # --------------------------------------------------
6 TARGET = PythonQtTest
7 TEMPLATE = app
8
9 CONFIG += qtestlib
10
11 include ( ../build/common.prf )
12 include ( ../build/PythonQt.prf )
13
14 HEADERS += \
15 PythonQtTests.h
16
17 SOURCES += \
18 PythonQtTestMain.cpp \
19 PythonQtTests.cpp
General Comments 0
You need to be logged in to leave comments. Login now