00001 /* 00002 * Linux Advanced Business Enterprise Management System 00003 * 00004 * 00005 * File name....... : qlabdbcombo.h 00006 * File version.... : 1.2.8 00007 * Revision Date... : Sat Feb 21 2004 00008 * 00009 * File Description : Base Class for all Combo Base Data Collection Access 00010 * 00011 * Author.......... : DJ Anubis 00012 * Copyright....... : (C) 2001-2004 by DJ Anubis 00013 * Email .......... : labproject@free.fr 00014 * 00015 * License : 00016 * Please read the license file in doc directory. 00017 * 1. Lab Public License. 00018 * You should have received a copy of the Lab Public License with this package. 00019 * If this is not the case, you can read it or download it at: 00020 * http://labproject.free.fr 00021 * 2. Q Public License. 00022 * Conformant to Trolltech QPL license. 00023 * 3. GNU General Public License. 00024 * Reserved for free projects. 00025 * 4. Commercial license. 00026 * Recommanded if your code is not distributed under one of the 3 models above. 00027 * 00028 * Read the license FAQ in doc directory. 00029 * 00030 */ 00031 00032 00033 #ifndef QLABDBCOMBO_H 00034 #define QLABDBCOMBO_H 00035 00036 #include <qwidget.h> 00037 #include <qwidgetplugin.h> 00038 #include <qcombobox.h> 00039 #include <qstringlist.h> 00040 #include <qmap.h> 00041 00042 00043 class QT_WIDGET_PLUGIN_EXPORT QlabDbCombo : public QComboBox 00044 { 00045 Q_OBJECT ; 00046 Q_ENUMS( ActiveState ) ; 00047 00048 Q_PROPERTY( QString tableName READ tableName WRITE setTableName 00049 DESIGNABLE true SCRIPTABLE true STORED true ) ; 00050 Q_PROPERTY( ActiveState activeFilter READ activeFilter WRITE setActiveFilter 00051 DESIGNABLE true SCRIPTABLE true STORED true ) ; 00052 Q_PROPERTY( QString filter READ filter WRITE setFilter 00053 DESIGNABLE true SCRIPTABLE true STORED true ) ; 00054 Q_PROPERTY( QStringList entries READ entries WRITE setEntries 00055 DESIGNABLE true SCRIPTABLE true STORED true ) ; 00056 Q_PROPERTY( QStringList order READ order WRITE setOrder 00057 DESIGNABLE true SCRIPTABLE true STORED true ) ; 00058 Q_PROPERTY( int itemId READ itemId WRITE setItemId 00059 DESIGNABLE true SCRIPTABLE true STORED true ) ; 00060 Q_PROPERTY( QStringList valueList READ valueList ) ; 00061 00062 public : 00063 QlabDbCombo( QWidget* parent = 0, const char * name = 0 ) ; 00064 ~QlabDbCombo() ; 00073 enum ActiveState { Active, 00074 Inactive, 00075 Both 00076 } ; 00077 virtual void rehash() ; 00078 bool inInit ; 00080 public slots : 00081 int itemId() const ; 00082 void setItemId( int recid ) ; 00083 int getId( const QString & txt ) ; 00084 00085 QString tableName() const ; 00086 void setTableName( const QString & table ) ; 00087 ActiveState activeFilter() const ; 00088 void setActiveFilter( ActiveState flt ) ; 00089 QString filter() const ; 00090 void setFilter( const QString & flt ) ; 00091 QStringList entries() const ; 00092 void setEntries( const QStringList & lst ) ; 00093 QStringList order() const ; 00094 void setOrder( const QStringList & ordering ) ; 00095 QStringList valueList() const ; 00096 00097 void setActive( int id ) ; 00098 void setActive( const QString & data ) ; 00099 00100 signals : 00106 void idChanged( int idx ) ; 00107 00108 protected : 00109 virtual void mapModes( QString & name, int &id, bool populate ) ; 00110 QMap<QString, int> tblMap ; 00111 QMap<int, QString> revMap ; 00114 private : 00115 QString mainTable ; 00116 ActiveState activeState ; 00117 QString defaultFilter ; 00118 QStringList fields ; 00119 QStringList orderField ; 00120 int itemid ; 00122 } ; 00123 00124 #endif // QLABDBCOMBO_H