List of all members | Properties | Public Slots | Public Member Functions | Static Public Member Functions | Protected Member Functions
ScriptToolbox Class Reference

The ScriptToolbox provides a collection of miscellaneous utility methods used when writing xTuple ERP extension scripts. More...

#include <scripttoolbox.h>

Inheritance diagram for ScriptToolbox:
QObject

Properties

 objectName
 

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. More...
 
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. More...
 
QObjectcostVal ()
 Get a standard Cost QValidator. More...
 
QObjectcreateGridLayout ()
 Create a new QGridLayout. More...
 
QObjectcreateLayout (const QString &className, QWidget *parent, const QString &name=QString())
 Create a new layout based on the name of the desired class. More...
 
QWidgetcreateWidget (const QString &className, QWidget *parent=0, const QString &name=QString())
 Create a widget based on the name of the desired class. More...
 
QObjectcustomVal (const QString &ReqExp)
 This functions takes a regexp string and creates and returns a QRegExpValidator. More...
 
QObjectdayVal ()
 Get a standard Day QValidator. More...
 
XSqlQuery executeBegin ()
 This is a convenience function that simply begins a database transaction. More...
 
XSqlQuery executeCommit ()
 This is a convenience function that simply commits the currently open database transaction. More...
 
XSqlQuery executeDbQuery (const QString &group, const QString &name)
 Execute a simple query loaded from the metasql table. More...
 
XSqlQuery executeDbQuery (const QString &group, const QString &name, const ParameterList &params)
 Execute a MetaSQL query loaded from the metasql table. More...
 
XSqlQuery executeQuery (const QString &query)
 Execute a simple database query. More...
 
XSqlQuery executeQuery (const QString &query, const ParameterList &params)
 Execute a MetaSQL query. More...
 
XSqlQuery executeRollback ()
 This is a convenience function that simply rolls back the currently open database transaction. More...
 
QString fileDialog (QWidget *parent, const QString &caption, const QString &dir, const QString &filter, int fileModeSel, int acceptModeSel)
 Open a QFileDialog window. More...
 
bool fileExists (const QString &name)
 
QObjectgetCreditCardProcessor ()
 Get the CreditCardProcessor object for the default service. More...
 
QString getCurrentDir ()
 
QString getFileName (const QString &path)
 
QString getHomeDir ()
 
QString getTempDir ()
 
QWidgetlastWindow () const
 Return the last window opened by this instance of the ScriptToolbox. More...
 
void layoutBoxInsertWidget (QObject *, int index, QWidget *, int stretch=0, int alignment=0)
 Insert a QWidget into an existing QBoxLayout. More...
 
void layoutGridAddLayout (QObject *, QObject *, int row, int column, int alignment=0)
 Insert a QGridLayout into an existing QGridLayout. More...
 
void layoutGridAddWidget (QObject *, QWidget *, int row, int column, int alignment=0)
 Insert a QWidget into an existing QGridLayout. More...
 
void layoutGridAddWidget (QObject *, QWidget *, int fromRow, int fromColumn, int rowSpan, int columnSpan, int alignment=0)
 Insert a QWidget into an existing QGridLayout. More...
 
void layoutStackedInsertWidget (QObject *, int index, QWidget *)
 Insert a QWidget into an existing QStackedLayout. More...
 
void listProperties (const QScriptValue &obj, const bool showPrototype=true) const
 Show the properties of a QtScript object. More...
 
void loadQWebView (QWidget *webView, const QString &url)
 Load the given QWebView with the given URL. More...
 
QWidgetloadUi (const QString &screenName, QWidget *parent=0)
 Load a .ui definition from the uiform table. More...
 
bool makePath (const QString &mkPath, const QString &rootPath)
 
int menuActionCount (QObject *menu)
 Find the number of QActions in a QMenu. More...
 
QObjectmenuAddAction (QObject *menu, const QString &text, const bool enabled=true)
 Add an action to an existing QMenu. More...
 
QObjectmenuAddMenu (QObject *menu, const QString &text, const QString &name=QString())
 Add an action to an existing QMenu. More...
 
QObjectmenuAddSeparator (QObject *menu)
 Add a separator to an existing QMenu. More...
 
QObjectmenuInsertAction (QObject *menu, QObject *before, const QString &name=QString(), const bool enabled=true)
 Insert an action into an existing QMenu. More...
 
QObjectmenuInsertMenu (QObject *menu, QObject *before, const QString &name)
 Insert a QMenu into an existing QMenu. More...
 
