Ananas Library  0.9.5
aform.h
1 /****************************************************************************
2 ** $Id: aform.h,v 1.33 2008/05/26 08:37:14 app Exp $
3 **
4 ** Header file of Ananas forms 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-2005 Grigory Panov <gr1313 at mail.ru>, Yoshkar-Ola.
11 **
12 ** This file is part of the Library 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 
33 #ifndef AFORM_H
34 #define AFORM_H
35 
36 #include "ananasglobal.h"
37 
38 #include <qobject.h>
39 #include <qbuttongroup.h>
40 #include <qsproject.h>
41 #include <qsinterpreter.h>
42 #include <qsargument.h>
43 #include <qmutex.h>
44 #include <qdialog.h>
45 
46 #include "engine.h"
47 #include "adatabase.h"
48 #include "adocument.h"
49 #include "acfg.h"
50 
51 
52 class QWidget;
53 class QSqlForm;
54 class aWidget;
55 class EventDialog;
56 
57 
75 class ANANAS_EXPORT aForm : public QObject
76 {
77  Q_OBJECT
78 public:
79  aEngine* engine;
80  aDatabase* db;
81  aCfg* md;
82  aCfgItem mdObj;
83  QWidget* parentWidget;
84  bool closeAfterSelect;
85 
86  aForm();
87  aForm( QWidget *parent, aEngine *eng );
88  aForm( QWidget *parent, aEngine *eng, Q_ULONG form_mid = 0, aWidget* caller = NULL);
89  aForm( QWidget *parent, aEngine *eng, QString oftype, QObject *aobj = NULL);
90  ~aForm();
91  QWidget *form;
92  void init();
93  QWidget* aParent( QWidget *widget );
94  int New();
95  int Select( Q_ULLONG id );
96  int SelectGroup( Q_ULLONG id );
97  Q_ULLONG selectedCatId(){ return db_uid;} // Return uid, selected in Catalogue
98  Q_ULLONG selectedId(){ return id;} // Return uid, selected in main wDBTable
99 signals:
100  void selected( Q_ULLONG uid );
101  void closeForm( Q_ULLONG );
102  void changedData();
103  void update( ANANAS_UID );
104 public:
105 
106  QVariant tabValue(const QString &tname, int row, int col, bool dbval=false);
107  void setMode(int m);
108 
109 public slots:
110 // QObject * object(const QString &name);
111  void done( int rc );
112  void Show(bool modal=FALSE);
113  bool Close();
114  void show(); //depricated
115  void close(); //depricated
116  void maximize(bool m);
117  QVariant Value(const QString &name);
118  QVariant DBValue(const QString &name);
119  int SetValue(const QString &name, QVariant value);
120  int SetObjValue(const QString &name, aObject *value);
121  void SetColumnReadOnly(const QString &tname, int numCol, bool ro);
122  int ColIndex(const QString &tname, const QString &colname);
123  int TabCount(const QString &tname);
124 // QVariant TabValue(const QString &tname, const QString &colname, int row =-1 );
125  QVariant TabValue(const QString &tname, int row, int col);
126  QVariant TabDBValue(const QString &tname, int row, int col);
127  void TabNewLine(const QString &tname);
128  void TabUpdate(const QString &tname);
129 // QVariant TabDBValue(const QString &tname, const QString &colname , int row =-1);
130 // void SetTabValue(const QString &tname, const QString &name, QVariant value);
131  void SetTabValue(const QString &tname, const QString &colname, int row, QVariant value);
132  void setfocus(QString fname);
133  void SetFocus();
134  ERR_Code UpdateDB(); // Обновить в БД
135  ERR_Code update(); // Depricated
136  int turn_on(); // Depricated
137  int turn_off(); // Depricated
138  int SignIn(); // Провести документ
139  int SignOut(); // Отменить проведение документа
140 // void formClose();
141  int Update();
142  void SetReadOnly( bool status );
143  bool IsReadOnly();
144  int GetMode();
145 
146  QString Propis( QString val ,
147  bool need_kopeyki=true,
148  bool male=true,
149  const QString &end1="рублей",
150  const QString &end2="рубль",
151  const QString &end3="рубля");
152  QString MoneyToText( QString amount , QString currency );
153  QString ConvertNumber2MoneyFormat(double number);
154  QString ConvertDateFromIso(const QString &ISODate);
155  QString EndOfDay(const QString& ISODate);
156 
157  void SelectByCurrent(aObject *doc);
158  void SetCurrent(aObject *doc);
159  aObject* Current();
160 
161  QWidget* Widget( QString name );
162  bool FormHasFunction(const QString functionName);
163 
164 // after compleete will remove value() setValue()
165 // aDataField* getAttribute(const QString &name);
166 // int setAttribute(const QString &name, aDataField *value);
167 
173 // char* formMetaObjectId(QString fn);
174 private slots:
175  void on_dbtablerow( QSqlRecord *r );
176  void on_tabupdate( QSqlRecord *r );
177  void on_button();//int id);
178  void on_actionbutton();
179  bool on_form_close();
180  void on_return();
181  void on_lostfocus();
182  void on_valueChanged(const QString &s);
183  void on_valueChanged( const QString & name, const QVariant & value );
184  void on_tabvalueChanged(int row, int col);
185  void on_tabselected( Q_ULLONG uid );
186  void on_event( const QString &source, const QString &data );
187  void on_tablerow( Q_ULLONG uid );
188 // QObject *findWidget(QString name);
189 // QString widgetName(QObject *w);
190 // void openForm( int oid, int fid = 0 , int defaultfor = 1, int mode = 0, bool readonly = false );
191  void connectSlots();
192 protected:
193  virtual void initWidget( QWidget *widget, aDatabase *adb );
194  virtual void initContainer( aWidget *widget, aDatabase *adb );
195  aWidget *parentContainer( QWidget *widget );
196 private:
197  QObject* dbobject;
198  int tobj, objid;
199  int mode;
200  Q_ULLONG id;
201  Q_ULLONG db_uid;
202  bool RO;
203  aWidget* mainWidget;
204  aWidget* callerWidget;
205  bool modal;
206  EventDialog * dlg;
207 };
208 
217 class EventDialog : public QDialog
218 {
219  Q_OBJECT
220 public:
221  EventDialog(QWidget * w, const char * c, bool m = false) : QDialog(w, c, m) {};
222  ~EventDialog() {};
223 signals:
224  bool closed();
225 protected:
226  virtual void closeEvent(QCloseEvent * e) { if(emit(closed())) QDialog::closeEvent(e); else e->ignore(); };
227 };
228 
237 class EventWindow : public QMainWindow
238 {
239  Q_OBJECT
240 public :
241  EventWindow(QWidget * parent = 0, const char * name = 0, WFlags f = WType_TopLevel) : QMainWindow(parent, name, f) {};
242  ~EventWindow() {};
243 signals:
244  bool closed();
245 protected:
246  virtual void closeEvent(QCloseEvent * e) { if(emit(closed())) QMainWindow::closeEvent(e); else e->ignore(); };
247 };
248 
249 #endif // AFORM_H
Определяет программный интерфейс экранных форм Ананас...
Definition: aform.h:75
Класс реализует програмный интерфейс доступа к элемен...
Definition: acfg.h:436
Класс для работы с СУБД. Ananas Data Abstraction Layer. Наследует QObject...
Definition: adatabase.h:77
Класс наследует QMainWindow, единственный добавленный функц...
Definition: aform.h:237
Базовый класс для визуальных объектов. Наследует QWidget...
Definition: awidget.h:52
Базовый класс для невизуальных классов (моделей в терм...
Definition: aobject.h:63
Класс наследует QDialog, единственный добавленный функцио...
Definition: aform.h:217
Определяет программный интерфейс Runtime системы, который используется Ананас скриптом. Наследует QObject.
Definition: engine.h:87