00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef HK_QBE
00012 #define HK_QBE
00013 #include "hk_presentation.h"
00014 #include "hk_string.h"
00015 #include <list>
00016 #include <vector>
00017 class hk_qbeprivate;
00018 class hk_qbe:public hk_presentation
00019 {
00020 public:
00021 hk_qbe(void);
00022 virtual ~hk_qbe();
00026 enum enum_querytype{qt_select,qt_groupselect,qt_update,qt_delete};
00027 enum enum_functiontype {ft_condition,ft_group,ft_sum,ft_count,ft_avg,ft_min,ft_max};
00028 void set_querytype(enum_querytype,bool registerchange=true);
00029 enum_querytype querytype(void) const;
00030 void set_distinct(bool d,bool registerchange=true);
00031 bool distinct(void) const;
00032 bool create_sql(hk_string& sql);
00033 enum enum_order{none,ascending,descending};
00034 typedef class
00035 {
00036 public:
00037 hk_string field;
00038 int table;
00039 hk_string alias;
00040 enum_functiontype functiontype;
00041 enum_order order;
00042 bool show;
00043 hk_string updatevalue;
00044 vector<hk_string> conditions;
00045
00046 }hk_qbedataclass;
00047
00048 void clear_definition(bool registerchange=true);
00049 void add_definition( const hk_string& field,
00050 int table,
00051 const hk_string& alias,
00052 enum_functiontype functiontype,
00053 enum_order order,
00054 bool show,
00055 const hk_string& updatevalue,
00056 vector<hk_string>& conditions,
00057 bool registerchange=true
00058 );
00059 void add_definition( hk_qbedataclass*, bool registerchange=true);
00060 const list<hk_qbe::hk_qbedataclass>* definitionlist(void) ;
00061
00062
00063
00064 virtual void savedata(ostream& s);
00065 virtual void loaddata(xmlNodePtr definition);
00066
00067 protected:
00068 virtual void widget_specific_querytype_has_changed(enum_querytype oldtype,enum_querytype newtype);
00069 private:
00070 hk_string joindefinition(hk_datasource*);
00071 hk_qbeprivate* p_private;
00072 hk_string create_where(void);
00073 hk_string create_depending_where(void);
00074 hk_string create_from(void);
00075 hk_string create_what(void);
00076 hk_string create_order_by(void);
00077 hk_string create_group_by(void);
00078 hk_string create_update_set(void);
00079 hk_string create_select_sql(bool&);
00080 hk_string create_groupselect_sql(bool&);
00081 hk_string create_update_sql(bool&);
00082 hk_string create_delete_sql(bool&);
00083 hk_string fieldname(hk_qbedataclass*,bool withalias=false);
00084
00085
00086 };
00087
00088 #endif //HK_QBE