Singleton Bps object as application global. More...
#include <bps.h>
Public Types | |
| enum | Access { AccessNone = 0, AccessReadOnly = 1, AccessReadWrite = 2 } |
| Simple access control. More... | |
| enum | Alignment { AlignTopLeft = 0, AlignTopCenter = 1, AlignTopRight = 2, AlignMiddleLeft = 3, AlignMiddleCenter = 4, AlignMiddleRight = 5, AlignBottomLeft = 6, AlignBottomCenter = 7, AlignBottomRight = 8 } |
| General alignment. More... | |
| enum | Barcode { BarcodeEAN13 = 0, BarcodeEAN8 = 1, BarcodeUPCA = 2, BarcodeUPCE0 = 3, BarcodeUPCE1 = 4, BarcodeSUPPL2 = 5, BarcodeSUPPL5 = 6, Barcode39 = 7, Barcode39C = 8, Barcode39E = 9, Barcode39EC = 10, Barcode2of5 = 11, Barcode2of5C = 12, Barcode128 = 13, Barcode128S = 14, Barcode128R = 15, BarcodeEAN128 = 16, BarcodeEAN128S = 17, BarcodeRSS14 = 18, BarcodeRSS14S = 19, BarcodeRSS14SO = 20, BarcodeRSSLIM = 21 } |
| Type of the bar code construction element. More... | |
| enum | Direction { DirectionEast = 0, DirectionSouth = 1, DirectionWest = 2, DirectionNorth = 3 } |
| Basic Compass Directions. More... | |
| enum | HorizontalAlignment { AlignLeft = 0, AlignCenter = 1, AlignRight = 2 } |
| Horizontal alignment. More... | |
| enum | ItemDataRole { RoleSort = Qt::UserRole+100000, RoleFractionDigits = Qt::UserRole+100001 } |
| Item data roles. More... | |
| enum | Rotation { Rotation0 = 0, Rotation90 = 1, Rotation180 = 2, Rotation270 = 3 } |
| Rotation in 90 degree steps. More... | |
| enum | VerticalAlignment { AlignTop = 0, AlignMiddle = 1, AlignBottom = 2 } |
| Vertical alignment. More... | |
Signals | |
| void | masterTableChanged (const QString &aTable) |
| Emitted when emitMasterTableChanged is called by an application. | |
| void | tableChanged (const QString &aTable) |
| Emitted when emitTableChanged or emitMasterTableChanged is called by an application. | |
Public Member Functions | |
| QStringList | accessTexts () const |
| QStringList | alignmentTexts () const |
| QStringList | barcodeTexts () const |
| void | clearCache () |
| Clears all cached values from the object. | |
| QString | computerName () const |
| Get the computer name. | |
| QString | createTempFile (const QString &aTemplate=QString()) const |
| Creates a temporary file and returns the complete file name. | |
| int | decryptPin (int aUserid, int aPin) const |
| Decrypt a user PIN. | |
| QStringList | directionTexts () const |
| QString | directory (const QString &aName=QString()) const |
| Get a BPS application directory. | |
| qreal | dot2mm () const |
| void | emitMasterTableChanged (const QString &aTable) |
| Emit the signals masterTableChanged and tableChanged. | |
| void | emitTableChanged (const QString &aTable) |
| Emit the signal tableChanged. | |
| int | encryptPin (int aUserid, int aPin) const |
| Encrypt a user PIN. | |
| QBrush | invalidInputBackgroundBrush () const |
| bool | isElevated () |
| Check if the current process is running with elevated or limited privilege. | |
| bool | isEqual (const QVariant &aFirst, const QVariant &aSecond) const |
| Compare 2 QVariants for non-strict equality (e.g. | |
| bool | isStrictlyEqual (const QVariant &aFirst, const QVariant &aSecond) const |
| Compare 2 QVariants for strict equality. | |
| QString | loadStyleSheet (const QString &aFilename) const |
| Load a style sheet with the given file name. | |
| QMap< QString, QString > | lowerKeyStringMap (const QMap< QString, QString > &aStringMap) |
| Get a string map where all keys are lower case. | |
| QMap< QString, QString > | lowerKeyStringMap (const QVariantMap &aVariantMap) |
| Get a string map where all keys are lower case. | |
| QDateTime | makeDateTime (const QString &aDateTime) |
| Create QDateTime from a BPS date/time string. | |
| qreal | mm2dot () const |
| void | msleep (int aMilliseconds) const |
| Sleep for a number of milliseconds. | |
| void | mwait (int aMilliseconds) const |
| Wait for a number of milliseconds. | |
| QString | nodeName () const |
| Get the node name. | |
| QString | personalFolder () const |
| Get the personal data folder. | |
| QString | printerShareName (const QString &aPrinterName) const |
| Get the share name of a printer if it is a network printer. | |
| bool | printFile (const QString &aPrinterName, const QString &aDocName, const QString &aFileName) const |
| Send a file to a printer. | |
| qreal | round (qreal aValue, int aDigits=3) const |
| Round off as per standard commercial practice. | |
| int | screenResolution () const |
| void | setUserStatusPath (const QString &aPath) |
| Set a new user status path. | |
| void | sleep (int aSeconds) const |
| Sleep for a number of seconds. | |
| QString | stripTimeFormat (const QString &aDateTimeFormat) |
| Strip the time format from a date/time format string, creating a date only format. | |
| QString | terminalName () const |
| Get the terminal name. | |
| QString | toString (double aValue, int aFractionalDigits=3) const |
| Convert a double floating point to string. | |
| QMap< QString, QString > | toStringMap (const QVariantMap &aVariantMap) |
| Convert a variant map to a string map. | |
| QVariantMap | toVariantMap (const QMap< QString, QString > &aStringMap) |
| Convert a string map to a variant map. | |
| 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 trimmed text. | |
| QString | userName () const |
| Get the system user name. | |
| QString | userStatusPath () const |
| The user status path is convenient to store local user settings additionally separated by database user name. | |
| void | usleep (int aMicroseconds) const |
| Sleep for a number of microseconds. | |
| 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. | |
| void | wait (int aSeconds) const |
| Wait for a number of seconds. | |
Static Public Member Functions | |
| static QModelIndexList | bottomIndexes (const QModelIndexList &aIndexes) |
| Reduces a list of tree indexes to the most bottom elements, by removing the indexes which are higher-ups of another index in the list. | |
| static Bps * | instance () |
| static int | modelIndexLevel (const QModelIndex &aIndex) |
| Find the level of a tree model index. | |
| static QModelIndexList | topIndexes (const QModelIndexList &aIndexes) |
| Reduces a list of tree indexes to the topmost elements, by removing the indexes which are descendants of another index in the list. | |
| static bool | treeModelIndexGreaterThan (const QModelIndex &aFirst, const QModelIndex &aSecond) |
| Compares two indexes of a tree model. | |
| static bool | treeModelIndexLessThan (const QModelIndex &aFirst, const QModelIndex &aSecond) |
| Compares two indexes of a tree model. | |
Related Functions | |
(Note that these are not member functions.) | |
| #define | bps Bps::instance() |
| Convenience notation for Bps::instance() | |
Singleton Bps object as application global.
| enum Bps::Access |
| enum Bps::Alignment |
General alignment.
| enum Bps::Barcode |
Type of the bar code construction element.
| enum Bps::Direction |
| enum Bps::ItemDataRole |
Item data roles.
| RoleSort |
The data used for custom item sorting.
|
| RoleFractionDigits |
Number of fraction digits to use for display of numeric values.
|
| enum Bps::Rotation |
| QStringList Bps::accessTexts | ( | ) | const |
| QStringList Bps::alignmentTexts | ( | ) | const |
| QStringList Bps::barcodeTexts | ( | ) | const |
| static QModelIndexList Bps::bottomIndexes | ( | const QModelIndexList & | aIndexes | ) | [static] |
Reduces a list of tree indexes to the most bottom elements, by removing the indexes which are higher-ups of another index in the list.
| [in] | aIndexes | The index list to process. |
| QString Bps::computerName | ( | ) | const |
Get the computer name.
The computer name taken from the environment variables COMPUTERNAME. For fat clients COMPUTERNAME is the name of the workstation. For thin clients COMPUTERNAME is the name of the terminal server.
| QString Bps::createTempFile | ( | const QString & | aTemplate = QString() | ) | const |
Creates a temporary file and returns the complete file name.
It is purpose of the application to delete the file when it is no longer needed.
In most cases it will be more convenient to use QTemporaryFile, however there are special cases like when printing where you need to provide a file name and the class will open, write and close the file itself.
| [in] | aTemplate | A file name template, as in QTemporaryFile. |
| int Bps::decryptPin | ( | int | aUserid, |
| int | aPin | ||
| ) | const |
Decrypt a user PIN.
| [in] | aUserid | The user id. |
| [in] | aPin | The encrypted PIN. |
| QStringList Bps::directionTexts | ( | ) | const |
| QString Bps::directory | ( | const QString & | aName = QString() | ) | const |
Get a BPS application directory.
The path is first searched in the environment where aName is prefixed with "BPS_".
When the path was not found in the environment variables, it is searched in the file bps.conf which is in the directory where the executable was started from. The key aName is expected in section [Paths].
If the found path is relative (not starting with a drive or slash/backslash), it is assumed to be relative to the BPS installation directory (one above the exe's). The returned path is made absolute under this premise.
Example 1: Relative path in environment variable
| aName | Logs |
| Environment variable BPS_LOGS= | mylogs |
| BPS installation directory | C:\Program Files\IBK BPS 2.0.0 |
| Returned path | C:/Program Files/IBK BPS 2.0.0/mylogs |
Example 2: Relative path in bps.conf
| aName | Logs |
| Environment variable BPS_LOGS= | (not found) |
| bps.conf: [Paths] ... Logs= | logs |
| BPS installation directory | C:\Program Files\IBK BPS 2.0.0 |
| Returned path | C:/Program Files/IBK BPS 2.0.0/logs |
| [in] | aName | Logical path name, for example: Logs, CSS, Plugins or Scripts. Get the BPS installation directory if aName is empty. |
| qreal Bps::dot2mm | ( | ) | const |
| void Bps::emitMasterTableChanged | ( | const QString & | aTable | ) |
Emit the signals masterTableChanged and tableChanged.
Called by applications when a master data table has been changed.
| [in] | aTable | Name of the table changed. |
| void Bps::emitTableChanged | ( | const QString & | aTable | ) |
Emit the signal tableChanged.
Called by applications when data of a table has been changed.
| [in] | aTable | Name of the table changed. |
| int Bps::encryptPin | ( | int | aUserid, |
| int | aPin | ||
| ) | const |
Encrypt a user PIN.
| [in] | aUserid | The user id. |
| [in] | aPin | The unencrypted PIN. |
| QBrush Bps::invalidInputBackgroundBrush | ( | ) | const |
| bool Bps::isElevated | ( | ) |
Check if the current process is running with elevated or limited privilege.
Elevated: Either UAC is enabled and the process was elevated by the administrator, or UAC is disabled and the process was started by a user who is a member of the Administrators group.
Not elevated (limited): Either UAC is enabled and the process was started normally without the elevation, or UAC is disabled and the process was started by a standard user.
| bool Bps::isEqual | ( | const QVariant & | aFirst, |
| const QVariant & | aSecond | ||
| ) | const |
Compare 2 QVariants for non-strict equality (e.g.
type may differ). They are considered equal when both are null, or both are not null and have same value.
| [in] | aFirst | First value to compare. |
| [in] | aSecond | Second value to compare against. |
| bool Bps::isStrictlyEqual | ( | const QVariant & | aFirst, |
| const QVariant & | aSecond | ||
| ) | const |
Compare 2 QVariants for strict equality.
They are considered equal when both are of same type and value.
QBrush need to have the same transform too.
For user types the equality is tested by the plain type == operators.
Supported user types: BpsMargins
| [in] | aFirst | First value to compare. |
| [in] | aSecond | Second value to compare against. |
| QString Bps::loadStyleSheet | ( | const QString & | aFilename | ) | const |
Load a style sheet with the given file name.
If the filename does not have an extension, .css will be added. If the file name is no absolute path, the file will first be searched from the current directory, and then in the logical path CSS.
| [in] | aFilename | The file name of the style sheet. |
| QMap<QString,QString> Bps::lowerKeyStringMap | ( | const QMap< QString, QString > & | aStringMap | ) |
Get a string map where all keys are lower case.
Keys and values of the returned string map are trimmed, e.g. the leading and trailing whitespace is removed
| [in] | aStringMap | The map with probably mixed case keys. |
| QMap<QString,QString> Bps::lowerKeyStringMap | ( | const QVariantMap & | aVariantMap | ) |
Get a string map where all keys are lower case.
Keys and values of the returned string map are trimmed, e.g. the leading and trailing whitespace is removed
| [in] | aVariantMap | The variant map with probably mixed case keys. |
| QDateTime Bps::makeDateTime | ( | const QString & | aDateTime | ) |
Create QDateTime from a BPS date/time string.
The input is assumed to be of format YYYY.MM.DD HH:MM:SS, but may contain + or - signs for each portion to indicate relative years/months/days/hours/minutes/seconds the add subtract to the current date time. First the relative numbers get added or subtracted to/from the current date, then the absolute numbers get set.
In the following examples the current date/time is assumed to be 2009.05.28 07:47:32
| aDateTime | Return |
|---|---|
| 2010.03.01 12:10:00 | 2010.03.01 12:10:00 |
| +0000.+00.+00 +00:+00:+00 | 2009.05.28 07:47:32 |
| -0010.-00.-00 00:00:00 | 1999.05.28 00:00:00 |
| +0000.+00.+01 12:00:00 | 2009.05.29 12:00:00 |
| [in] | aDateTime | The date/time string. |
| qreal Bps::mm2dot | ( | ) | const |
| static int Bps::modelIndexLevel | ( | const QModelIndex & | aIndex | ) | [static] |
Find the level of a tree model index.
The root item has level 0, children of root have level 1, grandchildren have level 2 and so on.
| [in] | aIndex | The tree model index of interest. |
| void Bps::msleep | ( | int | aMilliseconds | ) | const |
Sleep for a number of milliseconds.
No event processing will be done so the application will be unresponsive. Use mwait() in case to for non-blocking sleeping.
| [in] | aMilliseconds | The time to sleep. |
| void Bps::mwait | ( | int | aMilliseconds | ) | const |
Wait for a number of milliseconds.
While waiting, events will be processed and the application will stay responsive to user interface events and network communication.
| [in] | aMilliseconds | The time to wait. |
| QString Bps::nodeName | ( | ) | const |
Get the node name.
The node name is made up by the three parts computerName(), terminalName() and sysUserName() joined together by dots, for example WS12325.TC005.pmiller. Equal parts are omitted, for example if computerName() is equal to terminalName(), only one of them is shown.
| QString Bps::personalFolder | ( | ) | const |
Get the personal data folder.
Under windows this is the path of "My documents" or "Eigene Dateien". Under other operating systems this function is equivalent to QDir::homePath().
| QString Bps::printerShareName | ( | const QString & | aPrinterName | ) | const |
Get the share name of a printer if it is a network printer.
| [in] | aPrinterName | The given printer name. |
| bool Bps::printFile | ( | const QString & | aPrinterName, |
| const QString & | aDocName, | ||
| const QString & | aFileName | ||
| ) | const |
Send a file to a printer.
The printer may be any local or network printer known to the workstation.
| [in] | aPrinterName | The name of the printer. |
| [in] | aDocName | The document name as shown in the spooler. The document name will be prefixed with the node name, for example when the document name is "My Report", the spooler might show "SPEEDY.Console.kochp: My Report". |
| [in] | aFileName | The name of the file to send. |
| qreal Bps::round | ( | qreal | aValue, |
| int | aDigits = 3 |
||
| ) | const |
Round off as per standard commercial practice.
| [in] | aValue | The value to round off. |
| [in] | aDigits | Number of digits behind the decimal point. |
| int Bps::screenResolution | ( | ) | const |
| void Bps::setUserStatusPath | ( | const QString & | aPath | ) |
Set a new user status path.
| [in] | aPath | The new user status path to set. |
| void Bps::sleep | ( | int | aSeconds | ) | const |
Sleep for a number of seconds.
No event processing will be done so the application will be unresponsive. Use wait() in case to for non-blocking sleeping.
| [in] | aSeconds | The time to sleep. |
| QString Bps::stripTimeFormat | ( | const QString & | aDateTimeFormat | ) |
Strip the time format from a date/time format string, creating a date only format.
Leading delimiter chars (in " -.,:;") before the first time format char (in "hHmszt"), and all characters between the first and last time format char are removed.
Examples:
fmt = stripTimeFormat(bStr("dd.MM.yyyy hh:mm"); // fmt = "dd.MM.yyyy" fmt = stripTimeFormat(bStr("dd.MM.yyyy-hh:mm"); // fmt = "dd.MM.yyyy" fmt = stripTimeFormat(bStr("XXX dd.MM # hh:mm-yyyy-zzz ++"); // fmt = "XXX dd.MM # ++"
| [in] | aDateTimeFormat | The date/time format string. |
| QString Bps::terminalName | ( | ) | const |
Get the terminal name.
The terminal name is taken from the environment variable CLIENTNAME, if such is present and it is not "Console". Otherwise it is set equal to computerName().
| static QModelIndexList Bps::topIndexes | ( | const QModelIndexList & | aIndexes | ) | [static] |
Reduces a list of tree indexes to the topmost elements, by removing the indexes which are descendants of another index in the list.
| [in] | aIndexes | The index list to process. |
| QString Bps::toString | ( | double | aValue, |
| int | aFractionalDigits = 3 |
||
| ) | const |
Convert a double floating point to string.
When aFractionalDigits is >= 0, the number is converted by QString::number(aValue,'f',aFractionalDigits). If the digits after the decimal point are all 0, the fractional part is removed. This can be summarized as: If it looks like an integer, return an integer else the floating point with the fixed number of digits after decimal point.
When aFractionalDigits is < 0, the number is converted by QString::number(aValue,'f',qAbs(aFractionalDigits)). After conversion trailing 0 decimals are removed. This can be summarized as: If it looks like an integer, return an integer, otherwise the floating point with the variable number of digits (1...precision) after decimal point.
| [in] | aValue | The value to convert |
| [in] | aFractionalDigits | Number of fractional digits . |
| QMap<QString,QString> Bps::toStringMap | ( | const QVariantMap & | aVariantMap | ) |
Convert a variant map to a string map.
The case of the keys is retained.
| [in] | aVariantMap | The variant map to convert. |
| QVariantMap Bps::toVariantMap | ( | const QMap< QString, QString > & | aStringMap | ) |
Convert a string map to a variant map.
The case of the keys is retained.
| [in] | aStringMap | The string map to convert. |
| static bool Bps::treeModelIndexGreaterThan | ( | const QModelIndex & | aFirst, |
| const QModelIndex & | aSecond | ||
| ) | [static] |
Compares two indexes of a tree model.
This is useful for sorting a QModelIndexList of a tree model in descending order.
Example:
QModelIndexList list; // list populated with arbitrary indexes qSort(list.begin(), list.end(), Bps::treeModelIndexGreaterThan);
| [in] | aFirst | The first index. |
| [in] | aSecond | The second index. |
| static bool Bps::treeModelIndexLessThan | ( | const QModelIndex & | aFirst, |
| const QModelIndex & | aSecond | ||
| ) | [static] |
Compares two indexes of a tree model.
This is useful for sorting a QModelIndexList of a tree model in ascending order.
Example:
QModelIndexList list; // list populated with arbitrary indexes qSort(list.begin(), list.end(), Bps::treeModelIndexLessThan);
| [in] | aFirst | The first index. |
| [in] | aSecond | The second index. |
| QString Bps::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 trimmed text.
| [in] | aDatastore | The datastore to use. |
| [in] | aTable | The table name for the validator settings to use. |
| [in] | aColumn | The column name for the validator settings to use. |
| [in] | aText | The text to check and in case trim. |
| QString Bps::userName | ( | ) | const |
Get the system user name.
The system user name taken from the environment variable USERNAME.
| QString Bps::userStatusPath | ( | ) | const |
The user status path is convenient to store local user settings additionally separated by database user name.
After construction of the bps Object, the default is initialized to "Status", and by convention the main application (workplace for example) will set it to "Status/dbUserName" after login.
| void Bps::usleep | ( | int | aMicroseconds | ) | const |
Sleep for a number of microseconds.
| [in] | aMicroseconds | The time to sleep. |
| QVariant Bps::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.
The read values are cached for speed.
| [in] | aDatastore | The datastore to operate on. |
| [in] | aTable | The table name. |
| [in] | aKey | The key name, mostly something as "c_fieldname.mask" for example. |
| [in] | aDefValue | A default value to return if no value is found or it is empty. |
| BpsException | On datastore errors. |
| void Bps::wait | ( | int | aSeconds | ) | const |
Wait for a number of seconds.
While waiting, events will be processed and the application will stay responsive to user interface events and network communication.
| [in] | aSeconds | The time to wait. |