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 FORMFILE_H 00028 #define FORMFILE_H 00029 00030 #include <qobject.h> 00031 #include "timestamp.h" 00032 #include "metadatabase.h" 00033 00034 class Project; 00035 class FormWindow; 00036 class SourceEditor; 00037 00038 class FormFile : public QObject 00039 { 00040 Q_OBJECT 00041 friend class SourceEditor; 00042 00043 public: 00044 enum Who { 00045 WFormWindow = 1, 00046 WFormCode = 2, 00047 WAnyOrAll = WFormWindow | WFormCode 00048 }; 00049 00050 enum UihState { None, Ok, Deleted }; 00051 00052 FormFile( const QString &fn, bool temp, Project *p, const char *name = 0 ); 00053 ~FormFile(); 00054 00055 void setFormWindow( FormWindow *f ); 00056 void setEditor( SourceEditor *e ); 00057 void setFileName( const QString &fn ); 00058 void setCode( const QString &c ); 00059 void setModified( bool m, int who = WAnyOrAll ); 00060 void setCodeEdited( bool b ); 00061 00062 FormWindow *formWindow() const; 00063 SourceEditor *editor() const; 00064 QString fileName() const; 00065 QString absFileName() const; 00066 00067 bool supportsCodeFile() const { return !codeExtension().isEmpty(); } 00068 QString codeComment() const; 00069 QString codeFile() const; 00070 QString code(); 00071 bool isCodeEdited() const; 00072 00073 bool loadCode(); 00074 void load(); 00075 bool save( bool withMsgBox = TRUE, bool ignoreModified = FALSE ); 00076 bool saveAs( bool ignoreModified = FALSE ); 00077 bool close(); 00078 bool closeEvent(); 00079 bool isModified( int who = WAnyOrAll ); 00080 bool hasFormCode() const; 00081 void createFormCode(); 00082 void syncCode(); 00083 void checkTimeStamp(); 00084 bool isUihFileUpToDate(); 00085 void addFunctionCode( MetaDataBase::Function function ); 00086 void removeFunctionCode( MetaDataBase::Function function ); 00087 void functionNameChanged( const QString &oldName, const QString &newName ); 00088 void functionRetTypeChanged( const QString &fuName, const QString &oldType, const QString &newType ); 00089 00090 void showFormWindow(); 00091 SourceEditor *showEditor( bool askForUih = TRUE ); 00092 00093 static QString createUnnamedFileName(); 00094 QString formName() const; 00095 00096 bool isFake() const { return fake; } 00097 00098 void parseCode( const QString &txt, bool allowModify ); 00099 00100 void addConnection( const QString &sender, const QString &signal, 00101 const QString &receiver, const QString &slot ); 00102 void removeConnection( const QString &sender, const QString &signal, 00103 const QString &receiver, const QString &slot ); 00104 00105 bool hasTempFileName() const { return fileNameTemp; } 00106 void setCodeFileState( UihState ); 00107 int codeFileState() const; 00108 bool setupUihFile( bool askForUih = TRUE ); 00109 00110 Project *project() const { return pro; } 00111 00112 signals: 00113 void somethingChanged( FormFile* ); 00114 00115 private slots: 00116 void formWindowChangedSomehow(); 00117 void notifyFormWindowChange(); 00118 00119 private: 00120 bool isFormWindowModified() const; 00121 bool isCodeModified() const; 00122 void setFormWindowModified( bool m ); 00123 void setCodeModified( bool m ); 00124 QString codeExtension() const; 00125 bool checkFileName( bool allowBreak ); 00126 bool shouldOverwriteUi() const; 00127 00128 private: 00129 QString filename; 00130 bool fileNameTemp; 00131 Project *pro; 00132 FormWindow *fw; 00133 SourceEditor *ed; 00134 QString cod; 00135 TimeStamp timeStamp; 00136 bool codeEdited; 00137 QString cachedFormName; 00138 bool fake; 00139 bool pkg; 00140 bool cm; 00141 UihState codeFileStat; 00142 00143 TimeStamp timeStampUi; 00144 }; 00145 00146 #endif