BPS C++ API  2.24.4
bps.h
Go to the documentation of this file.
1 
4 #ifndef BPS_H
5 #define BPS_H
6 
7 #include "bpscore_global.h"
8 #include <QLocale>
9 #include <QVariant>
10 #include <QDateTime>
11 #include <QModelIndex>
12 
13 #define ASCII_NUL char(0)
14 #define ASCII_SOH char(1)
15 #define ASCII_STX char(2)
16 #define ASCII_ETX char(3)
17 #define ASCII_EOT char(4)
18 #define ASCII_ENQ char(5)
19 #define ASCII_ACK char(6)
20 #define ASCII_BEL char(7)
21 #define ASCII_BS char(8)
22 #define ASCII_HT char(9)
23 #define ASCII_LF char(10)
24 #define ASCII_VT char(11)
25 #define ASCII_FF char(12)
26 #define ASCII_CR char(13)
27 #define ASCII_SO char(14)
28 #define ASCII_SI char(15)
29 #define ASCII_DLE char(16)
30 #define ASCII_DC1 char(17)
31 #define ASCII_DC2 char(18)
32 #define ASCII_DC3 char(19)
33 #define ASCII_DC4 char(20)
34 #define ASCII_NAK char(21)
35 #define ASCII_SYN char(22)
36 #define ASCII_ETB char(23)
37 #define ASCII_CAN char(24)
38 #define ASCII_EM char(25)
39 #define ASCII_SUB char(26)
40 #define ASCII_ESC char(27)
41 #define ASCII_FS char(28)
42 #define ASCII_GS char(29)
43 #define ASCII_RS char(30)
44 #define ASCII_US char(31)
45 
46 class BpsDatastore;
47 class BpsDecimal;
48 
53 #define bps Bps::instance()
54 
58 class BPSCORE_EXPORT Bps : public QObject
59 {
60  Q_OBJECT
62 
63 private:
65  Bps(QObject* aParent = nullptr);
66  Bps(const Bps& aBps);
67  Bps& operator=(const Bps& aBps);
68  virtual ~Bps();
70 
71 public:
75  static Bps* instance();
76 
80  enum Status {
81  OK = 0,
82  Error = 1,
83  Timeout = 2,
84  Locked = 3,
85  Notlocked = 4,
86  Notfound = 5
87  };
88 
92  enum NumStatus {
96  NumNaN
97  };
98 
107  RoleSort = Qt::UserRole+100000,
108 
113  RoleFractionDigits = Qt::UserRole+100001,
114 
120  RoleKeyString = Qt::UserRole+100002
121  };
122 
126  enum Access {
127  AccessNone = 0,
128  AccessReadOnly = 1,
129  AccessReadWrite = 2
130  };
131 
136  AlignLeft = 0,
137  AlignCenter = 1,
138  AlignRight = 2
139  };
140 
145  AlignTop = 0,
146  AlignMiddle = 1,
147  AlignBottom = 2
148  };
149 
153  enum Alignment {
154  AlignTopLeft = 0,
155  AlignTopCenter = 1,
156  AlignTopRight = 2,
157  AlignMiddleLeft = 3,
158  AlignMiddleCenter = 4,
159  AlignMiddleRight = 5,
160  AlignBottomLeft = 6,
161  AlignBottomCenter = 7,
162  AlignBottomRight = 8
163  };
164 
168  enum Direction {
169  DirectionEast = 0,
170  DirectionSouth = 1,
171  DirectionWest = 2,
172  DirectionNorth = 3
173  };
174 
178  enum Rotation {
179  Rotation0 = 0,
180  Rotation90 = 1,
181  Rotation180 = 2,
182  Rotation270 = 3
183  };
184 
200  enum EccLevel {
201  EccLevelMin = 0,
202  EccLevelVeryLow = 1,
203  EccLevelLow = 2,
204  EccLevelMedium = 3,
205  EccLevelHigh = 4,
206  EccLevelVeryHigh= 5,
207  EccLevelMax = 6
208  };
209 
219  enum Barcode {
220  // EAN/UPC Group
221  BarcodeEAN13 = 0,
222  BarcodeEAN8 = 1,
223  BarcodeUPCA = 2,
224  BarcodeUPCE0 = 3,
225  BarcodeUPCE1 = 4,
226  BarcodeSUPPL2 = 5,
227  BarcodeSUPPL5 = 6,
228 
229  // Code 39 Group
230  Barcode39 = 7,
231  Barcode39C = 8,
232  Barcode39E = 9,
233  Barcode39EC = 10,
234 
235  // Interleaved 2 of 5 group
236  Barcode2of5 = 11,
237  Barcode2of5C = 12,
238 
239  // Code 128 group
240  Barcode128 = 13,
241  Barcode128S = 14,
242  Barcode128R = 15,
243  BarcodeGS1128 = 16,
244  BarcodeGS1128S = 17,
245 
246  // GS1 DataBar group (formerly RSS)
247  BarcodeGS1DB = 18,
248  BarcodeGS1DBS = 19,
249  BarcodeGS1DBSO = 20,
250  BarcodeGS1DBL = 21,
251  BarcodeGS1DBX = 22,
252  BarcodeGS1DBXS = 23,
253 
254  // QR Code Group
255  BarcodeQR = 24,
256  BarcodeGS1QR = 25,
257 
258  // Data Matrix Group
259  BarcodeDM = 26,
260  BarcodeGS1DM = 27,
261  BarcodeDMR = 28,
262  BarcodeGS1DMR = 29
263  };
264 
268  void clearCache();
269 
276  void sleep(int aSeconds) const;
277 
284  void msleep(int aMilliseconds) const;
285 
290  void usleep(int aMicroseconds) const;
291 
298  void wait(int aSeconds) const;
299 
306  void mwait(int aMilliseconds) const;
307 
314  int encryptPin(int aUserid, int aPin) const;
315 
322  int decryptPin(int aUserid, int aPin) const;
323 
331 
368  QString directory(const QString& aName = QString()) const;
369 
378  QString loadStyleSheet(const QString& aFilename) const;
379 
383  int screenResolution() const;
384 
388  qreal mm2dot() const;
389 
393  qreal dot2mm() const;
394 
401  double round(double aValue, int aDecPlaces = 3) const;
402 
416  QString toString(const QVariant& aValue, int aDecPlaces = -3, int aMaxSize = 17) const;
417 
423  inline bool isNaN(double aValue) const;
424 
444  inline bool isInfinite(double aValue) const;
445 
451  NumStatus numStatus(double aValue) const;
452 
458  NumStatus numStatus(const BpsDecimal& aValue) const;
459 
472  bool isStrictlyEqual(const QVariant& aFirst, const QVariant& aSecond) const;
473 
486  bool isEqual(const QVariant& aFirst, const QVariant& aSecond) const;
487 
498  bool isEqual(const QVariantMap& aFirst, const QVariantMap& aSecond) const;
499 
506  int indexOf(const QString& aCharList, const QString& aChar) const;
507 
514  int indexOf(const QString& aCharList, const QVariant& aChar) const;
515 
524  QString nodeName() const;
525 
534 
543 
549  QString userName() const;
550 
567  QLocale locale() const;
568 
574  QString printerShareName(const QString& aPrinterName) const;
575 
586  bool printFile(const QString& aPrinterName, const QString& aDocName, const QString& aFileName) const;
587 
597  bool printData(const QString& aPrinterName, const QString& aDocName, const QByteArray& aData) const;
598 
610  QString createTempFile(const QString& aTemplate = QString()) const;
611 
616 
621 
626 
631 
636 
644 
649  void setUserStatusPath(const QString& aPath);
650 
655 
662  static int modelIndexLevel(const QModelIndex& aIndex);
663 
678  static bool treeModelIndexLessThan(const QModelIndex& aFirst, const QModelIndex& aSecond);
679 
694  static bool treeModelIndexGreaterThan(const QModelIndex& aFirst, const QModelIndex& aSecond);
695 
702  static QModelIndexList topIndexes(const QModelIndexList& aIndexes);
703 
710  static QModelIndexList bottomIndexes(const QModelIndexList& aIndexes);
711 
717  void emitTableChanged(const QString& aTable);
718 
724  void emitMasterTableChanged(const QString& aTable);
725 
746  QDateTime makeDateTime(const QString& aDateTime);
747 
748 
759  QVariant validatorValue(BpsDatastore* aDatastore, const QString& aTable, const QString& aKey, const QVariant& aDefValue = QVariant());
760 
769  QString trimMultilineText(BpsDatastore* aDatastore, const QString& aTable, const QString& aColumn, const QString& aText);
770 
783  bool isElevated();
784 
791 
799 
806  QMap<QString,QString> lowerKeyStringMap(const QVariantMap& aVariantMap);
807 
814  QMap<QString,QString> toStringMap(const QVariantMap& aVariantMap);
815 
822  QVariantMap toVariantMap(const QMap<QString,QString>& aStringMap);
823 
838  QString stripTimeFormat(const QString& aDateTimeFormat);
839 
840 signals:
841 
845  void tableChanged(const QString& aTable);
846 
850  void masterTableChanged(const QString& aTable);
851 };
852 
854 inline bool Bps::isNaN(double aValue) const { return aValue != aValue; }
855 inline bool Bps::isInfinite(double aValue) const { return !isNaN(aValue) && isNaN(aValue - aValue); }
856 
858 
859 #endif // BPS_H
Public include file for BPS CORE library macros.
#define BPSCORE_EXPORT
Declare class to be an import from the shared library.
Definition: bpscore_global.h:22
#define BPS_PRIVATE(Class)
Declare pointer to private object in a public class.
Definition: bpsglobals.h:102
BPS datastore class.
Definition: bpsdatastore.h:61
A class for decimal arithmetics.
Definition: bpsdecimal.h:87
Singleton Bps object as application global.
Definition: bps.h:59
bool isNaN(double aValue) const
Check if a double value is NaN.
QStringList alignmentTexts() const
QMap< QString, QString > lowerKeyStringMap(const QMap< QString, QString > &aStringMap)
Get a string map where all keys are lower case.
Rotation
Rotation in 90 degree steps.
Definition: bps.h:178
int decryptPin(int aUserid, int aPin) const
Decrypt a user PIN.
QStringList directionTexts() const
void emitMasterTableChanged(const QString &aTable)
Emit the signals masterTableChanged and tableChanged.
bool isEqual(const QVariant &aFirst, const QVariant &aSecond) const
Compare 2 QVariant for non-strict equality (so the QVariant type may differ).
QLocale locale() const
Get the locale to be used.
QMap< QString, QString > toStringMap(const QVariantMap &aVariantMap)
Convert a variant map to a string map.
VerticalAlignment
Vertical alignment.
Definition: bps.h:144
static QModelIndexList bottomIndexes(const QModelIndexList &aIndexes)
Reduces a list of tree indexes to the most bottom elements, by removing the indexes which are higher-...
double round(double aValue, int aDecPlaces=3) const
Round off as per standard commercial practice.
bool canEditInstallSettings()
Check if the the local installation settings are editable.
void tableChanged(const QString &aTable)
Emitted when emitTableChanged or emitMasterTableChanged is called by an application.
static bool treeModelIndexLessThan(const QModelIndex &aFirst, const QModelIndex &aSecond)
Compares two indexes of a tree model.
QString stripTimeFormat(const QString &aDateTimeFormat)
Strip the time format from a date/time format string, creating a date only format.
void emitTableChanged(const QString &aTable)
Emit the signal tableChanged.
Direction
Basic Compass Directions.
Definition: bps.h:168
QBrush invalidInputBackgroundBrush() const
HorizontalAlignment
Horizontal alignment.
Definition: bps.h:135
QDateTime makeDateTime(const QString &aDateTime)
Create QDateTime from a BPS date/time string.
bool isStrictlyEqual(const QVariant &aFirst, const QVariant &aSecond) const
Compare 2 QVariants for strict equality.
Alignment
General alignment.
Definition: bps.h:153
int indexOf(const QString &aCharList, const QVariant &aChar) const
Replacement for QString::indexOf to check for a single char position.
static Bps * instance()
void setUserStatusPath(const QString &aPath)
Set a new user status path.
QVariant validatorValue(BpsDatastore *aDatastore, const QString &aTable, const QString &aKey, const QVariant &aDefValue=QVariant())
Reads a validator setting from the central system settings in Validators/table/key.
QMap< QString, QString > lowerKeyStringMap(const QVariantMap &aVariantMap)
Get a string map where all keys are lower case.
void wait(int aSeconds) const
Wait for a number of seconds.
void masterTableChanged(const QString &aTable)
Emitted when emitMasterTableChanged is called by an application.
void clearCache()
Clears all cached values from the object.
Access
Simple access control.
Definition: bps.h:126
NumStatus numStatus(const BpsDecimal &aValue) const
Returns the numeric status of a BpsDecimal value.
void sleep(int aSeconds) const
Sleep for a number of seconds.
bool isElevated()
Check if the current process is running with elevated or limited privilege.
ItemDataRole
Item data roles.
Definition: bps.h:102
int encryptPin(int aUserid, int aPin) const
Encrypt a user PIN.
QString directory(const QString &aName=QString()) const
Get a BPS application directory.
QString userStatusPath() const
The user status path is convenient to store local user settings additionally separated by database us...
QStringList accessTexts() const
bool isInfinite(double aValue) const
Check if a double value is infinite.
NumStatus numStatus(double aValue) const
Returns the numeric status of a double value.
static QModelIndexList topIndexes(const QModelIndexList &aIndexes)
Reduces a list of tree indexes to the topmost elements, by removing the indexes which are descendants...
bool printData(const QString &aPrinterName, const QString &aDocName, const QByteArray &aData) const
Send data to a printer.
static bool treeModelIndexGreaterThan(const QModelIndex &aFirst, const QModelIndex &aSecond)
Compares two indexes of a tree model.
QString trimMultilineText(BpsDatastore *aDatastore, const QString &aTable, const QString &aColumn, const QString &aText)
Apply a validators multi line text constraints (maxlines and maxperline) to a text and return the tri...
QVariantMap toVariantMap(const QMap< QString, QString > &aStringMap)
Convert a string map to a variant map.
QString computerName() const
Get the computer name.
QString personalFolder() const
Get the personal data folder.
void mwait(int aMilliseconds) const
Wait for a number of milliseconds.
Barcode
Type of the bar code construction element.
Definition: bps.h:219
Status
General purpose return status.
Definition: bps.h:80
bool printFile(const QString &aPrinterName, const QString &aDocName, const QString &aFileName) const
Send a file to a printer.
QString toString(const QVariant &aValue, int aDecPlaces=-3, int aMaxSize=17) const
Get string representation of a QVariant.
QString userName() const
Get the system user name.
static int modelIndexLevel(const QModelIndex &aIndex)
Find the level of a tree model index.
void usleep(int aMicroseconds) const
Sleep for a number of microseconds.
int indexOf(const QString &aCharList, const QString &aChar) const
Replacement for QString::indexOf to check for a single char position.
void msleep(int aMilliseconds) const
Sleep for a number of milliseconds.
QStringList eccLevelTexts() const
QString loadStyleSheet(const QString &aFilename) const
Load a style sheet with the given file name.
NumStatus
Numeric status.
Definition: bps.h:92
@ NumNegInfinite
Negative infinite.
Definition: bps.h:95
@ NumFinite
Finite.
Definition: bps.h:93
@ NumPosInfinite
Positive infinite.
Definition: bps.h:94
QStringList barcodeTexts() const
QString terminalName() const
Get the terminal name.
int screenResolution() const
QString createTempFile(const QString &aTemplate=QString()) const
Creates a temporary file and returns the complete file name.
QString printerShareName(const QString &aPrinterName) const
Get the share name of a printer if it is a network printer.
EccLevel
Error correction code level.
Definition: bps.h:200
qreal dot2mm() const
qreal mm2dot() const
QString nodeName() const
Get the node name.
bool isEqual(const QVariantMap &aFirst, const QVariantMap &aSecond) const
Compare a pair of QVariantMap for non-strict equality.
UserRole