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 MAINWINDOW_H 00028 #define MAINWINDOW_H 00029 00030 #include "metadatabase.h" 00031 #include "../interfaces/actioninterface.h" // for GCC 2.7.* compatibility 00032 #include "../interfaces/editorinterface.h" 00033 #include "../interfaces/templatewizardiface.h" 00034 #include "../interfaces/languageinterface.h" 00035 #include "../interfaces/filterinterface.h" 00036 #include "../interfaces/interpreterinterface.h" 00037 #include "../interfaces/preferenceinterface.h" 00038 #include "../interfaces/projectsettingsiface.h" 00039 #include "../interfaces/sourcetemplateiface.h" 00040 #include "sourceeditor.h" 00041 00042 #include <qaction.h> 00043 #include <qmainwindow.h> 00044 #include <qmap.h> 00045 #include <qguardedptr.h> 00046 #include <private/qpluginmanager_p.h> 00047 #include <qobjectlist.h> 00048 00049 class QToolBox; 00050 class PropertyEditor; 00051 class QWorkspace; 00052 class QMenuBar; 00053 class FormWindow; 00054 class QPopupMenu; 00055 class HierarchyView; 00056 class QCloseEvent; 00057 class Workspace; 00058 class ActionEditor; 00059 class Project; 00060 class OutputWindow; 00061 class QTimer; 00062 class FindDialog; 00063 struct DesignerProject; 00064 class ReplaceDialog; 00065 class GotoLineDialog; 00066 class SourceFile; 00067 class FormFile; 00068 class QAssistantClient; 00069 00070 #if defined(Q_FULL_TEMPLATE_INSTANTIATION) 00071 #include <qtoolbar.h> 00072 #else 00073 class QToolBar; 00074 #endif 00075 class Preferences; 00076 00077 class MainWindow : public QMainWindow 00078 { 00079 Q_OBJECT 00080 00081 public: 00082 enum LineMode { Error, Step, StackFrame }; 00083 00084 MainWindow( bool asClient, bool single = FALSE, const QString &plgDir = "/designer" ); 00085 ~MainWindow(); 00086 00087 HierarchyView *objectHierarchy() const; 00088 Workspace *workspace() const; 00089 PropertyEditor *propertyeditor() const; 00090 ActionEditor *actioneditor() const; 00091 00092 void resetTool(); 00093 int currentTool() const; 00094 00095 FormWindow *formWindow(); 00096 00097 bool unregisterClient( FormWindow *w ); 00098 void editorClosed( SourceEditor *e ); 00099 QWidget *isAFormWindowChild( QObject *o ) const; 00100 QWidget *isAToolBarChild( QObject *o ) const; 00101 00102 void insertFormWindow( FormWindow *fw ); 00103 QWorkspace *qWorkspace() const; 00104 00105 void popupFormWindowMenu( const QPoint &gp, FormWindow *fw ); 00106 void popupWidgetMenu( const QPoint &gp, FormWindow *fw, QWidget *w ); 00107 00108 QPopupMenu *setupNormalHierarchyMenu( QWidget *parent ); 00109 QPopupMenu *setupTabWidgetHierarchyMenu( QWidget *parent, const char *addSlot, const char *removeSlot ); 00110 00111 FormWindow *openFormWindow( const QString &fn, bool validFileName = TRUE, FormFile *ff = 0 ); 00112 bool isCustomWidgetUsed( MetaDataBase::CustomWidget *w ); 00113 00114 void setGrid( const QPoint &p ); 00115 void setShowGrid( bool b ); 00116 void setSnapGrid( bool b ); 00117 QPoint grid() const { return grd; } 00118 bool showGrid() const { return sGrid; } 00119 bool snapGrid() const { return snGrid && sGrid; } 00120 00121 QString documentationPath() const; 00122 00123 static MainWindow *self; 00124 00125 QString templatePath() const { return templPath; } 00126 00127 void editFunction( const QString &func, bool rereadSource = FALSE ); 00128 00129 bool isPreviewing() const { return previewing; } 00130 00131 Project *currProject() const { return currentProject; } 00132 00133 FormWindow *activeForm() const { return lastActiveFormWindow; } 00134 00135 TemplateWizardInterface* templateWizardInterface( const QString& className ); 00136 QStringList sourceTemplates() const; 00137 SourceTemplateInterface* sourceTemplateInterface( const QString& templ ); 00138 QUnknownInterface* designerInterface() const { return desInterface; } 00139 QPtrList<DesignerProject> projectList() const; 00140 QStringList projectNames() const; 00141 QStringList projectFileNames() const; 00142 Project *findProject( const QString &projectName ) const; 00143 void setCurrentProject( Project *pro ); 00144 void setCurrentProjectByFilename( const QString& proFilename ); 00145 OutputWindow *outputWindow() const { return oWindow; } 00146 void addPreferencesTab( QWidget *tab, const QString &title, QObject *receiver, const char *init_slot, const char *accept_slot ); 00147 void addProjectTab( QWidget *tab, const QString &title, QObject *receiver, const char *init_slot, const char *accept_slot ); 00148 void setModified( bool b, QWidget *window ); 00149 void functionsChanged(); 00150 void updateFunctionList(); 00151 void updateWorkspace(); 00152 void runProjectPrecondition(); 00153 void runProjectPostcondition( QObjectList *l ); 00154 00155 void formNameChanged( FormWindow *fw ); 00156 00157 int currentLayoutDefaultSpacing() const; 00158 int currentLayoutDefaultMargin() const; 00159 00160 void saveAllBreakPoints(); 00161 void resetBreakPoints(); 00162 00163 SourceFile *sourceFile(); 00164 void createNewProject( const QString &lang ); 00165 00166 void popupProjectMenu( const QPoint &pos ); 00167 QObject *findRealObject( QObject *o ); 00168 00169 void setSingleProject( Project *pro ); 00170 bool singleProjectMode() const { return singleProject; } 00171 00172 void showSourceLine( QObject *o, int line, LineMode lm ); 00173 00174 void shuttingDown(); 00175 void showGUIStuff( bool b ); 00176 void setEditorsReadOnly( bool b ); 00177 bool areEditorsReadOnly() const { return editorsReadOnly; } 00178 void toggleSignalHandlers( bool show ); 00179 bool showSignalHandlers() const { return sSignalHandlers; } 00180 void writeConfig(); 00181 00182 void openProject( const QString &fn ); 00183 void setPluginDirectory( const QString &pd ); 00184 QString pluginDirectory() const { return pluginDir; } 00185 00186 QAssistantClient* assistantClient() const { return assistant; } 00187 00188 void addRecentlyOpenedFile( const QString &fn ) { addRecentlyOpened( fn, recentlyFiles ); } 00189 00190 public slots: 00191 void showProperties( QObject *w ); 00192 void updateProperties( QObject *w ); 00193 void showDialogHelp(); 00194 void showDebugStep( QObject *o, int line ); 00195 void showStackFrame( QObject *o, int line ); 00196 void showErrorMessage( QObject *o, int line, const QString &errorMessage ); 00197 void finishedRun(); 00198 void breakPointsChanged(); 00199 00200 signals: 00201 void currentToolChanged(); 00202 void hasActiveForm( bool ); 00203 void hasActiveWindow( bool ); 00204 void hasActiveWindowOrProject( bool ); 00205 void hasNonDummyProject( bool ); 00206 void formModified( bool ); 00207 void formWindowsChanged(); 00208 void formWindowChanged(); 00209 void projectChanged(); 00210 void editorChanged(); 00211 00212 protected: 00213 bool eventFilter( QObject *o, QEvent *e ); 00214 void closeEvent( QCloseEvent *e ); 00215 00216 public slots: 00217 void fileNew(); 00218 void fileNewDialog(); 00219 void fileNewFile(); 00220 void fileClose(); 00221 void fileQuit(); 00222 void fileCloseProject(); // not visible in menu, called from fileClose 00223 void fileOpen(); 00224 void fileOpen( const QString &filter, const QString &extension, const QString &filename = "" , bool inProject = TRUE ); 00225 bool fileSave(); 00226 bool fileSaveForm(); // not visible in menu, called from fileSave 00227 bool fileSaveProject(); // not visible in menu, called from fileSaveProject 00228 bool fileSaveAs(); 00229 void fileSaveAll(); 00230 void fileCreateTemplate(); 00231 00232 public slots: 00233 void editUndo(); 00234 void editRedo(); 00235 void editCut(); 00236 void editCopy(); 00237 void editPaste(); 00238 void editDelete(); 00239 void editSelectAll(); 00240 void editLower(); 00241 void editRaise(); 00242 void editAdjustSize(); 00243 void editLayoutHorizontal(); 00244 void editLayoutVertical(); 00245 void editLayoutHorizontalSplit(); 00246 void editLayoutVerticalSplit(); 00247 void editLayoutGrid(); 00248 void editLayoutContainerHorizontal(); 00249 void editLayoutContainerVertical(); 00250 void editLayoutContainerGrid(); 00251 void editBreakLayout(); 00252 void editAccels(); 00253 void editFunctions(); 00254 void editConnections(); 00255 SourceEditor *editSource(); 00256 SourceEditor *editSource( SourceFile *f ); 00257 SourceEditor *openSourceEditor(); 00258 SourceEditor *createSourceEditor( QObject *object, Project *project, 00259 const QString &lang = QString::null, 00260 const QString &func = QString::null, 00261 bool rereadSource = FALSE ); 00262 void editFormSettings(); 00263 void editProjectSettings(); 00264 void editPixmapCollection(); 00265 void editDatabaseConnections(); 00266 void editPreferences(); 00267 00268 void projectInsertFile(); 00269 00270 void searchFind(); 00271 void searchIncremetalFindMenu(); 00272 void searchIncremetalFind(); 00273 void searchIncremetalFindNext(); 00274 void searchReplace(); 00275 void searchGotoLine(); 00276 00277 void previewForm(); 00278 void previewForm( const QString& ); 00279 00280 void toolsCustomWidget(); 00281 void toolsConfigure(); 00282 00283 void helpContents(); 00284 void helpManual(); 00285 void helpAbout(); 00286 void helpAboutQt(); 00287 void helpRegister(); 00288 00289 private slots: 00290 void activeWindowChanged( QWidget *w ); 00291 void updateUndoRedo( bool, bool, const QString &, const QString & ); 00292 void updateEditorUndoRedo(); 00293 00294 void toolSelected( QAction* ); 00295 00296 void clipboardChanged(); 00297 void selectionChanged(); 00298 00299 void windowsMenuActivated( int id ); 00300 void setupWindowActions(); 00301 00302 void createNewTemplate(); 00303 void projectSelected( QAction *a ); 00304 00305 void setupRecentlyFilesMenu(); 00306 void setupRecentlyProjectsMenu(); 00307 void recentlyFilesMenuActivated( int id ); 00308 void recentlyProjectsMenuActivated( int id ); 00309 00310 void emitProjectSignals(); 00311 00312 void showStartDialog(); 00313 00314 private: 00315 void setupMDI(); 00316 void setupMenuBar(); 00317 void setupEditActions(); 00318 void setupProjectActions(); 00319 void setupSearchActions(); 00320 void setupToolActions(); 00321 void setupLayoutActions(); 00322 void setupFileActions(); 00323 void setupPreviewActions(); 00324 void setupHelpActions(); 00325 void setupRMBMenus(); 00326 00327 void setupPropertyEditor(); 00328 void setupHierarchyView(); 00329 void setupWorkspace(); 00330 void setupActionEditor(); 00331 void setupOutputWindow(); 00332 void setupToolbox(); 00333 00334 void setupActionManager(); 00335 void setupPluginManagers(); 00336 00337 void enableAll( bool enable ); 00338 00339 QWidget* previewFormInternal( QStyle* style = 0, QPalette* pal = 0 ); 00340 00341 void readConfig(); 00342 00343 void setupRMBProperties( QValueList<uint> &ids, QMap<QString, int> &props, QWidget *w ); 00344 void handleRMBProperties( int id, QMap<QString, int> &props, QWidget *w ); 00345 void setupRMBSpecialCommands( QValueList<uint> &ids, QMap<QString, int> &commands, QWidget *w ); 00346 void handleRMBSpecialCommands( int id, QMap<QString, int> &commands, QWidget *w ); 00347 void setupRMBSpecialCommands( QValueList<uint> &ids, QMap<QString, int> &commands, FormWindow *w ); 00348 void handleRMBSpecialCommands( int id, QMap<QString, int> &commands, FormWindow *w ); 00349 bool openEditor( QWidget *w, FormWindow *fw ); 00350 void rebuildCustomWidgetGUI(); 00351 void rebuildCommonWidgetsToolBoxPage(); 00352 void checkTempFiles(); 00353 00354 void addRecentlyOpened( const QString &fn, QStringList &lst ); 00355 00356 QString whatsThisFrom( const QString &key ); 00357 00358 private slots: 00359 void doFunctionsChanged(); 00360 bool openProjectSettings( Project *pro ); 00361 00362 private: 00363 struct Tab 00364 { 00365 QWidget *w; 00366 QString title; 00367 QObject *receiver; 00368 const char *init_slot, *accept_slot; 00369 Q_DUMMY_COMPARISON_OPERATOR( Tab ) 00370 }; 00371 00372 private: 00373 PropertyEditor *propertyEditor; 00374 HierarchyView *hierarchyView; 00375 Workspace *wspace; 00376 QWidget *lastPressWidget; 00377 QWorkspace *qworkspace; 00378 QMenuBar *menubar; 00379 QGuardedPtr<FormWindow> lastActiveFormWindow; 00380 bool breakLayout, layoutChilds, layoutSelected; 00381 QPoint grd; 00382 bool sGrid, snGrid; 00383 bool restoreConfig; 00384 bool backPix; 00385 bool splashScreen; 00386 QString fileFilter; 00387 00388 QMap<QAction*, Project*> projects; 00389 QAction *actionEditUndo, *actionEditRedo, *actionEditCut, *actionEditCopy, 00390 *actionEditPaste, *actionEditDelete, 00391 *actionEditAdjustSize, 00392 *actionEditHLayout, *actionEditVLayout, *actionEditGridLayout, 00393 *actionEditSplitHorizontal, *actionEditSplitVertical, 00394 *actionEditSelectAll, *actionEditBreakLayout, *actionEditFunctions, *actionEditConnections, 00395 *actionEditLower, *actionEditRaise, *actionInsertSpacer; 00396 QActionGroup *actionGroupTools, *actionGroupProjects; 00397 QAction* actionPointerTool, *actionConnectTool, *actionOrderTool, *actionBuddyTool; 00398 QAction* actionCurrentTool; 00399 QAction *actionHelpContents, *actionHelpAbout, *actionHelpAboutQt, *actionHelpWhatsThis; 00400 QAction *actionHelpManual; 00401 #if defined(QT_NON_COMMERCIAL) 00402 QAction *actionHelpRegister; 00403 #endif 00404 QAction *actionToolsCustomWidget, *actionEditPreferences; 00405 QAction *actionWindowTile, *actionWindowCascade, *actionWindowClose, *actionWindowCloseAll; 00406 QAction *actionWindowNext, *actionWindowPrevious; 00407 QAction *actionEditFormSettings, *actionEditAccels; 00408 QAction *actionEditSource, *actionNewFile, *actionFileSave, *actionFileExit; 00409 QAction *actionSearchFind, *actionSearchIncremetal, *actionSearchReplace, *actionSearchGotoLine; 00410 QActionGroup *actionGroupNew; 00411 00412 QPopupMenu *rmbWidgets; 00413 QPopupMenu *rmbFormWindow; 00414 QPopupMenu *customWidgetMenu, *windowMenu, *fileMenu, *recentlyFilesMenu, *recentlyProjectsMenu; 00415 QPopupMenu *toolsMenu, *layoutMenu, *previewMenu; 00416 QToolBar *customWidgetToolBar, *layoutToolBar, *projectToolBar, *customWidgetToolBar2, *toolsToolBar; 00417 QToolBar *commonWidgetsToolBar; 00418 QPtrList<QToolBar> widgetToolBars; 00419 00420 Preferences *prefDia; 00421 QMap<QString,QString> propertyDocumentation; 00422 bool client; 00423 QString templPath; 00424 ActionEditor *actionEditor; 00425 Project *currentProject; 00426 QPluginManager<ActionInterface> *actionPluginManager; 00427 QPluginManager<EditorInterface> *editorPluginManager; 00428 QPluginManager<TemplateWizardInterface> *templateWizardPluginManager; 00429 QPluginManager<InterpreterInterface> *interpreterPluginManager; 00430 QPluginManager<PreferenceInterface> *preferencePluginManager; 00431 QPluginManager<ProjectSettingsInterface> *projectSettingsPluginManager; 00432 QPluginManager<SourceTemplateInterface> *sourceTemplatePluginManager; 00433 QPtrList<SourceEditor> sourceEditors; 00434 bool previewing; 00435 QUnknownInterface *desInterface; 00436 QStringList recentlyFiles; 00437 QStringList recentlyProjects; 00438 OutputWindow *oWindow; 00439 QValueList<Tab> preferenceTabs; 00440 QValueList<Tab> projectTabs; 00441 bool databaseAutoEdit; 00442 QTimer *updateFunctionsTimer; 00443 QTimer *autoSaveTimer; 00444 bool autoSaveEnabled; 00445 int autoSaveInterval; 00446 QLineEdit *incrementalSearch; 00447 QGuardedPtr<FindDialog> findDialog; 00448 QGuardedPtr<ReplaceDialog> replaceDialog; 00449 QGuardedPtr<GotoLineDialog> gotoLineDialog; 00450 Project *eProject; 00451 bool inDebugMode; 00452 QObjectList debuggingForms; 00453 QString lastOpenFilter; 00454 QGuardedPtr<QWidget> previewedForm; 00455 QPopupMenu *projectMenu; 00456 QString menuHelpFile; 00457 bool singleProject; 00458 QToolBox *toolBox; 00459 int toolsMenuId, toolsMenuIndex; 00460 uint guiStuffVisible : 1; 00461 uint editorsReadOnly : 1; 00462 uint savePluginPaths : 1; 00463 QAssistantClient *assistant; 00464 bool shStartDialog; 00465 QString pluginDir; 00466 bool sSignalHandlers; 00467 00468 public: 00469 QString lastSaveFilter; 00470 QPtrList<QAction> toolActions; 00471 QPtrList<QAction> commonWidgetsPage; 00472 00473 }; 00474 00475 class SenderObject : public QObject 00476 { 00477 Q_OBJECT 00478 00479 public: 00480 SenderObject( QUnknownInterface *i ) : iface( i ) { iface->addRef(); } 00481 ~SenderObject() { iface->release(); } 00482 00483 public slots: 00484 void emitInitSignal() { emit initSignal( iface ); } 00485 void emitAcceptSignal() { emit acceptSignal( iface ); } 00486 00487 signals: 00488 void initSignal( QUnknownInterface * ); 00489 void acceptSignal( QUnknownInterface * ); 00490 00491 private: 00492 QUnknownInterface *iface; 00493 00494 }; 00495 00496 #endif