0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-10-04 04:06:43 +03:00

removed sort case sensitivity

This commit is contained in:
yanis60
2024-05-30 17:26:00 +01:00
parent 8915075561
commit 84c0f652d8
6 changed files with 54 additions and 41 deletions

View File

@@ -81,7 +81,7 @@ private:
bool m_resetPageNumber;
QString m_condition;
QString m_conditionValue;
Qt::SortOrder m_sortFieldNameBy;
Qt::SortOrder m_sortFieldNameBy = Qt::AscendingOrder;
};
class GroupBandFooter : public BandDesignIntf{

View File

@@ -199,6 +199,7 @@ ModelToDataSource::ModelToDataSource(QAbstractItemModel* model, bool owned)
model->fetchMore(QModelIndex());
if (model->rowCount() <= 0) break;
}
connect(model, SIGNAL(destroyed()), this, SLOT(slotModelDestroed()));
connect(model, SIGNAL(modelReset()), this, SIGNAL(modelStateChanged()));
}
@@ -306,6 +307,12 @@ int ModelToDataSource::columnCount()
return m_model->columnCount();
}
int ModelToDataSource::rowCount()
{
if (isInvalid()) return 0;
return m_model->rowCount();
}
QString ModelToDataSource::columnNameByIndex(int columnIndex)
{
if (isInvalid()) return "";

View File

@@ -107,7 +107,7 @@ public:
void setPort(QString port);
public:
static QString connectionNameForUser(const QString& connectionName);
static QString connectionNameForReport(const QString& connectionName);
static QString connectionNameForReport(const QString& connectionName);
signals:
void nameChanged(const QString& oldName,const QString& newName);
private:
@@ -325,7 +325,7 @@ private:
QString m_name;
};
class MasterDetailProxyModel : public QSortFilterProxyModel{
class MasterDetailProxyModel : public QSortFilterProxyModel{
Q_OBJECT
public:
MasterDetailProxyModel(DataSourceManager* dataManager):m_maps(0),m_dataManager(dataManager){}
@@ -392,6 +392,7 @@ public:
QVariant dataByRowIndex(const QString &columnName, int rowIndex, const QString &roleName);
QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData);
int columnCount();
int rowCount();
QString columnNameByIndex(int columnIndex);
int columnIndexByName(QString name);
QVariant headerData(const QString &columnName, const QString &roleName);

View File

@@ -181,6 +181,7 @@ void ReportRender::initDatasources(){
void ReportRender::initDatasource(const QString& name){
try{
if (datasources()->containsDatasource(name)){
if(m_dataSourceSorted)return;
IDataSource* ds = datasources()->dataSource(name);
if (ds)
ds->first();
@@ -259,8 +260,10 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool
clearPageMap();
try{
datasources()->setAllDatasourcesToFirst();
datasources()->clearGroupFuntionsExpressions();
} catch(ReportError &exception){
//TODO possible should thow exeption
QMessageBox::critical(0,tr("Error"),exception.what());
@@ -274,6 +277,7 @@ void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool
m_dataSourceSorted = false;
BandDesignIntf* lastRenderedBand = 0;
for (int i=0;i<m_patternPageItem->dataBandCount() && !m_renderCanceled; i++){
lastRenderedBand = m_patternPageItem->dataBandAt(i);
initDatasource(lastRenderedBand->datasourceName());
renderDataBand(lastRenderedBand);
@@ -696,7 +700,6 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
IDataSource* bandDatasource = 0;
m_lastRenderedFooter = 0;
if (!dataBand->datasourceName().isEmpty())
bandDatasource = datasources()->dataSource(dataBand->datasourceName());
@@ -968,10 +971,12 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
GroupBandHeader *group = dynamic_cast<GroupBandHeader*>(parentBand);
if(dataSource->model() && group && !group->groupFieldName().isEmpty() && !m_dataSourceSorted)
{
MasterDetailProxyModel *proxyModel = static_cast<MasterDetailProxyModel*>(dataSource->model());
if(proxyModel)
{
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
//proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
proxyModel->sort(dataSource->columnIndexByName(group->groupFieldName()),group->SortFieldNameBy());
m_dataSourceSorted = true;