00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef HK_KDETABLEDESIGN_H
00013 #define HK_KDETABLEDESIGN_H
00014 #include <hk_dsgrid.h>
00015 #include <hk_dsvisible.h>
00016 #include <qvariant.h>
00017 #include <qwidget.h>
00018 #include <hk_column.h>
00019 #include <qstring.h>
00020 #include <qstringlist.h>
00021 #include <list>
00022 class QVBoxLayout;
00023 class QHBoxLayout;
00024 class QGridLayout;
00025 class QButtonGroup;
00026 class QCheckBox;
00027 class QComboBox;
00028 class QLabel;
00029 class QLineEdit;
00030 class QListView;
00031 class QListViewItem;
00032 class QPushButton;
00033 class QSpinBox;
00034 class QToolButton;
00035 class hk_kdeindexwindow;
00047 class hk_kdetabledesign : public QWidget ,public hk_dsvisible
00048 {
00049 Q_OBJECT
00050
00051 public:
00052 hk_kdetabledesign( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
00053 virtual ~hk_kdetabledesign();
00054
00055 virtual void set_datasource(hk_datasource* d);
00056 hk_datasource* datasource(void);
00057 bool has_changed() const;
00058 signals:
00059 void signal_has_changed();
00060 void signal_tablename_changed();
00061 public slots:
00065 virtual bool alter_table(bool ask=true);
00066 virtual void load_fieldinfo();
00067 void set_designmode();
00068 virtual void alterbutton_clicked();
00069 protected slots:
00070 virtual void delete_clicked();
00071 virtual void index_clicked();
00072 virtual void name_changed();
00073 virtual void new_clicked();
00074 virtual void primary_changed();
00075 virtual void notnull_changed();
00076 virtual void selection_changed();
00077 virtual void indexselection_changed();
00078 virtual void size_changed();
00079 virtual void type_changed();
00080 virtual void new_index();
00081 virtual void alter_index();
00082 virtual void delete_index();
00083 virtual void set_indexlist(void);
00084
00085 protected:
00086
00087 virtual void showEvent(QShowEvent* e);
00088 virtual void list_changes(listtype type);
00089 void set_fields_enabled(void);
00090 QGridLayout* hk_kdetabledesignLayout;
00091 QHBoxLayout* Layoutindexwindow;
00092 QVBoxLayout* buttonlayout;
00093 QHBoxLayout* Layout8;
00094 QHBoxLayout* Layout7;
00095 QVBoxLayout* Layout22;
00096 QHBoxLayout* Layout25;
00097 QVBoxLayout* Layout24;
00098 QHBoxLayout* Layout23;
00099 QVBoxLayout* editlayout;
00100 QVBoxLayout* fieldbuttonlayout;
00101 QHBoxLayout* fieldtoplayout;
00102
00103 QListView* fieldlist;
00104 QPushButton* newbutton;
00105 QPushButton* deletebutton;
00106 QPushButton* alterbutton;
00107 QPushButton* indexdeletebutton;
00108 QPushButton* indexnewbutton;
00109 QPushButton* indexalterbutton;
00110 QLabel* fieldnamelabel;
00111 QLabel* columntypelabel;
00112 QLabel* sizelabel;
00113 QLabel* notnulllabel;
00114 QLabel* primaryindexlabel;
00115 QLineEdit* namefield;
00116 QComboBox* typefield;
00117 QSpinBox* sizefield;
00118 QCheckBox* primaryfield;
00119 QCheckBox* notnullfield;
00120 QListView* indexwindow;
00121
00122 void create_columntypelist(void);
00123 private :
00124 void structure_changes(bool c);
00125 void clear_fieldlist(void);
00126 hk_column::enum_columntype ftype(const QString&);
00127 enum enum_state {unchanged,delfield,newfield,altered};
00128 int fieldname_count(const hk_string&);
00132
00133 typedef class fieldstruct
00134 {
00135 public:
00136 hk_string oldname;
00137 bool oldprimary;
00138 bool oldnotnull;
00139 hk_column::enum_columntype oldtype;
00140 long oldsize;
00141 hk_string newname;
00142 bool newprimary;
00143 bool newnotnull;
00144 hk_column::enum_columntype newtype;
00145 long newsize;
00146 enum_state state;
00147 };
00148 typedef class dictclass
00149 {
00150 public:
00151 QString name;
00152 hk_column::enum_columntype type;
00153 };
00154 void show_fieldinfos(fieldstruct*);
00155 list<dictclass> columntype_dictionary;
00156 list<fieldstruct> fields;
00157 list<fieldstruct>::iterator actualfieldit;
00158 QListViewItem* lastmarkedItem;
00159 bool p_fieldlist_created;
00160 bool p_has_changed;
00161 bool fieldnamecheck;
00162
00163 };
00164 #endif // HK_KDETABLEdesign_H