QSortFilterProxyModel is very slow with strings



  • We have a problem with a simple QSortFilterProxyModel. My model is very slow when i use the sort method.
    Can anybody fix my problem?
    I put the code.

    @flightsModel = new LroOptimalDelayedFlightPlansModel();
    sortModel = new QSortFilterProxyModel(this);
    sortModel->setSourceModel(flightsModel);
    ui->tableViewFlightPlans->setModel(sortModel);
    configurationViewFlightPlans();
    connect(flightsModel, SIGNAL(sortModel()), this, SLOT(sortModelAfterValuesChanged()));
    

    QVariant LroDelayedFlightPlansModel::data(const QModelIndex &index, int role) const
    {
    if((!index.isValid()) ||
    (index.row() >= rowCount(index)))
    {
    return QVariant();
    }

    if(role == Qt::DisplayRole)
    {
    
        if(index.column() == 0)
        {
            return QString::fromStdString(fp.getFPs(index.row()).getCallsign());
        }
        else if(index.column() == 1)
        {
            return QString::fromStdString(fp.getFPs(index.row()).getOpType());
        }
        else if(index.column() == 2)
        {
            if(fp.getFPs(index.row()).getOpType() == "DEP")
            {
                return QString::fromStdString(
                            fp.getFPs(index.row()).getDepartureTimes().getItot());
            }
            else
            {
                return QString::fromStdString(
                            fp.getFPs(index.row() ).getArrivalTimes().getIldt());
            }
        }
        else if(index.column() == 3)
        {
            if(fp.getFPs(index.row()).getOpType() == "DEP")
            {
                return QString::fromStdString(
                            fp.getFPs(index.row()).getDepartureTimes().getStot());
            }
            else
            {
                return QString::fromStdString(
                            fp.getFPs(index.row()).getArrivalTimes().getSldt());
            }
        }
        else if(index.column() == 4)
        {
            if(fp.getFPs(index.row()).getOpType() == "DEP")
            {
                return QString::fromStdString(
                            fp.getFPs(index.row()).getDepartureTimes().getFtot());
            }
            else
            {
                return QString::fromStdString(
                            fp.getFPs(index.row()).getArrivalTimes().getFldt());
            }
        }
        else if(index.column() == 5)
        {
            return QVariant(fp.getFPs(index.row()).getForecastDelay());
        }
        else if(index.column() == 6)
        {
            return QVariant(fp.getFPs(index.row()).getPunctualityDelay());
        }
        else if(index.column() == 7)
        {
            return QString::fromStdString(fp.getFPs(index.row()).getRunwayAllocation());
        }
    
        return QVariant();
    }
    else if(role == Qt::TextAlignmentRole)
    {
        return Qt::AlignCenter;
    }
    return QVariant();
    

    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.