File: screen.h

package info (click to toggle)
postbooks 4.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 112,660 kB
  • ctags: 22,890
  • sloc: cpp: 310,358; sh: 607; xml: 214; python: 140; awk: 104; makefile: 50
file content (118 lines) | stat: -rw-r--r-- 4,470 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * This file is part of the xTuple ERP: PostBooks Edition, a free and
 * open source Enterprise Resource Planning software suite,
 * Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
 * It is licensed to you under the Common Public Attribution License
 * version 1.0, the full text of which (including xTuple-specific Exhibits)
 * is available at www.xtuple.com/CPAL.  By using this software, you agree
 * to be bound by its terms.
 */

#ifndef SCREEN_H
#define SCREEN_H

#include "widgets.h"
#include "xdatawidgetmapper.h"
#include "xsqltablemodel.h"
#include <xsqlquery.h>

#include <QWidget>
#include <QSqlDatabase>
#include <QSqlIndex>
#include <QList>

class XTUPLEWIDGETS_EXPORT Screen : public QWidget
{
	Q_OBJECT
		
	Q_ENUMS(Modes)
	Q_ENUMS(SearchTypes)
        Q_ENUMS(Disposition)
	
	Q_PROPERTY (QString		schemaName            READ schemaName		WRITE setSchemaName)
	Q_PROPERTY (QString 		tableName             READ tableName 		WRITE setTableName)
        Q_PROPERTY (int                 primaryKeyColumns     READ primaryKeyColumns    WRITE setPrimaryKeyColumns)
	Q_PROPERTY (Modes		mode                  READ mode                 WRITE setMode)              
        Q_PROPERTY (bool                lockRecords           READ lockRecords          WRITE setLockRecords);

	public:
		Screen(QWidget * = 0);
                ~Screen();
		
                bool throwScriptException(const QString &message);
		enum Modes { New, Edit, View };
                enum Disposition { NoChanges, Save, Cancel };
		Modes mode();

                Q_INVOKABLE bool submit();
                Q_INVOKABLE bool locked()                { return _locked;}
                Q_INVOKABLE bool lockRecords()           { return _lock;}
                Q_INVOKABLE Disposition check();
                Q_INVOKABLE XDataWidgetMapper *mapper()  { return _mapper;}
                Q_INVOKABLE XSqlTableModel    *model()   { return _model;}
                
                void showEvent ( QShowEvent * event );
       	
	public slots:
                bool cancel();
                bool isDirty();
                bool tryLock();
                int  currentIndex();
                int  primaryKeyColumns()    const { return _keyColumns;       }
                QString filter()            const { return _model->filter();  }
                QString schemaName()        const { return _schemaName;       }
                QString sortColumn()        const { return _sortColumn;       }
                QString tableName()         const { return _tableName;        }
                void clear();
                void deleteCurrent();
                void insert();
                void loadAll();
                void newMappedWidget(QWidget *widget);
                void removeCurrent();
                void removeRows(int row, int count);
                void revert();
                void revertAll();
                void revertRow(int row);
		void toNext();
		void toPrevious();
		void save();
		void search(QString criteria);
		void select();
                void setCurrentIndex(int index);
                void setFilter(QString filter)          { _model->setFilter(filter);      }
                void setLockRecords(bool lock);
                void setModel(XSqlTableModel *model);
		void setMode(Modes p);
                void setPrimaryKeyColumns(int count)    { _keyColumns = count;           }
		void setSchemaName(QString schema);
		void setSortColumn(QString p);
		void setTableName(QString table);
		void setTable(QString schema, QString table);
		void setDataWidgetMapper(XSqlTableModel *model);
                void setWidgetsEnabled(bool enabled);
                void unlock();
	
	signals:
                void currentIndexChanged(int index);
                void lockGranted(bool);
		void newDataWidgetMapper(XDataWidgetMapper *mapper);
                void newModel(XSqlTableModel *model);
		void saved();
                void revertedAll();
                void reverted(int index);

	private:
                bool                    _shown;
		enum  Modes		_mode;
                int                     _keyColumns;
                bool                    _lock;
                bool                    _locked;
                qint64                  _key;
		QString			_schemaName;
                QString                 _sortColumn;
		QString			_tableName;
		XDataWidgetMapper*	_mapper;
                XSqlTableModel*		_model;
};

#endif // SCREEN_H