Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 FLDataTable.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 FLDATATABLE_H 00020 #define FLDATATABLE_H 00021 00022 #include <qdatatable.h> 00023 #include <qpainter.h> 00024 #include <qpixmapcache.h> 00025 #include <qdatetime.h> 00026 #include <qcolor.h> 00027 #include <qcheckbox.h> 00028 00029 class FLSqlCursor; 00030 00037 class FLDataTable: public QDataTable 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 00046 FLDataTable(QWidget *parent = 0, const char *name = 0, bool popup = false); 00047 00051 ~FLDataTable(); 00052 00056 void setFLSqlCursor(FLSqlCursor *c); 00057 00062 void setPersistentFilter(const QString &pFilter); 00063 00067 FLSqlCursor *cursor() const { 00068 return cursor_; 00069 } 00070 00074 void setFLReadOnly(const bool mode); 00075 00079 void setEditOnly(const bool mode); 00080 00084 void setInsertOnly(const bool mode); 00085 00089 const QValueList<QVariant> primarysKeysChecked() const; 00090 00094 void clearChecked(); 00095 00099 void setPrimaryKeyChecked(const QVariant &primaryKeyValue, bool on); 00100 00104 void setShowAllPixmaps(bool s) { 00105 showAllPixmaps_ = s; 00106 } 00107 00111 void setFunctionGetColor(const QString &f) { 00112 functionGetColor_ = f; 00113 } 00114 00118 int indexOf(uint i) const; 00119 00120 protected: 00121 00125 bool eventFilter(QObject *o, QEvent *e); 00126 00130 void paintCell(QPainter *p, int row, int col, const QRect &cr, 00131 bool selected, const QColorGroup &cg); 00132 00136 void paintField(QPainter *p, const QSqlField *field, const QRect &cr, bool selected); 00137 00142 void contentsContextMenuEvent(QContextMenuEvent *e); 00143 00148 void contentsMouseDoubleClickEvent(QMouseEvent *e); 00149 00153 void focusOutEvent(QFocusEvent *); 00154 00158 void handleError(const QSqlError &); 00159 00160 private: 00161 00165 int rowSelected; 00166 00170 int colSelected; 00171 00175 FLSqlCursor *cursor_; 00176 00180 bool readonly_; 00181 00185 bool editonly_; 00186 00190 bool insertonly_; 00191 00195 QString lastTextPainted; 00196 00200 QBrush bu_; 00201 00205 QPixmap ok; 00206 QPixmap no; 00207 00211 QValueList<QVariant> primarysKeysChecked_; 00212 00216 QString persistentFilter_; 00217 00221 bool refreshing_; 00222 00226 bool popup_; 00227 00231 QMap<QString, int> widthCols_; 00232 00236 bool showAllPixmaps_; 00237 00241 QString functionGetColor_; 00242 00243 public slots: 00244 00251 void selectRow(int r = -1, int c = -1); 00252 00256 void setFocus(); 00257 00261 void refresh(); 00262 00266 void ensureRowSelectedVisible(); 00267 00271 void setQuickFocus(); 00272 00279 void setColumnWidth(const QString &field, int w); 00280 00281 protected slots: 00282 00286 void setChecked(bool on); 00287 00288 signals: 00289 00293 void recordChoosed(); 00294 00304 void primaryKeyToggled(const QVariant &primaryKeyValue, bool on); 00305 }; 00306 00307 // Uso interno 00308 class FLCheckBox: public QCheckBox 00309 { 00310 public: 00311 00312 FLCheckBox(QWidget *parent, int row = 0, const char *name = 0) : QCheckBox(parent, name), row_(row) {} 00313 00314 int row() const { 00315 return row_; 00316 } 00317 00318 protected: 00319 00320 void drawButton(QPainter *p); 00321 bool hitButton(const QPoint &pos) const; 00322 00323 private: 00324 00325 int row_; 00326 }; 00327 00328 #endif