QObjectmenuInsertSeparator (QObject *menu, QObject *before)
 Insert a separator into an existing QMenu. More...
 
void menuRemove (QObject *menu, QObject *action)
 Remove a QAction from a QMenu. More...
 
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. More...
 
QObjectmoneyVal ()
 Get a standard Money QValidator. More...
 
QObjectnegMoneyVal ()
 Get a standard Negative Money QValidator. More...
 
QWidgetnewDisplay (const QString pname, QWidget *parent=0, Qt::WindowModality modality=Qt::NonModal, Qt::WindowFlags flags=0)
 
void openUrl (const QString &fileUrl)
 Open a web page or open a file with an appropriate application. More...
 
QWidgetopenWindow (const QString pname, QWidget *parent=0, Qt::WindowModality modality=Qt::NonModal, Qt::WindowFlags flags=0)
 Open a new scripted or core application window. More...
 
QObjectorderVal ()
 Get a standard Order QValidator. More...
 
QObjectpercentVal ()
 Get a standard Percent QValidator. More...
 
void populateXTreeWidget (QWidget *tree, XSqlQuery pSql, bool=false)
 Populate an XTreeWidget with the results of the given query. More...
 
QObjectpriceVal ()
 Get a standard Price QValidator. More...
 
bool printReport (const QString &name, const ParameterList &params, const QString &pdfFilename=QString::null)
 Use the embedded OpenRPT to print a named report. More...
 
bool printReport (const QString &name, const ParameterList &params, const bool preview, QWidget *parent=0)
 Use the embedded OpenRPT to print or preview a named report. More...
 
bool printReportCopies (const QString &name, const ParameterList &params, int copies)
 Print multiple copies of a single report. More...
 
QObjectqtyPerVal ()
 Get a standard Quantity Per QValidator. More...
 
QObjectqtyVal ()
 Get a standard Quantity QValidator. More...
 
QObjectratioVal ()
 Get a standard Ratio QValidator. More...
 
bool removeFile (const QString &name)
 
bool removePath (const QString &rmPath, const QString &rootPath)
 
bool renameFile (const QString &oldName, const QString &newName)
 
QString rootPath ()
 
QObjectrunTimeVal ()
 Get a standard Run Time QValidator. More...
 
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. More...
 
QString storedProcErrorLookup (const QString proc, const int result)
 This is a wrapper around the core storedProcErrorLookup. More...
 
int tabCount (QWidget *tab)
 Find the number of tabs in the QTabWidget. More...
 
int tabInsertTab (QWidget *tab, int idx, QWidget *page, const QString &text)
 Insert a new tab into a QTabWidget. More...
 
void tabRemoveTab (QWidget *tab, int idx)
 Remove a particular tab from a QTabWidget. More...
 
void tabSetTabEnabled (QWidget *tab, int idx, bool enable)
 Enable or disable a particular tab on a QTabWidget. More...
 
void tabSetTabText (QWidget *tab, int idx, const QString &text)
 Set the text for a particular tab on a QTabWidget. More...
 
int tabTabIndex (QWidget *tab, QWidget *page)
 Get the index of a particular tab in a QTabWidget. More...
 
QString tabtabText (QWidget *tab, int idx)
 Get the text for a particular tab on a QTabWidget. More...
 
QWidgettabWidget (QWidget *tab, int idx)
 Return the QWidget for a particular tab in a QTabWidget. More...
 
QString textStreamRead (const QString &name)
 Read the entire contents of a text file. More...
 
bool textStreamWrite (const QString &name, const QString &WriteText)
 Write the given text to the named file. More...
 
QObjectTransQtyVal ()
 Get a standard Transfer Quantity QValidator. More...
 
QObjectweightVal ()
 Get a standard Weight QValidator. More...
 
QObjectwidgetGetLayout (QWidget *w)
 Get the layout containing the given widget. More...
 

Public Member Functions

 ScriptToolbox (QScriptEngine *engine)
 Create a new ScriptToolbox. More...
 
virtual ~ScriptToolbox ()
 
bool blockSignals (bool block)
 
const QObjectList & children () const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
Q_INVOKABLE int decimalPlaces (QString p)
 This is a wrapper for the C++ core function decimalPlaces. More...
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const
 
Q_INVOKABLE QString formatCost (double val, int curr=-1)
 This is a wrapper for the C++ core function formatCost. More...
 
Q_INVOKABLE QString formatDate (const QDate &pDate)
 This is a wrapper for the C++ core function formatDate. More...
 
