[packagechooser] Refactor fromApp*()

- These don't have to be static methods of PackageItem, a free
   function is more convenient.
 - Since it's not API of PackageItem anymore, need to
   - update tests not to use API
   - do API-not-available warnings in consumers
This commit is contained in:
Adriaan de Groot 2019-08-20 04:15:35 -04:00
parent 17abbeda96
commit 0a92ef7655
8 changed files with 102 additions and 56 deletions

View file

@ -18,6 +18,12 @@
#include "PackageChooserViewStep.h"
#ifdef HAVE_XML
#include "ItemAppData.h"
#endif
#ifdef HAVE_APPSTREAM
#include "ItemAppStream.h"
#endif
#include "PackageChooserPage.h"
#include "PackageModel.h"
@ -217,11 +223,19 @@ PackageChooserViewStep::fillModel( const QVariantList& items )
if ( item_map.contains( "appdata" ) )
{
m_model->addPackage( PackageItem::fromAppData( item_map ) );
#ifdef HAVE_XML
m_model->addPackage( fromAppData( item_map ) );
#else
cWarning() << "Loading AppData XML is not supported.";
#endif
}
else if ( item_map.contains( "appstream" ) )
{
m_model->addPackage( PackageItem::fromAppStream( item_map ) );
#ifdef HAVE_APPSTREAM
m_model->addPackage( fromAppStream( item_map ) );
#else
cWarning() << "Loading AppStream data is not supported.";
#endif
}
else
{