Eneboo - Documentación para desarrolladores
src/flbase/FLFieldDB.h
Ir a la documentación de este archivo.
00001 /***************************************************************************
00002                               FLFieldDB.h
00003                           -------------------
00004  begin                : Wed Jul 4 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  trminos  de  la  Licencia  Pblica General de GNU   en  su
00016    versin 2, publicada  por  la  Free  Software Foundation.
00017  ***************************************************************************/
00018 
00019 #ifndef FLFIELDDB_H
00020 #define FLFIELDDB_H
00021 
00022 #include <qapplication.h>
00023 #include <qvariant.h>
00024 #include <qstring.h>
00025 #include <qwidget.h>
00026 #include <qlabel.h>
00027 #include <qpushbutton.h>
00028 #include <qspinbox.h>
00029 #include <qlineedit.h>
00030 #include <qfiledialog.h>
00031 #include <qpainter.h>
00032 #include <qvalidator.h>
00033 #include <qdatetime.h>
00034 #include <qdatetimeedit.h>
00035 #include <qtextedit.h>
00036 #include <qcheckbox.h>
00037 #include <qpixmapcache.h>
00038 #include <qtoolbutton.h>
00039 #include <qframe.h>
00040 #include <qcombobox.h>
00041 #include <qtooltip.h>
00042 #include <qwhatsthis.h>
00043 #include <qvbox.h>
00044 #include <qsqldatabase.h>
00045 #include <qaccel.h>
00046 #include <qsplitter.h>
00047 
00048 #include "FLWidgetFieldDB.h"
00049 
00050 class FLSqlCursor;
00051 class VDatePopup;
00052 class FLPixmapView;
00053 class FLFieldDBInterface;
00054 class FLDataTable;
00055 
00092 class FLFieldDB: public FLWidgetFieldDB
00093 {
00094   Q_OBJECT
00095 
00096   Q_PROPERTY(QString fieldName READ fieldName WRITE setFieldName)
00097   Q_PROPERTY(QString tableName READ tableName WRITE setTableName)
00098   Q_PROPERTY(QString foreignField READ foreignField WRITE setForeignField)
00099   Q_PROPERTY(QString fieldRelation READ fieldRelation WRITE setFieldRelation)
00100   Q_PROPERTY(QString fieldAlias READ fieldAlias WRITE setFieldAlias)
00101   Q_PROPERTY(QString actionName READ actionName WRITE setActionName)
00102   Q_PROPERTY(bool showAlias READ showAlias WRITE setShowAlias)
00103   Q_PROPERTY(bool showEditor READ showEditor WRITE setShowEditor)
00104   Q_PROPERTY(int textFormat READ textFormat WRITE setTextFormat)
00105 
00106   friend class FLFieldDBInterface;
00107   friend class FLFormDB;
00108   friend class FLFormRecordDB;
00109   friend class FLFormSearchDB;
00110 
00111 public:
00112 
00116   FLFieldDB(QWidget *parent = 0, const char *name = 0);
00117 
00123   QString actionName() const;
00124 
00130   void setActionName(const QString &aN);
00131 
00137   QString fieldName() const;
00138 
00143   void setFilter(const QString &f);
00144 
00149   QString filter() const;
00150 
00156   void setFieldName(const QString &fN);
00157 
00163   QString tableName() const;
00164 
00170   void setTableName(const QString &fT);
00171 
00177   QString foreignField() const;
00178 
00184   void setForeignField(const QString &fN);
00185 
00191   QString fieldRelation() const;
00192 
00196   QString fieldAlias() const;
00197 
00203   QWidget *editor() const {
00204     return editor_;
00205   }
00206 
00212   void setFieldRelation(const QString &fN);
00213 
00219   void setFieldAlias(const QString &alias);
00220 
00226   void setTextFormat(const int &f);
00227 
00231   int textFormat() const;
00232 
00238   void setValue(const QVariant &v);
00239 
00243   QVariant value();
00244 
00248   void selectAll();
00249 
00255   FLSqlCursor *cursor();
00256 
00262   bool showAlias() const;
00263 
00267   void setShowAlias(const bool value);
00268 
00275   int insertAccel(const QString &key);
00276 
00282   void removeAccel(int id);
00283 
00290   void setKeepDisabled(const bool keep);
00291 
00295   bool showEditor() const;
00296 
00300   void setShowEditor(const bool show);
00301 
00305   void setPartDecimal(int d);
00306 
00307 protected slots:
00308 
00319   void refresh(const QString &fN = QString::null);
00320 
00324   void refreshQuick(const QString &fN = QString::null);
00325 
00330   void initCursor();
00331 
00337   void initEditor();
00338 
00344   void updateValue(const QString &t);
00345 
00351   void updateValue(const QDate &d);
00352 
00358   void updateValue(const QTime &t);
00359 
00365   void updateValue(bool b);
00366 
00371   void updateValue();
00372 
00376   void toggleDatePicker();
00377 
00381   void clearPixmap();
00382 
00388   void savePixmap(int f);
00389 
00393   void toggleAutoCompletion();
00394 
00399   void autoCompletionUpdateValue();
00400 
00401 public slots:
00402 
00406   void openFormRecordRelation();
00407 
00411   void searchValue();
00412 
00418   void searchPixmap();
00419 
00424   void setPixmap(const QString &filename);
00425 
00429   void emitLostFocus();
00430 
00434   void setNoShowed();
00435 
00446   void setMapValue(const QString &v);
00447 
00454   void emitKeyF2Pressed();
00455 
00459   void emitLabelClicked();
00460 
00467   void emitTextChanged(const QString &t);
00468 
00472   void emitActivatedAccel(int id);
00473 
00474 protected:
00475 
00479   bool eventFilter(QObject *obj, QEvent *ev);
00480 
00484   void showEvent(QShowEvent *e);
00485 
00486 private:
00487 
00491   void showWidget();
00492 
00501   void initFakeEditor();
00502 
00506   void setMapValue();
00507 
00511   QWidget *editor_;
00512 
00516   QString fieldName_;
00517 
00521   QString tableName_;
00522 
00526   QString actionName_;
00527 
00531   QString foreignField_;
00532 
00536   QString fieldRelation_;
00537 
00541   QString filter_;
00542 
00546   FLSqlCursor *cursor_;
00547 
00552   FLSqlCursor *cursorAux;
00553 
00557   bool cursorInit;
00558 
00562   bool cursorAuxInit;
00563 
00567   QWidget *topWidget_;
00568 
00572   bool showed;
00573 
00577   FLSqlCursor *cursorBackup_;
00578 
00582   bool showAlias_;
00583 
00587   VDatePopup *datePopup_;
00588   QVBox *dateFrame_;
00589   bool datePickerOn_;
00590 
00594   QAccel *accel_;
00595 
00600   bool keepDisabled_;
00601 
00605   FLPixmapView *editorImg_;
00606 
00610   QPushButton *pbAux_;
00611 
00615   QPushButton *pbAux2_;
00616 
00620   QPushButton *pbAux3_;
00621 
00625   QString fieldAlias_;
00626 
00632   bool showEditor_;
00633 
00637   int partDecimal_;
00638 
00642   QSize initMaxSize_;
00643   QSize initMinSize_;
00644 
00648   FLDataTable *autoComPopup_;
00649   QVBox *autoComFrame_;
00650   QString autoComFieldName_;
00651   QString autoComFieldRelation_;
00652 
00656   FLFieldDB *fieldMapValue_;
00657   QString mapValue_;
00658 
00659 signals:
00660 
00664   void lostFocus();
00665 
00669   void keyF2Pressed();
00670 
00674   void labelClicked();
00675 
00679   void textChanged(const QString &);
00680 
00685   void activatedAccel(int);
00686 
00690   void keyF4Pressed();
00691 
00695   void keyReturnPressed();
00696 };
00697 
00698 class FLPixmapView: public QScrollView, public QFilePreview
00699 {
00700 public:
00701 
00702   FLPixmapView(QWidget *parent = 0);
00703   void setPixmap(const QPixmap &pix);
00704   void drawContents(QPainter *p, int, int, int, int);
00705   void previewUrl(const QUrl &u);
00706   void clear();
00707   QPixmap pixmap();
00708   void setAutoScaled(const bool autoScaled);
00709 
00710 private:
00711 
00712   QPixmap pixmap_;
00713   QPixmap pixmapView_;
00714   QString path_;
00715   bool autoScaled_;
00716 };
00717 
00718 class FLLineEdit: public QLineEdit
00719 {
00720   Q_OBJECT
00721 
00722 public:
00723 
00724   FLLineEdit(QWidget *parent, const char *name = 0);
00725 
00726   QString text() const;
00727 
00728   int type;
00729   int partDecimal;
00730 
00731 public slots:
00732   virtual void setText(const QString &);
00733 
00734 protected:
00735 
00736   void focusOutEvent(QFocusEvent *f);
00737   void focusInEvent(QFocusEvent *f);
00738 };
00739 
00740 // Uso interno
00741 class FLDoubleValidator: public QDoubleValidator
00742 {
00743 public:
00744 
00745   FLDoubleValidator(QObject *parent, const char *name = 0);
00746   FLDoubleValidator(double bottom, double top, int decimals,
00747                     QObject *parent, const char *name = 0);
00748   QValidator::State validate(QString &input, int &) const;
00749 };
00750 
00751 // Uso interno
00752 class FLIntValidator: public QIntValidator
00753 {
00754 public:
00755 
00756   FLIntValidator(QObject *parent, const char *name = 0);
00757   FLIntValidator(int minimum, int maximum,
00758                  QObject *parent, const char *name = 0);
00759   QValidator::State validate(QString &input, int &) const;
00760 };
00761 
00762 // Uso interno
00763 class FLUIntValidator: public QIntValidator
00764 {
00765 public:
00766 
00767   FLUIntValidator(QObject *parent, const char *name = 0);
00768   FLUIntValidator(int minimum, int maximum,
00769                   QObject *parent, const char *name = 0);
00770   QValidator::State validate(QString &input, int &) const;
00771 };
00772 
00773 // Uso interno
00774 class FLSpinBox: public QSpinBox
00775 {
00776 public:
00777 
00778   FLSpinBox(QWidget *parent = 0, const char *name = 0) :
00779     QSpinBox(parent, name) {
00780     editor() ->setAlignment(Qt::AlignRight);
00781   }
00782 };
00783 
00784 // Uso interno
00785 class FLDateEdit: public QDateEdit
00786 {
00787 public:
00788 
00789   FLDateEdit(QWidget *parent = 0, const char *name = 0) : QDateEdit(parent, name) {}
00790 
00791 protected:
00792 
00793   void fix();
00794 };
00795 
00796 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'