[netinstall] Refactor variant-from-ItemData
This commit is contained in:
parent
d5675508fa
commit
056b0d7548
@ -111,7 +111,6 @@ NetInstallViewStep::onActivate()
|
||||
m_widget->onActivate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetInstallViewStep::onLeave()
|
||||
{
|
||||
@ -131,26 +130,15 @@ NetInstallViewStep::onLeave()
|
||||
QVariantList installPackages;
|
||||
QVariantList tryInstallPackages;
|
||||
|
||||
for ( auto package : packages )
|
||||
for ( const auto& package : packages )
|
||||
{
|
||||
QVariant details( package.packageName );
|
||||
// If it's a package with a pre- or post-script, replace
|
||||
// with the more complicated datastructure.
|
||||
if ( !package.preScript.isEmpty() || !package.postScript.isEmpty() )
|
||||
{
|
||||
QMap< QString, QVariant > sdetails;
|
||||
sdetails.insert( "pre-script", package.preScript );
|
||||
sdetails.insert( "package", package.packageName );
|
||||
sdetails.insert( "post-script", package.postScript );
|
||||
details = sdetails;
|
||||
}
|
||||
if ( package.isCritical )
|
||||
{
|
||||
installPackages.append( details );
|
||||
installPackages.append( package.toOperation() );
|
||||
}
|
||||
else
|
||||
{
|
||||
tryInstallPackages.append( details );
|
||||
tryInstallPackages.append( package.toOperation() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,25 @@
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
QVariant
|
||||
PackageTreeItem::ItemData::toOperation() const
|
||||
{
|
||||
// If it's a package with a pre- or post-script, replace
|
||||
// with the more complicated datastructure.
|
||||
if ( !preScript.isEmpty() || !postScript.isEmpty() )
|
||||
{
|
||||
QMap< QString, QVariant > sdetails;
|
||||
sdetails.insert( "pre-script", preScript );
|
||||
sdetails.insert( "package", packageName );
|
||||
sdetails.insert( "post-script", postScript );
|
||||
return sdetails;
|
||||
}
|
||||
else
|
||||
{
|
||||
return packageName;
|
||||
}
|
||||
}
|
||||
|
||||
PackageTreeItem::PackageTreeItem( const ItemData& data, PackageTreeItem* parent )
|
||||
: m_parentItem( parent )
|
||||
, m_data( data )
|
||||
|
@ -37,6 +37,13 @@ public:
|
||||
bool isCritical = false;
|
||||
bool isHidden = false;
|
||||
Qt::CheckState selected = Qt::Unchecked;
|
||||
|
||||
/** @brief Turns this item into a variant for PackageOperations use
|
||||
*
|
||||
* For "plain" items, this is just the package name; items with
|
||||
* scripts return a map. See the package module for how it's interpreted.
|
||||
*/
|
||||
QVariant toOperation() const;
|
||||
};
|
||||
explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = nullptr );
|
||||
explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = nullptr );
|
||||
|
Loading…
Reference in New Issue
Block a user