diff options
Diffstat (limited to 'python/pyqt/pyuic2')
-rw-r--r-- | python/pyqt/pyuic2/COPYING | 280 | ||||
-rw-r--r-- | python/pyqt/pyuic2/domtool.cpp | 260 | ||||
-rw-r--r-- | python/pyqt/pyuic2/domtool.h | 41 | ||||
-rw-r--r-- | python/pyqt/pyuic2/globaldefs.h | 33 | ||||
-rw-r--r-- | python/pyqt/pyuic2/pyuic.pro.in | 24 | ||||
-rw-r--r-- | python/pyqt/pyuic2/pyuic.sbf | 24 | ||||
-rw-r--r-- | python/pyqt/pyuic2/uic.cpp | 1601 | ||||
-rw-r--r-- | python/pyqt/pyuic2/uic.h | 133 | ||||
-rw-r--r-- | python/pyqt/pyuic2/widgetdatabase.cpp | 640 | ||||
-rw-r--r-- | python/pyqt/pyuic2/widgetdatabase.h | 75 |
10 files changed, 0 insertions, 3111 deletions
diff --git a/python/pyqt/pyuic2/COPYING b/python/pyqt/pyuic2/COPYING deleted file mode 100644 index c7aea189..00000000 --- a/python/pyqt/pyuic2/COPYING +++ /dev/null @@ -1,280 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/python/pyqt/pyuic2/domtool.cpp b/python/pyqt/pyuic2/domtool.cpp deleted file mode 100644 index a1ffac47..00000000 --- a/python/pyqt/pyuic2/domtool.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** Copyright (C) 2000, 2001 Phil Thompson <phil@river-bank.demon.co.uk> -** -** This file is part of Qt Designer. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "domtool.h" - -#include <tqsizepolicy.h> -#include <tqpalette.h> -#include <tqcursor.h> -#include <tqrect.h> -#include <tqsize.h> -#include <tqfont.h> - - -/*! - \class DomTool domtool.h - \brief Tools for the dom - - A collection of static functions used by Resource (part of the - designer) and Uic. - -*/ - - -/*! - Returns the contents of property \a name of object \a e as - variant or the variant passed as \a defValue if the property does - not exist. - - \sa hasProperty() - */ -TQVariant DomTool::readProperty( const TQDomElement& e, const TQString& name, const TQVariant& defValue ) -{ - TQDomElement n; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString prop = n2.firstChild().toText().data(); - if ( prop == name ) - return elementToVariant( n2.nextSibling().toElement(), defValue ); - } - } - } - return defValue; -} - -/*! - Returns wheter object \a e defines property \a name or not. - - \sa readProperty() - */ -bool DomTool::hasProperty( const TQDomElement& e, const TQString& name ) -{ - TQDomElement n; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString prop = n2.firstChild().toText().data(); - if ( prop == name ) - return TRUE; - } - } - } - return FALSE; -} - -TQVariant DomTool::elementToVariant( const TQDomElement& e, const TQVariant& defValue ) -{ - TQString dummy; - return elementToVariant( e, defValue, dummy ); -} - -/*! - Interprets element \a e as variant and returns the result of the interpretation. - */ -TQVariant DomTool::elementToVariant( const TQDomElement& e, const TQVariant& defValue, TQString &comment ) -{ - TQVariant v; - if ( e.tagName() == "rect" ) { - TQDomElement n3 = e.firstChild().toElement(); - int x = 0, y = 0, w = 0, h = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "x" ) - x = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "y" ) - y = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "width" ) - w = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "height" ) - h = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = TQVariant( TQRect( x, y, w, h ) ); - } else if ( e.tagName() == "point" ) { - TQDomElement n3 = e.firstChild().toElement(); - int x = 0, y = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "x" ) - x = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "y" ) - y = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = TQVariant( TQPoint( x, y ) ); - } else if ( e.tagName() == "size" ) { - TQDomElement n3 = e.firstChild().toElement(); - int w = 0, h = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "width" ) - w = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "height" ) - h = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = TQVariant( TQSize( w, h ) ); - } else if ( e.tagName() == "color" ) { - v = TQVariant( readColor( e ) ); - } else if ( e.tagName() == "font" ) { - TQDomElement n3 = e.firstChild().toElement(); - TQFont f( defValue.toFont() ); - while ( !n3.isNull() ) { - if ( n3.tagName() == "family" ) - f.setFamily( n3.firstChild().toText().data() ); - else if ( n3.tagName() == "pointsize" ) - f.setPointSize( n3.firstChild().toText().data().toInt() ); - else if ( n3.tagName() == "bold" ) - f.setBold( n3.firstChild().toText().data().toInt() ); - else if ( n3.tagName() == "italic" ) - f.setItalic( n3.firstChild().toText().data().toInt() ); - else if ( n3.tagName() == "underline" ) - f.setUnderline( n3.firstChild().toText().data().toInt() ); - else if ( n3.tagName() == "strikeout" ) - f.setStrikeOut( n3.firstChild().toText().data().toInt() ); - n3 = n3.nextSibling().toElement(); - } - v = TQVariant( f ); - } else if ( e.tagName() == "string" ) { - v = TQVariant( e.firstChild().toText().data() ); - TQDomElement n = e; - n = n.nextSibling().toElement(); - if ( n.tagName() == "comment" ) - comment = n.firstChild().toText().data(); - } else if ( e.tagName() == "cstring" ) { - v = TQVariant( TQCString( e.firstChild().toText().data() ) ); - } else if ( e.tagName() == "number" ) { - v = TQVariant( e.firstChild().toText().data().toInt() ); - } else if ( e.tagName() == "bool" ) { - TQString t = e.firstChild().toText().data(); - v = TQVariant( t == "true" || t == "1", 0 ); - } else if ( e.tagName() == "pixmap" ) { - v = TQVariant( e.firstChild().toText().data() ); - } else if ( e.tagName() == "iconset" ) { - v = TQVariant( e.firstChild().toText().data() ); - } else if ( e.tagName() == "image" ) { - v = TQVariant( e.firstChild().toText().data() ); - } else if ( e.tagName() == "enum" ) { - v = TQVariant( e.firstChild().toText().data() ); - } else if ( e.tagName() == "set" ) { - v = TQVariant( e.firstChild().toText().data() ); - } else if ( e.tagName() == "sizepolicy" ) { - TQDomElement n3 = e.firstChild().toElement(); - TQSizePolicy sp; - while ( !n3.isNull() ) { - if ( n3.tagName() == "hsizetype" ) - sp.setHorData( (TQSizePolicy::SizeType)n3.firstChild().toText().data().toInt() ); - else if ( n3.tagName() == "vsizetype" ) - sp.setVerData( (TQSizePolicy::SizeType)n3.firstChild().toText().data().toInt() ); - n3 = n3.nextSibling().toElement(); - } - v = TQVariant( sp ); - } else if ( e.tagName() == "cursor" ) { - v = TQVariant( TQCursor( e.firstChild().toText().data().toInt() ) ); - } - - return v; -} - - -/*! Returns the color which is returned in the dom element \a e. - */ - -TQColor DomTool::readColor( const TQDomElement &e ) -{ - TQDomElement n = e.firstChild().toElement(); - int r= 0, g = 0, b = 0; - while ( !n.isNull() ) { - if ( n.tagName() == "red" ) - r = n.firstChild().toText().data().toInt(); - else if ( n.tagName() == "green" ) - g = n.firstChild().toText().data().toInt(); - else if ( n.tagName() == "blue" ) - b = n.firstChild().toText().data().toInt(); - n = n.nextSibling().toElement(); - } - - return TQColor( r, g, b ); -} - -/*! - Returns the contents of attribute \a name of object \a e as - variant or the variant passed as \a defValue if the attribute does - not exist. - - \sa hasAttribute() - */ -TQVariant DomTool::readAttribute( const TQDomElement& e, const TQString& name, const TQVariant& defValue ) -{ - TQDomElement n; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "attribute" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString prop = n2.firstChild().toText().data(); - if ( prop == name ) - return elementToVariant( n2.nextSibling().toElement(), defValue ); - } - } - } - return defValue; -} - -/*! - Returns wheter object \a e defines attribute \a name or not. - - \sa readAttribute() - */ -bool DomTool::hasAttribute( const TQDomElement& e, const TQString& name ) -{ - TQDomElement n; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "attribute" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString prop = n2.firstChild().toText().data(); - if ( prop == name ) - return TRUE; - } - } - } - return FALSE; -} diff --git a/python/pyqt/pyuic2/domtool.h b/python/pyqt/pyuic2/domtool.h deleted file mode 100644 index 9d31897b..00000000 --- a/python/pyqt/pyuic2/domtool.h +++ /dev/null @@ -1,41 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Troll Tech AS. All rights reserved. -** Copyright (C) 2000, 2001 Phil Thompson <phil@river-bank.demon.co.uk> -** -** This file is part of Qt GUI Designer. -** -** This file may be distributed under the terms of the GNU General -** Public License version 2 as published by the Free Software -** Foundation and appearing in the file COPYING included in the -** packaging of this file. If you did not get the file, send email -** to info@trolltech.com -** -** The file is provided AS IS with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#ifndef DOMTOOL_H -#define DOMTOOL_H - -#include <tqnamespace.h> -#include <tqvariant.h> -#include <tqdom.h> - - -class DomTool : public Qt -{ -public: - static TQVariant readProperty( const TQDomElement& e, const TQString& name, const TQVariant& defValue ); - static bool hasProperty( const TQDomElement& e, const TQString& name ); - static TQVariant elementToVariant( const TQDomElement& e, const TQVariant& defValue ); - static TQVariant elementToVariant( const TQDomElement& e, const TQVariant& defValue, TQString &comment ); - static TQVariant readAttribute( const TQDomElement& e, const TQString& name, const TQVariant& defValue ); - static bool hasAttribute( const TQDomElement& e, const TQString& name ); - static TQColor readColor( const TQDomElement &e ); - -}; - - -#endif // DOMTOOL_H diff --git a/python/pyqt/pyuic2/globaldefs.h b/python/pyqt/pyuic2/globaldefs.h deleted file mode 100644 index e436e5a6..00000000 --- a/python/pyqt/pyuic2/globaldefs.h +++ /dev/null @@ -1,33 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qt Designer. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef GLOBALDEFS_H -#define GLOBALDEFS_H - -#include <tqcolor.h> - -#define BOXLAYOUT_DEFAULT_MARGIN 11 -#define BOXLAYOUT_DEFAULT_SPACING 6 - -static TQColor backColor1( 226, 244, 216 ); -static TQColor backColor2( 235, 235, 235 ); -static TQColor selectedBack( 192, 192, 192 ); - -#endif diff --git a/python/pyqt/pyuic2/pyuic.pro.in b/python/pyqt/pyuic2/pyuic.pro.in deleted file mode 100644 index 8df15136..00000000 --- a/python/pyqt/pyuic2/pyuic.pro.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2000, 2001 -# Phil Thompson <phil@river-bank.demon.co.uk> -# Copyright (c) 2002, 2003 -# Riverbank Computing Limited <info@riverbankcomputing.co.uk> -# -# The project file for pyuic for Qt v2. - - -TEMPLATE = app -CONFIG = qt console warn_on release -INCLUDEPATH = @BLX_INCLUDEPATH@ $(QTDIR)/src/3rdparty/zlib -DEFINES = UIC @BLX_DEFINES@ - -DESTDIR = @PYQT_BINDIR@ -TARGET = pyuic - -HEADERS = domtool.h \ - globaldefs.h \ - uic.h \ - widgetdatabase.h - -SOURCES = domtool.cpp \ - uic.cpp \ - widgetdatabase.cpp diff --git a/python/pyqt/pyuic2/pyuic.sbf b/python/pyqt/pyuic2/pyuic.sbf deleted file mode 100644 index 1bec4ac3..00000000 --- a/python/pyqt/pyuic2/pyuic.sbf +++ /dev/null @@ -1,24 +0,0 @@ -# This is the build file for pyuic for Qt v2. -# -# Copyright (c) 2007 -# Riverbank Computing Limited <info@riverbankcomputing.co.uk> -# -# This file is part of PyQt. -# -# This copy of PyQt is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2, or (at your option) any later -# version. -# -# PyQt is supplied in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# PyQt; see the file LICENSE. If not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -target = pyuic -sources = uic.cpp widgetdatabase.cpp domtool.cpp -headers = uic.h widgetdatabase.h domtool.h globaldefs.h diff --git a/python/pyqt/pyuic2/uic.cpp b/python/pyqt/pyuic2/uic.cpp deleted file mode 100644 index 93c67f6b..00000000 --- a/python/pyqt/pyuic2/uic.cpp +++ /dev/null @@ -1,1601 +0,0 @@ -// Copyright (c) 2000 - 2001 Phil Thompson <phil@river-bank.demon.co.uk> - -/********************************************************************** -** Copyright (C) 2000 Troll Tech AS. All rights reserved. -** -** This file is part of Qt GUI Designer. -** -** This file may be distributed under the terms of the GNU General -** Public License version 2 as published by the Free Software -** Foundation and appearing in the file COPYING included in the -** packaging of this file. If you did not get the file, send email -** to info@trolltech.com -** -** The file is provided AS IS with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#include "uic.h" -#include <tqapplication.h> -#include <tqfile.h> -#include <tqfileinfo.h> -#include <stdio.h> -#include <stdlib.h> -#include <tqstringlist.h> -#include <tqstrlist.h> -#include <tqdatetime.h> -#include <widgetdatabase.h> -#include <domtool.h> -#include <globaldefs.h> -#include <tqregexp.h> -#include <zlib.h> - -static TQString mkBool( bool b ) -{ - return b? "1" : "0"; -} - -static TQString mkBool( const TQString& s ) -{ - return mkBool( s == "true" || s == "1" ); -} - -static bool toBool( const TQString& s ) -{ - return s == "true" || s.toInt() != 0; -} - - -// fixString is only used in conjunction with tr(). We need to write out the -// string in utf8 and make sure it's converted from utf8 when created. -static TQString fixString( const TQString &str ) -{ - TQString s( str ); - s.replace( TQRegExp( "\\\\" ), "\\\\" ); - s.replace( TQRegExp( "\"" ), "\\\"" ); - s.replace( TQRegExp( "\n" ), "\\n\"\n\"" ); - s.replace( TQRegExp( "\r" ), "\\r" ); - - bool onlyAscii = TRUE; - unsigned int i; - for ( i = 0; i < s.length(); i++ ) { - if ( s.at(i).unicode() >= 0x80 ) { - onlyAscii = FALSE; - break; - } - } - if ( onlyAscii ) - s = "\"" + s + "\""; - else - s = "TQString.fromUtf8(\"" + s + "\")"; - return s; -} - -static TQString mkStdSet( const TQString& prop ) -{ - return TQString( "set" ) + prop[0].upper() + prop.mid(1); -} - - -/*! - \class Uic uic.h - \brief User Interface Compiler - - The class Uic encapsulates the user interface compiler (uic). - */ - -static TQString className; - -Uic::Uic( TQTextStream &outStream, TQDomDocument doc, const TQString &trm ) - : out( outStream ), trmacro( trm ) -{ - item_used = cg_used = pal_used = 0; - - initIndent(); - - layouts << "hbox" << "vbox" << "grid"; - tags = layouts; - tags << "widget"; - - nameOfClass = getClassName( doc.firstChild().toElement() ); - - TQDomElement firstWidget = doc.firstChild().firstChild().toElement(); - while ( firstWidget.tagName() != "widget" ) - firstWidget = firstWidget.nextSibling().toElement(); - - if ( nameOfClass.isEmpty() ) - nameOfClass = getObjectName( firstWidget ); - - // This is a hack. - className = nameOfClass; - - createFormImpl( firstWidget ); -} - - -/*! Extracts a class name from \a e - */ -TQString Uic::getClassName( const TQDomElement& e ) -{ - TQDomElement n; - TQString cn; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "class" ) { - TQString s = n.firstChild().toText().data(); - int i; - while ( ( i = s.find(' ' )) != -1 ) - s[i] = '_'; - cn = s; - } else if ( n.tagName() == "pixmapfunction" ) { - pixmapLoaderFunction = n.firstChild().toText().data(); - } - } - return cn; -} - -/*! Extracts an object name from \a e. It's stored in the 'name' - property. - */ -TQString Uic::getObjectName( const TQDomElement& e ) -{ - TQDomElement n; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" && n2.firstChild().toText().data() == "name" ) { - return n2.nextSibling().toElement().firstChild().toText().data(); - } - } - } - return TQString::null; -} - -/*! Extracts an layout name from \a e. It's stored in the 'name' - property of the preceeding sibling (the first child of a QLayoutWidget). - */ -TQString Uic::getLayoutName( const TQDomElement& e ) -{ - TQDomElement p = e.parentNode().toElement(); - TQString tail = TQString::null; - - if (getClassName(p) != "QLayoutWidget") - tail = "Layout"; - - TQDomElement n; - for ( n = p.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" && n2.firstChild().toText().data() == "name" ) { - return n2.nextSibling().toElement().firstChild().toText().data() + tail; - } - } - } - return e.tagName(); -} - -TQByteArray unzipXPM( TQString data, ulong& length ) -{ - char *ba = new char[ data.length() / 2 ]; - for ( int i = 0; i < (int)data.length() / 2; ++i ) { - char h = data[ 2 * i ].latin1(); - char l = data[ 2 * i + 1 ].latin1(); - uchar r = 0; - if ( h <= '9' ) - r += h - '0'; - else - r += h - 'a' + 10; - r = r << 4; - if ( l <= '9' ) - r += l - '0'; - else - r += l - 'a' + 10; - ba[ i ] = r; - } - if ( length < data.length() * 5 ) - length = data.length() * 5; - TQByteArray baunzip( length ); - ::uncompress( (uchar*) baunzip.data(), &length, (uchar*) ba, data.length()/2 ); - return baunzip; -} - - -/*! - Creates an implementation ( cpp-file ) for the form given in \a e - - \sa createFormDecl(), createObjectImpl() - */ -void Uic::createFormImpl( const TQDomElement &e ) -{ - TQStringList::Iterator it; - TQDomElement n; - TQDomNodeList nl; - int i; - TQString objClass = getClassName( e ); - if ( objClass.isEmpty() ) - return; - TQString objName = getObjectName( e ); - - // Handle custom widgets. - for (n = e; !n.isNull(); n = n.nextSibling().toElement()) - { - if (n.tagName() != "customwidgets") - continue; - - TQDomElement n2 = n.firstChild().toElement(); - - while (!n2.isNull()) - { - if (n2.tagName() == "customwidget") - { - TQDomElement n3 = n2.firstChild().toElement(); - TQString cname, header; - - while (!n3.isNull()) - { - if (n3.tagName() == "class") - cname = n3.firstChild().toText().data(); - else if (n3.tagName() == "header") - header = n3.firstChild().toText().data(); - - n3 = n3.nextSibling().toElement(); - } - - if (cname.isEmpty()) - cname = "UnnamedCustomClass"; - - int ext = header.findRev('.'); - - if (ext >= 0) - header.truncate(ext); - - if (header.isEmpty()) - header = cname.lower(); - - out << "from " << header << " import " << cname << endl; - } - - n2 = n2.nextSibling().toElement(); - } - } - - // find out what images are required - TQStringList requiredImages; - nl = e.elementsByTagName( "pixmap" ); - for ( int j = 0; j < (int) nl.length(); j++ ) { - requiredImages += nl.item(j).firstChild().toText().data(); - } - - TQStringList images; - TQStringList xpmImages; - if ( pixmapLoaderFunction.isEmpty() ) { - // create images - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "images" ) { - nl = n.elementsByTagName( "image" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - TQDomElement tmp = nl.item(i).firstChild().toElement(); - TQString img = registerObject( tmp.firstChild().toText().data() ); - if ( !requiredImages.contains( img ) ) - continue; - tmp = tmp.nextSibling().toElement(); - TQString format = tmp.attribute("format", "PNG" ); - TQString data = tmp.firstChild().toText().data(); - - out << endl; - out << endl; - - if ( format == "XPM.GZ" ) { - xpmImages += img; - ulong length = tmp.attribute("length").toULong(); - TQByteArray baunzip = unzipXPM( data, length ); - int a = 0; - out << indent << img << "_data = [" << endl; - while ( baunzip[a] != '\"' ) - a++; - for ( ; a < (int) length; a++ ) - { - char ch; - - if ((ch = baunzip[a]) == '}') - { - out << endl << "]" << endl; - break; - } - - if (ch == '\"') - ch = '\''; - - out << ch; - } - } else { - images += img; - out << indent << img << "_data = \\" << endl; - pushIndent(); - out << indent << "'"; - int a ; - for ( a = 0; a < (int) (data.length()/2)-1; a++ ) { - out << "\\x" << TQString(data[2*a]) << TQString(data[2*a+1]); - if ( a % 12 == 11 ) - out << "' \\" << endl << indent << "'"; - } - out << "\\x" << TQString(data[2*a]) << TQString(data[2*a+1]) << "'" << endl; - popIndent(); - } - } - } - } - } - - // register the object and unify its name - objName = registerObject( objName ); - - - // constructor - - out << endl; - out << endl; - out << indent << "class " << nameOfClass << "(" << objClass << "):" << endl; - pushIndent(); - - if ( objClass == "TQDialog" || objClass == "TQWizard" ) { - out << indent << "def __init__(self,parent = None,name = None,modal = 0,fl = 0):" << endl; - pushIndent(); - out << indent << objClass << ".__init__(self,parent,name,modal,fl)" << endl; - } else if ( objClass == "TQWidget" ) { // standard QWidget - out << indent << "def __init__(self,parent = None,name = None,fl = 0):" << endl; - pushIndent(); - out << indent << objClass << ".__init__(self,parent,name,fl)" << endl; - } else { - out << indent << "def __init__(self,parent = None,name = None):" << endl; - pushIndent(); - out << indent << objClass << ".__init__(self,parent,name)" << endl; - } - - out << endl; - - // create pixmaps for all images - if ( !images.isEmpty() ) { - TQStringList::Iterator it; - for ( it = images.begin(); it != images.end(); ++it ) { - out << indent << (*it) << " = TQPixmap()" << endl; - out << indent << (*it) << ".loadFromData(" << (*it) << "_data,'PNG')" << endl; - } - - out << endl; - } - // create pixmaps for all images - if ( !xpmImages.isEmpty() ) { - for ( it = xpmImages.begin(); it != xpmImages.end(); ++it ) { - out << indent << (*it) << " = TQPixmap(" << (*it) << "_data)" << endl; - } - - out << endl; - } - - - // set the properties - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - bool stdset = toBool( n.attribute( "stdset" ) ); - TQDomElement n2 = n.firstChild().toElement(); - - if ( n2.tagName() == "name" ) { - TQString prop = n2.firstChild().toText().data(); - TQString value = setObjectProperty( objClass, TQString::null, prop, n2.nextSibling().toElement(), stdset ); - - if ( value.isEmpty() ) - continue; - - if ( prop == "name" ) { - out << indent << "if name == None:" << endl; - pushIndent(); - } - - out << indent; - - if ( prop == "geometry" && n2.nextSibling().toElement().tagName() == "rect") { - TQDomElement n3 = n2.nextSibling().toElement().firstChild().toElement(); - int w = 0, h = 0; - - while ( !n3.isNull() ) { - if ( n3.tagName() == "width" ) - w = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "height" ) - h = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - - out << "self.resize(" << w << "," << h << ")" << endl; - } else { - if ( stdset ) - out << "self." << mkStdSet(prop) << "(" << value << ")" << endl; - else - out << "self.setProperty('" << prop << "',TQVariant(" << value << "))" << endl; - } - - if (prop == "name") { - popIndent(); - out << endl; - } - } - } - } - - - // create all children, some forms have special requirements - - if ( objClass == "TQWizard" ) { - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( tags.contains( n.tagName() ) ) { - TQString page = createObjectImpl( n, objClass, "self" ); - TQString label = DomTool::readAttribute( n, "title", "" ).toString(); - out << indent << "self.addPage(" << page << ","<< trmacro << "(" << fixString( label ) << "))" << endl; - TQVariant def( FALSE, 0 ); - if ( DomTool::hasAttribute( n, "backEnabled" ) ) - out << indent << "self.setBackEnabled(" << page << "," << mkBool( DomTool::readAttribute( n, "backEnabled", def).toBool() ) << ")" << endl; - if ( DomTool::hasAttribute( n, "nextEnabled" ) ) - out << indent << "self.setNextEnabled(" << page << "," << mkBool( DomTool::readAttribute( n, "nextEnabled", def).toBool() ) << ")" << endl; - if ( DomTool::hasAttribute( n, "finishEnabled" ) ) - out << indent << "self.setFinishEnabled(" << page << "," << mkBool( DomTool::readAttribute( n, "finishEnabled", def).toBool() ) << ")" << endl; - if ( DomTool::hasAttribute( n, "helpEnabled" ) ) - out << indent << "self.setHelpEnabled(" << page << "," << mkBool( DomTool::readAttribute( n, "helpEnabled", def).toBool() ) << ")" << endl; - if ( DomTool::hasAttribute( n, "finish" ) ) - out << indent << "self.setFinish(" << page << "," << mkBool( DomTool::readAttribute( n, "finish", def).toBool() ) << ")" << endl; - } - } - } else { // standard widgets - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( tags.contains( n.tagName() ) ) - createObjectImpl( n, objName, "self" ); - } - } - - // Get the list of any user defined slots. - - TQStringList userSlots; - - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "connections" ) { - for ( TQDomElement n2 = n.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) { - if ( n2.tagName() == "slot" ) { - userSlots += n2.firstChild().toText().data(); - } - } - } - } - - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "connections" ) { - // setup signals and slots connections - out << endl; - nl = n.elementsByTagName( "connection" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - TQString sender, receiver, signal, slot; - for ( TQDomElement n2 = nl.item(i).firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) { - if ( n2.tagName() == "sender" ) - sender = n2.firstChild().toText().data(); - else if ( n2.tagName() == "receiver" ) - receiver = n2.firstChild().toText().data(); - else if ( n2.tagName() == "signal" ) - signal = n2.firstChild().toText().data(); - else if ( n2.tagName() == "slot" ) - slot = n2.firstChild().toText().data(); - } - if ( sender.isEmpty() || receiver.isEmpty() || signal.isEmpty() || slot.isEmpty() ) - continue; - - sender = registeredName( sender ); - receiver = registeredName( receiver ); - - // translate formwindow name to "self" - if ( sender == objName ) - sender = "self"; - else - sender = "self." + sender; - if ( receiver == objName ) - receiver = "self"; - else - receiver = "self." + receiver; - - // Note that we never use the TQT_SLOT() macro in case we have - // custom widgets implemented in Python. - out << indent << "self.connect(" << sender - << ",TQT_SIGNAL('" << signal << "'),self." - << slot.left(slot.find('(')) << ")" << endl; - } - } else if ( n.tagName() == "tabstops" ) { - // setup tab order - out << endl; - TQString lastName; - TQDomElement n2 = n.firstChild().toElement(); - while ( !n2.isNull() ) { - if ( n2.tagName() == "tabstop" ) { - TQString name = n2.firstChild().toText().data(); - name = registeredName( name ); - if ( !lastName.isEmpty() ) - out << indent << "self.setTabOrder(self." << lastName << ",self." << name << ")" << endl; - lastName = name; - } - n2 = n2.nextSibling().toElement(); - } - } - } - - - // buddies - bool firstBuddy = TRUE; - for ( TQValueList<Buddy>::Iterator buddy = buddies.begin(); buddy != buddies.end(); ++buddy ) { - if ( isObjectRegistered( (*buddy).buddy ) ) { - if ( firstBuddy ) { - out << endl; - } - out << indent << "self." << (*buddy).key << ".setBuddy(self." << registeredName( (*buddy).buddy ) << ")" << endl; - firstBuddy = FALSE; - } - - } - - // end of constructor - popIndent(); - - // handle application font changes if required - nl = e.elementsByTagName( "widget" ); - bool needEventHandler = FALSE; - for ( i = 0; i < (int) nl.length(); i++ ) { - if ( DomTool::hasProperty( nl.item(i).toElement() , "font" ) ) { - needEventHandler = TRUE; - break; - } - } - if ( needEventHandler ) { - out << endl; - out << indent << "def event(self,ev):" << endl; - pushIndent(); - out << indent << "ret = " << objClass << ".event(self,ev)" << endl; - out << endl; - out << indent << "if ev.type() == TQEvent.ApplicationFontChange:" << endl; - pushIndent(); - - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - if ( DomTool::hasProperty( n, "font" ) ) - createExclusiveProperty( n, "font" ); - } - - out << endl; - popIndent(); - out << indent << "return ret" << endl; - popIndent(); - } - - - // Generate user defined slot hooks. - - for (it = userSlots.begin(); it != userSlots.end(); ++it) { - int astart = (*it).find('('); - - out << endl; - out << indent << "def " << (*it).left(astart) << "(self"; - - // We don't reproduce the argument names (if any) because we would have - // to remove the types - too complicated for the moment, so we just - // count them and give them names based on their position. - - TQString args = (*it).mid(astart + 1,(*it).find(')') - astart - 1).stripWhiteSpace(); - - if (!args.isEmpty()) { - int nrargs = args.contains(',') + 1; - - for (int i = 0; i < nrargs; ++i) - out << ",a" << i; - } - - out << "):" << endl; - pushIndent(); - out << indent << "print '" << nameOfClass << "." << *it << ": not implemented yet'" << endl; - popIndent(); - } - - popIndent(); -} - - -/*! - Creates an implementation for the object given in \a e. - - Traverses recursively over all children. - - Returns the name of the generated child object. - - \sa createObjectDecl() - */ -TQString Uic::createObjectImpl( const TQDomElement &e, const TQString& parentClass, const TQString& parent, const TQString& layout ) -{ - - TQDomElement n; - TQString objClass, objName, fullObjName; - - if ( layouts.contains( e.tagName() ) ) - return createLayoutImpl( e, parentClass, parent, layout ); - - objClass = getClassName( e ); - if ( objClass.isEmpty() ) - return objName; - objName = getObjectName( e ); - - TQString definedName = objName; - bool isTmpObject = objName.isEmpty() || objClass == "QLayoutWidget"; - if ( isTmpObject ) { - if ( objClass[0] == 'Q' ) - objName = objClass.mid(1); - else - objName = objClass.lower(); - } - - bool isLine = objClass == "Line"; - if ( isLine ) - objClass = "TQFrame"; - - out << endl; - if ( objClass == "QLayoutWidget" ) { - if ( layout.isEmpty() ) { - // register the object and unify its name - objName = registerObject( objName ); - out << indent << objName << " = TQWidget(" << parent << ",'" << definedName << "')" << endl; - } else { - // the layout widget is not necessary, hide it by creating its child in the parent - TQString result; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if (tags.contains( n.tagName() ) ) - result = createObjectImpl( n, parentClass, parent, layout ); - } - return result; - } - - // Layouts don't go into the class instance dictionary. - fullObjName = objName; - } else { - // register the object and unify its name - objName = registerObject( objName ); - - // Temporary objects don't go into the class instance dictionary. - fullObjName = isTmpObject ? objName : "self." + objName; - - out << indent << fullObjName << " = " << createObjectInstance( objClass, parent, objName ) << endl; - } - - lastItem = "None"; - // set the properties and insert items - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - bool stdset = toBool( n.attribute( "stdset" ) ); - TQDomElement n2 = n.firstChild().toElement(); - - if ( n2.tagName() == "name" ) { - TQString prop = n2.firstChild().toText().data(); - TQString value = setObjectProperty( objClass, objName, prop, n2.nextSibling().toElement(), stdset ); - - if ( value.isEmpty() ) - continue; - if ( prop == "name" ) - continue; - if ( prop == "buddy" && value[0] == '\'' && value[(int)value.length()-1] == '\'' ) { - buddies << Buddy( objName, value.mid(1, value.length() - 2 ) ); - continue; - } - if ( isLine && prop == "orientation" ) { - prop = "frameStyle"; - if ( value.right(10) == "Horizontal" ) - value = "TQFrame.HLine | TQFrame.Sunken"; - else - value = "TQFrame.VLine | TQFrame.Sunken"; - } - if ( prop == "buttonGroupId" ) { - if ( parentClass == "TQButtonGroup" ) - out << indent << parent << ".insert(" << fullObjName << "," << value << ")" << endl; - continue; - } - if ( prop == "geometry") { - out << indent << fullObjName << ".setGeometry(" << value << ")" << endl; - } else { - if ( stdset ) - out << indent << fullObjName << "." << mkStdSet(prop) << "(" << value << ")" << endl; - else - out << indent << fullObjName << ".setProperty('" << prop << "',TQVariant(" << value << "))" << endl; - } - - } - } else if ( n.tagName() == "item" ) { - if ( objClass.mid(1) == "ListBox" ) { - TQString s = createListBoxItemImpl( n, fullObjName ); - if ( !s.isEmpty() ) - out << indent << s << endl; - } else if ( objClass.mid(1) == "ComboBox" ) { - TQString s = createListBoxItemImpl( n, fullObjName ); - if ( !s.isEmpty() ) - out << indent << s << endl; - } else if ( objClass.mid(1) == "IconView" ) { - TQString s = createIconViewItemImpl( n, fullObjName ); - if ( !s.isEmpty() ) - out << indent << s << endl; - } else if ( objClass.mid(1) == "ListView" ) { - TQString s = createListViewItemImpl( n, fullObjName, TQString::null ); - if ( !s.isEmpty() ) - out << s << endl; - } - } else if ( n.tagName() == "column" ) { - if ( objClass.mid(1) == "ListView" ) { - TQString s = createListViewColumnImpl( n, fullObjName ); - if ( !s.isEmpty() ) - out << s; - } - } - } - - // create all children, some widgets have special requirements - - if ( objClass == "TQTabWidget" ) { - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( tags.contains( n.tagName() ) ) { - TQString page = createObjectImpl( n, objClass, fullObjName ); - TQString label = DomTool::readAttribute( n, "title", "" ).toString(); - out << indent << fullObjName << ".insertTab(" << page << "," << trmacro << "(" << fixString( label ) << "))" << endl; - } - } - } else { // standard widgets - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( tags.contains( n.tagName() ) ) - createObjectImpl( n, objClass, fullObjName ); - } - } - - return fullObjName; -} - -/*! - Creates implementation of an listbox item tag. -*/ - -TQString Uic::createListBoxItemImpl( const TQDomElement &e, const TQString &parent ) -{ - TQDomElement n = e.firstChild().toElement(); - TQString txt; - TQString pix; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString attrib = n2.firstChild().toText().data(); - TQVariant v = DomTool::elementToVariant( n2.nextSibling().toElement(), TQVariant() ); - if ( attrib == "text" ) - txt = v.toString(); - else if ( attrib == "pixmap" ) { - pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "(" ); - pix.append( ")" ); - } - } - } - } - n = n.nextSibling().toElement(); - } - - return pix.isEmpty() ? - parent + ".insertItem(" + trmacro + "(" + fixString( txt ) + "))": - parent + ".insertItem(" + pix + "," + trmacro + "(" + fixString( txt ) + "))"; -} - -/*! - Creates implementation of an iconview item tag. -*/ - -TQString Uic::createIconViewItemImpl( const TQDomElement &e, const TQString &parent ) -{ - TQDomElement n = e.firstChild().toElement(); - TQString txt; - TQString pix; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString attrib = n2.firstChild().toText().data(); - TQVariant v = DomTool::elementToVariant( n2.nextSibling().toElement(), TQVariant() ); - if ( attrib == "text" ) - txt = v.toString(); - else if ( attrib == "pixmap" ) { - pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "( " ); - pix.append( " )" ); - } - } - } - } - n = n.nextSibling().toElement(); - } - - if ( pix.isEmpty() ) - return "TQIconViewItem(" + parent + "," + trmacro + "(" + fixString( txt ) + "))"; - return "TQIconViewItem(" + parent + "," + trmacro + "(" + fixString( txt ) + ")," + pix + ")"; - -} - -/*! - Creates implementation of an listview item tag. -*/ - -TQString Uic::createListViewItemImpl( const TQDomElement &e, const TQString &parent, - const TQString &parentItem ) -{ - TQString s; - - TQDomElement n = e.firstChild().toElement(); - - bool hasChildren = e.elementsByTagName( "item" ).count() > 0; - TQString item; - - if ( hasChildren ) { - item = registerObject( "item" ); - s = indent + item + " = "; - } else { - item = "item"; - if ( item_used ) - s = indent + item + " = "; - else - s = indent + item + " = "; - item_used = TRUE; - } - - if ( !parentItem.isEmpty() ) - s += "TQListViewItem(" + parentItem + "," + lastItem + ")\n"; - else - s += "TQListViewItem(" + parent + "," + lastItem + ")\n"; - - TQStringList textes; - TQStringList pixmaps; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString attrib = n2.firstChild().toText().data(); - TQVariant v = DomTool::elementToVariant( n2.nextSibling().toElement(), TQVariant() ); - if ( attrib == "text" ) - textes << v.toString(); - else if ( attrib == "pixmap" ) { - TQString pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "( " ); - pix.append( " )" ); - } - pixmaps << pix; - } - } - } else if ( n.tagName() == "item" ) { - s += indent + item + ".setOpen(1)\n"; - s += createListViewItemImpl( n, parent, item ); - } - n = n.nextSibling().toElement(); - } - - for ( int i = 0; i < (int)textes.count(); ++i ) { - if ( !textes[ i ].isEmpty() ) - s += indent + item + ".setText(" + TQString::number( i ) + "," + trmacro + "(" + fixString( textes[ i ] ) + "))\n"; - if ( !pixmaps[ i ].isEmpty() ) - s += indent + item + ".setPixmap(" + TQString::number( i ) + "," + pixmaps[ i ] + ")\n"; - } - - lastItem = item; - return s; -} - -/*! - Creates implementation of an listview column tag. -*/ - -TQString Uic::createListViewColumnImpl( const TQDomElement &e, const TQString &parent ) -{ - TQDomElement n = e.firstChild().toElement(); - TQString txt; - TQString pix; - bool clickable = FALSE, resizeable = FALSE; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString attrib = n2.firstChild().toText().data(); - TQVariant v = DomTool::elementToVariant( n2.nextSibling().toElement(), TQVariant() ); - if ( attrib == "text" ) - txt = v.toString(); - else if ( attrib == "pixmap" ) { - pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "( " ); - pix.append( " )" ); - } - } else if ( attrib == "clickable" ) - clickable = v.toBool(); - else if ( attrib == "resizeable" ) - resizeable = v.toBool(); - } - } - n = n.nextSibling().toElement(); - } - - TQString s; - s = indent + parent + ".addColumn(" + trmacro + "(" + fixString( txt ) + "))\n"; - if ( !pix.isEmpty() ) - s += indent + parent + ".header().setLabel(" + parent + ".header().count() - 1," + pix + "," + trmacro + "(" + fixString( txt ) + "))\n"; - if ( !clickable ) - s += indent + parent + ".header().setClickEnabled(0," + parent + ".header().count() - 1)\n"; - if ( !resizeable ) - s += indent + parent + ".header().setResizeEnabled(0," + parent + ".header().count() - 1)\n"; - - return s; -} - -/*! - Creates the implementation of a layout tag. Called from createObjectImpl(). - */ -TQString Uic::createLayoutImpl( const TQDomElement &e, const TQString& parentClass, const TQString& parent, const TQString& layout ) -{ - TQDomElement n; - TQString objClass, objName; - objClass = e.tagName(); - - TQString qlayout = "TQVBoxLayout"; - if ( objClass == "hbox" ) - qlayout = "TQHBoxLayout"; - else if ( objClass == "grid" ) - qlayout = "TQGridLayout"; - - bool isGrid = e.tagName() == "grid" ; - objName = registerObject( getLayoutName( e ) ); - layoutObjects += objName; - int margin = DomTool::readProperty( e, "margin", BOXLAYOUT_DEFAULT_MARGIN ).toInt(); - int spacing = DomTool::readProperty( e, "spacing", BOXLAYOUT_DEFAULT_SPACING ).toInt(); - - if ( (parentClass == "TQGroupBox" || parentClass == "TQButtonGroup") && layout.isEmpty() ) { - // special case for group box - out << indent << parent << ".setColumnLayout(0,Qt.Vertical)" << endl; - out << indent << parent << ".layout().setSpacing(0)" << endl; - out << indent << parent << ".layout().setMargin(0)" << endl; - out << indent << objName << " = " << qlayout << "(" << parent << ".layout())" << endl; - out << indent << objName << ".setAlignment(Qt.AlignTop)" << endl; - } else { - if ( layout.isEmpty() ) - out << indent << objName << " = " << qlayout << "(" << parent << ")" << endl; - else - out << indent << objName << " = " << qlayout << "()" << endl; - } - - out << indent << objName << ".setSpacing(" << spacing << ")" << endl; - out << indent << objName << ".setMargin(" << margin << ")" << endl; - - if ( !isGrid ) { - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "spacer" ) { - TQString child = createSpacerImpl( n, parentClass, parent, objName ); - out << indent << objName << ".addItem(" << child << ")" << endl; - } else if ( tags.contains( n.tagName() ) ) { - TQString child = createObjectImpl( n, parentClass, parent, objName ); - if ( isLayout( child ) ) - out << indent << objName << ".addLayout(" << child << ")" << endl; - else - out << indent << objName << ".addWidget(" << child << ")" << endl; - } - } - } else { - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - TQDomElement ae = n; - int row = ae.attribute( "row" ).toInt(); - int col = ae.attribute( "column" ).toInt(); - int rowspan = ae.attribute( "rowspan" ).toInt(); - int colspan = ae.attribute( "colspan" ).toInt(); - if ( rowspan < 1 ) - rowspan = 1; - if ( colspan < 1 ) - colspan = 1; - if ( n.tagName() == "spacer" ) { - TQString child = createSpacerImpl( n, parentClass, parent, objName ); - if ( rowspan * colspan != 1 ) - out << indent << objName << ".addMultiCell(" << child << "," - << row << "," << row + rowspan - 1 << "," << col << "," - << col + colspan - 1 << ")" << endl; - else - out << indent << objName << ".addItem(" << child << "," - << row << "," << col << ")" << endl; - } else if ( tags.contains( n.tagName() ) ) { - TQString child = createObjectImpl( n, parentClass, parent, objName ); - out << endl; - TQString o = "Widget"; - if ( isLayout( child ) ) - o = "Layout"; - if ( rowspan * colspan != 1 ) - out << indent << objName << ".addMultiCell" << o << "(" << child << "," - << row << "," << row + rowspan - 1 << "," << col << "," << col + colspan - 1 << ")" << endl; - else - out << indent << objName << ".add" << o << "(" << child << "," - << row << "," << col << ")" << endl; - } - } - } - - return objName; -} - - - -TQString Uic::createSpacerImpl( const TQDomElement &e, const TQString& /*parentClass*/, const TQString& /*parent*/, const TQString& /*layout*/) -{ - TQDomElement n; - TQString objClass, objName; - objClass = e.tagName(); - objName = registerObject( "spacer" ); - - TQSize size = DomTool::readProperty( e, "sizeHint", TQSize(0,0) ).toSize(); - TQString sizeType = DomTool::readProperty( e, "sizeType", "Expanding" ).toString(); - bool isVspacer = DomTool::readProperty( e, "orientation", "Horizontal" ) == "Vertical"; - - if ( sizeType != "Expanding" && sizeType != "MinimumExpanding" && - DomTool::hasProperty( e, "geometry" ) ) { // compatibility Qt 2.2 - TQRect geom = DomTool::readProperty( e, "geometry", TQRect(0,0,0,0) ).toRect(); - size = geom.size(); - } - - if ( isVspacer ) - out << indent << objName << " = TQSpacerItem(" - << size.width() << "," << size.height() - << ",TQSizePolicy.Minimum,TQSizePolicy." << sizeType << ")" << endl; - else - out << indent << objName << " = TQSpacerItem(" - << size.width() << "," << size.height() - << ",TQSizePolicy." << sizeType << ",TQSizePolicy.Minimum)" << endl; - - return objName; -} - -/*! - Creates a set-call for property \a exclusiveProp of the object - given in \a e. - - If the object does not have this property, the function does nothing. - - Exclusive properties are used to generate the implementation of - application font or palette change handlers in createFormImpl(). - - */ -void Uic::createExclusiveProperty( const TQDomElement & e, const TQString& exclusiveProp ) -{ - TQDomElement n; - TQString objClass = getClassName( e ); - if ( objClass.isEmpty() ) - return; - TQString objName = getObjectName( e ); - if ( objClass.isEmpty() ) - return; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - bool stdset = toBool( n.attribute( "stdset" ) ); - TQDomElement n2 = n.firstChild().toElement(); - if ( n2.tagName() == "name" ) { - TQString prop = n2.firstChild().toText().data(); - if ( prop != exclusiveProp ) - continue; - TQString value = setObjectProperty( objClass, objName, prop, n2.nextSibling().toElement(), stdset ); - if ( value.isEmpty() ) - continue; - out << indent << objName << ".setProperty('" << prop << "',TQVariant(" << value << "))" << endl; - } - } - } - -} - - -const char* const ColorRole[] = { - "Foreground", "Button", "Light", "Midlight", "Dark", "Mid", - "Text", "BrightText", "ButtonText", "Base", "Background", "Shadow", - "Highlight", "HighlightedText", 0 -}; - - -/*! - Attention: this function has to be in sync with Resource::setWidgetProperty(). If you change one, change both. - */ -TQString Uic::setObjectProperty( const TQString& objClass, const TQString& obj, const TQString &prop, const TQDomElement &e, bool stdset ) -{ - TQString v; - if ( e.tagName() == "rect" ) { - TQDomElement n3 = e.firstChild().toElement(); - int x = 0, y = 0, w = 0, h = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "x" ) - x = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "y" ) - y = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "width" ) - w = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "height" ) - h = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = "TQRect(%1,%2,%3,%4)"; - v = v.arg(x).arg(y).arg(w).arg(h); - - } else if ( e.tagName() == "point" ) { - TQDomElement n3 = e.firstChild().toElement(); - int x = 0, y = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "x" ) - x = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "y" ) - y = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = "TQPoint(%1,%2)"; - v = v.arg(x).arg(y); - } else if ( e.tagName() == "size" ) { - TQDomElement n3 = e.firstChild().toElement(); - int w = 0, h = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "width" ) - w = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "height" ) - h = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = "TQSize(%1,%2)"; - v = v.arg(w).arg(h); - } else if ( e.tagName() == "color" ) { - TQDomElement n3 = e.firstChild().toElement(); - int r= 0, g = 0, b = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "red" ) - r = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "green" ) - g = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "blue" ) - b = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = "TQColor(%1,%2,%3)"; - v = v.arg(r).arg(g).arg(b); - } else if ( e.tagName() == "font" ) { - TQDomElement n3 = e.firstChild().toElement(); - TQString fontname = "f"; - if ( !obj.isEmpty() ) { - fontname = obj + "_font"; - out << indent << fontname << " = TQFont(self." << obj << ".font())" << endl; - } else { - out << indent << fontname << " = TQFont(self.font())" << endl; - } - while ( !n3.isNull() ) { - if ( n3.tagName() == "family" ) - out << indent << fontname << ".setFamily('" << n3.firstChild().toText().data() << "')" << endl; - else if ( n3.tagName() == "pointsize" ) - out << indent << fontname << ".setPointSize(" << n3.firstChild().toText().data() << ")" << endl; - else if ( n3.tagName() == "bold" ) - out << indent << fontname << ".setBold(" << mkBool( n3.firstChild().toText().data() ) << ")" << endl; - else if ( n3.tagName() == "italic" ) - out << indent << fontname << ".setItalic(" << mkBool( n3.firstChild().toText().data() ) << ")" << endl; - else if ( n3.tagName() == "underline" ) - out << indent << fontname << ".setUnderline(" << mkBool( n3.firstChild().toText().data() ) << ")" << endl; - else if ( n3.tagName() == "strikeout" ) - out << indent << fontname << ".setStrikeOut(" << mkBool( n3.firstChild().toText().data() ) << ")" << endl; - n3 = n3.nextSibling().toElement(); - } - - if ( prop == "font" ) { - if ( !obj.isEmpty() ) - out << indent << "self." << obj << ".setFont(" << fontname << ")" << endl; - else - out << indent << "self.setFont(" << fontname << ")" << endl; - } else { - v = fontname; - } - } else if ( e.tagName() == "string" ) { - if ( prop == "toolTip" ) { - if ( !obj.isEmpty() ) - out << indent << "TQToolTip.add(self." << obj << "," + trmacro + "(" << fixString( e.firstChild().toText().data() ) << "))" << endl; - else - out << indent << "TQToolTip.add(self," + trmacro + "(" << fixString( e.firstChild().toText().data() ) << "))" << endl; - } else if ( prop == "whatsThis" ) { - if ( !obj.isEmpty() ) - out << indent << "TQWhatsThis.add(self." << obj << "," << trmacro << "(" << fixString( e.firstChild().toText().data() ) << "))" << endl; - else - out << indent << "TQWhatsThis.add(self," << trmacro << "(" << fixString( e.firstChild().toText().data() ) << "))" << endl; - } else { - v = trmacro + "(%1)"; - v = v.arg( fixString( e.firstChild().toText().data() ) ); - } - } else if ( e.tagName() == "cstring" ) { - v = "'%1'"; - v = v.arg( e.firstChild().toText().data() ); - } else if ( e.tagName() == "number" ) { - v = "%1"; - v = v.arg( e.firstChild().toText().data() ); - } else if ( e.tagName() == "bool" ) { - if ( stdset ) - v = "%1"; - else - v = "%1,0"; - v = v.arg( mkBool( e.firstChild().toText().data() ) ); - } else if ( e.tagName() == "pixmap" ) { - v = e.firstChild().toText().data(); - if ( !pixmapLoaderFunction.isEmpty() ) { - v.prepend( pixmapLoaderFunction + "( " ); - v.append( " )" ); - } - } else if ( e.tagName() == "iconset" ) { - v = "TQIconSet(%1)"; - v = v.arg( e.firstChild().toText().data() ); - } else if ( e.tagName() == "image" ) { - v = e.firstChild().toText().data() + ".convertToImage()"; - } else if ( e.tagName() == "enum" ) { - v = "%1.%2"; - TQString oc = objClass; - TQString ev = e.firstChild().toText().data(); - if ( oc == "TQListView" && ev == "Manual" ) // #### workaround, rename TQListView::Manual of WithMode enum in 3.0 - oc = "TQScrollView"; - v = v.arg( oc ).arg( ev ); - } else if ( e.tagName() == "set" ) { - TQString keys( e.firstChild().toText().data() ); - TQStringList lst = TQStringList::split( '|', keys ); - v = ""; - for ( TQStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { - v += objClass + "." + *it; - if ( it != lst.fromLast() ) - v += " | "; - } - } else if ( e.tagName() == "sizepolicy" ) { - TQDomElement n3 = e.firstChild().toElement(); - TQSizePolicy sp; - while ( !n3.isNull() ) { - if ( n3.tagName() == "hsizetype" ) - sp.setHorData( (TQSizePolicy::SizeType)n3.firstChild().toText().data().toInt() ); - else if ( n3.tagName() == "vsizetype" ) - sp.setVerData( (TQSizePolicy::SizeType)n3.firstChild().toText().data().toInt() ); - n3 = n3.nextSibling().toElement(); - } - TQString tmp; - if ( !obj.isEmpty() ) - tmp = "self." + obj; - else - tmp = "self"; - v = "TQSizePolicy(%1,%2," + tmp + ".sizePolicy().hasHeightForWidth())"; - v = v.arg( (int)sp.horData() ).arg( (int)sp.verData() ); - } else if ( e.tagName() == "palette" ) { - TQPalette pal; - bool no_pixmaps = e.elementsByTagName( "pixmap" ).count() == 0; - TQDomElement n; - if ( no_pixmaps ) { - n = e.firstChild().toElement(); - while ( !n.isNull() ) { - TQColorGroup cg; - if ( n.tagName() == "active" ) { - cg = loadColorGroup( n ); - pal.setActive( cg ); - } else if ( n.tagName() == "inactive" ) { - cg = loadColorGroup( n ); - pal.setInactive( cg ); - } else if ( n.tagName() == "disabled" ) { - cg = loadColorGroup( n ); - pal.setDisabled( cg ); - } - n = n.nextSibling().toElement(); - } - } - if ( no_pixmaps && pal == TQPalette( pal.active().button(), pal.active().background() ) ) { - v = "TQPalette(TQColor(%1,%2,%3),TQColor(%1,%2,%3))"; - v = v.arg( pal.active().button().red() ).arg( pal.active().button().green() ).arg( pal.active().button().blue() ); - v = v.arg( pal.active().background().red() ).arg( pal.active().background().green() ).arg( pal.active().background().blue() ); - } else { - TQString palette = "pal"; - if ( !pal_used ) { - out << indent << palette << " = TQPalette()" << endl; - pal_used = TRUE; - } - TQString cg = "cg"; - if ( !cg_used ) { - out << indent << cg << " = TQColorGroup()" << endl; - cg_used = TRUE; - } - n = e.firstChild().toElement(); - while ( !n.isNull() && n.tagName() != "active") - n = n.nextSibling().toElement(); - createColorGroupImpl( cg, n ); - out << indent << palette << ".setActive(" << cg << ")" << endl; - - n = e.firstChild().toElement(); - while ( !n.isNull() && n.tagName() != "inactive") - n = n.nextSibling().toElement(); - createColorGroupImpl( cg, n ); - out << indent << palette << ".setInactive(" << cg << ")" << endl; - - n = e.firstChild().toElement(); - while ( !n.isNull() && n.tagName() != "disabled") - n = n.nextSibling().toElement(); - createColorGroupImpl( cg, n ); - out << indent << palette << ".setDisabled(" << cg << ")" << endl; - v = palette; - } - } else if ( e.tagName() == "cursor" ) { - v = "TQCursor(%1)"; - v = v.arg( e.firstChild().toText().data() ); - } - return v; -} - - - -/*! - Creates a colorgroup with name \a name from the color group \a cg - */ -void Uic::createColorGroupImpl( const TQString& name, const TQDomElement& e ) -{ - TQColorGroup cg; - int r = -1; - TQDomElement n = e.firstChild().toElement(); - TQString color; - while ( !n.isNull() ) { - if ( n.tagName() == "color" ) { - r++; - TQColor col = DomTool::readColor( n ); - color = "TQColor(%1,%2,%3)"; - color = color.arg( col.red() ).arg( col.green() ).arg( col.blue() ); - if ( col == white ) - color = "Qt.white"; - else if ( col == black ) - color = "Qt.black"; - if ( n.nextSibling().toElement().tagName() != "pixmap" ) { - out << indent << name << ".setColor(TQColorGroup." << ColorRole[r] << "," << color << ")" << endl; - } - } else if ( n.tagName() == "pixmap" ) { - TQString pixmap = n.firstChild().toText().data(); - if ( !pixmapLoaderFunction.isEmpty() ) { - pixmap.prepend( pixmapLoaderFunction + "(" ); - pixmap.append( ")" ); - } - out << indent << name << ".setBrush(TQColorGroup." - << ColorRole[r] << ",TQBrush(" << color << "," << pixmap << "))" << endl; - } - n = n.nextSibling().toElement(); - } -} - -/*! - Auxiliary function to load a color group. The colorgroup must not - contain pixmaps. - */ -TQColorGroup Uic::loadColorGroup( const TQDomElement &e ) -{ - TQColorGroup cg; - int r = -1; - TQDomElement n = e.firstChild().toElement(); - TQColor col; - while ( !n.isNull() ) { - if ( n.tagName() == "color" ) { - r++; - cg.setColor( (TQColorGroup::ColorRole)r, (col = DomTool::readColor( n ) ) ); - } - n = n.nextSibling().toElement(); - } - return cg; -} - - - -/*! - Registers an object with name \a name. - - The returned name is a valid variable identifier, as similar to \a - name as possible and guaranteed to be unique within the form. - - \sa registeredName(), isObjectRegistered() - */ -TQString Uic::registerObject( const TQString& name ) -{ - if ( objectNames.isEmpty() ) { - // some temporary variables we need - objectNames += "img"; - objectNames += "item"; - objectNames += "cg"; - objectNames += "pal"; - } - - TQString result = name; - int i; - while ( ( i = result.find(' ' )) != -1 ) { - result[i] = '_'; - } - - if ( objectNames.contains( result ) ) { - int i = 2; - while ( objectNames.contains( result + "_" + TQString::number(i) ) ) - i++; - result += "_"; - result += TQString::number(i); - } - objectNames += result; - objectMapper.insert( name, result ); - return result; -} - -/*! - Returns the registered name for the original name \a name - or \a name if \a name wasn't registered. - - \sa registerObject(), isObjectRegistered() - */ -TQString Uic::registeredName( const TQString& name ) -{ - if ( !objectMapper.contains( name ) ) - return name; - return objectMapper[name]; -} - -/*! - Returns whether the object \a name was registered yet or not. - */ -bool Uic::isObjectRegistered( const TQString& name ) -{ - return objectMapper.contains( name ); -} - - -/*! - Unifies the entries in stringlist \a list. Should really be a TQStringList feature. - */ -TQStringList Uic::unique( const TQStringList& list ) -{ - TQStringList result; - if (list.isEmpty() ) - return result; - TQStringList l = list; - l.sort(); - result += l.first(); - for ( TQStringList::Iterator it = l.begin(); it != l.end(); ++it ) { - if ( *it != result.last() ) - result += *it; - } - return result; -} - - - -/*! - Creates an instance of class \a objClass, with parent \a parent and name \a objName - */ -TQString Uic::createObjectInstance( const TQString& objClass, const TQString& parent, const TQString& objName ) -{ - - if ( objClass.mid(1) == "ComboBox" ) { - return objClass + "(0," + parent + ",'" + objName + "')"; - } - return objClass + "(" + parent + ",'" + objName + "')"; -} - -bool Uic::isLayout( const TQString& name ) const -{ - return layoutObjects.contains( name ); -} - - -#if defined(BLACKADDER) -#include "ba.h" - -int BA::compilePython(const TQString &fileName,const TQString &outputFile, - const TQString &trmacro,bool execCode) -{ -#else -int main( int argc, char * argv[] ) -{ - const char *error = 0; - TQString fileName; - TQString outputFile; - TQString trmacro; - bool execCode = FALSE; - - for ( int n = 1; n < argc && error == 0; n++ ) { - TQCString arg = argv[n]; - if ( arg[0] == '-' ) { // option - TQCString opt = &arg[1]; - if ( opt[0] == 'o' ) { // output redirection - if ( opt[1] == '\0' ) { - if ( !(n < argc-1) ) { - error = "Missing output-file name"; - break; - } - outputFile = argv[++n]; - } else - outputFile = &opt[1]; - } else if ( opt == "tr" ) { - if ( opt == "tr" || opt[1] == '\0' ) { - if ( !(n < argc-1) ) { - error = "Missing tr macro."; - break; - } - trmacro = argv[++n]; - } else { - trmacro = &opt[1]; - } - } else if ( opt == "x" ) { - execCode = TRUE; - } - } else { - if (!fileName.isEmpty()) // can handle only one file - error = "Too many input files specified"; - else - fileName = argv[n]; - } - } - - if ( argc < 2 || error || fileName.isEmpty() ) { - fprintf( stderr, "PyQt user interface compiler\n" ); - if ( error ) - fprintf( stderr, "pyuic: %s\n", error ); - - fprintf( stderr, "Usage: %s [options] <uifile>\n" - "\nGenerate PyQt implementation:\n" - " %s [options] <uifile>\n" - "Options:\n" - "\t-o file Write output to file rather than stdout\n" - "\t-tr func Use func(...) rather than tr(...) for i18n\n" - "\t-x Generate extra code to test the class\n" - , argv[0], argv[0]); - exit( 1 ); - } -#endif - - TQFile file( fileName ); - if ( !file.open( IO_ReadOnly ) ) - qFatal( "pyuic: Could not open file '%s' ", (const char *)fileName ); - - TQFile fileOut; - if (!outputFile.isEmpty()) { - fileOut.setName( outputFile ); - if (!fileOut.open( IO_WriteOnly ) ) - qFatal( "pyuic: Could not open output file '%s'", (const char *)outputFile ); - } else { - fileOut.open( IO_WriteOnly, stdout ); - } - TQTextStream out( &fileOut ); - out.setEncoding( TQTextStream::UnicodeUTF8 ); - - TQDomDocument doc; - if ( !doc.setContent( &file ) ) - qFatal( "pyuic: Failed to parse %s\n", (const char *)fileName ); - - out << "# Form implementation generated from reading ui file '" << fileName << "'" << endl; - out << "#" << endl; - out << "# Created: " << TQDateTime::currentDateTime().toString() << endl; - out << "# by: The Python User Interface Compiler (pyuic) " << PYQT_VERSION << endl; - out << "#" << endl; - out << "# WARNING! All changes made in this file will be lost!" << endl; - out << endl; - out << endl; - - if (execCode) - out << "import sys" << endl; - - out << "from qt import *" << endl; - - Uic( out, doc, trmacro.isEmpty() ? TQString("self.tr") : trmacro ); - - if (execCode) { - out << endl; - out << endl; - out << "if __name__ == '__main__':" << endl; - out << " a = TQApplication(sys.argv)" << endl; - out << " TQObject.connect(a,TQT_SIGNAL('lastWindowClosed()'),a,TQT_SLOT('quit()'))" << endl; - out << " w = " << className << "()" << endl; - out << " a.setMainWidget(w)" << endl; - out << " w.show()" << endl; - out << " a.exec_loop()" << endl; - } - - return 0; -} diff --git a/python/pyqt/pyuic2/uic.h b/python/pyqt/pyuic2/uic.h deleted file mode 100644 index 50e1d7a3..00000000 --- a/python/pyqt/pyuic2/uic.h +++ /dev/null @@ -1,133 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Troll Tech AS. All rights reserved. -** Copyright (C) 2000, 2001 Phil Thompson <phil@river-bank.demon.co.uk> -** -** This file is part of Qt GUI Designer. -** -** This file may be distributed under the terms of the GNU General -** Public License version 2 as published by the Free Software -** Foundation and appearing in the file COPYING included in the -** packaging of this file. If you did not get the file, send email -** to info@trolltech.com -** -** The file is provided AS IS with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#ifndef UIC_H -#define UIC_H - -#include <tqnamespace.h> -#include <tqdom.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <tqmap.h> -#include <tqtextstream.h> -#include <tqcolor.h> - - -#define PYQT_VERSION "3.17.2" - - -class Uic : public Qt -{ -public: - Uic( TQTextStream& out, TQDomDocument doc, const TQString &trm ); - - void createFormImpl( const TQDomElement &e ); - - TQString createObjectImpl( const TQDomElement &e, const TQString& parentClass, const TQString& parent, const TQString& layout = TQString::null ); - TQString createLayoutImpl( const TQDomElement &e, const TQString& parentClass, const TQString& parent, const TQString& layout = TQString::null ); - TQString createObjectInstance( const TQString& objClass, const TQString& parent, const TQString& objName ); - TQString createSpacerImpl( const TQDomElement &e, const TQString& parentClass, const TQString& parent, const TQString& layout = TQString::null ); - void createExclusiveProperty( const TQDomElement & e, const TQString& exclusiveProp ); - TQString createListBoxItemImpl( const TQDomElement &e, const TQString &parent ); - TQString createIconViewItemImpl( const TQDomElement &e, const TQString &parent ); - TQString createListViewColumnImpl( const TQDomElement &e, const TQString &parent ); - TQString createListViewItemImpl( const TQDomElement &e, const TQString &parent, - const TQString &parentItem ); - void createColorGroupImpl( const TQString& cg, const TQDomElement& e ); - TQColorGroup loadColorGroup( const TQDomElement &e ); - - TQString getClassName( const TQDomElement& e ); - TQString getObjectName( const TQDomElement& e ); - TQString getLayoutName( const TQDomElement& e ); - - TQString setObjectProperty( const TQString& objClass, const TQString& obj, const TQString &prop, const TQDomElement &e, bool stdset ); - - TQString registerObject( const TQString& name ); - TQString registeredName( const TQString& name ); - bool isObjectRegistered( const TQString& name ); - TQStringList unique( const TQStringList& ); - -private: - void pushIndent() - { - ++nrindents; - setIndent(); - } - - void popIndent() - { - --nrindents; - setIndent(); - } - - void setIndent() - { - indent = ""; - - for (int i = 0; i < nrindents; ++i) - indent += newindent; - } - - void initIndent() - { - newindent = " "; - indent = ""; - nrindents = 0; - } - - TQString indent, newindent; - int nrindents; - - TQTextStream& out; - TQStringList objectNames; - TQMap<TQString,TQString> objectMapper; - TQStringList tags; - TQStringList layouts; - TQString formName; - TQString lastItem; - TQString trmacro; - - struct Buddy - { - Buddy( const TQString& k, const TQString& b ) - : key( k ), buddy( b ) {} - Buddy(){}; // for valuelist - TQString key; - TQString buddy; - bool operator==( const Buddy& other ) const - { return (key == other.key); } - }; - struct CustomInclude - { - TQString header; - TQString location; - }; - TQValueList<Buddy> buddies; - - TQStringList layoutObjects; - bool isLayout( const TQString& name ) const; - - uint item_used : 1; - uint cg_used : 1; - uint pal_used : 1; - - TQString pixmapLoaderFunction; - TQString nameOfClass; -}; - -#endif diff --git a/python/pyqt/pyuic2/widgetdatabase.cpp b/python/pyqt/pyuic2/widgetdatabase.cpp deleted file mode 100644 index db5158e9..00000000 --- a/python/pyqt/pyuic2/widgetdatabase.cpp +++ /dev/null @@ -1,640 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qt Designer. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include <tqvariant.h> // HP-UX compiler needs this here - -#include "widgetdatabase.h" - -#if defined(DESIGNER) -#include "../designer/formwindow.h" -#include "../designer/pixmapchooser.h" -#endif - -//#include "../integration/kdevelop/kdewidgets.h" - -#include <globaldefs.h> -#include <tqstrlist.h> -#include <tqdict.h> -#include <tqfile.h> -#include <tqtextstream.h> - -#include <tqmodules.h> - -const int dbsize = 300; -const int dbcustom = 200; -const int dbdictsize = 211; -static WidgetDatabaseRecord* db[ dbsize ]; -static TQDict<int> *className2Id = 0; -static int dbcount = 0; -static int dbcustomcount = 200; -static TQStrList *wGroups; -static TQStrList *invisibleGroups; -static bool whatsThisLoaded = FALSE; - - -WidgetDatabaseRecord::WidgetDatabaseRecord() -{ - isContainer = FALSE; - icon = 0; - nameCounter = 0; -} - -WidgetDatabaseRecord::~WidgetDatabaseRecord() -{ - delete icon; -} - - -/*! - \class WidgetDatabase widgetdatabase.h - \brief The WidgetDatabase class holds information about widgets - - The WidgetDatabase holds information about widgets like toolTip(), - iconSet(), ... It works Id-based, so all access functions take the - widget id as parameter. To get the id for a widget (classname), use - idFromClassName(). - - All access functions are static. Having multiple widgetdatabases in - one application doesn't make sense anyway and so you don't need more - than an instance of the widgetdatabase. - - For creating widgets, layouts, etc. see WidgetFactory. -*/ - -/*! - Creatse widget database. Does nothing -*/ - -WidgetDatabase::WidgetDatabase() -{ -} - -/*! Sets up the widget database. If the static widgetdatabase already - exists, the functions returns immediately. -*/ - -void WidgetDatabase::setupDataBase() -{ - if ( dbcount ) - return; - - wGroups = new TQStrList; - invisibleGroups = new TQStrList; - invisibleGroups->append( "Forms" ); - invisibleGroups->append( "Temp" ); - className2Id = new TQDict<int>( dbdictsize ); - className2Id->setAutoDelete( TRUE ); - - WidgetDatabaseRecord *r = 0; - - r = new WidgetDatabaseRecord; - r->iconSet = "pushbutton.xpm"; - r->name = "TQPushButton"; - r->group = widgetGroup( "Buttons" ); - r->toolTip = "Push Button"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "toolbutton.xpm"; - r->name = "TQToolButton"; - r->group = widgetGroup( "Buttons" ); - r->toolTip = "Tool Button"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "radiobutton.xpm"; - r->name = "TQRadioButton"; - r->group = widgetGroup( "Buttons" ); - r->toolTip = "Radio Button"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "checkbox.xpm"; - r->name = "TQCheckBox"; - r->group = widgetGroup( "Buttons" ); - r->toolTip = "Check Box"; - - - - - append( r ); - r = new WidgetDatabaseRecord; - r->iconSet = "groupbox.xpm"; - r->name = "TQGroupBox"; - r->group = widgetGroup( "Containers" ); - r->toolTip = "Group Box"; - r->isContainer = TRUE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "buttongroup.xpm"; - r->name = "TQButtonGroup"; - r->group = widgetGroup( "Containers" ); - r->toolTip = "Button Group"; - r->isContainer = TRUE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "frame.xpm"; - r->name = "TQFrame"; - r->group = widgetGroup( "Containers" ); - r->toolTip = "Frame"; - r->isContainer = TRUE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "tabwidget.xpm"; - r->name = "TQTabWidget"; - r->group = widgetGroup( "Containers" ); - r->toolTip = "Tabwidget"; - r->isContainer = TRUE; - - append( r ); - - - r = new WidgetDatabaseRecord; - r->iconSet = "listbox.xpm"; - r->name = "TQListBox"; - r->group = widgetGroup( "Views" ); - r->toolTip = "List Box"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "listview.xpm"; - r->name = "TQListView"; - r->group = widgetGroup( "Views" ); - r->toolTip = "List View"; - - append( r ); - -#if defined(QT_MODULE_ICONVIEW) || defined(UIC) - r = new WidgetDatabaseRecord; - r->iconSet = "iconview.xpm"; - r->name = "TQIconView"; - r->group = widgetGroup( "Views" ); - r->toolTip = "Icon View"; - - append( r ); -#endif - -#if defined(QT_MODULE_TABLE) - r = new WidgetDatabaseRecord; - r->iconSet = "table.xpm"; - r->name = "TQTable"; - r->group = widgetGroup( "Views" ); - r->toolTip = "Table"; - - append( r ); -#endif - - - r = new WidgetDatabaseRecord; - r->iconSet = "lineedit.xpm"; - r->name = "TQLineEdit"; - r->group = widgetGroup( "Input" ); - r->toolTip = "Line Edit"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "spinbox.xpm"; - r->name = "TQSpinBox"; - r->group = widgetGroup( "Input" ); - r->toolTip = "Spin Box"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "multilineedit.xpm"; - r->name = "TQMultiLineEdit"; - r->group = widgetGroup( "Input" ); - r->toolTip = "Multi Line Edit"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "combobox.xpm"; - r->name = "TQComboBox"; - r->group = widgetGroup( "Input" ); - r->toolTip = "Combo Box"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "slider.xpm"; - r->name = "TQSlider"; - r->group = widgetGroup( "Input" ); - r->toolTip = "Slider"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "dial.xpm"; - r->name = "TQDial"; - r->group = widgetGroup( "Input" ); - r->toolTip = "Dial"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "label.xpm"; - r->name = "TQLabel"; - r->group = widgetGroup( "Temp" ); - r->toolTip = "Label"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "label.xpm"; - r->name = "TextLabel"; - r->group = widgetGroup( "Display" ); - r->toolTip = "Text Label"; - r->whatsThis = "The Text Label provides a widget to display static text."; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "pixlabel.xpm"; - r->name = "PixmapLabel"; - r->group = widgetGroup( "Display" ); - r->toolTip = "Pixmap Label"; - r->whatsThis = "The Pixmap Label provides a widget to display pixmaps."; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "lcdnumber.xpm"; - r->name = "TQLCDNumber"; - r->group = widgetGroup( "Display" ); - r->toolTip = "LCD Number"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "line.xpm"; - r->name = "Line"; - r->group = widgetGroup( "Display" ); - r->toolTip = "Line"; - r->includeFile = "tqframe.h"; - r->whatsThis = "The Line widget provides horizontal and vertical lines."; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "progress.xpm"; - r->name = "TQProgressBar"; - r->group = widgetGroup( "Display" ); - r->toolTip = "Progress Bar"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "textview.xpm"; - r->name = "TQTextView"; - r->group = widgetGroup( "Display" ); - r->toolTip = "Text View"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "textbrowser.xpm"; - r->name = "TQTextBrowser"; - r->group = widgetGroup( "Display" ); - r->toolTip = "Text Browser"; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "spacer.xpm"; - r->name = "Spacer"; - r->group = widgetGroup( "Temp" ); - r->toolTip = "Spacer"; - r->whatsThis = "The Spacer provides horizontal and vertical spacing to be able to manipulate the bahviour of layouts."; - - append( r ); - - r = new WidgetDatabaseRecord; - r->name = "TQWidget"; - r->isContainer = FALSE; - r->group = widgetGroup( "Forms" ); - - append( r ); - - r = new WidgetDatabaseRecord; - r->name = "TQDialog"; - r->group = widgetGroup( "Forms" ); - r->isContainer = FALSE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->name = "TQWizard"; - r->group = widgetGroup( "Forms" ); - r->isContainer = TRUE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->name = "QDesignerWizard"; - r->group = widgetGroup( "Forms" ); - r->isContainer = TRUE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->name = "QLayoutWidget"; - r->group = widgetGroup( "Temp" ); - r->includeFile = ""; - r->isContainer = TRUE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "tabwidget.xpm"; - r->name = "QDesignerTabWidget"; - r->group = widgetGroup( "Temp" ); - r->isContainer = TRUE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "tabwidget.xpm"; - r->name = "QDesignerWidget"; - r->group = widgetGroup( "Temp" ); - r->isContainer = TRUE; - - append( r ); - - r = new WidgetDatabaseRecord; - r->iconSet = "tabwidget.xpm"; - r->name = "QDesignerDialog"; - r->group = widgetGroup( "Temp" ); - r->isContainer = TRUE; - - append( r ); - -// qt_init_kde_widget_database(); -} - -/*! - Returns the number of elements in the widget database. -*/ - -int WidgetDatabase::count() -{ - setupDataBase(); - return dbcount; -} - -/*! - Returns the id at which the ids of custom widgets start. -*/ - -int WidgetDatabase::startCustom() -{ - setupDataBase(); - return dbcustom; -} - -/*! Returns the iconset which represents the class registered as \a - id. -*/ - -TQIconSet WidgetDatabase::iconSet( int id ) -{ - setupDataBase(); - WidgetDatabaseRecord *r = at( id ); - if ( !r ) - return TQIconSet(); -#if defined(DESIGNER) - if ( !r->icon ) - r->icon = new TQIconSet( PixmapChooser::loadPixmap( r->iconSet, PixmapChooser::Small ), - PixmapChooser::loadPixmap( r->iconSet, PixmapChooser::Large ) ); - return *r->icon; -#endif - - return TQIconSet(); -} - -/*! - Returns the classname of the widget which is registered as \a id. -*/ - -TQString WidgetDatabase::className( int id ) -{ - setupDataBase(); - WidgetDatabaseRecord *r = at( id ); - if ( !r ) - return TQString::null; - return r->name; -} - -/*! - Returns the group to which the widget registered as \a id belongs. -*/ - -TQString WidgetDatabase::group( int id ) -{ - setupDataBase(); - WidgetDatabaseRecord *r = at( id ); - if ( !r ) - return TQString::null; - return r->group; -} - -/*! Returns the tooltip text of the widget which is registered as \a - id. -*/ - -TQString WidgetDatabase::toolTip( int id ) -{ - setupDataBase(); - WidgetDatabaseRecord *r = at( id ); - if ( !r ) - return TQString::null; - return r->toolTip; -} - -/*! Returns the what's this? test of the widget which is registered - as \a id. -*/ - -TQString WidgetDatabase::whatsThis( int id ) -{ - setupDataBase(); - WidgetDatabaseRecord *r = at( id ); - if ( !r ) - return TQString::null; - return r->whatsThis; -} - -/*! - Returns the include file if the widget which is registered as \a id. -*/ - -TQString WidgetDatabase::includeFile( int id ) -{ - setupDataBase(); - WidgetDatabaseRecord *r = at( id ); - if ( !r ) - return TQString::null; - if ( r->includeFile.isNull() ) - return r->name.lower() + ".h"; - return r->includeFile; -} - -/*! Returns wheather the widget registered as \a id is a container - (can have children) or not. -*/ - -bool WidgetDatabase::isContainer( int id ) -{ - setupDataBase(); - WidgetDatabaseRecord *r = at( id ); - if ( !r ) - return FALSE; - return r->isContainer; -} - -TQString WidgetDatabase::createWidgetName( int id ) -{ - setupDataBase(); - TQString n = className( id ); - if ( n == "QLayoutWidget" ) - n = "Layout"; - if ( n[ 0 ] == 'Q' ) - n = n.mid( 1 ); - WidgetDatabaseRecord *r = at( id ); - if ( !r ) - return n; - n += TQString::number( ++r->nameCounter ); - return n; -} - -/*! Returns the id for \a name or -1 if \a name is unknown. - */ -int WidgetDatabase::idFromClassName( const TQString &name ) -{ - setupDataBase(); - if ( name.isEmpty() ) - return 0; - int *i = className2Id->find( name ); - if ( i ) - return *i; - if ( name == "FormWindow" ) - return idFromClassName( "QLayoutWidget" ); - return -1; -} - -WidgetDatabaseRecord *WidgetDatabase::at( int index ) -{ - if ( index < 0 ) - return 0; - if ( index >= dbcustom && index < dbcustomcount ) - return db[ index ]; - if ( index < dbcount ) - return db[ index ]; - return 0; -} - -void WidgetDatabase::insert( int index, WidgetDatabaseRecord *r ) -{ - if ( index < 0 || index >= dbsize ) - return; - db[ index ] = r; - className2Id->insert( r->name, new int( index ) ); - if ( index < dbcustom ) - dbcount = QMAX( dbcount, index ); -} - -void WidgetDatabase::append( WidgetDatabaseRecord *r ) -{ - insert( dbcount++, r ); -} - -TQString WidgetDatabase::widgetGroup( const TQString &g ) -{ - if ( wGroups->find( g ) == -1 ) - wGroups->append( g ); - return g; -} - -TQString WidgetDatabase::widgetGroup( int i ) -{ - setupDataBase(); - if ( i >= 0 && i < (int)wGroups->count() ) - return wGroups->at( i ); - return TQString::null; -} - -int WidgetDatabase::numWidgetGroups() -{ - setupDataBase(); - return wGroups->count(); -} - -bool WidgetDatabase::isGroupVisible( const TQString &g ) -{ - setupDataBase(); - return invisibleGroups->find( g ) == -1; -} - -int WidgetDatabase::addCustomWidget( WidgetDatabaseRecord *r ) -{ - insert( dbcustomcount++, r ); - return dbcustomcount - 1; -} - -bool WidgetDatabase::isCustomWidget( int id ) -{ - if ( id >= dbcustom && id < dbcustomcount ) - return TRUE; - return FALSE; -} - -bool WidgetDatabase::isWhatsThisLoaded() -{ - return whatsThisLoaded; -} - -void WidgetDatabase::loadWhatsThis( const TQString &docPath ) -{ - TQString whatsthisFile = docPath + "/whatsthis"; - TQFile f( whatsthisFile ); - if ( !f.open( IO_ReadOnly ) ) - return; - TQTextStream ts( &f ); - while ( !ts.atEnd() ) { - TQString s = ts.readLine(); - TQStringList l = TQStringList::split( " | ", s ); - int id = idFromClassName( l[ 1 ] ); - WidgetDatabaseRecord *r = at( id ); - if ( r ) - r->whatsThis = l[ 0 ]; - } - whatsThisLoaded = TRUE; -} diff --git a/python/pyqt/pyuic2/widgetdatabase.h b/python/pyqt/pyuic2/widgetdatabase.h deleted file mode 100644 index dd327d7a..00000000 --- a/python/pyqt/pyuic2/widgetdatabase.h +++ /dev/null @@ -1,75 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qt Designer. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef WIDGETDATABASE_H -#define WIDGETDATABASE_H - -#include <tqiconset.h> -#include <tqstring.h> -#include <tqstringlist.h> - -struct WidgetDatabaseRecord -{ - WidgetDatabaseRecord(); - ~WidgetDatabaseRecord(); - TQString iconSet, name, group, toolTip, whatsThis, includeFile; - uint isContainer : 1; - TQIconSet *icon; - int nameCounter; -}; - -class WidgetDatabase : public Qt -{ -public: - WidgetDatabase(); - static void setupDataBase(); - - static int count(); - static int startCustom(); - - static TQIconSet iconSet( int id ); - static TQString className( int id ); - static TQString group( int id ); - static TQString toolTip( int id ); - static TQString whatsThis( int id ); - static TQString includeFile( int id ); - static bool isContainer( int id ); - - static int idFromClassName( const TQString &name ); - static TQString createWidgetName( int id ); - - static WidgetDatabaseRecord *at( int index ); - static void insert( int index, WidgetDatabaseRecord *r ); - static void append( WidgetDatabaseRecord *r ); - - static TQString widgetGroup( const TQString &g ); - static TQString widgetGroup( int i ); - static int numWidgetGroups(); - static bool isGroupVisible( const TQString &g ); - - static int addCustomWidget( WidgetDatabaseRecord *r ); - static bool isCustomWidget( int id ); - - static bool isWhatsThisLoaded(); - static void loadWhatsThis( const TQString &docPath ); - -}; - -#endif |