[packagechooser] Build AppStream Pool first
- Don't build a Pool for each PackageItem loaded - Do make it load all languages instead of only the current one
This commit is contained in:
parent
0a92ef7655
commit
d8af11adee
@ -96,7 +96,7 @@ fromComponent( AppStream::Component& component )
|
||||
}
|
||||
|
||||
PackageItem
|
||||
fromAppStream( const QVariantMap& item_map )
|
||||
fromAppStream( AppStream::Pool& pool, const QVariantMap& item_map )
|
||||
{
|
||||
QString appstreamId = CalamaresUtils::getString( item_map, "appstream" );
|
||||
if ( appstreamId.isEmpty() )
|
||||
@ -106,13 +106,6 @@ fromAppStream( const QVariantMap& item_map )
|
||||
}
|
||||
cDebug() << "Loading AppStream data for" << appstreamId;
|
||||
|
||||
AppStream::Pool pool;
|
||||
if ( !pool.load() )
|
||||
{
|
||||
cWarning() << "AppStream load failed" << pool.lastError();
|
||||
return PackageItem();
|
||||
}
|
||||
|
||||
auto itemList = pool.componentsById( appstreamId );
|
||||
if ( itemList.count() < 1 )
|
||||
{
|
||||
|
@ -21,6 +21,11 @@
|
||||
|
||||
#include "PackageModel.h"
|
||||
|
||||
namespace AppStream
|
||||
{
|
||||
class Pool;
|
||||
}
|
||||
|
||||
/** @brief Loads an item from AppStream data.
|
||||
*
|
||||
* The @p map must have a key *appstream*. That is used as the
|
||||
@ -33,6 +38,6 @@
|
||||
* Requires AppStreamQt, if not present will return invalid
|
||||
* PackageItems.
|
||||
*/
|
||||
PackageItem fromAppStream( const QVariantMap& map );
|
||||
PackageItem fromAppStream( AppStream::Pool& pool, const QVariantMap& map );
|
||||
|
||||
#endif
|
||||
|
@ -23,6 +23,8 @@
|
||||
#endif
|
||||
#ifdef HAVE_APPSTREAM
|
||||
#include "ItemAppStream.h"
|
||||
#include <AppStreamQt/pool.h>
|
||||
#include <memory>
|
||||
#endif
|
||||
#include "PackageChooserPage.h"
|
||||
#include "PackageModel.h"
|
||||
@ -209,6 +211,11 @@ PackageChooserViewStep::fillModel( const QVariantList& items )
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_APPSTREAM
|
||||
std::unique_ptr< AppStream::Pool > pool;
|
||||
bool poolOk = false;
|
||||
#endif
|
||||
|
||||
cDebug() << "Loading PackageChooser model items from config";
|
||||
int item_index = 0;
|
||||
for ( const auto& item_it : items )
|
||||
@ -232,7 +239,16 @@ PackageChooserViewStep::fillModel( const QVariantList& items )
|
||||
else if ( item_map.contains( "appstream" ) )
|
||||
{
|
||||
#ifdef HAVE_APPSTREAM
|
||||
m_model->addPackage( fromAppStream( item_map ) );
|
||||
if ( !pool )
|
||||
{
|
||||
pool = std::make_unique< AppStream::Pool >();
|
||||
pool->setLocale( QStringLiteral( "ALL" ) );
|
||||
poolOk = pool->load();
|
||||
}
|
||||
if ( pool && poolOk )
|
||||
{
|
||||
m_model->addPackage( fromAppStream( *pool, item_map ) );
|
||||
}
|
||||
#else
|
||||
cWarning() << "Loading AppStream data is not supported.";
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user