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 CONNECTIONITEMS_H 00028 #define CONNECTIONITEMS_H 00029 00030 class FormWindow; 00031 00032 #include <qtable.h> 00033 00034 class SenderItem; 00035 class ReceiverItem; 00036 class SignalItem; 00037 class SlotItem; 00038 class ConnectionContainer; 00039 00040 00041 class ConnectionItem : public QObject, 00042 public QComboTableItem 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 ConnectionItem( QTable *table, FormWindow *fw ); 00048 00049 void paint( QPainter *p, const QColorGroup &cg, 00050 const QRect &cr, bool selected ); 00051 00052 void setSender( SenderItem *i ); 00053 void setReceiver( ReceiverItem *i ); 00054 void setSignal( SignalItem *i ); 00055 void setSlot( SlotItem *i ); 00056 void setConnection( ConnectionContainer *c ); 00057 00058 public slots: 00059 virtual void senderChanged( QObject *sender ); 00060 virtual void receiverChanged( QObject *receiver ); 00061 virtual void signalChanged( const QString &sig ); 00062 virtual void slotChanged( const QString &slot ); 00063 00064 signals: 00065 void changed(); 00066 00067 protected: 00068 FormWindow *formWindow; 00069 00070 private: 00071 ConnectionContainer *conn; 00072 00073 }; 00074 00075 // ------------------------------------------------------------------ 00076 00077 class SenderItem : public ConnectionItem 00078 { 00079 Q_OBJECT 00080 00081 public: 00082 SenderItem( QTable *table, FormWindow *fw ); 00083 QWidget *createEditor() const; 00084 void setSenderEx( QObject *sender ); 00085 00086 signals: 00087 void currentSenderChanged( QObject *sender ); 00088 00089 private slots: 00090 void senderChanged( const QString &sender ); 00091 00092 }; 00093 00094 // ------------------------------------------------------------------ 00095 00096 class ReceiverItem : public ConnectionItem 00097 { 00098 Q_OBJECT 00099 00100 public: 00101 ReceiverItem( QTable *table, FormWindow *fw ); 00102 QWidget *createEditor() const; 00103 void setReceiverEx( QObject *receiver ); 00104 00105 signals: 00106 void currentReceiverChanged( QObject *receiver ); 00107 00108 private slots: 00109 void receiverChanged( const QString &receiver ); 00110 00111 }; 00112 00113 // ------------------------------------------------------------------ 00114 00115 class SignalItem : public ConnectionItem 00116 { 00117 Q_OBJECT 00118 00119 public: 00120 SignalItem( QTable *table, FormWindow *fw ); 00121 00122 void senderChanged( QObject *sender ); 00123 QWidget *createEditor() const; 00124 00125 signals: 00126 void currentSignalChanged( const QString & ); 00127 00128 }; 00129 00130 // ------------------------------------------------------------------ 00131 00132 class SlotItem : public ConnectionItem 00133 { 00134 Q_OBJECT 00135 00136 public: 00137 SlotItem( QTable *table, FormWindow *fw ); 00138 00139 void receiverChanged( QObject *receiver ); 00140 void signalChanged( const QString &signal ); 00141 QWidget *createEditor() const; 00142 00143 void customSlotsChanged(); 00144 00145 signals: 00146 void currentSlotChanged( const QString & ); 00147 00148 private: 00149 void updateSlotList(); 00150 bool ignoreSlot( const char* slot ) const; 00151 00152 private: 00153 QObject *lastReceiver; 00154 QString lastSignal; 00155 00156 }; 00157 00158 // ------------------------------------------------------------------ 00159 00160 class ConnectionContainer : public QObject 00161 { 00162 Q_OBJECT 00163 00164 public: 00165 ConnectionContainer( QObject *parent, SenderItem *i1, SignalItem *i2, 00166 ReceiverItem *i3, SlotItem *i4, int r ) 00167 : QObject( parent ), mod( FALSE ), se( i1 ), si( i2 ), 00168 re( i3 ), sl( i4 ), rw ( r ) { 00169 i1->setConnection( this ); 00170 i2->setConnection( this ); 00171 i3->setConnection( this ); 00172 i4->setConnection( this ); 00173 connect( i1, SIGNAL( changed() ), this, SLOT( somethingChanged() ) ); 00174 connect( i2, SIGNAL( changed() ), this, SLOT( somethingChanged() ) ); 00175 connect( i3, SIGNAL( changed() ), this, SLOT( somethingChanged() ) ); 00176 connect( i4, SIGNAL( changed() ), this, SLOT( somethingChanged() ) ); 00177 } 00178 00179 bool isModified() const { return mod; } 00180 void setModified( bool b ) { mod = b; repaint(); } 00181 bool isValid() const { 00182 return se->currentText()[0] != '<' && 00183 si->currentText()[0] != '<' && 00184 re->currentText()[0] != '<' && 00185 sl->currentText()[0] != '<'; 00186 } 00187 00188 void repaint() { 00189 se->table()->updateCell( se->row(), se->col() ); 00190 si->table()->updateCell( si->row(), si->col() ); 00191 re->table()->updateCell( re->row(), re->col() ); 00192 sl->table()->updateCell( sl->row(), sl->col() ); 00193 } 00194 00195 int row() const { return rw; } 00196 void setRow( int r ) { rw = r; } 00197 00198 SenderItem *senderItem() const { return se; } 00199 SignalItem *signalItem() const { return si; } 00200 ReceiverItem *receiverItem() const { return re; } 00201 SlotItem *slotItem() const { return sl; } 00202 00203 public slots: 00204 void somethingChanged() { mod = TRUE; emit changed( this ); } 00205 00206 signals: 00207 void changed( ConnectionContainer *c ); 00208 00209 private: 00210 bool mod; 00211 SenderItem *se; 00212 SignalItem *si; 00213 ReceiverItem *re; 00214 SlotItem *sl; 00215 int rw; 00216 00217 }; 00218 00219 00220 #endif