From e93b60dfa24c4b72c1cffa7556949afe69654c02 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 11 Oct 2024 22:21:44 +0900 Subject: Rename uic to tquic Signed-off-by: Michele Calgaro --- doc/changes.doc | 2 +- doc/html/archivesearch-example.html | 2 +- doc/html/commonproblems.html | 4 +- doc/html/designer-manual-1.html | 2 +- doc/html/designer-manual-13.html | 4 +- doc/html/designer-manual-16.html | 2 +- doc/html/designer-manual-5.html | 18 +- doc/html/designer-manual-6.html | 2 +- doc/html/designer-manual-7.html | 2 +- doc/html/designer-manual-9.html | 30 +- doc/html/distributor-example.html | 2 +- doc/html/extension-dialog-example.html | 6 +- doc/html/ftpclient-example.html | 2 +- doc/html/index | 2 +- doc/html/keyfeatures30.html | 2 +- doc/html/process-example.html | 8 +- doc/html/qmake-manual-8.html | 16 +- doc/html/qt.dcf | 4 +- doc/html/titleindex | 2 +- doc/html/tools-list.html | 2 +- doc/html/tqprocess.html | 8 +- doc/html/tquic.html | 133 ++ doc/html/tqwidgetplugin.html | 2 +- doc/html/uic.html | 133 -- doc/man/man1/tqdesigner.1 | 2 +- doc/man/man3/tqprocess.3qt | 4 +- doc/misc.doc | 4 +- doc/tquic.doc | 100 ++ doc/uic.doc | 100 -- examples/demo/opengl/gllandscapeviewer.ui.h | 2 +- examples/demo/opengl/printpreview.ui.h | 2 +- examples/demo/sql/connect.ui.h | 2 +- examples/demo/sql/sqlex.ui.h | 2 +- examples/distributor/distributor.ui.h | 2 +- examples/extension/dialogform.ui.h | 2 +- examples/extension/extension.ui.h | 2 +- examples/extension/mainform.ui.h | 2 +- examples/network/archivesearch/archivedialog.ui.h | 2 +- examples/network/ftpclient/ftpmainwindow.ui.h | 2 +- examples/process/README | 4 +- examples/process/process.cpp | 6 +- examples/process/process.doc | 2 +- mkspecs/win32-borland/qmake.conf | 2 +- mkspecs/win32-g++/qmake.conf | 2 +- mkspecs/win32-icc/qmake.conf | 2 +- mkspecs/win32-msvc.net/qmake.conf | 2 +- mkspecs/win32-msvc/qmake.conf | 2 +- mkspecs/win32-msvc2005/qmake.conf | 2 +- qmake/book/qmake-commandreference.leaf | 16 +- qmake/book/qmake-preface.leaf | 2 +- qmake/generators/mac/pbuilder_pbx.cpp | 4 +- qmake/generators/makefile.cpp | 10 +- qmake/generators/unix/unixmake2.cpp | 2 +- qmake/generators/win32/borland_bmake.cpp | 2 +- qmake/generators/win32/mingw_make.cpp | 2 +- qmake/generators/win32/msvc_dsp.cpp | 4 +- qmake/generators/win32/msvc_nmake.cpp | 2 +- qmake/generators/win32/msvc_objectmodel.cpp | 10 +- qmake/generators/win32/msvc_objectmodel.h | 2 +- qmake/generators/win32/msvc_vcproj.cpp | 6 +- src/kernel/tqcolor_x11.cpp | 2 +- src/kernel/tqprocess.cpp | 8 +- src/widgets/tqwidgetinterface_p.h | 2 +- src/widgets/tqwidgetplugin.cpp | 6 +- tools/assistant/tabbedbrowser.ui.h | 2 +- tools/designer/designer.pro | 2 +- tools/designer/designer/connectiondialog.ui.h | 2 +- tools/designer/designer/designer_de.ts | 2 +- tools/designer/designer/designer_fr.ts | 2 +- tools/designer/designer/formfile.cpp | 2 +- tools/designer/designer/formsettings.ui | 2 +- tools/designer/designer/formwindow.cpp | 2 +- tools/designer/designer/listeditor.ui.h | 2 +- tools/designer/designer/resource.cpp | 2 +- tools/designer/designer/richtextfontdialog.ui.h | 2 +- .../designer/examples/addressbook/addressbook.ui.h | 2 +- .../examples/addressbook/addressdetails.ui.h | 2 +- tools/designer/examples/addressbook/search.ui.h | 2 +- .../designer/examples/colortool/colornameform.ui.h | 2 +- tools/designer/examples/colortool/findform.ui.h | 2 +- tools/designer/examples/colortool/mainform.ui.h | 2 +- tools/designer/examples/colortool/optionsform.ui.h | 2 +- tools/designer/examples/credit/creditformbase.cpp | 2 +- tools/designer/examples/credit/creditformbase.h | 2 +- tools/designer/examples/metric/metric.ui.h | 2 +- .../plugins/cppeditor/mainfilesettings.ui.h | 2 +- .../plugins/cppeditor/projectsettings.ui.h | 2 +- tools/designer/plugins/kdevdlg/main.cpp | 2 +- tools/designer/plugins/rc/main.cpp | 2 +- tools/designer/shared/domtool.cpp | 2 +- tools/designer/shared/ui2uib.cpp | 2 +- tools/designer/shared/uib.h | 2 +- tools/designer/shared/widgetdatabase.cpp | 18 +- tools/designer/tquic/embed.cpp | 309 +++++ tools/designer/tquic/form.cpp | 1452 ++++++++++++++++++++ tools/designer/tquic/main.cpp | 358 +++++ tools/designer/tquic/object.cpp | 734 ++++++++++ tools/designer/tquic/subclassing.cpp | 352 +++++ tools/designer/tquic/tquic.cpp | 1129 +++++++++++++++ tools/designer/tquic/tquic.h | 176 +++ tools/designer/tquic/tquic.pro | 42 + tools/designer/uic/embed.cpp | 309 ----- tools/designer/uic/form.cpp | 1452 -------------------- tools/designer/uic/main.cpp | 358 ----- tools/designer/uic/object.cpp | 734 ---------- tools/designer/uic/subclassing.cpp | 352 ----- tools/designer/uic/uic.cpp | 1129 --------------- tools/designer/uic/uic.h | 176 --- tools/designer/uic/uic.pro | 42 - 109 files changed, 4951 insertions(+), 4951 deletions(-) create mode 100644 doc/html/tquic.html delete mode 100644 doc/html/uic.html create mode 100644 doc/tquic.doc delete mode 100644 doc/uic.doc create mode 100644 tools/designer/tquic/embed.cpp create mode 100644 tools/designer/tquic/form.cpp create mode 100644 tools/designer/tquic/main.cpp create mode 100644 tools/designer/tquic/object.cpp create mode 100644 tools/designer/tquic/subclassing.cpp create mode 100644 tools/designer/tquic/tquic.cpp create mode 100644 tools/designer/tquic/tquic.h create mode 100644 tools/designer/tquic/tquic.pro delete mode 100644 tools/designer/uic/embed.cpp delete mode 100644 tools/designer/uic/form.cpp delete mode 100644 tools/designer/uic/main.cpp delete mode 100644 tools/designer/uic/object.cpp delete mode 100644 tools/designer/uic/subclassing.cpp delete mode 100644 tools/designer/uic/uic.cpp delete mode 100644 tools/designer/uic/uic.h delete mode 100644 tools/designer/uic/uic.pro diff --git a/doc/changes.doc b/doc/changes.doc index 6ce47761c..773e08bc7 100644 --- a/doc/changes.doc +++ b/doc/changes.doc @@ -370,7 +370,7 @@ and do some global operations on the project. You can now open the project file and have one-click access to all the *.ui forms in the project. -In addition to generating code via uic, TQt Designer now supports the +In addition to generating code via tquic, TQt Designer now supports the dynamic creation of widgets directly from XML user interface description files (*.ui files) at runtime. This eliminates the need of recompiling your application when the GUI changes, and could be used diff --git a/doc/html/archivesearch-example.html b/doc/html/archivesearch-example.html index fb9244d04..ef6cce68f 100644 --- a/doc/html/archivesearch-example.html +++ b/doc/html/archivesearch-example.html @@ -49,7 +49,7 @@ were done using TQt Designer. *****************************************************************************/ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions or slots use ** TQt Designer which will update this file, preserving your code. Create an diff --git a/doc/html/commonproblems.html b/doc/html/commonproblems.html index c8abf99f8..c633f621f 100644 --- a/doc/html/commonproblems.html +++ b/doc/html/commonproblems.html @@ -73,8 +73,8 @@ the relevant release of TQt.

Programmers need to run tqmoc and other tools such as tquic. These tools are usually located in the bin subdirectory of TQt distributions. Either run "$TQTDIR"/bin/tqmoc and "$TQTDIR"/bin/tquic or add "$TQTDIR"/bin -to your PATH and run tqmoc and uic. If you use qmake the -appropriate lines will be added to your Makefiles so that uic and +to your PATH and run tqmoc and tquic. If you use qmake the +appropriate lines will be added to your Makefiles so that tquic and tqmoc will be executed as required.

Static or shared libraries - Link time

Programmers need to link with the TQt static or shared libraries. The TQt diff --git a/doc/html/designer-manual-1.html b/doc/html/designer-manual-1.html index f7039a9bb..57bb2e8a1 100644 --- a/doc/html/designer-manual-1.html +++ b/doc/html/designer-manual-1.html @@ -39,7 +39,7 @@ body { background: #ffffff; color: black; }
  • Chapter two, Creating a Main Window Application, introduces TQt Designer and takes you step by step through the creation of a small but fully functional application. Along the way you will learn how to create a main window with menus, toolbars and a status bar. Most of the application's implementation will be covered, but the custom dialogs are deferred until chapter three. In the course of this chapter you will use the form and property editors to customize the application. You'll also learn how to use TQt's signals and slots mechanism and TQt Designer's built-in code editor to make the application functional. We will also explain how to use qmake to generate a Makefile so that you can compile and run the application.

  • In chapter three, Creating Dialogs, we will create the custom dialogs required by the main window application created in chapter two. In addition to demonstrating various ways of creating dialogs, you will also learn how to lay out forms using the layout tools.

  • Chapter four, The Designer Approach, provides information on the TQt Designer approach to developing applications, and explains some of the rationale behind TQt Designer.

    -
  • Chapter five, Subclassing and Dynamic Dialogs, will show you how to subclass a form; this allows you to clearly separate the user interface from the underlying code that implements its functionality. Additional information on qmake and uic is included in this chapter. This chapter will also explain how you can dynamically load dialogs from .ui files into your application using TQWidgetFactory and how to access the widgets and sub-widgets of these dialogs.

    +
  • Chapter five, Subclassing and Dynamic Dialogs, will show you how to subclass a form; this allows you to clearly separate the user interface from the underlying code that implements its functionality. Additional information on qmake and tquic is included in this chapter. This chapter will also explain how you can dynamically load dialogs from .ui files into your application using TQWidgetFactory and how to access the widgets and sub-widgets of these dialogs.

  • Chapter six, Creating Custom Widgets, explains how you can create your own custom widgets. Both the simple method, that was introduced with the first version of TQt Designer, and the new more powerful method using plugins, are explained.

  • Chapter seven, Creating Database Applications introduces TQt's SQL classes and takes you through an example that demonstrates how to execute SQL queries and how to set up master-detail relationships, perform drilldown and handle foreign keys.

  • Chapter eight, Customizing and Integrating TQt Designer, focuses on TQt Designer itself, showing you how to customize Designer, how to integrate Designer with Visual Studio and how to create Makefiles.

    diff --git a/doc/html/designer-manual-13.html b/doc/html/designer-manual-13.html index 19f2fb743..26509a689 100644 --- a/doc/html/designer-manual-13.html +++ b/doc/html/designer-manual-13.html @@ -59,7 +59,7 @@ body { background: #ffffff; color: black; }

    The 'Insert Into' drop-down combobox lists the open projects, defaulting to the current project. New files are added to the project displayed in this combobox. To add a new file to a different project, choose the project you want to use in the 'Insert Into' combobox.

    The 'Dialog' file type is highlighted by default when the New File dialog pops up. Click on the file type you want to use and click OK to create it. Click Cancel to leave the dialog without creating a new file. Note that if you select C++ Project, the 'Insert Into' combobox will be disabled, since it is not possible to insert a new C++ Project into an existing project.

    C++ Project Files
    -

    Click C++ Project to start a new project. This option invokes the Project Settings Dialog. C++ projects are saved as .pro files, which include the information TQt Designer needs to manage projects. When you add a form to your project in TQt Designer, it is automatically added to the FORMS section of the project file. The .pro file contains the list of forms (.ui files) used in the project. TQt Designer reads and writes .ui files, e.g. form.ui. The uic (user interface compiler) creates both a header file, e.g. form.h, and an implementation file, e.g. form.cpp, from the .ui file.

    +

    Click C++ Project to start a new project. This option invokes the Project Settings Dialog. C++ projects are saved as .pro files, which include the information TQt Designer needs to manage projects. When you add a form to your project in TQt Designer, it is automatically added to the FORMS section of the project file. The .pro file contains the list of forms (.ui files) used in the project. TQt Designer reads and writes .ui files, e.g. form.ui. The tquic (user interface compiler) creates both a header file, e.g. form.h, and an implementation file, e.g. form.cpp, from the .ui file.

    Dialog Forms

    Click Dialog to create a plain dialog form. Typically, this type of form is used to present the user with configuration options, or to present related sets of choices, for example, printer setting dialogs and find and replace dialogs.

    Wizard Forms
    @@ -144,7 +144,7 @@ body { background: #ffffff; color: black; }
    Settings

    In the Settings section, you can change or add the name of the class that will be created by typing in the 'Class Name' line edit. Note that the default name is the form name, but it can be changed. You can also enter text to the 'Comment' and 'Author' line edits or leave them blank, since they are not required.

    Pixmaps
    -

    The default (for projects) is 'Project Imagefile'. This is the recommended option. Images are handled automatically, with TQt Designer storing the images in a subdirectory, and uic producing code that contains the images and the necessary supporting code. Each image is stored just once, no matter how many forms it is used in.

    +

    The default (for projects) is 'Project Imagefile'. This is the recommended option. Images are handled automatically, with TQt Designer storing the images in a subdirectory, and tquic producing code that contains the images and the necessary supporting code. Each image is stored just once, no matter how many forms it is used in.

    If you do not want TQt Designer to handle the images, (or are not using a project) choose either 'Save Inline' or 'Use Function'. 'Save Inline' saves the pixmaps in the .ui files. The disadvantage of this approach is that it stores images in the forms in which they're used, meaning that images cannot be shared across forms. Click 'Use Function' to use your own icon-loader function for loading pixmaps. Type the function's name (with no signature) in the 'Use Function' line edit. This function will be used in the generated code for loading pixmaps. Your function will be called with the text you put in the pixmap property (e.g. the image name) whenever an image is required.

    Layouts

    Click the 'Default Margin' spinbox or the 'Default Spacing' spinbox to change the default layout settings of the current form.

    diff --git a/doc/html/designer-manual-16.html b/doc/html/designer-manual-16.html index 4d6b536a2..a480fc707 100644 --- a/doc/html/designer-manual-16.html +++ b/doc/html/designer-manual-16.html @@ -185,7 +185,7 @@ body { background: #ffffff; color: black; }

    If you have a class that requires some Windows-specific export macro, e.g. for classes in a DLL that need to be declared like this: class win_specific_declaration_goes_here Class, you can use the <exportmacro> tag. (In standard TQt we use the TQ_EXPORT macro, e.g. class TQ_EXPORT TQWidget.) If you use this tag you must also:

    1. include the file which contains the macro definition;

    2. add the export macro to the form -- this is achieved by entering the macro's name in the 'export macro' sub-property of the form's name property.

      -

    Following these steps will ensure that uic will create the correct class YOUR_MACRO Form declarations.

    +

    Following these steps will ensure that tquic will create the correct class YOUR_MACRO Form declarations.

     <exportmacro>EDITOR_EXPORT</exportmacro>
     
    diff --git a/doc/html/designer-manual-5.html b/doc/html/designer-manual-5.html index cc669704e..e617f70c6 100644 --- a/doc/html/designer-manual-5.html +++ b/doc/html/designer-manual-5.html @@ -32,7 +32,7 @@ body { background: #ffffff; color: black; }

    [Prev: Creating Dialogs] [Home] [Next: Subclassing and Dynamic Dialogs]

    The Designer Approach

    Introduction

    -

    In TQt 2.x, TQt Designer was a visual form designer for editing files in the .ui file format. TQt Designer's primary goal was to turn the most tedious part of GUI programming -- dialog design -- into a pleasant experience. From an architectural point of view, TQt Designer in 2.x is a fairly simple program. It reads and writes .ui files. Each .ui file contains an XML description of a single dialog form. A second utility -- the user interface compiler uic -- is used during the build process of an application to generate C++ code from those XML descriptions.

    +

    In TQt 2.x, TQt Designer was a visual form designer for editing files in the .ui file format. TQt Designer's primary goal was to turn the most tedious part of GUI programming -- dialog design -- into a pleasant experience. From an architectural point of view, TQt Designer in 2.x is a fairly simple program. It reads and writes .ui files. Each .ui file contains an XML description of a single dialog form. A second utility -- the user interface compiler tquic -- is used during the build process of an application to generate C++ code from those XML descriptions.

    For TQt 3.0 our ambitions for TQt Designer have grown beyond single dialog editing. In addition to many new design features like the ability to creating main windows and actions, the new version introduces:

    • project management for the user interface part of your application;

    • code in forms TQt Designer provides a code editor so that you can code your slots directly; the code is stored in .ui.h files and eliminates the need for sub-classing (although you can still subclass if you prefer);

      @@ -58,35 +58,35 @@ body { background: #ffffff; color: black; }

      When you've opened or created a project you can set up its database connections using the Edit Database Connections dialog (invoked by the Project|Database Connections menu option). The connections you make are stored in a .db file. When you reload a project you can reconnect by going to the Edit Database Connections dialog, clicking a connection in the list and clicking the Connect button.

      In most non-trivial database applications you will want to access the database from more than one form. This is why the .db file is part of a project, not just part of a single form.

      .pro files

      -

      TQt Designer needs to store information on projects, for example, the list of forms, the image collection and information about available databases and how to access them. The majority of TQt users already use a project file format to create multiplatform makefiles: tmake (and with TQt 3.0 qmake) project .pro files. These files already contain the list of forms, .ui files, used in the project for uic.

      +

      TQt Designer needs to store information on projects, for example, the list of forms, the image collection and information about available databases and how to access them. The majority of TQt users already use a project file format to create multiplatform makefiles: tmake (and with TQt 3.0 qmake) project .pro files. These files already contain the list of forms, .ui files, used in the project for tquic.

      We've extended the sections in the .pro file to include the extra information that TQt Designer needs to manage projects. For example, when you add a form to your project in TQt Designer, it is automatically added to the FORMS section of the project file, and thus qmake will generate the required build rules without any further work. Similarly, the images are added to the IMAGES section and thus gets automatically compiled into your executable.

      We don't force you to use qmake; if you prefer another build system, for example automake/autoconf or jam, you can still continue to use it. Look upon the .pro file as a file that describes the GUI part of your application. All you need to do -- as previously -- is add the .ui files and the images collection to your own Makefiles.

      Extending the functionality of a form

      First let us look at a small figure that shows the relationship between .ui files, generated code and application code:

      -

      TQt Designer reads and writes .ui files, e.g. form.ui. The user interface compiler, uic, creates both a header file, e.g. form.h, and an implementation file, e.g. form.cpp, from the .ui file. The application code in main.cpp #includes form.h. Typically main.cpp is used to instantiate the TQApplication object and start off the event loop.

      -

      While this approach is simple, it isn't sufficient for more complex dialogs. Complex dialogs tend to have quite a lot of logic attached to the form's widgets, more logic than can usually be expressed with predefined signals and slots. One way of handling this extra logic is to write a controller class in the application code that adds functionality to the form. This is possible because uic generated classes expose a form's controls and their signals to the public space. The big disadvantage of this method is that it's not exactly TQt-style. If you were not using TQt Designer, you would almost always add the logic to the form itself, where it belongs.

      -

      This is why the capability of adding custom slots and member variables to a form was added to TQt Designer early on. The big additional benefit with this approach is that you can use TQt Designer to connect signals to those custom slots, in the same elegant graphical way that is used to connect signals to predefined slots. The uic then adds an empty stub for each custom slot to the generated form.cpp implementation file.

      -

      The big question now is how to add custom implementation code to those custom slots. Adding code to the generated form.cpp is not an option, as this file gets recreated by the uic whenever the form changes -- and we don't want a combination of generated and handwritten code. There are two possible solutions, which we'll cover next.

      +

      TQt Designer reads and writes .ui files, e.g. form.ui. The user interface compiler, tquic, creates both a header file, e.g. form.h, and an implementation file, e.g. form.cpp, from the .ui file. The application code in main.cpp #includes form.h. Typically main.cpp is used to instantiate the TQApplication object and start off the event loop.

      +

      While this approach is simple, it isn't sufficient for more complex dialogs. Complex dialogs tend to have quite a lot of logic attached to the form's widgets, more logic than can usually be expressed with predefined signals and slots. One way of handling this extra logic is to write a controller class in the application code that adds functionality to the form. This is possible because tquic generated classes expose a form's controls and their signals to the public space. The big disadvantage of this method is that it's not exactly TQt-style. If you were not using TQt Designer, you would almost always add the logic to the form itself, where it belongs.

      +

      This is why the capability of adding custom slots and member variables to a form was added to TQt Designer early on. The big additional benefit with this approach is that you can use TQt Designer to connect signals to those custom slots, in the same elegant graphical way that is used to connect signals to predefined slots. The tquic then adds an empty stub for each custom slot to the generated form.cpp implementation file.

      +

      The big question now is how to add custom implementation code to those custom slots. Adding code to the generated form.cpp is not an option, as this file gets recreated by the tquic whenever the form changes -- and we don't want a combination of generated and handwritten code. There are two possible solutions, which we'll cover next.

      The subclassing approach

      A very clean way to implement custom slots for generated forms is via C++ inheritance as shown in the next figure:

      -

      Here the user wrote an additional class FormImpl, which is split into the header file formimpl.h and the implementation file formimpl.cpp. The header file includes the uic generated form.h and reimplements all the custom slots. This is possible because uic generated custom slots are virtual. In addition to implementing custom slots, this approach gives the user a way to do extra initialization work in the constructor of the subclass, and extra cleanups in the destructor.

      +

      Here the user wrote an additional class FormImpl, which is split into the header file formimpl.h and the implementation file formimpl.cpp. The header file includes the tquic generated form.h and reimplements all the custom slots. This is possible because tquic generated custom slots are virtual. In addition to implementing custom slots, this approach gives the user a way to do extra initialization work in the constructor of the subclass, and extra cleanups in the destructor.

      Because of these benefits and its flexibility, this approach became the primary way of using TQt Designer in TQt 2.x.

      Note: To keep the namespace clean, most users did not follow the Form and FormImpl naming scheme shown in the figure, but instead named their TQt Designer forms FormBase and their subclasses Form. This made a lot of sense, because they always subclassed and were using those subclasses in application code.

      The ui.h extension approach

      Despite its flexibility and cleanness, the subclassing approach has some disadvantages:

      • Subclassing is not natural and easy for everybody. Newcomers to object-oriented techniques may feel uneasy about being forced to subclass for such a simple and natural thing like the implementation of a custom slot.

        -
      • Inheriting generated classes is an additional possible source of programming mistakes, especially if the number of reimplemented functions is high and the signatures change often during the design process. To make the development process smoother, uic generates empty stubs for custom slots rather than pure virtual functions. While this approach keeps the code compiling and running, programmers can find themselves in a situation where they miss a runtime warning message and lose time before they find a small spelling error in their subclass.

        +
      • Inheriting generated classes is an additional possible source of programming mistakes, especially if the number of reimplemented functions is high and the signatures change often during the design process. To make the development process smoother, tquic generates empty stubs for custom slots rather than pure virtual functions. While this approach keeps the code compiling and running, programmers can find themselves in a situation where they miss a runtime warning message and lose time before they find a small spelling error in their subclass.

      • In larger projects with hundreds of forms, the additional subclasses can make a noticeable difference in terms of compilation speed and code size.

      There may be more disadvantages, but these were reason enough for us to investigate alternative solutions. For TQt 3.0, we came up with a new concept, the ui.h extension.

      This is how it works:

      In addition to the .ui file, form.ui, TQt Designer reads and writes another associated file form.ui.h. This .ui.h file is an ordinary C++ source file that contains implementations of custom slots. The file gets included from the generated form implementation file form.cpp and thus can be totally ignored by other user code. The reason we use a .h extension for the .ui.h file even though it contains C++ code is because it is always included, and because it is easier to integrate into the build process with a .h extension.

      -

      The form.ui.h file has a special position among all other files. It is a shared source file that gets written and read by both the user and TQt Designer. As such it is an ordinary revision controlled source file and not generated by uic. TQt Designer's responsibility is to keep the file in sync with the custom slot definitions of the associated form:

      +

      The form.ui.h file has a special position among all other files. It is a shared source file that gets written and read by both the user and TQt Designer. As such it is an ordinary revision controlled source file and not generated by tquic. TQt Designer's responsibility is to keep the file in sync with the custom slot definitions of the associated form:

      1. Whenever the users adds a new slots to the form, TQt Designer adds a stub to the .ui.h file.

      2. Whenever the user changes a custom slot's signature, TQt Designer updates the corresponding implementation.

      3. Whenever the user removes a custom slot, TQt Designer removes it from the .ui.h file.

        diff --git a/doc/html/designer-manual-6.html b/doc/html/designer-manual-6.html index efb9b3536..1b2e796d9 100644 --- a/doc/html/designer-manual-6.html +++ b/doc/html/designer-manual-6.html @@ -35,7 +35,7 @@ body { background: #ffffff; color: black; }

        Subclassing

        We'll start with a general description of how to subclass a form and follow with a short example. Note that subclassing has some disadvantages compared with putting your code into a form directly; see Extending the functionality of a form in The Designer Approach chapter for details.

        Generating Source Code from TQt Designer .ui Files

        -

        TQt Designer reads and writes qmake .pro (project) files which are used to record the files used to build the application and from which Makefiles are generated. TQt Designer also reads and writes .ui (user interface) files. These are XML files that record the widgets, layouts, source code and settings you've used for a form. Every .ui file is converted by the uic (user interface compiler) into a C++ .h file and a C++ .cpp file. These C++ files are then read by tqmoc (meta object compiler), and finally compiled by your compiler into a working application.

        +

        TQt Designer reads and writes qmake .pro (project) files which are used to record the files used to build the application and from which Makefiles are generated. TQt Designer also reads and writes .ui (user interface) files. These are XML files that record the widgets, layouts, source code and settings you've used for a form. Every .ui file is converted by the tquic (user interface compiler) into a C++ .h file and a C++ .cpp file. These C++ files are then read by tqmoc (meta object compiler), and finally compiled by your compiler into a working application.

        If you create applications wholly within TQt Designer you only need to create a main.cpp.

        If you create the main.cpp file within TQt Designer, it will automatically be added to your project file by TQt Designer. If you create the main.cpp file outside of TQt Designer you must add it to the project file manually by adding the following line at the end of your project's .pro file:

        diff --git a/doc/html/designer-manual-7.html b/doc/html/designer-manual-7.html
        index f01f5ff1c..70b9555ac 100644
        --- a/doc/html/designer-manual-7.html
        +++ b/doc/html/designer-manual-7.html
        @@ -107,7 +107,7 @@ DBFILE   = vcr.db
         

        Incorporating custom widgets that have their own slots and properties is achieved in a similar way to adding signals. All the required information is in our custom widget's header file.

        Creating Custom Widgets with Plugins

        This section will show you how to write a custom widget and how to embed the custom widget into a plugin. There are no restrictions or special considerations that must be taken into account when creating a widget that is destined to become a plugin. If you are an experienced TQt programmer you can safely skip the section on creating a custom widget and go directly to Creating a Plugin.

        -

        Be aware that if you use the plugin approach to custom widgets, the plugin needs to be available not only to TQt Designer but also to uic at compile-time.

        +

        Be aware that if you use the plugin approach to custom widgets, the plugin needs to be available not only to TQt Designer but also to tquic at compile-time.

        Creating a Custom Widget

        A custom widget is often a specialization (subclass) of another widget or a combination of widgets working together or a blend of both these approaches. If you simply want a collection of widgets in a particular configuration it is easiest to create them, select them as a group, and copy and paste them as required within TQt Designer. Custom widgets are generally created when you need to add new functionality to existing widgets or groups of widgets.

        We have two recommendations that you should consider when creating a custom widget for a plugin:

        diff --git a/doc/html/designer-manual-9.html b/doc/html/designer-manual-9.html index fb8c87814..9e3bab8f6 100644 --- a/doc/html/designer-manual-9.html +++ b/doc/html/designer-manual-9.html @@ -111,20 +111,20 @@ body { background: #ffffff; color: black; }

        If you wish to delete the add-in remove it from the toolbar then delete the qmsdev.dll file from the add-ins directory.

        Creating Makefiles without qmake

        The qmake tool provided with TQt can create Makefiles appropriate to your platform based on .pro project files. This section describes the dependencies involved in building a TQt application and gives a couple of simple example Makefiles. This section assumes that you have a good understanding of Makefiles.

        -

        TQt Designer produces .ui files which are used to generate .h and .cpp files for the compiler to compile. The .ui files are processed by uic. Classes which inherit from TQObject, e.g. those which use slots and signals, require an additional .cpp file to be generated. These files are generated by tqmoc and are named 'tqmoc_file.cpp' where the original .cpp file is called 'file.cpp'. If your .cpp file contains the TQ_OBJECT macro an additional file 'file.moc' should be generated which must be #included in the .cpp, normally at the end. This requires an extra dependency being created.

        -

        Processing .ui files with uic is done twice:

        +

        TQt Designer produces .ui files which are used to generate .h and .cpp files for the compiler to compile. The .ui files are processed by tquic. Classes which inherit from TQObject, e.g. those which use slots and signals, require an additional .cpp file to be generated. These files are generated by tqmoc and are named 'tqmoc_file.cpp' where the original .cpp file is called 'file.cpp'. If your .cpp file contains the TQ_OBJECT macro an additional file 'file.moc' should be generated which must be #included in the .cpp, normally at the end. This requires an extra dependency being created.

        +

        Processing .ui files with tquic is done twice:

        -uic myform.ui -o myform.h
        -uic myform.ui -i myform.h -o myform.cpp
        +tquic myform.ui -o myform.h
        +tquic myform.ui -i myform.h -o myform.cpp
         
        -

        The first execution creates the header file, the second creates the .cpp file. If you wish to subclass a form you can use uic to generate subclass skeletons:

        +

        The first execution creates the header file, the second creates the .cpp file. If you wish to subclass a form you can use tquic to generate subclass skeletons:

        -uic formbase.ui -o formbase.h
        -uic formbase.ui -i formbase.h -o formbase.cpp
        -uic -subdecl Form formbase.h formbase.ui -o form.h
        -uic -subimpl Form form.h formbase.ui -o form.cpp
        +tquic formbase.ui -o formbase.h
        +tquic formbase.ui -i formbase.h -o formbase.cpp
        +tquic -subdecl Form formbase.h formbase.ui -o form.h
        +tquic -subimpl Form form.h formbase.ui -o form.cpp
         
        -

        First we generate the header and implementation file for our base class. Then we generate the header and implementation skeletons for our subclass. Note that the use of uic to generate skeletons is not something that would be done in a Makefile, we mention it here because it can be useful for command line users. Note also that the command line for -subdecl and for -subimpl are subtly different.

        +

        First we generate the header and implementation file for our base class. Then we generate the header and implementation skeletons for our subclass. Note that the use of tquic to generate skeletons is not something that would be done in a Makefile, we mention it here because it can be useful for command line users. Note also that the command line for -subdecl and for -subimpl are subtly different.

        For implementation files that contain classes which inherit from TQObject we must create tqmoc files:

         tqmoc myform.h -o tqmoc_myform.cpp
        @@ -147,12 +147,12 @@ myform.o: myform.cpp
                 g++ -o myform.o myform.cpp
         
         myform.cpp: myform.h myform.ui
        -        uic myform.ui -i myform.h -o myform.cpp
        +        tquic myform.ui -i myform.h -o myform.cpp
         
         myform.h: myform.ui
        -        uic myform.ui -o myform.h
        +        tquic myform.ui -o myform.h
         
        -

        Note that you may need to include the full path to the commands in your Makefile, and under Windows the filenames are tqmoc.exe and uic.exe.

        +

        Note that you may need to include the full path to the commands in your Makefile, and under Windows the filenames are tqmoc.exe and tquic.exe.

        In Unix/Linux environments the make command may be able to do more for us, so we should be able to use a simpler Makefile like this:

         myapp: tqmoc_myform.o myform.o main.o
        @@ -165,10 +165,10 @@ tqmoc_%.cpp: %.h
                 tqmoc $^ -o $@
         
         myform.cpp: myform.h myform.ui
        -        uic myform.ui -i myform.h -o myform.cpp
        +        tquic myform.ui -i myform.h -o myform.cpp
         
         myform.h: myform.ui
        -        uic myform.ui -o myform.h
        +        tquic myform.ui -o myform.h
         

        To see more sophisticated Makefiles simply generate them using qmake on any of your TQt projects or any of the examples supplied with TQt.

        Importing Foreign File Formats

        diff --git a/doc/html/distributor-example.html b/doc/html/distributor-example.html index 78f39ab29..c5794404f 100644 --- a/doc/html/distributor-example.html +++ b/doc/html/distributor-example.html @@ -54,7 +54,7 @@ distributed with TQt.


        Implementation:

        /****************************************************************************
        -** ui.h extension file, included from the uic-generated form implementation.
        +** ui.h extension file, included from the tquic-generated form implementation.
         **
         ** If you wish to add, delete or rename functions or slots use
         ** TQt Designer which will update this file, preserving your code. Create an
        diff --git a/doc/html/extension-dialog-example.html b/doc/html/extension-dialog-example.html
        index 50a59bc91..b51c97977 100644
        --- a/doc/html/extension-dialog-example.html
        +++ b/doc/html/extension-dialog-example.html
        @@ -59,7 +59,7 @@ DBFILE          = extension.db
         


        Implementation:

        /****************************************************************************
        -** ui.h extension file, included from the uic-generated form implementation.
        +** ui.h extension file, included from the tquic-generated form implementation.
         **
         ** If you wish to add, delete or rename functions use TQt Designer which will
         ** update this file, preserving your code. Create an init() function in place
        @@ -107,7 +107,7 @@ void MainForm::quit()
         
        /****************************************************************************
        -** ui.h extension file, included from the uic-generated form implementation.
        +** ui.h extension file, included from the tquic-generated form implementation.
         **
         ** If you wish to add, delete or rename functions use TQt Designer which will
         ** update this file, preserving your code. Create an init() function in place
        @@ -133,7 +133,7 @@ void DialogForm::toggleDetails()
         
        /****************************************************************************
        -** ui.h extension file, included from the uic-generated form implementation.
        +** ui.h extension file, included from the tquic-generated form implementation.
         **
         ** If you wish to add, delete or rename functions use TQt Designer which will
         ** update this file, preserving your code. Create an init() function in place
        diff --git a/doc/html/ftpclient-example.html b/doc/html/ftpclient-example.html
        index fed20eb58..1488b35a6 100644
        --- a/doc/html/ftpclient-example.html
        +++ b/doc/html/ftpclient-example.html
        @@ -49,7 +49,7 @@ commands. The GUI parts are done in the Designer.
         
         /****************************************************************************
         **
        -** ui.h extension file, included from the uic-generated form implementation.
        +** ui.h extension file, included from the tquic-generated form implementation.
         **
         ** The init() function is used in place of a constructor.
         ** The destroy() function is used in place of a destructor.
        diff --git a/doc/html/index b/doc/html/index
        index 7b3504745..4f94b1562 100644
        --- a/doc/html/index
        +++ b/doc/html/index
        @@ -7806,7 +7806,7 @@
         "Trademarks" trademarks.html
         "Transformed Graphics Demo" xform-example.html
         "Tutorial #2" tutorial2.html
        -"User Interface Compiler (uic)" uic.html
        +"User Interface Compiler (tquic)" tquic.html
         "Using menus" menu-example.html
         "Using the Meta Object Compiler" tqmoc.html
         "Walkthrough: A Simple Application" simple-application.html
        diff --git a/doc/html/keyfeatures30.html b/doc/html/keyfeatures30.html
        index df56420a4..74006dae3 100644
        --- a/doc/html/keyfeatures30.html
        +++ b/doc/html/keyfeatures30.html
        @@ -281,7 +281,7 @@ to read and edit *.pro files, add and remove files to/from the project
         and do some global operations on the project. You can now open the
         project file and have one-click access to all the *.ui forms in the
         project.
        -

        In addition to generating code via uic, TQt Designer now supports the +

        In addition to generating code via tquic, TQt Designer now supports the dynamic creation of widgets directly from XML user interface description files (*.ui files) at runtime. This eliminates the need of recompiling your application when the GUI changes, and could be used diff --git a/doc/html/process-example.html b/doc/html/process-example.html index ccf76102c..f9d36bb7c 100644 --- a/doc/html/process-example.html +++ b/doc/html/process-example.html @@ -34,7 +34,7 @@ body { background: #ffffff; color: black; }

        This example shows you how to start other processes with TQt and how -IO redirection is done. The example tries to start the uic (a tool +IO redirection is done. The example tries to start the tquic (a tool that comes with the TQt Designer) on a certain ui file and displays the output of the command.


        @@ -91,8 +91,8 @@ private: // Set up the command and arguments. // On the command line you would do: - // uic -tr i18n "small_dialog.ui" - proc->addArgument( "uic" ); + // tquic -tr i18n "small_dialog.ui" + proc->addArgument( "tquic" ); proc->addArgument( "-tr" ); proc->addArgument( "i18n" ); proc->addArgument( "small_dialog.ui" ); @@ -106,7 +106,7 @@ private: // error handling TQMessageBox::critical( 0, tr("Fatal error"), - tr("Could not start the uic command."), + tr("Could not start the tquic command."), tr("Quit") ); exit( -1 ); } diff --git a/doc/html/qmake-manual-8.html b/doc/html/qmake-manual-8.html index 6b26c1eac..ce478a8ec 100644 --- a/doc/html/qmake-manual-8.html +++ b/doc/html/qmake-manual-8.html @@ -156,7 +156,7 @@ HEADERS = myclass.h \ INCLUDEPATH = c:\msdev\include d:\stl\include
        FORMS
        -

        This variable specifies the .ui files (see TQt Designer) to be processed through uic before compiling. All dependencies, headers and source files required to build these .ui files will automatically be added to the project.

        +

        This variable specifies the .ui files (see TQt Designer) to be processed through tquic before compiling. All dependencies, headers and source files required to build these .ui files will automatically be added to the project.

        For example:

         FORMS = mydialog.ui \
        @@ -192,21 +192,21 @@ unix:OBJECTS_DIR = ../myproject/tmp
         win32:OBJECTS__DIR = c:\myproject\tmp
         
        UI_DIR
        -

        This variable specifies the directory where all intermediate files from uic should be placed. This variable overrides both UI_SOURCES_DIR and UI_HEADERS_DIR.

        +

        This variable specifies the directory where all intermediate files from tquic should be placed. This variable overrides both UI_SOURCES_DIR and UI_HEADERS_DIR.

        For example:

         unix:UI_DIR = ../myproject/ui
         win32:UI_DIR = c:\myproject\ui
         
        UI_HEADERS_DIR
        -

        This variable specifies the directory where all declaration files (as generated by uic) should be placed.

        +

        This variable specifies the directory where all declaration files (as generated by tquic) should be placed.

        For example:

         unix:UI_HEADERS_DIR = ../myproject/ui/include
         win32:UI_HEADERS_DIR = c:\myproject\ui\include
         
        UI_SOURCES_DIR
        -

        This variable specifies the directory where all implementation files (as generated by uic) should be placed.

        +

        This variable specifies the directory where all implementation files (as generated by tquic) should be placed.

        For example:

         unix:UI_SOURCES_DIR = ../myproject/ui/src
        @@ -500,10 +500,10 @@ app {
         
        QMAKE_TARGET

        This variable contains the name of the project target. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

        QMAKE_UIC
        -

        This variable contains the location of uic if it is not in the path. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

        -

        It can be used to specify arguments to uic as well, such as additional plugin paths. For example:

        +

        This variable contains the location of tquic if it is not in the path. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

        +

        It can be used to specify arguments to tquic as well, such as additional plugin paths. For example:

        -        QMAKE_UIC = uic -L /path/to/plugin
        +        QMAKE_UIC = tquic -L /path/to/plugin
         
        RC_FILE

        This variable contains the name of the resource file for the application. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

        @@ -518,7 +518,7 @@ app {
        TARGET_x.y.z

        This variable specifies the target's extension with version number. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

        UICIMPLS
        -

        This variable contains a list of the generated implementation files by UIC. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

        +

        This variable contains a list of the generated implementation files by TQUIC. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

        UICOBJECTS

        This variable is generated from the UICIMPLS variable. The extension of each file will have been replaced by .o (Unix) or .obj (Win32). The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified.

        VER_MAJ
        diff --git a/doc/html/qt.dcf b/doc/html/qt.dcf index f4e2cae34..0f08678ea 100644 --- a/doc/html/qt.dcf +++ b/doc/html/qt.dcf @@ -9796,8 +9796,8 @@
        Tutorial #2
        -
        - User Interface Compiler (uic) +
        + User Interface Compiler (tquic)
        Using menus diff --git a/doc/html/titleindex b/doc/html/titleindex index 112430414..5e2f9628d 100644 --- a/doc/html/titleindex +++ b/doc/html/titleindex @@ -1001,7 +1001,7 @@ Toplevel Widgets | toplevel-example.html Trademarks | trademarks.html Transformed Graphics Demo | xform-example.html Tutorial #2 | tutorial2.html -User Interface Compiler (uic) | uic.html +User Interface Compiler (tquic) | tquic.html Using menus | menu-example.html Using the Meta Object Compiler | tqmoc.html Walkthrough: A Simple Application | simple-application.html diff --git a/doc/html/tools-list.html b/doc/html/tools-list.html index 52f0711f8..18dbc7485 100644 --- a/doc/html/tools-list.html +++ b/doc/html/tools-list.html @@ -47,7 +47,7 @@ help you need simple platform-independent project files
      4. qembed - convert data, e.g. images, into C++ code
      5. tqmoc - the Meta Object Compiler -
      6. uic - the User Interface Compiler +
      7. tquic - the User Interface Compiler
      8. qtconfig - a Unix-based TQt configuration tool with online help

    diff --git a/doc/html/tqprocess.html b/doc/html/tqprocess.html index 4a33ff03b..517b14669 100644 --- a/doc/html/tqprocess.html +++ b/doc/html/tqprocess.html @@ -131,14 +131,14 @@ program's process identifier is available from use tryTerminate(), but note that the program may ignore this. If you really want to terminate the program, without it having any chance to clean up, you can use kill(). -

    As an example, suppose we want to start the uic command (a TQt +

    As an example, suppose we want to start the tquic command (a TQt command line tool used with TQt Designer) and perform some -operations on the output (the uic outputs the code it generates +operations on the output (the tquic outputs the code it generates to standard output by default). Suppose further that we want to run the program on the file "small_dialog.ui" with the command line options "-tr i18n". On the command line we would write:

    -    uic -tr i18n small_dialog.ui
    +    tquic -tr i18n small_dialog.ui
         

    @@ -148,7 +148,7 @@ this:

        UicManager::UicManager()
         {
     
            proc = new TQProcess( this );
    -
            proc->addArgument( "uic" );
    +
            proc->addArgument( "tquic" );
             proc->addArgument( "-tr" );
             proc->addArgument( "i18n" );
             proc->addArgument( "small_dialog.ui" );
    diff --git a/doc/html/tquic.html b/doc/html/tquic.html
    new file mode 100644
    index 000000000..500e7d0cd
    --- /dev/null
    +++ b/doc/html/tquic.html
    @@ -0,0 +1,133 @@
    +
    +
    +
    +
    +
    +User Interface Compiler (tquic)
    +
    +
    +
    +
    +
    +
    +
    +
    + +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

    User Interface Compiler (tquic)

    + + + + +

    This page documents the User Interface Compiler for the TQt GUI +toolkit. The tquic reads a user interface definition +(.ui) file in XML as generated by TQt +Designer and creates corresponding C++ header or source files. +It can also generate an image file to embed raw image data in C++ +source code. +

    Options +

    +

    File Generation Options +

    +

    Generate declaration: +

    +tquic  [options]  <file>
    +
    + +

    Generate implementation: +

    +tquic  [options] -impl <headerfile> <file>
    +
    + +
      +
    • <headerfile> - name of the declaration file +
    +

    Generate image collection: +

    +tquic  [options] -embed <project> <image1> <image2> <image3> ...
    +
    + +
      +
    • <project> - project name +
    • <image[0..n]> - image files +
    +

    For convenience, tquic can also generate declaration or +implementation stubs for subclasses. +

    Generate subclass declaration: +

    +tquic  [options] -subdecl <classname> <headerfile> <file>
    +
    + +
      +
    • <classname> - name of the subclass to generate +
    • <headerfile> - declaration file of the baseclass +
    +

    Generate subclass implementation: +

    +tquic  [options] -subimpl <classname> <headerfile> <file>
    +
    + +
      +
    • <classname> - name of the subclass to generate +
    • <headerfile> - declaration file of the subclass +
    +

    General Options +

    +

      +
    • -o file - write output to 'file' rather than to stdout. +
    • -nofwd - omit forward declarations of custom classes in the +generated header file. This is necessary if typedef classes are used. +
    • -tr func - use func(sourceText, comment) rather than +trUtf8(sourceText, comment) for internationalization. +
    • -pch file - add #include "file" as the first statement in the implementation file. +
    +

    Usage +

    +

    tquic is almost always invoked by make (1), rather than by hand. +

    Here are useful makefile rules if you only use GNU make: +

    +    %.h: %.ui
    +        tquic $< -o $@
    +
    +    %.cpp: %.ui
    +        tquic -impl $*.h $< -o $@
    +
    + +If you want to write portably, you can use individual rules of the +following form: +
    +    NAME.h: NAME.ui
    +        tquic $< -o $@
    +
    +    NAME.cpp: NAME.ui
    +        tquic -impl $*.h $< -o $@
    +
    + +You must also remember to add NAME.cpp to your SOURCES (substitute +your favorite name) variable and NAME.o to your OBJECTS variable. +

    (While we prefer to name our C++ source files .cpp, the tquic doesn't +care, so you can use .C, .cc, .CC, .cxx or even .c++ if you prefer.) +

    + +


    + +
    Copyright © 2007 +TrolltechTrademarks +
    TQt 3.3.8
    +
    + diff --git a/doc/html/tqwidgetplugin.html b/doc/html/tqwidgetplugin.html index c0a07213b..4e939e72b 100644 --- a/doc/html/tqwidgetplugin.html +++ b/doc/html/tqwidgetplugin.html @@ -102,7 +102,7 @@ the custom widget of class key in the toolbar.

    TQString TQWidgetPlugin::includeFile ( const TQString & key ) const [virtual]

    -Returns the name of the include file that TQt Designer and uic should use to include the custom widget of class key in +Returns the name of the include file that TQt Designer and tquic should use to include the custom widget of class key in generated code.

    The default implementation returns TQString::null. diff --git a/doc/html/uic.html b/doc/html/uic.html deleted file mode 100644 index 58f20744b..000000000 --- a/doc/html/uic.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - - -User Interface Compiler (uic) - - - - - - - -
    - -Home - | -All Classes - | -Main Classes - | -Annotated - | -Grouped Classes - | -Functions -

    User Interface Compiler (uic)

    - - - - -

    This page documents the User Interface Compiler for the TQt GUI -toolkit. The uic reads a user interface definition -(.ui) file in XML as generated by TQt -Designer and creates corresponding C++ header or source files. -It can also generate an image file to embed raw image data in C++ -source code. -

    Options -

    -

    File Generation Options -

    -

    Generate declaration: -

    -uic  [options]  <file>
    -
    - -

    Generate implementation: -

    -uic  [options] -impl <headerfile> <file>
    -
    - -
      -
    • <headerfile> - name of the declaration file -
    -

    Generate image collection: -

    -uic  [options] -embed <project> <image1> <image2> <image3> ...
    -
    - -
      -
    • <project> - project name -
    • <image[0..n]> - image files -
    -

    For convenience, uic can also generate declaration or -implementation stubs for subclasses. -

    Generate subclass declaration: -

    -uic  [options] -subdecl <classname> <headerfile> <file>
    -
    - -
      -
    • <classname> - name of the subclass to generate -
    • <headerfile> - declaration file of the baseclass -
    -

    Generate subclass implementation: -

    -uic  [options] -subimpl <classname> <headerfile> <file>
    -
    - -
      -
    • <classname> - name of the subclass to generate -
    • <headerfile> - declaration file of the subclass -
    -

    General Options -

    -

      -
    • -o file - write output to 'file' rather than to stdout. -
    • -nofwd - omit forward declarations of custom classes in the -generated header file. This is necessary if typedef classes are used. -
    • -tr func - use func(sourceText, comment) rather than -trUtf8(sourceText, comment) for internationalization. -
    • -pch file - add #include "file" as the first statement in the implementation file. -
    -

    Usage -

    -

    uic is almost always invoked by make (1), rather than by hand. -

    Here are useful makefile rules if you only use GNU make: -

    -    %.h: %.ui
    -        uic $< -o $@
    -
    -    %.cpp: %.ui
    -        uic -impl $*.h $< -o $@
    -
    - -If you want to write portably, you can use individual rules of the -following form: -
    -    NAME.h: NAME.ui
    -        uic $< -o $@
    -
    -    NAME.cpp: NAME.ui
    -        uic -impl $*.h $< -o $@
    -
    - -You must also remember to add NAME.cpp to your SOURCES (substitute -your favorite name) variable and NAME.o to your OBJECTS variable. -

    (While we prefer to name our C++ source files .cpp, the uic doesn't -care, so you can use .C, .cc, .CC, .cxx or even .c++ if you prefer.) -

    - -


    - -
    Copyright © 2007 -TrolltechTrademarks -
    TQt 3.3.8
    -
    - diff --git a/doc/man/man1/tqdesigner.1 b/doc/man/man1/tqdesigner.1 index cb760d231..3b68b5dc2 100644 --- a/doc/man/man1/tqdesigner.1 +++ b/doc/man/man1/tqdesigner.1 @@ -33,7 +33,7 @@ relationship between the widgets of a dialog can be understood at a glance. Integrating dialogs into a TQt project is straightforward -thanks to the User Interface Compiler (UIC), which +thanks to the User Interface Compiler (TQUIC), which generates C++ code from the XML dialog description on the fly. The programmer can easily extend the functionality of the generated classes by subclassing without touching diff --git a/doc/man/man3/tqprocess.3qt b/doc/man/man3/tqprocess.3qt index c1f3ee1d3..43e99642c 100644 --- a/doc/man/man3/tqprocess.3qt +++ b/doc/man/man3/tqprocess.3qt @@ -149,7 +149,7 @@ As an example, suppose we want to start the \fCuic\fR command (a TQt command lin .PP .nf .br - uic -tr i18n small_dialog.ui + tquic -tr i18n small_dialog.ui .br .fi .PP @@ -169,7 +169,7 @@ A code snippet for this with the TQProcess class might look like this: .PP .nf .br - proc->addArgument( "uic" ); + proc->addArgument( "tquic" ); .br proc->addArgument( "-tr" ); .br diff --git a/doc/misc.doc b/doc/misc.doc index 05d351a54..b1b36e115 100644 --- a/doc/misc.doc +++ b/doc/misc.doc @@ -88,11 +88,11 @@ the relevant release of Qt.
    Meta Object Compiler and other tools - Compile time -
    Programmers need to run \e tqmoc and other tools such as \e uic. These +
    Programmers need to run \e tqmoc and other tools such as \e tquic. These tools are usually located in the \c bin subdirectory of TQt distributions. Either run \c "$TQTDIR"/bin/tqmoc and \c "$TQTDIR"/bin/tquic or add \c "$TQTDIR"/bin to your \c PATH and run \c tqmoc and \c tquic. If you use \c qmake the -appropriate lines will be added to your Makefiles so that \e uic and +appropriate lines will be added to your Makefiles so that \e tquic and \e tqmoc will be executed as required.
    Static or shared libraries - Link time diff --git a/doc/tquic.doc b/doc/tquic.doc new file mode 100644 index 000000000..78fefcabe --- /dev/null +++ b/doc/tquic.doc @@ -0,0 +1,100 @@ +/*! + \page tquic.html + \title User Interface Compiler (tquic) + + \omit KEEP THIS FILE SYNCHRONIZED WITH tquic.1 \endomit + +This page documents the \e{User Interface Compiler} for the TQt GUI +toolkit. The \e tquic reads a user interface definition +(.ui) file in XML as generated by \link designer-manual.book Qt +Designer\endlink and creates corresponding C++ header or source files. +It can also generate an image file to embed raw image data in C++ +source code. + +\section1 Options + +\section2 File Generation Options + +Generate declaration: +\code +tquic [options] +\endcode + +Generate implementation: +\code +tquic [options] -impl +\endcode +\list +\i \ - name of the declaration file +\endlist + +Generate image collection: +\code +tquic [options] -embed ... +\endcode +\list +\i \ - project name +\i \ - image files +\endlist + +For convenience, \e tquic can also generate declaration or +implementation stubs for subclasses. + +Generate subclass declaration: +\code +tquic [options] -subdecl +\endcode +\list +\i \ - name of the subclass to generate +\i \ - declaration file of the baseclass +\endlist + +Generate subclass implementation: +\code +tquic [options] -subimpl +\endcode +\list +\i \ - name of the subclass to generate +\i \ - declaration file of the subclass +\endlist + +\section2 General Options + +\list +\i \c{-o file} - write output to 'file' rather than to stdout. +\i \c{-nofwd} - omit forward declarations of custom classes in the +generated header file. This is necessary if typedef classes are used. +\i \c{-tr func} - use \c{func(sourceText, comment)} rather than +trUtf8(sourceText, comment) for internationalization. +\i \c{-pch file} - add \c{#include "file"} as the first statement in the implementation file. +\endlist + +\section1 Usage + +\e tquic is almost always invoked by \c{make (1)}, rather than by hand. + +Here are useful makefile rules if you only use GNU make: +\code + %.h: %.ui + tquic $< -o $@ + + %.cpp: %.ui + tquic -impl $*.h $< -o $@ +\endcode +If you want to write portably, you can use individual rules of the +following form: +\code + NAME.h: NAME.ui + tquic $< -o $@ + + NAME.cpp: NAME.ui + tquic -impl $*.h $< -o $@ +\endcode +You must also remember to add \c{NAME.cpp} to your SOURCES (substitute +your favorite name) variable and \c{NAME.o} to your OBJECTS variable. + +(While we prefer to name our C++ source files .cpp, the \e tquic doesn't +care, so you can use .C, .cc, .CC, .cxx or even .c++ if you prefer.) + + +*/ diff --git a/doc/uic.doc b/doc/uic.doc deleted file mode 100644 index 04c790955..000000000 --- a/doc/uic.doc +++ /dev/null @@ -1,100 +0,0 @@ -/*! - \page uic.html - \title User Interface Compiler (uic) - - \omit KEEP THIS FILE SYNCHRONIZED WITH uic.1 \endomit - -This page documents the \e{User Interface Compiler} for the TQt GUI -toolkit. The \e uic reads a user interface definition -(.ui) file in XML as generated by \link designer-manual.book Qt -Designer\endlink and creates corresponding C++ header or source files. -It can also generate an image file to embed raw image data in C++ -source code. - -\section1 Options - -\section2 File Generation Options - -Generate declaration: -\code -uic [options] -\endcode - -Generate implementation: -\code -uic [options] -impl -\endcode -\list -\i \ - name of the declaration file -\endlist - -Generate image collection: -\code -uic [options] -embed ... -\endcode -\list -\i \ - project name -\i \ - image files -\endlist - -For convenience, \e uic can also generate declaration or -implementation stubs for subclasses. - -Generate subclass declaration: -\code -uic [options] -subdecl -\endcode -\list -\i \ - name of the subclass to generate -\i \ - declaration file of the baseclass -\endlist - -Generate subclass implementation: -\code -uic [options] -subimpl -\endcode -\list -\i \ - name of the subclass to generate -\i \ - declaration file of the subclass -\endlist - -\section2 General Options - -\list -\i \c{-o file} - write output to 'file' rather than to stdout. -\i \c{-nofwd} - omit forward declarations of custom classes in the -generated header file. This is necessary if typedef classes are used. -\i \c{-tr func} - use \c{func(sourceText, comment)} rather than -trUtf8(sourceText, comment) for internationalization. -\i \c{-pch file} - add \c{#include "file"} as the first statement in the implementation file. -\endlist - -\section1 Usage - -\e uic is almost always invoked by \c{make (1)}, rather than by hand. - -Here are useful makefile rules if you only use GNU make: -\code - %.h: %.ui - uic $< -o $@ - - %.cpp: %.ui - uic -impl $*.h $< -o $@ -\endcode -If you want to write portably, you can use individual rules of the -following form: -\code - NAME.h: NAME.ui - uic $< -o $@ - - NAME.cpp: NAME.ui - uic -impl $*.h $< -o $@ -\endcode -You must also remember to add \c{NAME.cpp} to your SOURCES (substitute -your favorite name) variable and \c{NAME.o} to your OBJECTS variable. - -(While we prefer to name our C++ source files .cpp, the \e uic doesn't -care, so you can use .C, .cc, .CC, .cxx or even .c++ if you prefer.) - - -*/ diff --git a/examples/demo/opengl/gllandscapeviewer.ui.h b/examples/demo/opengl/gllandscapeviewer.ui.h index c82acdc09..7b9ece379 100644 --- a/examples/demo/opengl/gllandscapeviewer.ui.h +++ b/examples/demo/opengl/gllandscapeviewer.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/examples/demo/opengl/printpreview.ui.h b/examples/demo/opengl/printpreview.ui.h index fd19c2c4b..6f7b9dae7 100644 --- a/examples/demo/opengl/printpreview.ui.h +++ b/examples/demo/opengl/printpreview.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions respectively slots use ** TQt Designer which will update this file, preserving your code. Create an diff --git a/examples/demo/sql/connect.ui.h b/examples/demo/sql/connect.ui.h index b6a3d21fd..f3570b162 100644 --- a/examples/demo/sql/connect.ui.h +++ b/examples/demo/sql/connect.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/examples/demo/sql/sqlex.ui.h b/examples/demo/sql/sqlex.ui.h index 9c722760f..e14559c98 100644 --- a/examples/demo/sql/sqlex.ui.h +++ b/examples/demo/sql/sqlex.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/examples/distributor/distributor.ui.h b/examples/distributor/distributor.ui.h index e4045080a..1c1ee2b8f 100644 --- a/examples/distributor/distributor.ui.h +++ b/examples/distributor/distributor.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions or slots use ** TQt Designer which will update this file, preserving your code. Create an diff --git a/examples/extension/dialogform.ui.h b/examples/extension/dialogform.ui.h index d6f873f33..6cfc98410 100644 --- a/examples/extension/dialogform.ui.h +++ b/examples/extension/dialogform.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions use TQt Designer which will ** update this file, preserving your code. Create an init() function in place diff --git a/examples/extension/extension.ui.h b/examples/extension/extension.ui.h index e43b8f3fd..e126094a6 100644 --- a/examples/extension/extension.ui.h +++ b/examples/extension/extension.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions use TQt Designer which will ** update this file, preserving your code. Create an init() function in place diff --git a/examples/extension/mainform.ui.h b/examples/extension/mainform.ui.h index 3ea3d5ed8..6ff472c56 100644 --- a/examples/extension/mainform.ui.h +++ b/examples/extension/mainform.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions use TQt Designer which will ** update this file, preserving your code. Create an init() function in place diff --git a/examples/network/archivesearch/archivedialog.ui.h b/examples/network/archivesearch/archivedialog.ui.h index 45c4553ee..34467aaa3 100644 --- a/examples/network/archivesearch/archivedialog.ui.h +++ b/examples/network/archivesearch/archivedialog.ui.h @@ -8,7 +8,7 @@ *****************************************************************************/ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions or slots use ** TQt Designer which will update this file, preserving your code. Create an diff --git a/examples/network/ftpclient/ftpmainwindow.ui.h b/examples/network/ftpclient/ftpmainwindow.ui.h index d57b0b9f0..ce6ff78b2 100644 --- a/examples/network/ftpclient/ftpmainwindow.ui.h +++ b/examples/network/ftpclient/ftpmainwindow.ui.h @@ -9,7 +9,7 @@ /**************************************************************************** ** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** The init() function is used in place of a constructor. ** The destroy() function is used in place of a destructor. diff --git a/examples/process/README b/examples/process/README index 10b9ed710..420faa557 100644 --- a/examples/process/README +++ b/examples/process/README @@ -1,8 +1,8 @@ The process example is not particularly useful, but it shows a typical use of the class TQProcess. -This example starts the uic command with some options and displays the -output of the uic call. The uic is a command line tool that is used if you +This example starts the tquic command with some options and displays the +output of the tquic call. The tquic is a command line tool that is used if you create dialogs with the TQt Designer. If you installed TQt correctly, it should be available on your system. It outputs the generated code to standard output by default. diff --git a/examples/process/process.cpp b/examples/process/process.cpp index 52da5b92f..1365b5b0d 100644 --- a/examples/process/process.cpp +++ b/examples/process/process.cpp @@ -49,8 +49,8 @@ UicManager::UicManager() // Set up the command and arguments. // On the command line you would do: - // uic -tr i18n "small_dialog.ui" - proc->addArgument( "uic" ); + // tquic -tr i18n "small_dialog.ui" + proc->addArgument( "tquic" ); proc->addArgument( "-tr" ); proc->addArgument( "i18n" ); proc->addArgument( "small_dialog.ui" ); @@ -64,7 +64,7 @@ UicManager::UicManager() // error handling TQMessageBox::critical( 0, tr("Fatal error"), - tr("Could not start the uic command."), + tr("Could not start the tquic command."), tr("Quit") ); exit( -1 ); } diff --git a/examples/process/process.doc b/examples/process/process.doc index 5faa066cc..72c9917fa 100644 --- a/examples/process/process.doc +++ b/examples/process/process.doc @@ -8,7 +8,7 @@ \title Starting processes with IO redirection This example shows you how to start other processes with TQt and how - IO redirection is done. The example tries to start the uic (a tool + IO redirection is done. The example tries to start the tquic (a tool that comes with the TQt Designer) on a certain ui file and displays the output of the command. diff --git a/mkspecs/win32-borland/qmake.conf b/mkspecs/win32-borland/qmake.conf index d43424761..8d58b0e8f 100644 --- a/mkspecs/win32-borland/qmake.conf +++ b/mkspecs/win32-borland/qmake.conf @@ -89,7 +89,7 @@ QMAKE_LIBS_OPENGL = QMAKE_LFLAGS_OPENGL = /dopengl32.dll QMAKE_MOC = $(TQTDIR)\bin\tqmoc.exe -QMAKE_UIC = $(TQTDIR)\bin\uic.exe +QMAKE_UIC = $(TQTDIR)\bin\tquic.exe QMAKE_IDC = $(TQTDIR)\bin\idc.exe QMAKE_IDL = midl diff --git a/mkspecs/win32-g++/qmake.conf b/mkspecs/win32-g++/qmake.conf index 4e79b3c8d..bef50fa70 100644 --- a/mkspecs/win32-g++/qmake.conf +++ b/mkspecs/win32-g++/qmake.conf @@ -78,7 +78,7 @@ QMAKE_LIBS_QT_ENTRY = -lqtmain QMAKE_LIBS_OPENGL = -lopengl32 -lglu32 QMAKE_MOC = $(TQTDIR)\bin\tqmoc.exe -QMAKE_UIC = $(TQTDIR)\bin\uic.exe +QMAKE_UIC = $(TQTDIR)\bin\tquic.exe QMAKE_IDC = $(TQTDIR)\bin\idc.exe QMAKE_IDL = midl diff --git a/mkspecs/win32-icc/qmake.conf b/mkspecs/win32-icc/qmake.conf index 3f182ef08..27590c3ef 100644 --- a/mkspecs/win32-icc/qmake.conf +++ b/mkspecs/win32-icc/qmake.conf @@ -86,7 +86,7 @@ QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib delayimp.lib QMAKE_LFLAGS_OPENGL = /DELAYLOAD:opengl32.dll QMAKE_MOC = $(TQTDIR)\bin\tqmoc.exe -QMAKE_UIC = $(TQTDIR)\bin\uic.exe +QMAKE_UIC = $(TQTDIR)\bin\tquic.exe QMAKE_IDC = $(TQTDIR)\bin\idc.exe QMAKE_IDL = midl diff --git a/mkspecs/win32-msvc.net/qmake.conf b/mkspecs/win32-msvc.net/qmake.conf index 9f597286a..eefcbe09a 100644 --- a/mkspecs/win32-msvc.net/qmake.conf +++ b/mkspecs/win32-msvc.net/qmake.conf @@ -86,7 +86,7 @@ QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib QMAKE_LFLAGS_OPENGL = /DELAYLOAD:opengl32.dll QMAKE_MOC = $(TQTDIR)\bin\tqmoc.exe -QMAKE_UIC = $(TQTDIR)\bin\uic.exe +QMAKE_UIC = $(TQTDIR)\bin\tquic.exe QMAKE_IDC = $(TQTDIR)\bin\idc.exe QMAKE_IDL = midl diff --git a/mkspecs/win32-msvc/qmake.conf b/mkspecs/win32-msvc/qmake.conf index 49eba4171..d824b958b 100644 --- a/mkspecs/win32-msvc/qmake.conf +++ b/mkspecs/win32-msvc/qmake.conf @@ -86,7 +86,7 @@ QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib delayimp.lib QMAKE_LFLAGS_OPENGL = /DELAYLOAD:opengl32.dll QMAKE_MOC = $(TQTDIR)\bin\tqmoc.exe -QMAKE_UIC = $(TQTDIR)\bin\uic.exe +QMAKE_UIC = $(TQTDIR)\bin\tquic.exe QMAKE_IDC = $(TQTDIR)\bin\idc.exe QMAKE_IDL = midl diff --git a/mkspecs/win32-msvc2005/qmake.conf b/mkspecs/win32-msvc2005/qmake.conf index bacaffade..141657e02 100644 --- a/mkspecs/win32-msvc2005/qmake.conf +++ b/mkspecs/win32-msvc2005/qmake.conf @@ -88,7 +88,7 @@ QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib QMAKE_LFLAGS_OPENGL = /DELAYLOAD:opengl32.dll QMAKE_MOC = $(TQTDIR)\bin\tqmoc.exe -QMAKE_UIC = $(TQTDIR)\bin\uic.exe +QMAKE_UIC = $(TQTDIR)\bin\tquic.exe QMAKE_IDC = $(TQTDIR)\bin\idc.exe QMAKE_IDL = midl diff --git a/qmake/book/qmake-commandreference.leaf b/qmake/book/qmake-commandreference.leaf index 965d96190..ee2584972 100644 --- a/qmake/book/qmake-commandreference.leaf +++ b/qmake/book/qmake-commandreference.leaf @@ -336,7 +336,7 @@ For example: \section3 FORMS This variable specifies the .ui files (see \link -designer-manual.book TQt Designer \endlink) to be processed through \e uic +designer-manual.book TQt Designer \endlink) to be processed through \e tquic before compiling. All dependencies, headers and source files required to build these .ui files will automatically be added to the project. @@ -415,7 +415,7 @@ win32:OBJECTS__DIR = c:\myproject\tmp \target UI_DIR \section3 UI_DIR -This variable specifies the directory where all intermediate files from uic +This variable specifies the directory where all intermediate files from tquic should be placed. This variable overrides both UI_SOURCES_DIR and UI_HEADERS_DIR. @@ -430,7 +430,7 @@ win32:UI_DIR = c:\myproject\ui \section3 UI_HEADERS_DIR This variable specifies the directory where all declaration files (as -generated by uic) should be placed. +generated by tquic) should be placed. For example: @@ -443,7 +443,7 @@ win32:UI_HEADERS_DIR = c:\myproject\ui\include \section3 UI_SOURCES_DIR This variable specifies the directory where all implementation files (as generated -by uic) should be placed. +by tquic) should be placed. For example: @@ -1572,15 +1572,15 @@ this variable is typically handled by \e qmake or \section3 QMAKE_UIC -This variable contains the location of uic if it is not in the path. +This variable contains the location of tquic if it is not in the path. The value of this variable is typically handled by \e qmake or \link #QMAKESPEC qmake.conf \endlink and rarely needs to be modified. -It can be used to specify arguments to uic as well, such as additional plugin +It can be used to specify arguments to tquic as well, such as additional plugin paths. For example: \code - QMAKE_UIC = uic -L /path/to/plugin + QMAKE_UIC = tquic -L /path/to/plugin \endcode @@ -1634,7 +1634,7 @@ modified. \section3 UICIMPLS -This variable contains a list of the generated implementation files by UIC. +This variable contains a list of the generated implementation files by TQUIC. The value of this variable is typically handled by \e qmake or \link #QMAKESPEC qmake.conf \endlink and rarely needs to be modified. diff --git a/qmake/book/qmake-preface.leaf b/qmake/book/qmake-preface.leaf index 59230c092..b716903f6 100644 --- a/qmake/book/qmake-preface.leaf +++ b/qmake/book/qmake-preface.leaf @@ -15,4 +15,4 @@ uses \e qmake as the primary build tool for the TQt library, and for the tools supplied with Qt. \e qmake also takes care of Qt's special requirements, automatically -including build rules for \link tqmoc.html tqmoc\endlink and \e uic. +including build rules for \link tqmoc.html tqmoc\endlink and \e tquic. diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index efd17ee62..691dc4306 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -403,7 +403,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(TQTextStream &t) else if(srcs[i] == "SRCMOC") src_group = "Sources [moc]"; else if(srcs[i] == "UICIMPLS" || srcs[i] == "FORMS") - src_group = "Sources [uic]"; + src_group = "Sources [tquic]"; else if(srcs[i] == "QMAKE_IMAGE_COLLECTION") src_group = "Sources [images]"; else if(srcs[i] == "QMAKE_INTERNAL_INCLUDED_FILES") @@ -545,7 +545,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(TQTextStream &t) TQTextStream mkt(&mkf); writeHeader(mkt); mkt << "MOC = " << Option::fixPathToTargetOS(var("QMAKE_MOC")) << endl; - mkt << "UIC = " << Option::fixPathToTargetOS(var("QMAKE_UIC")) << endl; + mkt << "TQUIC = " << Option::fixPathToTargetOS(var("QMAKE_UIC")) << endl; mkt << "LEX = " << var("QMAKE_LEX") << endl; mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; mkt << "YACC = " << var("QMAKE_YACC") << endl; diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index c4c42343f..02fa74c53 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1616,7 +1616,7 @@ MakefileGenerator::writeUicSrc(TQTextStream &t, const TQString &ui) deps.remove(decl); //avoid circular dependencies.. t << decl << ": " << (*it) << " "; t << deps.join(" \\\n\t\t") << "\n\t" - << "$(UIC) " << (*it) << " -o " << decl << endl << endl; + << "$(TQUIC) " << (*it) << " -o " << decl << endl << endl; TQString mildDecl = decl; int k = mildDecl.findRev(Option::dir_sep); @@ -1626,7 +1626,7 @@ MakefileGenerator::writeUicSrc(TQTextStream &t, const TQString &ui) if(TQFile::exists((*it) + Option::h_ext.first())) t << (*it) << Option::h_ext.first() << " "; t << deps.join(" \\\n\t\t") << "\n\t" - << "$(UIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl; + << "$(TQUIC) " << (*it) << " -i " << mildDecl << " -o " << impl << endl << endl; } } @@ -1807,15 +1807,15 @@ MakefileGenerator::writeImageSrc(TQTextStream &t, const TQString &src) TQString gen = project->first("MAKEFILE_GENERATOR"); if ( gen == "MSVC" ) { t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" - << "$(UIC) -o " << (*it) << " -embed " << project->first("QMAKE_ORIG_TARGET") + << "$(TQUIC) -o " << (*it) << " -embed " << project->first("QMAKE_ORIG_TARGET") << " -f <<\n" << findDependencies((*it)).join(" ") << "\n<<" << endl << endl; } else if ( gen == "BMAKE" ) { t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" - << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET") + << "$(TQUIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET") << " -f &&|\n" << findDependencies((*it)).join(" ") << "\n| -o " << (*it) << endl << endl; } else { t << (*it) << ": " << findDependencies((*it)).join(" \\\n\t\t") << "\n\t" - << "$(UIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET") + << "$(TQUIC) " << " -embed " << project->first("QMAKE_ORIG_TARGET") << " " << findDependencies((*it)).join(" ") << " -o " << (*it) << endl << endl; } } diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index c117a2d29..af0707441 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -182,7 +182,7 @@ UnixMakefileGenerator::writeMakeParts(TQTextStream &t) t << "AR = " << var("QMAKE_AR") << endl; t << "RANLIB = " << var("QMAKE_RANLIB") << endl; t << "MOC = " << var("QMAKE_MOC") << endl; - t << "UIC = " << var("QMAKE_UIC") << endl; + t << "TQUIC = " << var("QMAKE_UIC") << endl; t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? TQString("tqmake") : var("QMAKE_QMAKE")) << endl; t << "TAR = " << var("QMAKE_TAR") << endl; t << "GZIP = " << var("QMAKE_GZIP") << endl; diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp index 4e97ba527..c7d94e51f 100644 --- a/qmake/generators/win32/borland_bmake.cpp +++ b/qmake/generators/win32/borland_bmake.cpp @@ -117,7 +117,7 @@ BorlandMakefileGenerator::writeBorlandParts(TQTextStream &t) } t << "MOC = " << (project->isEmpty("QMAKE_MOC") ? TQString("moc") : Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; - t << "UIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("uic") : + t << "TQUIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("tquic") : Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? TQString("qmake") : Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index e59e7e3a2..a63d6454d 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -137,7 +137,7 @@ MingwMakefileGenerator::writeMingwParts(TQTextStream &t) } t << "MOC = " << (project->isEmpty("QMAKE_MOC") ? TQString("moc") : Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; - t << "UIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("uic") : + t << "TQUIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("tquic") : Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? TQString("qmake") : Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp index 988d4632d..568ff616f 100644 --- a/qmake/generators/win32/msvc_dsp.cpp +++ b/qmake/generators/win32/msvc_dsp.cpp @@ -365,7 +365,7 @@ DspMakefileGenerator::writeDspParts(TQTextStream &t) list.sort(); TQStringList::Iterator it; - // dump the image list to a file UIC can read. + // dump the image list to a file TQUIC can read. TQFile f( "images.tmp" ); f.open( IO_WriteOnly ); TQTextStream ts( &f ); @@ -464,7 +464,7 @@ DspMakefileGenerator::writeDspParts(TQTextStream &t) t << "USERDEP_" << base << "=\"$(TQTDIR)\\bin\\tqmoc.exe\" \"$(TQTDIR)\\bin\\tquic.exe\"" << endl << endl; - TQString build = "\n\n# Begin Custom Build - Uic'ing " + base + "...\n" + TQString build = "\n\n# Begin Custom Build - TQUic'ing " + base + "...\n" "InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base + " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath + base + " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n" diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index b95289f89..7dafb1f60 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -147,7 +147,7 @@ NmakeMakefileGenerator::writeNmakeParts(TQTextStream &t) } t << "MOC = " << (project->isEmpty("QMAKE_MOC") ? TQString("moc") : Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; - t << "UIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("uic") : + t << "TQUIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("tquic") : Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? TQString("qmake") : Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 1683de57d..1b17cdfde 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -1949,7 +1949,7 @@ void VCFilter::addUICstage( TQTextStream & /*strm*/, TQString str ) if ( mocDir.isEmpty() ) mocDir = pname; - CustomBuildTool.Description = ("Uic'ing " + str + "...\""); + CustomBuildTool.Description = ("TQUic'ing " + str + "...\""); CustomBuildTool.CommandLine += // Create .h from .ui file uicApp + " " + str + " -o " + uiHeaders + fname + ".h"; CustomBuildTool.CommandLine += // Create .cpp from .ui file @@ -2011,8 +2011,8 @@ bool VCFilter::addIMGstage( TQTextStream &/*strm*/, TQString str ) useCustomBuildTool = TRUE; // Some projects (like designer core) may have too many images to - // call uic directly. Therefor we have to create a temporary - // file, with the image list, and call uic with the -f option. + // call tquic directly. Therefor we have to create a temporary + // file, with the image list, and call tquic with the -f option. TQString tmpFileCmd = "echo "; TQString tmpImageFilename = ".imgcol"; TQStringList& list = Project->project->variables()["IMAGES"]; @@ -2139,10 +2139,10 @@ TQTextStream &operator<<( TQTextStream &strm, VCFilter &tool ) tool.useCustomBuildTool = FALSE; tool.useCompilerTool = FALSE; - // Add UIC, MOC and PCH stages to file + // Add TQUIC, MOC and PCH stages to file if ( tool.CustomBuild == moc ) tool.addMOCstage( strm, *it ); - else if ( tool.CustomBuild == uic ) + else if ( tool.CustomBuild == tquic ) tool.addUICstage( strm, *it ); else if ( tool.CustomBuild == lexyacc ) tool.addLexYaccStage( strm, *it ); diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index fc2a39e20..1141e8a9c 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -66,7 +66,7 @@ enum DotNET { enum customBuildCheck { none, moc, - uic, + tquic, lexyacc, resource }; diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index df6001580..128811ef9 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -358,9 +358,9 @@ void VcprojGenerator::writeSubDirs(TQTextStream &t) if(newDep->target.endsWith(".dll")) newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; - // All projects using Forms are dependent on uic.exe + // All projects using Forms are dependent on tquic.exe if(!tmp_proj.isEmpty("FORMS")) - newDep->dependencies << "uic.exe"; + newDep->dependencies << "tquic.exe"; // Add all unknown libs to the deps TQStringList where("QMAKE_LIBS"); @@ -970,7 +970,7 @@ void VcprojGenerator::initFormsFiles() vcProject.FormFiles.flat_files ); vcProject.FormFiles.Project = this; vcProject.FormFiles.Config = &(vcProject.Configuration); - vcProject.FormFiles.CustomBuild = uic; + vcProject.FormFiles.CustomBuild = tquic; } void VcprojGenerator::initTranslationFiles() diff --git a/src/kernel/tqcolor_x11.cpp b/src/kernel/tqcolor_x11.cpp index 09a8b8880..fe5f6685c 100644 --- a/src/kernel/tqcolor_x11.cpp +++ b/src/kernel/tqcolor_x11.cpp @@ -631,7 +631,7 @@ void TQColor::setSystemNamedColor( const TQString& name ) // setSystemNamedColor should look up rgb values from the built in // color tables first (see tqcolor_p.cpp), and failing that, use // the window system's interface for translating names to rgb values... - // we do this so that things like uic can load an XPM file with named colors + // we do this so that things like tquic can load an XPM file with named colors // and convert it to a png without having to use window system functions... d.argb = qt_get_rgb_val( name.latin1() ); TQRgb rgb; diff --git a/src/kernel/tqprocess.cpp b/src/kernel/tqprocess.cpp index db2318a30..bfca757a8 100644 --- a/src/kernel/tqprocess.cpp +++ b/src/kernel/tqprocess.cpp @@ -109,14 +109,14 @@ you \e really want to terminate the program, without it having any chance to clean up, you can use kill(). - As an example, suppose we want to start the \c uic command (a TQt + As an example, suppose we want to start the \c tquic command (a TQt command line tool used with \e{TQt Designer}) and perform some - operations on the output (the \c uic outputs the code it generates + operations on the output (the \c tquic outputs the code it generates to standard output by default). Suppose further that we want to run the program on the file "small_dialog.ui" with the command line options "-tr i18n". On the command line we would write: \code - uic -tr i18n small_dialog.ui + tquic -tr i18n small_dialog.ui \endcode \quotefile process/process.cpp @@ -129,7 +129,7 @@ \printline { \skipto proc = new TQProcess( this ); \printline proc = new TQProcess( this ); - \skipto proc->addArgument( "uic" ); + \skipto proc->addArgument( "tquic" ); \printuntil this, TQ_SLOT(readFromStdout()) ); \skipto if ( !proc->start() ) { \printuntil // error handling diff --git a/src/widgets/tqwidgetinterface_p.h b/src/widgets/tqwidgetinterface_p.h index 81a158cc5..9638a084e 100644 --- a/src/widgets/tqwidgetinterface_p.h +++ b/src/widgets/tqwidgetinterface_p.h @@ -91,7 +91,7 @@ public: virtual TQIconSet iconSet( const TQString &widget ) const = 0; /*! In the implementation return the include file which is needed - for the widget \a widget in the generated code which uic + for the widget \a widget in the generated code which tquic generates. */ virtual TQString includeFile( const TQString &widget ) const = 0; diff --git a/src/widgets/tqwidgetplugin.cpp b/src/widgets/tqwidgetplugin.cpp index a12f13418..5508ac7f0 100644 --- a/src/widgets/tqwidgetplugin.cpp +++ b/src/widgets/tqwidgetplugin.cpp @@ -393,7 +393,7 @@ TQIconSet TQWidgetPlugin::iconSet( const TQString & ) const /*! Returns the name of the include file that \e{TQt Designer} and \c - uic should use to include the custom widget of class \a key in + tquic should use to include the custom widget of class \a key in generated code. The default implementation returns TQString::null. @@ -702,7 +702,7 @@ TQWidgetList TQWidgetContainerPlugin::pages( const TQString &, TQWidget * ) cons Operates on the plugin's \a key class. This function is called from \e{TQt Designer}'s User Interface - Compiler \c uic, when generating C++ code for inserting a page in + Compiler \c tquic, when generating C++ code for inserting a page in the \a container custom widget. The name of the page widget which should be inserted at the end of the container is \a page, and the label of the page should be \a pageName. @@ -715,7 +715,7 @@ TQWidgetList TQWidgetContainerPlugin::pages( const TQString &, TQWidget * ) cons \endcode Warning: If the code returned by this function contains invalid - C++ syntax, the generated \c uic code will not compile. + C++ syntax, the generated \c tquic code will not compile. */ TQString TQWidgetContainerPlugin::createCode( const TQString &, const TQString &, diff --git a/tools/assistant/tabbedbrowser.ui.h b/tools/assistant/tabbedbrowser.ui.h index 425840d3b..68513fb90 100644 --- a/tools/assistant/tabbedbrowser.ui.h +++ b/tools/assistant/tabbedbrowser.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions or slots use ** TQt Designer which will update this file, preserving your code. Create an diff --git a/tools/designer/designer.pro b/tools/designer/designer.pro index bbe68ada4..21646f891 100644 --- a/tools/designer/designer.pro +++ b/tools/designer/designer.pro @@ -2,7 +2,7 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = uic \ +SUBDIRS = tquic \ uilib \ designer \ app \ diff --git a/tools/designer/designer/connectiondialog.ui.h b/tools/designer/designer/connectiondialog.ui.h index 010a5c193..6c4951b67 100644 --- a/tools/designer/designer/connectiondialog.ui.h +++ b/tools/designer/designer/connectiondialog.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/tools/designer/designer/designer_de.ts b/tools/designer/designer/designer_de.ts index 0461b3044..f92fe096d 100644 --- a/tools/designer/designer/designer_de.ts +++ b/tools/designer/designer/designer_de.ts @@ -1353,7 +1353,7 @@ filename '%1'. Please choose a new filename. - <b>Enter the name of the class that will be created.</b><p><em>classname.h</em> and <em>classname.cpp</em> will be generated as C++-output when it is compiled with the uic.</p> + <b>Enter the name of the class that will be created.</b><p><em>classname.h</em> and <em>classname.cpp</em> will be generated as C++-output when it is compiled with the tquic.</p> diff --git a/tools/designer/designer/designer_fr.ts b/tools/designer/designer/designer_fr.ts index c31eba6b0..a185365c4 100644 --- a/tools/designer/designer/designer_fr.ts +++ b/tools/designer/designer/designer_fr.ts @@ -1351,7 +1351,7 @@ filename '%1'. Please choose a new filename. - <b>Enter the name of the class that will be created.</b><p><em>classname.h</em> and <em>classname.cpp</em> will be generated as C++-output when it is compiled with the uic.</p> + <b>Enter the name of the class that will be created.</b><p><em>classname.h</em> and <em>classname.cpp</em> will be generated as C++-output when it is compiled with the tquic.</p> diff --git a/tools/designer/designer/formfile.cpp b/tools/designer/designer/formfile.cpp index 322dcff19..2870f57c5 100644 --- a/tools/designer/designer/formfile.cpp +++ b/tools/designer/designer/formfile.cpp @@ -509,7 +509,7 @@ TQString FormFile::codeExtension() const TQString FormFile::codeComment() const { return TQString( "/****************************************************************************\n" - "** ui.h extension file, included from the uic-generated form implementation.\n" + "** ui.h extension file, included from the tquic-generated form implementation.\n" "**\n" "** If you want to add, delete, or rename functions or slots, use\n" "** TQt Designer to update this file, preserving your code.\n" diff --git a/tools/designer/designer/formsettings.ui b/tools/designer/designer/formsettings.ui index 7b605aa6f..535a53f1c 100644 --- a/tools/designer/designer/formsettings.ui +++ b/tools/designer/designer/formsettings.ui @@ -173,7 +173,7 @@ Change class name - <b>Enter the name of the class that will be created.</b><p><em>classname.h</em> and <em>classname.cpp</em> will be generated as C++ output when it is compiled by uic.</p> + <b>Enter the name of the class that will be created.</b><p><em>classname.h</em> and <em>classname.cpp</em> will be generated as C++ output when it is compiled by tquic.</p> diff --git a/tools/designer/designer/formwindow.cpp b/tools/designer/designer/formwindow.cpp index a5451bdd8..8b7514f7f 100644 --- a/tools/designer/designer/formwindow.cpp +++ b/tools/designer/designer/formwindow.cpp @@ -1834,7 +1834,7 @@ bool FormWindow::checkCustomWidgets() "but are not known to TQt Designer:\n" ).arg( name() ); for ( TQStringList::Iterator sit = missingCustomWidgets.begin(); sit != missingCustomWidgets.end(); ++sit ) txt += " " + *sit + "\n"; - txt += "If you save this form and generate code for it using uic, \n" + txt += "If you save this form and generate code for it using tquic, \n" "the generated code will not compile.\n" "Do you want to save this form now?"; if ( TQMessageBox::information( mainWindow(), tr( "Save Form" ), txt ) == 1 ) diff --git a/tools/designer/designer/listeditor.ui.h b/tools/designer/designer/listeditor.ui.h index a7ee27961..e28e90551 100644 --- a/tools/designer/designer/listeditor.ui.h +++ b/tools/designer/designer/listeditor.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/tools/designer/designer/resource.cpp b/tools/designer/designer/resource.cpp index d2f913b05..e65493c5a 100644 --- a/tools/designer/designer/resource.cpp +++ b/tools/designer/designer/resource.cpp @@ -2219,7 +2219,7 @@ TQWidget *Resource::createSpacer( const TQDomElement &e, TQWidget *parent, TQLay } /*! - Attention: this function has to be in sync with Uic::setObjectProperty(). If you change one, change both. + Attention: this function has to be in sync with TQUic::setObjectProperty(). If you change one, change both. */ void Resource::setObjectProperty( TQObject* obj, const TQString &prop, const TQDomElement &e ) { diff --git a/tools/designer/designer/richtextfontdialog.ui.h b/tools/designer/designer/richtextfontdialog.ui.h index 27a11a212..68d0bd71a 100644 --- a/tools/designer/designer/richtextfontdialog.ui.h +++ b/tools/designer/designer/richtextfontdialog.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/tools/designer/examples/addressbook/addressbook.ui.h b/tools/designer/examples/addressbook/addressbook.ui.h index 6964e40b2..35cf1e737 100644 --- a/tools/designer/examples/addressbook/addressbook.ui.h +++ b/tools/designer/examples/addressbook/addressbook.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/tools/designer/examples/addressbook/addressdetails.ui.h b/tools/designer/examples/addressbook/addressdetails.ui.h index b4e739241..bf14ecdea 100644 --- a/tools/designer/examples/addressbook/addressdetails.ui.h +++ b/tools/designer/examples/addressbook/addressdetails.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/tools/designer/examples/addressbook/search.ui.h b/tools/designer/examples/addressbook/search.ui.h index 67715379c..8c08f0dd8 100644 --- a/tools/designer/examples/addressbook/search.ui.h +++ b/tools/designer/examples/addressbook/search.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/tools/designer/examples/colortool/colornameform.ui.h b/tools/designer/examples/colortool/colornameform.ui.h index 70d7f62f3..6d4f37bf8 100644 --- a/tools/designer/examples/colortool/colornameform.ui.h +++ b/tools/designer/examples/colortool/colornameform.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions use TQt Designer which will ** update this file, preserving your code. Create an init() function in place diff --git a/tools/designer/examples/colortool/findform.ui.h b/tools/designer/examples/colortool/findform.ui.h index 1f3e993b6..3a6a9e30e 100644 --- a/tools/designer/examples/colortool/findform.ui.h +++ b/tools/designer/examples/colortool/findform.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions use TQt Designer which will ** update this file, preserving your code. Create an init() function in place diff --git a/tools/designer/examples/colortool/mainform.ui.h b/tools/designer/examples/colortool/mainform.ui.h index 7a0f8a8db..0ec5059d5 100644 --- a/tools/designer/examples/colortool/mainform.ui.h +++ b/tools/designer/examples/colortool/mainform.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions use TQt Designer which will ** update this file, preserving your code. Create an init() function in place diff --git a/tools/designer/examples/colortool/optionsform.ui.h b/tools/designer/examples/colortool/optionsform.ui.h index e43b8f3fd..e126094a6 100644 --- a/tools/designer/examples/colortool/optionsform.ui.h +++ b/tools/designer/examples/colortool/optionsform.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions use TQt Designer which will ** update this file, preserving your code. Create an init() function in place diff --git a/tools/designer/examples/credit/creditformbase.cpp b/tools/designer/examples/credit/creditformbase.cpp index 73b060dbb..dd1428b60 100644 --- a/tools/designer/examples/credit/creditformbase.cpp +++ b/tools/designer/examples/credit/creditformbase.cpp @@ -2,7 +2,7 @@ ** Form implementation generated from reading ui file 'creditformbase.ui' ** ** Created: Fri Aug 10 09:48:16 2001 -** by: The User Interface Compiler (uic) +** by: The User Interface Compiler (tquic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ diff --git a/tools/designer/examples/credit/creditformbase.h b/tools/designer/examples/credit/creditformbase.h index 6c0ecc804..8422a1231 100644 --- a/tools/designer/examples/credit/creditformbase.h +++ b/tools/designer/examples/credit/creditformbase.h @@ -2,7 +2,7 @@ ** Form interface generated from reading ui file 'creditformbase.ui' ** ** Created: Fri Aug 10 09:48:10 2001 -** by: The User Interface Compiler (uic) +** by: The User Interface Compiler (tquic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ diff --git a/tools/designer/examples/metric/metric.ui.h b/tools/designer/examples/metric/metric.ui.h index 465a044c2..d2706be5d 100644 --- a/tools/designer/examples/metric/metric.ui.h +++ b/tools/designer/examples/metric/metric.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename functions respectively slots use ** TQt Designer which will update this file, preserving your code. Create an diff --git a/tools/designer/plugins/cppeditor/mainfilesettings.ui.h b/tools/designer/plugins/cppeditor/mainfilesettings.ui.h index 7dd3906c5..8ac48ad07 100644 --- a/tools/designer/plugins/cppeditor/mainfilesettings.ui.h +++ b/tools/designer/plugins/cppeditor/mainfilesettings.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** If you wish to add, delete or rename slots use TQt Designer which will ** update this file, preserving your code. Create an init() slot in place of diff --git a/tools/designer/plugins/cppeditor/projectsettings.ui.h b/tools/designer/plugins/cppeditor/projectsettings.ui.h index 32e770c93..7ec8e0214 100644 --- a/tools/designer/plugins/cppeditor/projectsettings.ui.h +++ b/tools/designer/plugins/cppeditor/projectsettings.ui.h @@ -1,5 +1,5 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. +** ui.h extension file, included from the tquic-generated form implementation. ** ** Add custom slot implementations here. Use a slot init() for ** initialization code called during construction, and a slot destroy() diff --git a/tools/designer/plugins/kdevdlg/main.cpp b/tools/designer/plugins/kdevdlg/main.cpp index 57d293a29..af5c08c93 100644 --- a/tools/designer/plugins/kdevdlg/main.cpp +++ b/tools/designer/plugins/kdevdlg/main.cpp @@ -89,7 +89,7 @@ TQStringList KDevDlgFilter::import( const TQString &, const TQString& filename ) { TQFile file( filename ); if ( !file.open( IO_ReadOnly ) ) - tqWarning( "uic: Could not open file '%s' ", filename.latin1() ); + tqWarning( "tquic: Could not open file '%s' ", filename.latin1() ); TQTextStream in; in.setDevice( &file ); diff --git a/tools/designer/plugins/rc/main.cpp b/tools/designer/plugins/rc/main.cpp index 9825ea649..c43a17264 100644 --- a/tools/designer/plugins/rc/main.cpp +++ b/tools/designer/plugins/rc/main.cpp @@ -87,7 +87,7 @@ TQStringList RCFilter::import( const TQString &, const TQString& filename ) { TQFile file( filename ); if ( !file.open( IO_ReadOnly ) ) - tqWarning( "uic: Could not open file '%s' ", filename.latin1() ); + tqWarning( "tquic: Could not open file '%s' ", filename.latin1() ); TQTextStream in; in.setDevice( &file ); diff --git a/tools/designer/shared/domtool.cpp b/tools/designer/shared/domtool.cpp index 46f999f89..498dec7f7 100644 --- a/tools/designer/shared/domtool.cpp +++ b/tools/designer/shared/domtool.cpp @@ -47,7 +47,7 @@ \brief Tools for the dom A collection of static functions used by Resource (part of the - designer) and Uic. + designer) and TQUic. */ diff --git a/tools/designer/shared/ui2uib.cpp b/tools/designer/shared/ui2uib.cpp index 4eddea7e9..3e31dda09 100644 --- a/tools/designer/shared/ui2uib.cpp +++ b/tools/designer/shared/ui2uib.cpp @@ -126,7 +126,7 @@ specified. 6. Some of the information stored in a .ui file is useful only - by uic, not to TQLayoutFactory. That information is, for now, + by tquic, not to TQLayoutFactory. That information is, for now, not taken along in the .uib file. Likewise, needless TQLayoutWidget objects are not taken along. diff --git a/tools/designer/shared/uib.h b/tools/designer/shared/uib.h index 5307595c6..8ee070ee6 100644 --- a/tools/designer/shared/uib.h +++ b/tools/designer/shared/uib.h @@ -89,7 +89,7 @@ private: }; /* - uic uses insertCString(), insertString(), and block(); + tquic uses insertCString(), insertString(), and block(); TQWidgetFactory uses readBlock(), asCString(), and asString(). By implementing these functions inline, we ensure that the binaries don't contain needless code. diff --git a/tools/designer/shared/widgetdatabase.cpp b/tools/designer/shared/widgetdatabase.cpp index 4fd0d79bf..e74139ef5 100644 --- a/tools/designer/shared/widgetdatabase.cpp +++ b/tools/designer/shared/widgetdatabase.cpp @@ -109,7 +109,7 @@ WidgetDatabase::WidgetDatabase() void WidgetDatabase::setupDataBase( int id ) { was_in_setup = TRUE; -#ifndef UIC +#ifndef TQUIC Q_UNUSED( id ) if ( dbcount ) return; @@ -240,7 +240,7 @@ void WidgetDatabase::setupDataBase( int id ) append( r ); -#if !defined(TQT_NO_ICONVIEW) || defined(UIC) +#if !defined(TQT_NO_ICONVIEW) || defined(TQUIC) r = new WidgetDatabaseRecord; r->iconSet = "designer_iconview.png"; r->name = "TQIconView"; @@ -572,7 +572,7 @@ void WidgetDatabase::setupDataBase( int id ) append( r ); #endif -#ifndef UIC +#ifndef TQUIC setupPlugins(); #endif } @@ -592,7 +592,7 @@ void WidgetDatabase::setupPlugins() if ( !iface ) continue; -#ifndef UIC +#ifndef TQUIC TQIconSet icon = iface->iconSet( *it ); if ( !icon.pixmap().isNull() ) r->icon = new TQIconSet( icon ); @@ -642,7 +642,7 @@ TQIconSet WidgetDatabase::iconSet( int id ) WidgetDatabaseRecord *r = at( id ); if ( !r ) return TQIconSet(); -#if !defined(UIC) && !defined(RESOURCE) +#if !defined(TQUIC) && !defined(RESOURCE) if ( !r->icon ) { if ( r->iconSet.isEmpty() ) return TQIconSet(); @@ -792,7 +792,7 @@ int WidgetDatabase::idFromClassName( const TQString &name ) return *i; if ( name == "FormWindow" ) return idFromClassName( "TQLayoutWidget" ); -#ifdef UIC +#ifdef TQUIC setupDataBase( -2 ); i = className2Id->find( name ); if ( i ) @@ -932,7 +932,7 @@ void WidgetDatabase::loadWhatsThis( const TQString &docPath ) // ### TQt 3.1: make these publically accessible via TQWidgetDatabase API -#if defined(UIC) +#if defined(TQUIC) bool dbnounload = FALSE; TQStringList *dbpaths = 0; #else @@ -944,13 +944,13 @@ TQPluginManager *widgetManager() { if ( !widgetPluginManager ) { TQString pluginDir = "/designer"; -#if !defined(UIC) +#if !defined(TQUIC) if ( qwf_plugin_dir ) pluginDir = *qwf_plugin_dir; #endif widgetPluginManager = new TQPluginManager( IID_Widget, TQApplication::libraryPaths(), pluginDir ); cleanup_manager.add( &widgetPluginManager ); -#if defined(UIC) +#if defined(TQUIC) if ( dbnounload ) widgetPluginManager->setAutoUnload( FALSE ); if ( dbpaths ) { diff --git a/tools/designer/tquic/embed.cpp b/tools/designer/tquic/embed.cpp new file mode 100644 index 000000000..422023009 --- /dev/null +++ b/tools/designer/tquic/embed.cpp @@ -0,0 +1,309 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tquic.h" +#include +#include +#include +#include +#include +#include +#include + +struct EmbedImage +{ + ~EmbedImage() { delete[] colorTable; } + int width, height, depth; + int numColors; + TQRgb* colorTable; + TQString name; + TQString cname; + bool alpha; +#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION + ulong compressed; +#endif +}; + +static TQString convertToCIdentifier( const char *s ) +{ + TQString r = s; + int len = r.length(); + if ( len > 0 && !isalpha( (char)r[0].latin1() ) ) + r[0] = '_'; + for ( int i=1; i> 4) & 15]; + s += hexdigits[v & 15]; + if ( i < (int)len-1 ) + s += ','; + } + if ( s.length() ) + out << (const char*)s; + return len; +} + +static void embedData( TQTextStream& out, const TQRgb* input, int n ) +{ + out << hex; + const TQRgb *v = input; + for ( int i=0; i\n"; + out << "#include \n"; + out << "#include \n"; + out << "#include \n"; + out << "\n"; + + TQPtrList list_image; + list_image.setAutoDelete( TRUE ); + int image_count = 0; + for ( it = images.begin(); it != images.end(); ++it ) { + TQImage img; + if ( !img.load( *it ) ) { + fprintf( stderr, "tquic: cannot load image file %s\n", (*it).latin1() ); + continue; + } + EmbedImage *e = new EmbedImage; + e->width = img.width(); + e->height = img.height(); + e->depth = img.depth(); + e->numColors = img.numColors(); + e->colorTable = new TQRgb[e->numColors]; + e->alpha = img.hasAlphaBuffer(); + memcpy(e->colorTable, img.colorTable(), e->numColors*sizeof(TQRgb)); + TQFileInfo fi( *it ); + e->name = fi.fileName(); + e->cname = TQString("image_%1").arg( image_count++); + list_image.append( e ); + out << "// " << *it << "\n"; + TQString s; + if ( e->depth == 1 ) + img = img.convertBitOrder(TQImage::BigEndian); + out << s.sprintf( "static const unsigned char %s_data[] = {", + (const char *)e->cname ); +#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION + e->compressed = +#endif + embedData( out, img.bits(), img.numBytes() ); + out << "\n};\n\n"; + if ( e->numColors ) { + out << s.sprintf( "static const TQRgb %s_ctable[] = {", + (const char *)e->cname ); + embedData( out, e->colorTable, e->numColors ); + out << "\n};\n\n"; + } + } + + if ( !list_image.isEmpty() ) { + out << "static struct EmbedImage {\n" + " int width, height, depth;\n" + " const unsigned char *data;\n" +#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION + " ulong compressed;\n" +#endif + " int numColors;\n" + " const TQRgb *colorTable;\n" + " bool alpha;\n" + " const char *name;\n" + "} embed_image_vec[] = {\n"; + EmbedImage *e = list_image.first(); + while ( e ) { + out << " { " + << e->width << ", " + << e->height << ", " + << e->depth << ", " + << "(const unsigned char*)" << e->cname << "_data, " +#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION + << e->compressed << ", " +#endif + << e->numColors << ", "; + if ( e->numColors ) + out << e->cname << "_ctable, "; + else + out << "0, "; + if ( e->alpha ) + out << "TRUE, "; + else + out << "FALSE, "; + out << "\"" << e->name << "\" },\n"; + e = list_image.next(); + } +#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION + out << " { 0, 0, 0, 0, 0, 0, 0, 0, 0 }\n};\n"; +#else + out << " { 0, 0, 0, 0, 0, 0, 0, 0 }\n};\n"; +#endif + + out << "\n" + "static TQImage uic_findImage( const TQString& name )\n" + "{\n" + " for ( int i=0; embed_image_vec[i].data; i++ ) {\n" + " if ( TQString::fromUtf8(embed_image_vec[i].name) == name ) {\n" +#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION + " TQByteArray baunzip;\n" + " baunzip = tqUncompress( embed_image_vec[i].data, \n" + " embed_image_vec[i].compressed );\n" + " TQImage img((uchar*)baunzip.data(),\n" + " embed_image_vec[i].width,\n" + " embed_image_vec[i].height,\n" + " embed_image_vec[i].depth,\n" + " (TQRgb*)embed_image_vec[i].colorTable,\n" + " embed_image_vec[i].numColors,\n" + " TQImage::BigEndian\n" + " );\n" + " img = img.copy();\n" +#else + " TQImage img((uchar*)embed_image_vec[i].data,\n" + " embed_image_vec[i].width,\n" + " embed_image_vec[i].height,\n" + " embed_image_vec[i].depth,\n" + " (TQRgb*)embed_image_vec[i].colorTable,\n" + " embed_image_vec[i].numColors,\n" + " TQImage::BigEndian\n" + " );\n" +#endif + " if ( embed_image_vec[i].alpha )\n" + " img.setAlphaBuffer(TRUE);\n" + " return img;\n" + " }\n" + " }\n" + " return TQImage();\n" + "}\n\n"; + + out << "class MimeSourceFactory_" << cProject << " : public TQMimeSourceFactory\n"; + out << "{\n"; + out << "public:\n"; + out << " MimeSourceFactory_" << cProject << "() {}\n"; + out << " ~MimeSourceFactory_" << cProject << "() {}\n"; + out << " const TQMimeSource* data( const TQString& abs_name ) const {\n"; + out << "\tconst TQMimeSource* d = TQMimeSourceFactory::data( abs_name );\n"; + out << "\tif ( d || abs_name.isNull() ) return d;\n"; + out << "\tTQImage img = uic_findImage( abs_name );\n"; + out << "\tif ( !img.isNull() )\n"; + out << "\t ((TQMimeSourceFactory*)this)->setImage( abs_name, img );\n"; + out << "\treturn TQMimeSourceFactory::data( abs_name );\n"; + out << " };\n"; + out << "};\n\n"; + + out << "static TQMimeSourceFactory* factory = 0;\n"; + out << "\n"; + + out << "TQ_EXPORT void qInitImages_" << cProject << "()\n"; + out << "{\n"; + out << " if ( !factory ) {\n"; + out << "\tfactory = new MimeSourceFactory_" << cProject << ";\n"; + out << "\tTQMimeSourceFactory::defaultFactory()->addFactory( factory );\n"; + out << " }\n"; + out << "}\n\n"; + + out << "void qCleanupImages_" << cProject << "()\n"; + out << "{\n"; + out << " if ( factory ) {\n"; + out << "\tTQMimeSourceFactory::defaultFactory()->removeFactory( factory );\n"; + out << "\tdelete factory;\n"; + out << "\tfactory = 0;\n"; + out << " }\n"; + out << "}\n\n"; + + out << "class StaticInitImages_" << cProject << "\n"; + out << "{\n"; + out << "public:\n"; + out << " StaticInitImages_" << cProject << "() { qInitImages_" << cProject << "(); }\n"; + out << "#if defined(Q_OS_SCO) || defined(Q_OS_UNIXWARE)\n"; + out << " ~StaticInitImages_" << cProject << "() { }\n"; + out << "#else\n"; + out << " ~StaticInitImages_" << cProject << "() { qCleanupImages_" << cProject << "(); }\n"; + out << "#endif\n"; + out << "};\n\n"; + + out << "static StaticInitImages_" << cProject << " staticImages;\n"; + } +} diff --git a/tools/designer/tquic/form.cpp b/tools/designer/tquic/form.cpp new file mode 100644 index 000000000..09b3a6828 --- /dev/null +++ b/tools/designer/tquic/form.cpp @@ -0,0 +1,1452 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tquic.h" +#include "parser.h" +#include "widgetdatabase.h" +#include "domtool.h" +#include +#include +#include +#include +#include +#include +#define NO_STATIC_COLORS +#include + +static TQByteArray unzipXPM( TQString data, ulong& length ) +{ + const int lengthOffset = 4; + int baSize = data.length() / 2 + lengthOffset; + uchar *ba = new uchar[ baSize ]; + for ( int i = lengthOffset; i < baSize; ++i ) { + char h = data[ 2 * (i-lengthOffset) ].latin1(); + char l = data[ 2 * (i-lengthOffset) + 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; + } + // tqUncompress() expects the first 4 bytes to be the expected length of the + // uncompressed data + ba[0] = ( length & 0xff000000 ) >> 24; + ba[1] = ( length & 0x00ff0000 ) >> 16; + ba[2] = ( length & 0x0000ff00 ) >> 8; + ba[3] = ( length & 0x000000ff ); + TQByteArray baunzip = tqUncompress( ba, baSize ); + delete[] ba; + return baunzip; +} + +#if TQT_VERSION >= 0x030900 +#error Add this functionality to TQDir (relativePathTo() maybe?) and \ +remove it from here and from moc +#endif + +TQCString combinePath( const char *infile, const char *outfile ) +{ + TQFileInfo inFileInfo( TQDir::current(), TQFile::decodeName(infile) ); + TQFileInfo outFileInfo( TQDir::current(), TQFile::decodeName(outfile) ); + int numCommonComponents = 0; + + TQStringList inSplitted = + TQStringList::split( '/', inFileInfo.dir().canonicalPath(), TRUE ); + TQStringList outSplitted = + TQStringList::split( '/', outFileInfo.dir().canonicalPath(), TRUE ); + + while ( !inSplitted.isEmpty() && !outSplitted.isEmpty() && + inSplitted.first() == outSplitted.first() ) { + inSplitted.remove( inSplitted.begin() ); + outSplitted.remove( outSplitted.begin() ); + numCommonComponents++; + } + + if ( numCommonComponents < 2 ) { + /* + The paths don't have the same drive, or they don't have the + same root directory. Use an absolute path. + */ + return TQFile::encodeName( inFileInfo.absFilePath() ); + } else { + /* + The paths have something in common. Use a path relative to + the output file. + */ + while ( !outSplitted.isEmpty() ) { + outSplitted.remove( outSplitted.begin() ); + inSplitted.prepend( ".." ); + } + inSplitted.append( inFileInfo.fileName() ); + return TQFile::encodeName( inSplitted.join("/") ); + } +} + +/*! + Creates a declaration (header file) for the form given in \a e + + \sa createFormImpl(), createObjectDecl() +*/ +void TQUic::createFormDecl( const TQDomElement &e ) +{ + TQDomElement n; + TQDomNodeList nl; + int i; + TQString objClass = getClassName( e ); + if ( objClass.isEmpty() ) + return; + TQString objName = getObjectName( e ); + + TQStringList typeDefs; + + TQMap customWidgetIncludes; + + TQString imageMembers; + + /* + We are generating a few TQImage members that are not strictly + necessary in some cases. Ideally, we would use requiredImage, + which is computed elsewhere, to keep the generated .h and .cpp + files synchronized. + */ + + // at first the images + TQMap customWidgets; + TQStringList forwardDecl; + TQStringList forwardDecl2; + TQString exportMacro; + 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++ ) { + TQString img = registerObject( nl.item(i).toElement().attribute("name") ); + registerObject( img ); + imageMembers += TQString( " TQPixmap %1;\n" ).arg( img ); + } + } else if ( n.tagName() == "customwidgets" ) { + TQDomElement n2 = n.firstChild().toElement(); + while ( !n2.isNull() ) { + if ( n2.tagName() == "customwidget" ) { + TQDomElement n3 = n2.firstChild().toElement(); + TQString cl; + WidgetDatabaseRecord *r = new WidgetDatabaseRecord; + while ( !n3.isNull() ) { + if ( n3.tagName() == "class" ) { + cl = n3.firstChild().toText().data(); + if ( !nofwd ) + forwardDecl << cl; + customWidgets.insert( cl, 0 ); + r->name = cl; + } else if ( n3.tagName() == "header" ) { + CustomInclude ci; + ci.header = n3.firstChild().toText().data(); + ci.location = n3.attribute( "location", "global" ); + r->includeFile = ci.header; + customWidgetIncludes.insert( cl, ci ); + } + WidgetDatabase::append( r ); + n3 = n3.nextSibling().toElement(); + } + } + n2 = n2.nextSibling().toElement(); + } + } + } + + // register the object and unify its name + objName = registerObject( objName ); + TQString protector = objName.upper() + "_H"; + protector.replace( "::", "_" ); + out << "#ifndef " << protector << endl; + out << "#define " << protector << endl; + out << endl; + out << "#include " << endl; // for broken HP-UX compilers + + if ( !imageMembers.isEmpty() ) + out << "#include " << endl; + + TQStringList globalIncludes, localIncludes; + int wid = WidgetDatabase::idFromClassName( objClass ); + { + TQMap::Iterator it = customWidgetIncludes.find( objClass ); + if ( it != customWidgetIncludes.end() ) { + if ( ( *it ).location == "global" ) + globalIncludes += (*it).header; + else + localIncludes += (*it).header; + } else { + globalIncludes += WidgetDatabase::includeFile( wid ); + } + } + + nl = e.parentNode().toElement().elementsByTagName( "include" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + TQDomElement n2 = nl.item(i).toElement(); + TQString s = n2.firstChild().toText().data(); + if ( n2.attribute( "impldecl", "in implementation" ) == "in declaration" && + n2.attribute( "location" ) != "local" ) { + if ( s.right( 5 ) == ".ui.h" ) + continue; + globalIncludes += s; + } + } + for ( i = 0; i < (int) nl.length(); i++ ) { + TQDomElement n2 = nl.item(i).toElement(); + TQString s = n2.firstChild().toText().data(); + if ( n2.attribute( "impldecl", "in implementation" ) == "in declaration" && + n2.attribute( "location" ) == "local" &&!globalIncludes.contains( s ) ) { + if ( s.right( 5 ) == ".ui.h" ) + continue; + localIncludes += s; + } + } + + TQStringList::Iterator it; + + globalIncludes = unique( globalIncludes ); + for ( it = globalIncludes.begin(); it != globalIncludes.end(); ++it ) { + if ( !(*it).isEmpty() ) + out << "#include <" << *it << ">" << endl; + } + localIncludes = unique( localIncludes ); + for ( it = localIncludes.begin(); it != localIncludes.end(); ++it ) { + if ( !(*it).isEmpty() ) + out << "#include \"" << *it << "\"" << endl; + } + out << endl; + + // forward declarations for child widgets and layouts + out << "class TQVBoxLayout;" << endl; + out << "class TQHBoxLayout;" << endl; + out << "class TQGridLayout;" << endl; + out << "class TQSpacerItem;" << endl; + if ( objClass == "TQMainWindow" ) { + out << "class TQAction;" << endl; + out << "class TQActionGroup;" << endl; + out << "class TQToolBar;" << endl; + out << "class TQPopupMenu;" << endl; + } + + bool dbForm = FALSE; + registerDatabases( e ); + dbConnections = unique( dbConnections ); + if ( dbConnections.count() ) + forwardDecl += "TQSqlDatabase"; + if ( dbCursors.count() ) + forwardDecl += "TQSqlCursor"; + if ( dbForms[ "(default)" ].count() ) + dbForm = TRUE; + bool subDbForms = FALSE; + for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { + if ( !(*it).isEmpty() && (*it) != "(default)" ) { + if ( dbForms[ (*it) ].count() ) { + subDbForms = TRUE; + break; + } + } + } + if ( dbForm || subDbForms ) + forwardDecl += "TQSqlForm"; + + for ( it = tags.begin(); it != tags.end(); ++it ) { + nl = e.parentNode().toElement().elementsByTagName( *it ); + for ( i = 1; i < (int) nl.length(); i++ ) { // begin at 1, 0 is the toplevel widget + TQString s = getClassName( nl.item(i).toElement() ); + if ( s == "TQLayoutWidget" ) + continue; // hide tqlayoutwidgets + if ( s == "Line" ) + s = "TQFrame"; + if ( !(nofwd && customWidgets.contains(s)) ) + forwardDecl += s; + if ( (s.mid( 2 ) == "ListBox") || (s.mid( 2 ) == "ListView") || (s.mid( 2 ) == "IconView") ) + forwardDecl += "TQ" + s.mid( 2 ) + "Item"; + if ( s == "TQDataTable" ) { // other convenience classes which are used in TQDataTable signals, and thus should be forward-declared by tquic for us + forwardDecl += "TQSqlRecord"; + } + } + } + + // some typedefs, maybe + typeDefs = unique( typeDefs ); + for ( it = typeDefs.begin(); it != typeDefs.end(); ++it ) { + if ( !(*it).isEmpty() ) + out << "typedef " << *it << ";" << endl; + } + + nl = e.parentNode().toElement().elementsByTagName( "forward" ); + for ( i = 0; i < (int) nl.length(); i++ ) + forwardDecl2 << nl.item(i).toElement().firstChild().toText().data(); + + nl = e.parentNode().toElement().elementsByTagName( "include" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + TQDomElement n2 = nl.item(i).toElement(); + TQString s = n2.firstChild().toText().data(); + if ( n2.attribute( "impldecl", "in implementation" ) == "in declaration" && + n2.attribute( "location" ) != "local" ) + globalIncludes += s; + } + for ( i = 0; i < (int) nl.length(); i++ ) { + TQDomElement n2 = nl.item(i).toElement(); + TQString s = n2.firstChild().toText().data(); + if ( n2.attribute( "impldecl", "in implementation" ) == "in declaration" && + n2.attribute( "location" ) == "local" &&!globalIncludes.contains( s ) ) + localIncludes += s; + } + nl = e.parentNode().toElement().elementsByTagName( "exportmacro" ); + if ( nl.length() == 1 ) + exportMacro = nl.item( 0 ).firstChild().toText().data(); + + forwardDecl = unique( forwardDecl ); + for ( it = forwardDecl.begin(); it != forwardDecl.end(); ++it ) { + if ( !(*it).isEmpty() && (*it) != objClass ) { + TQString forwardName = *it; + TQStringList forwardNamespaces = TQStringList::split( "::", + forwardName ); + forwardName = forwardNamespaces.last(); + forwardNamespaces.remove( forwardNamespaces.fromLast() ); + + TQStringList::ConstIterator ns = forwardNamespaces.begin(); + while ( ns != forwardNamespaces.end() ) { + out << "namespace " << *ns << " {" << endl; + ++ns; + } + out << "class " << forwardName << ";" << endl; + for ( int i = 0; i < (int) forwardNamespaces.count(); i++ ) + out << "}" << endl; + } + } + + for ( it = forwardDecl2.begin(); it != forwardDecl2.end(); ++it ) { + TQString fd = *it; + fd = fd.stripWhiteSpace(); + if ( !fd.endsWith( ";" ) ) + fd += ";"; + out << fd << endl; + } + + out << endl; + + TQStringList::ConstIterator ns = namespaces.begin(); + while ( ns != namespaces.end() ) { + out << "namespace " << *ns << " {" << endl; + ++ns; + } + + out << "class "; + if ( !exportMacro.isEmpty() ) + out << exportMacro << " "; + out << bareNameOfClass << " : public " << objClass << endl << "{" << endl; + + /* qmake ignore TQ_OBJECT */ + out << " TQ_OBJECT" << endl; + out << endl; + out << "public:" << endl; + + // constructor + if ( objClass == "TQDialog" || objClass == "TQWizard" ) { + out << " " << bareNameOfClass << "( TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );" << endl; + } else if ( objClass == "TQWidget" ) { + out << " " << bareNameOfClass << "( TQWidget* parent = 0, const char* name = 0, WFlags fl = 0 );" << endl; + } else if ( objClass == "TQMainWindow" ) { + out << " " << bareNameOfClass << "( TQWidget* parent = 0, const char* name = 0, WFlags fl = WType_TopLevel );" << endl; + isMainWindow = TRUE; + } else { + out << " " << bareNameOfClass << "( TQWidget* parent = 0, const char* name = 0 );" << endl; + } + + // destructor + out << " ~" << bareNameOfClass << "();" << endl; + out << endl; + + // children + bool needPolish = FALSE; + nl = e.parentNode().toElement().elementsByTagName( "widget" ); + for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget + n = nl.item(i).toElement(); + createObjectDecl( n ); + TQString t = n.tagName(); + if ( t == "vbox" || t == "hbox" || t == "grid" ) + createSpacerDecl( n ); + TQString s = getClassName( n ); + if ( s == "TQDataTable" || s == "TQDataBrowser" ) { + if ( isFrameworkCodeGenerated( n ) ) + needPolish = TRUE; + } + } + + // actions, toolbars, menus + for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "actions" ) { + for ( TQDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() ) + createActionDecl( a ); + } else if ( n.tagName() == "toolbars" ) { + for ( TQDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() ) + createToolbarDecl( a ); + } else if ( n.tagName() == "menubar" ) { + out << " " << "TQMenuBar *" << getObjectName( n ) << ";" << endl; + for ( TQDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() ) + createMenuBarDecl( a ); + } + } + out << endl; + + // database connections + dbConnections = unique( dbConnections ); + bool hadOutput = FALSE; + for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { + if ( !(*it).isEmpty() ) { + // only need pointers to non-default connections + if ( (*it) != "(default)" && !(*it).isEmpty() ) { + out << indent << "TQSqlDatabase* " << *it << "Connection;" << endl; + hadOutput = TRUE; + } + } + } + if ( hadOutput ) + out << endl; + + TQStringList publicSlots, protectedSlots, privateSlots; + TQStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes; + TQStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier; + + nl = e.parentNode().toElement().elementsByTagName( "slot" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item(i).toElement(); + if ( n.parentNode().toElement().tagName() != "slots" + && n.parentNode().toElement().tagName() != "connections" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString returnType = n.attribute( "returnType", "void" ); + TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); + if ( functionName.endsWith( ";" ) ) + functionName = functionName.left( functionName.length() - 1 ); + TQString specifier = n.attribute( "specifier" ); + TQString access = n.attribute( "access" ); + if ( access == "protected" ) { + protectedSlots += functionName; + protectedSlotTypes += returnType; + protectedSlotSpecifier += specifier; + } else if ( access == "private" ) { + privateSlots += functionName; + privateSlotTypes += returnType; + privateSlotSpecifier += specifier; + } else { + publicSlots += functionName; + publicSlotTypes += returnType; + publicSlotSpecifier += specifier; + } + } + + TQStringList publicFuncts, protectedFuncts, privateFuncts; + TQStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp; + TQStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec; + + nl = e.parentNode().toElement().elementsByTagName( "function" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item( i ).toElement(); + if ( n.parentNode().toElement().tagName() != "functions" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString returnType = n.attribute( "returnType", "void" ); + TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); + if ( functionName.endsWith( ";" ) ) + functionName = functionName.left( functionName.length() - 1 ); + TQString specifier = n.attribute( "specifier" ); + TQString access = n.attribute( "access" ); + if ( access == "protected" ) { + protectedFuncts += functionName; + protectedFunctRetTyp += returnType; + protectedFunctSpec += specifier; + } else if ( access == "private" ) { + privateFuncts += functionName; + privateFunctRetTyp += returnType; + privateFunctSpec += specifier; + } else { + publicFuncts += functionName; + publicFunctRetTyp += returnType; + publicFunctSpec += specifier; + } + } + + TQStringList publicVars, protectedVars, privateVars; + nl = e.parentNode().toElement().elementsByTagName( "variable" ); + for ( i = 0; i < (int)nl.length(); i++ ) { + n = nl.item( i ).toElement(); + // Because of compatibility the next lines have to be commented out. + // Someday it should be uncommented. + //if ( n.parentNode().toElement().tagName() != "variables" ) + // continue; + TQString access = n.attribute( "access", "protected" ); + TQString var = n.firstChild().toText().data().stripWhiteSpace(); + if (var.isEmpty()) + continue; + if ( !var.endsWith( ";" ) ) + var += ";"; + if ( access == "public" ) + publicVars += var; + else if ( access == "private" ) + privateVars += var; + else + protectedVars += var; + } + + if ( !publicVars.isEmpty() ) { + for ( it = publicVars.begin(); it != publicVars.end(); ++it ) + out << indent << *it << endl; + out << endl; + } + if ( !publicFuncts.isEmpty() ) + writeFunctionsDecl( publicFuncts, publicFunctRetTyp, publicFunctSpec ); + + if ( needPolish || !publicSlots.isEmpty() ) { + out << "public slots:" << endl; + if ( needPolish ) { + out << indent << "virtual void polish();" << endl; + out << endl; + } + if ( !publicSlots.isEmpty() ) + writeFunctionsDecl( publicSlots, publicSlotTypes, publicSlotSpecifier ); + } + + // find signals + TQStringList extraSignals; + nl = e.parentNode().toElement().elementsByTagName( "signal" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item( i ).toElement(); + if ( n.parentNode().toElement().tagName() != "signals" + && n.parentNode().toElement().tagName() != "connections" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString sigName = n.firstChild().toText().data().stripWhiteSpace(); + if ( sigName.endsWith( ";" ) ) + sigName = sigName.left( sigName.length() - 1 ); + extraSignals += sigName; + } + + // create signals + if ( !extraSignals.isEmpty() ) { + out << "signals:" << endl; + for ( it = extraSignals.begin(); it != extraSignals.end(); ++it ) + out << " void " << (*it) << ";" << endl; + out << endl; + } + + out << "protected:" << endl; + if ( !protectedVars.isEmpty() ) { + for ( it = protectedVars.begin(); it != protectedVars.end(); ++it ) + out << indent << *it << endl; + out << endl; + } + if ( !protectedFuncts.isEmpty() ) + writeFunctionsDecl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec ); + + // child layouts + registerLayouts( e ); + out << endl; + +#if TQT_VERSION >= 0x030900 +#error Make languageChange() a virtual protected non-slot member of TQWidget +#endif + + out << "protected slots:" << endl; + out << " virtual void languageChange();" << endl; + if ( !protectedSlots.isEmpty() ) { + out << endl; + writeFunctionsDecl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier ); + } + out << endl; + + // create all private stuff + if ( !privateFuncts.isEmpty() || !privateVars.isEmpty() || !imageMembers.isEmpty() ) { + out << "private:" << endl; + if ( !privateVars.isEmpty() ) { + for ( it = privateVars.begin(); it != privateVars.end(); ++it ) + out << indent << *it << endl; + out << endl; + } + if ( !imageMembers.isEmpty() ) { + out << imageMembers; + out << endl; + } + if ( !privateFuncts.isEmpty() ) + writeFunctionsDecl( privateFuncts, privateFunctRetTyp, privateFunctSpec ); + } + + if ( !privateSlots.isEmpty() ) { + out << "private slots:" << endl; + writeFunctionsDecl( privateSlots, privateSlotTypes, privateSlotSpecifier ); + } + + out << "};" << endl; + for ( i = 0; i < (int) namespaces.count(); i++ ) + out << "}" << endl; + + out << endl; + out << "#endif // " << protector << endl; +} + +void TQUic::writeFunctionsDecl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst ) +{ + TQValueListConstIterator it, it2, it3; + for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin(); + it != fuLst.end(); ++it, ++it2, ++it3 ) { + TQString signature = *it; + TQString specifier; + TQString pure; + TQString type = *it2; + if ( type.isEmpty() ) + type = "void"; + if ( *it3 == "static" ) { + specifier = "static "; + } else { + if ( *it3 != "non virtual" && *it3 != "nonVirtual" ) + specifier = "virtual "; + if ( *it3 == "pure virtual" || *it3 == "pureVirtual" ) + pure = " = 0"; + } + type.replace( ">>", "> >" ); + if ( !signature.contains("operator") ) + signature.replace( ">>", "> >" ); + out << " " << specifier << type << " " << signature << pure << ";" << endl; + } + out << endl; +} + +/*! + Creates an implementation (cpp-file) for the form given in \a e. + + \sa createFormDecl(), createObjectImpl() + */ +void TQUic::createFormImpl( const TQDomElement &e ) +{ + TQDomElement n; + TQDomNodeList nl; + int i; + TQString objClass = getClassName( e ); + if ( objClass.isEmpty() ) + return; + TQString objName = getObjectName( e ); + + // generate local and local includes required + TQStringList globalIncludes, localIncludes; + TQStringList::Iterator it; + + TQMap customWidgetIncludes; + + // find additional slots and functions + TQStringList extraFuncts; + TQStringList extraFunctTyp; + TQStringList extraFunctSpecifier; + + nl = e.parentNode().toElement().elementsByTagName( "slot" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item(i).toElement(); + if ( n.parentNode().toElement().tagName() != "slots" + && n.parentNode().toElement().tagName() != "connections" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); + if ( functionName.endsWith( ";" ) ) + functionName = functionName.left( functionName.length() - 1 ); + extraFuncts += functionName; + extraFunctTyp += n.attribute( "returnType", "void" ); + extraFunctSpecifier += n.attribute( "specifier", "virtual" ); + } + + nl = e.parentNode().toElement().elementsByTagName( "function" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item(i).toElement(); + if ( n.parentNode().toElement().tagName() != "functions" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); + if ( functionName.endsWith( ";" ) ) + functionName = functionName.left( functionName.length() - 1 ); + extraFuncts += functionName; + extraFunctTyp += n.attribute( "returnType", "void" ); + extraFunctSpecifier += n.attribute( "specifier", "virtual" ); + } + + for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "customwidgets" ) { + TQDomElement n2 = n.firstChild().toElement(); + while ( !n2.isNull() ) { + if ( n2.tagName() == "customwidget" ) { + TQDomElement n3 = n2.firstChild().toElement(); + TQString cl; + WidgetDatabaseRecord *r = new WidgetDatabaseRecord; + while ( !n3.isNull() ) { + if ( n3.tagName() == "class" ) { + cl = n3.firstChild().toText().data(); + r->name = cl; + } else if ( n3.tagName() == "header" ) { + CustomInclude ci; + ci.header = n3.firstChild().toText().data(); + ci.location = n3.attribute( "location", "global" ); + r->includeFile = ci.header; + customWidgetIncludes.insert( cl, ci ); + } + WidgetDatabase::append( r ); + n3 = n3.nextSibling().toElement(); + } + } + n2 = n2.nextSibling().toElement(); + } + } + } + + // additional includes (local or global) and forward declaractions + nl = e.parentNode().toElement().elementsByTagName( "include" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + TQDomElement n2 = nl.item(i).toElement(); + TQString s = n2.firstChild().toText().data(); + if ( n2.attribute( "location" ) != "local" ) { + if ( s.right( 5 ) == ".ui.h" && !TQFile::exists( s ) ) + continue; + if ( n2.attribute( "impldecl", "in implementation" ) != "in implementation" ) + continue; + globalIncludes += s; + } + } + + registerDatabases( e ); + dbConnections = unique( dbConnections ); + if ( dbConnections.count() ) + globalIncludes += "tqsqldatabase.h"; + if ( dbCursors.count() ) + globalIncludes += "tqsqlcursor.h"; + bool dbForm = FALSE; + if ( dbForms[ "(default)" ].count() ) + dbForm = TRUE; + bool subDbForms = FALSE; + for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { + if ( !(*it).isEmpty() && (*it) != "(default)" ) { + if ( dbForms[ (*it) ].count() ) { + subDbForms = TRUE; + break; + } + } + } + if ( dbForm || subDbForms ) { + globalIncludes += "tqsqlform.h"; + globalIncludes += "tqsqlrecord.h"; + } + + // do the local includes afterwards, since global includes have priority on clashes + for ( i = 0; i < (int) nl.length(); i++ ) { + TQDomElement n2 = nl.item(i).toElement(); + TQString s = n2.firstChild().toText().data(); + if ( n2.attribute( "location" ) == "local" &&!globalIncludes.contains( s ) ) { + if ( s.right( 5 ) == ".ui.h" && !TQFile::exists( s ) ) + continue; + if ( n2.attribute( "impldecl", "in implementation" ) != "in implementation" ) + continue; + localIncludes += s; + } + } + + // additional custom widget headers + nl = e.parentNode().toElement().elementsByTagName( "header" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + TQDomElement n2 = nl.item(i).toElement(); + TQString s = n2.firstChild().toText().data(); + if ( n2.attribute( "location" ) != "local" ) + globalIncludes += s; + else + localIncludes += s; + } + + // includes for child widgets + for ( it = tags.begin(); it != tags.end(); ++it ) { + nl = e.parentNode().toElement().elementsByTagName( *it ); + for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget + TQString name = getClassName( nl.item(i).toElement() ); + if ( name == "Spacer" ) { + globalIncludes += "tqlayout.h"; + globalIncludes += "ntqapplication.h"; + continue; + } + if (( name.mid( 1 ) == "ListView" ) || ( name.mid( 2 ) == "ListView" )) + globalIncludes += "tqheader.h"; + if ( name != objClass ) { + int wid = WidgetDatabase::idFromClassName( name ); + TQMap::Iterator it = customWidgetIncludes.find( name ); + if ( it == customWidgetIncludes.end() ) + globalIncludes += WidgetDatabase::includeFile( wid ); + } + } + } + + out << "#include " << endl; // first for gcc 2.7.2 + + globalIncludes = unique( globalIncludes ); + for ( it = globalIncludes.begin(); it != globalIncludes.end(); ++it ) { + if ( !(*it).isEmpty() ) + out << "#include <" << *it << ">" << endl; + } + + out << "#include " << endl; + out << "#include " << endl; + out << "#include " << endl; + if ( objClass == "TQMainWindow" ) { + out << "#include " << endl; + out << "#include " << endl; + out << "#include " << endl; + out << "#include " << endl; + } + + // find out what images are required + TQStringList requiredImages; + static const char *imgTags[] = { "pixmap", "iconset", 0 }; + for ( i = 0; imgTags[i] != 0; i++ ) { + nl = e.parentNode().toElement().elementsByTagName( imgTags[i] ); + for ( int j = 0; j < (int) nl.length(); j++ ) { + TQDomNode nn = nl.item(j); + while ( nn.parentNode() != e.parentNode() ) + nn = nn.parentNode(); + if ( nn.nodeName() != "customwidgets" ) + requiredImages += nl.item(j).firstChild().toText().data(); + } + } + + if ( !requiredImages.isEmpty() || externPixmaps ) { + out << "#include " << endl; + out << "#include " << endl << endl; + } + + /* + Put local includes after all global includes + */ + localIncludes = unique( localIncludes ); + for ( it = localIncludes.begin(); it != localIncludes.end(); ++it ) { + if ( !(*it).isEmpty() && *it != TQFileInfo( fileName + ".h" ).fileName() ) + out << "#include \"" << *it << "\"" << endl; + } + + TQString uiDotH = fileName + ".h"; + if ( TQFile::exists( uiDotH ) ) { + if ( !outputFileName.isEmpty() ) + uiDotH = combinePath( uiDotH, outputFileName ); + out << "#include \"" << uiDotH << "\"" << endl; + writeFunctImpl = FALSE; + } + + // register the object and unify its name + objName = registerObject( objName ); + + TQStringList images; + TQStringList xpmImages; + if ( pixmapLoaderFunction.isEmpty() && !externPixmaps ) { + // 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++ ) { + TQString img = registerObject( nl.item(i).toElement().attribute("name") ); + if ( !requiredImages.contains( img ) ) + continue; + TQDomElement tmp = nl.item(i).firstChild().toElement(); + if ( tmp.tagName() != "data" ) + continue; + TQString format = tmp.attribute("format", "PNG" ); + TQString data = tmp.firstChild().toText().data(); + if ( format == "XPM.GZ" ) { + xpmImages += img; + ulong length = tmp.attribute("length").toULong(); + TQByteArray baunzip = unzipXPM( data, length ); + length = baunzip.size(); + // shouldn't we test the initial 'length' against the + // resulting 'length' to catch corrupt TQUIC files? + int a = 0; + int column = 0; + bool inQuote = FALSE; + out << "static const char* const " << img << "_data[] = { " << endl; + while ( baunzip[a] != '\"' ) + a++; + for ( ; a < (int) length; a++ ) { + out << baunzip[a]; + if ( baunzip[a] == '\n' ) { + column = 0; + } else if ( baunzip[a] == '"' ) { + inQuote = !inQuote; + } + + if ( column++ >= 511 && inQuote ) { + out << "\"\n\""; // be nice with MSVC & Co. + column = 1; + } + } + out << endl; + } else { + images += img; + out << "static const unsigned char " << img << "_data[] = { " << endl; + out << " "; + int a ; + for ( a = 0; a < (int) (data.length()/2)-1; a++ ) { + out << "0x" << TQString(data[2*a]) << TQString(data[2*a+1]) << ","; + if ( a % 12 == 11 ) + out << endl << " "; + else + out << " "; + } + out << "0x" << TQString(data[2*a]) << TQString(data[2*a+1]) << endl; + out << "};" << endl << endl; + } + } + } + } + out << endl; + } else if ( externPixmaps ) { + pixmapLoaderFunction = "TQPixmap::fromMimeSource"; + } + + // constructor + if ( objClass == "TQDialog" || objClass == "TQWizard" ) { + out << "/*" << endl; + out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; + out << " * name 'name' and widget flags set to 'f'." << endl; + out << " *" << endl; + out << " * The " << objClass.mid(1).lower() << " will by default be modeless, unless you set 'modal' to" << endl; + out << " * TRUE to construct a modal " << objClass.mid(1).lower() << "." << endl; + out << " */" << endl; + out << nameOfClass << "::" << bareNameOfClass << "( TQWidget* parent, const char* name, bool modal, WFlags fl )" << endl; + out << " : " << objClass << "( parent, name, modal, fl )"; + } else if ( objClass == "TQWidget" ) { + out << "/*" << endl; + out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; + out << " * name 'name' and widget flags set to 'f'." << endl; + out << " */" << endl; + out << nameOfClass << "::" << bareNameOfClass << "( TQWidget* parent, const char* name, WFlags fl )" << endl; + out << " : " << objClass << "( parent, name, fl )"; + } else if ( objClass == "TQMainWindow" ) { + out << "/*" << endl; + out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; + out << " * name 'name' and widget flags set to 'f'." << endl; + out << " *" << endl; + out << " */" << endl; + out << nameOfClass << "::" << bareNameOfClass << "( TQWidget* parent, const char* name, WFlags fl )" << endl; + out << " : " << objClass << "( parent, name, fl )"; + isMainWindow = TRUE; + } else { + out << "/*" << endl; + out << " * Constructs a " << nameOfClass << " which is a child of 'parent', with the" << endl; + out << " * name 'name'.' " << endl; + out << " */" << endl; + out << nameOfClass << "::" << bareNameOfClass << "( TQWidget* parent, const char* name )" << endl; + out << " : " << objClass << "( parent, name )"; + } + + // create pixmaps for all images + if ( !xpmImages.isEmpty() ) { + for ( it = xpmImages.begin(); it != xpmImages.end(); ++it ) { + out << "," << endl; + out << indent << " " << *it << "( (const char **) " << (*it) << "_data )"; + } + } + out << endl; + + out << "{" << endl; + if ( isMainWindow ) + out << indent << "(void)statusBar();" << endl; + + if ( !images.isEmpty() ) { + out << indent << "TQImage img;" << endl; + for ( it = images.begin(); it != images.end(); ++it ) { + out << indent << "img.loadFromData( " << (*it) << "_data, sizeof( " << (*it) << "_data ), \"PNG\" );" << endl; + out << indent << (*it) << " = img;" << endl; + } + } + + // set the properties + TQSize geometry( 0, 0 ); + + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "property" ) { + bool stdset = stdsetdef; + if ( n.hasAttribute( "stdset" ) ) + stdset = toBool( n.attribute( "stdset" ) ); + TQString prop = n.attribute("name"); + TQDomElement n2 = n.firstChild().toElement(); + TQString value = setObjectProperty( objClass, TQString::null, prop, n2, stdset ); + if ( value.isEmpty() ) + continue; + + if ( prop == "geometry" && n2.tagName() == "rect" ) { + TQDomElement n3 = n2.firstChild().toElement(); + while ( !n3.isNull() ) { + if ( n3.tagName() == "width" ) + geometry.setWidth( n3.firstChild().toText().data().toInt() ); + else if ( n3.tagName() == "height" ) + geometry.setHeight( n3.firstChild().toText().data().toInt() ); + n3 = n3.nextSibling().toElement(); + } + } else { + TQString call; + if ( stdset ) { + call = mkStdSet( prop ) + "( "; + } else { + call = "setProperty( \"" + prop + "\", "; + } + call += value + " );"; + + if ( n2.tagName() == "string" ) { + trout << indent << call << endl; + } else if ( prop == "name" ) { + out << indent << "if ( !name )" << endl; + out << "\t" << call << endl; + } else { + out << indent << call << 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, "this" ); + TQString comment; + TQString label = DomTool::readAttribute( n, "title", "", comment ).toString(); + out << indent << "addPage( " << page << ", TQString(\"\") );" << endl; + trout << indent << "setTitle( " << page << ", " << trcall( label, comment ) << " );" << endl; + TQVariant def( false ); + if ( DomTool::hasAttribute( n, "backEnabled" ) ) + out << indent << "setBackEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "backEnabled", def).toBool() ) << endl; + if ( DomTool::hasAttribute( n, "nextEnabled" ) ) + out << indent << "setNextEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "nextEnabled", def).toBool() ) << endl; + if ( DomTool::hasAttribute( n, "finishEnabled" ) ) + out << indent << "setFinishEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "finishEnabled", def).toBool() ) << " );" << endl; + if ( DomTool::hasAttribute( n, "helpEnabled" ) ) + out << indent << "setHelpEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "helpEnabled", def).toBool() ) << endl; + if ( DomTool::hasAttribute( n, "finish" ) ) + out << indent << "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, "this" ); + } + } + + // database support + dbConnections = unique( dbConnections ); + if ( dbConnections.count() ) + out << endl; + for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { + if ( !(*it).isEmpty() && (*it) != "(default)") { + out << indent << (*it) << "Connection = TQSqlDatabase::database( \"" <<(*it) << "\" );" << endl; + } + } + + nl = e.parentNode().toElement().elementsByTagName( "widget" ); + for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget + n = nl.item(i).toElement(); + TQString s = getClassName( n ); + if ( (dbForm || subDbForms) && (s == "TQDataBrowser" || s == "TQDataView") ) { + TQString objName = getObjectName( n ); + TQString tab = getDatabaseInfo( n, "table" ); + TQString con = getDatabaseInfo( n, "connection" ); + out << indent << "TQSqlForm* " << objName << "Form = new TQSqlForm( this, \"" << objName << "Form\" );" << endl; + TQDomElement n2; + for ( n2 = n.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) + createFormImpl( n2, objName, con, tab ); + out << indent << objName << "->setForm( " << objName << "Form );" << endl; + } + } + + // actions, toolbars, menubar + bool needEndl = FALSE; + for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "actions" ) { + if ( !needEndl ) + out << endl << indent << "// actions" << endl; + createActionImpl( n.firstChild().toElement(), "this" ); + needEndl = TRUE; + } + } + if ( needEndl ) + out << endl; + needEndl = FALSE; + for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "toolbars" ) { + if ( !needEndl ) + out << endl << indent << "// toolbars" << endl; + createToolbarImpl( n, objClass, objName ); + needEndl = TRUE; + } + } + if ( needEndl ) + out << endl; + needEndl = FALSE; + for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "menubar" ) { + if ( !needEndl ) + out << endl << indent << "// menubar" << endl; + createMenuBarImpl( n, objClass, objName ); + needEndl = TRUE; + } + } + if ( needEndl ) + out << endl; + + out << indent << "languageChange();" << endl; + + // take minimumSizeHint() into account, for height-for-width widgets + if ( !geometry.isNull() ) { + out << indent << "resize( TQSize(" << geometry.width() << ", " + << geometry.height() << ").expandedTo(minimumSizeHint()) );" << endl; + out << indent << "clearWState( WState_Polished );" << endl; + } + + for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "connections" ) { + // setup signals and slots connections + out << endl << indent << "// signals and slots connections" << 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; + if ( sender[0] == '<' || + receiver[0] == '<' || + signal[0] == '<' || + slot[0] == '<' ) + continue; + + sender = registeredName( sender ); + receiver = registeredName( receiver ); + + // translate formwindow name to "this" + if ( sender == objName ) + sender = "this"; + if ( receiver == objName ) + receiver = "this"; + + out << indent << "connect( " << sender << ", TQ_SIGNAL( " << signal << " ), " + << receiver << ", TQ_SLOT( " << slot << " ) );" << endl; + } + } else if ( n.tagName() == "tabstops" ) { + // setup tab order + out << endl << indent << "// tab order" << 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 << "setTabOrder( " << lastName << ", " << name << " );" << endl; + lastName = name; + } + n2 = n2.nextSibling().toElement(); + } + } + } + + // buddies + bool firstBuddy = TRUE; + for ( TQValueList::Iterator buddy = buddies.begin(); buddy != buddies.end(); ++buddy ) { + if ( isObjectRegistered( (*buddy).buddy ) ) { + if ( firstBuddy ) { + out << endl << indent << "// buddies" << endl; + } + out << indent << (*buddy).key << "->setBuddy( " << registeredName( (*buddy).buddy ) << " );" << endl; + firstBuddy = FALSE; + } + } + + if ( extraFuncts.find( "init()" ) != extraFuncts.end() ) + out << indent << "init();" << endl; + + // end of constructor + out << "}" << endl; + out << endl; + + // destructor + out << "/*" << endl; + out << " * Destroys the object and frees any allocated resources" << endl; + out << " */" << endl; + out << nameOfClass << "::~" << bareNameOfClass << "()" << endl; + out << "{" << endl; + if ( extraFuncts.find( "destroy()" ) != extraFuncts.end() ) + out << indent << "destroy();" << endl; + out << indent << "// no need to delete child widgets, TQt does it all for us" << endl; + out << "}" << endl; + out << endl; + + // handle application events if required + bool needFontEventHandler = FALSE; + bool needSqlTableEventHandler = FALSE; + bool needSqlDataBrowserEventHandler = FALSE; + nl = e.elementsByTagName( "widget" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + if ( !DomTool::propertiesOfType( nl.item(i).toElement() , "font" ).isEmpty() ) + needFontEventHandler = TRUE; + TQString s = getClassName( nl.item(i).toElement() ); + if ( s == "TQDataTable" || s == "TQDataBrowser" ) { + if ( !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) + continue; + if ( s == "TQDataTable" ) + needSqlTableEventHandler = TRUE; + if ( s == "TQDataBrowser" ) + needSqlDataBrowserEventHandler = TRUE; + } + if ( needFontEventHandler && needSqlTableEventHandler && needSqlDataBrowserEventHandler ) + break; + } + if ( needFontEventHandler && FALSE ) { + // indent = "\t"; // increase indentation for if-clause below + out << "/*" << endl; + out << " * Main event handler. Reimplemented to handle" << endl; + out << " * application font changes"; + out << " */" << endl; + out << "bool " << nameOfClass << "::event( TQEvent* ev )" << endl; + out << "{" << endl; + out << " bool ret = " << objClass << "::event( ev ); " << endl; + if ( needFontEventHandler ) { + indent += "\t"; + out << " if ( ev->type() == TQEvent::ApplicationFontChange ) {" << endl; + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item(i).toElement(); + TQStringList list = DomTool::propertiesOfType( n, "font" ); + for ( it = list.begin(); it != list.end(); ++it ) + createExclusiveProperty( n, *it ); + } + out << " }" << endl; + indent = " "; + } + out << "}" << endl; + out << endl; + } + + if ( needSqlTableEventHandler || needSqlDataBrowserEventHandler ) { + out << "/*" << endl; + out << " * Widget polish. Reimplemented to handle" << endl; + if ( needSqlTableEventHandler ) + out << " * default data table initialization" << endl; + if ( needSqlDataBrowserEventHandler ) + out << " * default data browser initialization" << endl; + out << " */" << endl; + out << "void " << nameOfClass << "::polish()" << endl; + out << "{" << endl; + if ( needSqlTableEventHandler ) { + for ( i = 0; i < (int) nl.length(); i++ ) { + TQString s = getClassName( nl.item(i).toElement() ); + if ( s == "TQDataTable" ) { + n = nl.item(i).toElement(); + TQString c = getObjectName( n ); + TQString conn = getDatabaseInfo( n, "connection" ); + TQString tab = getDatabaseInfo( n, "table" ); + if ( !( conn.isEmpty() || tab.isEmpty() || !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) ) { + out << indent << "if ( " << c << " ) {" << endl; + out << indent << indent << "TQSqlCursor* cursor = " << c << "->sqlCursor();" << endl; + out << indent << indent << "if ( !cursor ) {" << endl; + if ( conn == "(default)" ) + out << indent << indent << indent << "cursor = new TQSqlCursor( \"" << tab << "\" );" << endl; + else + out << indent << indent << indent << "cursor = new TQSqlCursor( \"" << tab << "\", TRUE, " << conn << "Connection );" << endl; + out << indent << indent << indent << "if ( " << c << "->isReadOnly() ) " << endl; + out << indent << indent << indent << indent << "cursor->setMode( TQSqlCursor::ReadOnly );" << endl; + out << indent << indent << indent << c << "->setSqlCursor( cursor, FALSE, TRUE );" << endl; + out << indent << indent << "}" << endl; + out << indent << indent << "if ( !cursor->isActive() )" << endl; + out << indent << indent << indent << c << "->refresh( TQDataTable::RefreshAll );" << endl; + out << indent << "}" << endl; + } + } + } + } + if ( needSqlDataBrowserEventHandler ) { + nl = e.elementsByTagName( "widget" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + TQString s = getClassName( nl.item(i).toElement() ); + if ( s == "TQDataBrowser" ) { + TQString obj = getObjectName( nl.item(i).toElement() ); + TQString tab = getDatabaseInfo( nl.item(i).toElement(), + "table" ); + TQString conn = getDatabaseInfo( nl.item(i).toElement(), + "connection" ); + if ( !(tab.isEmpty() || !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) ) { + out << indent << "if ( " << obj << " ) {" << endl; + out << indent << indent << "if ( !" << obj << "->sqlCursor() ) {" << endl; + if ( conn == "(default)" ) + out << indent << indent << indent << "TQSqlCursor* cursor = new TQSqlCursor( \"" << tab << "\" );" << endl; + else + out << indent << indent << indent << "TQSqlCursor* cursor = new TQSqlCursor( \"" << tab << "\", TRUE, " << conn << "Connection );" << endl; + out << indent << indent << indent << obj << "->setSqlCursor( cursor, TRUE );" << endl; + out << indent << indent << indent << obj << "->refresh();" << endl; + out << indent << indent << indent << obj << "->first();" << endl; + out << indent << indent << "}" << endl; + out << indent << "}" << endl; + } + } + } + } + out << indent << objClass << "::polish();" << endl; + out << "}" << endl; + out << endl; + } + + out << "/*" << endl; + out << " * Sets the strings of the subwidgets using the current" << endl; + out << " * language." << endl; + out << " */" << endl; + out << "void " << nameOfClass << "::languageChange()" << endl; + out << "{" << endl; + out << languageChangeBody; + out << "}" << endl; + out << endl; + + // create stubs for additional slots if necessary + if ( !extraFuncts.isEmpty() && writeFunctImpl ) { + it = extraFuncts.begin(); + TQStringList::Iterator it2 = extraFunctTyp.begin(); + TQStringList::Iterator it3 = extraFunctSpecifier.begin(); + while ( it != extraFuncts.end() ) { + TQString type = *it2; + if ( type.isEmpty() ) + type = "void"; + type = type.simplifyWhiteSpace(); + TQString fname = Parser::cleanArgs( *it ); + if ( !(*it3).startsWith("pure") ) { // "pure virtual" or "pureVirtual" + out << type << " " << nameOfClass << "::" << fname << endl; + out << "{" << endl; + if ( *it != "init()" && *it != "destroy()" ) { + TQRegExp numeric( "^(?:signed|unsigned|u?char|u?short|u?int" + "|u?long|Q_U?INT(?:8|16|32)|Q_U?LONG|float" + "|double)$" ); + TQString retVal; + + /* + We return some kind of dummy value to shut the + compiler up. + + 1. If the type is 'void', we return nothing. + + 2. If the type is 'bool', we return 'FALSE'. + + 3. If the type is 'unsigned long' or + 'TQ_UINT16' or 'double' or similar, we + return '0'. + + 4. If the type is 'Foo *', we return '0'. + + 5. If the type is 'Foo &', we create a static + variable of type 'Foo' and return it. + + 6. If the type is 'Foo', we assume there's a + default constructor and use it. + */ + if ( type != "void" ) { + TQStringList toks = TQStringList::split( " ", type ); + bool isBasicNumericType = + ( toks.grep(numeric).count() == toks.count() ); + + if ( type == "bool" ) { + retVal = "FALSE"; + } else if ( isBasicNumericType || type.endsWith("*") ) { + retVal = "0"; + } else if ( type.endsWith("&") ) { + do { + type.truncate( type.length() - 1 ); + } while ( type.endsWith(" ") ); + retVal = "uic_temp_var"; + out << indent << "static " << type << " " << retVal << ";" << endl; + } else { + retVal = type + "()"; + } + } + + out << indent << "tqWarning( \"" << nameOfClass << "::" << fname << ": Not implemented yet\" );" << endl; + if ( !retVal.isEmpty() ) + out << indent << "return " << retVal << ";" << endl; + } + out << "}" << endl; + out << endl; + } + ++it; + ++it2; + ++it3; + } + } +} + + +/*! Creates form support implementation code for the widgets given + in \a e. + + Traverses recursively over all children. + */ + +void TQUic::createFormImpl( const TQDomElement& e, const TQString& form, const TQString& connection, const TQString& table ) +{ + if ( e.tagName() == "widget" && + e.attribute( "class" ) != "TQDataTable" ) { + TQString field = getDatabaseInfo( e, "field" ); + if ( !field.isEmpty() ) { + if ( isWidgetInTable( e, connection, table ) ) + out << indent << form << "Form->insert( " << getObjectName( e ) << ", " << fixString( field ) << " );" << endl; + } + } + TQDomElement n; + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + createFormImpl( n, form, connection, table ); + } +} diff --git a/tools/designer/tquic/main.cpp b/tools/designer/tquic/main.cpp new file mode 100644 index 000000000..636ffd432 --- /dev/null +++ b/tools/designer/tquic/main.cpp @@ -0,0 +1,358 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tquic.h" +#include "domtool.h" +#if defined(UIB) +#include "ui2uib.h" +#endif +#include +#include +#include +#include +#include +#define NO_STATIC_COLORS +#include +#include +#include + +// see ### in widgetdatabase.cpp +extern bool dbnounload; +extern TQStringList *dbpaths; + +int main( int argc, char * argv[] ) +{ + bool impl = FALSE; + bool subcl = FALSE; + bool imagecollection = FALSE; + bool imagecollection_tmpfile = FALSE; +#if defined(UIB) + bool binary = FALSE; +#endif + TQStringList images; + const char *error = 0; + const char* fileName = 0; + const char* className = 0; + const char* headerFile = 0; + TQCString outputFile; + TQCString image_tmpfile; + const char* projectName = 0; + const char* trmacro = 0; + bool nofwd = FALSE; + bool fix = FALSE; + TQCString pchFile; + TQApplication app(argc, argv, FALSE); + + TQString keybase( "/TQt Designer/" + + TQString::number( (TQT_VERSION >> 16) & 0xff ) +"." + TQString::number( (TQT_VERSION >> 8) & 0xff ) + "/" ); + TQSettings config; + config.insertSearchPath( TQSettings::Windows, "/Trolltech" ); + TQStringList pluginPaths = config.readListEntry( keybase + "PluginPaths" ); + if (pluginPaths.count()) + TQApplication::setLibraryPaths(pluginPaths); + + 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[0] == 'i' || opt == "impl" ) { + impl = TRUE; + if ( opt == "impl" || opt[1] == '\0' ) { + if ( !(n < argc-1) ) { + error = "Missing name of header file"; + break; + } + headerFile = argv[++n]; + } else + headerFile = &opt[1]; + } else if ( opt[0] == 'e' || opt == "embed" ) { + imagecollection = TRUE; + if ( opt == "embed" || opt[1] == '\0' ) { + if ( !(n < argc-1) ) { + error = "Missing name of project"; + break; + } + projectName = argv[++n]; + } else { + projectName = &opt[1]; + } + if ( argc > n+1 && qstrcmp( argv[n+1], "-f" ) == 0 ) { + imagecollection_tmpfile = TRUE; + image_tmpfile = argv[n+2]; + n += 2; + } +#if defined(UIB) + + } else if ( opt == "binary" ) { + binary = TRUE; +#endif + } else if ( opt == "nofwd" ) { + nofwd = TRUE; + } else if ( opt == "nounload" ) { + dbnounload = TRUE; + } else if ( opt == "subdecl" ) { + subcl = TRUE; + if ( !(n < argc-2) ) { + error = "Missing arguments"; + break; + } + className = argv[++n]; + headerFile = argv[++n]; + } else if ( opt == "subimpl" ) { + subcl = TRUE; + impl = TRUE; + if ( !(n < argc-2) ) { + error = "Missing arguments"; + break; + } + className = argv[++n]; + headerFile = argv[++n]; + } 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 == "L" ) { + if ( !(n < argc-1) ) { + error = "Missing plugin path."; + break; + } + if ( !dbpaths ) + dbpaths = new TQStringList(); + TQString fn = TQFile::decodeName( argv[++n] ); + dbpaths->append( fn ); + TQApplication::addLibraryPath( fn ); + } else if ( opt == "version" ) { + fprintf( stderr, + "User Interface Compiler for TQt version %s\n", + TQT_VERSION_STR ); + return 1; + } else if ( opt == "help" ) { + break; + } else if ( opt == "fix" ) { + fix = TRUE; + } else if ( opt == "pch") { + if ( !(n < argc-1) ) { + error = "Missing name of PCH file"; + break; + } + pchFile = argv[++n]; + } else { + error = "Unrecognized option"; + } + } else { + if ( imagecollection && !imagecollection_tmpfile ) + images << argv[n]; + else if ( fileName ) // can handle only one file + error = "Too many input files specified"; + else + fileName = argv[n]; + } + } + + if ( argc < 2 || error || (!fileName && !imagecollection ) ) { + fprintf( stderr, "TQt user interface compiler.\n" ); + if ( error ) + fprintf( stderr, "tquic: %s\n", error ); + + fprintf( stderr, "Usage: %s [options] [mode] \n\n" + "Generate declaration:\n" + " %s [options] \n" + "Generate implementation:\n" + " %s [options] -impl \n" + "\t name of the declaration file\n" + "Generate image collection:\n" + " %s [options] -embed ...\n" + "or\n" + " %s [options] -embed -f \n" + "\t project name\n" + "\t image files\n" +#if defined(UIB) + "Generate binary UI file:\n" + " %s [options] -binary \n" +#endif + "Generate subclass declaration:\n" + " %s [options] -subdecl \n" + "\t name of the subclass to generate\n" + "\t declaration file of the baseclass\n" + "Generate subclass implementation:\n" + " %s [options] -subimpl \n" + "\t name of the subclass to generate\n" + "\t declaration file of the subclass\n" + "Options:\n" + "\t-o file Write output to file rather than stdout\n" + "\t-pch file Add #include \"file\" as the first statement in implementation\n" + "\t-nofwd Omit forward declarations of custom classes\n" + "\t-nounload Don't unload plugins after processing\n" + "\t-tr func Use func() instead of tr() for i18n\n" + "\t-L path Additional plugin search path\n" + "\t-version Display version of tquic\n" + "\t-help Display this information\n" + , argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0] +#if defined(UIB) + , argv[0] +#endif + ); + return 1; + } + + if ( imagecollection_tmpfile ) { + TQFile ifile( image_tmpfile ); + if ( ifile.open( IO_ReadOnly ) ) { + TQTextStream ts( &ifile ); + TQString s = ts.read(); + s = s.simplifyWhiteSpace(); + images = TQStringList::split( ' ', s ); + for ( TQStringList::Iterator it = images.begin(); it != images.end(); ++it ) + *it = (*it).simplifyWhiteSpace(); + } + } + +#if defined(UIB) + if ( binary && outputFile.isEmpty() ) { + outputFile = fileName; + if ( outputFile.mid(outputFile.length() - 3).lower() == ".ui" ) + outputFile.truncate( outputFile.length() - 3 ); + outputFile += ".uib"; + } +#endif + + TQFile fileOut; + if ( !outputFile.isEmpty() ) { + fileOut.setName( outputFile ); + if (!fileOut.open( IO_WriteOnly ) ) { + tqWarning( "tquic: Could not open output file '%s'", outputFile.data() ); + return 1; + } + } else { + fileOut.open( IO_WriteOnly, stdout ); + } + TQTextStream out( &fileOut ); + + if ( imagecollection ) { + out.setEncoding( TQTextStream::Latin1 ); + TQUic::embed( out, projectName, images ); + return 0; + } + + out.setEncoding( TQTextStream::UnicodeUTF8 ); + + TQFile file( fileName ); + if ( !file.open( IO_ReadOnly ) ) { + tqWarning( "tquic: Could not open file '%s'", fileName ); + return 1; + } + + TQDomDocument doc; + TQString errMsg; + int errLine; + if ( !doc.setContent( &file, &errMsg, &errLine ) ) { + tqWarning( TQString("tquic: Failed to parse %s: ") + errMsg + TQString (" in line %d"), fileName, errLine ); + return 1; + } + + TQDomElement e = doc.firstChild().toElement(); + if ( e.hasAttribute("version") && e.attribute("version").toDouble() > 3.3 ) { + tqWarning( TQString("tquic: File generated with too recent version of TQt Designer (%s vs. %s)"), + e.attribute("version").latin1(), TQT_VERSION_STR ); + return 1; + } + + DomTool::fixDocument( doc ); + + if ( fix ) { + out << doc.toString(); + return 0; +#if defined(UIB) + } else if ( binary ) { + out.unsetDevice(); + TQDataStream binaryOut( &fileOut ); + convertUiToUib( doc, binaryOut ); + return 0; +#endif + } + + if ( !subcl ) { + out << "/****************************************************************************" << endl; + out << "** Form "<< (impl? "implementation" : "interface") << " generated from reading ui file '" << fileName << "'" << endl; + out << "**" << endl; + out << "** Created by: The TQt user interface compiler (TQt " << TQT_VERSION_STR << ")" << endl; + out << "**" << endl; + out << "** WARNING! All changes made in this file will be lost!" << endl; + out << "****************************************************************************/" << endl << endl; + } + + TQString protector; + if ( subcl && className && !impl ) + protector = TQString::fromLocal8Bit( className ).upper() + "_H"; + + if ( !protector.isEmpty() ) { + out << "#ifndef " << protector << endl; + out << "#define " << protector << endl; + } + + if ( !pchFile.isEmpty() && impl ) { + out << "#include \"" << pchFile << "\" // PCH include" << endl; + } + + if ( headerFile ) { + out << "#include \"" << headerFile << "\"" << endl << endl; + } + + TQUic( fileName, outputFile, out, doc, !impl, subcl, trmacro, className, nofwd ); + + if ( !protector.isEmpty() ) { + out << endl; + out << "#endif // " << protector << endl; + } + if ( fileOut.status() != IO_Ok ) { + tqWarning( "tquic: Error writing to file" ); + if ( !outputFile.isEmpty() ) + remove( outputFile ); + } + return 0; +} diff --git a/tools/designer/tquic/object.cpp b/tools/designer/tquic/object.cpp new file mode 100644 index 000000000..0ef19843f --- /dev/null +++ b/tools/designer/tquic/object.cpp @@ -0,0 +1,734 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tquic.h" +#include "parser.h" +#include "domtool.h" +#include +#include +#include +#define NO_STATIC_COLORS +#include +#include "../interfaces/widgetinterface.h" +#include "../shared/widgetdatabase.h" + +/*! + Creates a declaration for the object given in \a e. + + Children are not traversed recursively. + + \sa createObjectImpl() + */ +void TQUic::createObjectDecl( const TQDomElement& e ) +{ + if ( e.tagName() == "vbox" ) { + out << " TQVBoxLayout* " << registerObject(getLayoutName(e) ) << ";" << endl; + } else if ( e.tagName() == "hbox" ) { + out << " TQHBoxLayout* " << registerObject(getLayoutName(e) ) << ";" << endl; + } else if ( e.tagName() == "grid" ) { + out << " TQGridLayout* " << registerObject(getLayoutName(e) ) << ";" << endl; + } else { + TQString objClass = getClassName( e ); + if ( objClass.isEmpty() ) + return; + TQString objName = getObjectName( e ); + if ( objName.isEmpty() ) + return; + // ignore TQLayoutWidgets + if ( objClass == "TQLayoutWidget" ) + return; + // register the object and unify its name + objName = registerObject( objName ); + if ( objClass == "Line" ) + objClass = "TQFrame"; + else if (objClass == "Spacer") + objClass = "TQSpacerItem"; + out << " " << objClass << "* " << objName << ";" << endl; + } +} + + +/*! + 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() + */ + +static bool createdCentralWidget = FALSE; + +TQString TQUic::createObjectImpl( const TQDomElement &e, const TQString& parentClass, const TQString& par, const TQString& layout ) +{ + TQString parent( par ); + if ( parent == "this" && isMainWindow ) { + if ( !createdCentralWidget ) + out << indent << "setCentralWidget( new TQWidget( this, \"qt_central_widget\" ) );" << endl; + createdCentralWidget = TRUE; + parent = "centralWidget()"; + } + TQDomElement n; + TQString objClass, objName; + int numItems = 0; + int numColumns = 0; + int numRows = 0; + + 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 == "TQLayoutWidget"; + if ( isTmpObject ) { + if (( objClass[0] == 'T' ) && ( objClass[1] == 'Q' )) + objName = objClass.mid(2); + else + objName = objClass.lower(); + objName.prepend( "private" ); + } + + bool isLine = objClass == "Line"; + if ( isLine ) + objClass = "TQFrame"; + + out << endl; + if ( objClass == "TQLayoutWidget" ) { + if ( layout.isEmpty() ) { + // register the object and unify its name + objName = registerObject( objName ); + out << " TQWidget* " << objName << " = new 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; + } + } else if ( objClass != "TQToolBar" && objClass != "TQMenuBar" ) { + // register the object and unify its name + objName = registerObject( objName ); + out << " "; + if ( isTmpObject ) + out << objClass << "* "; + out << objName << " = new " << createObjectInstance( objClass, parent, objName ) << ";" << endl; + } + + lastItem = "0"; + // set the properties and insert items + bool hadFrameShadow = FALSE; + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "property" ) { + bool stdset = stdsetdef; + if ( n.hasAttribute( "stdset" ) ) + stdset = toBool( n.attribute( "stdset" ) ); + TQString prop = n.attribute( "name" ); + if ( prop == "database" ) + continue; + TQString value = setObjectProperty( objClass, objName, prop, n.firstChild().toElement(), stdset ); + if ( value.isEmpty() ) + continue; + if ( prop == "name" ) + continue; + if ( isLine && prop == "frameShadow" ) + hadFrameShadow = TRUE; + if ( prop == "buddy" && value.startsWith("\"") && value.endsWith("\"") ) { + buddies << Buddy( objName, value.mid(1, value.length() - 2 ) ); + continue; + } + if ( isLine && prop == "orientation" ) { + prop = "frameShape"; + if ( value.right(10) == "Horizontal" ) + value = "TQFrame::HLine"; + else + value = "TQFrame::VLine"; + if ( !hadFrameShadow ) { + prop = "frameStyle"; + value += " | TQFrame::Sunken"; + } + } + if ( prop == "buttonGroupId" ) { + if ( parentClass == "TQButtonGroup" ) + out << indent << parent << "->insert( " << objName << ", " << value << " );" << endl; + continue; + } + if ( prop == "frameworkCode" ) + continue; + if ( objClass == "TQMultiLineEdit" && + TQRegExp("echoMode|hMargin|maxLength|maxLines|undoEnabled").exactMatch(prop) ) + continue; + + TQString call = objName + "->"; + if ( stdset ) { + call += mkStdSet( prop ) + "( "; + } else { + call += "setProperty( \"" + prop + "\", "; + } + if ( prop == "accel" ) + call += "TQKeySequence( " + value + " ) );"; + else + call += value + " );"; + + if ( n.firstChild().toElement().tagName() == "string" || + prop == "currentItem" ) { + trout << indent << call << endl; + } else { + out << indent << call << endl; + } + } else if ( n.tagName() == "item" ) { + TQString call; + TQString value; + + if ( objClass.contains( "ListBox" ) ) { + call = createListBoxItemImpl( n, objName ); + if ( !call.isEmpty() ) { + if ( numItems == 0 ) + trout << indent << objName << "->clear();" << endl; + trout << indent << call << endl; + } + } else if ( objClass.contains( "ComboBox" ) ) { + call = createListBoxItemImpl( n, objName, &value ); + if ( !call.isEmpty() ) { + if ( numItems == 0 ) + trout << indent << objName << "->clear();" << endl; + trout << indent << call << endl; + } + } else if ( objClass.contains( "IconView" ) ) { + call = createIconViewItemImpl( n, objName ); + if ( !call.isEmpty() ) { + if ( numItems == 0 ) + trout << indent << objName << "->clear();" << endl; + trout << indent << call << endl; + } + } else if ( objClass.contains( "ListView" ) ) { + call = createListViewItemImpl( n, objName, TQString::null ); + if ( !call.isEmpty() ) { + if ( numItems == 0 ) + trout << indent << objName << "->clear();" << endl; + trout << call << endl; + } + } + if ( !call.isEmpty() ) + numItems++; + } else if ( n.tagName() == "column" || n.tagName() == "row" ) { + TQString call; + TQString value; + + if ( objClass.contains( "ListView" ) ) { + call = createListViewColumnImpl( n, objName, &value ); + if ( !call.isEmpty() ) { + out << call; + trout << indent << objName << "->header()->setLabel( " + << numColumns++ << ", " << value << " );\n"; + } + } else if ( objClass == "TQTable" || objClass == "TQDataTable" ) { + bool isCols = ( n.tagName() == "column" ); + call = createTableRowColumnImpl( n, objName, &value ); + if ( !call.isEmpty() ) { + out << call; + trout << indent << objName << "->" + << ( isCols ? "horizontalHeader" : "verticalHeader" ) + << "()->setLabel( " + << ( isCols ? numColumns++ : numRows++ ) + << ", " << value << " );\n"; + } + } + } + } + + // 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, objName ); + TQString comment; + TQString label = DomTool::readAttribute( n, "title", "", comment ).toString(); + out << indent << objName << "->insertTab( " << page << ", TQString::fromLatin1(\"\") );" << endl; + trout << indent << objName << "->changeTab( " << page << ", " + << trcall( label, comment ) << " );" << endl; + } + } + } else if ( objClass == "TQWidgetStack" ) { + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( tags.contains( n.tagName() ) ) { + TQString page = createObjectImpl( n, objClass, objName ); + int id = DomTool::readAttribute( n, "id", "" ).toInt(); + out << indent << objName << "->addWidget( " << page << ", " << id << " );" << endl; + } + } + } else if ( objClass == "TQToolBox" ) { + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( tags.contains( n.tagName() ) ) { + TQString page = createObjectImpl( n, objClass, objName ); + TQString comment; + TQString label = DomTool::readAttribute( n, "label", "", comment ).toString(); + out << indent << objName << "->addItem( " << page << ", TQString::fromLatin1(\"\") );" << endl; + trout << indent << objName << "->setItemLabel( " << objName + << "->indexOf(" << page << "), " << trcall( label, comment ) + << " );" << endl; + } + } + } else if ( objClass != "TQToolBar" && objClass != "TQMenuBar" ) { // standard widgets + WidgetInterface *iface = 0; + widgetManager()->queryInterface( objClass, &iface ); +#ifdef QT_CONTAINER_CUSTOM_WIDGETS + int id = WidgetDatabase::idFromClassName( objClass ); + if ( WidgetDatabase::isContainer( id ) && WidgetDatabase::isCustomPluginWidget( id ) && iface ) { + TQWidgetContainerInterfacePrivate *iface2 = 0; + iface->queryInterface( IID_QWidgetContainer, (TQUnknownInterface**)&iface2 ); + if ( iface2 ) { + bool supportsPages = iface2->supportsPages( objClass ); + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( tags.contains( n.tagName() ) ) { + if ( supportsPages ) { + TQString page = createObjectImpl( n, objClass, objName ); + TQString comment; + TQString label = DomTool::readAttribute( n, "label", "", comment ).toString(); + out << indent << iface2->createCode( objClass, objName, page, label ) << endl; + } else { + createObjectImpl( n, objClass, objName ); + } + } + } + iface2->release(); + } + iface->release(); + } else { +#endif + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( tags.contains( n.tagName() ) ) + createObjectImpl( n, objClass, objName ); + } +#ifdef QT_CONTAINER_CUSTOM_WIDGETS + } +#endif + } + + return objName; +} + +/*! + Creates declarations for spacer items that are children of \a e. + + \sa createObjectDecl() +*/ + +void TQUic::createSpacerDecl( const TQDomElement &e ) +{ + for ( TQDomElement n = e.firstChild().toElement(); + !n.isNull(); n = n.nextSibling().toElement() ) + if ( n.tagName() == "spacer" ) + out << " TQSpacerItem* " << registerObject(getObjectName(n)) << ";" << endl; +} + +/*! + 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 TQUic::createExclusiveProperty( const TQDomElement & e, const TQString& exclusiveProp ) +{ + TQDomElement n; + TQString objClass = getClassName( e ); + if ( objClass.isEmpty() ) + return; + TQString objName = getObjectName( e ); +#if 0 // it's not clear whether this check should be here or not + if ( objName.isEmpty() ) + return; +#endif + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "property" ) { + bool stdset = stdsetdef; + if ( n.hasAttribute( "stdset" ) ) + stdset = toBool( n.attribute( "stdset" ) ); + TQString prop = n.attribute( "name" ); + if ( prop != exclusiveProp ) + continue; + TQString value = setObjectProperty( objClass, objName, prop, n.firstChild().toElement(), stdset ); + if ( value.isEmpty() ) + continue; + // we assume the property isn't of type 'string' + out << '\t' << objName << "->setProperty( \"" << prop << "\", " << value << " );" << endl; + } + } +} + + +/*! Attention: this function has to be in sync with + Resource::saveProperty() and DomTool::elementToVariant. If you + change one, change all. + */ +TQString TQUic::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 attrname = e.parentNode().toElement().attribute( "name", "font" ); + TQString fontname; + if ( !obj.isEmpty() ) { + fontname = registerObject( obj + "_" + attrname ); + out << indent << "TQFont " << fontname << "( " << obj << "->font() );" << endl; + } else { + fontname = registerObject( "f" ); + out << indent << "TQFont " << fontname << "( 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 << obj << "->setFont( " << fontname << " ); " << endl; + else + out << indent << "setFont( " << fontname << " ); " << endl; + } else { + v = fontname; + } + } else if ( e.tagName() == "string" ) { + TQString txt = e.firstChild().toText().data(); + TQString com = getComment( e.parentNode() ); + + if ( prop == "toolTip" && objClass != "TQAction" && objClass != "TQActionGroup" ) { + if ( !obj.isEmpty() ) + trout << indent << "TQToolTip::add( " << obj << ", " + << trcall( txt, com ) << " );" << endl; + else + trout << indent << "TQToolTip::add( this, " + << trcall( txt, com ) << " );" << endl; + } else if ( prop == "whatsThis" && objClass != "TQAction" && objClass != "TQActionGroup" ) { + if ( !obj.isEmpty() ) + trout << indent << "TQWhatsThis::add( " << obj << ", " + << trcall( txt, com ) << " );" << endl; + else + trout << indent << "TQWhatsThis::add( this, " + << trcall( txt, com ) << " );" << endl; + } else { + v = trcall( txt, com ); + } + } 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 = "TQVariant( %1 )"; + v = v.arg( mkBool( e.firstChild().toText().data() ) ); + } else if ( e.tagName() == "pixmap" ) { + v = e.firstChild().toText().data(); + if ( !pixmapLoaderFunction.isEmpty() ) { + v.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); + v.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); + } + } else if ( e.tagName() == "iconset" ) { + v = "TQIconSet( %1 )"; + TQString s = e.firstChild().toText().data(); + if ( !pixmapLoaderFunction.isEmpty() ) { + s.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); + s.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); + } + v = v.arg( s ); + } else if ( e.tagName() == "image" ) { + v = e.firstChild().toText().data() + ".convertToImage()"; + } else if ( e.tagName() == "enum" ) { + if ( stdset ) + v = "%1::%2"; + else + v = "\"%1\""; + TQString oc = objClass; + TQString ev = e.firstChild().toText().data(); + if ( oc == "TQListView" && ev == "Manual" ) // #### workaround, rename TQListView::Manual in 4.0 + oc = "TQScrollView"; + if ( stdset ) + v = v.arg( oc ).arg( ev ); + else + v = v.arg( ev ); + } else if ( e.tagName() == "set" ) { + TQString keys( e.firstChild().toText().data() ); + TQStringList lst = TQStringList::split( '|', keys ); + v = "int( "; + TQStringList::Iterator it = lst.begin(); + while ( it != lst.end() ) { + v += objClass + "::" + *it; + if ( it != lst.fromLast() ) + v += " | "; + ++it; + } + 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() ); + else if ( n3.tagName() == "horstretch" ) + sp.setHorStretch( n3.firstChild().toText().data().toInt() ); + else if ( n3.tagName() == "verstretch" ) + sp.setVerStretch( n3.firstChild().toText().data().toInt() ); + n3 = n3.nextSibling().toElement(); + } + TQString tmp; + if ( !obj.isEmpty() ) + tmp = obj + "->"; + v = "TQSizePolicy( (TQSizePolicy::SizeType)%1, (TQSizePolicy::SizeType)%2, %3, %4, " + tmp + "sizePolicy().hasHeightForWidth() )"; + v = v.arg( (int)sp.horData() ).arg( (int)sp.verData() ).arg( sp.horStretch() ).arg( sp.verStretch() ); + } 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 << "TQPalette " << palette << ";" << endl; + pal_used = TRUE; + } + TQString cg = "cg"; + if ( !cg_used ) { + out << indent << "TQColorGroup " << cg << ";" << 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() ); + } else if ( e.tagName() == "date" ) { + TQDomElement n3 = e.firstChild().toElement(); + int y, m, d; + y = m = d = 0; + while ( !n3.isNull() ) { + if ( n3.tagName() == "year" ) + y = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "month" ) + m = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "day" ) + d = n3.firstChild().toText().data().toInt(); + n3 = n3.nextSibling().toElement(); + } + v = "TQDate( %1, %2, %3 )"; + v = v.arg(y).arg(m).arg(d); + } else if ( e.tagName() == "time" ) { + TQDomElement n3 = e.firstChild().toElement(); + int h, m, s; + h = m = s = 0; + while ( !n3.isNull() ) { + if ( n3.tagName() == "hour" ) + h = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "minute" ) + m = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "second" ) + s = n3.firstChild().toText().data().toInt(); + n3 = n3.nextSibling().toElement(); + } + v = "TQTime( %1, %2, %3 )"; + v = v.arg(h).arg(m).arg(s); + } else if ( e.tagName() == "datetime" ) { + TQDomElement n3 = e.firstChild().toElement(); + int h, mi, s, y, mo, d; + h = mi = s = y = mo = d = 0; + while ( !n3.isNull() ) { + if ( n3.tagName() == "hour" ) + h = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "minute" ) + mi = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "second" ) + s = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "year" ) + y = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "month" ) + mo = n3.firstChild().toText().data().toInt(); + else if ( n3.tagName() == "day" ) + d = n3.firstChild().toText().data().toInt(); + n3 = n3.nextSibling().toElement(); + } + v = "TQDateTime( TQDate( %1, %2, %3 ), TQTime( %4, %5, %6 ) )"; + v = v.arg(y).arg(mo).arg(d).arg(h).arg(mi).arg(s); + } else if ( e.tagName() == "stringlist" ) { + TQStringList l; + TQDomElement n3 = e.firstChild().toElement(); + TQString listname = "l"; + if ( !obj.isEmpty() ) { + listname = obj + "_stringlist"; + listname = registerObject( listname ); + out << indent << "TQStringList " << listname << ";" << endl; + } else { + listname = registerObject( listname ); + out << indent << "TQStringList " << listname << ";" << endl; + } + while ( !n3.isNull() ) { + if ( n3.tagName() == "string" ) + out << indent << listname << " << \"" << n3.firstChild().toText().data().simplifyWhiteSpace() << "\";" << endl; + n3 = n3.nextSibling().toElement(); + } + v = listname; + } + return v; +} + +/*! Extracts a named object property from \a e. + */ +TQDomElement TQUic::getObjectProperty( const TQDomElement& e, const TQString& name ) +{ + TQDomElement n; + for ( n = e.firstChild().toElement(); + !n.isNull(); + n = n.nextSibling().toElement() ) { + if ( n.tagName() == "property" && n.toElement().attribute("name") == name ) + return n; + } + return n; +} diff --git a/tools/designer/tquic/subclassing.cpp b/tools/designer/tquic/subclassing.cpp new file mode 100644 index 000000000..2ceed658e --- /dev/null +++ b/tools/designer/tquic/subclassing.cpp @@ -0,0 +1,352 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tquic.h" +#include "parser.h" +#include "widgetdatabase.h" +#include "domtool.h" +#include +#include +#include +#define NO_STATIC_COLORS +#include +#include +#include +#include + +/*! + Creates a declaration ( headerfile ) for a subclass \a subClass + of the form given in \a e + + \sa createSubImpl() + */ +void TQUic::createSubDecl( const TQDomElement &e, const TQString& subClass ) +{ + TQDomElement n; + TQDomNodeList nl; + int i; + + TQString objClass = getClassName( e ); + if ( objClass.isEmpty() ) + return; + + out << "class " << subClass << " : public " << nameOfClass << endl; + out << "{" << endl; + +/* tmake ignore TQ_OBJECT */ + out << " TQ_OBJECT" << endl; + out << endl; + out << "public:" << endl; + + // constructor + if ( objClass == "TQDialog" || objClass == "TQWizard" ) { + out << " " << subClass << "( TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );" << endl; + } else { // standard TQWidget + out << " " << subClass << "( TQWidget* parent = 0, const char* name = 0, WFlags fl = 0 );" << endl; + } + + // destructor + out << " ~" << subClass << "();" << endl; + out << endl; + + // find additional functions + TQStringList publicSlots, protectedSlots, privateSlots; + TQStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes; + TQStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier; + TQStringList publicFuncts, protectedFuncts, privateFuncts; + TQStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp; + TQStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec; + + nl = e.parentNode().toElement().elementsByTagName( "slot" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item(i).toElement(); + if ( n.parentNode().toElement().tagName() != "slots" + && n.parentNode().toElement().tagName() != "connections" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString returnType = n.attribute( "returnType", "void" ); + TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); + if ( functionName.endsWith( ";" ) ) + functionName = functionName.left( functionName.length() - 1 ); + TQString specifier = n.attribute( "specifier" ); + TQString access = n.attribute( "access" ); + if ( access == "protected" ) { + protectedSlots += functionName; + protectedSlotTypes += returnType; + protectedSlotSpecifier += specifier; + } else if ( access == "private" ) { + privateSlots += functionName; + privateSlotTypes += returnType; + privateSlotSpecifier += specifier; + } else { + publicSlots += functionName; + publicSlotTypes += returnType; + publicSlotSpecifier += specifier; + } + } + + nl = e.parentNode().toElement().elementsByTagName( "function" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item(i).toElement(); + if ( n.parentNode().toElement().tagName() != "functions" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString returnType = n.attribute( "returnType", "void" ); + TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); + if ( functionName.endsWith( ";" ) ) + functionName = functionName.left( functionName.length() - 1 ); + TQString specifier = n.attribute( "specifier" ); + TQString access = n.attribute( "access" ); + if ( access == "protected" ) { + protectedFuncts += functionName; + protectedFunctRetTyp += returnType; + protectedFunctSpec += specifier; + } else if ( access == "private" ) { + privateFuncts += functionName; + privateFunctRetTyp += returnType; + privateFunctSpec += specifier; + } else { + publicFuncts += functionName; + publicFunctRetTyp += returnType; + publicFunctSpec += specifier; + } + } + + if ( !publicFuncts.isEmpty() ) + writeFunctionsSubDecl( publicFuncts, publicFunctRetTyp, publicFunctSpec ); + + // create public additional slots + if ( !publicSlots.isEmpty() ) { + out << "public slots:" << endl; + writeFunctionsSubDecl( publicSlots, publicSlotTypes, publicSlotSpecifier ); + } + + if ( !protectedFuncts.isEmpty() ) { + out << "protected:" << endl; + writeFunctionsSubDecl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec ); + } + + // create protected additional slots + if ( !protectedSlots.isEmpty() ) { + out << "protected slots:" << endl; + writeFunctionsSubDecl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier ); + } + + if ( !privateFuncts.isEmpty() ) { + out << "private:" << endl; + writeFunctionsSubDecl( privateFuncts, privateFunctRetTyp, privateFunctSpec ); + } + + // create private additional slots + if ( !privateSlots.isEmpty() ) { + out << "private slots:" << endl; + writeFunctionsSubDecl( privateSlots, privateSlotTypes, privateSlotSpecifier ); + } + out << "};" << endl; +} + +void TQUic::writeFunctionsSubDecl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst ) +{ + TQValueListConstIterator it, it2, it3; + for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin(); + it != fuLst.end(); ++it, ++it2, ++it3 ) { + TQString type = *it2; + if ( type.isEmpty() ) + type = "void"; + if ( *it3 == "non virtual" ) + continue; + out << " " << type << " " << (*it) << ";" << endl; + } + out << endl; +} + +/*! + Creates an implementation for a subclass \a subClass of the form + given in \a e + + \sa createSubDecl() + */ +void TQUic::createSubImpl( const TQDomElement &e, const TQString& subClass ) +{ + TQDomElement n; + TQDomNodeList nl; + int i; + + TQString objClass = getClassName( e ); + if ( objClass.isEmpty() ) + return; + + // constructor + if ( objClass == "TQDialog" || objClass == "TQWizard" ) { + out << "/* " << endl; + out << " * Constructs a " << subClass << " which is a child of 'parent', with the " << endl; + out << " * name 'name' and widget flags set to 'f' " << endl; + out << " *" << endl; + out << " * The " << objClass.mid(1).lower() << " will by default be modeless, unless you set 'modal' to" << endl; + out << " * TRUE to construct a modal " << objClass.mid(1).lower() << "." << endl; + out << " */" << endl; + out << subClass << "::" << subClass << "( TQWidget* parent, const char* name, bool modal, WFlags fl )" << endl; + out << " : " << nameOfClass << "( parent, name, modal, fl )" << endl; + } else { // standard TQWidget + out << "/* " << endl; + out << " * Constructs a " << subClass << " which is a child of 'parent', with the " << endl; + out << " * name 'name' and widget flags set to 'f' " << endl; + out << " */" << endl; + out << subClass << "::" << subClass << "( TQWidget* parent, const char* name, WFlags fl )" << endl; + out << " : " << nameOfClass << "( parent, name, fl )" << endl; + } + out << "{" << endl; + out << "}" << endl; + out << endl; + + // destructor + out << "/* " << endl; + out << " * Destroys the object and frees any allocated resources" << endl; + out << " */" << endl; + out << subClass << "::~" << subClass << "()" << endl; + out << "{" << endl; + out << " // no need to delete child widgets, TQt does it all for us" << endl; + out << "}" << endl; + out << endl; + + + // find additional functions + TQStringList publicSlots, protectedSlots, privateSlots; + TQStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes; + TQStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier; + TQStringList publicFuncts, protectedFuncts, privateFuncts; + TQStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp; + TQStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec; + + nl = e.parentNode().toElement().elementsByTagName( "slot" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item(i).toElement(); + if ( n.parentNode().toElement().tagName() != "slots" + && n.parentNode().toElement().tagName() != "connections" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString returnType = n.attribute( "returnType", "void" ); + TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); + if ( functionName.endsWith( ";" ) ) + functionName = functionName.left( functionName.length() - 1 ); + TQString specifier = n.attribute( "specifier" ); + TQString access = n.attribute( "access" ); + if ( access == "protected" ) { + protectedSlots += functionName; + protectedSlotTypes += returnType; + protectedSlotSpecifier += specifier; + } else if ( access == "private" ) { + privateSlots += functionName; + privateSlotTypes += returnType; + privateSlotSpecifier += specifier; + } else { + publicSlots += functionName; + publicSlotTypes += returnType; + publicSlotSpecifier += specifier; + } + } + + nl = e.parentNode().toElement().elementsByTagName( "function" ); + for ( i = 0; i < (int) nl.length(); i++ ) { + n = nl.item(i).toElement(); + if ( n.parentNode().toElement().tagName() != "functions" ) + continue; + if ( n.attribute( "language", "C++" ) != "C++" ) + continue; + TQString returnType = n.attribute( "returnType", "void" ); + TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); + if ( functionName.endsWith( ";" ) ) + functionName = functionName.left( functionName.length() - 1 ); + TQString specifier = n.attribute( "specifier" ); + TQString access = n.attribute( "access" ); + if ( access == "protected" ) { + protectedFuncts += functionName; + protectedFunctRetTyp += returnType; + protectedFunctSpec += specifier; + } else if ( access == "private" ) { + privateFuncts += functionName; + privateFunctRetTyp += returnType; + privateFunctSpec += specifier; + } else { + publicFuncts += functionName; + publicFunctRetTyp += returnType; + publicFunctSpec += specifier; + } + } + + if ( !publicFuncts.isEmpty() ) + writeFunctionsSubImpl( publicFuncts, publicFunctRetTyp, publicFunctSpec, subClass, "public function" ); + + // create stubs for public additional slots + if ( !publicSlots.isEmpty() ) + writeFunctionsSubImpl( publicSlots, publicSlotTypes, publicSlotSpecifier, subClass, "public slot" ); + + if ( !protectedFuncts.isEmpty() ) + writeFunctionsSubImpl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec, subClass, "protected function" ); + + // create stubs for protected additional slots + if ( !protectedSlots.isEmpty() ) + writeFunctionsSubImpl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier, subClass, "protected slot" ); + + if ( !privateFuncts.isEmpty() ) + writeFunctionsSubImpl( privateFuncts, privateFunctRetTyp, privateFunctSpec, subClass, "private function" ); + + // create stubs for private additional slots + if ( !privateSlots.isEmpty() ) + writeFunctionsSubImpl( privateSlots, privateSlotTypes, privateSlotSpecifier, subClass, "private slot" ); +} + +void TQUic::writeFunctionsSubImpl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst, + const TQString &subClass, const TQString &descr ) +{ + TQValueListConstIterator it, it2, it3; + for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin(); + it != fuLst.end(); ++it, ++it2, ++it3 ) { + TQString type = *it2; + if ( type.isEmpty() ) + type = "void"; + if ( *it3 == "non virtual" ) + continue; + out << "/*" << endl; + out << " * " << descr << endl; + out << " */" << endl; + out << type << " " << subClass << "::" << (*it) << endl; + out << "{" << endl; + out << " tqWarning( \"" << subClass << "::" << (*it) << " not yet implemented!\" );" << endl; + out << "}" << endl << endl; + } + out << endl; +} diff --git a/tools/designer/tquic/tquic.cpp b/tools/designer/tquic/tquic.cpp new file mode 100644 index 000000000..b39ba4a4b --- /dev/null +++ b/tools/designer/tquic/tquic.cpp @@ -0,0 +1,1129 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tquic.h" +#include "parser.h" +#include "widgetdatabase.h" +#include "domtool.h" +#include +#include +#include +#define NO_STATIC_COLORS +#include +#include +#include +#include + +bool TQUic::isMainWindow = FALSE; + +TQString TQUic::getComment( const TQDomNode& n ) +{ + TQDomNode child = n.firstChild(); + while ( !child.isNull() ) { + if ( child.toElement().tagName() == "comment" ) + return child.toElement().firstChild().toText().data(); + child = child.nextSibling(); + } + return TQString::null; +} + +TQString TQUic::mkBool( bool b ) +{ + return b? "TRUE" : "FALSE"; +} + +TQString TQUic::mkBool( const TQString& s ) +{ + return mkBool( s == "true" || s == "1" ); +} + +bool TQUic::toBool( const TQString& s ) +{ + return s == "true" || s.toInt() != 0; +} + +TQString TQUic::fixString( const TQString &str, bool encode ) +{ + TQString s; + if ( !encode ) { + s = str; + s.replace( "\\", "\\\\" ); + s.replace( "\"", "\\\"" ); + s.replace( "\r", "" ); + s.replace( "\n", "\\n\"\n\"" ); + } else { + TQCString utf8 = str.utf8(); + const int l = utf8.length(); + + for ( int i = 0; i < l; ++i ) { + uchar c = (uchar)utf8[i]; + if (c != 0x0d) // skip \r + s += "\\x" + TQString::number(c, 16); + + if (i && (i % 20) == 0) + s += "\"\n \""; + } + } + + return "\"" + s + "\""; +} + +TQString TQUic::trcall( const TQString& sourceText, const TQString& comment ) +{ + if ( sourceText.isEmpty() && comment.isEmpty() ) + return "TQString::null"; + + TQString t = trmacro; + bool encode = FALSE; + if ( t.isNull() ) { + t = "tr"; + for ( int i = 0; i < (int) sourceText.length(); i++ ) { + if ( sourceText[i].unicode() >= 0x80 ) { + t = "trUtf8"; + encode = TRUE; + break; + } + } + } + + if ( comment.isEmpty() ) { + return t + "( " + fixString( sourceText, encode ) + " )"; + } else { + return t + "( " + fixString( sourceText, encode ) + ", " + + fixString( comment, encode ) + " )"; + } +} + +TQString TQUic::mkStdSet( const TQString& prop ) +{ + return TQString( "set" ) + prop[0].upper() + prop.mid(1); +} + + + +/*! + \class TQUic tquic.h + \brief User Interface Compiler + + The class TQUic encapsulates the user interface compiler (tquic). + */ +TQUic::TQUic( const TQString &fn, const char *outputFn, TQTextStream &outStream, + TQDomDocument doc, bool decl, bool subcl, const TQString &trm, + const TQString& subClass, bool omitForwardDecls ) + : out( outStream ), trout( &languageChangeBody ), + outputFileName( outputFn ), trmacro( trm ), nofwd( omitForwardDecls ) +{ + fileName = fn; + writeFunctImpl = TRUE; + defMargin = BOXLAYOUT_DEFAULT_MARGIN; + defSpacing = BOXLAYOUT_DEFAULT_SPACING; + externPixmaps = FALSE; + indent = " "; // default indent + + item_used = cg_used = pal_used = 0; + + layouts << "hbox" << "vbox" << "grid"; + tags = layouts; + tags << "widget"; + + pixmapLoaderFunction = getPixmapLoaderFunction( doc.firstChild().toElement() ); + nameOfClass = getFormClassName( doc.firstChild().toElement() ); + + uiFileVersion = doc.firstChild().toElement().attribute("version"); + stdsetdef = toBool( doc.firstChild().toElement().attribute("stdsetdef") ); + + if ( doc.firstChild().isNull() || doc.firstChild().firstChild().isNull() ) + return; + TQDomElement e = doc.firstChild().firstChild().toElement(); + TQDomElement widget; + while ( !e.isNull() ) { + if ( e.tagName() == "widget" ) { + widget = e; + } else if ( e.tagName() == "pixmapinproject" ) { + externPixmaps = TRUE; + } else if ( e.tagName() == "layoutdefaults" ) { + defSpacing = e.attribute( "spacing", defSpacing.toString() ); + defMargin = e.attribute( "margin", defMargin.toString() ); + } else if ( e.tagName() == "layoutfunctions" ) { + defSpacing = e.attribute( "spacing", defSpacing.toString() ); + bool ok; + defSpacing.toInt( &ok ); + if ( !ok ) { + TQString buf = defSpacing.toString(); + defSpacing = buf.append( "()" ); + } + defMargin = e.attribute( "margin", defMargin.toString() ); + defMargin.toInt( &ok ); + if ( !ok ) { + TQString buf = defMargin.toString(); + defMargin = buf.append( "()" ); + } + } + e = e.nextSibling().toElement(); + } + e = widget; + + if ( nameOfClass.isEmpty() ) + nameOfClass = getObjectName( e ); + namespaces = TQStringList::split( "::", nameOfClass ); + bareNameOfClass = namespaces.last(); + namespaces.remove( namespaces.fromLast() ); + + if ( subcl ) { + if ( decl ) + createSubDecl( e, subClass ); + else + createSubImpl( e, subClass ); + } else { + if ( decl ) + createFormDecl( e ); + else + createFormImpl( e ); + } + +} + +/*! Extracts a pixmap loader function from \a e + */ +TQString TQUic::getPixmapLoaderFunction( const TQDomElement& e ) +{ + TQDomElement n; + for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "pixmapfunction" ) + return n.firstChild().toText().data(); + } + return TQString::null; +} + + +/*! Extracts the forms class name from \a e + */ +TQString TQUic::getFormClassName( 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; + } + } + return cn; +} + +/*! Extracts a class name from \a e. + */ +TQString TQUic::getClassName( const TQDomElement& e ) +{ + TQString s = e.attribute( "class" ); + if ( s.isEmpty() && e.tagName() == "toolbar" ) + s = "TQToolBar"; + else if ( s.isEmpty() && e.tagName() == "menubar" ) + s = "TQMenuBar"; + return s; +} + +/*! Returns TRUE if database framework code is generated, else FALSE. +*/ + +bool TQUic::isFrameworkCodeGenerated( const TQDomElement& e ) +{ + TQDomElement n = getObjectProperty( e, "frameworkCode" ); + if ( n.attribute("name") == "frameworkCode" && + !DomTool::elementToVariant( n.firstChild().toElement(), TQVariant( true ) ).toBool() ) + return FALSE; + return TRUE; +} + +/*! Extracts an object name from \a e. It's stored in the 'name' + property. + */ +TQString TQUic::getObjectName( const TQDomElement& e ) +{ + TQDomElement n = getObjectProperty( e, "name" ); + if ( n.firstChild().toElement().tagName() == "cstring" ) + return n.firstChild().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 TQLayoutWidget). + */ +TQString TQUic::getLayoutName( const TQDomElement& e ) +{ + TQDomElement p = e.parentNode().toElement(); + TQString name; + + if ( getClassName(p) != "TQLayoutWidget" ) + name = "Layout"; + + TQDomElement n = getObjectProperty( p, "name" ); + if ( n.firstChild().toElement().tagName() == "cstring" ) { + name.prepend( n.firstChild().toElement().firstChild().toText().data() ); + return TQStringList::split( "::", name ).last(); + } + return e.tagName(); +} + + +TQString TQUic::getDatabaseInfo( const TQDomElement& e, const TQString& tag ) +{ + TQDomElement n; + TQDomElement n1; + int child = 0; + // database info is a stringlist stored in this order + if ( tag == "connection" ) + child = 0; + else if ( tag == "table" ) + child = 1; + else if ( tag == "field" ) + child = 2; + else + return TQString::null; + n = getObjectProperty( e, "database" ); + if ( n.firstChild().toElement().tagName() == "stringlist" ) { + // find correct stringlist entry + TQDomElement n1 = n.firstChild().firstChild().toElement(); + for ( int i = 0; i < child && !n1.isNull(); ++i ) + n1 = n1.nextSibling().toElement(); + if ( n1.isNull() ) + return TQString::null; + return n1.firstChild().toText().data(); + } + return TQString::null; +} + + +void TQUic::registerLayouts( const TQDomElement &e ) +{ + if ( layouts.contains(e.tagName())) { + createObjectDecl(e); + TQString t = e.tagName(); + if ( t == "vbox" || t == "hbox" || t == "grid" ) + createSpacerDecl( e ); + } + + TQDomNodeList nl = e.childNodes(); + for ( int i = 0; i < (int) nl.length(); ++i ) + registerLayouts( nl.item(i).toElement() ); +} + + +/*! + Returns include file for class \a className or a null string. + */ +TQString TQUic::getInclude( const TQString& className ) +{ + int wid = WidgetDatabase::idFromClassName( className ); + if ( wid != -1 ) + return WidgetDatabase::includeFile( wid ); + return TQString::null; +} + + +void TQUic::createActionDecl( const TQDomElement& e ) +{ + TQString objClass = e.tagName() == "action" ? "TQAction" : "TQActionGroup"; + TQString objName = getObjectName( e ); + if ( objName.isEmpty() ) + return; + out << " " << objClass << "* " << objName << ";" << endl; + if ( e.tagName() == "actiongroup" ) { + for ( TQDomElement n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "action" || n.tagName() == "actiongroup" ) + createActionDecl( n ); + } + } +} + +void TQUic::createToolbarDecl( const TQDomElement &e ) +{ + if ( e.tagName() == "toolbar" ) + out << " " << "TQToolBar *" << getObjectName( e ) << ";" << endl; +} + +void TQUic::createMenuBarDecl( const TQDomElement &e ) +{ + if ( e.tagName() == "item" ) { + out << " " << "TQPopupMenu *" << e.attribute( "name" ) << ";" << endl; + createPopupMenuDecl( e ); + } +} + +void TQUic::createPopupMenuDecl( const TQDomElement &e ) +{ + for ( TQDomElement n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "action" || n.tagName() == "actiongroup" ) { + TQDomElement n2 = n.nextSibling().toElement(); + if ( n2.tagName() == "item" ) { // the action has a sub menu + out << " " << "TQPopupMenu *" << n2.attribute( "name" ) << ";" << endl; + createPopupMenuDecl( n2 ); + n = n2; + } + } + } +} + +void TQUic::createActionImpl( const TQDomElement &n, const TQString &parent ) +{ + for ( TQDomElement ae = n; !ae.isNull(); ae = ae.nextSibling().toElement() ) { + TQString objName = registerObject( getObjectName( ae ) ); + if ( ae.tagName() == "action" ) + out << indent << objName << " = new TQAction( " << parent << ", \"" << objName << "\" );" << endl; + else if ( ae.tagName() == "actiongroup" ) + out << indent << objName << " = new TQActionGroup( " << parent << ", \"" << objName << "\" );" << endl; + else + continue; + bool subActionsDone = FALSE; + bool hasMenuText = FALSE; + TQString actionText; + for ( TQDomElement n2 = ae.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) { + if ( n2.tagName() == "property" ) { + bool stdset = stdsetdef; + if ( n2.hasAttribute( "stdset" ) ) + stdset = toBool( n2.attribute( "stdset" ) ); + TQString prop = n2.attribute("name"); + if ( prop == "name" ) + continue; + TQString value = setObjectProperty( "TQAction", objName, prop, n2.firstChild().toElement(), stdset ); + if ( value.isEmpty() ) + continue; + + TQString call = objName + "->"; + if ( stdset ) { + call += mkStdSet( prop ) + "( "; + } else { + call += "setProperty( \"" + prop + "\", "; + } + call += value + " );"; + + if (prop == "menuText") + hasMenuText = TRUE; + else if (prop == "text") + actionText = value; + + if ( n2.firstChild().toElement().tagName() == "string" ) { + trout << indent << call << endl; + } else { + out << indent << call << endl; + } + } else if ( !subActionsDone && ( n2.tagName() == "actiongroup" || n2.tagName() == "action" ) ) { + createActionImpl( n2, objName ); + subActionsDone = TRUE; + } + } + // workaround for loading pre-3.3 files expecting bogus TQAction behavior + if (!hasMenuText && !actionText.isEmpty() && uiFileVersion < "3.3") + trout << indent << objName << "->setMenuText(" << actionText << ");" << endl; + } +} + +TQString get_dock( const TQString &d ) +{ + if ( d == "0" ) + return "DockUnmanaged"; + if ( d == "1" ) + return "DockTornOff"; + if ( d == "2" ) + return "DockTop"; + if ( d == "3" ) + return "DockBottom"; + if ( d == "4" ) + return "DockRight"; + if ( d == "5" ) + return "DockLeft"; + if ( d == "6" ) + return "DockMinimized"; + return ""; +} + +void TQUic::createToolbarImpl( const TQDomElement &n, const TQString &parentClass, const TQString &parent ) +{ + TQDomNodeList nl = n.elementsByTagName( "toolbar" ); + for ( int i = 0; i < (int) nl.length(); i++ ) { + TQDomElement ae = nl.item( i ).toElement(); + TQString dock = get_dock( ae.attribute( "dock" ) ); + TQString objName = getObjectName( ae ); + out << indent << objName << " = new TQToolBar( TQString(\"\"), this, " << dock << " ); " << endl; + createObjectImpl( ae, parentClass, parent ); + for ( TQDomElement n2 = ae.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) { + if ( n2.tagName() == "action" ) { + out << indent << n2.attribute( "name" ) << "->addTo( " << objName << " );" << endl; + } else if ( n2.tagName() == "separator" ) { + out << indent << objName << "->addSeparator();" << endl; + } else if ( n2.tagName() == "widget" ) { + if ( n2.attribute( "class" ) != "Spacer" ) { + createObjectImpl( n2, "TQToolBar", objName ); + } else { + TQString child = createSpacerImpl( n2, parentClass, parent, objName ); + out << indent << "TQApplication::sendPostedEvents( " << objName + << ", TQEvent::ChildInserted );" << endl; + out << indent << objName << "->boxLayout()->addItem( " << child << " );" << endl; + } + } + } + } +} + +void TQUic::createMenuBarImpl( const TQDomElement &n, const TQString &parentClass, const TQString &parent ) +{ + TQString objName = getObjectName( n ); + out << indent << objName << " = new TQMenuBar( this, \"" << objName << "\" );" << endl; + createObjectImpl( n, parentClass, parent ); + int i = 0; + TQDomElement c = n.firstChild().toElement(); + while ( !c.isNull() ) { + if ( c.tagName() == "item" ) { + TQString itemName = c.attribute( "name" ); + out << endl; + out << indent << itemName << " = new TQPopupMenu( this );" << endl; + createPopupMenuImpl( c, parentClass, itemName ); + out << indent << objName << "->insertItem( TQString(\"\"), " << itemName << ", " << i << " );" << endl; + TQString findItem(objName + "->findItem(%1)"); + findItem = findItem.arg(i); + trout << indent << "if (" << findItem << ")" << endl; + trout << indent << indent << findItem << "->setText( " << trcall( c.attribute( "text" ) ) << " );" << endl; + } else if ( c.tagName() == "separator" ) { + out << endl; + out << indent << objName << "->insertSeparator( " << i << " );" << endl; + } + c = c.nextSibling().toElement(); + i++; + } +} + +void TQUic::createPopupMenuImpl( const TQDomElement &e, const TQString &parentClass, const TQString &parent ) +{ + int i = 0; + for ( TQDomElement n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "action" || n.tagName() == "actiongroup" ) { + TQDomElement n2 = n.nextSibling().toElement(); + if ( n2.tagName() == "item" ) { // the action has a sub menu + TQString itemName = n2.attribute( "name" ); + TQString itemText = n2.attribute( "text" ); + out << indent << itemName << " = new TQPopupMenu( this );" << endl; + out << indent << parent << "->insertItem( " << n.attribute( "name" ) << "->iconSet(), "; + out << trcall( itemText ) << ", " << itemName << " );" << endl; + trout << indent << parent << "->changeItem( " << parent << "->idAt( " << i << " ), "; + trout << trcall( itemText ) << " );" << endl; + createPopupMenuImpl( n2, parentClass, itemName ); + n = n2; + } else { + out << indent << n.attribute( "name" ) << "->addTo( " << parent << " );" << endl; + } + } else if ( n.tagName() == "separator" ) { + out << indent << parent << "->insertSeparator();" << endl; + } + ++i; + } +} + +/*! + Creates implementation of an listbox item tag. +*/ + +TQString TQUic::createListBoxItemImpl( const TQDomElement &e, const TQString &parent, + TQString *value ) +{ + TQDomElement n = e.firstChild().toElement(); + TQString txt; + TQString com; + TQString pix; + while ( !n.isNull() ) { + if ( n.tagName() == "property" ) { + TQString attrib = n.attribute( "name" ); + TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); + if ( attrib == "text" ) { + txt = v.toString(); + com = getComment( n ); + } else if ( attrib == "pixmap" ) { + pix = v.toString(); + if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { + pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); + pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); + } + } + } + n = n.nextSibling().toElement(); + } + + if ( value ) + *value = trcall( txt, com ); + + if ( pix.isEmpty() ) { + return parent + "->insertItem( " + trcall( txt, com ) + " );"; + } else { + return parent + "->insertItem( " + pix + ", " + trcall( txt, com ) + " );"; + } +} + +/*! + Creates implementation of an iconview item tag. +*/ + +TQString TQUic::createIconViewItemImpl( const TQDomElement &e, const TQString &parent ) +{ + TQDomElement n = e.firstChild().toElement(); + TQString txt; + TQString com; + TQString pix; + while ( !n.isNull() ) { + if ( n.tagName() == "property" ) { + TQString attrib = n.attribute( "name" ); + TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); + if ( attrib == "text" ) { + txt = v.toString(); + com = getComment( n ); + } else if ( attrib == "pixmap" ) { + pix = v.toString(); + if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { + pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); + pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); + } + } + } + n = n.nextSibling().toElement(); + } + + if ( pix.isEmpty() ) + return "(void) new TQIconViewItem( " + parent + ", " + trcall( txt, com ) + " );"; + else + return "(void) new TQIconViewItem( " + parent + ", " + trcall( txt, com ) + ", " + pix + " );"; +} + +/*! + Creates implementation of an listview item tag. +*/ + +TQString TQUic::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 + "TQListViewItem * " + item + " = "; + } else { + item = "item"; + if ( item_used ) + s = indent + item + " = "; + else + s = indent + "TQListViewItem * " + item + " = "; + item_used = TRUE; + } + + if ( !parentItem.isEmpty() ) + s += "new TQListViewItem( " + parentItem + ", " + lastItem + " );\n"; + else + s += "new TQListViewItem( " + parent + ", " + lastItem + " );\n"; + + TQStringList texts; + TQStringList pixmaps; + while ( !n.isNull() ) { + if ( n.tagName() == "property" ) { + TQString attrib = n.attribute("name"); + TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); + if ( attrib == "text" ) + texts << v.toString(); + else if ( attrib == "pixmap" ) { + TQString pix = v.toString(); + if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { + pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); + pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); + } + pixmaps << pix; + } + } else if ( n.tagName() == "item" ) { + s += indent + item + "->setOpen( TRUE );\n"; + s += createListViewItemImpl( n, parent, item ); + } + n = n.nextSibling().toElement(); + } + + for ( int i = 0; i < (int)texts.count(); ++i ) { + if ( !texts[ i ].isEmpty() ) + s += indent + item + "->setText( " + TQString::number( i ) + ", " + trcall( texts[ 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 TQUic::createListViewColumnImpl( const TQDomElement &e, const TQString &parent, + TQString *value ) +{ + TQDomElement n = e.firstChild().toElement(); + TQString txt; + TQString com; + TQString pix; + bool clickable = FALSE, resizable = FALSE; + while ( !n.isNull() ) { + if ( n.tagName() == "property" ) { + TQString attrib = n.attribute("name"); + TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); + if ( attrib == "text" ) { + txt = v.toString(); + com = getComment( n ); + } else if ( attrib == "pixmap" ) { + pix = v.toString(); + if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { + pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); + pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); + } + } else if ( attrib == "clickable" ) + clickable = v.toBool(); + else if ( attrib == "resizable" || attrib == "resizeable" ) + resizable = v.toBool(); + } + n = n.nextSibling().toElement(); + } + + if ( value ) + *value = trcall( txt, com ); + + TQString s; + s = indent + parent + "->addColumn( " + trcall( txt, com ) + " );\n"; + if ( !pix.isEmpty() ) + s += indent + parent + "->header()->setLabel( " + parent + "->header()->count() - 1, " + pix + ", " + trcall( txt, com ) + " );\n"; + if ( !clickable ) + s += indent + parent + "->header()->setClickEnabled( FALSE, " + parent + "->header()->count() - 1 );\n"; + if ( !resizable ) + s += indent + parent + "->header()->setResizeEnabled( FALSE, " + parent + "->header()->count() - 1 );\n"; + return s; +} + +TQString TQUic::createTableRowColumnImpl( const TQDomElement &e, const TQString &parent, + TQString *value ) +{ + TQString objClass = getClassName( e.parentNode().toElement() ); + TQDomElement n = e.firstChild().toElement(); + TQString txt; + TQString com; + TQString pix; + TQString field; + bool isRow = e.tagName() == "row"; + while ( !n.isNull() ) { + if ( n.tagName() == "property" ) { + TQString attrib = n.attribute("name"); + TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); + if ( attrib == "text" ) { + txt = v.toString(); + com = getComment( n ); + } else if ( attrib == "pixmap" ) { + pix = v.toString(); + if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { + pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); + pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); + } + } else if ( attrib == "field" ) + field = v.toString(); + } + n = n.nextSibling().toElement(); + } + + if ( value ) + *value = trcall( txt, com ); + + // ### This generated code sucks! We have to set the number of + // rows/cols before and then only do setLabel/() + // ### careful, though, since TQDataTable has an API which makes this code pretty good + + TQString s; + if ( isRow ) { + s = indent + parent + "->setNumRows( " + parent + "->numRows() + 1 );\n"; + if ( pix.isEmpty() ) + s += indent + parent + "->verticalHeader()->setLabel( " + parent + "->numRows() - 1, " + + trcall( txt, com ) + " );\n"; + else + s += indent + parent + "->verticalHeader()->setLabel( " + parent + "->numRows() - 1, " + + pix + ", " + trcall( txt, com ) + " );\n"; + } else { + if ( objClass == "TQTable" ) { + s = indent + parent + "->setNumCols( " + parent + "->numCols() + 1 );\n"; + if ( pix.isEmpty() ) + s += indent + parent + "->horizontalHeader()->setLabel( " + parent + "->numCols() - 1, " + + trcall( txt, com ) + " );\n"; + else + s += indent + parent + "->horizontalHeader()->setLabel( " + parent + "->numCols() - 1, " + + pix + ", " + trcall( txt, com ) + " );\n"; + } else if ( objClass == "TQDataTable" ) { + if ( !txt.isEmpty() && !field.isEmpty() ) { + if ( pix.isEmpty() ) + out << indent << parent << "->addColumn( " << fixString( field ) << ", " << trcall( txt, com ) << " );" << endl; + else + out << indent << parent << "->addColumn( " << fixString( field ) << ", " << trcall( txt, com ) << ", " << pix << " );" << endl; + } + } + } + return s; +} + +/*! + Creates the implementation of a layout tag. Called from createObjectImpl(). + */ +TQString TQUic::createLayoutImpl( const TQDomElement &e, const TQString& parentClass, const TQString& parent, const TQString& layout ) +{ + TQDomElement n; + TQString objClass, objName; + objClass = e.tagName(); + + TQString tqlayout = "TQVBoxLayout"; + if ( objClass == "hbox" ) + tqlayout = "TQHBoxLayout"; + else if ( objClass == "grid" ) + tqlayout = "TQGridLayout"; + + bool isGrid = e.tagName() == "grid" ; + objName = registerObject( getLayoutName( e ) ); + layoutObjects += objName; + + TQString margin = DomTool::readProperty( e, "margin", defMargin ).toString(); + TQString spacing = DomTool::readProperty( e, "spacing", defSpacing ).toString(); + TQString resizeMode = DomTool::readProperty( e, "resizeMode", TQString::null ).toString(); + + TQString optcells; + if ( isGrid ) + optcells = "1, 1, "; + if ( (parentClass == "TQGroupBox" || parentClass == "TQButtonGroup") && layout.isEmpty() ) { + // special case for group box + out << indent << parent << "->setColumnLayout(0, TQt::Vertical );" << endl; + out << indent << parent << "->layout()->setSpacing( " << spacing << " );" << endl; + out << indent << parent << "->layout()->setMargin( " << margin << " );" << endl; + out << indent << objName << " = new " << tqlayout << "( " << parent << "->layout() );" << endl; + out << indent << objName << "->setAlignment( TQt::AlignTop );" << endl; + } else { + out << indent << objName << " = new " << tqlayout << "( "; + if ( layout.isEmpty() ) + out << parent; + else { + out << "0"; + if ( !DomTool::hasProperty( e, "margin" ) ) + margin = "0"; + } + out << ", " << optcells << margin << ", " << spacing << ", \"" << objName << "\"); " << endl; + } + if ( !resizeMode.isEmpty() ) + out << indent << objName << "->setResizeMode( TQLayout::" << resizeMode << " );" << 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 TQUic::createSpacerImpl( const TQDomElement &e, const TQString& /*parentClass*/, const TQString& /*parent*/, const TQString& /*layout*/) +{ + TQDomElement n; + TQString objClass, objName; + objClass = e.tagName(); + objName = registerObject( getObjectName( e ) ); + + 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 TQt 2.2 + TQRect geom = DomTool::readProperty( e, "geometry", TQRect(0,0,0,0) ).toRect(); + size = geom.size(); + } + + if ( isVspacer ) + out << " " << objName << " = new TQSpacerItem( " + << size.width() << ", " << size.height() + << ", TQSizePolicy::Minimum, TQSizePolicy::" << sizeType << " );" << endl; + else + out << " " << objName << " = new TQSpacerItem( " + << size.width() << ", " << size.height() + << ", TQSizePolicy::" << sizeType << ", TQSizePolicy::Minimum );" << endl; + + return objName; +} + +static const char* const ColorRole[] = { + "Foreground", "Button", "Light", "Midlight", "Dark", "Mid", + "Text", "BrightText", "ButtonText", "Base", "Background", "Shadow", + "Highlight", "HighlightedText", "Link", "LinkVisited", 0 +}; + + +/*! + Creates a colorgroup with name \a name from the color group \a cg + */ +void TQUic::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 = "white"; + else if ( col == black ) + color = "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 + "( " + TQString( externPixmaps ? "\"" : "" ) ); + pixmap.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); + } + 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 TQUic::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; +} + +/*! Returns TRUE if the widget properties specify that it belongs to + the database \a connection and \a table. +*/ + +bool TQUic::isWidgetInTable( const TQDomElement& e, const TQString& connection, const TQString& table ) +{ + TQString conn = getDatabaseInfo( e, "connection" ); + TQString tab = getDatabaseInfo( e, "table" ); + if ( conn == connection && tab == table ) + return TRUE; + return FALSE; +} + +/*! + Registers all database connections, cursors and forms. +*/ + +void TQUic::registerDatabases( const TQDomElement& e ) +{ + TQDomElement n; + TQDomNodeList nl; + int i; + nl = e.parentNode().toElement().elementsByTagName( "widget" ); + for ( i = 0; i < (int) nl.length(); ++i ) { + n = nl.item(i).toElement(); + TQString conn = getDatabaseInfo( n, "connection" ); + TQString tab = getDatabaseInfo( n, "table" ); + TQString fld = getDatabaseInfo( n, "field" ); + if ( !conn.isNull() ) { + dbConnections += conn; + if ( !tab.isNull() ) { + dbCursors[conn] += tab; + if ( !fld.isNull() ) + dbForms[conn] += tab; + } + } + } +} + +/*! + 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 TQUic::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 TQUic::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 TQUic::isObjectRegistered( const TQString& name ) +{ + return objectMapper.contains( name ); +} + + +/*! + Unifies the entries in stringlist \a list. Should really be a TQStringList feature. + */ +TQStringList TQUic::unique( const TQStringList& list ) +{ + if ( list.isEmpty() ) + return list; + + TQStringList result; + for ( TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { + if ( !result.contains(*it) ) + result += *it; + } + return result; +} + + + +/*! + Creates an instance of class \a objClass, with parent \a parent and name \a objName + */ +TQString TQUic::createObjectInstance( const TQString& objClass, const TQString& parent, const TQString& objName ) +{ + + if (( objClass.mid( 1 ) == "ComboBox" ) || ( objClass.mid( 2 ) == "ComboBox" )) { + return objClass + "( FALSE, " + parent + ", \"" + objName + "\" )"; + } + return objClass + "( " + parent + ", \"" + objName + "\" )"; +} + +bool TQUic::isLayout( const TQString& name ) const +{ + return layoutObjects.contains( name ); +} + + + diff --git a/tools/designer/tquic/tquic.h b/tools/designer/tquic/tquic.h new file mode 100644 index 000000000..a296e4f54 --- /dev/null +++ b/tools/designer/tquic/tquic.h @@ -0,0 +1,176 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Designer. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef UIC_H +#define UIC_H +#include +#include +#include +#include +#include +#include +#include + +class TQUic : public TQt +{ +public: + TQUic( const TQString &fn, const char *outputFn, TQTextStream& out, + TQDomDocument doc, bool decl, bool subcl, const TQString &trm, + const TQString& subclname, bool omitForwardDecls ); + + void createFormDecl( const TQDomElement &e ); + void createFormImpl( const TQDomElement &e ); + + void createSubDecl( const TQDomElement &e, const TQString& subclname ); + void createSubImpl( const TQDomElement &e, const TQString& subclname ); + + void createObjectDecl( const TQDomElement &e ); + void createSpacerDecl( const TQDomElement &e ); + void createActionDecl( const TQDomElement &e ); + void createToolbarDecl( const TQDomElement &e ); + void createMenuBarDecl( const TQDomElement &e ); + void createPopupMenuDecl( const TQDomElement &e ); + void createActionImpl( const TQDomElement &e, const TQString &parent ); + void createToolbarImpl( const TQDomElement &e, const TQString &parentClass, const TQString &parent ); + void createMenuBarImpl( const TQDomElement &e, const TQString &parentClass, const TQString &parent ); + void createPopupMenuImpl( const TQDomElement &e, const TQString &parentClass, const TQString &parent ); + 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 *value = 0 ); + TQString createIconViewItemImpl( const TQDomElement &e, const TQString &parent ); + TQString createListViewColumnImpl( const TQDomElement &e, const TQString &parent, TQString *value = 0 ); + TQString createTableRowColumnImpl( const TQDomElement &e, const TQString &parent, TQString *value = 0 ); + TQString createListViewItemImpl( const TQDomElement &e, const TQString &parent, + const TQString &parentItem ); + void createColorGroupImpl( const TQString& cg, const TQDomElement& e ); + TQColorGroup loadColorGroup( const TQDomElement &e ); + + TQDomElement getObjectProperty( const TQDomElement& e, const TQString& name ); + TQString getPixmapLoaderFunction( const TQDomElement& e ); + TQString getFormClassName( const TQDomElement& e ); + TQString getClassName( const TQDomElement& e ); + TQString getObjectName( const TQDomElement& e ); + TQString getLayoutName( const TQDomElement& e ); + TQString getInclude( const TQString& className ); + + 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& ); + + TQString trcall( const TQString& sourceText, const TQString& comment = "" ); + + static void embed( TQTextStream& out, const char* project, const TQStringList& images ); + +private: + void registerLayouts ( const TQDomElement& e ); + + TQTextStream& out; + TQTextOStream trout; + TQString languageChangeBody; + TQCString outputFileName; + TQStringList objectNames; + TQMap objectMapper; + TQString indent; + TQStringList tags; + TQStringList layouts; + TQString formName; + TQString lastItem; + TQString trmacro; + bool nofwd; + + 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; + TQ_DUMMY_COMPARISON_OPERATOR(CustomInclude) + }; + TQValueList buddies; + + TQStringList layoutObjects; + bool isLayout( const TQString& name ) const; + + uint item_used : 1; + uint cg_used : 1; + uint pal_used : 1; + uint stdsetdef : 1; + uint externPixmaps : 1; + + TQString uiFileVersion; + TQString nameOfClass; + TQStringList namespaces; + TQString bareNameOfClass; + TQString pixmapLoaderFunction; + + void registerDatabases( const TQDomElement& e ); + bool isWidgetInTable( const TQDomElement& e, const TQString& connection, const TQString& table ); + bool isFrameworkCodeGenerated( const TQDomElement& e ); + TQString getDatabaseInfo( const TQDomElement& e, const TQString& tag ); + void createFormImpl( const TQDomElement& e, const TQString& form, const TQString& connection, const TQString& table ); + void writeFunctionsDecl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst ); + void writeFunctionsSubDecl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst ); + void writeFunctionsSubImpl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst, + const TQString &subClass, const TQString &descr ); + TQStringList dbConnections; + TQMap< TQString, TQStringList > dbCursors; + TQMap< TQString, TQStringList > dbForms; + + static bool isMainWindow; + static TQString mkBool( bool b ); + static TQString mkBool( const TQString& s ); + bool toBool( const TQString& s ); + static TQString fixString( const TQString &str, bool encode = FALSE ); + static bool onlyAscii; + static TQString mkStdSet( const TQString& prop ); + static TQString getComment( const TQDomNode& n ); + TQVariant defSpacing, defMargin; + TQString fileName; + bool writeFunctImpl; +}; + +#endif diff --git a/tools/designer/tquic/tquic.pro b/tools/designer/tquic/tquic.pro new file mode 100644 index 000000000..40a9b436e --- /dev/null +++ b/tools/designer/tquic/tquic.pro @@ -0,0 +1,42 @@ +TEMPLATE = app +CONFIG += qt console warn_on release professional +HEADERS = tquic.h \ + ../shared/widgetdatabase.h \ + ../shared/domtool.h \ + ../shared/parser.h \ + ../interfaces/widgetinterface.h + +#HEADERS += ../shared/ui2uib.h \ +# ../shared/uib.h + +SOURCES = main.cpp tquic.cpp form.cpp object.cpp \ + subclassing.cpp embed.cpp\ + ../shared/widgetdatabase.cpp \ + ../shared/domtool.cpp \ + ../shared/parser.cpp + +#SOURCES += ../shared/ui2uib.cpp \ +# ../shared/uib.cpp + +DEFINES += QT_INTERNAL_XML +include( ../../../src/qt_professional.pri ) + +TARGET = tquic +INCLUDEPATH += ../shared +DEFINES += TQUIC +DESTDIR = ../../../bin + +target.path=$$bins.path +INSTALLS += target + +*-mwerks { + TEMPLATE = lib + TARGET = McUic + CONFIG -= static + CONFIG += shared plugin + DEFINES += UIC_MWERKS_PLUGIN + MWERKSDIR = $(QT_SOURCE_TREE)/util/mwerks_plugin + INCLUDEPATH += $$MWERKSDIR/Headers + LIBS += $$MWERKSDIR/Libraries/PluginLib4.shlb + SOURCES += mwerks_mac.cpp +} diff --git a/tools/designer/uic/embed.cpp b/tools/designer/uic/embed.cpp deleted file mode 100644 index d16abc6cd..000000000 --- a/tools/designer/uic/embed.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. -** -** This file is part of TQt Designer. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "uic.h" -#include -#include -#include -#include -#include -#include -#include - -struct EmbedImage -{ - ~EmbedImage() { delete[] colorTable; } - int width, height, depth; - int numColors; - TQRgb* colorTable; - TQString name; - TQString cname; - bool alpha; -#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION - ulong compressed; -#endif -}; - -static TQString convertToCIdentifier( const char *s ) -{ - TQString r = s; - int len = r.length(); - if ( len > 0 && !isalpha( (char)r[0].latin1() ) ) - r[0] = '_'; - for ( int i=1; i> 4) & 15]; - s += hexdigits[v & 15]; - if ( i < (int)len-1 ) - s += ','; - } - if ( s.length() ) - out << (const char*)s; - return len; -} - -static void embedData( TQTextStream& out, const TQRgb* input, int n ) -{ - out << hex; - const TQRgb *v = input; - for ( int i=0; i\n"; - out << "#include \n"; - out << "#include \n"; - out << "#include \n"; - out << "\n"; - - TQPtrList list_image; - list_image.setAutoDelete( TRUE ); - int image_count = 0; - for ( it = images.begin(); it != images.end(); ++it ) { - TQImage img; - if ( !img.load( *it ) ) { - fprintf( stderr, "uic: cannot load image file %s\n", (*it).latin1() ); - continue; - } - EmbedImage *e = new EmbedImage; - e->width = img.width(); - e->height = img.height(); - e->depth = img.depth(); - e->numColors = img.numColors(); - e->colorTable = new TQRgb[e->numColors]; - e->alpha = img.hasAlphaBuffer(); - memcpy(e->colorTable, img.colorTable(), e->numColors*sizeof(TQRgb)); - TQFileInfo fi( *it ); - e->name = fi.fileName(); - e->cname = TQString("image_%1").arg( image_count++); - list_image.append( e ); - out << "// " << *it << "\n"; - TQString s; - if ( e->depth == 1 ) - img = img.convertBitOrder(TQImage::BigEndian); - out << s.sprintf( "static const unsigned char %s_data[] = {", - (const char *)e->cname ); -#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION - e->compressed = -#endif - embedData( out, img.bits(), img.numBytes() ); - out << "\n};\n\n"; - if ( e->numColors ) { - out << s.sprintf( "static const TQRgb %s_ctable[] = {", - (const char *)e->cname ); - embedData( out, e->colorTable, e->numColors ); - out << "\n};\n\n"; - } - } - - if ( !list_image.isEmpty() ) { - out << "static struct EmbedImage {\n" - " int width, height, depth;\n" - " const unsigned char *data;\n" -#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION - " ulong compressed;\n" -#endif - " int numColors;\n" - " const TQRgb *colorTable;\n" - " bool alpha;\n" - " const char *name;\n" - "} embed_image_vec[] = {\n"; - EmbedImage *e = list_image.first(); - while ( e ) { - out << " { " - << e->width << ", " - << e->height << ", " - << e->depth << ", " - << "(const unsigned char*)" << e->cname << "_data, " -#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION - << e->compressed << ", " -#endif - << e->numColors << ", "; - if ( e->numColors ) - out << e->cname << "_ctable, "; - else - out << "0, "; - if ( e->alpha ) - out << "TRUE, "; - else - out << "FALSE, "; - out << "\"" << e->name << "\" },\n"; - e = list_image.next(); - } -#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION - out << " { 0, 0, 0, 0, 0, 0, 0, 0, 0 }\n};\n"; -#else - out << " { 0, 0, 0, 0, 0, 0, 0, 0 }\n};\n"; -#endif - - out << "\n" - "static TQImage uic_findImage( const TQString& name )\n" - "{\n" - " for ( int i=0; embed_image_vec[i].data; i++ ) {\n" - " if ( TQString::fromUtf8(embed_image_vec[i].name) == name ) {\n" -#ifndef TQT_NO_IMAGE_COLLECTION_COMPRESSION - " TQByteArray baunzip;\n" - " baunzip = tqUncompress( embed_image_vec[i].data, \n" - " embed_image_vec[i].compressed );\n" - " TQImage img((uchar*)baunzip.data(),\n" - " embed_image_vec[i].width,\n" - " embed_image_vec[i].height,\n" - " embed_image_vec[i].depth,\n" - " (TQRgb*)embed_image_vec[i].colorTable,\n" - " embed_image_vec[i].numColors,\n" - " TQImage::BigEndian\n" - " );\n" - " img = img.copy();\n" -#else - " TQImage img((uchar*)embed_image_vec[i].data,\n" - " embed_image_vec[i].width,\n" - " embed_image_vec[i].height,\n" - " embed_image_vec[i].depth,\n" - " (TQRgb*)embed_image_vec[i].colorTable,\n" - " embed_image_vec[i].numColors,\n" - " TQImage::BigEndian\n" - " );\n" -#endif - " if ( embed_image_vec[i].alpha )\n" - " img.setAlphaBuffer(TRUE);\n" - " return img;\n" - " }\n" - " }\n" - " return TQImage();\n" - "}\n\n"; - - out << "class MimeSourceFactory_" << cProject << " : public TQMimeSourceFactory\n"; - out << "{\n"; - out << "public:\n"; - out << " MimeSourceFactory_" << cProject << "() {}\n"; - out << " ~MimeSourceFactory_" << cProject << "() {}\n"; - out << " const TQMimeSource* data( const TQString& abs_name ) const {\n"; - out << "\tconst TQMimeSource* d = TQMimeSourceFactory::data( abs_name );\n"; - out << "\tif ( d || abs_name.isNull() ) return d;\n"; - out << "\tTQImage img = uic_findImage( abs_name );\n"; - out << "\tif ( !img.isNull() )\n"; - out << "\t ((TQMimeSourceFactory*)this)->setImage( abs_name, img );\n"; - out << "\treturn TQMimeSourceFactory::data( abs_name );\n"; - out << " };\n"; - out << "};\n\n"; - - out << "static TQMimeSourceFactory* factory = 0;\n"; - out << "\n"; - - out << "TQ_EXPORT void qInitImages_" << cProject << "()\n"; - out << "{\n"; - out << " if ( !factory ) {\n"; - out << "\tfactory = new MimeSourceFactory_" << cProject << ";\n"; - out << "\tTQMimeSourceFactory::defaultFactory()->addFactory( factory );\n"; - out << " }\n"; - out << "}\n\n"; - - out << "void qCleanupImages_" << cProject << "()\n"; - out << "{\n"; - out << " if ( factory ) {\n"; - out << "\tTQMimeSourceFactory::defaultFactory()->removeFactory( factory );\n"; - out << "\tdelete factory;\n"; - out << "\tfactory = 0;\n"; - out << " }\n"; - out << "}\n\n"; - - out << "class StaticInitImages_" << cProject << "\n"; - out << "{\n"; - out << "public:\n"; - out << " StaticInitImages_" << cProject << "() { qInitImages_" << cProject << "(); }\n"; - out << "#if defined(Q_OS_SCO) || defined(Q_OS_UNIXWARE)\n"; - out << " ~StaticInitImages_" << cProject << "() { }\n"; - out << "#else\n"; - out << " ~StaticInitImages_" << cProject << "() { qCleanupImages_" << cProject << "(); }\n"; - out << "#endif\n"; - out << "};\n\n"; - - out << "static StaticInitImages_" << cProject << " staticImages;\n"; - } -} diff --git a/tools/designer/uic/form.cpp b/tools/designer/uic/form.cpp deleted file mode 100644 index a3ec6801c..000000000 --- a/tools/designer/uic/form.cpp +++ /dev/null @@ -1,1452 +0,0 @@ -/********************************************************************** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of TQt Designer. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "uic.h" -#include "parser.h" -#include "widgetdatabase.h" -#include "domtool.h" -#include -#include -#include -#include -#include -#include -#define NO_STATIC_COLORS -#include - -static TQByteArray unzipXPM( TQString data, ulong& length ) -{ - const int lengthOffset = 4; - int baSize = data.length() / 2 + lengthOffset; - uchar *ba = new uchar[ baSize ]; - for ( int i = lengthOffset; i < baSize; ++i ) { - char h = data[ 2 * (i-lengthOffset) ].latin1(); - char l = data[ 2 * (i-lengthOffset) + 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; - } - // tqUncompress() expects the first 4 bytes to be the expected length of the - // uncompressed data - ba[0] = ( length & 0xff000000 ) >> 24; - ba[1] = ( length & 0x00ff0000 ) >> 16; - ba[2] = ( length & 0x0000ff00 ) >> 8; - ba[3] = ( length & 0x000000ff ); - TQByteArray baunzip = tqUncompress( ba, baSize ); - delete[] ba; - return baunzip; -} - -#if TQT_VERSION >= 0x030900 -#error Add this functionality to TQDir (relativePathTo() maybe?) and \ -remove it from here and from moc -#endif - -TQCString combinePath( const char *infile, const char *outfile ) -{ - TQFileInfo inFileInfo( TQDir::current(), TQFile::decodeName(infile) ); - TQFileInfo outFileInfo( TQDir::current(), TQFile::decodeName(outfile) ); - int numCommonComponents = 0; - - TQStringList inSplitted = - TQStringList::split( '/', inFileInfo.dir().canonicalPath(), TRUE ); - TQStringList outSplitted = - TQStringList::split( '/', outFileInfo.dir().canonicalPath(), TRUE ); - - while ( !inSplitted.isEmpty() && !outSplitted.isEmpty() && - inSplitted.first() == outSplitted.first() ) { - inSplitted.remove( inSplitted.begin() ); - outSplitted.remove( outSplitted.begin() ); - numCommonComponents++; - } - - if ( numCommonComponents < 2 ) { - /* - The paths don't have the same drive, or they don't have the - same root directory. Use an absolute path. - */ - return TQFile::encodeName( inFileInfo.absFilePath() ); - } else { - /* - The paths have something in common. Use a path relative to - the output file. - */ - while ( !outSplitted.isEmpty() ) { - outSplitted.remove( outSplitted.begin() ); - inSplitted.prepend( ".." ); - } - inSplitted.append( inFileInfo.fileName() ); - return TQFile::encodeName( inSplitted.join("/") ); - } -} - -/*! - Creates a declaration (header file) for the form given in \a e - - \sa createFormImpl(), createObjectDecl() -*/ -void Uic::createFormDecl( const TQDomElement &e ) -{ - TQDomElement n; - TQDomNodeList nl; - int i; - TQString objClass = getClassName( e ); - if ( objClass.isEmpty() ) - return; - TQString objName = getObjectName( e ); - - TQStringList typeDefs; - - TQMap customWidgetIncludes; - - TQString imageMembers; - - /* - We are generating a few TQImage members that are not strictly - necessary in some cases. Ideally, we would use requiredImage, - which is computed elsewhere, to keep the generated .h and .cpp - files synchronized. - */ - - // at first the images - TQMap customWidgets; - TQStringList forwardDecl; - TQStringList forwardDecl2; - TQString exportMacro; - 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++ ) { - TQString img = registerObject( nl.item(i).toElement().attribute("name") ); - registerObject( img ); - imageMembers += TQString( " TQPixmap %1;\n" ).arg( img ); - } - } else if ( n.tagName() == "customwidgets" ) { - TQDomElement n2 = n.firstChild().toElement(); - while ( !n2.isNull() ) { - if ( n2.tagName() == "customwidget" ) { - TQDomElement n3 = n2.firstChild().toElement(); - TQString cl; - WidgetDatabaseRecord *r = new WidgetDatabaseRecord; - while ( !n3.isNull() ) { - if ( n3.tagName() == "class" ) { - cl = n3.firstChild().toText().data(); - if ( !nofwd ) - forwardDecl << cl; - customWidgets.insert( cl, 0 ); - r->name = cl; - } else if ( n3.tagName() == "header" ) { - CustomInclude ci; - ci.header = n3.firstChild().toText().data(); - ci.location = n3.attribute( "location", "global" ); - r->includeFile = ci.header; - customWidgetIncludes.insert( cl, ci ); - } - WidgetDatabase::append( r ); - n3 = n3.nextSibling().toElement(); - } - } - n2 = n2.nextSibling().toElement(); - } - } - } - - // register the object and unify its name - objName = registerObject( objName ); - TQString protector = objName.upper() + "_H"; - protector.replace( "::", "_" ); - out << "#ifndef " << protector << endl; - out << "#define " << protector << endl; - out << endl; - out << "#include " << endl; // for broken HP-UX compilers - - if ( !imageMembers.isEmpty() ) - out << "#include " << endl; - - TQStringList globalIncludes, localIncludes; - int wid = WidgetDatabase::idFromClassName( objClass ); - { - TQMap::Iterator it = customWidgetIncludes.find( objClass ); - if ( it != customWidgetIncludes.end() ) { - if ( ( *it ).location == "global" ) - globalIncludes += (*it).header; - else - localIncludes += (*it).header; - } else { - globalIncludes += WidgetDatabase::includeFile( wid ); - } - } - - nl = e.parentNode().toElement().elementsByTagName( "include" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - TQDomElement n2 = nl.item(i).toElement(); - TQString s = n2.firstChild().toText().data(); - if ( n2.attribute( "impldecl", "in implementation" ) == "in declaration" && - n2.attribute( "location" ) != "local" ) { - if ( s.right( 5 ) == ".ui.h" ) - continue; - globalIncludes += s; - } - } - for ( i = 0; i < (int) nl.length(); i++ ) { - TQDomElement n2 = nl.item(i).toElement(); - TQString s = n2.firstChild().toText().data(); - if ( n2.attribute( "impldecl", "in implementation" ) == "in declaration" && - n2.attribute( "location" ) == "local" &&!globalIncludes.contains( s ) ) { - if ( s.right( 5 ) == ".ui.h" ) - continue; - localIncludes += s; - } - } - - TQStringList::Iterator it; - - globalIncludes = unique( globalIncludes ); - for ( it = globalIncludes.begin(); it != globalIncludes.end(); ++it ) { - if ( !(*it).isEmpty() ) - out << "#include <" << *it << ">" << endl; - } - localIncludes = unique( localIncludes ); - for ( it = localIncludes.begin(); it != localIncludes.end(); ++it ) { - if ( !(*it).isEmpty() ) - out << "#include \"" << *it << "\"" << endl; - } - out << endl; - - // forward declarations for child widgets and layouts - out << "class TQVBoxLayout;" << endl; - out << "class TQHBoxLayout;" << endl; - out << "class TQGridLayout;" << endl; - out << "class TQSpacerItem;" << endl; - if ( objClass == "TQMainWindow" ) { - out << "class TQAction;" << endl; - out << "class TQActionGroup;" << endl; - out << "class TQToolBar;" << endl; - out << "class TQPopupMenu;" << endl; - } - - bool dbForm = FALSE; - registerDatabases( e ); - dbConnections = unique( dbConnections ); - if ( dbConnections.count() ) - forwardDecl += "TQSqlDatabase"; - if ( dbCursors.count() ) - forwardDecl += "TQSqlCursor"; - if ( dbForms[ "(default)" ].count() ) - dbForm = TRUE; - bool subDbForms = FALSE; - for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { - if ( !(*it).isEmpty() && (*it) != "(default)" ) { - if ( dbForms[ (*it) ].count() ) { - subDbForms = TRUE; - break; - } - } - } - if ( dbForm || subDbForms ) - forwardDecl += "TQSqlForm"; - - for ( it = tags.begin(); it != tags.end(); ++it ) { - nl = e.parentNode().toElement().elementsByTagName( *it ); - for ( i = 1; i < (int) nl.length(); i++ ) { // begin at 1, 0 is the toplevel widget - TQString s = getClassName( nl.item(i).toElement() ); - if ( s == "TQLayoutWidget" ) - continue; // hide tqlayoutwidgets - if ( s == "Line" ) - s = "TQFrame"; - if ( !(nofwd && customWidgets.contains(s)) ) - forwardDecl += s; - if ( (s.mid( 2 ) == "ListBox") || (s.mid( 2 ) == "ListView") || (s.mid( 2 ) == "IconView") ) - forwardDecl += "TQ" + s.mid( 2 ) + "Item"; - if ( s == "TQDataTable" ) { // other convenience classes which are used in TQDataTable signals, and thus should be forward-declared by uic for us - forwardDecl += "TQSqlRecord"; - } - } - } - - // some typedefs, maybe - typeDefs = unique( typeDefs ); - for ( it = typeDefs.begin(); it != typeDefs.end(); ++it ) { - if ( !(*it).isEmpty() ) - out << "typedef " << *it << ";" << endl; - } - - nl = e.parentNode().toElement().elementsByTagName( "forward" ); - for ( i = 0; i < (int) nl.length(); i++ ) - forwardDecl2 << nl.item(i).toElement().firstChild().toText().data(); - - nl = e.parentNode().toElement().elementsByTagName( "include" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - TQDomElement n2 = nl.item(i).toElement(); - TQString s = n2.firstChild().toText().data(); - if ( n2.attribute( "impldecl", "in implementation" ) == "in declaration" && - n2.attribute( "location" ) != "local" ) - globalIncludes += s; - } - for ( i = 0; i < (int) nl.length(); i++ ) { - TQDomElement n2 = nl.item(i).toElement(); - TQString s = n2.firstChild().toText().data(); - if ( n2.attribute( "impldecl", "in implementation" ) == "in declaration" && - n2.attribute( "location" ) == "local" &&!globalIncludes.contains( s ) ) - localIncludes += s; - } - nl = e.parentNode().toElement().elementsByTagName( "exportmacro" ); - if ( nl.length() == 1 ) - exportMacro = nl.item( 0 ).firstChild().toText().data(); - - forwardDecl = unique( forwardDecl ); - for ( it = forwardDecl.begin(); it != forwardDecl.end(); ++it ) { - if ( !(*it).isEmpty() && (*it) != objClass ) { - TQString forwardName = *it; - TQStringList forwardNamespaces = TQStringList::split( "::", - forwardName ); - forwardName = forwardNamespaces.last(); - forwardNamespaces.remove( forwardNamespaces.fromLast() ); - - TQStringList::ConstIterator ns = forwardNamespaces.begin(); - while ( ns != forwardNamespaces.end() ) { - out << "namespace " << *ns << " {" << endl; - ++ns; - } - out << "class " << forwardName << ";" << endl; - for ( int i = 0; i < (int) forwardNamespaces.count(); i++ ) - out << "}" << endl; - } - } - - for ( it = forwardDecl2.begin(); it != forwardDecl2.end(); ++it ) { - TQString fd = *it; - fd = fd.stripWhiteSpace(); - if ( !fd.endsWith( ";" ) ) - fd += ";"; - out << fd << endl; - } - - out << endl; - - TQStringList::ConstIterator ns = namespaces.begin(); - while ( ns != namespaces.end() ) { - out << "namespace " << *ns << " {" << endl; - ++ns; - } - - out << "class "; - if ( !exportMacro.isEmpty() ) - out << exportMacro << " "; - out << bareNameOfClass << " : public " << objClass << endl << "{" << endl; - - /* qmake ignore TQ_OBJECT */ - out << " TQ_OBJECT" << endl; - out << endl; - out << "public:" << endl; - - // constructor - if ( objClass == "TQDialog" || objClass == "TQWizard" ) { - out << " " << bareNameOfClass << "( TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );" << endl; - } else if ( objClass == "TQWidget" ) { - out << " " << bareNameOfClass << "( TQWidget* parent = 0, const char* name = 0, WFlags fl = 0 );" << endl; - } else if ( objClass == "TQMainWindow" ) { - out << " " << bareNameOfClass << "( TQWidget* parent = 0, const char* name = 0, WFlags fl = WType_TopLevel );" << endl; - isMainWindow = TRUE; - } else { - out << " " << bareNameOfClass << "( TQWidget* parent = 0, const char* name = 0 );" << endl; - } - - // destructor - out << " ~" << bareNameOfClass << "();" << endl; - out << endl; - - // children - bool needPolish = FALSE; - nl = e.parentNode().toElement().elementsByTagName( "widget" ); - for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget - n = nl.item(i).toElement(); - createObjectDecl( n ); - TQString t = n.tagName(); - if ( t == "vbox" || t == "hbox" || t == "grid" ) - createSpacerDecl( n ); - TQString s = getClassName( n ); - if ( s == "TQDataTable" || s == "TQDataBrowser" ) { - if ( isFrameworkCodeGenerated( n ) ) - needPolish = TRUE; - } - } - - // actions, toolbars, menus - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "actions" ) { - for ( TQDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() ) - createActionDecl( a ); - } else if ( n.tagName() == "toolbars" ) { - for ( TQDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() ) - createToolbarDecl( a ); - } else if ( n.tagName() == "menubar" ) { - out << " " << "TQMenuBar *" << getObjectName( n ) << ";" << endl; - for ( TQDomElement a = n.firstChild().toElement(); !a.isNull(); a = a.nextSibling().toElement() ) - createMenuBarDecl( a ); - } - } - out << endl; - - // database connections - dbConnections = unique( dbConnections ); - bool hadOutput = FALSE; - for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { - if ( !(*it).isEmpty() ) { - // only need pointers to non-default connections - if ( (*it) != "(default)" && !(*it).isEmpty() ) { - out << indent << "TQSqlDatabase* " << *it << "Connection;" << endl; - hadOutput = TRUE; - } - } - } - if ( hadOutput ) - out << endl; - - TQStringList publicSlots, protectedSlots, privateSlots; - TQStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes; - TQStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier; - - nl = e.parentNode().toElement().elementsByTagName( "slot" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - if ( n.parentNode().toElement().tagName() != "slots" - && n.parentNode().toElement().tagName() != "connections" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString returnType = n.attribute( "returnType", "void" ); - TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); - if ( functionName.endsWith( ";" ) ) - functionName = functionName.left( functionName.length() - 1 ); - TQString specifier = n.attribute( "specifier" ); - TQString access = n.attribute( "access" ); - if ( access == "protected" ) { - protectedSlots += functionName; - protectedSlotTypes += returnType; - protectedSlotSpecifier += specifier; - } else if ( access == "private" ) { - privateSlots += functionName; - privateSlotTypes += returnType; - privateSlotSpecifier += specifier; - } else { - publicSlots += functionName; - publicSlotTypes += returnType; - publicSlotSpecifier += specifier; - } - } - - TQStringList publicFuncts, protectedFuncts, privateFuncts; - TQStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp; - TQStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec; - - nl = e.parentNode().toElement().elementsByTagName( "function" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item( i ).toElement(); - if ( n.parentNode().toElement().tagName() != "functions" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString returnType = n.attribute( "returnType", "void" ); - TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); - if ( functionName.endsWith( ";" ) ) - functionName = functionName.left( functionName.length() - 1 ); - TQString specifier = n.attribute( "specifier" ); - TQString access = n.attribute( "access" ); - if ( access == "protected" ) { - protectedFuncts += functionName; - protectedFunctRetTyp += returnType; - protectedFunctSpec += specifier; - } else if ( access == "private" ) { - privateFuncts += functionName; - privateFunctRetTyp += returnType; - privateFunctSpec += specifier; - } else { - publicFuncts += functionName; - publicFunctRetTyp += returnType; - publicFunctSpec += specifier; - } - } - - TQStringList publicVars, protectedVars, privateVars; - nl = e.parentNode().toElement().elementsByTagName( "variable" ); - for ( i = 0; i < (int)nl.length(); i++ ) { - n = nl.item( i ).toElement(); - // Because of compatibility the next lines have to be commented out. - // Someday it should be uncommented. - //if ( n.parentNode().toElement().tagName() != "variables" ) - // continue; - TQString access = n.attribute( "access", "protected" ); - TQString var = n.firstChild().toText().data().stripWhiteSpace(); - if (var.isEmpty()) - continue; - if ( !var.endsWith( ";" ) ) - var += ";"; - if ( access == "public" ) - publicVars += var; - else if ( access == "private" ) - privateVars += var; - else - protectedVars += var; - } - - if ( !publicVars.isEmpty() ) { - for ( it = publicVars.begin(); it != publicVars.end(); ++it ) - out << indent << *it << endl; - out << endl; - } - if ( !publicFuncts.isEmpty() ) - writeFunctionsDecl( publicFuncts, publicFunctRetTyp, publicFunctSpec ); - - if ( needPolish || !publicSlots.isEmpty() ) { - out << "public slots:" << endl; - if ( needPolish ) { - out << indent << "virtual void polish();" << endl; - out << endl; - } - if ( !publicSlots.isEmpty() ) - writeFunctionsDecl( publicSlots, publicSlotTypes, publicSlotSpecifier ); - } - - // find signals - TQStringList extraSignals; - nl = e.parentNode().toElement().elementsByTagName( "signal" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item( i ).toElement(); - if ( n.parentNode().toElement().tagName() != "signals" - && n.parentNode().toElement().tagName() != "connections" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString sigName = n.firstChild().toText().data().stripWhiteSpace(); - if ( sigName.endsWith( ";" ) ) - sigName = sigName.left( sigName.length() - 1 ); - extraSignals += sigName; - } - - // create signals - if ( !extraSignals.isEmpty() ) { - out << "signals:" << endl; - for ( it = extraSignals.begin(); it != extraSignals.end(); ++it ) - out << " void " << (*it) << ";" << endl; - out << endl; - } - - out << "protected:" << endl; - if ( !protectedVars.isEmpty() ) { - for ( it = protectedVars.begin(); it != protectedVars.end(); ++it ) - out << indent << *it << endl; - out << endl; - } - if ( !protectedFuncts.isEmpty() ) - writeFunctionsDecl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec ); - - // child layouts - registerLayouts( e ); - out << endl; - -#if TQT_VERSION >= 0x030900 -#error Make languageChange() a virtual protected non-slot member of TQWidget -#endif - - out << "protected slots:" << endl; - out << " virtual void languageChange();" << endl; - if ( !protectedSlots.isEmpty() ) { - out << endl; - writeFunctionsDecl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier ); - } - out << endl; - - // create all private stuff - if ( !privateFuncts.isEmpty() || !privateVars.isEmpty() || !imageMembers.isEmpty() ) { - out << "private:" << endl; - if ( !privateVars.isEmpty() ) { - for ( it = privateVars.begin(); it != privateVars.end(); ++it ) - out << indent << *it << endl; - out << endl; - } - if ( !imageMembers.isEmpty() ) { - out << imageMembers; - out << endl; - } - if ( !privateFuncts.isEmpty() ) - writeFunctionsDecl( privateFuncts, privateFunctRetTyp, privateFunctSpec ); - } - - if ( !privateSlots.isEmpty() ) { - out << "private slots:" << endl; - writeFunctionsDecl( privateSlots, privateSlotTypes, privateSlotSpecifier ); - } - - out << "};" << endl; - for ( i = 0; i < (int) namespaces.count(); i++ ) - out << "}" << endl; - - out << endl; - out << "#endif // " << protector << endl; -} - -void Uic::writeFunctionsDecl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst ) -{ - TQValueListConstIterator it, it2, it3; - for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin(); - it != fuLst.end(); ++it, ++it2, ++it3 ) { - TQString signature = *it; - TQString specifier; - TQString pure; - TQString type = *it2; - if ( type.isEmpty() ) - type = "void"; - if ( *it3 == "static" ) { - specifier = "static "; - } else { - if ( *it3 != "non virtual" && *it3 != "nonVirtual" ) - specifier = "virtual "; - if ( *it3 == "pure virtual" || *it3 == "pureVirtual" ) - pure = " = 0"; - } - type.replace( ">>", "> >" ); - if ( !signature.contains("operator") ) - signature.replace( ">>", "> >" ); - out << " " << specifier << type << " " << signature << pure << ";" << endl; - } - out << endl; -} - -/*! - Creates an implementation (cpp-file) for the form given in \a e. - - \sa createFormDecl(), createObjectImpl() - */ -void Uic::createFormImpl( const TQDomElement &e ) -{ - TQDomElement n; - TQDomNodeList nl; - int i; - TQString objClass = getClassName( e ); - if ( objClass.isEmpty() ) - return; - TQString objName = getObjectName( e ); - - // generate local and local includes required - TQStringList globalIncludes, localIncludes; - TQStringList::Iterator it; - - TQMap customWidgetIncludes; - - // find additional slots and functions - TQStringList extraFuncts; - TQStringList extraFunctTyp; - TQStringList extraFunctSpecifier; - - nl = e.parentNode().toElement().elementsByTagName( "slot" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - if ( n.parentNode().toElement().tagName() != "slots" - && n.parentNode().toElement().tagName() != "connections" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); - if ( functionName.endsWith( ";" ) ) - functionName = functionName.left( functionName.length() - 1 ); - extraFuncts += functionName; - extraFunctTyp += n.attribute( "returnType", "void" ); - extraFunctSpecifier += n.attribute( "specifier", "virtual" ); - } - - nl = e.parentNode().toElement().elementsByTagName( "function" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - if ( n.parentNode().toElement().tagName() != "functions" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); - if ( functionName.endsWith( ";" ) ) - functionName = functionName.left( functionName.length() - 1 ); - extraFuncts += functionName; - extraFunctTyp += n.attribute( "returnType", "void" ); - extraFunctSpecifier += n.attribute( "specifier", "virtual" ); - } - - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "customwidgets" ) { - TQDomElement n2 = n.firstChild().toElement(); - while ( !n2.isNull() ) { - if ( n2.tagName() == "customwidget" ) { - TQDomElement n3 = n2.firstChild().toElement(); - TQString cl; - WidgetDatabaseRecord *r = new WidgetDatabaseRecord; - while ( !n3.isNull() ) { - if ( n3.tagName() == "class" ) { - cl = n3.firstChild().toText().data(); - r->name = cl; - } else if ( n3.tagName() == "header" ) { - CustomInclude ci; - ci.header = n3.firstChild().toText().data(); - ci.location = n3.attribute( "location", "global" ); - r->includeFile = ci.header; - customWidgetIncludes.insert( cl, ci ); - } - WidgetDatabase::append( r ); - n3 = n3.nextSibling().toElement(); - } - } - n2 = n2.nextSibling().toElement(); - } - } - } - - // additional includes (local or global) and forward declaractions - nl = e.parentNode().toElement().elementsByTagName( "include" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - TQDomElement n2 = nl.item(i).toElement(); - TQString s = n2.firstChild().toText().data(); - if ( n2.attribute( "location" ) != "local" ) { - if ( s.right( 5 ) == ".ui.h" && !TQFile::exists( s ) ) - continue; - if ( n2.attribute( "impldecl", "in implementation" ) != "in implementation" ) - continue; - globalIncludes += s; - } - } - - registerDatabases( e ); - dbConnections = unique( dbConnections ); - if ( dbConnections.count() ) - globalIncludes += "tqsqldatabase.h"; - if ( dbCursors.count() ) - globalIncludes += "tqsqlcursor.h"; - bool dbForm = FALSE; - if ( dbForms[ "(default)" ].count() ) - dbForm = TRUE; - bool subDbForms = FALSE; - for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { - if ( !(*it).isEmpty() && (*it) != "(default)" ) { - if ( dbForms[ (*it) ].count() ) { - subDbForms = TRUE; - break; - } - } - } - if ( dbForm || subDbForms ) { - globalIncludes += "tqsqlform.h"; - globalIncludes += "tqsqlrecord.h"; - } - - // do the local includes afterwards, since global includes have priority on clashes - for ( i = 0; i < (int) nl.length(); i++ ) { - TQDomElement n2 = nl.item(i).toElement(); - TQString s = n2.firstChild().toText().data(); - if ( n2.attribute( "location" ) == "local" &&!globalIncludes.contains( s ) ) { - if ( s.right( 5 ) == ".ui.h" && !TQFile::exists( s ) ) - continue; - if ( n2.attribute( "impldecl", "in implementation" ) != "in implementation" ) - continue; - localIncludes += s; - } - } - - // additional custom widget headers - nl = e.parentNode().toElement().elementsByTagName( "header" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - TQDomElement n2 = nl.item(i).toElement(); - TQString s = n2.firstChild().toText().data(); - if ( n2.attribute( "location" ) != "local" ) - globalIncludes += s; - else - localIncludes += s; - } - - // includes for child widgets - for ( it = tags.begin(); it != tags.end(); ++it ) { - nl = e.parentNode().toElement().elementsByTagName( *it ); - for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget - TQString name = getClassName( nl.item(i).toElement() ); - if ( name == "Spacer" ) { - globalIncludes += "tqlayout.h"; - globalIncludes += "ntqapplication.h"; - continue; - } - if (( name.mid( 1 ) == "ListView" ) || ( name.mid( 2 ) == "ListView" )) - globalIncludes += "tqheader.h"; - if ( name != objClass ) { - int wid = WidgetDatabase::idFromClassName( name ); - TQMap::Iterator it = customWidgetIncludes.find( name ); - if ( it == customWidgetIncludes.end() ) - globalIncludes += WidgetDatabase::includeFile( wid ); - } - } - } - - out << "#include " << endl; // first for gcc 2.7.2 - - globalIncludes = unique( globalIncludes ); - for ( it = globalIncludes.begin(); it != globalIncludes.end(); ++it ) { - if ( !(*it).isEmpty() ) - out << "#include <" << *it << ">" << endl; - } - - out << "#include " << endl; - out << "#include " << endl; - out << "#include " << endl; - if ( objClass == "TQMainWindow" ) { - out << "#include " << endl; - out << "#include " << endl; - out << "#include " << endl; - out << "#include " << endl; - } - - // find out what images are required - TQStringList requiredImages; - static const char *imgTags[] = { "pixmap", "iconset", 0 }; - for ( i = 0; imgTags[i] != 0; i++ ) { - nl = e.parentNode().toElement().elementsByTagName( imgTags[i] ); - for ( int j = 0; j < (int) nl.length(); j++ ) { - TQDomNode nn = nl.item(j); - while ( nn.parentNode() != e.parentNode() ) - nn = nn.parentNode(); - if ( nn.nodeName() != "customwidgets" ) - requiredImages += nl.item(j).firstChild().toText().data(); - } - } - - if ( !requiredImages.isEmpty() || externPixmaps ) { - out << "#include " << endl; - out << "#include " << endl << endl; - } - - /* - Put local includes after all global includes - */ - localIncludes = unique( localIncludes ); - for ( it = localIncludes.begin(); it != localIncludes.end(); ++it ) { - if ( !(*it).isEmpty() && *it != TQFileInfo( fileName + ".h" ).fileName() ) - out << "#include \"" << *it << "\"" << endl; - } - - TQString uiDotH = fileName + ".h"; - if ( TQFile::exists( uiDotH ) ) { - if ( !outputFileName.isEmpty() ) - uiDotH = combinePath( uiDotH, outputFileName ); - out << "#include \"" << uiDotH << "\"" << endl; - writeFunctImpl = FALSE; - } - - // register the object and unify its name - objName = registerObject( objName ); - - TQStringList images; - TQStringList xpmImages; - if ( pixmapLoaderFunction.isEmpty() && !externPixmaps ) { - // 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++ ) { - TQString img = registerObject( nl.item(i).toElement().attribute("name") ); - if ( !requiredImages.contains( img ) ) - continue; - TQDomElement tmp = nl.item(i).firstChild().toElement(); - if ( tmp.tagName() != "data" ) - continue; - TQString format = tmp.attribute("format", "PNG" ); - TQString data = tmp.firstChild().toText().data(); - if ( format == "XPM.GZ" ) { - xpmImages += img; - ulong length = tmp.attribute("length").toULong(); - TQByteArray baunzip = unzipXPM( data, length ); - length = baunzip.size(); - // shouldn't we test the initial 'length' against the - // resulting 'length' to catch corrupt UIC files? - int a = 0; - int column = 0; - bool inQuote = FALSE; - out << "static const char* const " << img << "_data[] = { " << endl; - while ( baunzip[a] != '\"' ) - a++; - for ( ; a < (int) length; a++ ) { - out << baunzip[a]; - if ( baunzip[a] == '\n' ) { - column = 0; - } else if ( baunzip[a] == '"' ) { - inQuote = !inQuote; - } - - if ( column++ >= 511 && inQuote ) { - out << "\"\n\""; // be nice with MSVC & Co. - column = 1; - } - } - out << endl; - } else { - images += img; - out << "static const unsigned char " << img << "_data[] = { " << endl; - out << " "; - int a ; - for ( a = 0; a < (int) (data.length()/2)-1; a++ ) { - out << "0x" << TQString(data[2*a]) << TQString(data[2*a+1]) << ","; - if ( a % 12 == 11 ) - out << endl << " "; - else - out << " "; - } - out << "0x" << TQString(data[2*a]) << TQString(data[2*a+1]) << endl; - out << "};" << endl << endl; - } - } - } - } - out << endl; - } else if ( externPixmaps ) { - pixmapLoaderFunction = "TQPixmap::fromMimeSource"; - } - - // constructor - if ( objClass == "TQDialog" || objClass == "TQWizard" ) { - out << "/*" << endl; - out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; - out << " * name 'name' and widget flags set to 'f'." << endl; - out << " *" << endl; - out << " * The " << objClass.mid(1).lower() << " will by default be modeless, unless you set 'modal' to" << endl; - out << " * TRUE to construct a modal " << objClass.mid(1).lower() << "." << endl; - out << " */" << endl; - out << nameOfClass << "::" << bareNameOfClass << "( TQWidget* parent, const char* name, bool modal, WFlags fl )" << endl; - out << " : " << objClass << "( parent, name, modal, fl )"; - } else if ( objClass == "TQWidget" ) { - out << "/*" << endl; - out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; - out << " * name 'name' and widget flags set to 'f'." << endl; - out << " */" << endl; - out << nameOfClass << "::" << bareNameOfClass << "( TQWidget* parent, const char* name, WFlags fl )" << endl; - out << " : " << objClass << "( parent, name, fl )"; - } else if ( objClass == "TQMainWindow" ) { - out << "/*" << endl; - out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; - out << " * name 'name' and widget flags set to 'f'." << endl; - out << " *" << endl; - out << " */" << endl; - out << nameOfClass << "::" << bareNameOfClass << "( TQWidget* parent, const char* name, WFlags fl )" << endl; - out << " : " << objClass << "( parent, name, fl )"; - isMainWindow = TRUE; - } else { - out << "/*" << endl; - out << " * Constructs a " << nameOfClass << " which is a child of 'parent', with the" << endl; - out << " * name 'name'.' " << endl; - out << " */" << endl; - out << nameOfClass << "::" << bareNameOfClass << "( TQWidget* parent, const char* name )" << endl; - out << " : " << objClass << "( parent, name )"; - } - - // create pixmaps for all images - if ( !xpmImages.isEmpty() ) { - for ( it = xpmImages.begin(); it != xpmImages.end(); ++it ) { - out << "," << endl; - out << indent << " " << *it << "( (const char **) " << (*it) << "_data )"; - } - } - out << endl; - - out << "{" << endl; - if ( isMainWindow ) - out << indent << "(void)statusBar();" << endl; - - if ( !images.isEmpty() ) { - out << indent << "TQImage img;" << endl; - for ( it = images.begin(); it != images.end(); ++it ) { - out << indent << "img.loadFromData( " << (*it) << "_data, sizeof( " << (*it) << "_data ), \"PNG\" );" << endl; - out << indent << (*it) << " = img;" << endl; - } - } - - // set the properties - TQSize geometry( 0, 0 ); - - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - bool stdset = stdsetdef; - if ( n.hasAttribute( "stdset" ) ) - stdset = toBool( n.attribute( "stdset" ) ); - TQString prop = n.attribute("name"); - TQDomElement n2 = n.firstChild().toElement(); - TQString value = setObjectProperty( objClass, TQString::null, prop, n2, stdset ); - if ( value.isEmpty() ) - continue; - - if ( prop == "geometry" && n2.tagName() == "rect" ) { - TQDomElement n3 = n2.firstChild().toElement(); - while ( !n3.isNull() ) { - if ( n3.tagName() == "width" ) - geometry.setWidth( n3.firstChild().toText().data().toInt() ); - else if ( n3.tagName() == "height" ) - geometry.setHeight( n3.firstChild().toText().data().toInt() ); - n3 = n3.nextSibling().toElement(); - } - } else { - TQString call; - if ( stdset ) { - call = mkStdSet( prop ) + "( "; - } else { - call = "setProperty( \"" + prop + "\", "; - } - call += value + " );"; - - if ( n2.tagName() == "string" ) { - trout << indent << call << endl; - } else if ( prop == "name" ) { - out << indent << "if ( !name )" << endl; - out << "\t" << call << endl; - } else { - out << indent << call << 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, "this" ); - TQString comment; - TQString label = DomTool::readAttribute( n, "title", "", comment ).toString(); - out << indent << "addPage( " << page << ", TQString(\"\") );" << endl; - trout << indent << "setTitle( " << page << ", " << trcall( label, comment ) << " );" << endl; - TQVariant def( false ); - if ( DomTool::hasAttribute( n, "backEnabled" ) ) - out << indent << "setBackEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "backEnabled", def).toBool() ) << endl; - if ( DomTool::hasAttribute( n, "nextEnabled" ) ) - out << indent << "setNextEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "nextEnabled", def).toBool() ) << endl; - if ( DomTool::hasAttribute( n, "finishEnabled" ) ) - out << indent << "setFinishEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "finishEnabled", def).toBool() ) << " );" << endl; - if ( DomTool::hasAttribute( n, "helpEnabled" ) ) - out << indent << "setHelpEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "helpEnabled", def).toBool() ) << endl; - if ( DomTool::hasAttribute( n, "finish" ) ) - out << indent << "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, "this" ); - } - } - - // database support - dbConnections = unique( dbConnections ); - if ( dbConnections.count() ) - out << endl; - for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { - if ( !(*it).isEmpty() && (*it) != "(default)") { - out << indent << (*it) << "Connection = TQSqlDatabase::database( \"" <<(*it) << "\" );" << endl; - } - } - - nl = e.parentNode().toElement().elementsByTagName( "widget" ); - for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget - n = nl.item(i).toElement(); - TQString s = getClassName( n ); - if ( (dbForm || subDbForms) && (s == "TQDataBrowser" || s == "TQDataView") ) { - TQString objName = getObjectName( n ); - TQString tab = getDatabaseInfo( n, "table" ); - TQString con = getDatabaseInfo( n, "connection" ); - out << indent << "TQSqlForm* " << objName << "Form = new TQSqlForm( this, \"" << objName << "Form\" );" << endl; - TQDomElement n2; - for ( n2 = n.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) - createFormImpl( n2, objName, con, tab ); - out << indent << objName << "->setForm( " << objName << "Form );" << endl; - } - } - - // actions, toolbars, menubar - bool needEndl = FALSE; - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "actions" ) { - if ( !needEndl ) - out << endl << indent << "// actions" << endl; - createActionImpl( n.firstChild().toElement(), "this" ); - needEndl = TRUE; - } - } - if ( needEndl ) - out << endl; - needEndl = FALSE; - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "toolbars" ) { - if ( !needEndl ) - out << endl << indent << "// toolbars" << endl; - createToolbarImpl( n, objClass, objName ); - needEndl = TRUE; - } - } - if ( needEndl ) - out << endl; - needEndl = FALSE; - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "menubar" ) { - if ( !needEndl ) - out << endl << indent << "// menubar" << endl; - createMenuBarImpl( n, objClass, objName ); - needEndl = TRUE; - } - } - if ( needEndl ) - out << endl; - - out << indent << "languageChange();" << endl; - - // take minimumSizeHint() into account, for height-for-width widgets - if ( !geometry.isNull() ) { - out << indent << "resize( TQSize(" << geometry.width() << ", " - << geometry.height() << ").expandedTo(minimumSizeHint()) );" << endl; - out << indent << "clearWState( WState_Polished );" << endl; - } - - for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "connections" ) { - // setup signals and slots connections - out << endl << indent << "// signals and slots connections" << 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; - if ( sender[0] == '<' || - receiver[0] == '<' || - signal[0] == '<' || - slot[0] == '<' ) - continue; - - sender = registeredName( sender ); - receiver = registeredName( receiver ); - - // translate formwindow name to "this" - if ( sender == objName ) - sender = "this"; - if ( receiver == objName ) - receiver = "this"; - - out << indent << "connect( " << sender << ", TQ_SIGNAL( " << signal << " ), " - << receiver << ", TQ_SLOT( " << slot << " ) );" << endl; - } - } else if ( n.tagName() == "tabstops" ) { - // setup tab order - out << endl << indent << "// tab order" << 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 << "setTabOrder( " << lastName << ", " << name << " );" << endl; - lastName = name; - } - n2 = n2.nextSibling().toElement(); - } - } - } - - // buddies - bool firstBuddy = TRUE; - for ( TQValueList::Iterator buddy = buddies.begin(); buddy != buddies.end(); ++buddy ) { - if ( isObjectRegistered( (*buddy).buddy ) ) { - if ( firstBuddy ) { - out << endl << indent << "// buddies" << endl; - } - out << indent << (*buddy).key << "->setBuddy( " << registeredName( (*buddy).buddy ) << " );" << endl; - firstBuddy = FALSE; - } - } - - if ( extraFuncts.find( "init()" ) != extraFuncts.end() ) - out << indent << "init();" << endl; - - // end of constructor - out << "}" << endl; - out << endl; - - // destructor - out << "/*" << endl; - out << " * Destroys the object and frees any allocated resources" << endl; - out << " */" << endl; - out << nameOfClass << "::~" << bareNameOfClass << "()" << endl; - out << "{" << endl; - if ( extraFuncts.find( "destroy()" ) != extraFuncts.end() ) - out << indent << "destroy();" << endl; - out << indent << "// no need to delete child widgets, TQt does it all for us" << endl; - out << "}" << endl; - out << endl; - - // handle application events if required - bool needFontEventHandler = FALSE; - bool needSqlTableEventHandler = FALSE; - bool needSqlDataBrowserEventHandler = FALSE; - nl = e.elementsByTagName( "widget" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - if ( !DomTool::propertiesOfType( nl.item(i).toElement() , "font" ).isEmpty() ) - needFontEventHandler = TRUE; - TQString s = getClassName( nl.item(i).toElement() ); - if ( s == "TQDataTable" || s == "TQDataBrowser" ) { - if ( !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) - continue; - if ( s == "TQDataTable" ) - needSqlTableEventHandler = TRUE; - if ( s == "TQDataBrowser" ) - needSqlDataBrowserEventHandler = TRUE; - } - if ( needFontEventHandler && needSqlTableEventHandler && needSqlDataBrowserEventHandler ) - break; - } - if ( needFontEventHandler && FALSE ) { - // indent = "\t"; // increase indentation for if-clause below - out << "/*" << endl; - out << " * Main event handler. Reimplemented to handle" << endl; - out << " * application font changes"; - out << " */" << endl; - out << "bool " << nameOfClass << "::event( TQEvent* ev )" << endl; - out << "{" << endl; - out << " bool ret = " << objClass << "::event( ev ); " << endl; - if ( needFontEventHandler ) { - indent += "\t"; - out << " if ( ev->type() == TQEvent::ApplicationFontChange ) {" << endl; - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - TQStringList list = DomTool::propertiesOfType( n, "font" ); - for ( it = list.begin(); it != list.end(); ++it ) - createExclusiveProperty( n, *it ); - } - out << " }" << endl; - indent = " "; - } - out << "}" << endl; - out << endl; - } - - if ( needSqlTableEventHandler || needSqlDataBrowserEventHandler ) { - out << "/*" << endl; - out << " * Widget polish. Reimplemented to handle" << endl; - if ( needSqlTableEventHandler ) - out << " * default data table initialization" << endl; - if ( needSqlDataBrowserEventHandler ) - out << " * default data browser initialization" << endl; - out << " */" << endl; - out << "void " << nameOfClass << "::polish()" << endl; - out << "{" << endl; - if ( needSqlTableEventHandler ) { - for ( i = 0; i < (int) nl.length(); i++ ) { - TQString s = getClassName( nl.item(i).toElement() ); - if ( s == "TQDataTable" ) { - n = nl.item(i).toElement(); - TQString c = getObjectName( n ); - TQString conn = getDatabaseInfo( n, "connection" ); - TQString tab = getDatabaseInfo( n, "table" ); - if ( !( conn.isEmpty() || tab.isEmpty() || !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) ) { - out << indent << "if ( " << c << " ) {" << endl; - out << indent << indent << "TQSqlCursor* cursor = " << c << "->sqlCursor();" << endl; - out << indent << indent << "if ( !cursor ) {" << endl; - if ( conn == "(default)" ) - out << indent << indent << indent << "cursor = new TQSqlCursor( \"" << tab << "\" );" << endl; - else - out << indent << indent << indent << "cursor = new TQSqlCursor( \"" << tab << "\", TRUE, " << conn << "Connection );" << endl; - out << indent << indent << indent << "if ( " << c << "->isReadOnly() ) " << endl; - out << indent << indent << indent << indent << "cursor->setMode( TQSqlCursor::ReadOnly );" << endl; - out << indent << indent << indent << c << "->setSqlCursor( cursor, FALSE, TRUE );" << endl; - out << indent << indent << "}" << endl; - out << indent << indent << "if ( !cursor->isActive() )" << endl; - out << indent << indent << indent << c << "->refresh( TQDataTable::RefreshAll );" << endl; - out << indent << "}" << endl; - } - } - } - } - if ( needSqlDataBrowserEventHandler ) { - nl = e.elementsByTagName( "widget" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - TQString s = getClassName( nl.item(i).toElement() ); - if ( s == "TQDataBrowser" ) { - TQString obj = getObjectName( nl.item(i).toElement() ); - TQString tab = getDatabaseInfo( nl.item(i).toElement(), - "table" ); - TQString conn = getDatabaseInfo( nl.item(i).toElement(), - "connection" ); - if ( !(tab.isEmpty() || !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) ) { - out << indent << "if ( " << obj << " ) {" << endl; - out << indent << indent << "if ( !" << obj << "->sqlCursor() ) {" << endl; - if ( conn == "(default)" ) - out << indent << indent << indent << "TQSqlCursor* cursor = new TQSqlCursor( \"" << tab << "\" );" << endl; - else - out << indent << indent << indent << "TQSqlCursor* cursor = new TQSqlCursor( \"" << tab << "\", TRUE, " << conn << "Connection );" << endl; - out << indent << indent << indent << obj << "->setSqlCursor( cursor, TRUE );" << endl; - out << indent << indent << indent << obj << "->refresh();" << endl; - out << indent << indent << indent << obj << "->first();" << endl; - out << indent << indent << "}" << endl; - out << indent << "}" << endl; - } - } - } - } - out << indent << objClass << "::polish();" << endl; - out << "}" << endl; - out << endl; - } - - out << "/*" << endl; - out << " * Sets the strings of the subwidgets using the current" << endl; - out << " * language." << endl; - out << " */" << endl; - out << "void " << nameOfClass << "::languageChange()" << endl; - out << "{" << endl; - out << languageChangeBody; - out << "}" << endl; - out << endl; - - // create stubs for additional slots if necessary - if ( !extraFuncts.isEmpty() && writeFunctImpl ) { - it = extraFuncts.begin(); - TQStringList::Iterator it2 = extraFunctTyp.begin(); - TQStringList::Iterator it3 = extraFunctSpecifier.begin(); - while ( it != extraFuncts.end() ) { - TQString type = *it2; - if ( type.isEmpty() ) - type = "void"; - type = type.simplifyWhiteSpace(); - TQString fname = Parser::cleanArgs( *it ); - if ( !(*it3).startsWith("pure") ) { // "pure virtual" or "pureVirtual" - out << type << " " << nameOfClass << "::" << fname << endl; - out << "{" << endl; - if ( *it != "init()" && *it != "destroy()" ) { - TQRegExp numeric( "^(?:signed|unsigned|u?char|u?short|u?int" - "|u?long|Q_U?INT(?:8|16|32)|Q_U?LONG|float" - "|double)$" ); - TQString retVal; - - /* - We return some kind of dummy value to shut the - compiler up. - - 1. If the type is 'void', we return nothing. - - 2. If the type is 'bool', we return 'FALSE'. - - 3. If the type is 'unsigned long' or - 'TQ_UINT16' or 'double' or similar, we - return '0'. - - 4. If the type is 'Foo *', we return '0'. - - 5. If the type is 'Foo &', we create a static - variable of type 'Foo' and return it. - - 6. If the type is 'Foo', we assume there's a - default constructor and use it. - */ - if ( type != "void" ) { - TQStringList toks = TQStringList::split( " ", type ); - bool isBasicNumericType = - ( toks.grep(numeric).count() == toks.count() ); - - if ( type == "bool" ) { - retVal = "FALSE"; - } else if ( isBasicNumericType || type.endsWith("*") ) { - retVal = "0"; - } else if ( type.endsWith("&") ) { - do { - type.truncate( type.length() - 1 ); - } while ( type.endsWith(" ") ); - retVal = "uic_temp_var"; - out << indent << "static " << type << " " << retVal << ";" << endl; - } else { - retVal = type + "()"; - } - } - - out << indent << "tqWarning( \"" << nameOfClass << "::" << fname << ": Not implemented yet\" );" << endl; - if ( !retVal.isEmpty() ) - out << indent << "return " << retVal << ";" << endl; - } - out << "}" << endl; - out << endl; - } - ++it; - ++it2; - ++it3; - } - } -} - - -/*! Creates form support implementation code for the widgets given - in \a e. - - Traverses recursively over all children. - */ - -void Uic::createFormImpl( const TQDomElement& e, const TQString& form, const TQString& connection, const TQString& table ) -{ - if ( e.tagName() == "widget" && - e.attribute( "class" ) != "TQDataTable" ) { - TQString field = getDatabaseInfo( e, "field" ); - if ( !field.isEmpty() ) { - if ( isWidgetInTable( e, connection, table ) ) - out << indent << form << "Form->insert( " << getObjectName( e ) << ", " << fixString( field ) << " );" << endl; - } - } - TQDomElement n; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - createFormImpl( n, form, connection, table ); - } -} diff --git a/tools/designer/uic/main.cpp b/tools/designer/uic/main.cpp deleted file mode 100644 index c754d73ed..000000000 --- a/tools/designer/uic/main.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/********************************************************************** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of TQt Designer. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "uic.h" -#include "domtool.h" -#if defined(UIB) -#include "ui2uib.h" -#endif -#include -#include -#include -#include -#include -#define NO_STATIC_COLORS -#include -#include -#include - -// see ### in widgetdatabase.cpp -extern bool dbnounload; -extern TQStringList *dbpaths; - -int main( int argc, char * argv[] ) -{ - bool impl = FALSE; - bool subcl = FALSE; - bool imagecollection = FALSE; - bool imagecollection_tmpfile = FALSE; -#if defined(UIB) - bool binary = FALSE; -#endif - TQStringList images; - const char *error = 0; - const char* fileName = 0; - const char* className = 0; - const char* headerFile = 0; - TQCString outputFile; - TQCString image_tmpfile; - const char* projectName = 0; - const char* trmacro = 0; - bool nofwd = FALSE; - bool fix = FALSE; - TQCString pchFile; - TQApplication app(argc, argv, FALSE); - - TQString keybase( "/TQt Designer/" + - TQString::number( (TQT_VERSION >> 16) & 0xff ) +"." + TQString::number( (TQT_VERSION >> 8) & 0xff ) + "/" ); - TQSettings config; - config.insertSearchPath( TQSettings::Windows, "/Trolltech" ); - TQStringList pluginPaths = config.readListEntry( keybase + "PluginPaths" ); - if (pluginPaths.count()) - TQApplication::setLibraryPaths(pluginPaths); - - 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[0] == 'i' || opt == "impl" ) { - impl = TRUE; - if ( opt == "impl" || opt[1] == '\0' ) { - if ( !(n < argc-1) ) { - error = "Missing name of header file"; - break; - } - headerFile = argv[++n]; - } else - headerFile = &opt[1]; - } else if ( opt[0] == 'e' || opt == "embed" ) { - imagecollection = TRUE; - if ( opt == "embed" || opt[1] == '\0' ) { - if ( !(n < argc-1) ) { - error = "Missing name of project"; - break; - } - projectName = argv[++n]; - } else { - projectName = &opt[1]; - } - if ( argc > n+1 && qstrcmp( argv[n+1], "-f" ) == 0 ) { - imagecollection_tmpfile = TRUE; - image_tmpfile = argv[n+2]; - n += 2; - } -#if defined(UIB) - - } else if ( opt == "binary" ) { - binary = TRUE; -#endif - } else if ( opt == "nofwd" ) { - nofwd = TRUE; - } else if ( opt == "nounload" ) { - dbnounload = TRUE; - } else if ( opt == "subdecl" ) { - subcl = TRUE; - if ( !(n < argc-2) ) { - error = "Missing arguments"; - break; - } - className = argv[++n]; - headerFile = argv[++n]; - } else if ( opt == "subimpl" ) { - subcl = TRUE; - impl = TRUE; - if ( !(n < argc-2) ) { - error = "Missing arguments"; - break; - } - className = argv[++n]; - headerFile = argv[++n]; - } 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 == "L" ) { - if ( !(n < argc-1) ) { - error = "Missing plugin path."; - break; - } - if ( !dbpaths ) - dbpaths = new TQStringList(); - TQString fn = TQFile::decodeName( argv[++n] ); - dbpaths->append( fn ); - TQApplication::addLibraryPath( fn ); - } else if ( opt == "version" ) { - fprintf( stderr, - "User Interface Compiler for TQt version %s\n", - TQT_VERSION_STR ); - return 1; - } else if ( opt == "help" ) { - break; - } else if ( opt == "fix" ) { - fix = TRUE; - } else if ( opt == "pch") { - if ( !(n < argc-1) ) { - error = "Missing name of PCH file"; - break; - } - pchFile = argv[++n]; - } else { - error = "Unrecognized option"; - } - } else { - if ( imagecollection && !imagecollection_tmpfile ) - images << argv[n]; - else if ( fileName ) // can handle only one file - error = "Too many input files specified"; - else - fileName = argv[n]; - } - } - - if ( argc < 2 || error || (!fileName && !imagecollection ) ) { - fprintf( stderr, "TQt user interface compiler.\n" ); - if ( error ) - fprintf( stderr, "uic: %s\n", error ); - - fprintf( stderr, "Usage: %s [options] [mode] \n\n" - "Generate declaration:\n" - " %s [options] \n" - "Generate implementation:\n" - " %s [options] -impl \n" - "\t name of the declaration file\n" - "Generate image collection:\n" - " %s [options] -embed ...\n" - "or\n" - " %s [options] -embed -f \n" - "\t project name\n" - "\t image files\n" -#if defined(UIB) - "Generate binary UI file:\n" - " %s [options] -binary \n" -#endif - "Generate subclass declaration:\n" - " %s [options] -subdecl \n" - "\t name of the subclass to generate\n" - "\t declaration file of the baseclass\n" - "Generate subclass implementation:\n" - " %s [options] -subimpl \n" - "\t name of the subclass to generate\n" - "\t declaration file of the subclass\n" - "Options:\n" - "\t-o file Write output to file rather than stdout\n" - "\t-pch file Add #include \"file\" as the first statement in implementation\n" - "\t-nofwd Omit forward declarations of custom classes\n" - "\t-nounload Don't unload plugins after processing\n" - "\t-tr func Use func() instead of tr() for i18n\n" - "\t-L path Additional plugin search path\n" - "\t-version Display version of uic\n" - "\t-help Display this information\n" - , argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0] -#if defined(UIB) - , argv[0] -#endif - ); - return 1; - } - - if ( imagecollection_tmpfile ) { - TQFile ifile( image_tmpfile ); - if ( ifile.open( IO_ReadOnly ) ) { - TQTextStream ts( &ifile ); - TQString s = ts.read(); - s = s.simplifyWhiteSpace(); - images = TQStringList::split( ' ', s ); - for ( TQStringList::Iterator it = images.begin(); it != images.end(); ++it ) - *it = (*it).simplifyWhiteSpace(); - } - } - -#if defined(UIB) - if ( binary && outputFile.isEmpty() ) { - outputFile = fileName; - if ( outputFile.mid(outputFile.length() - 3).lower() == ".ui" ) - outputFile.truncate( outputFile.length() - 3 ); - outputFile += ".uib"; - } -#endif - - TQFile fileOut; - if ( !outputFile.isEmpty() ) { - fileOut.setName( outputFile ); - if (!fileOut.open( IO_WriteOnly ) ) { - tqWarning( "uic: Could not open output file '%s'", outputFile.data() ); - return 1; - } - } else { - fileOut.open( IO_WriteOnly, stdout ); - } - TQTextStream out( &fileOut ); - - if ( imagecollection ) { - out.setEncoding( TQTextStream::Latin1 ); - Uic::embed( out, projectName, images ); - return 0; - } - - out.setEncoding( TQTextStream::UnicodeUTF8 ); - - TQFile file( fileName ); - if ( !file.open( IO_ReadOnly ) ) { - tqWarning( "uic: Could not open file '%s'", fileName ); - return 1; - } - - TQDomDocument doc; - TQString errMsg; - int errLine; - if ( !doc.setContent( &file, &errMsg, &errLine ) ) { - tqWarning( TQString("uic: Failed to parse %s: ") + errMsg + TQString (" in line %d"), fileName, errLine ); - return 1; - } - - TQDomElement e = doc.firstChild().toElement(); - if ( e.hasAttribute("version") && e.attribute("version").toDouble() > 3.3 ) { - tqWarning( TQString("uic: File generated with too recent version of TQt Designer (%s vs. %s)"), - e.attribute("version").latin1(), TQT_VERSION_STR ); - return 1; - } - - DomTool::fixDocument( doc ); - - if ( fix ) { - out << doc.toString(); - return 0; -#if defined(UIB) - } else if ( binary ) { - out.unsetDevice(); - TQDataStream binaryOut( &fileOut ); - convertUiToUib( doc, binaryOut ); - return 0; -#endif - } - - if ( !subcl ) { - out << "/****************************************************************************" << endl; - out << "** Form "<< (impl? "implementation" : "interface") << " generated from reading ui file '" << fileName << "'" << endl; - out << "**" << endl; - out << "** Created by: The TQt user interface compiler (TQt " << TQT_VERSION_STR << ")" << endl; - out << "**" << endl; - out << "** WARNING! All changes made in this file will be lost!" << endl; - out << "****************************************************************************/" << endl << endl; - } - - TQString protector; - if ( subcl && className && !impl ) - protector = TQString::fromLocal8Bit( className ).upper() + "_H"; - - if ( !protector.isEmpty() ) { - out << "#ifndef " << protector << endl; - out << "#define " << protector << endl; - } - - if ( !pchFile.isEmpty() && impl ) { - out << "#include \"" << pchFile << "\" // PCH include" << endl; - } - - if ( headerFile ) { - out << "#include \"" << headerFile << "\"" << endl << endl; - } - - Uic( fileName, outputFile, out, doc, !impl, subcl, trmacro, className, nofwd ); - - if ( !protector.isEmpty() ) { - out << endl; - out << "#endif // " << protector << endl; - } - if ( fileOut.status() != IO_Ok ) { - tqWarning( "uic: Error writing to file" ); - if ( !outputFile.isEmpty() ) - remove( outputFile ); - } - return 0; -} diff --git a/tools/designer/uic/object.cpp b/tools/designer/uic/object.cpp deleted file mode 100644 index cd3cfbe8a..000000000 --- a/tools/designer/uic/object.cpp +++ /dev/null @@ -1,734 +0,0 @@ -/********************************************************************** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of TQt Designer. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "uic.h" -#include "parser.h" -#include "domtool.h" -#include -#include -#include -#define NO_STATIC_COLORS -#include -#include "../interfaces/widgetinterface.h" -#include "../shared/widgetdatabase.h" - -/*! - Creates a declaration for the object given in \a e. - - Children are not traversed recursively. - - \sa createObjectImpl() - */ -void Uic::createObjectDecl( const TQDomElement& e ) -{ - if ( e.tagName() == "vbox" ) { - out << " TQVBoxLayout* " << registerObject(getLayoutName(e) ) << ";" << endl; - } else if ( e.tagName() == "hbox" ) { - out << " TQHBoxLayout* " << registerObject(getLayoutName(e) ) << ";" << endl; - } else if ( e.tagName() == "grid" ) { - out << " TQGridLayout* " << registerObject(getLayoutName(e) ) << ";" << endl; - } else { - TQString objClass = getClassName( e ); - if ( objClass.isEmpty() ) - return; - TQString objName = getObjectName( e ); - if ( objName.isEmpty() ) - return; - // ignore TQLayoutWidgets - if ( objClass == "TQLayoutWidget" ) - return; - // register the object and unify its name - objName = registerObject( objName ); - if ( objClass == "Line" ) - objClass = "TQFrame"; - else if (objClass == "Spacer") - objClass = "TQSpacerItem"; - out << " " << objClass << "* " << objName << ";" << endl; - } -} - - -/*! - 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() - */ - -static bool createdCentralWidget = FALSE; - -TQString Uic::createObjectImpl( const TQDomElement &e, const TQString& parentClass, const TQString& par, const TQString& layout ) -{ - TQString parent( par ); - if ( parent == "this" && isMainWindow ) { - if ( !createdCentralWidget ) - out << indent << "setCentralWidget( new TQWidget( this, \"qt_central_widget\" ) );" << endl; - createdCentralWidget = TRUE; - parent = "centralWidget()"; - } - TQDomElement n; - TQString objClass, objName; - int numItems = 0; - int numColumns = 0; - int numRows = 0; - - 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 == "TQLayoutWidget"; - if ( isTmpObject ) { - if (( objClass[0] == 'T' ) && ( objClass[1] == 'Q' )) - objName = objClass.mid(2); - else - objName = objClass.lower(); - objName.prepend( "private" ); - } - - bool isLine = objClass == "Line"; - if ( isLine ) - objClass = "TQFrame"; - - out << endl; - if ( objClass == "TQLayoutWidget" ) { - if ( layout.isEmpty() ) { - // register the object and unify its name - objName = registerObject( objName ); - out << " TQWidget* " << objName << " = new 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; - } - } else if ( objClass != "TQToolBar" && objClass != "TQMenuBar" ) { - // register the object and unify its name - objName = registerObject( objName ); - out << " "; - if ( isTmpObject ) - out << objClass << "* "; - out << objName << " = new " << createObjectInstance( objClass, parent, objName ) << ";" << endl; - } - - lastItem = "0"; - // set the properties and insert items - bool hadFrameShadow = FALSE; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - bool stdset = stdsetdef; - if ( n.hasAttribute( "stdset" ) ) - stdset = toBool( n.attribute( "stdset" ) ); - TQString prop = n.attribute( "name" ); - if ( prop == "database" ) - continue; - TQString value = setObjectProperty( objClass, objName, prop, n.firstChild().toElement(), stdset ); - if ( value.isEmpty() ) - continue; - if ( prop == "name" ) - continue; - if ( isLine && prop == "frameShadow" ) - hadFrameShadow = TRUE; - if ( prop == "buddy" && value.startsWith("\"") && value.endsWith("\"") ) { - buddies << Buddy( objName, value.mid(1, value.length() - 2 ) ); - continue; - } - if ( isLine && prop == "orientation" ) { - prop = "frameShape"; - if ( value.right(10) == "Horizontal" ) - value = "TQFrame::HLine"; - else - value = "TQFrame::VLine"; - if ( !hadFrameShadow ) { - prop = "frameStyle"; - value += " | TQFrame::Sunken"; - } - } - if ( prop == "buttonGroupId" ) { - if ( parentClass == "TQButtonGroup" ) - out << indent << parent << "->insert( " << objName << ", " << value << " );" << endl; - continue; - } - if ( prop == "frameworkCode" ) - continue; - if ( objClass == "TQMultiLineEdit" && - TQRegExp("echoMode|hMargin|maxLength|maxLines|undoEnabled").exactMatch(prop) ) - continue; - - TQString call = objName + "->"; - if ( stdset ) { - call += mkStdSet( prop ) + "( "; - } else { - call += "setProperty( \"" + prop + "\", "; - } - if ( prop == "accel" ) - call += "TQKeySequence( " + value + " ) );"; - else - call += value + " );"; - - if ( n.firstChild().toElement().tagName() == "string" || - prop == "currentItem" ) { - trout << indent << call << endl; - } else { - out << indent << call << endl; - } - } else if ( n.tagName() == "item" ) { - TQString call; - TQString value; - - if ( objClass.contains( "ListBox" ) ) { - call = createListBoxItemImpl( n, objName ); - if ( !call.isEmpty() ) { - if ( numItems == 0 ) - trout << indent << objName << "->clear();" << endl; - trout << indent << call << endl; - } - } else if ( objClass.contains( "ComboBox" ) ) { - call = createListBoxItemImpl( n, objName, &value ); - if ( !call.isEmpty() ) { - if ( numItems == 0 ) - trout << indent << objName << "->clear();" << endl; - trout << indent << call << endl; - } - } else if ( objClass.contains( "IconView" ) ) { - call = createIconViewItemImpl( n, objName ); - if ( !call.isEmpty() ) { - if ( numItems == 0 ) - trout << indent << objName << "->clear();" << endl; - trout << indent << call << endl; - } - } else if ( objClass.contains( "ListView" ) ) { - call = createListViewItemImpl( n, objName, TQString::null ); - if ( !call.isEmpty() ) { - if ( numItems == 0 ) - trout << indent << objName << "->clear();" << endl; - trout << call << endl; - } - } - if ( !call.isEmpty() ) - numItems++; - } else if ( n.tagName() == "column" || n.tagName() == "row" ) { - TQString call; - TQString value; - - if ( objClass.contains( "ListView" ) ) { - call = createListViewColumnImpl( n, objName, &value ); - if ( !call.isEmpty() ) { - out << call; - trout << indent << objName << "->header()->setLabel( " - << numColumns++ << ", " << value << " );\n"; - } - } else if ( objClass == "TQTable" || objClass == "TQDataTable" ) { - bool isCols = ( n.tagName() == "column" ); - call = createTableRowColumnImpl( n, objName, &value ); - if ( !call.isEmpty() ) { - out << call; - trout << indent << objName << "->" - << ( isCols ? "horizontalHeader" : "verticalHeader" ) - << "()->setLabel( " - << ( isCols ? numColumns++ : numRows++ ) - << ", " << value << " );\n"; - } - } - } - } - - // 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, objName ); - TQString comment; - TQString label = DomTool::readAttribute( n, "title", "", comment ).toString(); - out << indent << objName << "->insertTab( " << page << ", TQString::fromLatin1(\"\") );" << endl; - trout << indent << objName << "->changeTab( " << page << ", " - << trcall( label, comment ) << " );" << endl; - } - } - } else if ( objClass == "TQWidgetStack" ) { - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( tags.contains( n.tagName() ) ) { - TQString page = createObjectImpl( n, objClass, objName ); - int id = DomTool::readAttribute( n, "id", "" ).toInt(); - out << indent << objName << "->addWidget( " << page << ", " << id << " );" << endl; - } - } - } else if ( objClass == "TQToolBox" ) { - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( tags.contains( n.tagName() ) ) { - TQString page = createObjectImpl( n, objClass, objName ); - TQString comment; - TQString label = DomTool::readAttribute( n, "label", "", comment ).toString(); - out << indent << objName << "->addItem( " << page << ", TQString::fromLatin1(\"\") );" << endl; - trout << indent << objName << "->setItemLabel( " << objName - << "->indexOf(" << page << "), " << trcall( label, comment ) - << " );" << endl; - } - } - } else if ( objClass != "TQToolBar" && objClass != "TQMenuBar" ) { // standard widgets - WidgetInterface *iface = 0; - widgetManager()->queryInterface( objClass, &iface ); -#ifdef QT_CONTAINER_CUSTOM_WIDGETS - int id = WidgetDatabase::idFromClassName( objClass ); - if ( WidgetDatabase::isContainer( id ) && WidgetDatabase::isCustomPluginWidget( id ) && iface ) { - TQWidgetContainerInterfacePrivate *iface2 = 0; - iface->queryInterface( IID_QWidgetContainer, (TQUnknownInterface**)&iface2 ); - if ( iface2 ) { - bool supportsPages = iface2->supportsPages( objClass ); - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( tags.contains( n.tagName() ) ) { - if ( supportsPages ) { - TQString page = createObjectImpl( n, objClass, objName ); - TQString comment; - TQString label = DomTool::readAttribute( n, "label", "", comment ).toString(); - out << indent << iface2->createCode( objClass, objName, page, label ) << endl; - } else { - createObjectImpl( n, objClass, objName ); - } - } - } - iface2->release(); - } - iface->release(); - } else { -#endif - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( tags.contains( n.tagName() ) ) - createObjectImpl( n, objClass, objName ); - } -#ifdef QT_CONTAINER_CUSTOM_WIDGETS - } -#endif - } - - return objName; -} - -/*! - Creates declarations for spacer items that are children of \a e. - - \sa createObjectDecl() -*/ - -void Uic::createSpacerDecl( const TQDomElement &e ) -{ - for ( TQDomElement n = e.firstChild().toElement(); - !n.isNull(); n = n.nextSibling().toElement() ) - if ( n.tagName() == "spacer" ) - out << " TQSpacerItem* " << registerObject(getObjectName(n)) << ";" << endl; -} - -/*! - 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 0 // it's not clear whether this check should be here or not - if ( objName.isEmpty() ) - return; -#endif - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" ) { - bool stdset = stdsetdef; - if ( n.hasAttribute( "stdset" ) ) - stdset = toBool( n.attribute( "stdset" ) ); - TQString prop = n.attribute( "name" ); - if ( prop != exclusiveProp ) - continue; - TQString value = setObjectProperty( objClass, objName, prop, n.firstChild().toElement(), stdset ); - if ( value.isEmpty() ) - continue; - // we assume the property isn't of type 'string' - out << '\t' << objName << "->setProperty( \"" << prop << "\", " << value << " );" << endl; - } - } -} - - -/*! Attention: this function has to be in sync with - Resource::saveProperty() and DomTool::elementToVariant. If you - change one, change all. - */ -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 attrname = e.parentNode().toElement().attribute( "name", "font" ); - TQString fontname; - if ( !obj.isEmpty() ) { - fontname = registerObject( obj + "_" + attrname ); - out << indent << "TQFont " << fontname << "( " << obj << "->font() );" << endl; - } else { - fontname = registerObject( "f" ); - out << indent << "TQFont " << fontname << "( 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 << obj << "->setFont( " << fontname << " ); " << endl; - else - out << indent << "setFont( " << fontname << " ); " << endl; - } else { - v = fontname; - } - } else if ( e.tagName() == "string" ) { - TQString txt = e.firstChild().toText().data(); - TQString com = getComment( e.parentNode() ); - - if ( prop == "toolTip" && objClass != "TQAction" && objClass != "TQActionGroup" ) { - if ( !obj.isEmpty() ) - trout << indent << "TQToolTip::add( " << obj << ", " - << trcall( txt, com ) << " );" << endl; - else - trout << indent << "TQToolTip::add( this, " - << trcall( txt, com ) << " );" << endl; - } else if ( prop == "whatsThis" && objClass != "TQAction" && objClass != "TQActionGroup" ) { - if ( !obj.isEmpty() ) - trout << indent << "TQWhatsThis::add( " << obj << ", " - << trcall( txt, com ) << " );" << endl; - else - trout << indent << "TQWhatsThis::add( this, " - << trcall( txt, com ) << " );" << endl; - } else { - v = trcall( txt, com ); - } - } 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 = "TQVariant( %1 )"; - v = v.arg( mkBool( e.firstChild().toText().data() ) ); - } else if ( e.tagName() == "pixmap" ) { - v = e.firstChild().toText().data(); - if ( !pixmapLoaderFunction.isEmpty() ) { - v.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); - v.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); - } - } else if ( e.tagName() == "iconset" ) { - v = "TQIconSet( %1 )"; - TQString s = e.firstChild().toText().data(); - if ( !pixmapLoaderFunction.isEmpty() ) { - s.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); - s.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); - } - v = v.arg( s ); - } else if ( e.tagName() == "image" ) { - v = e.firstChild().toText().data() + ".convertToImage()"; - } else if ( e.tagName() == "enum" ) { - if ( stdset ) - v = "%1::%2"; - else - v = "\"%1\""; - TQString oc = objClass; - TQString ev = e.firstChild().toText().data(); - if ( oc == "TQListView" && ev == "Manual" ) // #### workaround, rename TQListView::Manual in 4.0 - oc = "TQScrollView"; - if ( stdset ) - v = v.arg( oc ).arg( ev ); - else - v = v.arg( ev ); - } else if ( e.tagName() == "set" ) { - TQString keys( e.firstChild().toText().data() ); - TQStringList lst = TQStringList::split( '|', keys ); - v = "int( "; - TQStringList::Iterator it = lst.begin(); - while ( it != lst.end() ) { - v += objClass + "::" + *it; - if ( it != lst.fromLast() ) - v += " | "; - ++it; - } - 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() ); - else if ( n3.tagName() == "horstretch" ) - sp.setHorStretch( n3.firstChild().toText().data().toInt() ); - else if ( n3.tagName() == "verstretch" ) - sp.setVerStretch( n3.firstChild().toText().data().toInt() ); - n3 = n3.nextSibling().toElement(); - } - TQString tmp; - if ( !obj.isEmpty() ) - tmp = obj + "->"; - v = "TQSizePolicy( (TQSizePolicy::SizeType)%1, (TQSizePolicy::SizeType)%2, %3, %4, " + tmp + "sizePolicy().hasHeightForWidth() )"; - v = v.arg( (int)sp.horData() ).arg( (int)sp.verData() ).arg( sp.horStretch() ).arg( sp.verStretch() ); - } 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 << "TQPalette " << palette << ";" << endl; - pal_used = TRUE; - } - TQString cg = "cg"; - if ( !cg_used ) { - out << indent << "TQColorGroup " << cg << ";" << 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() ); - } else if ( e.tagName() == "date" ) { - TQDomElement n3 = e.firstChild().toElement(); - int y, m, d; - y = m = d = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "year" ) - y = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "month" ) - m = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "day" ) - d = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = "TQDate( %1, %2, %3 )"; - v = v.arg(y).arg(m).arg(d); - } else if ( e.tagName() == "time" ) { - TQDomElement n3 = e.firstChild().toElement(); - int h, m, s; - h = m = s = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "hour" ) - h = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "minute" ) - m = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "second" ) - s = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = "TQTime( %1, %2, %3 )"; - v = v.arg(h).arg(m).arg(s); - } else if ( e.tagName() == "datetime" ) { - TQDomElement n3 = e.firstChild().toElement(); - int h, mi, s, y, mo, d; - h = mi = s = y = mo = d = 0; - while ( !n3.isNull() ) { - if ( n3.tagName() == "hour" ) - h = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "minute" ) - mi = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "second" ) - s = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "year" ) - y = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "month" ) - mo = n3.firstChild().toText().data().toInt(); - else if ( n3.tagName() == "day" ) - d = n3.firstChild().toText().data().toInt(); - n3 = n3.nextSibling().toElement(); - } - v = "TQDateTime( TQDate( %1, %2, %3 ), TQTime( %4, %5, %6 ) )"; - v = v.arg(y).arg(mo).arg(d).arg(h).arg(mi).arg(s); - } else if ( e.tagName() == "stringlist" ) { - TQStringList l; - TQDomElement n3 = e.firstChild().toElement(); - TQString listname = "l"; - if ( !obj.isEmpty() ) { - listname = obj + "_stringlist"; - listname = registerObject( listname ); - out << indent << "TQStringList " << listname << ";" << endl; - } else { - listname = registerObject( listname ); - out << indent << "TQStringList " << listname << ";" << endl; - } - while ( !n3.isNull() ) { - if ( n3.tagName() == "string" ) - out << indent << listname << " << \"" << n3.firstChild().toText().data().simplifyWhiteSpace() << "\";" << endl; - n3 = n3.nextSibling().toElement(); - } - v = listname; - } - return v; -} - -/*! Extracts a named object property from \a e. - */ -TQDomElement Uic::getObjectProperty( const TQDomElement& e, const TQString& name ) -{ - TQDomElement n; - for ( n = e.firstChild().toElement(); - !n.isNull(); - n = n.nextSibling().toElement() ) { - if ( n.tagName() == "property" && n.toElement().attribute("name") == name ) - return n; - } - return n; -} diff --git a/tools/designer/uic/subclassing.cpp b/tools/designer/uic/subclassing.cpp deleted file mode 100644 index dd07cf209..000000000 --- a/tools/designer/uic/subclassing.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/********************************************************************** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of TQt Designer. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "uic.h" -#include "parser.h" -#include "widgetdatabase.h" -#include "domtool.h" -#include -#include -#include -#define NO_STATIC_COLORS -#include -#include -#include -#include - -/*! - Creates a declaration ( headerfile ) for a subclass \a subClass - of the form given in \a e - - \sa createSubImpl() - */ -void Uic::createSubDecl( const TQDomElement &e, const TQString& subClass ) -{ - TQDomElement n; - TQDomNodeList nl; - int i; - - TQString objClass = getClassName( e ); - if ( objClass.isEmpty() ) - return; - - out << "class " << subClass << " : public " << nameOfClass << endl; - out << "{" << endl; - -/* tmake ignore TQ_OBJECT */ - out << " TQ_OBJECT" << endl; - out << endl; - out << "public:" << endl; - - // constructor - if ( objClass == "TQDialog" || objClass == "TQWizard" ) { - out << " " << subClass << "( TQWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );" << endl; - } else { // standard TQWidget - out << " " << subClass << "( TQWidget* parent = 0, const char* name = 0, WFlags fl = 0 );" << endl; - } - - // destructor - out << " ~" << subClass << "();" << endl; - out << endl; - - // find additional functions - TQStringList publicSlots, protectedSlots, privateSlots; - TQStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes; - TQStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier; - TQStringList publicFuncts, protectedFuncts, privateFuncts; - TQStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp; - TQStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec; - - nl = e.parentNode().toElement().elementsByTagName( "slot" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - if ( n.parentNode().toElement().tagName() != "slots" - && n.parentNode().toElement().tagName() != "connections" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString returnType = n.attribute( "returnType", "void" ); - TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); - if ( functionName.endsWith( ";" ) ) - functionName = functionName.left( functionName.length() - 1 ); - TQString specifier = n.attribute( "specifier" ); - TQString access = n.attribute( "access" ); - if ( access == "protected" ) { - protectedSlots += functionName; - protectedSlotTypes += returnType; - protectedSlotSpecifier += specifier; - } else if ( access == "private" ) { - privateSlots += functionName; - privateSlotTypes += returnType; - privateSlotSpecifier += specifier; - } else { - publicSlots += functionName; - publicSlotTypes += returnType; - publicSlotSpecifier += specifier; - } - } - - nl = e.parentNode().toElement().elementsByTagName( "function" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - if ( n.parentNode().toElement().tagName() != "functions" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString returnType = n.attribute( "returnType", "void" ); - TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); - if ( functionName.endsWith( ";" ) ) - functionName = functionName.left( functionName.length() - 1 ); - TQString specifier = n.attribute( "specifier" ); - TQString access = n.attribute( "access" ); - if ( access == "protected" ) { - protectedFuncts += functionName; - protectedFunctRetTyp += returnType; - protectedFunctSpec += specifier; - } else if ( access == "private" ) { - privateFuncts += functionName; - privateFunctRetTyp += returnType; - privateFunctSpec += specifier; - } else { - publicFuncts += functionName; - publicFunctRetTyp += returnType; - publicFunctSpec += specifier; - } - } - - if ( !publicFuncts.isEmpty() ) - writeFunctionsSubDecl( publicFuncts, publicFunctRetTyp, publicFunctSpec ); - - // create public additional slots - if ( !publicSlots.isEmpty() ) { - out << "public slots:" << endl; - writeFunctionsSubDecl( publicSlots, publicSlotTypes, publicSlotSpecifier ); - } - - if ( !protectedFuncts.isEmpty() ) { - out << "protected:" << endl; - writeFunctionsSubDecl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec ); - } - - // create protected additional slots - if ( !protectedSlots.isEmpty() ) { - out << "protected slots:" << endl; - writeFunctionsSubDecl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier ); - } - - if ( !privateFuncts.isEmpty() ) { - out << "private:" << endl; - writeFunctionsSubDecl( privateFuncts, privateFunctRetTyp, privateFunctSpec ); - } - - // create private additional slots - if ( !privateSlots.isEmpty() ) { - out << "private slots:" << endl; - writeFunctionsSubDecl( privateSlots, privateSlotTypes, privateSlotSpecifier ); - } - out << "};" << endl; -} - -void Uic::writeFunctionsSubDecl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst ) -{ - TQValueListConstIterator it, it2, it3; - for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin(); - it != fuLst.end(); ++it, ++it2, ++it3 ) { - TQString type = *it2; - if ( type.isEmpty() ) - type = "void"; - if ( *it3 == "non virtual" ) - continue; - out << " " << type << " " << (*it) << ";" << endl; - } - out << endl; -} - -/*! - Creates an implementation for a subclass \a subClass of the form - given in \a e - - \sa createSubDecl() - */ -void Uic::createSubImpl( const TQDomElement &e, const TQString& subClass ) -{ - TQDomElement n; - TQDomNodeList nl; - int i; - - TQString objClass = getClassName( e ); - if ( objClass.isEmpty() ) - return; - - // constructor - if ( objClass == "TQDialog" || objClass == "TQWizard" ) { - out << "/* " << endl; - out << " * Constructs a " << subClass << " which is a child of 'parent', with the " << endl; - out << " * name 'name' and widget flags set to 'f' " << endl; - out << " *" << endl; - out << " * The " << objClass.mid(1).lower() << " will by default be modeless, unless you set 'modal' to" << endl; - out << " * TRUE to construct a modal " << objClass.mid(1).lower() << "." << endl; - out << " */" << endl; - out << subClass << "::" << subClass << "( TQWidget* parent, const char* name, bool modal, WFlags fl )" << endl; - out << " : " << nameOfClass << "( parent, name, modal, fl )" << endl; - } else { // standard TQWidget - out << "/* " << endl; - out << " * Constructs a " << subClass << " which is a child of 'parent', with the " << endl; - out << " * name 'name' and widget flags set to 'f' " << endl; - out << " */" << endl; - out << subClass << "::" << subClass << "( TQWidget* parent, const char* name, WFlags fl )" << endl; - out << " : " << nameOfClass << "( parent, name, fl )" << endl; - } - out << "{" << endl; - out << "}" << endl; - out << endl; - - // destructor - out << "/* " << endl; - out << " * Destroys the object and frees any allocated resources" << endl; - out << " */" << endl; - out << subClass << "::~" << subClass << "()" << endl; - out << "{" << endl; - out << " // no need to delete child widgets, TQt does it all for us" << endl; - out << "}" << endl; - out << endl; - - - // find additional functions - TQStringList publicSlots, protectedSlots, privateSlots; - TQStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes; - TQStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier; - TQStringList publicFuncts, protectedFuncts, privateFuncts; - TQStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp; - TQStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec; - - nl = e.parentNode().toElement().elementsByTagName( "slot" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - if ( n.parentNode().toElement().tagName() != "slots" - && n.parentNode().toElement().tagName() != "connections" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString returnType = n.attribute( "returnType", "void" ); - TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); - if ( functionName.endsWith( ";" ) ) - functionName = functionName.left( functionName.length() - 1 ); - TQString specifier = n.attribute( "specifier" ); - TQString access = n.attribute( "access" ); - if ( access == "protected" ) { - protectedSlots += functionName; - protectedSlotTypes += returnType; - protectedSlotSpecifier += specifier; - } else if ( access == "private" ) { - privateSlots += functionName; - privateSlotTypes += returnType; - privateSlotSpecifier += specifier; - } else { - publicSlots += functionName; - publicSlotTypes += returnType; - publicSlotSpecifier += specifier; - } - } - - nl = e.parentNode().toElement().elementsByTagName( "function" ); - for ( i = 0; i < (int) nl.length(); i++ ) { - n = nl.item(i).toElement(); - if ( n.parentNode().toElement().tagName() != "functions" ) - continue; - if ( n.attribute( "language", "C++" ) != "C++" ) - continue; - TQString returnType = n.attribute( "returnType", "void" ); - TQString functionName = n.firstChild().toText().data().stripWhiteSpace(); - if ( functionName.endsWith( ";" ) ) - functionName = functionName.left( functionName.length() - 1 ); - TQString specifier = n.attribute( "specifier" ); - TQString access = n.attribute( "access" ); - if ( access == "protected" ) { - protectedFuncts += functionName; - protectedFunctRetTyp += returnType; - protectedFunctSpec += specifier; - } else if ( access == "private" ) { - privateFuncts += functionName; - privateFunctRetTyp += returnType; - privateFunctSpec += specifier; - } else { - publicFuncts += functionName; - publicFunctRetTyp += returnType; - publicFunctSpec += specifier; - } - } - - if ( !publicFuncts.isEmpty() ) - writeFunctionsSubImpl( publicFuncts, publicFunctRetTyp, publicFunctSpec, subClass, "public function" ); - - // create stubs for public additional slots - if ( !publicSlots.isEmpty() ) - writeFunctionsSubImpl( publicSlots, publicSlotTypes, publicSlotSpecifier, subClass, "public slot" ); - - if ( !protectedFuncts.isEmpty() ) - writeFunctionsSubImpl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec, subClass, "protected function" ); - - // create stubs for protected additional slots - if ( !protectedSlots.isEmpty() ) - writeFunctionsSubImpl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier, subClass, "protected slot" ); - - if ( !privateFuncts.isEmpty() ) - writeFunctionsSubImpl( privateFuncts, privateFunctRetTyp, privateFunctSpec, subClass, "private function" ); - - // create stubs for private additional slots - if ( !privateSlots.isEmpty() ) - writeFunctionsSubImpl( privateSlots, privateSlotTypes, privateSlotSpecifier, subClass, "private slot" ); -} - -void Uic::writeFunctionsSubImpl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst, - const TQString &subClass, const TQString &descr ) -{ - TQValueListConstIterator it, it2, it3; - for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin(); - it != fuLst.end(); ++it, ++it2, ++it3 ) { - TQString type = *it2; - if ( type.isEmpty() ) - type = "void"; - if ( *it3 == "non virtual" ) - continue; - out << "/*" << endl; - out << " * " << descr << endl; - out << " */" << endl; - out << type << " " << subClass << "::" << (*it) << endl; - out << "{" << endl; - out << " tqWarning( \"" << subClass << "::" << (*it) << " not yet implemented!\" );" << endl; - out << "}" << endl << endl; - } - out << endl; -} diff --git a/tools/designer/uic/uic.cpp b/tools/designer/uic/uic.cpp deleted file mode 100644 index bcd670290..000000000 --- a/tools/designer/uic/uic.cpp +++ /dev/null @@ -1,1129 +0,0 @@ -/********************************************************************** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of TQt Designer. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "uic.h" -#include "parser.h" -#include "widgetdatabase.h" -#include "domtool.h" -#include -#include -#include -#define NO_STATIC_COLORS -#include -#include -#include -#include - -bool Uic::isMainWindow = FALSE; - -TQString Uic::getComment( const TQDomNode& n ) -{ - TQDomNode child = n.firstChild(); - while ( !child.isNull() ) { - if ( child.toElement().tagName() == "comment" ) - return child.toElement().firstChild().toText().data(); - child = child.nextSibling(); - } - return TQString::null; -} - -TQString Uic::mkBool( bool b ) -{ - return b? "TRUE" : "FALSE"; -} - -TQString Uic::mkBool( const TQString& s ) -{ - return mkBool( s == "true" || s == "1" ); -} - -bool Uic::toBool( const TQString& s ) -{ - return s == "true" || s.toInt() != 0; -} - -TQString Uic::fixString( const TQString &str, bool encode ) -{ - TQString s; - if ( !encode ) { - s = str; - s.replace( "\\", "\\\\" ); - s.replace( "\"", "\\\"" ); - s.replace( "\r", "" ); - s.replace( "\n", "\\n\"\n\"" ); - } else { - TQCString utf8 = str.utf8(); - const int l = utf8.length(); - - for ( int i = 0; i < l; ++i ) { - uchar c = (uchar)utf8[i]; - if (c != 0x0d) // skip \r - s += "\\x" + TQString::number(c, 16); - - if (i && (i % 20) == 0) - s += "\"\n \""; - } - } - - return "\"" + s + "\""; -} - -TQString Uic::trcall( const TQString& sourceText, const TQString& comment ) -{ - if ( sourceText.isEmpty() && comment.isEmpty() ) - return "TQString::null"; - - TQString t = trmacro; - bool encode = FALSE; - if ( t.isNull() ) { - t = "tr"; - for ( int i = 0; i < (int) sourceText.length(); i++ ) { - if ( sourceText[i].unicode() >= 0x80 ) { - t = "trUtf8"; - encode = TRUE; - break; - } - } - } - - if ( comment.isEmpty() ) { - return t + "( " + fixString( sourceText, encode ) + " )"; - } else { - return t + "( " + fixString( sourceText, encode ) + ", " + - fixString( comment, encode ) + " )"; - } -} - -TQString Uic::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). - */ -Uic::Uic( const TQString &fn, const char *outputFn, TQTextStream &outStream, - TQDomDocument doc, bool decl, bool subcl, const TQString &trm, - const TQString& subClass, bool omitForwardDecls ) - : out( outStream ), trout( &languageChangeBody ), - outputFileName( outputFn ), trmacro( trm ), nofwd( omitForwardDecls ) -{ - fileName = fn; - writeFunctImpl = TRUE; - defMargin = BOXLAYOUT_DEFAULT_MARGIN; - defSpacing = BOXLAYOUT_DEFAULT_SPACING; - externPixmaps = FALSE; - indent = " "; // default indent - - item_used = cg_used = pal_used = 0; - - layouts << "hbox" << "vbox" << "grid"; - tags = layouts; - tags << "widget"; - - pixmapLoaderFunction = getPixmapLoaderFunction( doc.firstChild().toElement() ); - nameOfClass = getFormClassName( doc.firstChild().toElement() ); - - uiFileVersion = doc.firstChild().toElement().attribute("version"); - stdsetdef = toBool( doc.firstChild().toElement().attribute("stdsetdef") ); - - if ( doc.firstChild().isNull() || doc.firstChild().firstChild().isNull() ) - return; - TQDomElement e = doc.firstChild().firstChild().toElement(); - TQDomElement widget; - while ( !e.isNull() ) { - if ( e.tagName() == "widget" ) { - widget = e; - } else if ( e.tagName() == "pixmapinproject" ) { - externPixmaps = TRUE; - } else if ( e.tagName() == "layoutdefaults" ) { - defSpacing = e.attribute( "spacing", defSpacing.toString() ); - defMargin = e.attribute( "margin", defMargin.toString() ); - } else if ( e.tagName() == "layoutfunctions" ) { - defSpacing = e.attribute( "spacing", defSpacing.toString() ); - bool ok; - defSpacing.toInt( &ok ); - if ( !ok ) { - TQString buf = defSpacing.toString(); - defSpacing = buf.append( "()" ); - } - defMargin = e.attribute( "margin", defMargin.toString() ); - defMargin.toInt( &ok ); - if ( !ok ) { - TQString buf = defMargin.toString(); - defMargin = buf.append( "()" ); - } - } - e = e.nextSibling().toElement(); - } - e = widget; - - if ( nameOfClass.isEmpty() ) - nameOfClass = getObjectName( e ); - namespaces = TQStringList::split( "::", nameOfClass ); - bareNameOfClass = namespaces.last(); - namespaces.remove( namespaces.fromLast() ); - - if ( subcl ) { - if ( decl ) - createSubDecl( e, subClass ); - else - createSubImpl( e, subClass ); - } else { - if ( decl ) - createFormDecl( e ); - else - createFormImpl( e ); - } - -} - -/*! Extracts a pixmap loader function from \a e - */ -TQString Uic::getPixmapLoaderFunction( const TQDomElement& e ) -{ - TQDomElement n; - for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "pixmapfunction" ) - return n.firstChild().toText().data(); - } - return TQString::null; -} - - -/*! Extracts the forms class name from \a e - */ -TQString Uic::getFormClassName( 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; - } - } - return cn; -} - -/*! Extracts a class name from \a e. - */ -TQString Uic::getClassName( const TQDomElement& e ) -{ - TQString s = e.attribute( "class" ); - if ( s.isEmpty() && e.tagName() == "toolbar" ) - s = "TQToolBar"; - else if ( s.isEmpty() && e.tagName() == "menubar" ) - s = "TQMenuBar"; - return s; -} - -/*! Returns TRUE if database framework code is generated, else FALSE. -*/ - -bool Uic::isFrameworkCodeGenerated( const TQDomElement& e ) -{ - TQDomElement n = getObjectProperty( e, "frameworkCode" ); - if ( n.attribute("name") == "frameworkCode" && - !DomTool::elementToVariant( n.firstChild().toElement(), TQVariant( true ) ).toBool() ) - return FALSE; - return TRUE; -} - -/*! Extracts an object name from \a e. It's stored in the 'name' - property. - */ -TQString Uic::getObjectName( const TQDomElement& e ) -{ - TQDomElement n = getObjectProperty( e, "name" ); - if ( n.firstChild().toElement().tagName() == "cstring" ) - return n.firstChild().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 TQLayoutWidget). - */ -TQString Uic::getLayoutName( const TQDomElement& e ) -{ - TQDomElement p = e.parentNode().toElement(); - TQString name; - - if ( getClassName(p) != "TQLayoutWidget" ) - name = "Layout"; - - TQDomElement n = getObjectProperty( p, "name" ); - if ( n.firstChild().toElement().tagName() == "cstring" ) { - name.prepend( n.firstChild().toElement().firstChild().toText().data() ); - return TQStringList::split( "::", name ).last(); - } - return e.tagName(); -} - - -TQString Uic::getDatabaseInfo( const TQDomElement& e, const TQString& tag ) -{ - TQDomElement n; - TQDomElement n1; - int child = 0; - // database info is a stringlist stored in this order - if ( tag == "connection" ) - child = 0; - else if ( tag == "table" ) - child = 1; - else if ( tag == "field" ) - child = 2; - else - return TQString::null; - n = getObjectProperty( e, "database" ); - if ( n.firstChild().toElement().tagName() == "stringlist" ) { - // find correct stringlist entry - TQDomElement n1 = n.firstChild().firstChild().toElement(); - for ( int i = 0; i < child && !n1.isNull(); ++i ) - n1 = n1.nextSibling().toElement(); - if ( n1.isNull() ) - return TQString::null; - return n1.firstChild().toText().data(); - } - return TQString::null; -} - - -void Uic::registerLayouts( const TQDomElement &e ) -{ - if ( layouts.contains(e.tagName())) { - createObjectDecl(e); - TQString t = e.tagName(); - if ( t == "vbox" || t == "hbox" || t == "grid" ) - createSpacerDecl( e ); - } - - TQDomNodeList nl = e.childNodes(); - for ( int i = 0; i < (int) nl.length(); ++i ) - registerLayouts( nl.item(i).toElement() ); -} - - -/*! - Returns include file for class \a className or a null string. - */ -TQString Uic::getInclude( const TQString& className ) -{ - int wid = WidgetDatabase::idFromClassName( className ); - if ( wid != -1 ) - return WidgetDatabase::includeFile( wid ); - return TQString::null; -} - - -void Uic::createActionDecl( const TQDomElement& e ) -{ - TQString objClass = e.tagName() == "action" ? "TQAction" : "TQActionGroup"; - TQString objName = getObjectName( e ); - if ( objName.isEmpty() ) - return; - out << " " << objClass << "* " << objName << ";" << endl; - if ( e.tagName() == "actiongroup" ) { - for ( TQDomElement n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "action" || n.tagName() == "actiongroup" ) - createActionDecl( n ); - } - } -} - -void Uic::createToolbarDecl( const TQDomElement &e ) -{ - if ( e.tagName() == "toolbar" ) - out << " " << "TQToolBar *" << getObjectName( e ) << ";" << endl; -} - -void Uic::createMenuBarDecl( const TQDomElement &e ) -{ - if ( e.tagName() == "item" ) { - out << " " << "TQPopupMenu *" << e.attribute( "name" ) << ";" << endl; - createPopupMenuDecl( e ); - } -} - -void Uic::createPopupMenuDecl( const TQDomElement &e ) -{ - for ( TQDomElement n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "action" || n.tagName() == "actiongroup" ) { - TQDomElement n2 = n.nextSibling().toElement(); - if ( n2.tagName() == "item" ) { // the action has a sub menu - out << " " << "TQPopupMenu *" << n2.attribute( "name" ) << ";" << endl; - createPopupMenuDecl( n2 ); - n = n2; - } - } - } -} - -void Uic::createActionImpl( const TQDomElement &n, const TQString &parent ) -{ - for ( TQDomElement ae = n; !ae.isNull(); ae = ae.nextSibling().toElement() ) { - TQString objName = registerObject( getObjectName( ae ) ); - if ( ae.tagName() == "action" ) - out << indent << objName << " = new TQAction( " << parent << ", \"" << objName << "\" );" << endl; - else if ( ae.tagName() == "actiongroup" ) - out << indent << objName << " = new TQActionGroup( " << parent << ", \"" << objName << "\" );" << endl; - else - continue; - bool subActionsDone = FALSE; - bool hasMenuText = FALSE; - TQString actionText; - for ( TQDomElement n2 = ae.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) { - if ( n2.tagName() == "property" ) { - bool stdset = stdsetdef; - if ( n2.hasAttribute( "stdset" ) ) - stdset = toBool( n2.attribute( "stdset" ) ); - TQString prop = n2.attribute("name"); - if ( prop == "name" ) - continue; - TQString value = setObjectProperty( "TQAction", objName, prop, n2.firstChild().toElement(), stdset ); - if ( value.isEmpty() ) - continue; - - TQString call = objName + "->"; - if ( stdset ) { - call += mkStdSet( prop ) + "( "; - } else { - call += "setProperty( \"" + prop + "\", "; - } - call += value + " );"; - - if (prop == "menuText") - hasMenuText = TRUE; - else if (prop == "text") - actionText = value; - - if ( n2.firstChild().toElement().tagName() == "string" ) { - trout << indent << call << endl; - } else { - out << indent << call << endl; - } - } else if ( !subActionsDone && ( n2.tagName() == "actiongroup" || n2.tagName() == "action" ) ) { - createActionImpl( n2, objName ); - subActionsDone = TRUE; - } - } - // workaround for loading pre-3.3 files expecting bogus TQAction behavior - if (!hasMenuText && !actionText.isEmpty() && uiFileVersion < "3.3") - trout << indent << objName << "->setMenuText(" << actionText << ");" << endl; - } -} - -TQString get_dock( const TQString &d ) -{ - if ( d == "0" ) - return "DockUnmanaged"; - if ( d == "1" ) - return "DockTornOff"; - if ( d == "2" ) - return "DockTop"; - if ( d == "3" ) - return "DockBottom"; - if ( d == "4" ) - return "DockRight"; - if ( d == "5" ) - return "DockLeft"; - if ( d == "6" ) - return "DockMinimized"; - return ""; -} - -void Uic::createToolbarImpl( const TQDomElement &n, const TQString &parentClass, const TQString &parent ) -{ - TQDomNodeList nl = n.elementsByTagName( "toolbar" ); - for ( int i = 0; i < (int) nl.length(); i++ ) { - TQDomElement ae = nl.item( i ).toElement(); - TQString dock = get_dock( ae.attribute( "dock" ) ); - TQString objName = getObjectName( ae ); - out << indent << objName << " = new TQToolBar( TQString(\"\"), this, " << dock << " ); " << endl; - createObjectImpl( ae, parentClass, parent ); - for ( TQDomElement n2 = ae.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) { - if ( n2.tagName() == "action" ) { - out << indent << n2.attribute( "name" ) << "->addTo( " << objName << " );" << endl; - } else if ( n2.tagName() == "separator" ) { - out << indent << objName << "->addSeparator();" << endl; - } else if ( n2.tagName() == "widget" ) { - if ( n2.attribute( "class" ) != "Spacer" ) { - createObjectImpl( n2, "TQToolBar", objName ); - } else { - TQString child = createSpacerImpl( n2, parentClass, parent, objName ); - out << indent << "TQApplication::sendPostedEvents( " << objName - << ", TQEvent::ChildInserted );" << endl; - out << indent << objName << "->boxLayout()->addItem( " << child << " );" << endl; - } - } - } - } -} - -void Uic::createMenuBarImpl( const TQDomElement &n, const TQString &parentClass, const TQString &parent ) -{ - TQString objName = getObjectName( n ); - out << indent << objName << " = new TQMenuBar( this, \"" << objName << "\" );" << endl; - createObjectImpl( n, parentClass, parent ); - int i = 0; - TQDomElement c = n.firstChild().toElement(); - while ( !c.isNull() ) { - if ( c.tagName() == "item" ) { - TQString itemName = c.attribute( "name" ); - out << endl; - out << indent << itemName << " = new TQPopupMenu( this );" << endl; - createPopupMenuImpl( c, parentClass, itemName ); - out << indent << objName << "->insertItem( TQString(\"\"), " << itemName << ", " << i << " );" << endl; - TQString findItem(objName + "->findItem(%1)"); - findItem = findItem.arg(i); - trout << indent << "if (" << findItem << ")" << endl; - trout << indent << indent << findItem << "->setText( " << trcall( c.attribute( "text" ) ) << " );" << endl; - } else if ( c.tagName() == "separator" ) { - out << endl; - out << indent << objName << "->insertSeparator( " << i << " );" << endl; - } - c = c.nextSibling().toElement(); - i++; - } -} - -void Uic::createPopupMenuImpl( const TQDomElement &e, const TQString &parentClass, const TQString &parent ) -{ - int i = 0; - for ( TQDomElement n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { - if ( n.tagName() == "action" || n.tagName() == "actiongroup" ) { - TQDomElement n2 = n.nextSibling().toElement(); - if ( n2.tagName() == "item" ) { // the action has a sub menu - TQString itemName = n2.attribute( "name" ); - TQString itemText = n2.attribute( "text" ); - out << indent << itemName << " = new TQPopupMenu( this );" << endl; - out << indent << parent << "->insertItem( " << n.attribute( "name" ) << "->iconSet(), "; - out << trcall( itemText ) << ", " << itemName << " );" << endl; - trout << indent << parent << "->changeItem( " << parent << "->idAt( " << i << " ), "; - trout << trcall( itemText ) << " );" << endl; - createPopupMenuImpl( n2, parentClass, itemName ); - n = n2; - } else { - out << indent << n.attribute( "name" ) << "->addTo( " << parent << " );" << endl; - } - } else if ( n.tagName() == "separator" ) { - out << indent << parent << "->insertSeparator();" << endl; - } - ++i; - } -} - -/*! - Creates implementation of an listbox item tag. -*/ - -TQString Uic::createListBoxItemImpl( const TQDomElement &e, const TQString &parent, - TQString *value ) -{ - TQDomElement n = e.firstChild().toElement(); - TQString txt; - TQString com; - TQString pix; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQString attrib = n.attribute( "name" ); - TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); - if ( attrib == "text" ) { - txt = v.toString(); - com = getComment( n ); - } else if ( attrib == "pixmap" ) { - pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); - pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); - } - } - } - n = n.nextSibling().toElement(); - } - - if ( value ) - *value = trcall( txt, com ); - - if ( pix.isEmpty() ) { - return parent + "->insertItem( " + trcall( txt, com ) + " );"; - } else { - return parent + "->insertItem( " + pix + ", " + trcall( txt, com ) + " );"; - } -} - -/*! - Creates implementation of an iconview item tag. -*/ - -TQString Uic::createIconViewItemImpl( const TQDomElement &e, const TQString &parent ) -{ - TQDomElement n = e.firstChild().toElement(); - TQString txt; - TQString com; - TQString pix; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQString attrib = n.attribute( "name" ); - TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); - if ( attrib == "text" ) { - txt = v.toString(); - com = getComment( n ); - } else if ( attrib == "pixmap" ) { - pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); - pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); - } - } - } - n = n.nextSibling().toElement(); - } - - if ( pix.isEmpty() ) - return "(void) new TQIconViewItem( " + parent + ", " + trcall( txt, com ) + " );"; - else - return "(void) new TQIconViewItem( " + parent + ", " + trcall( txt, com ) + ", " + 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 + "TQListViewItem * " + item + " = "; - } else { - item = "item"; - if ( item_used ) - s = indent + item + " = "; - else - s = indent + "TQListViewItem * " + item + " = "; - item_used = TRUE; - } - - if ( !parentItem.isEmpty() ) - s += "new TQListViewItem( " + parentItem + ", " + lastItem + " );\n"; - else - s += "new TQListViewItem( " + parent + ", " + lastItem + " );\n"; - - TQStringList texts; - TQStringList pixmaps; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQString attrib = n.attribute("name"); - TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); - if ( attrib == "text" ) - texts << v.toString(); - else if ( attrib == "pixmap" ) { - TQString pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); - pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); - } - pixmaps << pix; - } - } else if ( n.tagName() == "item" ) { - s += indent + item + "->setOpen( TRUE );\n"; - s += createListViewItemImpl( n, parent, item ); - } - n = n.nextSibling().toElement(); - } - - for ( int i = 0; i < (int)texts.count(); ++i ) { - if ( !texts[ i ].isEmpty() ) - s += indent + item + "->setText( " + TQString::number( i ) + ", " + trcall( texts[ 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, - TQString *value ) -{ - TQDomElement n = e.firstChild().toElement(); - TQString txt; - TQString com; - TQString pix; - bool clickable = FALSE, resizable = FALSE; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQString attrib = n.attribute("name"); - TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); - if ( attrib == "text" ) { - txt = v.toString(); - com = getComment( n ); - } else if ( attrib == "pixmap" ) { - pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); - pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); - } - } else if ( attrib == "clickable" ) - clickable = v.toBool(); - else if ( attrib == "resizable" || attrib == "resizeable" ) - resizable = v.toBool(); - } - n = n.nextSibling().toElement(); - } - - if ( value ) - *value = trcall( txt, com ); - - TQString s; - s = indent + parent + "->addColumn( " + trcall( txt, com ) + " );\n"; - if ( !pix.isEmpty() ) - s += indent + parent + "->header()->setLabel( " + parent + "->header()->count() - 1, " + pix + ", " + trcall( txt, com ) + " );\n"; - if ( !clickable ) - s += indent + parent + "->header()->setClickEnabled( FALSE, " + parent + "->header()->count() - 1 );\n"; - if ( !resizable ) - s += indent + parent + "->header()->setResizeEnabled( FALSE, " + parent + "->header()->count() - 1 );\n"; - return s; -} - -TQString Uic::createTableRowColumnImpl( const TQDomElement &e, const TQString &parent, - TQString *value ) -{ - TQString objClass = getClassName( e.parentNode().toElement() ); - TQDomElement n = e.firstChild().toElement(); - TQString txt; - TQString com; - TQString pix; - TQString field; - bool isRow = e.tagName() == "row"; - while ( !n.isNull() ) { - if ( n.tagName() == "property" ) { - TQString attrib = n.attribute("name"); - TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() ); - if ( attrib == "text" ) { - txt = v.toString(); - com = getComment( n ); - } else if ( attrib == "pixmap" ) { - pix = v.toString(); - if ( !pix.isEmpty() && !pixmapLoaderFunction.isEmpty() ) { - pix.prepend( pixmapLoaderFunction + "( " + TQString( externPixmaps ? "\"" : "" ) ); - pix.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); - } - } else if ( attrib == "field" ) - field = v.toString(); - } - n = n.nextSibling().toElement(); - } - - if ( value ) - *value = trcall( txt, com ); - - // ### This generated code sucks! We have to set the number of - // rows/cols before and then only do setLabel/() - // ### careful, though, since TQDataTable has an API which makes this code pretty good - - TQString s; - if ( isRow ) { - s = indent + parent + "->setNumRows( " + parent + "->numRows() + 1 );\n"; - if ( pix.isEmpty() ) - s += indent + parent + "->verticalHeader()->setLabel( " + parent + "->numRows() - 1, " - + trcall( txt, com ) + " );\n"; - else - s += indent + parent + "->verticalHeader()->setLabel( " + parent + "->numRows() - 1, " - + pix + ", " + trcall( txt, com ) + " );\n"; - } else { - if ( objClass == "TQTable" ) { - s = indent + parent + "->setNumCols( " + parent + "->numCols() + 1 );\n"; - if ( pix.isEmpty() ) - s += indent + parent + "->horizontalHeader()->setLabel( " + parent + "->numCols() - 1, " - + trcall( txt, com ) + " );\n"; - else - s += indent + parent + "->horizontalHeader()->setLabel( " + parent + "->numCols() - 1, " - + pix + ", " + trcall( txt, com ) + " );\n"; - } else if ( objClass == "TQDataTable" ) { - if ( !txt.isEmpty() && !field.isEmpty() ) { - if ( pix.isEmpty() ) - out << indent << parent << "->addColumn( " << fixString( field ) << ", " << trcall( txt, com ) << " );" << endl; - else - out << indent << parent << "->addColumn( " << fixString( field ) << ", " << trcall( txt, com ) << ", " << pix << " );" << endl; - } - } - } - 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 tqlayout = "TQVBoxLayout"; - if ( objClass == "hbox" ) - tqlayout = "TQHBoxLayout"; - else if ( objClass == "grid" ) - tqlayout = "TQGridLayout"; - - bool isGrid = e.tagName() == "grid" ; - objName = registerObject( getLayoutName( e ) ); - layoutObjects += objName; - - TQString margin = DomTool::readProperty( e, "margin", defMargin ).toString(); - TQString spacing = DomTool::readProperty( e, "spacing", defSpacing ).toString(); - TQString resizeMode = DomTool::readProperty( e, "resizeMode", TQString::null ).toString(); - - TQString optcells; - if ( isGrid ) - optcells = "1, 1, "; - if ( (parentClass == "TQGroupBox" || parentClass == "TQButtonGroup") && layout.isEmpty() ) { - // special case for group box - out << indent << parent << "->setColumnLayout(0, TQt::Vertical );" << endl; - out << indent << parent << "->layout()->setSpacing( " << spacing << " );" << endl; - out << indent << parent << "->layout()->setMargin( " << margin << " );" << endl; - out << indent << objName << " = new " << tqlayout << "( " << parent << "->layout() );" << endl; - out << indent << objName << "->setAlignment( TQt::AlignTop );" << endl; - } else { - out << indent << objName << " = new " << tqlayout << "( "; - if ( layout.isEmpty() ) - out << parent; - else { - out << "0"; - if ( !DomTool::hasProperty( e, "margin" ) ) - margin = "0"; - } - out << ", " << optcells << margin << ", " << spacing << ", \"" << objName << "\"); " << endl; - } - if ( !resizeMode.isEmpty() ) - out << indent << objName << "->setResizeMode( TQLayout::" << resizeMode << " );" << 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( getObjectName( e ) ); - - 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 TQt 2.2 - TQRect geom = DomTool::readProperty( e, "geometry", TQRect(0,0,0,0) ).toRect(); - size = geom.size(); - } - - if ( isVspacer ) - out << " " << objName << " = new TQSpacerItem( " - << size.width() << ", " << size.height() - << ", TQSizePolicy::Minimum, TQSizePolicy::" << sizeType << " );" << endl; - else - out << " " << objName << " = new TQSpacerItem( " - << size.width() << ", " << size.height() - << ", TQSizePolicy::" << sizeType << ", TQSizePolicy::Minimum );" << endl; - - return objName; -} - -static const char* const ColorRole[] = { - "Foreground", "Button", "Light", "Midlight", "Dark", "Mid", - "Text", "BrightText", "ButtonText", "Base", "Background", "Shadow", - "Highlight", "HighlightedText", "Link", "LinkVisited", 0 -}; - - -/*! - 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 = "white"; - else if ( col == black ) - color = "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 + "( " + TQString( externPixmaps ? "\"" : "" ) ); - pixmap.append( TQString( externPixmaps ? "\"" : "" ) + " )" ); - } - 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; -} - -/*! Returns TRUE if the widget properties specify that it belongs to - the database \a connection and \a table. -*/ - -bool Uic::isWidgetInTable( const TQDomElement& e, const TQString& connection, const TQString& table ) -{ - TQString conn = getDatabaseInfo( e, "connection" ); - TQString tab = getDatabaseInfo( e, "table" ); - if ( conn == connection && tab == table ) - return TRUE; - return FALSE; -} - -/*! - Registers all database connections, cursors and forms. -*/ - -void Uic::registerDatabases( const TQDomElement& e ) -{ - TQDomElement n; - TQDomNodeList nl; - int i; - nl = e.parentNode().toElement().elementsByTagName( "widget" ); - for ( i = 0; i < (int) nl.length(); ++i ) { - n = nl.item(i).toElement(); - TQString conn = getDatabaseInfo( n, "connection" ); - TQString tab = getDatabaseInfo( n, "table" ); - TQString fld = getDatabaseInfo( n, "field" ); - if ( !conn.isNull() ) { - dbConnections += conn; - if ( !tab.isNull() ) { - dbCursors[conn] += tab; - if ( !fld.isNull() ) - dbForms[conn] += tab; - } - } - } -} - -/*! - 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 ) -{ - if ( list.isEmpty() ) - return list; - - TQStringList result; - for ( TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { - if ( !result.contains(*it) ) - 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" ) || ( objClass.mid( 2 ) == "ComboBox" )) { - return objClass + "( FALSE, " + parent + ", \"" + objName + "\" )"; - } - return objClass + "( " + parent + ", \"" + objName + "\" )"; -} - -bool Uic::isLayout( const TQString& name ) const -{ - return layoutObjects.contains( name ); -} - - - diff --git a/tools/designer/uic/uic.h b/tools/designer/uic/uic.h deleted file mode 100644 index b09d67037..000000000 --- a/tools/designer/uic/uic.h +++ /dev/null @@ -1,176 +0,0 @@ -/********************************************************************** -** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. -** -** This file is part of TQt Designer. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** Licensees holding valid TQt Commercial licenses may use this file in -** accordance with the TQt Commercial License Agreement provided with -** the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef UIC_H -#define UIC_H -#include -#include -#include -#include -#include -#include -#include - -class Uic : public TQt -{ -public: - Uic( const TQString &fn, const char *outputFn, TQTextStream& out, - TQDomDocument doc, bool decl, bool subcl, const TQString &trm, - const TQString& subclname, bool omitForwardDecls ); - - void createFormDecl( const TQDomElement &e ); - void createFormImpl( const TQDomElement &e ); - - void createSubDecl( const TQDomElement &e, const TQString& subclname ); - void createSubImpl( const TQDomElement &e, const TQString& subclname ); - - void createObjectDecl( const TQDomElement &e ); - void createSpacerDecl( const TQDomElement &e ); - void createActionDecl( const TQDomElement &e ); - void createToolbarDecl( const TQDomElement &e ); - void createMenuBarDecl( const TQDomElement &e ); - void createPopupMenuDecl( const TQDomElement &e ); - void createActionImpl( const TQDomElement &e, const TQString &parent ); - void createToolbarImpl( const TQDomElement &e, const TQString &parentClass, const TQString &parent ); - void createMenuBarImpl( const TQDomElement &e, const TQString &parentClass, const TQString &parent ); - void createPopupMenuImpl( const TQDomElement &e, const TQString &parentClass, const TQString &parent ); - 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 *value = 0 ); - TQString createIconViewItemImpl( const TQDomElement &e, const TQString &parent ); - TQString createListViewColumnImpl( const TQDomElement &e, const TQString &parent, TQString *value = 0 ); - TQString createTableRowColumnImpl( const TQDomElement &e, const TQString &parent, TQString *value = 0 ); - TQString createListViewItemImpl( const TQDomElement &e, const TQString &parent, - const TQString &parentItem ); - void createColorGroupImpl( const TQString& cg, const TQDomElement& e ); - TQColorGroup loadColorGroup( const TQDomElement &e ); - - TQDomElement getObjectProperty( const TQDomElement& e, const TQString& name ); - TQString getPixmapLoaderFunction( const TQDomElement& e ); - TQString getFormClassName( const TQDomElement& e ); - TQString getClassName( const TQDomElement& e ); - TQString getObjectName( const TQDomElement& e ); - TQString getLayoutName( const TQDomElement& e ); - TQString getInclude( const TQString& className ); - - 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& ); - - TQString trcall( const TQString& sourceText, const TQString& comment = "" ); - - static void embed( TQTextStream& out, const char* project, const TQStringList& images ); - -private: - void registerLayouts ( const TQDomElement& e ); - - TQTextStream& out; - TQTextOStream trout; - TQString languageChangeBody; - TQCString outputFileName; - TQStringList objectNames; - TQMap objectMapper; - TQString indent; - TQStringList tags; - TQStringList layouts; - TQString formName; - TQString lastItem; - TQString trmacro; - bool nofwd; - - 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; - TQ_DUMMY_COMPARISON_OPERATOR(CustomInclude) - }; - TQValueList buddies; - - TQStringList layoutObjects; - bool isLayout( const TQString& name ) const; - - uint item_used : 1; - uint cg_used : 1; - uint pal_used : 1; - uint stdsetdef : 1; - uint externPixmaps : 1; - - TQString uiFileVersion; - TQString nameOfClass; - TQStringList namespaces; - TQString bareNameOfClass; - TQString pixmapLoaderFunction; - - void registerDatabases( const TQDomElement& e ); - bool isWidgetInTable( const TQDomElement& e, const TQString& connection, const TQString& table ); - bool isFrameworkCodeGenerated( const TQDomElement& e ); - TQString getDatabaseInfo( const TQDomElement& e, const TQString& tag ); - void createFormImpl( const TQDomElement& e, const TQString& form, const TQString& connection, const TQString& table ); - void writeFunctionsDecl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst ); - void writeFunctionsSubDecl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst ); - void writeFunctionsSubImpl( const TQStringList &fuLst, const TQStringList &typLst, const TQStringList &specLst, - const TQString &subClass, const TQString &descr ); - TQStringList dbConnections; - TQMap< TQString, TQStringList > dbCursors; - TQMap< TQString, TQStringList > dbForms; - - static bool isMainWindow; - static TQString mkBool( bool b ); - static TQString mkBool( const TQString& s ); - bool toBool( const TQString& s ); - static TQString fixString( const TQString &str, bool encode = FALSE ); - static bool onlyAscii; - static TQString mkStdSet( const TQString& prop ); - static TQString getComment( const TQDomNode& n ); - TQVariant defSpacing, defMargin; - TQString fileName; - bool writeFunctImpl; -}; - -#endif diff --git a/tools/designer/uic/uic.pro b/tools/designer/uic/uic.pro deleted file mode 100644 index 722dedfb0..000000000 --- a/tools/designer/uic/uic.pro +++ /dev/null @@ -1,42 +0,0 @@ -TEMPLATE = app -CONFIG += qt console warn_on release professional -HEADERS = uic.h \ - ../shared/widgetdatabase.h \ - ../shared/domtool.h \ - ../shared/parser.h \ - ../interfaces/widgetinterface.h - -#HEADERS += ../shared/ui2uib.h \ -# ../shared/uib.h - -SOURCES = main.cpp uic.cpp form.cpp object.cpp \ - subclassing.cpp embed.cpp\ - ../shared/widgetdatabase.cpp \ - ../shared/domtool.cpp \ - ../shared/parser.cpp - -#SOURCES += ../shared/ui2uib.cpp \ -# ../shared/uib.cpp - -DEFINES += QT_INTERNAL_XML -include( ../../../src/qt_professional.pri ) - -TARGET = tquic -INCLUDEPATH += ../shared -DEFINES += UIC -DESTDIR = ../../../bin - -target.path=$$bins.path -INSTALLS += target - -*-mwerks { - TEMPLATE = lib - TARGET = McUic - CONFIG -= static - CONFIG += shared plugin - DEFINES += UIC_MWERKS_PLUGIN - MWERKSDIR = $(QT_SOURCE_TREE)/util/mwerks_plugin - INCLUDEPATH += $$MWERKSDIR/Headers - LIBS += $$MWERKSDIR/Libraries/PluginLib4.shlb - SOURCES += mwerks_mac.cpp -} -- cgit v1.2.1