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 HIRARCHYVIEW_H 00028 #define HIRARCHYVIEW_H 00029 00030 #include <qvariant.h> 00031 #include <qlistview.h> 00032 #include <qtabwidget.h> 00033 #include <qguardedptr.h> 00034 #include <private/qcom_p.h> 00035 #include "../interfaces/classbrowserinterface.h" 00036 00037 class FormWindow; 00038 class QCloseEvent; 00039 class QPopupMenu; 00040 class QKeyEvent; 00041 class QMouseEvent; 00042 class QWizard; 00043 class SourceEditor; 00044 00045 class HierarchyItem : public QListViewItem 00046 { 00047 public: 00048 enum Type { 00049 Widget, 00050 SlotParent, 00051 SlotPublic, 00052 SlotProtected, 00053 SlotPrivate, 00054 Slot, 00055 DefinitionParent, 00056 Definition, 00057 Event, 00058 EventFunction, 00059 FunctParent, 00060 FunctPublic, 00061 FunctProtected, 00062 FunctPrivate, 00063 Function, 00064 VarParent, 00065 VarPublic, 00066 VarProtected, 00067 VarPrivate, 00068 Variable 00069 }; 00070 00071 HierarchyItem( Type type, QListViewItem *parent, QListViewItem *after, 00072 const QString &txt1, const QString &txt2, const QString &txt3 ); 00073 HierarchyItem( Type type, QListView *parent, QListViewItem *after, 00074 const QString &txt1, const QString &txt2, const QString &txt3 ); 00075 00076 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align ); 00077 void updateBackColor(); 00078 00079 void setObject( QObject *o ); 00080 QObject *object() const; 00081 00082 void setText( int col, const QString &txt ) { if ( !txt.isEmpty() ) QListViewItem::setText( col, txt ); } 00083 00084 int rtti() const { return (int)typ; } 00085 00086 private: 00087 void okRename( int col ); 00088 void cancelRename( int col ); 00089 00090 private: 00091 QColor backgroundColor(); 00092 QColor backColor; 00093 QObject *obj; 00094 Type typ; 00095 00096 }; 00097 00098 class HierarchyList : public QListView 00099 { 00100 Q_OBJECT 00101 00102 public: 00103 HierarchyList( QWidget *parent, FormWindow *fw, bool doConnects = TRUE ); 00104 00105 virtual void setup(); 00106 virtual void setCurrent( QObject *o ); 00107 void setOpen( QListViewItem *i, bool b ); 00108 void changeNameOf( QObject *o, const QString &name ); 00109 void changeDatabaseOf( QObject *o, const QString &info ); 00110 void setFormWindow( FormWindow *fw ) { formWindow = fw; } 00111 void drawContentsOffset( QPainter *p, int ox, int oy, 00112 int cx, int cy, int cw, int ch ) { 00113 setUpdatesEnabled( FALSE ); 00114 triggerUpdate(); 00115 setUpdatesEnabled( TRUE ); 00116 QListView::drawContentsOffset( p, ox, oy, cx, cy, cw, ch ); 00117 } 00118 00119 void insertEntry( QListViewItem *i, const QPixmap &pix = QPixmap(), const QString &s = QString::null ); 00120 00121 protected: 00122 void keyPressEvent( QKeyEvent *e ); 00123 void keyReleaseEvent( QKeyEvent *e ); 00124 void viewportMousePressEvent( QMouseEvent *e ); 00125 void viewportMouseReleaseEvent( QMouseEvent *e ); 00126 00127 public slots: 00128 void addTabPage(); 00129 void removeTabPage(); 00130 00131 private: 00132 void insertObject( QObject *o, QListViewItem *parent ); 00133 QObject *findObject( QListViewItem *i ); 00134 QListViewItem *findItem( QObject *o ); 00135 QObject *current() const; 00136 QObject *handleObjectClick( QListViewItem *i ); 00137 00138 private slots: 00139 virtual void objectClicked( QListViewItem *i ); 00140 virtual void objectDoubleClicked( QListViewItem *i ); 00141 virtual void showRMBMenu( QListViewItem *, const QPoint & ); 00142 00143 protected: 00144 FormWindow *formWindow; 00145 QPopupMenu *normalMenu, *tabWidgetMenu; 00146 bool deselect; 00147 00148 }; 00149 00150 class FormDefinitionView : public HierarchyList 00151 { 00152 Q_OBJECT 00153 00154 public: 00155 FormDefinitionView( QWidget *parent, FormWindow *fw ); 00156 00157 void setup(); 00158 void setupVariables(); 00159 void refresh(); 00160 void setCurrent( QWidget *w ); 00161 00162 protected: 00163 void contentsMouseDoubleClickEvent( QMouseEvent *e ); 00164 00165 private: 00166 void save( QListViewItem *p, QListViewItem *i ); 00167 void execFunctionDialog( const QString &access, const QString &type, bool addFunc ); 00168 void addVariable( const QString &varName, const QString &access ); 00169 00170 private slots: 00171 void objectClicked( QListViewItem *i ); 00172 void showRMBMenu( QListViewItem *, const QPoint & ); 00173 void renamed( QListViewItem *i ); 00174 00175 private: 00176 bool popupOpen; 00177 HierarchyItem *itemSlots, *itemPrivate, *itemProtected, *itemPublic; 00178 HierarchyItem *itemFunct, *itemFunctPriv, *itemFunctProt, *itemFunctPubl; 00179 HierarchyItem *itemVar, *itemVarPriv, *itemVarProt, *itemVarPubl; 00180 }; 00181 00182 00183 class HierarchyView : public QTabWidget 00184 { 00185 Q_OBJECT 00186 00187 public: 00188 HierarchyView( QWidget *parent ); 00189 ~HierarchyView(); 00190 00191 void setFormWindow( FormWindow *fw, QObject *o ); 00192 FormWindow *formWindow() const; 00193 SourceEditor *sourceEditor() const { return editor; } 00194 void clear(); 00195 00196 void showClasses( SourceEditor *se ); 00197 void updateClassBrowsers(); 00198 00199 void widgetInserted( QWidget *w ); 00200 void widgetRemoved( QWidget *w ); 00201 void widgetsInserted( const QWidgetList &l ); 00202 void widgetsRemoved( const QWidgetList &l ); 00203 void namePropertyChanged( QWidget *w, const QVariant &old ); 00204 void databasePropertyChanged( QWidget *w, const QStringList& info ); 00205 void tabsChanged( QTabWidget *w ); 00206 void pagesChanged( QWizard *w ); 00207 void rebuild(); 00208 void closed( FormWindow *fw ); 00209 void updateFormDefinitionView(); 00210 00211 FormDefinitionView *formDefinitionView() const { return fView; } 00212 HierarchyList *hierarchyList() const { return listview; } 00213 00214 protected slots: 00215 void jumpTo( const QString &func, const QString &clss,int type ); 00216 void showClassesTimeout(); 00217 00218 protected: 00219 void closeEvent( QCloseEvent *e ); 00220 00221 signals: 00222 void hidden(); 00223 00224 private: 00225 struct ClassBrowser 00226 { 00227 ClassBrowser( QListView * = 0, ClassBrowserInterface * = 0 ); 00228 ~ClassBrowser(); 00229 QListView *lv; 00230 QInterfacePtr<ClassBrowserInterface> iface; 00231 00232 Q_DUMMY_COMPARISON_OPERATOR( ClassBrowser ) 00233 }; 00234 FormWindow *formwindow; 00235 HierarchyList *listview; 00236 FormDefinitionView *fView; 00237 SourceEditor *editor; 00238 QMap<QString, ClassBrowser> *classBrowsers; 00239 QGuardedPtr<SourceEditor> lastSourceEditor; 00240 00241 }; 00242 00243 00244 #endif