hk_kdedbdesigner.h

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

Generated on Tue Sep 25 22:39:06 2007 for Databasehandlingdialogclasses by  doxygen 1.5.3