Databasehandlingdialogclasses  0.5.3
hk_kdetabledesign.h
1 // ****************************************************************************
2 // copyright (c) 2000-2005 Horst Knorr <hk_classes@knoda.org>
3 // This file is part of the hk_kdeclasses library.
4 // This file may be distributed and/or modified under the terms of the
5 // GNU Library Public License version 2 as published by the Free Software
6 // Foundation and appearing in the file LGPL included in the
7 // packaging of this file.
8 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
9 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10 // ****************************************************************************
11 
12 #ifndef HK_KDETABLEDESIGN_H
13 #define HK_KDETABLEDESIGN_H
14 #include <hk_dsgrid.h>
15 #include <hk_dsvisible.h>
16 #include <qvariant.h>
17 #include <qwidget.h>
18 #include <hk_column.h>
19 #include <qstring.h>
20 #include <qstringlist.h>
21 #include <list>
22 class QVBoxLayout;
23 class QHBoxLayout;
24 class QGridLayout;
25 class QButtonGroup;
26 class QCheckBox;
27 class QComboBox;
28 class QLabel;
29 class QLineEdit;
30 class QListView;
31 class QListViewItem;
32 class QPushButton;
33 class QSpinBox;
34 class QToolButton;
35 class hk_kdeindexwindow;
47 class hk_kdetabledesign : public QWidget ,public hk_dsvisible
48 {
49  Q_OBJECT
50 
51  public:
52  hk_kdetabledesign( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
53  virtual ~hk_kdetabledesign();
54 
55  virtual void set_datasource(hk_datasource* d);
56  hk_datasource* datasource(void);
57  bool has_changed() const;
58  signals:
59  void signal_has_changed();
60  void signal_tablename_changed();
61  public slots:
65  virtual bool alter_table(bool ask=true);
66  virtual void load_fieldinfo();
67  void set_designmode();
68  virtual void alterbutton_clicked();
69  protected slots:
70  virtual void delete_clicked();
71  virtual void index_clicked();
72  virtual void name_changed();
73  virtual void new_clicked();
74  virtual void primary_changed();
75  virtual void notnull_changed();
76  virtual void selection_changed();
77  virtual void indexselection_changed();
78  virtual void size_changed();
79  virtual void type_changed();
80  virtual void new_index();
81  virtual void alter_index();
82  virtual void delete_index();
83  virtual void set_indexlist(void);
84 
85  protected:
86 
87  virtual void showEvent(QShowEvent* e);
88  virtual void list_changes(listtype type);
89  void set_fields_enabled(void);
90  QGridLayout* hk_kdetabledesignLayout;
91  QHBoxLayout* Layoutindexwindow;
92  QVBoxLayout* buttonlayout;
93  QHBoxLayout* Layout8;
94  QHBoxLayout* Layout7;
95  QVBoxLayout* Layout22;
96  QHBoxLayout* Layout25;
97  QVBoxLayout* Layout24;
98  QHBoxLayout* Layout23;
99  QVBoxLayout* editlayout;
100  QVBoxLayout* fieldbuttonlayout;
101  QHBoxLayout* fieldtoplayout;
102 
103  QListView* fieldlist;
104  QPushButton* newbutton;
105  QPushButton* deletebutton;
106  QPushButton* alterbutton;
107  QPushButton* indexdeletebutton;
108  QPushButton* indexnewbutton;
109  QPushButton* indexalterbutton;
110  QLabel* fieldnamelabel;
111  QLabel* columntypelabel;
112  QLabel* sizelabel;
113  QLabel* notnulllabel;
114  QLabel* primaryindexlabel;
115  QLineEdit* namefield;
116  QComboBox* typefield;
117  QSpinBox* sizefield;
118  QCheckBox* primaryfield;
119  QCheckBox* notnullfield;
120  QListView* indexwindow;
121 
122  void create_columntypelist(void);
123  private :
124  void structure_changes(bool c);
125  void clear_fieldlist(void);
126  hk_column::enum_columntype ftype(const QString&);
127  enum enum_state {unchanged,delfield,newfield,altered};
128  int fieldname_count(const hk_string&);
132  //bool is_keyword(const QString&);
133  typedef class fieldstruct
134  {
135  public:
136  hk_string oldname;
137  bool oldprimary;
138  bool oldnotnull;
139  hk_column::enum_columntype oldtype;
140  long oldsize;
141  hk_string newname;
142  bool newprimary;
143  bool newnotnull;
144  hk_column::enum_columntype newtype;
145  long newsize;
146  enum_state state;
147  };
148  typedef class dictclass
149  {
150  public:
151  QString name;
152  hk_column::enum_columntype type;
153  };
154  void show_fieldinfos(fieldstruct*);
155  list<dictclass> columntype_dictionary;
156  list<fieldstruct> fields;
157  list<fieldstruct>::iterator actualfieldit;
158  QListViewItem* lastmarkedItem;
159  bool p_fieldlist_created;
160  bool p_has_changed;
161  bool fieldnamecheck;
162 // QStringList p_keywordlist;
163 };
164 #endif // HK_KDETABLEdesign_H
Definition: hk_kderowselector.cpp:97
virtual bool alter_table(bool ask=true)
Definition: hk_kdetabledesign.cpp:450
KDE widget to alter tables.
Definition: hk_kdetabledesign.h:47