Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 FLTableDB.h 00003 ------------------- 00004 begin : Sun Jul 1 2001 00005 copyright : (C) 2001-2005 by InfoSiAL S.L. 00006 email : mail@infosial.com 00007 ***************************************************************************/ 00008 /*************************************************************************** 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; version 2 of the License. * 00012 ***************************************************************************/ 00013 /*************************************************************************** 00014 Este programa es software libre. Puede redistribuirlo y/o modificarlo 00015 bajo los términos de la Licencia Pública General de GNU en su 00016 versión 2, publicada por la Free Software Foundation. 00017 ***************************************************************************/ 00018 00019 #ifndef FLTABLEDB_H 00020 #define FLTABLEDB_H 00021 00022 #include <qlayout.h> 00023 #include <qcombobox.h> 00024 #include <qlineedit.h> 00025 #include <qtimer.h> 00026 #include <qvalidator.h> 00027 #include <qstringlist.h> 00028 #include <qwidgetstack.h> 00029 #include <qbuttongroup.h> 00030 #include <qprogressdialog.h> 00031 #include "FLWidgetTableDB.h" 00032 00033 class FLSqlCursor; 00034 class FLDataTable; 00035 class FLFieldMetaData; 00036 class FLTableDBInterface; 00037 00050 class FL_EXPORT FLTableDB: public FLWidgetTableDB { 00051 00052 Q_OBJECT 00053 00054 Q_PROPERTY( QString tableName READ tableName WRITE setTableName ) 00055 Q_PROPERTY( QString foreignField READ foreignField WRITE setForeignField ) 00056 Q_PROPERTY( QString fieldRelation READ fieldRelation WRITE setFieldRelation ) 00057 Q_PROPERTY( bool checkColumnEnabled READ checkColumnEnabled WRITE setCheckColumnEnabled ) 00058 Q_PROPERTY( QString aliasCheckColumn READ aliasCheckColumn WRITE setAliasCheckColumn ) 00059 Q_PROPERTY( bool findHidden READ findHidden WRITE setFindHidden ) 00060 Q_PROPERTY( bool filterHidden READ filterHidden WRITE setFilterHidden ) 00061 Q_PROPERTY( bool showAllPixmaps READ showAllPixmaps WRITE setShowAllPixmaps ) 00062 Q_PROPERTY( QString functionGetColor READ functionGetColor WRITE setFunctionGetColor ) 00063 00064 friend class FLTableDBInterface; 00065 friend class FLFormDB; 00066 00067 public: 00068 00072 FLTableDB( QWidget * parent = 0, const char *name = 0 ); 00073 00077 FLDataTable * tableRecords(); 00078 00084 FLSqlCursor *cursor(); 00085 00091 QString tableName() const; 00092 00098 void setTableName( const QString & fT ); 00099 00105 QString foreignField() const; 00106 00112 void setForeignField( const QString & fN ); 00113 00119 QString fieldRelation() const; 00120 00126 void setFieldRelation( const QString & fN ); 00127 00131 void setReadOnly( const bool mode ); 00132 00136 void setEditOnly( const bool mode ); 00137 00141 void setInsertOnly( const bool mode ); 00142 00146 void setInitSearch( const QString & iS ) { 00147 initSearch_ = iS; 00148 } 00149 00155 void setOrderCols( QStringList & fields ); 00156 00160 QStringList orderCols(); 00161 00167 void setFilter( const QString &f ); 00168 00174 QString filter(); 00175 00181 QString findFilter(); 00182 00186 bool checkColumnEnabled() const; 00187 00193 void setCheckColumnEnabled( bool b ); 00194 00198 QString aliasCheckColumn() const; 00199 00205 void setAliasCheckColumn( const QString & t ); 00206 00210 bool findHidden() const; 00211 00217 void setFindHidden( bool h ); 00218 00222 bool filterHidden() const; 00223 00229 void setFilterHidden( bool h ); 00230 00234 bool showAllPixmaps() const; 00235 00239 void setShowAllPixmaps( bool s ); 00240 00244 QString functionGetColor() const; 00245 00249 void setFunctionGetColor( const QString & f ); 00250 00251 protected: 00252 00256 bool eventFilter( QObject * obj, QEvent * ev ); 00257 00261 void showEvent( QShowEvent * e ); 00262 00263 private: 00264 00268 enum CondType { 00269 All, 00270 Contains, 00271 Starts, 00272 End, 00273 Equal, 00274 Dist, 00275 Greater, 00276 Less, 00277 FromTo, 00278 Null, 00279 NotNull 00280 }; 00281 00285 void showWidget(); 00286 00290 void setTableRecordsCursor(); 00291 00295 void refreshTabData(); 00296 00300 void refreshTabFilter(); 00301 00306 FLTableDB::CondType decodeCondType( const QString & strCondType ) const; 00307 00312 QString tdbFilterBuildWhere(); 00313 00322 void initFakeEditor(); 00323 00327 FLDataTable * tableRecords_; 00328 00332 QString tableName_; 00333 00337 QString foreignField_; 00338 00342 QString fieldRelation_; 00343 00347 FLSqlCursor *cursor_; 00348 00353 FLSqlCursor *cursorAux; 00354 00358 QWidget *topWidget; 00359 00363 bool showed; 00364 00368 QString filter_; 00369 00373 bool readonly_; 00374 bool reqReadOnly_; 00375 00379 bool editonly_; 00380 bool reqEditOnly_; 00381 00385 bool insertonly_; 00386 bool reqInsertOnly_; 00387 00391 FLFieldMetaData *sortField_; 00392 00396 QTimer *timer; 00397 00401 QString initSearch_; 00402 00406 bool checkColumnEnabled_; 00407 00411 QString aliasCheckColumn_; 00412 00416 QString fieldNameCheckColumn_; 00417 00421 bool checkColumnVisible_; 00422 00426 int sortColumn_; 00427 00431 bool orderAsc_; 00432 00436 QString tdbFilterLastWhere_; 00437 00442 QMap<QString, FLTableDB::CondType> mapCondType; 00443 00447 bool findHidden_; 00448 00452 bool filterHidden_; 00453 00457 bool showAllPixmaps_; 00458 00503 QString functionGetColor_; 00504 00508 QWidget * fakeEditor_; 00509 00510 public slots: 00511 00515 void refresh( const bool refreshHead = false, const bool refreshData = false ); 00516 00525 void refreshDelayed( int msec = 50, const bool refreshData = true ); 00526 00530 void insertRecord(); 00531 00535 void editRecord(); 00536 00540 void browseRecord(); 00541 00545 void deleteRecord(); 00546 00550 void copyRecord(); 00551 00566 void putFirstCol( const QString & c ); 00567 00574 void moveCol( const QString & from, const QString & to ); 00575 00580 void initCursor(); 00581 00585 void seekCursor(); 00586 00590 void setEnabled( bool ); 00591 00598 void setColumnWidth( const QString & field, int w ); 00599 00603 int columnWidth( int c ); 00604 00611 void setRowHeight( int row, int h ); 00612 00616 int rowHeight( int row ); 00617 00621 void exportToOds(); 00622 00623 protected slots: 00624 00637 void putFirstCol( int c ); 00638 00645 void moveCol( int from, int to ); 00646 00655 void filterRecords( const QString & p ); 00656 00661 void switchSortOrder( int ); 00662 00666 void activeTabData( bool ); 00667 00671 void activeTabFilter( bool ); 00672 00676 void tdbFilterClear(); 00677 00678 signals: 00679 00683 void readOnlyChanged( bool ); 00684 00688 void editOnlyChanged( bool ); 00689 00693 void insertOnlyChanged( bool ); 00694 00698 void currentChanged(); 00699 }; 00700 00701 #endif