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 PROJECT_H 00028 #define PROJECT_H 00029 00030 #include <qfeatures.h> 00031 00032 #include <qstring.h> 00033 #include <qstringlist.h> 00034 #include <qptrlist.h> 00035 #include <qmap.h> 00036 #include <private/qpluginmanager_p.h> 00037 #include "../interfaces/projectsettingsiface.h" 00038 #include "sourcefile.h" 00039 #include "formfile.h" 00040 #include <qobjectlist.h> 00041 #include <qptrdict.h> 00042 #include "formfile.h" 00043 00044 class QObjectList; 00045 struct DesignerProject; 00046 struct DesignerDatabase; 00047 class PixmapCollection; 00048 class Project; 00049 00050 #ifndef QT_NO_SQL 00051 class QSqlDatabase; 00052 00053 class DatabaseConnection 00054 { 00055 public: 00056 DatabaseConnection( Project *p ) : 00057 #ifndef QT_NO_SQL 00058 conn( 0 ), 00059 #endif 00060 project( p ), loaded( FALSE ), iface( 0 ) {} 00061 ~DatabaseConnection(); 00062 00063 bool refreshCatalog(); 00064 bool open( bool suppressDialog = TRUE ); 00065 void close(); 00066 DesignerDatabase *iFace(); 00067 00068 bool isLoaded() const { return loaded; } 00069 void setName( const QString& n ) { nm = n; } 00070 QString name() const { return nm; } 00071 void setDriver( const QString& d ) { drv = d; } 00072 QString driver() const { return drv; } 00073 void setDatabase( const QString& db ) { dbName = db; } 00074 QString database() const { return dbName; } 00075 void setUsername( const QString& u ) { uname = u; } 00076 QString username() const { return uname; } 00077 void setPassword( const QString& p ) { pword = p; } 00078 QString password() const { return pword; } 00079 void setHostname( const QString& h ) { hname = h; } 00080 QString hostname() const { return hname; } 00081 void setPort( int p ) { prt = p; } 00082 int port() const { return prt; } 00083 QString lastError() const { return dbErr; } 00084 void addTable( const QString& t ) { tbls.append(t); } 00085 void setFields( const QString& t, const QStringList& f ) { flds[t] = f; } 00086 QStringList tables() const { return tbls; } 00087 QStringList fields( const QString& t ) { return flds[t]; } 00088 QMap<QString, QStringList> fields() { return flds; } 00089 #ifndef QT_NO_SQL 00090 QSqlDatabase* connection() const { return conn; } 00091 void remove(); 00092 #endif 00093 00094 private: 00095 QString nm; 00096 QString drv, dbName, uname, pword, hname; 00097 QString dbErr; 00098 int prt; 00099 QStringList tbls; 00100 QMap<QString, QStringList> flds; 00101 #ifndef QT_NO_SQL 00102 QSqlDatabase *conn; 00103 #endif 00104 Project *project; 00105 bool loaded; 00106 DesignerDatabase *iface; 00107 }; 00108 00109 #endif 00110 00111 class Project : public QObject 00112 { 00113 Q_OBJECT 00114 friend class DatabaseConnection; 00115 00116 public: 00117 Project( const QString &fn, const QString &pName = QString::null, 00118 QPluginManager<ProjectSettingsInterface> *pm = 0, bool isDummy = FALSE, 00119 const QString &l = "C++" ); 00120 ~Project(); 00121 00122 void setFileName( const QString &fn, bool doClear = TRUE ); 00123 QString fileName( bool singlePro = FALSE ) const; 00124 QString projectName() const; 00125 00126 void setDatabaseDescription( const QString &db ); 00127 QString databaseDescription() const; 00128 00129 void setDescription( const QString &s ); 00130 QString description() const; 00131 00132 void setLanguage( const QString &l ); 00133 QString language() const; 00134 00135 00136 bool isValid() const; 00137 00138 // returns TRUE if this project is the <No Project> project 00139 bool isDummy() const; 00140 00141 QString makeAbsolute( const QString &f ); 00142 QString makeRelative( const QString &f ); 00143 00144 void save( bool onlyProjectFile = FALSE ); 00145 00146 #ifndef QT_NO_SQL 00147 QPtrList<DatabaseConnection> databaseConnections() const; 00148 void setDatabaseConnections( const QPtrList<DatabaseConnection> &lst ); 00149 void addDatabaseConnection( DatabaseConnection *conn ); 00150 void removeDatabaseConnection( const QString &conn ); 00151 DatabaseConnection *databaseConnection( const QString &name ); 00152 QStringList databaseConnectionList(); 00153 QStringList databaseTableList( const QString &connection ); 00154 QStringList databaseFieldList( const QString &connection, const QString &table ); 00155 #endif 00156 void saveConnections(); 00157 void loadConnections(); 00158 00159 bool openDatabase( const QString &connection, bool suppressDialog = TRUE ); 00160 void closeDatabase( const QString &connection ); 00161 00162 QObjectList *formList( bool resolveFakeObjects = FALSE ) const; 00163 00164 DesignerProject *iFace(); 00165 00166 void setCustomSetting( const QString &key, const QString &value ); 00167 QString customSetting( const QString &key ) const; 00168 00169 PixmapCollection *pixmapCollection() const { return pixCollection; } 00170 00171 void setActive( bool b ); 00172 00173 QPtrListIterator<SourceFile> sourceFiles() const { return QPtrListIterator<SourceFile>(sourcefiles); } 00174 void addSourceFile( SourceFile *sf ); 00175 bool removeSourceFile( SourceFile *sf ); 00176 SourceFile* findSourceFile( const QString& filename, SourceFile *ignore = 0 ) const; 00177 00178 QPtrListIterator<FormFile> formFiles() const { return QPtrListIterator<FormFile>(formfiles); } 00179 void addFormFile( FormFile *ff ); 00180 bool removeFormFile( FormFile *ff ); 00181 FormFile* findFormFile( const QString& filename, FormFile *ignore = 0 ) const; 00182 00183 void setIncludePath( const QString &platform, const QString &path ); 00184 void setLibs( const QString &platform, const QString &path ); 00185 void setDefines( const QString &platform, const QString &path ); 00186 void setConfig( const QString &platform, const QString &config ); 00187 void setTemplate( const QString &t ); 00188 00189 QString config( const QString &platform ) const; 00190 QString libs( const QString &platform ) const; 00191 QString defines( const QString &platform ) const; 00192 QString includePath( const QString &platform ) const; 00193 QString templte() const; 00194 00195 bool isModified() const { return !isDummy() && modified; } 00196 void setModified( bool b ); 00197 00198 void addObject( QObject *o ); 00199 void setObjects( const QObjectList &ol ); 00200 void removeObject( QObject *o ); 00201 QObjectList objects() const; 00202 FormFile *fakeFormFileFor( QObject *o ) const; 00203 QObject *objectForFakeForm( FormWindow *fw ) const; 00204 QObject *objectForFakeFormFile( FormFile *ff ) const; 00205 00206 void addAndEditFunction( const QString &functionName, const QString &functionBody, 00207 bool openDeveloper ); 00208 00209 void removeTempProject(); 00210 bool hasParentObject( QObject *o ); 00211 QString qualifiedName( QObject *o ); 00212 00213 bool isCpp() const { return is_cpp; } 00214 00215 void designerCreated(); 00216 00217 void formOpened( FormWindow *fw ); 00218 00219 QString locationOfObject( QObject *o ); 00220 00221 bool hasGUI() const; 00222 00223 signals: 00224 void projectModified(); 00225 void sourceFileAdded( SourceFile* ); 00226 void sourceFileRemoved( SourceFile* ); 00227 void formFileAdded( FormFile* ); 00228 void formFileRemoved( FormFile* ); 00229 void objectAdded( QObject * ); 00230 void objectRemoved( QObject * ); 00231 void newFormOpened( FormWindow *fw ); 00232 00233 private: 00234 void parse(); 00235 void clear(); 00236 void updateCustomSettings(); 00237 void readPlatformSettings( const QString &contents, 00238 const QString &setting, 00239 QMap<QString, QString> &res ); 00240 void removePlatformSettings( QString &contents, const QString &setting ); 00241 void writePlatformSettings( QString &contents, const QString &setting, 00242 const QMap<QString, QString> &input ); 00243 bool singleProjectMode() const; 00244 QWidget *messageBoxParent() const; 00245 00246 private: 00247 QString filename; 00248 QString proName; 00249 QString desc; 00250 QString dbFile; 00251 #ifndef QT_NO_SQL 00252 QPtrList<DatabaseConnection> dbConnections; 00253 #endif 00254 QString lang; 00255 DesignerProject *iface; 00256 QMap<QString, QString> customSettings; 00257 QStringList csList; 00258 QPluginManager<ProjectSettingsInterface> *projectSettingsPluginManager; 00259 PixmapCollection *pixCollection; 00260 QPtrList<SourceFile> sourcefiles; 00261 QPtrList<FormFile> formfiles; 00262 QMap<QString, QString> inclPath, defs, lbs, cfg, sources, headers; 00263 QString templ; 00264 bool isDummyProject; 00265 bool modified; 00266 QObjectList objs; 00267 QPtrDict<FormFile> fakeFormFiles; 00268 QString singleProFileName; 00269 bool is_cpp; 00270 00271 }; 00272 00273 #endif