1
/**********************************************************************
2
** Copyright (C) 2000 Trolltech AS. All rights reserved.
4
** This file is part of Qt Designer.
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.
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.
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.
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.
22
** Contact info@trolltech.com if any conditions of this licensing are
25
**********************************************************************/
27
#ifndef QWIDGETFACTORY_H
28
#define QWIDGETFACTORY_H
35
#include <qvaluelist.h>
48
class QWidgetFactoryPrivate;
55
virtual ~QWidgetFactory();
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 );
62
virtual QWidget *createWidget( const QString &className, QWidget *parent, const char *name ) const;
63
static QStringList widgets();
64
static bool supportsWidget( const QString &widget );
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,
85
void createTableColumnOrRow( QTable *table, const QString& txt,
86
const QPixmap& pix, const QString& field,
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 );
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,
108
void unpackString( const UibStrTable& strings, QDataStream& in,
110
void unpackStringSplit( const UibStrTable& strings, QDataStream& in,
112
void unpackVariant( const UibStrTable& strings, QDataStream& in,
114
void inputSpacer( const UibStrTable& strings, QDataStream& in,
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 );
135
bool operator==( const Image &i ) const {
136
return ( i.name == name &&
144
Field( const QString &s1, const QPixmap &p, const QString &s2 ) : name( s1 ), pix( p ), field( s2 ) {}
148
Q_DUMMY_COMPARISON_OPERATOR( Field )
151
struct SqlWidgetConnection
153
SqlWidgetConnection() {}
154
SqlWidgetConnection( const QString &c, const QString &t )
155
: conn( c ), table( t ), dbControls( new QMap<QString, QString>() ) {}
158
QMap<QString, QString> *dbControls;
159
Q_DUMMY_COMPARISON_OPERATOR( SqlWidgetConnection )
162
QValueList<Image> images;
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;
177
QString uiFileVersion;