mirror of
https://github.com/fralx/LimeReport.git
synced 2025-12-16 01:39:55 +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:
@@ -1689,6 +1689,28 @@ QVariant DataSourceManager::fieldDataByRowIndex(const QString &fieldName, int ro
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant DataSourceManager::fieldDataByRowIndex(const QString &fieldName, int rowIndex, int role)
|
||||
{
|
||||
if(containsField(fieldName)) {
|
||||
IDataSource *ds = dataSource(extractDataSource(fieldName));
|
||||
if(ds) {
|
||||
return ds->dataByRowIndex(extractFieldName(fieldName), rowIndex, role);
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant DataSourceManager::fieldDataByRowIndex(const QString &fieldName, int rowIndex, const QString &roleName)
|
||||
{
|
||||
if(containsField(fieldName)) {
|
||||
IDataSource *ds = dataSource(extractDataSource(fieldName));
|
||||
if(ds) {
|
||||
return ds->dataByRowIndex(extractFieldName(fieldName), rowIndex, roleName);
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant DataSourceManager::fieldDataByKey(const QString& datasourceName, const QString& valueFieldName, const QString& keyFieldName, QVariant keyValue)
|
||||
{
|
||||
IDataSource* ds = dataSource(datasourceName);
|
||||
@@ -1698,6 +1720,36 @@ QVariant DataSourceManager::fieldDataByKey(const QString& datasourceName, const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant DataSourceManager::headerData(const QString &fieldName, const QString &roleName)
|
||||
{
|
||||
if(containsField(fieldName)) {
|
||||
IDataSource *ds = dataSource(extractDataSource(fieldName));
|
||||
if(ds) {
|
||||
return ds->headerData(extractFieldName(fieldName), roleName);
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QString DataSourceManager::columnName(const QString &datasourceName, int index)
|
||||
{
|
||||
IDataSource *ds = dataSource(datasourceName);
|
||||
if(ds && !ds->isInvalid() && ds->columnCount() > index) {
|
||||
return ds->columnNameByIndex(index);
|
||||
}
|
||||
return QString("unknown");
|
||||
}
|
||||
|
||||
int DataSourceManager::columnCount(const QString &datasourceName)
|
||||
{
|
||||
IDataSource *ds = dataSource(datasourceName);
|
||||
if(ds && !ds->isInvalid()) {
|
||||
return ds->columnCount();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DataSourceManager::reopenDatasource(const QString& datasourceName)
|
||||
{
|
||||
QueryHolder* qh = dynamic_cast<QueryHolder*>(dataSourceHolder(datasourceName));
|
||||
|
||||
Reference in New Issue
Block a user