The ScriptToolbox provides a collection of miscellaneous utility methods used when writing xTuple ERP extension scripts. More...
#include <scripttoolbox.h>
Public Member Functions | |
ScriptToolbox (QScriptEngine *engine) | |
Create a new ScriptToolbox. | |
virtual | ~ScriptToolbox () |
Q_INVOKABLE int | decimalPlaces (QString p) |
This is a wrapper for the C++ core function decimalPlaces. | |
Q_INVOKABLE QString | formatCost (double val, int curr=-1) |
This is a wrapper for the C++ core function formatCost. | |
Q_INVOKABLE QString | formatDate (const QDate &pDate) |
This is a wrapper for the C++ core function formatDate. | |
Q_INVOKABLE QString | formatExtPrice (double val, int curr=-1) |
This is a wrapper for the C++ core function formatExtPrice. | |
Q_INVOKABLE QString | formatMoney (double val, int curr=-1, int extra=0) |
This is a wrapper for the C++ core function formatMoney. | |
Q_INVOKABLE QString | formatNumber (double value, int decimals) |
This is a wrapper for the C++ core function formatNumber. | |
Q_INVOKABLE QString | formatPercent (double val) |
This is a wrapper for the C++ core function formatPercent. | |
Q_INVOKABLE QString | formatPurchPrice (double val, int curr=-1) |
This is a wrapper for the C++ core function formatPurchPrice. | |
Q_INVOKABLE QString | formatQty (double val) |
This is a wrapper for the C++ core function formatQty. | |
Q_INVOKABLE QString | formatQtyPer (double val) |
This is a wrapper for the C++ core function formatQtyPer. | |
Q_INVOKABLE QString | formatSalesPrice (double val, int curr=-1) |
This is a wrapper for the C++ core function formatSalesPrice. | |
Q_INVOKABLE QString | formatUOMRatio (double val) |
This is a wrapper for the C++ core function formatUOMRatio. | |
Q_INVOKABLE QString | formatWeight (double val) |
This is a wrapper for the C++ core function formatWeight. | |
Q_INVOKABLE QColor | namedColor (QString name) |
This is a wrapper for the C++ core function namedColor. | |
Public Slots | |
void | addColumnXTreeWidget (QWidget *tree, const QString &, int, int, bool=true, const QString=QString(), const QString=QString()) |
Add a column to an existing XTreeWidget. | |
bool | copyFile (const QString &oldName, const QString &newName) |
bool | coreDisconnect (QObject *sender, const QString &signal, QObject *receiver, const QString &method) |
Break a signal/slot or signal/signal connection established in the C++ core. | |
QObject * | costVal () |
Get a standard Cost QValidator. | |
QObject * | createGridLayout () |
Create a new QGridLayout. | |
QObject * | createLayout (const QString &className, QWidget *parent, const QString &name=QString()) |
Create a new layout based on the name of the desired class. | |
QWidget * | createWidget (const QString &className, QWidget *parent=0, const QString &name=QString()) |
Create a widget based on the name of the desired class. | |
QObject * | customVal (const QString &ReqExp) |
This functions takes a regexp string and creates and returns a QRegExpValidator. | |
QObject * | dayVal () |
Get a standard Day QValidator. | |
XSqlQuery | executeBegin () |
This is a convenience function that simply begins a database transaction. | |
XSqlQuery | executeCommit () |
This is a convenience function that simply commits the currently open database transaction. | |
XSqlQuery | executeDbQuery (const QString &group, const QString &name, const ParameterList ¶ms) |
Execute a MetaSQL query loaded from the metasql table. | |
XSqlQuery | executeDbQuery (const QString &group, const QString &name) |
Execute a simple query loaded from the metasql table. | |
XSqlQuery | executeQuery (const QString &query, const ParameterList ¶ms) |
Execute a MetaSQL query. | |
XSqlQuery | executeQuery (const QString &query) |
Execute a simple database query. | |
XSqlQuery | executeRollback () |
This is a convenience function that simply rolls back the currently open database transaction. | |
QString | fileDialog (QWidget *parent, const QString &caption, const QString &dir, const QString &filter, int fileModeSel, int acceptModeSel) |
Open a QFileDialog window. | |
bool | fileExists (const QString &name) |
QObject * | getCreditCardProcessor () |
Get the CreditCardProcessor object for the default service. | |
QString | getCurrentDir () |
A wrapper around QDir::currentPath. | |
QString | getFileName (const QString &path) |
This is a wrapper around QFileInfo.fileName. | |
QString | getHomeDir () |
A wrapper around QDir::homePath. | |
QString | getTempDir () |
A wrapper around QDir::tmpPath. | |
QWidget * | lastWindow () const |
Return the last window opened by this instance of the ScriptToolbox. | |
void | layoutBoxInsertWidget (QObject *, int index, QWidget *, int stretch=0, int alignment=0) |
Insert a QWidget into an existing QBoxLayout. | |
void | layoutGridAddLayout (QObject *, QObject *, int row, int column, int alignment=0) |
Insert a QGridLayout into an existing QGridLayout. | |
void | layoutGridAddWidget (QObject *, QWidget *, int fromRow, int fromColumn, int rowSpan, int columnSpan, int alignment=0) |
Insert a QWidget into an existing QGridLayout. | |
void | layoutGridAddWidget (QObject *, QWidget *, int row, int column, int alignment=0) |
Insert a QWidget into an existing QGridLayout. | |
void | layoutStackedInsertWidget (QObject *, int index, QWidget *) |
Insert a QWidget into an existing QStackedLayout. | |
void | listProperties (const QScriptValue &obj) const |
Show the properties of a QtScript object. | |
void | loadQWebView (QWidget *webView, const QString &url) |
Load the given QWebView with the given URL. | |
QWidget * | loadUi (const QString &screenName, QWidget *parent=0) |
Load a .ui definition from the uiform table. | |
bool | makePath (const QString &mkPath, const QString &rootPath) |
A wrapper around QDir::mkpath. | |
int | menuActionCount (QObject *menu) |
Find the number of QActions in a QMenu. | |
QObject * | menuAddAction (QObject *menu, const QString &text, const bool enabled=true) |
Add an action to an existing QMenu. | |
QObject * | menuAddMenu (QObject *menu, const QString &text, const QString &name=QString()) |
Add an action to an existing QMenu. | |
QObject * | menuAddSeparator (QObject *menu) |
Add a separator to an existing QMenu. | |
QObject * | menuInsertAction (QObject *menu, QObject *before, const QString &name=QString(), const bool enabled=true) |
Insert an action into an existing QMenu. | |
QObject * | menuInsertMenu (QObject *menu, QObject *before, const QString &name) |
Insert a QMenu into an existing QMenu. | |
QObject * | menuInsertSeparator (QObject *menu, QObject *before) |
Insert a separator into an existing QMenu. | |
void | menuRemove (QObject *menu, QObject *action) |
Remove a QAction from a QMenu. | |
int | messageBox (const QString &type, QWidget *parent, const QString &title, const QString &text, int buttons=0x00000400, int defaultButton=0x00000000) |
A wrapper around the QMessageBox static methods for standard dialogs. | |
QObject * | moneyVal () |
Get a standard Money QValidator. | |
QObject * | negMoneyVal () |
Get a standard Negative Money QValidator. | |
void | openUrl (const QString &fileUrl) |
Open a web page or open a file with an appropriate application. | |
QWidget * | openWindow (const QString pname, QWidget *parent=0, Qt::WindowModality modality=Qt::NonModal, Qt::WindowFlags flags=0) |
Open a new scripted or core application window. | |
QObject * | orderVal () |
Get a standard Order QValidator. | |
QObject * | percentVal () |
Get a standard Percent QValidator. | |
void | populateXTreeWidget (QWidget *tree, XSqlQuery pSql, bool=FALSE) |
Populate an XTreeWidget with the results of the given query. | |
QObject * | priceVal () |
Get a standard Price QValidator. | |
bool | printReport (const QString &name, const ParameterList ¶ms, const bool preview) |
Use the embedded OpenRPT to print or preview a named report. | |
bool | printReport (const QString &name, const ParameterList ¶ms, const QString &pdfFilename=QString::null) |
Use the embedded OpenRPT to print a named report. | |
bool | printReportCopies (const QString &name, const ParameterList ¶ms, int copies) |
Print multiple copies of a single report. | |
QObject * | qtyPerVal () |
Get a standard Quantity Per QValidator. | |
QObject * | qtyVal () |
Get a standard Quantity QValidator. | |
QObject * | ratioVal () |
Get a standard Ratio QValidator. | |
bool | removeFile (const QString &name) |
bool | removePath (const QString &rmPath, const QString &rootPath) |
A wrapper around QDir.rmpath. | |
bool | renameFile (const QString &oldName, const QString &newName) |
QString | rootPath () |
A wrapper around QDir::rootPath. | |
QObject * | runTimeVal () |
Get a standard Run Time QValidator. | |
int | saveCreditCard (QWidget *parent, int custId, QString ccName, QString ccAddress1, QString ccAddress2, QString ccCity, QString ccState, QString ccZip, QString ccCountry, QString ccNumber, QString ccType, QString ccExpireMonth, QString ccExpireYear, int ccId=0, bool ccActive=true) |
Save a credit card definition from a script. | |
QString | storedProcErrorLookup (const QString proc, const int result) |
This is a wrapper around the core storedProcErrorLookup. | |
int | tabCount (QWidget *tab) |
Find the number of tabs in the QTabWidget. | |
int | tabInsertTab (QWidget *tab, int idx, QWidget *page, const QString &text) |
Insert a new tab into a QTabWidget. | |
void | tabRemoveTab (QWidget *tab, int idx) |
Remove a particular tab from a QTabWidget. | |
void | tabSetTabEnabled (QWidget *tab, int idx, bool enable) |
Enable or disable a particular tab on a QTabWidget. | |
void | tabSetTabText (QWidget *tab, int idx, const QString &text) |
Set the text for a particular tab on a QTabWidget. | |
int | tabTabIndex (QWidget *tab, QWidget *page) |
Get the index of a particular tab in a QTabWidget. | |
QString | tabtabText (QWidget *tab, int idx) |
Get the text for a particular tab on a QTabWidget. | |
QWidget * | tabWidget (QWidget *tab, int idx) |
Return the QWidget for a particular tab in a QTabWidget. | |
QString | textStreamRead (const QString &name) |
Read the entire contents of a text file. | |
bool | textStreamWrite (const QString &name, const QString &WriteText) |
Write the given text to the named file. | |
QObject * | TransQtyVal () |
Get a standard Transfer Quantity QValidator. | |
QObject * | weightVal () |
Get a standard Weight QValidator. | |
QObject * | widgetGetLayout (QWidget *w) |
Get the layout containing the given widget. | |
Static Public Member Functions | |
static void | setLastWindow (QWidget *lw) |
Override the last window opened by this toolbox instance. |
The ScriptToolbox provides a collection of miscellaneous utility methods used when writing xTuple ERP extension scripts.
The ScriptToolbox class provides the C++ implementation of the global toolbox object. A toolbox object is created whenever xTuple ERP creates a QScriptEngine, such as starting the application and opening a new window.
Scripts should use these methods by using the toolbox object in the script's global namespace:
var qry = toolbox.executeQuery("SELECT CURRENT_DATE AS result;");
The methods in the class are intended to be used from scripts only. Use the appropriate classes and methods directly if you are writing in C++. The descriptions of individual methods below should point you to the proper C++ classes to use.
Historical note: Many methods in the ScriptToolbox are deprecated. They were created while we were learning how best to integrate QtScript with xTuple ERP. Please do not use these, as they will eventually be removed from the toolbox. The documentation for these deprecated methods refers to better ways to handle relevant situations.
expose QFile and QDir to scripting, including static methods, then deprecate the methods here that wrap them.
figure out how to link this class with the scriptapi group
ScriptToolbox::ScriptToolbox | ( | QScriptEngine * | engine | ) |
Create a new ScriptToolbox.
This constructor should not be called directly except in a small number of places in the xTuple ERP core. It does not install the toolbox object in the engine's global namespace.
engine | The script engine in which to create the toolbox object |
ScriptToolbox::~ScriptToolbox | ( | ) | [virtual] |
void ScriptToolbox::addColumnXTreeWidget | ( | QWidget * | tree, | |
const QString & | pString, | |||
int | pWidth, | |||
int | pAlignment, | |||
bool | pVisible = true , |
|||
const QString | pEditColumn = QString() , |
|||
const QString | pDisplayColumn = QString() | |||
) | [slot] |
Add a column to an existing XTreeWidget.
bool ScriptToolbox::coreDisconnect | ( | QObject * | sender, | |
const QString & | signal, | |||
QObject * | receiver, | |||
const QString & | method | |||
) | [slot] |
Break a signal/slot or signal/signal connection established in the C++ core.
Much of the behavior in the core application is controlled by Qt signal/slot connections. To modify certain behaviors, scripts need to break the connection between signals emitted by core objects and the core slots.
Note that a single object can emit several signals at different times and that each signal can have multiple recipients. Make sure the script disconnects all of the required signal/slot pairs and only those required.
The caller is responsible for ensuring that the original behavior gets restored or appropriately modified. For example, if a script disconnects a Save button's clicked
signal from a core method to save the data, that script developer takes responsibility to either save the data in the script or call the core's save method at an appropriate time.
sender | The QObject that has emits the signal | |
signal | The particular signal that the script needs to intercept | |
receiver | The core object coded to receive the signal | |
method | The slot (or signal) of the receiver to disconnect |
QObject * ScriptToolbox::costVal | ( | ) | [slot] |
Get a standard Cost QValidator.
QObject * ScriptToolbox::createGridLayout | ( | ) | [slot] |
Create a new QGridLayout.
QObject * ScriptToolbox::createLayout | ( | const QString & | className, | |
QWidget * | parent, | |||
const QString & | name = QString() | |||
) | [slot] |
Create a new layout based on the name of the desired class.
This is a wrapper around XUiLoader::createLayout.
className | The name of the class of the desired layout | |
parent | The widget that should be set as the parent of the new layout | |
name | The name to give the newly-created layout |
QWidget * ScriptToolbox::createWidget | ( | const QString & | className, | |
QWidget * | parent = 0 , |
|||
const QString & | name = QString() | |||
) | [slot] |
Create a widget based on the name of the desired class.
This is a wrapper around XUiLoader::createWidget.
The following example creates a new QPushButton:
var newbutton = toolbox.createWidget("QPushButton", mywindow, "_scriptButton");
className | The name of the class of the desired widget | |
parent | The widget that should be set as the parent of the new widget | |
name | The name to give the newly-created widget |
This functions takes a regexp string and creates and returns a QRegExpValidator.
QObject * ScriptToolbox::dayVal | ( | ) | [slot] |
Get a standard Day QValidator.
int ScriptToolbox::decimalPlaces | ( | QString | p | ) | [inline] |
This is a wrapper for the C++ core function decimalPlaces.
XSqlQuery ScriptToolbox::executeBegin | ( | ) | [slot] |
This is a convenience function that simply begins a database transaction.
XSqlQuery ScriptToolbox::executeCommit | ( | ) | [slot] |
This is a convenience function that simply commits the currently open database transaction.
XSqlQuery ScriptToolbox::executeDbQuery | ( | const QString & | group, | |
const QString & | name, | |||
const ParameterList & | params | |||
) | [slot] |
Execute a MetaSQL query loaded from the metasql
table.
This loads a query string from the metasql
table in the xTuple ERP database. The given ParameterList controls parsing of the string to generate the actual query to execute.
This method executes the query but the caller is responsible for navigating the results and checking for errors.
The following scripted example creates a ParameterList params
, populates it with the number of days preauthorized credit card charges are configured to be valid (defaults to 7) and defines some standard text values to display instead of internal codes (e.g. Preauthorization
), then queries the database for a list of credit card transactions. The query itself it taken from the metasql
table where the metasql_group
is ccpayments
and the metasql_name
is list
. The results are then used to populate an XTreeWidget.
function sPopulateTransactions() { var params = new Object; params.preauth = "Preauthorization"; params.charge = "Charge"; params.refund = "Refund/Credit"; params.authorized = "Authorized"; params.approved = "Approved"; params.declined = "Declined/Denied"; params.voided = "Voided"; params.noapproval = "Not Approved"; if (metrics.value("CCValidDays") > 0) params.ccValidDays = metrics.value("CCValidDays"); else params.ccValidDays = 7; _transactions.populate(toolbox.executeDbQuery("ccpayments", "list", params)); }
%group | The metasql_group value to use when searching for this query | |
name | The metasql_name value to use when searching for this query | |
params | The ParameterList used by MetaSQL to formulate the final query |
Execute a simple query loaded from the metasql
table.
This loads a query string from the metasql
table in the xTuple ERP database. This string is then executed as a database query. If the string has MetaSQL tags in it, they are all treated as undefined (the ParameterList is empty).
It is the caller's responsibility to ensure that there is a record in the metasql
table that matches the given group and name, and that processing the query string with an empty parameter list will result in valid SQL.
%group | The metasql_group value to use when searching for this query | |
name | The metasql_name value to use when searching for this query |
XSqlQuery ScriptToolbox::executeQuery | ( | const QString & | query, | |
const ParameterList & | params | |||
) | [slot] |
Execute a MetaSQL query.
The passed-in string is processed as a MetaSQL query and then sent to the database engine for execution. The given ParameterList controls parsing of the string to generate the actual query to execute.
This method executes the query but the caller is responsible for navigating the results and checking for errors.
The following scripted example creates a ParameterList params
, sets the site
parameter to the internal id of the currently selected _site
widget, then queries the database for a list of items associated with that itemsite. The results are then used to populate an XTreeWidget.
function sFillList() { var params = new Object; params.site = _site.id(); var qry = toolbox.executeQuery('SELECT item_id, itemsite_id, item_number, ' + ' itemsite_loccntrl, itemsite_controlmethod ' + 'FROM itemsite ' + ' JOIN item ON (itemsite_item_id=item_id) ' + 'WHERE itemsite_warehous_id=<? value("site") ?> ' + 'ORDER BY item_number;', params); _itemsite.populate(qry, true); }
query | The MetaSQL string from which to build the query | |
params | The ParameterList used by MetaSQL to formulate the final query |
XSqlQuery ScriptToolbox::executeQuery | ( | const QString & | query | ) | [slot] |
Execute a simple database query.
The passed-in string is sent to the database engine for execution. The resulting XSqlQuery object is returned. The calling script is responsible for navigating the results, including reading the query results and checking for errors.
For example, let's say you want a warning every day when you log in about currencies with missing exchange rates. The following lines check the database for currencies that do not have exchange rates defined for today:
var fxqry = toolbox.executeQuery("SELECT curr_abbr, curr_rate " + " FROM curr_symbol LEFT OUTER JOIN" + " curr_rate ON (curr_symbol.curr_id=curr_rate.curr_id" + " AND CURRENT_DATE BETWEEN curr_effective AND curr_expires + 1)" + " WHERE curr_rate IS NULL;");
Now the script must loop through the results to inform you of each row found:
while (fxqry.next()) QMessageBox.warning(mainwindow, qsTr("No exchange rate"), qsTr("%1 has no exchange rate for today.") .arg(fxqry.value("curr_abbr")));
Without this loop, the script would have asked the database for the missing exchange rates but nothing would have been done with the results.
query | The database query to execute |
XSqlQuery ScriptToolbox::executeRollback | ( | ) | [slot] |
This is a convenience function that simply rolls back the currently open database transaction.
QString ScriptToolbox::fileDialog | ( | QWidget * | parent, | |
const QString & | caption, | |||
const QString & | dir, | |||
const QString & | filter, | |||
int | fileModeSel, | |||
int | acceptModeSel | |||
) | [slot] |
Open a QFileDialog window.
This is a convenience wrapper around common uses for the QFileDialog class. It can be used to open files or directories or to save a file.
parent | The QWidget to set as the parent of the QFileDialog | |||||||||||
caption | The caption to use on the dialog | |||||||||||
dir | Start at the given directory | |||||||||||
filter | A semicolon-separated list of strings to filter the directory contents | |||||||||||
fileModeSel | An integer limiting what the user may select. Note that the values accepted here are not the same as the integer values of the named Qt constants:
| |||||||||||
acceptModeSel | An integer controlling whether the dialog is to be opened to let the user open a file or save a file
|
bool ScriptToolbox::fileExists | ( | const QString & | name | ) | [slot] |
QString ScriptToolbox::formatCost | ( | double | val, | |
int | curr = -1 | |||
) | [inline] |
This is a wrapper for the C++ core function formatCost.
This is a wrapper for the C++ core function formatDate.
QString ScriptToolbox::formatExtPrice | ( | double | val, | |
int | curr = -1 | |||
) | [inline] |
This is a wrapper for the C++ core function formatExtPrice.
QString ScriptToolbox::formatMoney | ( | double | val, | |
int | curr = -1 , |
|||
int | extra = 0 | |||
) | [inline] |
This is a wrapper for the C++ core function formatMoney.
QString ScriptToolbox::formatNumber | ( | double | value, | |
int | decimals | |||
) | [inline] |
This is a wrapper for the C++ core function formatNumber.
QString ScriptToolbox::formatPercent | ( | double | val | ) | [inline] |
This is a wrapper for the C++ core function formatPercent.
QString ScriptToolbox::formatPurchPrice | ( | double | val, | |
int | curr = -1 | |||
) | [inline] |
This is a wrapper for the C++ core function formatPurchPrice.
QString ScriptToolbox::formatQty | ( | double | val | ) | [inline] |
This is a wrapper for the C++ core function formatQty.
QString ScriptToolbox::formatQtyPer | ( | double | val | ) | [inline] |
This is a wrapper for the C++ core function formatQtyPer.
QString ScriptToolbox::formatSalesPrice | ( | double | val, | |
int | curr = -1 | |||
) | [inline] |
This is a wrapper for the C++ core function formatSalesPrice.
QString ScriptToolbox::formatUOMRatio | ( | double | val | ) | [inline] |
This is a wrapper for the C++ core function formatUOMRatio.
QString ScriptToolbox::formatWeight | ( | double | val | ) | [inline] |
This is a wrapper for the C++ core function formatWeight.
QObject * ScriptToolbox::getCreditCardProcessor | ( | ) | [slot] |
Get the CreditCardProcessor object for the default service.
This is a wrapper around CreditCardProcessor::getProcessor. There is no scriptable way to get a CreditCardProcessor object for a named service provider.
QString ScriptToolbox::getCurrentDir | ( | ) | [slot] |
A wrapper around QDir::currentPath.
This is a wrapper around QFileInfo.fileName.
Get the name of the file, excluding the path if given.
path | The path of the file, possibly absolute, relative, or simple |
QString ScriptToolbox::getHomeDir | ( | ) | [slot] |
A wrapper around QDir::homePath.
QString ScriptToolbox::getTempDir | ( | ) | [slot] |
A wrapper around QDir::tmpPath.
QWidget * ScriptToolbox::lastWindow | ( | ) | const [slot] |
Return the last window opened by this instance of the ScriptToolbox.
void ScriptToolbox::layoutBoxInsertWidget | ( | QObject * | obj, | |
int | index, | |||
QWidget * | widget, | |||
int | stretch = 0 , |
|||
int | alignment = 0 | |||
) | [slot] |
Insert a QWidget into an existing QBoxLayout.
void ScriptToolbox::layoutGridAddLayout | ( | QObject * | parent, | |
QObject * | child, | |||
int | row, | |||
int | column, | |||
int | alignment = 0 | |||
) | [slot] |
Insert a QGridLayout into an existing QGridLayout.
void ScriptToolbox::layoutGridAddWidget | ( | QObject * | obj, | |
QWidget * | widget, | |||
int | fromRow, | |||
int | fromColumn, | |||
int | rowSpan, | |||
int | columnSpan, | |||
int | alignment = 0 | |||
) | [slot] |
Insert a QWidget into an existing QGridLayout.
void ScriptToolbox::layoutGridAddWidget | ( | QObject * | obj, | |
QWidget * | widget, | |||
int | row, | |||
int | column, | |||
int | alignment = 0 | |||
) | [slot] |
Insert a QWidget into an existing QGridLayout.
Insert a QWidget into an existing QStackedLayout.
void ScriptToolbox::listProperties | ( | const QScriptValue & | obj | ) | const [slot] |
Show the properties of a QtScript object.
This writes all of the properties of a QtScript object using qWarning. This is a debugging tool, most useful when not using the Qt script debugger. The property list is not sorted and is not generally recursive. This method does show prototype properties in a separately labeled list if the given object has a prototype.
The output has the name of each property and the result of toString(), so properties which are functions show as something like "function()". The values which would be returned by these functions are not displayed. For example,
toolbox.listProperties(_aWarehouseClusterWidget);
will show a line similar to this:
id = "function() returning int"
rather than the usually-more-useful
id = -1
obj | The object whose properties should be listed |
Load the given QWebView with the given URL.
Load a .ui definition from the uiform table.
Instantiate a new user interface using a .ui definition that has been stored in the uiform table. If multiple rows in the uiform match the given name, the enabled row with the highest uiform_order
is used.
screenName | The name of the .ui to load (uiform_name ) | |
parent | The widget to set as the parent of the loaded .ui |
A wrapper around QDir::mkpath.
Create a new directory.
mkPath | The directory to create | |
rootPath | The parent directory of the newly-created directory |
int ScriptToolbox::menuActionCount | ( | QObject * | menu | ) | [slot] |
QObject * ScriptToolbox::menuAddAction | ( | QObject * | menu, | |
const QString & | text, | |||
const bool | enabled = true | |||
) | [slot] |
Add an action to an existing QMenu.
QObject * ScriptToolbox::menuAddMenu | ( | QObject * | menu, | |
const QString & | text, | |||
const QString & | name = QString() | |||
) | [slot] |
Add an action to an existing QMenu.
Add a separator to an existing QMenu.
QObject * ScriptToolbox::menuInsertAction | ( | QObject * | menu, | |
QObject * | before, | |||
const QString & | name = QString() , |
|||
const bool | enabled = true | |||
) | [slot] |
Insert an action into an existing QMenu.
QObject * ScriptToolbox::menuInsertMenu | ( | QObject * | menu, | |
QObject * | before, | |||
const QString & | name | |||
) | [slot] |
Insert a QMenu into an existing QMenu.
Insert a separator into an existing QMenu.
Remove a QAction from a QMenu.
int ScriptToolbox::messageBox | ( | const QString & | type, | |
QWidget * | parent, | |||
const QString & | title, | |||
const QString & | text, | |||
int | buttons = 0x00000400 , |
|||
int | defaultButton = 0x00000000 | |||
) | [slot] |
A wrapper around the QMessageBox static methods for standard dialogs.
QObject * ScriptToolbox::moneyVal | ( | ) | [slot] |
Get a standard Money QValidator.
This is a wrapper for the C++ core function namedColor.
QObject * ScriptToolbox::negMoneyVal | ( | ) | [slot] |
Get a standard Negative Money QValidator.
void ScriptToolbox::openUrl | ( | const QString & | fileUrl | ) | [slot] |
Open a web page or open a file with an appropriate application.
This is a wrapper around QDesktopServices::openUrl.
fileUrl | The file or URL to open. |
QWidget * ScriptToolbox::openWindow | ( | const QString | pname, | |
QWidget * | parent = 0 , |
|||
Qt::WindowModality | modality = Qt::NonModal , |
|||
Qt::WindowFlags | flags = 0 | |||
) | [slot] |
Open a new scripted or core application window.
This method opens a new window on the display. It can be defined in its .ui as an XWidget, XDialog, or XMainWindow. If there is a record in the uiform table, this .ui is instantiated; otherwise openWindow opens a core application window with the given name if one exists.
Windows that inherit from QDialog are handled specially. If the modality passed is Qt::NonModal, the modality is changed to Qt::WindowModal. The flags parameter gets Qt::Dialog set even if the caller did not set it. Because of the way the new windows are created, a special mydialog
object gets created to allow access to the QDialog properties and methods, such as QDialog::exec.
pname | The name of the uiform or core application class of the window to open | |
parent | The widget to set as the parent of the newly-created window | |
modality | This can be any of the defined Qt::WindowModality values | |
flags | This can be any Qt::WindowFlags value |
QObject * ScriptToolbox::orderVal | ( | ) | [slot] |
Get a standard Order QValidator.
QObject * ScriptToolbox::percentVal | ( | ) | [slot] |
Get a standard Percent QValidator.
void ScriptToolbox::populateXTreeWidget | ( | QWidget * | tree, | |
XSqlQuery | pSql, | |||
bool | pUseAltId = FALSE | |||
) | [slot] |
Populate an XTreeWidget with the results of the given query.
QObject * ScriptToolbox::priceVal | ( | ) | [slot] |
Get a standard Price QValidator.
bool ScriptToolbox::printReport | ( | const QString & | name, | |
const ParameterList & | params, | |||
const bool | preview | |||
) | [slot] |
Use the embedded OpenRPT to print or preview a named report.
Print or preview on-screen the report using the given parameters.
name | The name of the report definition to use | |
params | The MetaSQL parameters used to control the report output | |
preview | If preview is true, open a report preview window; otherwise print using the standard print methodology |
bool ScriptToolbox::printReport | ( | const QString & | name, | |
const ParameterList & | params, | |||
const QString & | pdfFilename = QString::null | |||
) | [slot] |
Use the embedded OpenRPT to print a named report.
Print the report using the given parameters, optionally saving the output to a PDF file.
name | The name of the report definition to use | |
params | The MetaSQL parameters used to control the report output | |
pdfFilename | The name of the PDF file to create. If empty the function uses the standard print methodology |
bool ScriptToolbox::printReportCopies | ( | const QString & | name, | |
const ParameterList & | params, | |||
int | copies | |||
) | [slot] |
Print multiple copies of a single report.
Print the same report multiple times using the same set of parameters as part of the same print job. This serves as a scriptable replacement for multi-part forms. Note that all copies of the report are identical as only one set of parameters is passed in.
name | The name of the report definition to use | |
params | The MetaSQL parameters used to control the report output | |
copies | The number of copies to print |
QObject * ScriptToolbox::qtyPerVal | ( | ) | [slot] |
Get a standard Quantity Per QValidator.
QObject * ScriptToolbox::qtyVal | ( | ) | [slot] |
Get a standard Quantity QValidator.
QObject * ScriptToolbox::ratioVal | ( | ) | [slot] |
Get a standard Ratio QValidator.
bool ScriptToolbox::removeFile | ( | const QString & | name | ) | [slot] |
A wrapper around QDir.rmpath.
Remove a directory.
rmPath | The directory to remove | |
rootPath | The parent directory of the directory to remove |
QString ScriptToolbox::rootPath | ( | ) | [slot] |
A wrapper around QDir::rootPath.
QObject * ScriptToolbox::runTimeVal | ( | ) | [slot] |
Get a standard Run Time QValidator.
int ScriptToolbox::saveCreditCard | ( | QWidget * | parent, | |
int | custId, | |||
QString | ccName, | |||
QString | ccAddress1, | |||
QString | ccAddress2, | |||
QString | ccCity, | |||
QString | ccState, | |||
QString | ccZip, | |||
QString | ccCountry, | |||
QString | ccNumber, | |||
QString | ccType, | |||
QString | ccExpireMonth, | |||
QString | ccExpireYear, | |||
int | ccId = 0 , |
|||
bool | ccActive = true | |||
) | [slot] |
Save a credit card definition from a script.
This is a wrapper around creditCard::saveCreditCard().
void ScriptToolbox::setLastWindow | ( | QWidget * | lw | ) | [static] |
Override the last window opened by this toolbox instance.
This is a wrapper around the core storedProcErrorLookup.
int ScriptToolbox::tabCount | ( | QWidget * | tab | ) | [slot] |
Find the number of tabs in the QTabWidget.
int ScriptToolbox::tabInsertTab | ( | QWidget * | tab, | |
int | idx, | |||
QWidget * | page, | |||
const QString & | text | |||
) | [slot] |
Insert a new tab into a QTabWidget.
void ScriptToolbox::tabRemoveTab | ( | QWidget * | tab, | |
int | idx | |||
) | [slot] |
Remove a particular tab from a QTabWidget.
void ScriptToolbox::tabSetTabEnabled | ( | QWidget * | tab, | |
int | idx, | |||
bool | enable | |||
) | [slot] |
Enable or disable a particular tab on a QTabWidget.
Set the text for a particular tab on a QTabWidget.
Get the index of a particular tab in a QTabWidget.
Get the text for a particular tab on a QTabWidget.
Return the QWidget for a particular tab in a QTabWidget.
Read the entire contents of a text file.
This method opens a text file, reads its contents into a string, and closes the file again.
name | The name of the file to open |
Write the given text to the named file.
Create or overwrite a file with the given name, using the given contents. If the file name passed does not contain a suffix, .txt is appended when the file is created.
pName | The name of the file to create | |
WriteText | The string to write to the file |
QObject * ScriptToolbox::TransQtyVal | ( | ) | [slot] |
Get a standard Transfer Quantity QValidator.
QObject * ScriptToolbox::weightVal | ( | ) | [slot] |
Get a standard Weight QValidator.
Get the layout containing the given widget.
Search the object hierarchy and find the smallest QLayout that contains the given widget. This lets a script create a new QWidget and insert it into the user interface near another widget.
var btnDelete = mywindow.findChild("_delete");
var layout = toolbox.widgetGetLayout(btnDelete);
w | The widget whose layout you want to find |
Generated on Tue Apr 20 12:03:25 2010 | xTuple ERP Programmer Reference, Version 3.5.0 |
![]() |