source: trunk/tools/designer/designer/resource.h

Last change on this file was 197, checked in by rudi, 14 years ago

Added QtDesigner

File size: 6.7 KB
Line 
1/**********************************************************************
2** Copyright (C) 2005-2007 Trolltech ASA. 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 RESOURCE_H
28#define RESOURCE_H
29
30#include <qstring.h>
31#include <qtextstream.h>
32#include <qvariant.h>
33#include <qvaluelist.h>
34#include <qimage.h>
35#include "actiondnd.h"
36
37#include "metadatabase.h"
38
39class QWidget;
40class QObject;
41class QLayout;
42class QStyle;
43class QPalette;
44class FormWindow;
45class MainWindow;
46class QDomElement;
47class QDesignerGridLayout;
48class QListViewItem;
49class QMainWindow;
50struct LanguageInterface;
51class FormFile;
52class Project;
53class PopupMenuEditor;
54
55class Resource
56{
57public:
58 struct Image {
59 QImage img;
60 QString name;
61 bool operator==( const Image &i ) const {
62 return ( i.name == name &&
63 i.img == img );
64 }
65 };
66
67 Resource();
68 Resource( MainWindow* mw );
69 ~Resource();
70
71 void setWidget( FormWindow *w );
72 QWidget *widget() const;
73
74 bool load( FormFile *ff, Project *defProject = 0 );
75 bool load( FormFile *ff, QIODevice*, Project *defProject = 0 );
76 QString copy();
77
78 bool save( const QString& filename, bool formCodeOnly = FALSE);
79 bool save( QIODevice* );
80 void paste( const QString &cb, QWidget *parent );
81
82 static void saveImageData( const QImage &img, QTextStream &ts, int indent );
83 static void loadCustomWidgets( const QDomElement &e, Resource *r );
84 static void loadExtraSource( FormFile *formfile, const QString &currFileName,
85 LanguageInterface *langIface, bool hasFunctions );
86 static bool saveFormCode( FormFile *formfile, LanguageInterface *langIface );
87
88private:
89 void saveObject( QObject *obj, QDesignerGridLayout* grid, QTextStream &ts, int indent );
90 void saveChildrenOf( QObject* obj, QTextStream &ts, int indent );
91 void saveObjectProperties( QObject *w, QTextStream &ts, int indent );
92 void saveSetProperty( QObject *w, const QString &name, QVariant::Type t, QTextStream &ts, int indent );
93 void saveEnumProperty( QObject *w, const QString &name, QVariant::Type t, QTextStream &ts, int indent );
94 void saveProperty( QObject *w, const QString &name, const QVariant &value, QVariant::Type t, QTextStream &ts, int indent );
95 void saveProperty( const QVariant &value, QTextStream &ts, int indent );
96 void saveItems( QObject *obj, QTextStream &ts, int indent );
97 void saveItem( const QStringList &text, const QPtrList<QPixmap> &pixmaps, QTextStream &ts, int indent );
98 void saveItem( QListViewItem *i, QTextStream &ts, int indent );
99 void saveConnections( QTextStream &ts, int indent );
100 void saveCustomWidgets( QTextStream &ts, int indent );
101 void saveTabOrder( QTextStream &ts, int indent );
102 void saveColorGroup( QTextStream &ts, int indent, const QColorGroup &cg );
103 void saveColor( QTextStream &ts, int indent, const QColor &c );
104 void saveMetaInfoBefore( QTextStream &ts, int indent );
105 void saveMetaInfoAfter( QTextStream &ts, int indent );
106 void saveIncludeHints( QTextStream &ts, int indent );
107 void savePixmap( const QPixmap &p, QTextStream &ts, int indent, const QString &tagname = "pixmap" );
108 void saveActions( const QPtrList<QAction> &actions, QTextStream &ts, int indent );
109 void saveChildActions( QAction *a, QTextStream &ts, int indent );
110 void saveToolBars( QMainWindow *mw, QTextStream &ts, int indent );
111 void saveMenuBar( QMainWindow *mw, QTextStream &ts, int indent );
112 void savePopupMenu( PopupMenuEditor *pm, QMainWindow *mw, QTextStream &ts, int indent );
113
114 QObject *createObject( const QDomElement &e, QWidget *parent, QLayout* layout = 0 );
115 QWidget *createSpacer( const QDomElement &e, QWidget *parent, QLayout *layout, Qt::Orientation o );
116 void createItem( const QDomElement &e, QWidget *widget, QListViewItem *i = 0 );
117 void createColumn( const QDomElement &e, QWidget *widget );
118 void setObjectProperty( QObject* widget, const QString &prop, const QDomElement &e);
119 QString saveInCollection( const QImage &img );
120 QString saveInCollection( const QPixmap &pix ) { return saveInCollection( pix.convertToImage() ); }
121 QImage loadFromCollection( const QString &name );
122 void saveImageCollection( QTextStream &ts, int indent );
123 void loadImageCollection( const QDomElement &e );
124 void loadConnections( const QDomElement &e );
125 void loadTabOrder( const QDomElement &e );
126 void loadItem( const QDomElement &n, QPixmap &pix, QString &txt, bool &hasPixmap );
127 void loadActions( const QDomElement &n );
128 void loadChildAction( QObject *parent, const QDomElement &e );
129 void loadToolBars( const QDomElement &n );
130 void loadMenuBar( const QDomElement &n );
131 void loadPopupMenu( PopupMenuEditor *pm, const QDomElement &e );
132 QColorGroup loadColorGroup( const QDomElement &e );
133 QPixmap loadPixmap( const QDomElement &e, const QString &tagname = "pixmap" );
134
135private:
136 MainWindow *mainwindow;
137 FormWindow *formwindow;
138 QWidget* toplevel;
139 QValueList<Image> images;
140 bool copying, pasting;
141 bool mainContainerSet;
142 QStringList knownNames;
143 QStringList usedCustomWidgets;
144 QListViewItem *lastItem;
145
146 QValueList<MetaDataBase::Include> metaIncludes;
147 QValueList<MetaDataBase::Variable> metaVariables;
148 QStringList metaForwards;
149 QStringList metaSignals;
150 MetaDataBase::MetaInfo metaInfo;
151 QMap<QString, QString> dbControls;
152 QMap<QString, QStringList> dbTables;
153 QMap<QString, QWidget*> widgets;
154 QString exportMacro;
155 bool hadGeometry;
156 QMap<QString, QValueList<MetaDataBase::Connection> > langConnections;
157 QString currFileName;
158 LanguageInterface *langIface;
159 bool hasFunctions;
160 QStringList includeHints;
161
162 QString uiFileVersion;
163};
164
165#endif
Note: See TracBrowser for help on using the repository browser.