コード例 #1
0
ファイル: georesolver.cpp プロジェクト: zhao07/leechcraft
	void GeoResolver::Cache (QList<int> ids, QHash<int, QString>& result, GeoIdType type)
	{
		auto newEnd = std::remove_if (ids.begin (), ids.end (),
				[&result] (int id) { return result.contains (id); });
		ids.erase (newEnd, ids.end ());

		Conn_->RequestGeoIds (ids,
				[&result] (const QHash<int, QString>& newItems)
					{ result.unite (newItems); },
				type);
	}
コード例 #2
0
QHash<int, QString> getMoves(const Pokemon::uniqueId &num, int gen, bool root = true) {
    QHash<int, QString> ret;
    if (gen != 1 && gen != 3) {
        ret = getMoves(num, gen-1, false);
    }
    return ret.unite(map_container_with_value(PokemonInfo::TMMoves(num, gen), root ? QObject::tr("TM/HM") : QObject::tr("%1G TM/HM").arg(gen)))
              .unite(map_container_with_value(PokemonInfo::TutorMoves(num, gen), root ? QObject::tr("Tutor") : QObject::tr("%1G Tutor").arg(gen)))
              .unite(map_container_with_value(PokemonInfo::LevelMoves(num, gen), root ? QObject::tr("Level") : QObject::tr("%1G Level").arg(gen)))
              .unite(map_container_with_value(PokemonInfo::PreEvoMoves(num, gen), root ? QObject::tr("Pre Evo") :QObject:: tr("%1G Pre Evo").arg(gen)))
              .unite(map_container_with_value(PokemonInfo::EggMoves(num, gen), root ? QObject::tr("Breeding") : QObject::tr("%1G Breeding").arg(gen)))
              .unite((gen == 5 ? map_container_with_value(PokemonInfo::dreamWorldMoves(num), QObject::tr("Dream World")) : QHash<int, QString>()))
              .unite(map_container_with_value(PokemonInfo::SpecialMoves(num, gen), root ? QObject::tr("Special", "Learning") : QObject::tr("%1G Special").arg(gen)));
}
コード例 #3
0
ファイル: rssfolder.cpp プロジェクト: AdunanzA/Tsunami-Old
QHash<QString, RssFeedPtr> RssFolder::getAllFeedsAsHash() const {
  QHash<QString, RssFeedPtr> ret;

  RssFileHash::ConstIterator it = m_children.begin();
  RssFileHash::ConstIterator itend = m_children.end();
  for ( ; it != itend; ++it) {
    if (RssFeedPtr feed = qSharedPointerDynamicCast<RssFeed>(it.value())) {
      qDebug() << Q_FUNC_INFO << feed->url();
      ret[feed->url()] = feed;
    } else if (RssFolderPtr folder = qSharedPointerDynamicCast<RssFolder>(it.value())) {
      ret.unite(folder->getAllFeedsAsHash());
    }
  }
  return ret;
}
コード例 #4
0
ファイル: georesolver.cpp プロジェクト: zhao07/leechcraft
	void GeoResolver::Get (int code, std::function<void (QString)> setter,
			QHash<int, QString>& hash, GeoIdType type)
	{
		if (hash.contains (code))
		{
			setter (hash [code]);
			return;
		}

		Conn_->RequestGeoIds ({ code },
				[&hash, setter, code] (const QHash<int, QString>& result)
				{
					hash.unite (result);
					setter (result [code]);
				},
				type);
	}