Q_INVOKABLE QString formatExtPrice (double val, int curr=-1)
 This is a wrapper for the C++ core function formatExtPrice. More...
 
Q_INVOKABLE QString formatMoney (double val, int curr=-1, int extra=0)
 This is a wrapper for the C++ core function formatMoney. More...
 
Q_INVOKABLE QString formatNumber (double value, int decimals)
 This is a wrapper for the C++ core function formatNumber. More...
 
Q_INVOKABLE QString formatPercent (double val)
 This is a wrapper for the C++ core function formatPercent. More...
 
Q_INVOKABLE QString formatPurchPrice (double val, int curr=-1)
 This is a wrapper for the C++ core function formatPurchPrice. More...
 
Q_INVOKABLE QString formatQty (double val)
 This is a wrapper for the C++ core function formatQty. More...
 
Q_INVOKABLE QString formatQtyPer (double val)
 This is a wrapper for the C++ core function formatQtyPer. More...
 
Q_INVOKABLE QString formatSalesPrice (double val, int curr=-1)
 This is a wrapper for the C++ core function formatSalesPrice. More...
 
Q_INVOKABLE QString formatUOMRatio (double val)
 This is a wrapper for the C++ core function formatUOMRatio. More...
 
Q_INVOKABLE QString formatWeight (double val)
 This is a wrapper for the C++ core function formatWeight. More...
 
bool inherits (const char *className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
Q_INVOKABLE QColor namedColor (QString name)
 This is a wrapper for the C++ core function namedColor. More...
 
QString objectName () const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType)
 
QThreadthread () const
 

Static Public Member Functions

QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
static void setLastWindow (QWidget *lw)
 Override the last window opened by this toolbox instance. More...
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const
 
int receivers (const char *signal) const
 
QObjectsender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

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.

See also
initMenu
toolbox
XDialog
XMainWindow
XWidget

Constructor & Destructor Documentation

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.

Parameters
engineThe script engine in which to create the toolbox object
ScriptToolbox::~ScriptToolbox ( )
virtual

Member Function Documentation

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.

Deprecated:
Use XTreeWidget::addColumn directly.
bool ScriptToolbox::copyFile ( const QString oldName,
const QString newName 
)
slot
Deprecated:
Use QFile.copyFile(oldName, newName) instead
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.

Parameters
senderThe QObject that has emits the signal
signalThe particular signal that the script needs to intercept
receiverThe core object coded to receive the signal
methodThe slot (or signal) of the receiver to disconnect
Returns
Returns true if the connection is successfully broken; otherwise false
See also
QObject::disconnect
Todo:
Add an example to sample_scripts
QObject * ScriptToolbox::costVal ( )
slot

Get a standard Cost QValidator.

Deprecated:
Use mainwindow.costVal() instead.
QObject * ScriptToolbox::createGridLayout ( )
slot

Create a new QGridLayout.

Deprecated:
Use QGridLayout instead.
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.

Parameters
classNameThe name of the class of the desired layout
parentThe widget that should be set as the parent of the new layout
nameThe name to give the newly-created layout
Returns
The newly-created layout
See also
qboxlayoutproto.cpp
qgridlayoutproto.cpp
QBoxLayout
QGridLayout
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 _expand = toolbox.createWidget("QPushButton", mywindow, "_expand");
var _collapse = toolbox.createWidget("QPushButton", mywindow, "_collapse");

Parameters
classNameThe name of the class of the desired widget
parentThe widget that should be set as the parent of the new widget
nameThe name to give the newly-created widget
Returns
The newly-created widget
QObject * ScriptToolbox::customVal ( const QString ReqExp)
slot

This functions takes a regexp string and creates and returns a QRegExpValidator.

QObject * ScriptToolbox::dayVal ( )
slot

Get a standard Day QValidator.

Deprecated:
Use mainwindow.dayVal() instead.
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 
)
slot

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.

Parameters
%groupThe metasql_group value to use when searching for this query
nameThe metasql_name value to use when searching for this query
Returns
The XSqlQuery object after calling XSqlQuery::exec()
See also
mqlLoad
MetaSQLQuery
XSqlQuery
QSqlQuery
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));
}

Parameters
%groupThe metasql_group value to use when searching for this query
nameThe metasql_name value to use when searching for this query
paramsThe ParameterList used by MetaSQL to formulate the final query
Returns
The XSqlQuery object after calling XSqlQuery::exec()
See also
MetaSQLQuery
XSqlQuery
QSqlQuery
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.

