[license] Move logic to LicenseEntry class
This commit is contained in:
parent
81016667ae
commit
614bd3c6de
@ -25,6 +25,7 @@
|
|||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/CalamaresUtils.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
#include "ViewManager.h"
|
#include "ViewManager.h"
|
||||||
@ -37,6 +38,33 @@
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
LicenseEntry::LicenseEntry(const QVariantMap& conf)
|
||||||
|
{
|
||||||
|
if ( !conf.contains( "id" ) || !conf.contains( "name" ) || !conf.contains( "url" ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
id = conf[ "id" ].toString();
|
||||||
|
prettyName = conf[ "name" ].toString();
|
||||||
|
prettyVendor = conf.value( "vendor" ).toString();
|
||||||
|
url = QUrl( conf[ "url" ].toString() );
|
||||||
|
|
||||||
|
required = CalamaresUtils::getBool( conf, "required", false );
|
||||||
|
|
||||||
|
QString entryType = conf.value( "type", "software" ).toString();
|
||||||
|
if ( entryType == "driver" )
|
||||||
|
type = LicenseEntry::Type::Driver;
|
||||||
|
else if ( entryType == "gpudriver" )
|
||||||
|
type = LicenseEntry::Type::GpuDriver;
|
||||||
|
else if ( entryType == "browserplugin" )
|
||||||
|
type = LicenseEntry::Type::BrowserPlugin;
|
||||||
|
else if ( entryType == "codec" )
|
||||||
|
type = LicenseEntry::Type::Codec;
|
||||||
|
else if ( entryType == "package" )
|
||||||
|
type = LicenseEntry::Type::Package;
|
||||||
|
else
|
||||||
|
type = LicenseEntry::Type::Software;
|
||||||
|
}
|
||||||
|
|
||||||
LicensePage::LicensePage(QWidget *parent)
|
LicensePage::LicensePage(QWidget *parent)
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, ui( new Ui::LicensePage )
|
, ui( new Ui::LicensePage )
|
||||||
|
@ -43,6 +43,11 @@ public:
|
|||||||
Package
|
Package
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LicenseEntry( const QVariantMap& conf );
|
||||||
|
LicenseEntry( const LicenseEntry& ) = default;
|
||||||
|
|
||||||
|
bool isValid() const { return !id.isEmpty(); }
|
||||||
|
|
||||||
QString id;
|
QString id;
|
||||||
QString prettyName;
|
QString prettyName;
|
||||||
QString prettyVendor;
|
QString prettyVendor;
|
||||||
|
@ -106,34 +106,9 @@ LicenseViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
if ( entryV.type() != QVariant::Map )
|
if ( entryV.type() != QVariant::Map )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QVariantMap entryMap = entryV.toMap();
|
LicenseEntry entry( entryV.toMap() );
|
||||||
if ( !entryMap.contains( "id" ) ||
|
if ( entry.isValid() )
|
||||||
!entryMap.contains( "name" ) ||
|
entriesList.append( entry );
|
||||||
!entryMap.contains( "url" ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
LicenseEntry entry;
|
|
||||||
entry.id = entryMap[ "id" ].toString();
|
|
||||||
entry.prettyName = entryMap[ "name" ].toString();
|
|
||||||
entry.prettyVendor =entryMap.value( "vendor" ).toString();
|
|
||||||
entry.url = QUrl( entryMap[ "url" ].toString() );
|
|
||||||
entry.required = entryMap.value( "required", QVariant( false ) ).toBool();
|
|
||||||
|
|
||||||
QString entryType = entryMap.value( "type", "software" ).toString();
|
|
||||||
if ( entryType == "driver" )
|
|
||||||
entry.type = LicenseEntry::Type::Driver;
|
|
||||||
else if ( entryType == "gpudriver" )
|
|
||||||
entry.type = LicenseEntry::Type::GpuDriver;
|
|
||||||
else if ( entryType == "browserplugin" )
|
|
||||||
entry.type = LicenseEntry::Type::BrowserPlugin;
|
|
||||||
else if ( entryType == "codec" )
|
|
||||||
entry.type = LicenseEntry::Type::Codec;
|
|
||||||
else if ( entryType == "package" )
|
|
||||||
entry.type = LicenseEntry::Type::Package;
|
|
||||||
else
|
|
||||||
entry.type = LicenseEntry::Type::Software;
|
|
||||||
|
|
||||||
entriesList.append( entry );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user