Ananas Library  0.9.5
wdbtable.h
1 /****************************************************************************
2 ** $Id: wdbtable.h,v 1.60 2008/04/12 18:05:35 app Exp $
3 **
4 ** Header file of the database table plugin of Ananas
5 ** Designer and Engine applications
6 **
7 ** Created : 20031201
8 **
9 ** Copyright (C) 2003-2004 Leader InfoTech. All rights reserved.
10 ** Copyright (C) 2003-2004 Grigory Panov, Yoshkar-Ola.
11 **
12 ** This file is part of the Ananas Plugins of the Ananas
13 ** automation accounting system.
14 **
15 ** This file may be distributed and/or modified under the terms of the
16 ** GNU General Public License version 2 as published by the Free Software
17 ** Foundation and appearing in the file LICENSE.GPL included in the
18 ** packaging of this file.
19 **
20 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 **
23 ** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru
24 ** See http://www.leaderit.ru/gpl/ for GPL licensing information.
25 **
26 ** Contact org@leaderit.ru if any conditions of this licensing are
27 ** not clear to you.
28 **
29 **********************************************************************/
30 
31 #ifndef WDBTABLE_H
32 #define WDBTABLE_H
33 
34 #include <qsqlpropertymap.h>
35 #include <qdatatable.h>
36 #include <qdragobject.h>
37 #include "acfg.h"
38 #include "aobject.h"
39 #include "awidget.h"
40 #include "wfield.h"
41 
42 class aDatabase;
43 class wDBTable;
44 class QDataTable;
45 
46 class aSearchWidget : public QFrame
47 {
48 Q_OBJECT
49 public:
50  aSearchWidget( QWidget *parent, wDBTable *table );
51  ~aSearchWidget();
52  void search( const QString &t ="");
53 public slots:
54  void setText( const QString &t );
55 protected:
56 // virtual void keyPressEvent ( QKeyEvent *e );
57  bool eventFilter( QObject *obj, QEvent *ev );
58 private:
59  QString ftext;
60  QLineEdit *l;
61  wDBTable *t;
62 };
63 
64 
65 
77 class QT_WIDGET_PLUGIN_EXPORT wDBTable : public QDataTable
78 {
79  friend class aForm;
80 
81  Q_OBJECT
82  Q_PROPERTY( Q_ULLONG Id READ getId WRITE setId DESIGNABLE true )
83  Q_PROPERTY( int DefaultColWidth READ getDefColWidth WRITE setDefColWidth DESIGNABLE true )
84  Q_PROPERTY( int TableInd READ getTblInd WRITE setTblInd DESIGNABLE true )
85  Q_PROPERTY( QStringList DefFields READ getDefFields WRITE setDefFields DESIGNABLE true )
86  Q_PROPERTY( QStringList DefHeaders READ getDefHeaders WRITE setDefHeaders DESIGNABLE true )
87  Q_PROPERTY( QStringList ColWidth READ getColWidth WRITE setColWidth DESIGNABLE true )
88  Q_PROPERTY( QStringList DefIdList READ getDefIdList WRITE setDefIdList DESIGNABLE true )
89 // Q_PROPERTY( bool openEditor READ getOpenEditor WRITE setOpenEditor STORED true )
90  Q_PROPERTY( QString editFormName READ getEditFormName WRITE setEditFormName DESIGNABLE true )
91 public:
92  aCfg* md;
93  aDatabase* db;
94  aEngine* engine;
95  //char vLoaded;
96  QStringList list_available_tables;
97  QStringList fname, hname, colWidth,idList;
98  int defColWidth;
99  int tableInd;
100  aCfgItem tables;
101  QSqlCursor* cur;
102  bool searchMode;
103  QString searchString;
104  aSearchWidget *searchWidget;
105 
106  wDBTable( QString objtype, QWidget *parent = 0, const char *name = 0);
107  virtual ~wDBTable();
108  void checkFields();
109  void setFields(int numTable); //set propertis default value for table with num=numTable
110  QStringList getFields(int numTable, bool GetId=false); // return list field names or id's, defined in metadata
111  QString getFieldName(long idField); // return attribute `name' value
112  QString getFieldType(long idField); // return attribute `type' value
113  int getTableInd(int id);
114  int getTableId(int ind);
115 
116  // void init( aDatabase *adb );
117  void init();
118  void init(aDatabase *adb, aEngine *e = 0 ); // call in ananas engine
119  void OpenEditor();
120  //QWidget* createEditor();
121 
122  //int getDefaultWidth() const {return defColWidth;};
123 
124  QStringList getDefFields() const;
125  QStringList getDefHeaders() const;
126  QStringList getColWidth() const;
127  QStringList getDefIdList() const;
128  Q_ULLONG getId() const;
129  int getTblInd() const;
130  bool getOpenEditor() const;
131  int getDefColWidth() const;
132 
133  void setDefFields(QStringList lst);
134  void setDefHeaders(QStringList lst);
135  void setColWidth(QStringList lst);
136  void setDefIdList(QStringList lst);
137  void setId( Q_ULLONG fn );
138  void setTblInd( int ind );
139  void setOpenEditor( bool fn );
140  void setDefColWidth( int fn );
141 
142  QString getEditFormName() const { return vEditFormName;};
143  void setEditFormName( QString name) { vEditFormName = name; };
144 
145  QString containerType() const { return container_type;};
146  void setContainerType( QString name) { container_type = name; };
147  QPixmap systemIcon();
148  virtual int Select( ANANAS_UID db_uid );
149 public slots:
150  QValueList<int> getBindList();
151  void setWFieldEditor();
152  void setAvailableTables();
153  void lineUpdate(QSql::Op mode);
154  void newFilter(const QString & );
155  void newDataId(const Q_ULLONG );
156  QVariant Value( const QString &colname );
157 
158  bool searchColumn( const QString &text, bool FromCurrent = FALSE, bool Forward = TRUE );
159  void searchOpen( const QString &text = "" );
160  void searchClose();
161 
162 protected slots:
163  void doubleClickEventHandler(int , int , int, const QPoint& ); //parametrs not used
164  virtual void updateTableCellHandler(int, int);
165  void dropped(QDropEvent *);
166 signals:
167 
175  void saveLine(QSqlRecord *rec);
176 
184  void deleteLine(QSqlRecord *rec);
192  void selected( Q_ULLONG uid );
200  void selectRecord ( Q_ULLONG );
208  void updateCurr(int row, int col);
209 //<<<<<<< wdbtable.h
210 
211  //signals from context menu for connecting to wJournal
212  //if container has another type, then do QDataTable context menu
213  //and this signal no emitted
214 //=======
215 
229 //>>>>>>> 1.45.2.4
230  void insertRequest();
234  void updateRequest();
238  void deleteRequest();
242  void viewRequest();
243  // end
244 
245 private slots:
246  //void select( Q_ULLONG group );
247  void lineChange(int, int);
248  void lineInsert(QSqlRecord*);
249  void updateItem( ANANAS_UID db_uid );
250 
251 protected:
252  virtual QDragObject * dragObject ();
253  virtual void paintField ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected );
254  QWidget * beginUpdate ( int row, int col, bool replace );
255  virtual bool updateCurrent();
256  void contentsContextMenuEvent ( QContextMenuEvent * e );
257 // void propertyUpdate(const QString &propName);
258  virtual bool deleteCurrent();
259  //virtual QSql::Confirm confirmEdit ( QSql::Op m );
260  virtual void keyPressEvent ( QKeyEvent *e );
261  void EditElement();
262  virtual void activateNextCell();
263  virtual bool beginInsert ();
264  virtual QSql::Confirm confirmEdit( QSql::Op m );
265 
266 private:
267 
268  QPixmap t_doc;
269  QPixmap t_doc_d;
270  QPixmap t_doc_t;
271  QPixmap t_doc_m;
272  QPixmap t_doc_tm;
273  QPixmap t_cat_e;
274  QPixmap t_cat_ed;
275  QPixmap t_cat_g;
276  QPixmap t_cat_gd;
277 
278  int lastEditedRow;
279  int lastEditedCol;
280 
281  QString container_type;
282  Q_ULLONG doc_id;
283  Q_ULLONG cat_group_id;
284  long journalFieldId(long);
285  QString journalFieldName(long);
286  bool inEditMode;
287  //aDBTablePrivate impl;
288 // void updateProp(void);
289  QValueList<int> listBindings;
290  aCfgItem obj;
291  QString vName, vEditFormName;
292  QString vDefineCols;
293  Q_ULLONG oid;
294 };
295 
296 
304 class aEditorFactory: public QSqlEditorFactory
305 {
306 public:
311  aEditorFactory(QObject * parent = 0, const char * name = 0):QSqlEditorFactory(parent,name) {};
312  QWidget * createEditor (QWidget * parent, const QSqlField * field);
313  void setMd(aCfg *md);
314 private:
315  aCfg * md;
316 };
317 
324 class aObjectDrag : public QDragObject
325 {
326  Q_OBJECT
327 public:
328  aObjectDrag(aObject * obj, QWidget * dragSource);
329  ~aObjectDrag();
330 
331  virtual void setObject(aObject* obj);
332  aObject* object() { return fObj; };
333  const char* format(int i) const;
334  virtual QByteArray encodedData(const char*) const;
335 private:
336  aObject* fObj;
337 };
338 
339 
340 #endif
Класс для реализации перетаскивания мышкой элементов справочников между группами. ...
Definition: wdbtable.h:324
QVariant Value(const QString &name)
ScriptAPI. Возвращает значение поля экранной формы.
Definition: aform.cpp:805
int Select(Q_ULLONG id)
Definition: aform.cpp:1656
Definition: wdbtable.h:46
Класс для поддержки собственного редактора поля в wDBTable. Наследует QSqlEditorFactory.
Definition: wdbtable.h:304
aEditorFactory(QObject *parent=0, const char *name=0)
Definition: wdbtable.h:311
void init()
Definition: aform.cpp:265
Определяет программный интерфейс экранных форм Ананаса, предназначенный для использования Ананас...
Definition: aform.h:75
QWidget * createEditor(QWidget *parent, const QSqlField *field)
Definition: wdbtable.cpp:1134
Класс реализует програмный интерфейс доступа к элементам метаданных системы. Наследует QObject...
Definition: acfg.h:436
Класс для работы с СУБД. Ananas Data Abstraction Layer. Наследует QObject.
Definition: adatabase.h:77
Визуальный класс для редактирования табличных частей документа. Наследует QDataTable.
Definition: wdbtable.h:77
Базовый класс для невизуальных классов (моделей в терминологии MVC) Ананаса, которым необходим доступ...
Definition: aobject.h:63
aSearchWidget(QWidget *parent, wDBTable *table)
Definition: wdbtable.cpp:1853
Определяет программный интерфейс Runtime системы, который используется Ананас скриптом. Наследует QObject.
Definition: engine.h:87