Commit d38ffa81 authored by Lisa's avatar Lisa
Browse files

Style fixes: copyright statements (with me included), comments, astyle fixes.

parent 1bd9d22c
......@@ -35,35 +35,34 @@ NetInstallPage::isReady()
return true;
}
void NetInstallPage::ReadGroups(const QByteArray& yamlData) {
void NetInstallPage::ReadGroups( const QByteArray& yamlData )
{
YAML::Node groups = YAML::Load( yamlData.constData() );
Q_ASSERT( groups.IsSequence() );
for ( YAML::const_iterator it = groups.begin(); it != groups.end(); ++it) {
for ( YAML::const_iterator it = groups.begin(); it != groups.end(); ++it )
{
YAML::Node groupDefinition = it->as<YAML::Node>();
QString name( tr(groupDefinition["name"].as<std::string>().c_str()) );
QString description( tr(groupDefinition["description"].as<std::string>().c_str()) );
QString name( tr( groupDefinition["name"].as<std::string>().c_str() ) );
QString description( tr( groupDefinition["description"].as<std::string>().c_str() ) );
QStringList packages;
for ( YAML::const_iterator it = groupDefinition["packages"].begin();
it != groupDefinition["packages"].end(); ++it) {
packages.append((*it).as<std::string>().c_str());
}
it != groupDefinition["packages"].end(); ++it )
packages.append( ( *it ).as<std::string>().c_str() );
m_groups[name].name = name;
m_groups[name].description = description;
m_groups[name].packages = packages;
if (groupDefinition["selected"]) {
if ( groupDefinition["selected"] )
m_groups[name].selected = groupDefinition["selected"].as<bool>();
}
if (groupDefinition["hidden"]) {
if ( groupDefinition["hidden"] )
m_groups[name].hidden = groupDefinition["hidden"].as<bool>();
}
m_groupOrder.append(name);
m_groupOrder.append( name );
}
}
......@@ -79,13 +78,14 @@ NetInstallPage::dataIsHere( KJob* job )
auto transferJob = dynamic_cast<KIO::StoredTransferJob*>( job );
Q_ASSERT( transferJob != nullptr );
ReadGroups(transferJob->data());
ReadGroups( transferJob->data() );
QSignalMapper* mapper = new QSignalMapper( this );
foreach ( const QString& groupKey, m_groupOrder )
{
{
Group group = m_groups[groupKey];
if (group.hidden) {
if ( group.hidden )
{
// Do not present on view.
continue;
}
......@@ -116,9 +116,8 @@ QStringList NetInstallPage::selectedPackages() const
// Add all the packages for groups that are hidden but selected.
for ( const Group& group : m_groups.values() )
{
if (group.hidden && group.selected) {
if ( group.hidden && group.selected )
selectedPackages += group.packages;
}
}
return selectedPackages;
......
/*
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
* Lisa Vitolo <shainer@chakraos.org>
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NETINSTALLPAGE_H
#define NETINSTALLPAGE_H
......@@ -10,7 +27,8 @@ class KJob;
class QByteArray;
class GroupSelectionWidget;
namespace Ui {
namespace Ui
{
class Page_NetInst;
}
......@@ -18,25 +36,29 @@ class NetInstallPage : public QWidget
{
Q_OBJECT
struct Group {
// Internal representation of a package group.
struct Group
{
Group()
: Group("","",false, false) { }
Group(QString name, QString description, bool selected, bool hidden)
: name(name), description(description), selected(selected), hidden(hidden) { }
Group(QString name, QString description)
: Group(name, description, false, false) { }
: Group( "","",false, false ) { }
Group( QString name, QString description, bool selected, bool hidden )
: name( name ), description( description ), selected( selected ), hidden( hidden ) { }
Group( QString name, QString description )
: Group( name, description, false, false ) { }
QString name;
QString description;
QStringList packages;
// See README.md for a description of these two fields.
bool selected = false;
bool hidden = false;
};
public:
NetInstallPage(QWidget *parent = 0);
NetInstallPage( QWidget* parent = 0 );
void onActivate();
bool isReady();
// Retrieves the groups, with name, description and packages, from
......@@ -45,11 +67,12 @@ public:
void loadGroupList();
// Returns the list of packages belonging to groups that are
// selected in the view in this given moment. No data is cached here.
// selected in the view in this given moment. No data is cached here, so
// this function does not have constant time.
QStringList selectedPackages() const;
public slots:
void dataIsHere(KJob *);
void dataIsHere( KJob* );
signals:
void checkReady( bool );
......@@ -58,14 +81,14 @@ private:
// Takes the YAML data representing the groups and reads them into the
// m_groups and m_groupOrder internal structures. See the README.md
// of this module to know the format expected of the YAML files.
void ReadGroups(const QByteArray& yamlData);
void ReadGroups( const QByteArray& yamlData );
Ui::Page_NetInst* ui;
QHash<QString, Group> m_groups;
// For each group name, store the selection widget to retrieve UI
// properties.
QHash<QString, GroupSelectionWidget *> m_groupWidgets;
QHash<QString, GroupSelectionWidget*> m_groupWidgets;
QList<QString> m_groupOrder;
};
......
......@@ -125,8 +125,11 @@ NetInstallViewStep::onLeave()
cDebug() << "Leaving netinstall, adding packages to be installed"
<< "to global storage";
if (!m_widget->selectedPackages().empty()) {
if ( !m_widget->selectedPackages().empty() )
{
QHash<QString, QVariant> packagesWithOperation;
// Gets all packages selected in the page; includes groups that are
// selected by default but not displayed.
packagesWithOperation.insert( "install", m_widget->selectedPackages() );
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
......
/*
/*
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
*
* Lisa Vitolo <shainer@chakraos.org>
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
......@@ -54,6 +54,8 @@ public:
QList< Calamares::job_ptr > jobs() const override;
void onActivate() override;
// Leaving the page; store all selected packages for later installation.
void onLeave() override;
void setConfigurationMap( const QVariantMap& configurationMap ) override;
......@@ -63,9 +65,6 @@ private:
bool m_nextEnabled;
QString m_prettyStatus;
//QString m_xOrgConfFileName;
//QString m_convertedKeymapPath;
QList< Calamares::job_ptr > m_jobs;
};
......
......@@ -2,27 +2,29 @@
#include <QtDebug>
GroupSelectionWidget::GroupSelectionWidget(QString name, QString description, QStringList packages, QWidget *parent) :
QWidget(parent),
m_isToggled(false)
GroupSelectionWidget::GroupSelectionWidget( QString name, QString description, QStringList packages, QWidget* parent ) :
QWidget( parent ),
m_isToggled( false )
{
ui.setupUi(this);
ui.setupUi( this );
connect(ui.group, SIGNAL(toggled(bool)), this, SLOT(toggleGroup(bool)));
connect( ui.group, SIGNAL( toggled( bool ) ), this, SLOT( toggleGroup( bool ) ) );
ui.group->setText(name);
ui.description->setText(description);
ui.group->setText( name );
ui.description->setText( description );
const int columns = 4;
const int rows = (packages.size() - 1) / columns + 1;
ui.packageview->setRowCount(rows);
ui.packageview->setColumnCount(columns);
const int rows = ( packages.size() - 1 ) / columns + 1;
ui.packageview->setRowCount( rows );
ui.packageview->setColumnCount( columns );
ui.packageview->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui.packageview->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch );
int r = 0, c = 0;
for (int i = 0; i < packages.size(); ++i) {
ui.packageview->setItem(r++,c, new QTableWidgetItem(packages.at(i)));
if (r == ui.packageview->rowCount()) {
for ( int i = 0; i < packages.size(); ++i )
{
ui.packageview->setItem( r++,c, new QTableWidgetItem( packages.at( i ) ) );
if ( r == ui.packageview->rowCount() )
{
++c;
r = 0;
}
......@@ -30,15 +32,17 @@ GroupSelectionWidget::GroupSelectionWidget(QString name, QString description, QS
int rowsShown = 6;
rowsShown = rows < rowsShown ? rows : 6;
ui.packageview->setFixedHeight(rowsShown * ui.packageview->rowHeight(0));
ui.packageview->setFixedHeight( rowsShown * ui.packageview->rowHeight( 0 ) );
ui.packageview->hide();
}
void GroupSelectionWidget::toggleGroup(bool isToggled) {
void GroupSelectionWidget::toggleGroup( bool isToggled )
{
m_isToggled = isToggled;
emit toggled(isToggled);
emit toggled( isToggled );
}
bool GroupSelectionWidget::isToggled() const {
bool GroupSelectionWidget::isToggled() const
{
return m_isToggled;
}
/*
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
* Lisa Vitolo <shainer@chakraos.org>
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GROUPSELECTIONWIDGET_H
#define GROUPSELECTIONWIDGET_H
......@@ -6,24 +23,25 @@
#include <QSignalMapper>
#include <QWidget>
// Represents a widget to display and select a group.
class GroupSelectionWidget : public QWidget
{
Q_OBJECT
public:
explicit GroupSelectionWidget(QString name, QString description, QStringList packages, QWidget *parent = 0);
explicit GroupSelectionWidget( QString name, QString description, QStringList packages, QWidget* parent = 0 );
// Current status of the group: is it selected in the view?
bool isToggled() const;
signals:
void toggled(bool);
void toggled( bool );
public slots:
void toggleGroup(bool isToggled);
void toggleGroup( bool isToggled );
private:
Ui::GroupSelectionWidget ui;
static QSignalMapper *m_mapper;
static QSignalMapper* m_mapper;
bool m_isToggled;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment