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 WORKSPACE_H 00028 #define WORKSPACE_H 00029 00030 #include <qlistview.h> 00031 00032 class FormWindow; 00033 class QResizeEvent; 00034 class QCloseEvent; 00035 class QDropEvent; 00036 class QDragMoveEvent; 00037 class QDragEnterEvent; 00038 class MainWindow; 00039 class Project; 00040 class SourceFile; 00041 class FormFile; 00042 class QCompletionEdit; 00043 class SourceEditor; 00044 00045 class WorkspaceItem : public QListViewItem 00046 { 00047 public: 00048 enum Type { ProjectType, FormFileType, FormSourceType, SourceFileType, ObjectType }; 00049 00050 WorkspaceItem( QListView *parent, Project* p ); 00051 WorkspaceItem( QListViewItem *parent, SourceFile* sf ); 00052 WorkspaceItem( QListViewItem *parent, FormFile* ff, Type t = FormFileType ); 00053 WorkspaceItem( QListViewItem *parent, QObject *o, Project *p ); 00054 00055 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ); 00056 00057 Type type() const { return t; } 00058 00059 bool isModified() const; 00060 00061 QString text( int ) const; 00062 00063 void fillCompletionList( QStringList& completion ); 00064 bool checkCompletion( const QString& completion ); 00065 00066 QString key( int, bool ) const; // column sorting key 00067 00068 Project* project; 00069 SourceFile* sourceFile; 00070 FormFile* formFile; 00071 QObject *object; 00072 00073 void setOpen( bool ); 00074 00075 void setAutoOpen( bool ); 00076 bool isAutoOpen() const { return isOpen() && autoOpen; } 00077 00078 bool useOddColor; 00079 00080 private: 00081 void init(); 00082 bool autoOpen; 00083 QColor backgroundColor(); 00084 Type t; 00085 }; 00086 00087 class Workspace : public QListView 00088 { 00089 Q_OBJECT 00090 00091 public: 00092 Workspace( QWidget *parent , MainWindow *mw ); 00093 00094 void setCurrentProject( Project *pro ); 00095 00096 void contentsDropEvent( QDropEvent *e ); 00097 void contentsDragEnterEvent( QDragEnterEvent *e ); 00098 void contentsDragMoveEvent( QDragMoveEvent *e ); 00099 00100 void setBufferEdit( QCompletionEdit *edit ); 00101 00102 public slots: 00103 00104 void update(); 00105 void update( FormFile* ); 00106 00107 void activeFormChanged( FormWindow *fw ); 00108 void activeEditorChanged( SourceEditor *se ); 00109 00110 protected: 00111 void closeEvent( QCloseEvent *e ); 00112 bool eventFilter( QObject *, QEvent * ); 00113 00114 00115 private slots: 00116 void itemClicked( int, QListViewItem *i, const QPoint& pos ); 00117 void itemDoubleClicked( QListViewItem *i ); 00118 void rmbClicked( QListViewItem *i, const QPoint& pos ); 00119 void bufferChosen( const QString &buffer ); 00120 00121 void projectDestroyed( QObject* ); 00122 00123 void sourceFileAdded( SourceFile* ); 00124 void sourceFileRemoved( SourceFile* ); 00125 00126 void formFileAdded( FormFile* ); 00127 void formFileRemoved( FormFile* ); 00128 00129 void objectAdded( QObject* ); 00130 void objectRemoved( QObject * ); 00131 00132 private: 00133 WorkspaceItem *findItem( FormFile *ff ); 00134 WorkspaceItem *findItem( SourceFile *sf ); 00135 WorkspaceItem *findItem( QObject *o ); 00136 00137 void closeAutoOpenItems(); 00138 00139 private: 00140 MainWindow *mainWindow; 00141 Project *project; 00142 WorkspaceItem *projectItem; 00143 QCompletionEdit *bufferEdit; 00144 bool blockNewForms; 00145 void updateBufferEdit(); 00146 bool completionDirty; 00147 void updateColors(); 00148 00149 }; 00150 00151 #endif