00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00033 #ifndef AFORM_H
00034 #define AFORM_H
00035
00036 #include "ananasglobal.h"
00037
00038 #include <qobject.h>
00039 #include <qbuttongroup.h>
00040 #include <qsproject.h>
00041 #include <qsinterpreter.h>
00042 #include <qsargument.h>
00043 #include <qmutex.h>
00044 #include <qdialog.h>
00045
00046 #include "engine.h"
00047 #include "adatabase.h"
00048 #include "adocument.h"
00049 #include "acfg.h"
00050
00051
00052 class QWidget;
00053 class QSqlForm;
00054 class aWidget;
00055 class EventDialog;
00056
00057
00075 class ANANAS_EXPORT aForm : public QObject
00076 {
00077 Q_OBJECT
00078 public:
00079 aEngine* engine;
00080 aDatabase* db;
00081 aCfg* md;
00082 aCfgItem mdObj;
00083 QWidget* parentWidget;
00084 bool closeAfterSelect;
00085
00086 aForm();
00087 aForm( QWidget *parent, aEngine *eng );
00088 aForm( QWidget *parent, aEngine *eng, Q_ULONG form_mid = 0, aWidget* caller = NULL);
00089 aForm( QWidget *parent, aEngine *eng, QString oftype, QObject *aobj = NULL);
00090 ~aForm();
00091 QWidget *form;
00092 void init();
00093 QWidget* aParent( QWidget *widget );
00094 int New();
00095 int Select( Q_ULLONG id );
00096 int SelectGroup( Q_ULLONG id );
00097 Q_ULLONG selectedCatId(){ return db_uid;}
00098 Q_ULLONG selectedId(){ return id;}
00099 signals:
00100 void selected( Q_ULLONG uid );
00101 void closeForm( Q_ULLONG );
00102 void changedData();
00103 void update( ANANAS_UID );
00104 public:
00105
00106 QVariant tabValue(const QString &tname, int row, int col, bool dbval=false);
00107 void setMode(int m);
00108
00109 public slots:
00110
00111 void done( int rc );
00112 void Show(bool modal=FALSE);
00113 bool Close();
00114 void show();
00115 void close();
00116 void maximize(bool m);
00117 QVariant Value(const QString &name);
00118 QVariant DBValue(const QString &name);
00119 int SetValue(const QString &name, QVariant value);
00120 int SetObjValue(const QString &name, aObject *value);
00121 void SetColumnReadOnly(const QString &tname, int numCol, bool ro);
00122 int ColIndex(const QString &tname, const QString &colname);
00123 int TabCount(const QString &tname);
00124
00125 QVariant TabValue(const QString &tname, int row, int col);
00126 QVariant TabDBValue(const QString &tname, int row, int col);
00127 void TabNewLine(const QString &tname);
00128 void TabUpdate(const QString &tname);
00129
00130
00131 void SetTabValue(const QString &tname, const QString &colname, int row, QVariant value);
00132 void setfocus(QString fname);
00133 void SetFocus();
00134 ERR_Code UpdateDB();
00135 ERR_Code update();
00136 int turn_on();
00137 int turn_off();
00138 int SignIn();
00139 int SignOut();
00140
00141 int Update();
00142 void SetReadOnly( bool status );
00143 bool IsReadOnly();
00144 int GetMode();
00145
00146 QString Propis( QString val ,
00147 bool need_kopeyki=true,
00148 bool male=true,
00149 const QString &end1="рублей",
00150 const QString &end2="рубль",
00151 const QString &end3="рубля");
00152 QString MoneyToText( QString amount , QString currency );
00153 QString ConvertNumber2MoneyFormat(double number);
00154 QString ConvertDateFromIso(const QString &ISODate);
00155 QString EndOfDay(const QString& ISODate);
00156
00157 void SelectByCurrent(aObject *doc);
00158 void SetCurrent(aObject *doc);
00159 aObject* Current();
00160
00161 QWidget* Widget( QString name );
00162 bool FormHasFunction(const QString functionName);
00163
00164
00165
00166
00167
00173
00174 private slots:
00175 void on_dbtablerow( QSqlRecord *r );
00176 void on_tabupdate( QSqlRecord *r );
00177 void on_button();
00178 void on_actionbutton();
00179 bool on_form_close();
00180 void on_return();
00181 void on_lostfocus();
00182 void on_valueChanged(const QString &s);
00183 void on_valueChanged( const QString & name, const QVariant & value );
00184 void on_tabvalueChanged(int row, int col);
00185 void on_tabselected( Q_ULLONG uid );
00186 void on_event( const QString &source, const QString &data );
00187 void on_tablerow( Q_ULLONG uid );
00188
00189
00190
00191 void connectSlots();
00192 protected:
00193 virtual void initWidget( QWidget *widget, aDatabase *adb );
00194 virtual void initContainer( aWidget *widget, aDatabase *adb );
00195 aWidget *parentContainer( QWidget *widget );
00196 private:
00197 QObject* dbobject;
00198 int tobj, objid;
00199 int mode;
00200 Q_ULLONG id;
00201 Q_ULLONG db_uid;
00202 bool RO;
00203 aWidget* mainWidget;
00204 aWidget* callerWidget;
00205 bool modal;
00206 EventDialog * dlg;
00207 };
00208
00217 class EventDialog : public QDialog
00218 {
00219 Q_OBJECT
00220 public:
00221 EventDialog(QWidget * w, const char * c, bool m = false) : QDialog(w, c, m) {};
00222 ~EventDialog() {};
00223 signals:
00224 bool closed();
00225 protected:
00226 virtual void closeEvent(QCloseEvent * e) { if(emit(closed())) QDialog::closeEvent(e); else e->ignore(); };
00227 };
00228
00237 class EventWindow : public QMainWindow
00238 {
00239 Q_OBJECT
00240 public :
00241 EventWindow(QWidget * parent = 0, const char * name = 0, WFlags f = WType_TopLevel) : QMainWindow(parent, name, f) {};
00242 ~EventWindow() {};
00243 signals:
00244 bool closed();
00245 protected:
00246 virtual void closeEvent(QCloseEvent * e) { if(emit(closed())) QMainWindow::closeEvent(e); else e->ignore(); };
00247 };
00248
00249 #endif // AFORM_H