コード例 #5
0
ファイル: ImportHTML.cpp プロジェクト: Mingkeo/Sigil
// Loads the referenced files into the main folder of the book;
// as the files get a new name, the references are updated
QHash<QString, QString> ImportHTML::LoadFolderStructure(const QString & source)
{
    QStringList mediapaths = XhtmlDoc::GetPathsToMediaFiles(source);
    QStringList stylepaths = XhtmlDoc::GetPathsToStyleFiles(source);
    QFutureSynchronizer<QHash<QString, QString>> sync;
    sync.addFuture(QtConcurrent::run(this, &ImportHTML::LoadMediaFiles,  mediapaths));
    sync.addFuture(QtConcurrent::run(this, &ImportHTML::LoadStyleFiles,  stylepaths));
    sync.waitForFinished();
    QList<QFuture<QHash<QString, QString>>> futures = sync.futures();
    int num_futures = futures.count();
    QHash<QString, QString> updates;

    for (int i = 0; i < num_futures; ++i) {
        updates.unite(futures.at(i).result());
    }

    return updates;
}
コード例 #6
0
ファイル: datasetparser.cpp プロジェクト: TinaSeifpoor/repo
QVariantList DatasetParser::parseDataFile(QFileInfo dataFileInfo)
{
    QVariantList datasetDescriptor;
    QHash<int,int> instanceDescriptor;
    QHash<int,QString> classDescriptor;
    QFile dataFile(dataFileInfo.filePath());
    QString datasetDescriptionPlain;
    if (dataFile.open(QIODevice::ReadOnly))
        datasetDescriptionPlain = dataFile.readAll();
    else
    {
        qDebug(QString("Can't open file: %1").arg(dataFileInfo.absoluteFilePath()).toAscii());
        return QVariantList();
    }

    QStringList instanceDescriptionPlainList = datasetDescriptionPlain.split(instanceSeperator);
    QStringList headerList = instanceDescriptionPlainList.takeFirst().split(headerSeperator);
    int instanceUniqueIDIndex = headerList.indexOf(instanceUniqueIDHeader);
    int classNameIndex = headerList.indexOf(classNameHeader);
    int classIDIndex = headerList.indexOf(classIDHeader);

    foreach (QString instanceDescriptionPlain, instanceDescriptionPlainList)
    {
        QStringList instanceDescriptionList = instanceDescriptionPlain.split(headerSeperator);
        QString className = instanceDescriptionList[classNameIndex];
        int classID = instanceDescriptionList[classIDIndex].toInt();
        if (!classDescriptor[classID].isEmpty())
        {
            if (classDescriptor[classID] != className)
            {
                qDebug(QString("Class ID %1 is matched to classes with names %2 & %3").arg(classID).arg(classDescriptor[classIDIndex]).arg(className).toAscii());
            }
        }
        else
            classDescriptor[classID] = className;
        QString instanceUniqueID = instanceDescriptionList[instanceUniqueIDIndex];
        instanceDescriptor.unite(this->parseInstanceUniqueID(instanceUniqueID, classID));
    }
コード例 #7
0
bool XsdParticleChecker::subsumes(const XsdParticle::Ptr &particle, const XsdParticle::Ptr &derivedParticle, const XsdSchemaContext::Ptr &context, QString &errorMsg)
{
    /**
     * The algorithm is implemented like described in http://www.ltg.ed.ac.uk/~ht/XML_Europe_2003.html#S2.3
     */

    const NamePool::Ptr namePool(context->namePool());

    XsdStateMachine<XsdTerm::Ptr> baseStateMachine(namePool);
    XsdStateMachine<XsdTerm::Ptr> derivedStateMachine(namePool);

    // build up state machines for both particles
    {
        XsdStateMachineBuilder builder(&baseStateMachine, namePool);
        const XsdStateMachine<XsdTerm::Ptr>::StateId endState = builder.reset();
        const XsdStateMachine<XsdTerm::Ptr>::StateId startState = builder.buildParticle(particle, endState);
        builder.addStartState(startState);

        baseStateMachine = baseStateMachine.toDFA();
    }
    {
        XsdStateMachineBuilder builder(&derivedStateMachine, namePool);
        const XsdStateMachine<XsdTerm::Ptr>::StateId endState = builder.reset();
        const XsdStateMachine<XsdTerm::Ptr>::StateId startState = builder.buildParticle(derivedParticle, endState);
        builder.addStartState(startState);

        derivedStateMachine = derivedStateMachine.toDFA();
    }

    QHash<XsdTerm::Ptr, XsdParticle::Ptr> particlesHash = XsdStateMachineBuilder::particleLookupMap(particle);
    particlesHash.unite(XsdStateMachineBuilder::particleLookupMap(derivedParticle));

/*
    static int counter = 0;
    {
        QFile file(QString("/tmp/file_base%1.dot").arg(counter));
        file.open(QIODevice::WriteOnly);
        baseStateMachine.outputGraph(&file, QLatin1String("Base"));
        file.close();
    }
    {
        QFile file(QString("/tmp/file_derived%1.dot").arg(counter));
        file.open(QIODevice::WriteOnly);
        derivedStateMachine.outputGraph(&file, QLatin1String("Base"));
        file.close();
    }
    ::system(QString("dot -Tpng /tmp/file_base%1.dot -o/tmp/file_base%1.png").arg(counter).toLatin1().data());
    ::system(QString("dot -Tpng /tmp/file_derived%1.dot -o/tmp/file_derived%1.png").arg(counter).toLatin1().data());
*/

    const XsdStateMachine<XsdTerm::Ptr>::StateId baseStartState = baseStateMachine.startState();
    const QHash<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateType> baseStates = baseStateMachine.states();
    const QHash<XsdStateMachine<XsdTerm::Ptr>::StateId, QHash<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > > baseTransitions = baseStateMachine.transitions();

    const XsdStateMachine<XsdTerm::Ptr>::StateId derivedStartState = derivedStateMachine.startState();
    const QHash<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateType> derivedStates = derivedStateMachine.states();
    const QHash<XsdStateMachine<XsdTerm::Ptr>::StateId, QHash<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > > derivedTransitions = derivedStateMachine.transitions();

    // @see http://www.ltg.ed.ac.uk/~ht/XML_Europe_2003.html#S2.3.1

    // define working set
    QList<QPair<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateId> > workSet;
    QList<QPair<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateId> > processedSet;

    // 1) fill working set initially with start states
    workSet.append(qMakePair<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateId>(baseStartState, derivedStartState));
    processedSet.append(qMakePair<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateId>(baseStartState, derivedStartState));

    while (!workSet.isEmpty()) { // while there are state sets to process

        // 3) dequeue on state set
        const QPair<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateId> set = workSet.takeFirst();

        const QHash<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > derivedTrans = derivedTransitions.value(set.second);
        QHashIterator<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > derivedIt(derivedTrans);

        const QHash<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > baseTrans = baseTransitions.value(set.first);

        while (derivedIt.hasNext()) {
            derivedIt.next();

            bool found = false;
            QHashIterator<XsdTerm::Ptr, QVector<XsdStateMachine<XsdTerm::Ptr>::StateId> > baseIt(baseTrans);
            while (baseIt.hasNext()) {
                baseIt.next();
                if (derivedTermValid(baseIt.key(), derivedIt.key(), particlesHash, context, errorMsg)) {
                    const QPair<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateId> endSet =
                             qMakePair<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateId>(baseIt.value().first(), derivedIt.value().first());
                    if (!processedSet.contains(endSet) && !workSet.contains(endSet)) {
                        workSet.append(endSet);
                        processedSet.append(endSet);
                    }

                    found = true;
                }
            }

            if (!found) {
                return false;
            }
        }
    }

    // 5)
    QHashIterator<XsdStateMachine<XsdTerm::Ptr>::StateId, XsdStateMachine<XsdTerm::Ptr>::StateType> it(derivedStates);
    while (it.hasNext()) {
        it.next();

        if (it.value() == XsdStateMachine<XsdTerm::Ptr>::EndState || it.value() == XsdStateMachine<XsdTerm::Ptr>::StartEndState) {
            for (int i = 0; i < processedSet.count(); ++i) {
                if (processedSet.at(i).second == it.key() &&
                    (baseStates.value(processedSet.at(i).first) != XsdStateMachine<XsdTerm::Ptr>::EndState &&
                     baseStates.value(processedSet.at(i).first) != XsdStateMachine<XsdTerm::Ptr>::StartEndState)) {
                    errorMsg = QtXmlPatterns::tr("Derived particle allows content that is not allowed in the base particle.");
                    return false;
                }
            }
        }
    }

    return true;
}
コード例 #8
0
ファイル: MapStyle_P.cpp プロジェクト: Congle/OsmAnd-core
bool OsmAnd::MapStyle_P::parse( QXmlStreamReader& xmlReader )
{
    auto rulesetType = MapStyleRulesetType::Invalid;

    struct Lexeme
    {
        enum Type
        {
            Rule,
            Group,
        };

        Lexeme(Type type_, MapStyle_P* style_)
            : type(type_)
            , style(style_)
        {}

        const Type type;
        MapStyle_P* const style;
    };

    struct Rule : public Lexeme
    {
        Rule(std::shared_ptr<MapStyleRule> rule_, MapStyle_P* style_)
            : Lexeme(Lexeme::Rule, style_)
            , rule(rule_)
        {}

        const std::shared_ptr<MapStyleRule> rule;
    };

    struct Group : public Lexeme
    {
        Group(MapStyle_P* const style_)
            : Lexeme(Lexeme::Group, style_)
        {}

        QHash< QString, QString > attributes;
        QList< std::shared_ptr<MapStyleRule> > children;
        QList< std::shared_ptr<Lexeme> > subgroups;

        void addGroupFilter(const std::shared_ptr<MapStyleRule>& rule)
        {
            for(auto itChild = children.cbegin(); itChild != children.cend(); ++itChild)
            {
                auto child = *itChild;

                child->_d->_ifChildren.push_back(rule);
            }

            for(auto itSubgroup = subgroups.cbegin(); itSubgroup != subgroups.cend(); ++itSubgroup)
            {
                auto subgroup = *itSubgroup;

                assert(subgroup->type == Lexeme::Group);
                std::static_pointer_cast<Group>(subgroup)->addGroupFilter(rule);
            }
        }

        bool registerGlobalRules(const MapStyleRulesetType type)
        {
            for(auto itChild = children.cbegin(); itChild != children.cend(); ++itChild)
            {
                auto child = *itChild;

                if(!style->registerRule(type, child))
                    return false;
            }

            for(auto itSubgroup = subgroups.cbegin(); itSubgroup != subgroups.cend(); ++itSubgroup)
            {
                auto subgroup = *itSubgroup;

                assert(subgroup->type == Lexeme::Group);
                if(!std::static_pointer_cast<Group>(subgroup)->registerGlobalRules(type))
                    return false;
            }

            return true;
        }
    };

    QStack< std::shared_ptr<Lexeme> > stack;

    while (!xmlReader.atEnd() && !xmlReader.hasError())
    {
        xmlReader.readNext();
        const auto tagName = xmlReader.name();
        if (xmlReader.isStartElement())
        {
            if(tagName == QLatin1String("renderingStyle"))
            {
                // We have already parsed metadata and resolved dependencies, so here we don't need to do anything
            }
            else if(tagName == QLatin1String("renderingConstant"))
            {
                const auto& attribs = xmlReader.attributes();

                auto name = attribs.value(QLatin1String("name")).toString();
                auto value = attribs.value(QLatin1String("value")).toString();
                _parsetimeConstants.insert(name, value);
            }
            else if(tagName == QLatin1String("renderingProperty"))
            {
                MapStyleConfigurableInputValue* inputValue = nullptr;

                const auto& attribs = xmlReader.attributes();
                auto name = obtainValue(attribs.value(QLatin1String("attr")).toString());
                auto type = obtainValue(attribs.value(QLatin1String("type")).toString());
                auto title = obtainValue(attribs.value(QLatin1String("name")).toString());
                auto description = attribs.value(QLatin1String("description")).toString();
                auto encodedPossibleValues = attribs.value(QLatin1String("possibleValues"));
                QStringList possibleValues;
                if(!encodedPossibleValues.isEmpty())
                    possibleValues = encodedPossibleValues.toString().split(',', QString::SkipEmptyParts);
                for(auto itPossibleValue = possibleValues.begin(); itPossibleValue != possibleValues.end(); ++itPossibleValue)
                {
                    auto& possibleValue = *itPossibleValue;
                    possibleValue = obtainValue(possibleValue);
                }
                if(type == QLatin1String("string"))
                {
                    inputValue = new MapStyleConfigurableInputValue(
                        MapStyleValueDataType::String,
                        name,
                        title,
                        description,
                        possibleValues);
                }
                else if(type == QLatin1String("boolean"))
                {
                    inputValue = new MapStyleConfigurableInputValue(
                        MapStyleValueDataType::Boolean,
                        name,
                        title,
                        description,
                        possibleValues);
                }
                else // treat as integer
                {
                    inputValue = new MapStyleConfigurableInputValue(
                        MapStyleValueDataType::Integer,
                        name,
                        title,
                        description,
                        possibleValues);
                }

                registerValue(inputValue);
            }
            else if(tagName == QLatin1String("renderingAttribute"))
            {
                const auto& attribs = xmlReader.attributes();

                auto name = obtainValue(attribs.value(QLatin1String("name")).toString());

                std::shared_ptr<MapStyleRule> attribute(new MapStyleRule(owner, QHash< QString, QString >()));
                _attributes.insert(name, attribute);

                std::shared_ptr<Lexeme> selector(new Rule(attribute, this));
                stack.push(qMove(selector));
            }
            else if(tagName == QLatin1String("filter"))
            {
                QHash< QString, QString > ruleAttributes;

                if(!stack.isEmpty())
                {
                    auto lexeme = stack.top();

                    if(lexeme->type == Lexeme::Group)
                        ruleAttributes.unite(std::static_pointer_cast<Group>(lexeme)->attributes);
                }

                const auto& attribs = xmlReader.attributes();
                for(auto itXmlAttrib = attribs.cbegin(); itXmlAttrib != attribs.cend(); ++itXmlAttrib)
                {
                    const auto& xmlAttrib = *itXmlAttrib;

                    const auto tag = xmlAttrib.name().toString();
                    const auto value = obtainValue(xmlAttrib.value().toString());
                    ruleAttributes.insert(qMove(tag), qMove(value));
                }

                const std::shared_ptr<MapStyleRule> rule(new MapStyleRule(owner, ruleAttributes));

                if(!stack.isEmpty())
                {
                    auto lexeme = stack.top();

                    if(lexeme->type == Lexeme::Group)
                    {
                        std::static_pointer_cast<Group>(lexeme)->children.push_back(rule);
                    }
                    else if(lexeme->type == Lexeme::Rule)
                    {
                        std::static_pointer_cast<Rule>(lexeme)->rule->_d->_ifElseChildren.push_back(rule);
                    }
                }
                else
                {
                    if(!registerRule(rulesetType, rule))
                        return false;
                }

                stack.push(qMove(std::shared_ptr<Lexeme>(new Rule(rule, this))));
            }
            else if(tagName == QLatin1String("groupFilter"))
            {
                QHash< QString, QString > attributes;

                const auto& attribs = xmlReader.attributes();
                for(auto itXmlAttrib = attribs.cbegin(); itXmlAttrib != attribs.cend(); ++itXmlAttrib)
                {
                    const auto& xmlAttrib = *itXmlAttrib;

                    const auto tag = xmlAttrib.name().toString();
                    const auto value = obtainValue(xmlAttrib.value().toString());
                    attributes.insert(qMove(tag), qMove(value));
                }

                std::shared_ptr<MapStyleRule> rule(new MapStyleRule(owner, attributes));

                if(stack.isEmpty())
                {
                    OsmAnd::LogPrintf(OsmAnd::LogSeverityLevel::Error, "Group filter without parent");
                    return false;
                }

                auto lexeme = stack.top();
                if(lexeme->type == Lexeme::Group)
                {
                    std::static_pointer_cast<Group>(lexeme)->addGroupFilter(rule);
                }
                else if(lexeme->type == Lexeme::Rule)
                {
                    std::static_pointer_cast<Rule>(lexeme)->rule->_d->_ifChildren.push_back(rule);
                }

                stack.push(qMove(std::shared_ptr<Lexeme>(new Rule(rule, this))));
            }
            else if(tagName == QLatin1String("group"))
            {
                const auto group = new Group(this);
                if(!stack.isEmpty())
                {
                    auto lexeme = stack.top();
                    if(lexeme->type == Lexeme::Group)
                        group->attributes.unite(std::static_pointer_cast<Group>(lexeme)->attributes);
                }

                const auto& attribs = xmlReader.attributes();
                for(auto itXmlAttrib = attribs.cbegin(); itXmlAttrib != attribs.cend(); ++itXmlAttrib)
                {
                    const auto& xmlAttrib = *itXmlAttrib;

                    const auto tag = xmlAttrib.name().toString();
                    const auto value = obtainValue(xmlAttrib.value().toString());
                    group->attributes.insert(qMove(tag), qMove(value));
                }

                stack.push(qMove(std::shared_ptr<Lexeme>(group)));
            }
            else if(tagName == QLatin1String("order"))
            {
                rulesetType = MapStyleRulesetType::Order;
            }
            else if(tagName == QLatin1String("text"))
            {
                rulesetType = MapStyleRulesetType::Text;
            }
            else if(tagName == QLatin1String("point"))
            {
                rulesetType = MapStyleRulesetType::Point;
            }
            else if(tagName == QLatin1String("line"))
            {
                rulesetType = MapStyleRulesetType::Polyline;
            }
            else if(tagName == QLatin1String("polygon"))
            {
                rulesetType = MapStyleRulesetType::Polygon;
            } 
        }
        else if(xmlReader.isEndElement())
        {
            if(tagName == QLatin1String("filter"))
            {
                stack.pop();
            }
            else if(tagName == QLatin1String("group"))
            {
                const auto lexeme = stack.pop();

                if (stack.isEmpty())
                {
                    assert(lexeme->type == Lexeme::Group);
                    if(!std::static_pointer_cast<Group>(lexeme)->registerGlobalRules(rulesetType))
                        return false;
                }
                else
                {
                    const auto group = stack.top();
                    if(group->type == Lexeme::Group)
                        std::static_pointer_cast<Group>(group)->subgroups.push_back(qMove(lexeme));
                }
            }
            else if(tagName == QLatin1String("groupFilter"))
            {
                stack.pop();
            }
            else if(tagName == QLatin1String("renderingAttribute"))
            {
                stack.pop();
            }
        }
    }
    if(xmlReader.hasError())
    {
        std::cerr << qPrintable(xmlReader.errorString()) << "(" << xmlReader.lineNumber() << ", " << xmlReader.columnNumber() << ")" << std::endl;
        return false;
    }

    return true;
}
コード例 #9
0
void
KernelModel::update()
{
    QHash<QString, QString> installedKernelPackages = getInstalledPackages();
    QHash<QString, QString> availableKernelPackages = getAvailablePackages();

    QHash<QString, QString> allKernelPackages;
    allKernelPackages.unite( installedKernelPackages );
    QHashIterator<QString, QString> i( availableKernelPackages );
    while ( i.hasNext() )
    {
        i.next();
        allKernelPackages.insert( i.key(), i.value() );
    }

    QString runningKernel = getRunningKernel();
    QStringList ltsKernels = getLtsKernels();
    QStringList recommendedKernels = getRecommendedKernels();

    QSet<QString> modulesToInstall;
    for ( const QString& module : QStringList( installedKernelPackages.keys() ).filter( QRegularExpression( "^linux[0-9][0-9]?([0-9])-" ) ) )
    {
        QString aux = QString( module ).remove( QRegularExpression( "^linux[0-9][0-9]?([0-9])-" ) );
        modulesToInstall.insert( aux );
    }

    beginResetModel();
    m_kernels.clear();
    for ( const QString& kernel : QStringList( allKernelPackages.keys() ).filter( QRegularExpression( "^linux[0-9][0-9]?([0-9])$" ) ) )
    {
        Kernel newKernel;

        newKernel.setPackage( kernel );
        newKernel.setAvailable( availableKernelPackages.contains( kernel ) );
        newKernel.setInstalled( installedKernelPackages.contains( kernel ) );
        newKernel.setVersion( allKernelPackages.value( kernel ) );
        newKernel.setAvailableModules( QStringList( availableKernelPackages.keys() )
                                       .filter( QRegularExpression( QString( "^%1-" ).arg( kernel ) ) ) );
        if ( newKernel.isInstalled() )
        {
            newKernel.setInstalledModules( QStringList( installedKernelPackages.keys() )
                                           .filter( QRegularExpression( QString( "^%1-" ).arg( kernel ) ) ) );
        }
        else
        {
            QStringList installableModules;
            for ( const QString& module : modulesToInstall )
            {
                QString modulePackage = QString( "%1-%2" ).arg( kernel ).arg( module );
                if ( availableKernelPackages.contains( modulePackage ) )
                    installableModules << modulePackage;
            }
            newKernel.setInstalledModules( installableModules );
        }
        newKernel.setLts( ltsKernels.contains( kernel ) );
        newKernel.setRecommended( recommendedKernels.contains( kernel ) );
        newKernel.setRunning( QString::compare( runningKernel, kernel ) == 0 );

        m_kernels.append( newKernel );
    }
    endResetModel();
}