1
/**********************************************************************
2
** Copyright (C) 2000-2002 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
**********************************************************************/
30
#include <qdatastream.h>
32
const Q_UINT32 UibMagic = 0xb77c61d8;
34
enum BlockTag { Block_End = '$', Block_Actions = 'A', Block_Buddies = 'B',
35
Block_Connections = 'C', Block_Functions = 'F',
36
Block_Images = 'G', Block_Intro = 'I', Block_Menubar = 'M',
37
Block_Slots = 'S', Block_Strings = 'Z', Block_Tabstops = 'T',
38
Block_Toolbars = 'O', Block_Variables = 'V',
41
enum ObjectTag { Object_End = '$', Object_ActionRef = 'X',
42
Object_Attribute = 'B', Object_Column = 'C',
43
Object_Event = 'E', Object_FontProperty = 'F',
44
Object_GridCell = 'G', Object_Item = 'I',
45
Object_MenuItem = 'M', Object_PaletteProperty = 'P',
46
Object_Row = 'R', Object_Separator = 'S', Object_Spacer = 'Y',
47
Object_SubAction = 'A', Object_SubLayout = 'L',
48
Object_SubWidget = 'W', Object_TextProperty = 'T',
49
Object_VariantProperty = 'V' };
51
enum PaletteTag { Palette_End = '$', Palette_Active = 'A',
52
Palette_Inactive = 'I', Palette_Disabled = 'D',
53
Palette_Color = 'C', Palette_Pixmap = 'P' };
55
enum IntroFlag { Intro_Pixmapinproject = 0x1 };
57
enum FontFlag { Font_Family = 0x1, Font_PointSize = 0x2, Font_Bold = 0x4,
58
Font_Italic = 0x8, Font_Underline = 0x10,
59
Font_StrikeOut = 0x20 };
61
enum ConnectionFlag { Connection_Language = 0x1, Connection_Sender = 0x2,
62
Connection_Signal = 0x4, Connection_Receiver = 0x8,
63
Connection_Slot = 0x10 };
70
inline int insertCString( const char *cstr );
71
inline int insertString( const QString& str );
72
inline void readBlock( QDataStream& in, int size );
74
inline const char *asCString( int offset ) const;
75
inline QString asString( int offset ) const;
76
inline QByteArray block() const;
85
uic uses insertCString(), insertString(), and block();
86
QWidgetFactory uses readBlock(), asCString(), and asString(). By
87
implementing these functions inline, we ensure that the binaries
88
don't contain needless code.
91
inline int UibStrTable::insertCString( const char *cstr )
93
if ( cstr == 0 || cstr[0] == 0 ) {
96
int nextPos = table.size();
97
int len = strlen( cstr );
99
for ( i = 0; i < nextPos - len; i++ ) {
100
if ( memcmp(table.data() + i, cstr, len + 1) == 0 )
103
for ( i = 0; i < len + 1; i++ )
104
out << (Q_UINT8) cstr[i];
109
inline int UibStrTable::insertString( const QString& str )
111
if ( str.contains('\0') || str[0] == QChar(0x7f) ) {
112
int nextPos = table.size();
113
out << (Q_UINT8) 0x7f;
117
return insertCString( str.utf8() );
121
inline void UibStrTable::readBlock( QDataStream& in, int size )
123
table.resize( start + size );
124
in.readRawBytes( table.data() + start, size );
127
inline QString UibStrTable::asString( int offset ) const
129
if ( table[offset] == 0x7f ) {
130
QDataStream in( table, IO_ReadOnly );
131
in.device()->at( offset + 1 );
136
return QString::fromUtf8( asCString(offset) );
140
inline const char *UibStrTable::asCString( int offset ) const
142
return table.data() + offset;
145
inline QByteArray UibStrTable::block() const
148
block.duplicate( table.data() + start, table.size() - start );