[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
|
PackageItem
|
||||||
fromAppStream( const QVariantMap& item_map )
|
fromAppStream( AppStream::Pool& pool, const QVariantMap& item_map )
|
||||||
{
|
{
|
||||||
QString appstreamId = CalamaresUtils::getString( item_map, "appstream" );
|
QString appstreamId = CalamaresUtils::getString( item_map, "appstream" );
|
||||||
if ( appstreamId.isEmpty() )
|
if ( appstreamId.isEmpty() )
|
||||||
@ -106,13 +106,6 @@ fromAppStream( const QVariantMap& item_map )
|
|||||||
}
|
}
|
||||||
cDebug() << "Loading AppStream data for" << appstreamId;
|
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 );
|
auto itemList = pool.componentsById( appstreamId );
|
||||||
if ( itemList.count() < 1 )
|
if ( itemList.count() < 1 )
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
|
|
||||||
#include "PackageModel.h"
|
#include "PackageModel.h"
|
||||||
|
|
||||||
|
namespace AppStream
|
||||||
|
{
|
||||||
|
class Pool;
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Loads an item from AppStream data.
|
/** @brief Loads an item from AppStream data.
|
||||||
*
|
*
|
||||||
* The @p map must have a key *appstream*. That is used as the
|
* 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
|
* Requires AppStreamQt, if not present will return invalid
|
||||||
* PackageItems.
|
* PackageItems.
|
||||||
*/
|
*/
|
||||||
PackageItem fromAppStream( const QVariantMap& map );
|
PackageItem fromAppStream( AppStream::Pool& pool, const QVariantMap& map );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_APPSTREAM
|
#ifdef HAVE_APPSTREAM
|
||||||
#include "ItemAppStream.h"
|
#include "ItemAppStream.h"
|
||||||
|
#include <AppStreamQt/pool.h>
|
||||||
|
#include <memory>
|
||||||
#endif
|
#endif
|
||||||
#include "PackageChooserPage.h"
|
#include "PackageChooserPage.h"
|
||||||
#include "PackageModel.h"
|
#include "PackageModel.h"
|
||||||
@ -209,6 +211,11 @@ PackageChooserViewStep::fillModel( const QVariantList& items )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_APPSTREAM
|
||||||
|
std::unique_ptr< AppStream::Pool > pool;
|
||||||
|
bool poolOk = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
cDebug() << "Loading PackageChooser model items from config";
|
cDebug() << "Loading PackageChooser model items from config";
|
||||||
int item_index = 0;
|
int item_index = 0;
|
||||||
for ( const auto& item_it : items )
|
for ( const auto& item_it : items )
|
||||||
@ -232,7 +239,16 @@ PackageChooserViewStep::fillModel( const QVariantList& items )
|
|||||||
else if ( item_map.contains( "appstream" ) )
|
else if ( item_map.contains( "appstream" ) )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_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
|
#else
|
||||||
cWarning() << "Loading AppStream data is not supported.";
|
cWarning() << "Loading AppStream data is not supported.";
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user