mirror of
https://github.com/fralx/LimeReport.git
synced 2025-11-25 00:18:06 +03:00
Add: added a function to get an arbitrary role of a model item
Example:
$D{appdata.Column_1}
$S{
var vRow = line('DataBand1') - 1;
// 8 - Qt::BackgroundRole
var vColor = getFieldByRowIndexEx('appdata.Column_1', vRow, 8);
THIS.backgroundColor = LimeReport.color('lightgray');
if(vColor > '')
{
THIS.backgroundColor = vColor;
}
''
}
Added several functions to get extended information from the model
- getFieldByRowIndexEx2(fieldName, rowIndex, roleName), default:
Qt::DisplayRole
- getHeaderData(fieldName, roleName), default: Qt::DisplayRole
- getHeaderColumnNameByIndex(datasourceName, columnIndex), default:
Qt::UserRole or Qt::DisplayRole
- getColumnCount(datasourceName), default: -1
This commit is contained in:
@@ -378,6 +378,43 @@ public:
|
||||
Q_INVOKABLE void addTableOfContentsItem(const QString& uniqKey, const QString& content, int indent = 0);
|
||||
Q_INVOKABLE void clearTableOfContents();
|
||||
Q_INVOKABLE QFont font(const QString& family, int pointSize = -1, bool bold = false, bool italic = false, bool underLine = false);
|
||||
/*!
|
||||
* \brief getFieldByRowIndexEx Выдает для поля значение заданной роли
|
||||
* \param fieldName имя источника данных + имя поля
|
||||
* \param rowIndex индекс строки
|
||||
* \param role код роли
|
||||
* \return
|
||||
*/
|
||||
Q_INVOKABLE QVariant getFieldByRowIndexEx(const QString &fieldName, int rowIndex, const int role);
|
||||
/*!
|
||||
* \brief getFieldByRowIndexEx2 Выдает для поля значение заданной роли
|
||||
* \param fieldName имя источника данных + имя поля
|
||||
* \param rowIndex индекс строки
|
||||
* \param roleName имя роли из roleNames()
|
||||
* \return
|
||||
*/
|
||||
Q_INVOKABLE QVariant getFieldByRowIndexEx2(const QString &fieldName, int rowIndex, const QString &roleName);
|
||||
/*!
|
||||
* \brief getHeaderData Выдает для поля заголовка значение заданной роли
|
||||
* \param fieldName имя источника данных + имя поля
|
||||
* \param role имя роли из roleNames()
|
||||
* \return
|
||||
*/
|
||||
Q_INVOKABLE QVariant getHeaderData(const QString &fieldName, const QString &roleName);
|
||||
/*!
|
||||
* \brief getHeaderColumnNameByIndex Выдает имя колонки по ее индексу (имя используемое LR)
|
||||
* \param datasourceName имя источника данных
|
||||
* \param columnIndex индекс колонки
|
||||
* \return
|
||||
*/
|
||||
Q_INVOKABLE QVariant getHeaderColumnNameByIndex(const QString &datasourceName, const int columnIndex);
|
||||
/*!
|
||||
* \brief getColumnCount Выдает число столбцов в источнике данных
|
||||
* \param datasourceName имя источника данных
|
||||
* \return возможно -1 при ошибке
|
||||
*/
|
||||
Q_INVOKABLE int getColumnCount(const QString &datasourceName);
|
||||
|
||||
#ifdef USE_QJSENGINE
|
||||
Q_INVOKABLE void addItemsToComboBox(QJSValue object, const QStringList& values);
|
||||
Q_INVOKABLE void addItemToComboBox(QJSValue object, const QString& value);
|
||||
@@ -506,6 +543,12 @@ private:
|
||||
bool createAddTableOfContentsItemFunction();
|
||||
bool createClearTableOfContentsFunction();
|
||||
bool createReopenDatasourceFunction();
|
||||
bool createGetFieldByRowIndexEx();
|
||||
bool createGetFieldByRowIndexEx2();
|
||||
bool createHeaderData();
|
||||
bool createHeaderColumnNameByIndex();
|
||||
bool createColumnCount();
|
||||
|
||||
private:
|
||||
ScriptEngineManager();
|
||||
ScriptEngineType* m_scriptEngine;
|
||||
|
||||
Reference in New Issue
Block a user