00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef HK_KDEDBDESIGNER
00012 #define HK_KDEDBDESIGNER
00013 #include <qwidget.h>
00014 #include <qlabel.h>
00015 #include <qlistbox.h>
00016 #include <qframe.h>
00017 #include <kparts/mainwindow.h>
00018 #include <hk_dbvisible.h>
00019 #include <hk_referentialintegrity.h>
00020 #include <hk_dsdatavisible.h>
00021
00022
00023
00024 class hk_presentation;
00025 class hk_kdedbdesignerprivate;
00026 class hk_kdedatasourceframe;
00027 class QVBoxLayout;
00028 class QGridLayout;
00029 class hk_kdedbrelation;
00030
00031
00032 class hk_kdedbdesigner:public QWidget, public hk_dbvisible
00033 {
00034 Q_OBJECT
00035 public:
00036 hk_kdedbdesigner(QWidget* parent=0);
00037 virtual ~hk_kdedbdesigner();
00038 void set_presentation(hk_presentation*);
00039 hk_presentation* presentation(void);
00040 QScrollView* scrollview(void) const;
00041 hk_kdedatasourceframe* get_dsframe(hk_datasource*);
00042 hk_kdedbrelation* get_relation(hk_datasource* ds);
00043 hk_kdedbrelation* get_relation(hk_datasource* master,hk_datasource* slave);
00044 hk_kdedbrelation* get_relation(hk_kdedatasourceframe* master,hk_kdedatasourceframe* slave);
00045 referentialclass* get_referentialintegrity(hk_datasource* master,hk_datasource* slave);
00046 hk_kdedbrelation* add_relation(hk_kdedatasourceframe* master,hk_kdedatasourceframe* slave);
00047 hk_kdedbrelation* add_relation(hk_datasource* master,hk_datasource* slave);
00048 hk_kdedbrelation* add_referentialintegrity(referentialclass ref, hk_kdedatasourceframe* ds);
00049 hk_kdedatasourceframe* add_dsframe(hk_datasource*);
00050 void set_all_relations(void);
00051
00052 signals:
00053 void signal_definition_has_changed(void);
00054 void signal_field_doubleclicked(int,const hk_string&);
00055
00056 public slots:
00057 void clear_datasources();
00058 void set_datasources();
00059 void relation_clicked(hk_kdedbrelation*);
00060 void new_focus(hk_kdedatasourceframe*);
00061 void delete_datasource(hk_kdedatasourceframe*);
00062 void delete_relation(hk_kdedbrelation*);
00063 void add_datasource(void);
00064
00065 void slot_field_doubleclicked(int, const hk_string&);
00066
00067 private:
00068 void raise_datasources(void);
00069 hk_datasource* already_added_table(const hk_string&t);
00070 void remove_relation(hk_kdedbrelation*);
00071
00072
00073 hk_kdedbdesignerprivate* p_private;
00074 };
00075
00076
00077
00078
00079
00080
00081
00082 class kdedatasourcelabel:public QLabel
00083 {
00084 public:
00085 friend class hk_kdedatasourceframe;
00086 kdedatasourcelabel(hk_kdedatasourceframe* w);
00087 protected:
00088 void mousePressEvent(QMouseEvent* event);
00089 void mouseReleaseEvent(QMouseEvent* event);
00090 virtual void mouseMoveEvent(QMouseEvent*);
00091 bool p_drag;
00092 int p_startx;
00093 int p_starty;
00094 int p_offsetx;
00095 int p_offsety;
00096 hk_kdedatasourceframe* p_datasourceframe;
00097 };
00098
00099
00100
00101 class hk_kdefieldlist:public QListBox
00102 {
00103 Q_OBJECT
00104 public:
00105 hk_kdefieldlist(hk_kdedatasourceframe* parent);
00106 void setFocus(void);
00107 void clearFocus(void);
00108
00109 signals:
00110 void signal_field_doubleclicked(int,const hk_string&);
00111
00112 protected:
00113 void mouseMoveEvent(QMouseEvent*);
00114 void mouseReleaseEvent(QMouseEvent*);
00115
00116 virtual void mouseDoubleClickEvent(QMouseEvent*);
00117 void dragEnterEvent(QDragEnterEvent*);
00118 void dropEvent(QDropEvent* );
00119 virtual void contextMenuEvent(QContextMenuEvent*);
00120
00121 private:
00122
00123 hk_kdedatasourceframe* p_datasourceframe;
00124 QPoint p_dragstartposition;
00125 };
00126
00127
00128
00129
00130
00131
00132 class hk_kdedatasourceframe :public QFrame, public hk_dsdatavisible
00133 {
00134 Q_OBJECT
00135 public:
00136 friend class hk_kdedbdesigner;
00137 hk_kdedatasourceframe(hk_kdedbdesigner* designer,QWidget* parent,hk_datasource* ds);
00138 void set_fields(void);
00139 void set_focus(hk_kdedatasourceframe*);
00140 void setFocus(void);
00141 void clearFocus(void);
00142 void mousePressEvent(QMouseEvent*);
00143 hk_kdedbdesigner* designer() const;
00144 kdedatasourcelabel* header() const {return p_header;}
00145
00146 public slots:
00147 void edit(void);
00148 void set_header(void);
00149 signals:
00150 void signal_moved(void);
00151
00152 protected:
00153 virtual void moveEvent(QMoveEvent*);
00154 virtual void resizeEvent(QResizeEvent*);
00155 bool eventFilter(QObject* object,QEvent* event);
00156
00157 private:
00158 void set_new_position(void);
00159 hk_kdedbdesigner* p_designer;
00160 QListBox* p_listbox;
00161 QGridLayout* p_layout;
00162 kdedatasourcelabel* p_header;
00163 bool p_positionupdate;
00164
00165 };
00166
00167
00168 class hk_kdedbrelation:public QWidget,public hk_class
00169 {
00170 Q_OBJECT
00171 public:
00172 hk_kdedbrelation(QWidget* parent,bool is_referentialinegrity);
00173 ~hk_kdedbrelation();
00174 void setAutoMask(bool);
00175 void set_datasources(hk_kdedatasourceframe* master,hk_kdedatasourceframe* slave);
00176 void set_referentialintegrity(referentialclass c,hk_kdedatasourceframe* master,hk_kdedatasourceframe* slave);
00177 hk_kdedatasourceframe* masterdatasource(void) const;
00178 hk_kdedatasourceframe* slavedatasource(void) const;
00179 void setFocus(void);
00180 void set_focus(void);
00181 hk_string referentialname()const;
00182 bool updatecascade()const;
00183 bool deletecascade()const;
00184 signals:
00185 void signal_relation_clicked(hk_kdedbrelation*);
00186
00187 public slots:
00188 void slot_relation_clicked(hk_kdedbrelation*);
00189 void edit(void);
00190
00191
00192 protected:
00193 void paint_relation(QPainter*);
00194 void paintEvent(QPaintEvent*);
00195 void keyPressEvent(QKeyEvent*);
00196 void updateMask(void);
00197 QString tooltipfields(referentialclass* c=NULL);
00198 virtual void mouseMoveEvent(QMouseEvent*);
00199 virtual void mousePressEvent(QMouseEvent*);
00200 virtual void mouseDoubleClickEvent(QMouseEvent*);
00201 virtual void contextMenuEvent(QContextMenuEvent*);
00202
00203 protected slots:
00204
00205 void datasource_moved(void);
00206 private:
00207
00208 hk_kdedatasourceframe* p_masterdatasource;
00209 hk_kdedatasourceframe* p_slavedatasource;
00210 int p_fromx,p_fromy,p_tox,p_toy;
00211 bool p_is_focused;
00212 bool p_is_referentialintegrity;
00213 hk_string p_refname;
00214 bool p_deletecascade;
00215 bool p_updatecascade;
00216 };
00217
00218
00219 class hk_kdemovewidget: public QWidget
00220 {
00221 Q_OBJECT
00222 public:
00223 enum enum_orientation {horizontal,vertical,diagonal};
00224 hk_kdemovewidget( enum_orientation orientation, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
00225 ~hk_kdemovewidget();
00226 enum_orientation orientation(void) const {return p_orientation;}
00227 protected:
00228 void mousePressEvent(QMouseEvent* event);
00229 virtual void mouseMoveEvent(QMouseEvent*);
00230
00231 private:
00232 bool p_drag;
00233 int p_startx;
00234 int p_starty;
00235 int p_offsetx;
00236 int p_offsety;
00237 enum_orientation p_orientation;
00238
00239 };
00240
00241
00242
00243 class hk_kdedbdesignerwindowprivate;
00244
00245 class hk_kdedbdesignerwindow: public KParts::MainWindow
00246 {
00247 Q_OBJECT
00248 public:
00249 hk_kdedbdesignerwindow( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
00250 ~hk_kdedbdesignerwindow();
00251 hk_kdedbdesigner* designer(void) const;
00252
00253 signals:
00254 void signal_closed(void);
00255
00256 protected:
00257 void closeEvent(QCloseEvent*);
00258
00259
00260 private:
00261
00262 hk_kdedbdesignerwindowprivate* p_private;
00263
00264 };
00265
00266 #endif //HK_KDEDBDESIGNER