mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
getFieldByRowIndex() has been added
This commit is contained in:
parent
e0ef984fca
commit
3bd49b6ffd
@ -17,6 +17,7 @@ public:
|
|||||||
virtual bool bof() = 0;
|
virtual bool bof() = 0;
|
||||||
virtual bool eof() = 0;
|
virtual bool eof() = 0;
|
||||||
virtual QVariant data(const QString& columnName) = 0;
|
virtual QVariant data(const QString& columnName) = 0;
|
||||||
|
virtual QVariant dataByRowIndex(const QString& columnName, int rowIndex) = 0;
|
||||||
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0;
|
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0;
|
||||||
virtual int columnCount() = 0;
|
virtual int columnCount() = 0;
|
||||||
virtual QString columnNameByIndex(int columnIndex) = 0;
|
virtual QString columnNameByIndex(int columnIndex) = 0;
|
||||||
|
@ -258,6 +258,13 @@ QVariant ModelToDataSource::data(const QString &columnName)
|
|||||||
return m_model->data(m_model->index(currentRow(),columnIndexByName(columnName)));
|
return m_model->data(m_model->index(currentRow(),columnIndexByName(columnName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant ModelToDataSource::dataByRowIndex(const QString &columnName, int rowIndex)
|
||||||
|
{
|
||||||
|
if (m_model->rowCount() > rowIndex)
|
||||||
|
return m_model->data(m_model->index(rowIndex, columnIndexByName(columnName)));
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant ModelToDataSource::dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData)
|
QVariant ModelToDataSource::dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData)
|
||||||
{
|
{
|
||||||
for( int i=0; i < m_model->rowCount(); ++i ){
|
for( int i=0; i < m_model->rowCount(); ++i ){
|
||||||
@ -693,6 +700,21 @@ QVariant CallbackDatasource::data(const QString& columnName)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant CallbackDatasource::dataByRowIndex(const QString &columnName, int rowIndex)
|
||||||
|
{
|
||||||
|
int backupCurrentRow = m_currentRow;
|
||||||
|
QVariant result = QVariant();
|
||||||
|
first();
|
||||||
|
for (int i = 0; i < rowIndex && !eof(); ++i, next()){}
|
||||||
|
if (!eof()) result = callbackData(columnName, rowIndex);
|
||||||
|
first();
|
||||||
|
if (backupCurrentRow != -1){
|
||||||
|
for (int i = 0; i < backupCurrentRow; ++i)
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant CallbackDatasource::dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData)
|
QVariant CallbackDatasource::dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData)
|
||||||
{
|
{
|
||||||
int backupCurrentRow = m_currentRow;
|
int backupCurrentRow = m_currentRow;
|
||||||
|
@ -328,6 +328,7 @@ public:
|
|||||||
bool eof();
|
bool eof();
|
||||||
bool bof();
|
bool bof();
|
||||||
QVariant data(const QString& columnName);
|
QVariant data(const QString& columnName);
|
||||||
|
QVariant dataByRowIndex(const QString &columnName, int rowIndex);
|
||||||
QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData);
|
QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData);
|
||||||
int columnCount();
|
int columnCount();
|
||||||
QString columnNameByIndex(int columnIndex);
|
QString columnNameByIndex(int columnIndex);
|
||||||
@ -360,6 +361,7 @@ public:
|
|||||||
bool bof(){return m_currentRow == -1;}
|
bool bof(){return m_currentRow == -1;}
|
||||||
bool eof(){return m_eof;}
|
bool eof(){return m_eof;}
|
||||||
QVariant data(const QString &columnName);
|
QVariant data(const QString &columnName);
|
||||||
|
QVariant dataByRowIndex(const QString& columnName, int rowIndex);
|
||||||
QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData);
|
QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData);
|
||||||
int columnCount();
|
int columnCount();
|
||||||
QString columnNameByIndex(int columnIndex);
|
QString columnNameByIndex(int columnIndex);
|
||||||
|
@ -17,6 +17,7 @@ public:
|
|||||||
virtual bool bof() = 0;
|
virtual bool bof() = 0;
|
||||||
virtual bool eof() = 0;
|
virtual bool eof() = 0;
|
||||||
virtual QVariant data(const QString& columnName) = 0;
|
virtual QVariant data(const QString& columnName) = 0;
|
||||||
|
virtual QVariant dataByRowIndex(const QString& columnName, int rowIndex) = 0;
|
||||||
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0;
|
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0;
|
||||||
virtual int columnCount() = 0;
|
virtual int columnCount() = 0;
|
||||||
virtual QString columnNameByIndex(int columnIndex) = 0;
|
virtual QString columnNameByIndex(int columnIndex) = 0;
|
||||||
|
@ -1469,6 +1469,17 @@ QVariant DataSourceManager::fieldData(const QString &fieldName)
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant DataSourceManager::fieldDataByRowIndex(const QString &fieldName, int rowIndex)
|
||||||
|
{
|
||||||
|
if (containsField(fieldName)){
|
||||||
|
IDataSource* ds = dataSource(extractDataSource(fieldName));
|
||||||
|
if (ds){
|
||||||
|
return ds->dataByRowIndex(extractFieldName(fieldName), rowIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant DataSourceManager::fieldDataByKey(const QString& datasourceName, const QString& valueFieldName, const QString& keyFieldName, QVariant keyValue)
|
QVariant DataSourceManager::fieldDataByKey(const QString& datasourceName, const QString& valueFieldName, const QString& keyFieldName, QVariant keyValue)
|
||||||
{
|
{
|
||||||
IDataSource* ds = dataSource(datasourceName);
|
IDataSource* ds = dataSource(datasourceName);
|
||||||
|
@ -167,6 +167,7 @@ public:
|
|||||||
QStringList fieldNames(const QString& datasourceName);
|
QStringList fieldNames(const QString& datasourceName);
|
||||||
bool containsField(const QString& fieldName);
|
bool containsField(const QString& fieldName);
|
||||||
QVariant fieldData(const QString& fieldName);
|
QVariant fieldData(const QString& fieldName);
|
||||||
|
QVariant fieldDataByRowIndex(const QString& fieldName, int rowIndex);
|
||||||
QVariant fieldDataByKey(
|
QVariant fieldDataByKey(
|
||||||
const QString& datasourceName,
|
const QString& datasourceName,
|
||||||
const QString& valueFieldName,
|
const QString& valueFieldName,
|
||||||
|
Loading…
Reference in New Issue
Block a user