Eneboo - Documentación para desarrolladores
|
00001 /********************************************************************** 00002 ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved. 00003 ** 00004 ** This file is part of Qt Designer. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00012 ** licenses may use this file in accordance with the Qt Commercial License 00013 ** Agreement provided with the Software. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00020 ** information about Qt Commercial License Agreements. 00021 ** 00022 ** Contact info@trolltech.com if any conditions of this licensing are 00023 ** not clear to you. 00024 ** 00025 **********************************************************************/ 00026 00027 #ifndef RESOURCE_H 00028 #define RESOURCE_H 00029 00030 #include <qstring.h> 00031 #include <qtextstream.h> 00032 #include <qvariant.h> 00033 #include <qvaluelist.h> 00034 #include <qimage.h> 00035 #include "actiondnd.h" 00036 00037 #include "metadatabase.h" 00038 00039 class QWidget; 00040 class QObject; 00041 class QLayout; 00042 class QStyle; 00043 class QPalette; 00044 class FormWindow; 00045 class MainWindow; 00046 class QDomElement; 00047 class QDesignerGridLayout; 00048 class QListViewItem; 00049 class QMainWindow; 00050 struct LanguageInterface; 00051 class FormFile; 00052 class Project; 00053 class PopupMenuEditor; 00054 00055 class Resource 00056 { 00057 public: 00058 struct Image { 00059 QImage img; 00060 QString name; 00061 bool operator==( const Image &i ) const { 00062 return ( i.name == name && 00063 i.img == img ); 00064 } 00065 }; 00066 00067 Resource(); 00068 Resource( MainWindow* mw ); 00069 ~Resource(); 00070 00071 void setWidget( FormWindow *w ); 00072 QWidget *widget() const; 00073 00074 bool load( FormFile *ff, Project *defProject = 0 ); 00075 bool load( FormFile *ff, QIODevice*, Project *defProject = 0 ); 00076 QString copy(); 00077 00078 bool save( const QString& filename, bool formCodeOnly = FALSE); 00079 bool save( QIODevice* ); 00080 void paste( const QString &cb, QWidget *parent ); 00081 00082 static void saveImageData( const QImage &img, QTextStream &ts, int indent ); 00083 static void loadCustomWidgets( const QDomElement &e, Resource *r ); 00084 static void loadExtraSource( FormFile *formfile, const QString &currFileName, 00085 LanguageInterface *langIface, bool hasFunctions ); 00086 static bool saveFormCode( FormFile *formfile, LanguageInterface *langIface ); 00087 00088 private: 00089 void saveObject( QObject *obj, QDesignerGridLayout* grid, QTextStream &ts, int indent ); 00090 void saveChildrenOf( QObject* obj, QTextStream &ts, int indent ); 00091 void saveObjectProperties( QObject *w, QTextStream &ts, int indent ); 00092 void saveSetProperty( QObject *w, const QString &name, QVariant::Type t, QTextStream &ts, int indent ); 00093 void saveEnumProperty( QObject *w, const QString &name, QVariant::Type t, QTextStream &ts, int indent ); 00094 void saveProperty( QObject *w, const QString &name, const QVariant &value, QVariant::Type t, QTextStream &ts, int indent ); 00095 void saveProperty( const QVariant &value, QTextStream &ts, int indent ); 00096 void saveItems( QObject *obj, QTextStream &ts, int indent ); 00097 void saveItem( const QStringList &text, const QPtrList<QPixmap> &pixmaps, QTextStream &ts, int indent ); 00098 void saveItem( QListViewItem *i, QTextStream &ts, int indent ); 00099 void saveConnections( QTextStream &ts, int indent ); 00100 void saveCustomWidgets( QTextStream &ts, int indent ); 00101 void saveTabOrder( QTextStream &ts, int indent ); 00102 void saveColorGroup( QTextStream &ts, int indent, const QColorGroup &cg ); 00103 void saveColor( QTextStream &ts, int indent, const QColor &c ); 00104 void saveMetaInfoBefore( QTextStream &ts, int indent ); 00105 void saveMetaInfoAfter( QTextStream &ts, int indent ); 00106 void saveIncludeHints( QTextStream &ts, int indent ); 00107 void savePixmap( const QPixmap &p, QTextStream &ts, int indent, const QString &tagname = "pixmap" ); 00108 void saveActions( const QPtrList<QAction> &actions, QTextStream &ts, int indent ); 00109 void saveChildActions( QAction *a, QTextStream &ts, int indent ); 00110 void saveToolBars( QMainWindow *mw, QTextStream &ts, int indent ); 00111 void saveMenuBar( QMainWindow *mw, QTextStream &ts, int indent ); 00112 void savePopupMenu( PopupMenuEditor *pm, QMainWindow *mw, QTextStream &ts, int indent ); 00113 00114 QObject *createObject( const QDomElement &e, QWidget *parent, QLayout* layout = 0 ); 00115 QWidget *createSpacer( const QDomElement &e, QWidget *parent, QLayout *layout, Qt::Orientation o ); 00116 void createItem( const QDomElement &e, QWidget *widget, QListViewItem *i = 0 ); 00117 void createColumn( const QDomElement &e, QWidget *widget ); 00118 void setObjectProperty( QObject* widget, const QString &prop, const QDomElement &e); 00119 QString saveInCollection( const QImage &img ); 00120 QString saveInCollection( const QPixmap &pix ) { return saveInCollection( pix.convertToImage() ); } 00121 QImage loadFromCollection( const QString &name ); 00122 void saveImageCollection( QTextStream &ts, int indent ); 00123 void loadImageCollection( const QDomElement &e ); 00124 void loadConnections( const QDomElement &e ); 00125 void loadTabOrder( const QDomElement &e ); 00126 void loadItem( const QDomElement &n, QPixmap &pix, QString &txt, bool &hasPixmap ); 00127 void loadActions( const QDomElement &n ); 00128 void loadChildAction( QObject *parent, const QDomElement &e ); 00129 void loadToolBars( const QDomElement &n ); 00130 void loadMenuBar( const QDomElement &n ); 00131 void loadPopupMenu( PopupMenuEditor *pm, const QDomElement &e ); 00132 QColorGroup loadColorGroup( const QDomElement &e ); 00133 QPixmap loadPixmap( const QDomElement &e, const QString &tagname = "pixmap" ); 00134 00135 private: 00136 MainWindow *mainwindow; 00137 FormWindow *formwindow; 00138 QWidget* toplevel; 00139 QValueList<Image> images; 00140 bool copying, pasting; 00141 bool mainContainerSet; 00142 QStringList knownNames; 00143 QStringList usedCustomWidgets; 00144 QListViewItem *lastItem; 00145 00146 QValueList<MetaDataBase::Include> metaIncludes; 00147 QValueList<MetaDataBase::Variable> metaVariables; 00148 QStringList metaForwards; 00149 QStringList metaSignals; 00150 MetaDataBase::MetaInfo metaInfo; 00151 QMap<QString, QString> dbControls; 00152 QMap<QString, QStringList> dbTables; 00153 QMap<QString, QWidget*> widgets; 00154 QString exportMacro; 00155 bool hadGeometry; 00156 QMap<QString, QValueList<MetaDataBase::Connection> > langConnections; 00157 QString currFileName; 00158 LanguageInterface *langIface; 00159 bool hasFunctions; 00160 QStringList includeHints; 00161 00162 QString uiFileVersion; 00163 }; 00164 00165 #endif