Parameters
queryThe database query to execute
Returns
The XSqlQuery object after calling XSqlQuery::exec()
See also
QSqlQuery
XSqlQuery
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);
}

Parameters
queryThe MetaSQL string from which to build the query
paramsThe ParameterList used by MetaSQL to formulate the final query
Returns
The XSqlQuery object after calling XSqlQuery::exec()
See also
MetaSQLQuery
XSqlQuery
QSqlQuery
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.

Parameters
parentThe QWidget to set as the parent of the QFileDialog
captionThe caption to use on the dialog
dirStart at the given directory
filterA semicolon-separated list of strings to filter the directory contents
fileModeSelAn 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:
1QFileDialog::ExistingFile
2QFileDialog::Directory
3QFileDialog::DirectoryOnly
4QFileDialog::ExistingFiles
anything elseQFileDialog::AnyFile
acceptModeSelAn integer controlling whether the dialog is to be opened to let the user open a file or save a file
1QFileDialog::AcceptSave
anything elseQFileDialog::AcceptOpen
See also
QFileDialog
bool ScriptToolbox::fileExists ( const QString name)
slot
Deprecated:
Use QFile.exists(name) instead
QString ScriptToolbox::formatCost ( double  val,
int  curr = -1 
)
inline

This is a wrapper for the C++ core function formatCost.

QString ScriptToolbox::formatDate ( const QDate pDate)
inline

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.

Returns
A CreditCardProcessor object for the current service provider
See also
CreditCardProcessor::getProcessor
QString ScriptToolbox::getCurrentDir ( )
slot
QString ScriptToolbox::getFileName ( const QString path)
slot
Deprecated:
Use var file = new QFileInfo(path).fileName() instead
QString ScriptToolbox::getHomeDir ( )
slot
QString ScriptToolbox::getTempDir ( )
slot
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.

Deprecated:
Use QBoxLayout::insertWidget directly
void ScriptToolbox::layoutGridAddLayout ( QObject parent,
QObject child,
int  row,
int  column,
int  alignment = 0 
)
slot

Insert a QGridLayout into an existing QGridLayout.

Deprecated:
Use QGridLayout::addLayout instead
void ScriptToolbox::layoutGridAddWidget ( QObject obj,
QWidget widget,
int  row,
int  column,
int  alignment = 0 
)
slot

Insert a QWidget into an existing QGridLayout.

Deprecated:
Use QGridLayout::addWidget instead.
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.

Deprecated:
Use QGridLayout::addWidget instead.
void ScriptToolbox::layoutStackedInsertWidget ( QObject obj,
int  index,
QWidget widget 
)
slot

Insert a QWidget into an existing QStackedLayout.

Deprecated:
Use QStackedWidget::insertWidget instead.
void ScriptToolbox::listProperties ( const QScriptValue &  obj,
const bool  showPrototype = true 
) 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 can 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 more useful

id = -1
Parameters
objThe object whose properties should be listed
showPrototypetrue: show the properties of obj 's prototype false: show just the top-level properties of obj
void ScriptToolbox::loadQWebView ( QWidget webView,
const QString url 
)
slot

Load the given QWebView with the given URL.

QWidget * ScriptToolbox::loadUi ( const QString screenName,
QWidget parent = 0 
)
slot

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.

Parameters
screenNameThe name of the .ui to load (uiform_name)
parentThe widget to set as the parent of the loaded .ui
Returns
A widget representing the user interface; 0 if no record matches or if there was an error
bool ScriptToolbox::makePath ( const QString mkPath,
const QString rootPath 
)
slot
Deprecated:
Use var dir = new QDir(rootPath) followed by dir.mkpath(mkPath) instead
int ScriptToolbox::menuActionCount ( QObject menu)
slot

Find the number of QActions in a QMenu.

Parameters
menuThe QMenu whose QAction children you want to count
Returns
The number of QAction objects in the menu or 0 if menu isn't really a QMenu
QObject * ScriptToolbox::menuAddAction ( QObject menu,
const QString text,
const bool  enabled = true 
)
slot

Add an action to an existing QMenu.

Deprecated:
Use QMenu::addAction instead.
QObject * ScriptToolbox::menuAddMenu ( QObject menu,
const QString text,
const QString name = QString() 
)
slot

Add an action to an existing QMenu.

Deprecated:
Use QMenu::addAction instead.
QObject * ScriptToolbox::menuAddSeparator ( QObject menu)
slot

Add a separator to an existing QMenu.

