From 3302fe319bf0ae3124417e922f53ea809aed7504 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Mar 2020 21:58:30 -0500 Subject: [PATCH 01/14] [netinstall] Fix typo's in README --- src/modules/netinstall/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/netinstall/README.md b/src/modules/netinstall/README.md index 855754822..8af7d3491 100644 --- a/src/modules/netinstall/README.md +++ b/src/modules/netinstall/README.md @@ -1,16 +1,16 @@ # Netinstall module The netinstall module allows distribution maintainers to ship minimal ISOs with -only a basic set of preinstall packages. At installation time, the user is +only a basic set of preinstalled packages. At installation time, the user is presented with the choice to install groups of packages from a predefined list. -Calamares will then invoke the correct backend to install the packages. +Calamares will then use the *packages* module to install the packages. ## Module Configuration The `netinstall.conf` file is self-describing, and at the very -lease should contain a *groupsUrl* key: +least should contain a *groupsUrl* key: ``` ---- @@ -18,13 +18,13 @@ lease should contain a *groupsUrl* key: ``` The URL must point to a YAML file, the *groups* file. See below for -the format of that groups file. The URL may be a local file. +the format of that groups file. The URL may be a local file (e.g. +scheme `file:///`) or a regular HTTP(s) URL. ## Groups Configuration - Here is a short example -of how the YAML file should look. +Here is a short example of how the YAML file should look. ``` - name: "Group name" @@ -45,7 +45,7 @@ More keys (per group) are supported: - *hidden*: if true, do not show the group on the page. Defaults to false. - *selected*: if true, display the group as selected. Defaults to false. - - critical*: if true, make the installation process fail if installing + - *critical*: if true, make the installation process fail if installing any of the packages in the group fails. Otherwise, just log a warning. Defaults to false. - *subgroups*: if present this follows the same structure as the top level From 4cf3ec8663a0bdba536028172890da6d631b6b8f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Mar 2020 22:01:39 -0500 Subject: [PATCH 02/14] [netinstall] Resolve TODO (changes translations) --- src/modules/netinstall/PackageModel.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index 0805a8135..f0bd3a962 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -21,9 +21,6 @@ #include "utils/Yaml.h" -// TODO: see headerData(), remove after 3.2.19 -#include - PackageModel::PackageModel( const YAML::Node& data, QObject* parent ) : QAbstractItemModel( parent ) { @@ -171,12 +168,7 @@ PackageModel::headerData( int section, Qt::Orientation orientation, int role ) c { if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) { - // Unusual translation call uses the existing translation from the NetInstallPage - // class (now removed). - // - // TODO: after 3.2.19, change this to just tr() and push TX - return ( section == 0 ) ? QCoreApplication::translate( "NetInstallPage", "Name" ) - : QCoreApplication::translate( "NetInstallPage", "Description" ); + return ( section == 0 ) ? tr( "Name" ) : tr( "Description" ); } return QVariant(); } From 201c5ddfe1598e3350864785d0f060dfb35ef474 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Mar 2020 22:44:16 -0500 Subject: [PATCH 03/14] [netinstall] Add some debug-logging - Also, prepare for a start-expanded setting --- src/modules/netinstall/NetInstallPage.cpp | 7 +++++++ src/modules/netinstall/PackageTreeItem.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index 735610c3d..86228558e 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -154,6 +154,13 @@ NetInstallPage::dataIsHere() ui->groupswidget->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents ); ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch ); + cDebug() << "Groups info rows=" << m_groups->rowCount(); + for ( int i = 0; i < m_groups->rowCount(); ++i ) + { + auto index = m_groups->index(i,0); + cDebug() << Logger::SubEntry << i << m_groups->data(index, Qt::DisplayRole); + } + emit checkReady( true ); } diff --git a/src/modules/netinstall/PackageTreeItem.h b/src/modules/netinstall/PackageTreeItem.h index 18a509861..cda1611b6 100644 --- a/src/modules/netinstall/PackageTreeItem.h +++ b/src/modules/netinstall/PackageTreeItem.h @@ -36,6 +36,7 @@ public: QString postScript; bool isCritical = false; bool isHidden = false; + bool startExpanded = false; // Only for groups Qt::CheckState selected = Qt::Unchecked; /** @brief Turns this item into a variant for PackageOperations use From 3d68c74a19a927ff665cfcf21a8f0ed048c07ed3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Mar 2020 22:46:59 -0500 Subject: [PATCH 04/14] [netinstall] Sanitize PackageTreeItem::data() - Use of != nullptr for QString just a bad idea - Massage code so structure for packages resembles that of groups --- src/modules/netinstall/PackageTreeItem.cpp | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/modules/netinstall/PackageTreeItem.cpp b/src/modules/netinstall/PackageTreeItem.cpp index 59e82a659..7a6a68f7b 100644 --- a/src/modules/netinstall/PackageTreeItem.cpp +++ b/src/modules/netinstall/PackageTreeItem.cpp @@ -108,22 +108,27 @@ PackageTreeItem::row() const QVariant PackageTreeItem::data( int column ) const { - if ( packageName() != nullptr ) // package + if ( !packageName().isEmpty() ) // packages have a packagename, groups don't { - if ( !column ) + switch ( column ) { + case 0: return QVariant( packageName() ); + default: + return QVariant(); } - return QVariant(); } - switch ( column ) // group + else { - case 0: - return QVariant( prettyName() ); - case 1: - return QVariant( description() ); - default: - return QVariant(); + switch ( column ) // group + { + case 0: + return QVariant( prettyName() ); + case 1: + return QVariant( description() ); + default: + return QVariant(); + } } } From df86972ea754ca8c63173588970785cef2122a5f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:22:56 -0500 Subject: [PATCH 05/14] [netinstall] Introduce constexpr names for columns and roles --- src/modules/netinstall/PackageModel.cpp | 6 +++--- src/modules/netinstall/PackageModel.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index f0bd3a962..f50273a7c 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -117,7 +117,7 @@ PackageModel::data( const QModelIndex& index, int role ) const } PackageTreeItem* item = static_cast< PackageTreeItem* >( index.internalPointer() ); - if ( index.column() == 0 && role == Qt::CheckStateRole ) + if ( index.column() == NameColumn && role == Qt::CheckStateRole ) { return item->isSelected(); } @@ -156,7 +156,7 @@ PackageModel::flags( const QModelIndex& index ) const { return Qt::ItemFlags(); } - if ( index.column() == 0 ) + if ( index.column() == NameColumn ) { return Qt::ItemIsUserCheckable | QAbstractItemModel::flags( index ); } @@ -168,7 +168,7 @@ PackageModel::headerData( int section, Qt::Orientation orientation, int role ) c { if ( orientation == Qt::Horizontal && role == Qt::DisplayRole ) { - return ( section == 0 ) ? tr( "Name" ) : tr( "Description" ); + return ( section == NameColumn ) ? tr( "Name" ) : tr( "Description" ); } return QVariant(); } diff --git a/src/modules/netinstall/PackageModel.h b/src/modules/netinstall/PackageModel.h index 25965cb7f..b76a58a42 100644 --- a/src/modules/netinstall/PackageModel.h +++ b/src/modules/netinstall/PackageModel.h @@ -39,6 +39,16 @@ class PackageModel : public QAbstractItemModel public: using PackageItemDataList = QList< PackageTreeItem::ItemData >; + // Names for columns (unused in the code) + static constexpr const int NameColumn = 0; + static constexpr const int DescriptionColumn = 1; + + /* The only interesting roles are DisplayRole (with text depending + * on the column, and MetaExpandRole which tells if an index + * should be initially expanded. + */ + static constexpr const int MetaExpandRole = Qt::UserRole + 1; + explicit PackageModel( const YAML::Node& data, QObject* parent = nullptr ); ~PackageModel() override; From 4f22a70b08b011b883ed5243aecd9a2370f5ab6c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:30:33 -0500 Subject: [PATCH 06/14] [netinstall] Restructure model-method data() --- src/modules/netinstall/PackageModel.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index f50273a7c..97c105ade 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -117,21 +117,15 @@ PackageModel::data( const QModelIndex& index, int role ) const } PackageTreeItem* item = static_cast< PackageTreeItem* >( index.internalPointer() ); - if ( index.column() == NameColumn && role == Qt::CheckStateRole ) + switch( role ) { - return item->isSelected(); + case Qt::CheckStateRole: + return index.column() == NameColumn ? item->isSelected() : QVariant(); + case Qt::DisplayRole: + return item->isHidden() ? QVariant() : item->data( index.column() ); + default: + return QVariant(); } - - if ( item->isHidden() && role == Qt::DisplayRole ) // Hidden group - { - return QVariant(); - } - - if ( role == Qt::DisplayRole ) - { - return item->data( index.column() ); - } - return QVariant(); } bool From 09006a936d7c0e59c9f2c86f263cd23864e5cad8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:37:57 -0500 Subject: [PATCH 07/14] [netinstall] Expand groups if requested --- src/modules/netinstall/NetInstallPage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index 86228558e..ac1ffc0b8 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -155,10 +155,14 @@ NetInstallPage::dataIsHere() ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch ); cDebug() << "Groups info rows=" << m_groups->rowCount(); - for ( int i = 0; i < m_groups->rowCount(); ++i ) + for ( int i = m_groups->rowCount() - 1; i >= 0; --i ) { auto index = m_groups->index(i,0); cDebug() << Logger::SubEntry << i << m_groups->data(index, Qt::DisplayRole); + if ( m_groups->data(index, PackageModel::MetaExpandRole).toBool() ) + { + ui->groupswidget->setExpanded(index, true); + } } emit checkReady( true ); From b074696ac1a51dbf237ab5994b94e90f32a209a6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:38:11 -0500 Subject: [PATCH 08/14] [netinstall] isCritical is const after construction --- src/modules/netinstall/PackageModel.cpp | 8 ++++---- src/modules/netinstall/PackageTreeItem.cpp | 6 ------ src/modules/netinstall/PackageTreeItem.h | 1 - 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index 97c105ade..f51203944 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -234,6 +234,10 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent ) { itemData.postScript = CalamaresUtils::yamlToVariant( itemDefinition[ "post-install" ] ).toString(); } + if ( itemDefinition[ "critical" ] ) + { + itemData.isCritical = CalamaresUtils::yamlToVariant( itemDefinition[ "critical" ] ).toBool(); + } PackageTreeItem* item = new PackageTreeItem( itemData, parent ); if ( itemDefinition[ "selected" ] ) @@ -249,10 +253,6 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent ) item->setHidden( CalamaresUtils::yamlToVariant( itemDefinition[ "hidden" ] ).toBool() ); } - if ( itemDefinition[ "critical" ] ) - { - item->setCritical( CalamaresUtils::yamlToVariant( itemDefinition[ "critical" ] ).toBool() ); - } if ( itemDefinition[ "packages" ] ) for ( YAML::const_iterator packageIt = itemDefinition[ "packages" ].begin(); diff --git a/src/modules/netinstall/PackageTreeItem.cpp b/src/modules/netinstall/PackageTreeItem.cpp index 7a6a68f7b..3a67a2682 100644 --- a/src/modules/netinstall/PackageTreeItem.cpp +++ b/src/modules/netinstall/PackageTreeItem.cpp @@ -217,12 +217,6 @@ PackageTreeItem::isCritical() const return m_data.isCritical; } -void -PackageTreeItem::setCritical( bool isCritical ) -{ - m_data.isCritical = isCritical; -} - Qt::CheckState PackageTreeItem::isSelected() const { diff --git a/src/modules/netinstall/PackageTreeItem.h b/src/modules/netinstall/PackageTreeItem.h index cda1611b6..cee89727d 100644 --- a/src/modules/netinstall/PackageTreeItem.h +++ b/src/modules/netinstall/PackageTreeItem.h @@ -79,7 +79,6 @@ public: bool hiddenSelected() const; bool isCritical() const; - void setCritical( bool isCritical ); Qt::CheckState isSelected() const; void setSelected( Qt::CheckState isSelected ); From 0f7f5216ee9e48039fcc713eccc33ef5284f29ec Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:39:35 -0500 Subject: [PATCH 09/14] [netinstall] isHidden is const after construction --- src/modules/netinstall/PackageModel.cpp | 9 +++++---- src/modules/netinstall/PackageTreeItem.cpp | 6 ------ src/modules/netinstall/PackageTreeItem.h | 1 - 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index f51203944..9b197b876 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -238,6 +238,11 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent ) { itemData.isCritical = CalamaresUtils::yamlToVariant( itemDefinition[ "critical" ] ).toBool(); } + if ( itemDefinition[ "hidden" ] ) + { + itemData.isHidden = CalamaresUtils::yamlToVariant( itemDefinition[ "hidden" ] ).toBool(); + } + PackageTreeItem* item = new PackageTreeItem( itemData, parent ); if ( itemDefinition[ "selected" ] ) @@ -248,10 +253,6 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent ) item->setSelected( parent->isSelected() ); // Inherit from it's parent } - if ( itemDefinition[ "hidden" ] ) - { - item->setHidden( CalamaresUtils::yamlToVariant( itemDefinition[ "hidden" ] ).toBool() ); - } if ( itemDefinition[ "packages" ] ) diff --git a/src/modules/netinstall/PackageTreeItem.cpp b/src/modules/netinstall/PackageTreeItem.cpp index 3a67a2682..7e20d63e1 100644 --- a/src/modules/netinstall/PackageTreeItem.cpp +++ b/src/modules/netinstall/PackageTreeItem.cpp @@ -181,12 +181,6 @@ PackageTreeItem::isHidden() const return m_data.isHidden; } -void -PackageTreeItem::setHidden( bool isHidden ) -{ - m_data.isHidden = isHidden; -} - bool PackageTreeItem::hiddenSelected() const { diff --git a/src/modules/netinstall/PackageTreeItem.h b/src/modules/netinstall/PackageTreeItem.h index cee89727d..5077694c9 100644 --- a/src/modules/netinstall/PackageTreeItem.h +++ b/src/modules/netinstall/PackageTreeItem.h @@ -68,7 +68,6 @@ public: QString postScript() const; bool isHidden() const; - void setHidden( bool isHidden ); /** * @brief Is this hidden item, considered "selected"? * From 4f216b0394dbc6341c9af15e6fe1acbf84cbeec4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:46:49 -0500 Subject: [PATCH 10/14] [netinstall] Refactor model-data setting - Introduce convenience methods getString(), getBool() to pick out an entry from item definitions in YAML format. - Apply coding style. - Pick up the "expanded" property as well. --- src/modules/netinstall/PackageModel.cpp | 49 ++++++++++++------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index 9b197b876..496934939 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -117,14 +117,14 @@ PackageModel::data( const QModelIndex& index, int role ) const } PackageTreeItem* item = static_cast< PackageTreeItem* >( index.internalPointer() ); - switch( role ) + switch ( role ) { - case Qt::CheckStateRole: - return index.column() == NameColumn ? item->isSelected() : QVariant(); - case Qt::DisplayRole: - return item->isHidden() ? QVariant() : item->data( index.column() ); - default: - return QVariant(); + case Qt::CheckStateRole: + return index.column() == NameColumn ? item->isSelected() : QVariant(); + case Qt::DisplayRole: + return item->isHidden() ? QVariant() : item->data( index.column() ); + default: + return QVariant(); } } @@ -212,6 +212,18 @@ PackageModel::getItemPackages( PackageTreeItem* item ) const return selectedPackages; } +static QString +getString( const YAML::Node& itemDefinition, const char* key ) +{ + return itemDefinition[ key ] ? CalamaresUtils::yamlToVariant( itemDefinition[ key ] ).toString() : QString(); +} + +static bool +getBool( const YAML::Node& itemDefinition, const char* key ) +{ + return itemDefinition[ key ] ? CalamaresUtils::yamlToVariant( itemDefinition[ key ] ).toBool() : false; +} + void PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent ) { @@ -226,22 +238,11 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent ) itemData.name = name; itemData.description = description; - if ( itemDefinition[ "pre-install" ] ) - { - itemData.preScript = CalamaresUtils::yamlToVariant( itemDefinition[ "pre-install" ] ).toString(); - } - if ( itemDefinition[ "post-install" ] ) - { - itemData.postScript = CalamaresUtils::yamlToVariant( itemDefinition[ "post-install" ] ).toString(); - } - if ( itemDefinition[ "critical" ] ) - { - itemData.isCritical = CalamaresUtils::yamlToVariant( itemDefinition[ "critical" ] ).toBool(); - } - if ( itemDefinition[ "hidden" ] ) - { - itemData.isHidden = CalamaresUtils::yamlToVariant( itemDefinition[ "hidden" ] ).toBool(); - } + itemData.preScript = getString( itemDefinition, "pre-install" ); + itemData.postScript = getString( itemDefinition, "post-install" ); + itemData.isCritical = getBool( itemDefinition, "critical" ); + itemData.isHidden = getBool( itemDefinition, "hidden" ); + itemData.startExpanded = getBool( itemDefinition, "expanded" ); PackageTreeItem* item = new PackageTreeItem( itemData, parent ); @@ -253,8 +254,6 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent ) item->setSelected( parent->isSelected() ); // Inherit from it's parent } - - if ( itemDefinition[ "packages" ] ) for ( YAML::const_iterator packageIt = itemDefinition[ "packages" ].begin(); packageIt != itemDefinition[ "packages" ].end(); From b9b48cfbb14ca9c1c8f3f15f21bac289e97fa993 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:49:12 -0500 Subject: [PATCH 11/14] [netinstall] Apply coding style - Some missing {} were not noticed by astyle --- src/modules/netinstall/PackageModel.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index 496934939..5308ed207 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -247,20 +247,24 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent ) PackageTreeItem* item = new PackageTreeItem( itemData, parent ); if ( itemDefinition[ "selected" ] ) - item->setSelected( CalamaresUtils::yamlToVariant( itemDefinition[ "selected" ] ).toBool() ? Qt::Checked - : Qt::Unchecked ); + { + item->setSelected( getBool( itemDefinition, "selected" ) ? Qt::Checked : Qt::Unchecked ); + } else { item->setSelected( parent->isSelected() ); // Inherit from it's parent } if ( itemDefinition[ "packages" ] ) + { for ( YAML::const_iterator packageIt = itemDefinition[ "packages" ].begin(); packageIt != itemDefinition[ "packages" ].end(); ++packageIt ) + { item->appendChild( new PackageTreeItem( CalamaresUtils::yamlToVariant( *packageIt ).toString(), item ) ); - + } + } if ( itemDefinition[ "subgroups" ] ) { setupModelData( itemDefinition[ "subgroups" ], item ); From e2d9ce737cd7df74e971e55962d31dab7be3973a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:59:41 -0500 Subject: [PATCH 12/14] [netinstall] Implement pre-expanded groups - Return relevant data - Document code - Add to README.md documentation about new key --- src/modules/netinstall/NetInstallPage.cpp | 3 +-- src/modules/netinstall/PackageModel.cpp | 2 ++ src/modules/netinstall/PackageTreeItem.h | 22 ++++++++++++++++++++-- src/modules/netinstall/README.md | 2 ++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index ac1ffc0b8..352eb9f3e 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -154,11 +154,10 @@ NetInstallPage::dataIsHere() ui->groupswidget->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents ); ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch ); - cDebug() << "Groups info rows=" << m_groups->rowCount(); + // Go backwards because expanding a group may cause rows to appear below it for ( int i = m_groups->rowCount() - 1; i >= 0; --i ) { auto index = m_groups->index(i,0); - cDebug() << Logger::SubEntry << i << m_groups->data(index, Qt::DisplayRole); if ( m_groups->data(index, PackageModel::MetaExpandRole).toBool() ) { ui->groupswidget->setExpanded(index, true); diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index 5308ed207..215ac2912 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -123,6 +123,8 @@ PackageModel::data( const QModelIndex& index, int role ) const return index.column() == NameColumn ? item->isSelected() : QVariant(); case Qt::DisplayRole: return item->isHidden() ? QVariant() : item->data( index.column() ); + case MetaExpandRole: + return item->isHidden() ? false : item->expandOnStart(); default: return QVariant(); } diff --git a/src/modules/netinstall/PackageTreeItem.h b/src/modules/netinstall/PackageTreeItem.h index 5077694c9..d9c1f9ec2 100644 --- a/src/modules/netinstall/PackageTreeItem.h +++ b/src/modules/netinstall/PackageTreeItem.h @@ -67,9 +67,14 @@ public: QString packageName() const; QString postScript() const; + /** @brief Is this item hidden? + * + * Hidden items (generally only groups) are maintained separately, + * not shown to the user, but do enter into the package-installation process. + */ bool isHidden() const; - /** - * @brief Is this hidden item, considered "selected"? + + /** @brief Is this hidden item, considered "selected"? * * This asserts when called on a non-hidden item. * A hidden item has its own selected state, but really @@ -77,8 +82,21 @@ public: */ bool hiddenSelected() const; + /** @brief Is this group critical? + * + * A critical group must be successfully installed, for the Calamares + * installation to continue. + */ bool isCritical() const; + /** @brief Is this group expanded on start? + * + * This does not affect installation, only the UI. A group + * that expands on start is shown expanded (not collapsed) + * in the treeview when the page is loaded. + */ + bool expandOnStart() const { return m_data.startExpanded; } + Qt::CheckState isSelected() const; void setSelected( Qt::CheckState isSelected ); void setChildrenSelected( Qt::CheckState isSelected ); diff --git a/src/modules/netinstall/README.md b/src/modules/netinstall/README.md index 8af7d3491..a8803edd5 100644 --- a/src/modules/netinstall/README.md +++ b/src/modules/netinstall/README.md @@ -48,6 +48,8 @@ More keys (per group) are supported: - *critical*: if true, make the installation process fail if installing any of the packages in the group fails. Otherwise, just log a warning. Defaults to false. + - *expanded*: if true, the group is shown in an expanded form (that is, + not-collapsed) in the treeview on start. - *subgroups*: if present this follows the same structure as the top level of the YAML file, allowing there to be sub-groups of packages to an arbitary depth From 257f718ab660390560c6b748939d7fa06c711022 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 13:14:53 -0500 Subject: [PATCH 13/14] Changes: document netinstall improvement --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index ad1aa55e8..e219bf3d3 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,9 @@ This release contains contributions from (alphabetically by first name): ## Modules ## - *packages* now reports more details in the installation progress-bar. + - *netinstall* module supports and `expanded` key, which will pre-expand + a group (as if the user had pressed the arrow-button in the tree-view). + This only affects the UI. # 3.2.20 (2020-02-27) # From 7ec6dff3528cdc20b1f25f5e81dc7344169474c7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 13:21:15 -0500 Subject: [PATCH 14/14] [calamares] Apply coding style to progresstree --- src/calamares/progresstree/ViewStepItem.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calamares/progresstree/ViewStepItem.cpp b/src/calamares/progresstree/ViewStepItem.cpp index 885b81dfc..bbb2846ce 100644 --- a/src/calamares/progresstree/ViewStepItem.cpp +++ b/src/calamares/progresstree/ViewStepItem.cpp @@ -65,9 +65,9 @@ ViewStepItem::data( int role ) const toolTip.append( "
Type:\tViewStep" ); toolTip.append( QString( "
Pretty:\t%1" ).arg( m_step->prettyName() ) ); toolTip.append( QString( "
Status:\t%1" ).arg( m_step->prettyStatus() ) ); - toolTip.append( - QString( "
Source:\t%1" ) - .arg( m_step->moduleInstanceKey().isValid() ? m_step->moduleInstanceKey().toString() : QStringLiteral("built-in") ) ); + toolTip.append( QString( "
Source:\t%1" ) + .arg( m_step->moduleInstanceKey().isValid() ? m_step->moduleInstanceKey().toString() + : QStringLiteral( "built-in" ) ) ); } else { @@ -77,7 +77,9 @@ ViewStepItem::data( int role ) const return toolTip; } if ( role == ProgressTreeModel::ProgressTreeItemCurrentRole ) + { return m_step ? ( Calamares::ViewManager::instance()->currentStep() == m_step ) : ( Calamares::ViewManager::instance()->currentStep() == m_accessor() ); + } return QVariant(); }