From e2d9ce737cd7df74e971e55962d31dab7be3973a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Mar 2020 12:59:41 -0500 Subject: [PATCH] [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