source: trunk/include/qwidgetfactory.h@ 203

Last change on this file since 203 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 6.9 KB
Line 
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Designer.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12** licenses may use this file in accordance with the Qt Commercial License
13** Agreement provided with the Software.
14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17**
18** See http://www.trolltech.com/gpl/ for GPL licensing information.
19** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20** information about Qt Commercial License Agreements.
21**
22** Contact info@trolltech.com if any conditions of this licensing are
23** not clear to you.
24**
25**********************************************************************/
26
27#ifndef QWIDGETFACTORY_H
28#define QWIDGETFACTORY_H
29
30#ifndef QT_H
31#include <qstring.h>
32#include <qptrlist.h>
33#include <qimage.h>
34#include <qpixmap.h>
35#include <qvaluelist.h>
36#include <qmap.h>
37#include <qaction.h>
38#endif // QT_H
39
40class QDomDocument;
41class QDomElement;
42class QLayout;
43class QListView;
44class QListViewItem;
45class QMenuBar;
46class QTable;
47class QWidget;
48class QWidgetFactoryPrivate;
49class UibStrTable;
50
51class QWidgetFactory
52{
53public:
54 QWidgetFactory();
55 virtual ~QWidgetFactory();
56
57 static QWidget *create( const QString &uiFile, QObject *connector = 0, QWidget *parent = 0, const char *name = 0 );
58 static QWidget *create( QIODevice *dev, QObject *connector = 0, QWidget *parent = 0, const char *name = 0 );
59 static void addWidgetFactory( QWidgetFactory *factory );
60 static void loadImages( const QString &dir );
61
62 virtual QWidget *createWidget( const QString &className, QWidget *parent, const char *name ) const;
63 static QStringList widgets();
64 static bool supportsWidget( const QString &widget );
65
66private:
67 enum LayoutType { HBox, VBox, Grid, NoLayout };
68 void loadImageCollection( const QDomElement &e );
69 void loadConnections( const QDomElement &e, QObject *connector );
70 void loadTabOrder( const QDomElement &e );
71 QWidget *createWidgetInternal( const QDomElement &e, QWidget *parent, QLayout* layout, const QString &classNameArg );
72 QLayout *createLayout( QWidget *widget, QLayout* layout, LayoutType type, bool isQLayoutWidget = FALSE );
73 LayoutType layoutType( QLayout *l ) const;
74 void setProperty( QObject* widget, const QString &prop, QVariant value );
75 void setProperty( QObject* widget, const QString &prop, const QDomElement &e );
76 void createSpacer( const QDomElement &e, QLayout *layout );
77 QImage loadFromCollection( const QString &name );
78 QPixmap loadPixmap( const QString &name );
79 QPixmap loadPixmap( const QDomElement &e );
80 QColorGroup loadColorGroup( const QDomElement &e );
81 void createListViewColumn( QListView *lv, const QString& txt,
82 const QPixmap& pix, bool clickable,
83 bool resizable );
84#ifndef QT_NO_TABLE
85 void createTableColumnOrRow( QTable *table, const QString& txt,
86 const QPixmap& pix, const QString& field,
87 bool isRow );
88#endif
89 void createColumn( const QDomElement &e, QWidget *widget );
90 void loadItem( const QDomElement &e, QPixmap &pix, QString &txt, bool &hasPixmap );
91 void createItem( const QDomElement &e, QWidget *widget, QListViewItem *i = 0 );
92 void loadChildAction( QObject *parent, const QDomElement &e );
93 void loadActions( const QDomElement &e );
94 void loadToolBars( const QDomElement &e );
95 void loadMenuBar( const QDomElement &e );
96 void loadPopupMenu( QPopupMenu *p, const QDomElement &e );
97 void loadFunctions( const QDomElement &e );
98 QAction *findAction( const QString &name );
99 void loadExtraSource();
100 QString translate( const char *sourceText, const char *comment = "" );
101 QString translate( const QString& sourceText, const QString& comment = QString::null );
102
103 void unpackUInt16( QDataStream& in, Q_UINT16& n );
104 void unpackUInt32( QDataStream& in, Q_UINT32& n );
105 void unpackByteArray( QDataStream& in, QByteArray& array );
106 void unpackCString( const UibStrTable& strings, QDataStream& in,
107 QCString& cstr );
108 void unpackString( const UibStrTable& strings, QDataStream& in,
109 QString& str );
110 void unpackStringSplit( const UibStrTable& strings, QDataStream& in,
111 QString& str );
112 void unpackVariant( const UibStrTable& strings, QDataStream& in,
113 QVariant& value );
114 void inputSpacer( const UibStrTable& strings, QDataStream& in,
115 QLayout *parent );
116 void inputColumnOrRow( const UibStrTable& strings, QDataStream& in,
117 QObject *parent, bool isRow );
118 void inputItem( const UibStrTable& strings, QDataStream& in,
119 QObject *parent, QListViewItem *parentItem = 0 );
120 void inputMenuItem( QObject **objects, const UibStrTable& strings,
121 QDataStream& in, QMenuBar *menuBar );
122 QObject *inputObject( QObject **objects, int& numObjects,
123 const UibStrTable& strings, QDataStream& in,
124 QWidget *ancestorWidget, QObject *parent,
125 QCString className = "" );
126 QWidget *createFromUiFile( QDomDocument doc, QObject *connector,
127 QWidget *parent, const char *name );
128 QWidget *createFromUibFile( QDataStream& in, QObject *connector,
129 QWidget *parent, const char *name );
130
131private:
132 struct Image {
133 QImage img;
134 QString name;
135 bool operator==( const Image &i ) const {
136 return ( i.name == name &&
137 i.img == img );
138 }
139 };
140
141 struct Field
142 {
143 Field() {}
144 Field( const QString &s1, const QPixmap &p, const QString &s2 ) : name( s1 ), pix( p ), field( s2 ) {}
145 QString name;
146 QPixmap pix;
147 QString field;
148 Q_DUMMY_COMPARISON_OPERATOR( Field )
149 };
150
151 struct SqlWidgetConnection
152 {
153 SqlWidgetConnection() {}
154 SqlWidgetConnection( const QString &c, const QString &t )
155 : conn( c ), table( t ), dbControls( new QMap<QString, QString>() ) {}
156 QString conn;
157 QString table;
158 QMap<QString, QString> *dbControls;
159 Q_DUMMY_COMPARISON_OPERATOR( SqlWidgetConnection )
160 };
161
162 QValueList<Image> images;
163 QWidget *toplevel;
164 QWidgetFactoryPrivate *d;
165 QMap<QString, QString> *dbControls;
166 QMap<QString, QStringList> dbTables;
167 QMap<QWidget*, SqlWidgetConnection> sqlWidgetConnections;
168 QMap<QString, QString> buddies;
169 QMap<QTable*, QValueList<Field> > fieldMaps;
170 QPtrList<QAction> actionList;
171 QMap<QString, QString> languageSlots;
172 QStringList noDatabaseWidgets;
173 bool usePixmapCollection;
174 int defMargin;
175 int defSpacing;
176 QString code;
177 QString uiFileVersion;
178};
179
180#endif
Note: See TracBrowser for help on using the repository browser.