From 704e2506649dc1359a1ae9a07877dc4ed9c81ca9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 27 Apr 2022 14:37:24 +0200 Subject: [PATCH] [libcalamaresui] Remove under-used function - there was one consumer of this function, and it was over-engineered for what was needed (removing a list of widgets). Just drop it. --- .../utils/CalamaresUtilsGui.cpp | 20 ------------------- src/libcalamaresui/utils/CalamaresUtilsGui.h | 8 -------- src/modules/license/LicensePage.cpp | 7 +++++-- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp index e21c532ac..2a8b380c5 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.cpp +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.cpp @@ -256,24 +256,4 @@ defaultIconSize() return QSize( w, w ); } - -void -clearLayout( QLayout* layout ) -{ - while ( QLayoutItem* item = layout->takeAt( 0 ) ) - { - if ( QWidget* widget = item->widget() ) - { - widget->deleteLater(); - } - - if ( QLayout* childLayout = item->layout() ) - { - clearLayout( childLayout ); - } - - delete item; - } -} - } // namespace CalamaresUtils diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.h b/src/libcalamaresui/utils/CalamaresUtilsGui.h index aa7aff79b..6f98db501 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.h +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.h @@ -95,14 +95,6 @@ UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size */ UIDLLEXPORT void unmarginLayout( QLayout* layout ); -// TODO:3.3:This has only one consumer, move to LicensePage, make static -/** - * @brief clearLayout recursively walks the QLayout tree and deletes all the child - * widgets and layouts. - * @param layout the layout to clear. - */ -UIDLLEXPORT void clearLayout( QLayout* layout ); - UIDLLEXPORT void setDefaultFontSize( int points ); UIDLLEXPORT int defaultFontSize(); // in points UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp index bafc9f463..eb609b2da 100644 --- a/src/modules/license/LicensePage.cpp +++ b/src/modules/license/LicensePage.cpp @@ -115,7 +115,11 @@ LicensePage::LicensePage( QWidget* parent ) void LicensePage::setEntries( const QList< LicenseEntry >& entriesList ) { - CalamaresUtils::clearLayout( ui->licenseEntriesLayout ); + for ( QWidget* w : m_entries ) + { + ui->licenseEntriesLayout->removeWidget( w ); + w->deleteLater(); + } m_allLicensesOptional = true; @@ -128,7 +132,6 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList ) m_entries.append( w ); m_allLicensesOptional &= !entry.isRequired(); } - ui->licenseEntriesLayout->addSpacerItem( new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); ui->acceptCheckBox->setChecked( false ); checkAcceptance( false );