Deprecated:
Use QMenu::addSeparator instead.
QObject * ScriptToolbox::menuInsertAction ( QObject menu,
QObject before,
const QString name = QString(),
const bool  enabled = true 
)
slot

Insert an action into an existing QMenu.

Deprecated:
Use QMenu::insertAction instead.
QObject * ScriptToolbox::menuInsertMenu ( QObject menu,
QObject before,
const QString name 
)
slot

Insert a QMenu into an existing QMenu.

Deprecated:
Use QMenu::insertMenu instead.
QObject * ScriptToolbox::menuInsertSeparator ( QObject menu,
QObject before 
)
slot

Insert a separator into an existing QMenu.

Deprecated:
Use QMenu::insertSeparator instead.
void ScriptToolbox::menuRemove ( QObject menu,
QObject action 
)
slot

Remove a QAction from a QMenu.

Deprecated:
Use QMenu::removeAction instead.
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.

Deprecated:
Use QMessageBox.critical, QMessageBox.information, QMessageBox.question, or QMessageBox.warning.
QObject * ScriptToolbox::moneyVal ( )
slot

Get a standard Money QValidator.

Deprecated:
Use mainwindow.moneyVal() instead.
QColor ScriptToolbox::namedColor ( QString  name)
inline

This is a wrapper for the C++ core function namedColor.

QObject * ScriptToolbox::negMoneyVal ( )
slot

Get a standard Negative Money QValidator.

Deprecated:
Use mainwindow.negMoneyVal() instead.
QWidget * ScriptToolbox::newDisplay ( const QString  pname,
QWidget parent = 0,
Qt::WindowModality  modality = Qt::NonModal,
Qt::WindowFlags  flags = 0 
)
slot
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.

Parameters
fileUrlThe 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.

Parameters
pnameThe name of the uiform or core application class of the window to open
parentThe widget to set as the parent of the newly-created window
modalityThis can be any of the defined Qt::WindowModality values
flagsThis can be any Qt::WindowFlags value
Returns
The newly-opened window; 0 if there was an error
QObject * ScriptToolbox::orderVal ( )
slot

Get a standard Order QValidator.

Deprecated:
Use mainwindow.orderVal() instead.
QObject * ScriptToolbox::percentVal ( )
slot

Get a standard Percent QValidator.

Deprecated:
Use mainwindow.percentVal() instead.
void ScriptToolbox::populateXTreeWidget ( QWidget tree,
XSqlQuery  pSql,
bool  pUseAltId = false 
)
slot

Populate an XTreeWidget with the results of the given query.

Deprecated:
Use XTreeWidget::populate directly.
QObject * ScriptToolbox::priceVal ( )
slot

Get a standard Price QValidator.

Deprecated:
Use mainwindow.priceVal() instead.
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.

Parameters
nameThe name of the report definition to use
paramsThe MetaSQL parameters used to control the report output
pdfFilenameThe name of the PDF file to create. If empty the function uses the standard print methodology
Returns
True if the report printed successfully; false if there was an apparent error printing
bool ScriptToolbox::printReport ( const QString name,
const ParameterList &  params,
const bool  preview,
QWidget parent = 0 
)
slot

Use the embedded OpenRPT to print or preview a named report.

Print or preview on-screen the report using the given parameters.

Parameters
nameThe name of the report definition to use
paramsThe MetaSQL parameters used to control the report output
previewIf preview is true, open a report preview window; otherwise print using the standard print methodology
parentThe parent widget to set for the preview window (optional)
Returns
True if the report printed successfully; false if there was an apparent error printing or previewing
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.

Parameters
nameThe name of the report definition to use
paramsThe MetaSQL parameters used to control the report output
copiesThe number of copies to print
Returns
True if the report printed successfully; false if there was an error or the user canceled printing
QObject * ScriptToolbox::qtyPerVal ( )
slot

Get a standard Quantity Per QValidator.

Deprecated:
Use mainwindow.qtyPerVal() instead.
QObject * ScriptToolbox::qtyVal ( )
slot

Get a standard Quantity QValidator.

Deprecated:
Use mainwindow.qtyVal() instead.
QObject * ScriptToolbox::ratioVal ( )
slot

Get a standard Ratio QValidator.

Deprecated:
Use mainwindow.ratioVal() instead.
bool ScriptToolbox::removeFile ( const QString name)
slot
Deprecated:
Use QFile.removeFile(oldName, newName) instead
bool ScriptToolbox::removePath ( const QString rmPath,
const QString rootPath 
)
slot
Deprecated:
Use var dir = new QDir(rootPath) followed by dir.rmpath(rmPath) instead
bool ScriptToolbox::renameFile ( const QString oldName,
const QString newName 
)
slot
Deprecated:
Use QFile.rename(oldName, newName) instead
QString ScriptToolbox::rootPath ( )
slot
QObject * ScriptToolbox::runTimeVal ( )
slot

Get a standard Run Time QValidator.

Deprecated:
Use mainwindow.runTimeVal() instead.
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().

See also
creditCard::saveCreditCard
void ScriptToolbox::setLastWindow ( QWidget lw)
static

Override the last window opened by this toolbox instance.

QString ScriptToolbox::storedProcErrorLookup ( const QString  proc,
const int  result 
)
slot

This is a wrapper around the core storedProcErrorLookup.

int ScriptToolbox::tabCount ( QWidget tab)
slot

Find the number of tabs in the QTabWidget.

Deprecated:
Use QTabWidget::count directly.
int ScriptToolbox::tabInsertTab ( QWidget tab,
int  idx,
QWidget page,
const QString text 
)
slot

Insert a new tab into a QTabWidget.

Deprecated:
Use QTabWidget::insertTab directly.
void ScriptToolbox::tabRemoveTab ( QWidget tab,
int  idx 
)
slot

Remove a particular tab from a QTabWidget.

Deprecated:
Use QTabWidget::removeTab directly.
void ScriptToolbox::tabSetTabEnabled ( QWidget tab,
int  idx,
bool  enable 
)
slot

Enable or disable a particular tab on a QTabWidget.

Deprecated:
Use QTabWidget::setTabEnabled directly.
void ScriptToolbox::tabSetTabText ( QWidget tab,
int  idx,
const QString text 
)
slot

Set the text for a particular tab on a QTabWidget.

Deprecated:
Use QTabWidget::setTabText directly.
int ScriptToolbox::tabTabIndex ( QWidget tab,
QWidget page 
)
slot

Get the index of a particular tab in a QTabWidget.

Deprecated:
Use QTabWidget::indexOf directly.
QString ScriptToolbox::tabtabText ( QWidget tab,
int  idx 
)
slot

Get the text for a particular tab on a QTabWidget.

Deprecated:
Use QTabWidget::tabText directly.
QWidget * ScriptToolbox::tabWidget ( QWidget tab,
int  idx 
)
slot

Return the QWidget for a particular tab in a QTabWidget.

Deprecated:
Use QTabWidget::widget directly.
QString ScriptToolbox::textStreamRead ( const QString name)
slot

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.

Parameters
nameThe name of the file to open
Returns
The textual content of the file, or "error" if the file could not be opened
See also
QFile
QTextStream
bool ScriptToolbox::textStreamWrite ( const QString pName,
const QString WriteText 
)
slot

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.

Parameters
pNameThe name of the file to create
WriteTextThe string to write to the file
Returns
True if successful; false if any errors were detected
See also
QFile
QTextStream
QObject * ScriptToolbox::TransQtyVal ( )
slot

Get a standard Transfer Quantity QValidator.

Deprecated:
Use mainwindow.transQtyVal() instead.
QObject * ScriptToolbox::weightVal ( )
slot

Get a standard Weight QValidator.

Deprecated:
Use mainwindow.weightVal() instead.
QObject * ScriptToolbox::widgetGetLayout ( QWidget w)
slot

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 _expand = toolbox.createWidget("QPushButton", mywindow, "_expand");
var _collapse = toolbox.createWidget("QPushButton", mywindow, "_collapse");
/* Set the text of those buttons.
qsTr allows the text to be translated while the & creates a hotkey
that can be used to click the button from the keyboard.
*/
_expand.text = qsTr("E&xpand All");
_collapse.text = qsTr("C&ollapse All");
// To position the new buttons, first find the layout container that holds _list
var _layout = toolbox.widgetGetLayout(_list);
/* _layout happens to be a QGridLayout and _list is in row 2, column 0. To put
_expand and _collapse under _list, we place them in rows 3 and 4, col 0.
*/
_layout.addWidget(_expand, 3, 0);
_layout.addWidget(_collapse, 4, 0);

Parameters
wThe widget whose layout you want to find
Returns
A pointer to the layout or 0 if no such layout could be found

The documentation for this class was generated from the following files:

Generated on Wed Nov 30 2016 xTuple ERP Programmer Reference, Version 4.10.0 doxygen 1.8.7