mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-25 16:38:21 -04:00
fixed style issues
This commit is contained in:
parent
a4aef3bce5
commit
f5fe887a79
6 changed files with 102 additions and 107 deletions
|
@ -103,14 +103,14 @@ void NetInstallPage::loadGroupList()
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl( QUrl( confUrl ) );
|
request.setUrl( QUrl( confUrl ) );
|
||||||
// Follows all redirects except unsafe ones (https to http).
|
// Follows all redirects except unsafe ones (https to http).
|
||||||
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
request.setAttribute( QNetworkRequest::FollowRedirectsAttribute, true );
|
||||||
// Not everybody likes the default User Agent used by this class (looking at you,
|
// Not everybody likes the default User Agent used by this class (looking at you,
|
||||||
// sourceforge.net), so let's set a more descriptive one.
|
// sourceforge.net), so let's set a more descriptive one.
|
||||||
request.setRawHeader( "User-Agent", "Mozilla/5.0 (compatible; Calamares)" );
|
request.setRawHeader( "User-Agent", "Mozilla/5.0 (compatible; Calamares)" );
|
||||||
|
|
||||||
connect(&m_networkManager, &QNetworkAccessManager::finished,
|
connect( &m_networkManager, &QNetworkAccessManager::finished,
|
||||||
this, &NetInstallPage::dataIsHere);
|
this, &NetInstallPage::dataIsHere );
|
||||||
m_networkManager.get(request);
|
m_networkManager.get( request );
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetInstallPage::onActivate()
|
void NetInstallPage::onActivate()
|
||||||
|
|
|
@ -126,8 +126,8 @@ NetInstallViewStep::onLeave()
|
||||||
<< "to global storage";
|
<< "to global storage";
|
||||||
|
|
||||||
QMap<QString, QVariant> packagesWithOperation;
|
QMap<QString, QVariant> packagesWithOperation;
|
||||||
QList<QVariant> installPackages = m_widget->selectedPackages(true);
|
QList<QVariant> installPackages = m_widget->selectedPackages( true );
|
||||||
QList<QVariant> tryInstallPackages = m_widget->selectedPackages(false);
|
QList<QVariant> tryInstallPackages = m_widget->selectedPackages( false );
|
||||||
|
|
||||||
if ( !installPackages.empty() )
|
if ( !installPackages.empty() )
|
||||||
packagesWithOperation.insert( "install", installPackages );
|
packagesWithOperation.insert( "install", installPackages );
|
||||||
|
|
|
@ -41,7 +41,7 @@ PackageModel::~PackageModel()
|
||||||
QModelIndex
|
QModelIndex
|
||||||
PackageModel::index( int row, int column, const QModelIndex& parent ) const
|
PackageModel::index( int row, int column, const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
if ( !hasIndex(row, column, parent ) )
|
if ( !hasIndex( row, column, parent ) )
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
PackageTreeItem* parentItem;
|
PackageTreeItem* parentItem;
|
||||||
|
@ -99,14 +99,10 @@ QVariant
|
||||||
PackageModel::data( const QModelIndex& index, int role ) const
|
PackageModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
{
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
|
||||||
PackageTreeItem* item = static_cast<PackageTreeItem*>( index.internalPointer() );
|
PackageTreeItem* item = static_cast<PackageTreeItem*>( index.internalPointer() );
|
||||||
if ( index.column() == 0 && role == Qt::CheckStateRole )
|
if ( index.column() == 0 && role == Qt::CheckStateRole )
|
||||||
{
|
|
||||||
return item->isSelected();
|
return item->isSelected();
|
||||||
}
|
|
||||||
|
|
||||||
if ( !item->childCount() ) // package
|
if ( !item->childCount() ) // package
|
||||||
{
|
{
|
||||||
|
@ -120,22 +116,20 @@ PackageModel::data( const QModelIndex& index, int role ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( item->isHidden() && role == Qt::DisplayRole ) // Hidden group
|
if ( item->isHidden() && role == Qt::DisplayRole ) // Hidden group
|
||||||
{
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
|
||||||
|
|
||||||
switch ( role )
|
switch ( role )
|
||||||
{
|
{
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return item->data( index.column() );
|
return item->data( index.column() );
|
||||||
case PackageTreeItem::PreScriptRole:
|
case PackageTreeItem::PreScriptRole:
|
||||||
return QVariant( item->preScript() );
|
return QVariant( item->preScript() );
|
||||||
case PackageTreeItem::PackageNameRole:
|
case PackageTreeItem::PackageNameRole:
|
||||||
return QVariant( item->packageName() );
|
return QVariant( item->packageName() );
|
||||||
case PackageTreeItem::PostScriptRole:
|
case PackageTreeItem::PostScriptRole:
|
||||||
return QVariant( item->postScript() );
|
return QVariant( item->postScript() );
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,8 +141,8 @@ PackageModel::setData( const QModelIndex& index, const QVariant& value, int role
|
||||||
PackageTreeItem* item = static_cast<PackageTreeItem*>( index.internalPointer() );
|
PackageTreeItem* item = static_cast<PackageTreeItem*>( index.internalPointer() );
|
||||||
item->setSelected( static_cast<Qt::CheckState>( value.toInt() ) );
|
item->setSelected( static_cast<Qt::CheckState>( value.toInt() ) );
|
||||||
|
|
||||||
emit dataChanged( this->index(0, 0), index.sibling( index.column(), index.row() + 1 ),
|
emit dataChanged( this->index( 0, 0 ), index.sibling( index.column(), index.row() + 1 ),
|
||||||
QVector<int>( Qt::CheckStateRole ) );
|
QVector<int>( Qt::CheckStateRole ) );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +189,7 @@ PackageModel::getItemPackages( PackageTreeItem* item, bool isCritical ) const
|
||||||
QList<PackageTreeItem*> selectedPackages;
|
QList<PackageTreeItem*> selectedPackages;
|
||||||
for ( int i = 0; i < item->childCount(); i++ )
|
for ( int i = 0; i < item->childCount(); i++ )
|
||||||
{
|
{
|
||||||
if ( item->child( i )->isSelected() == Qt::Unchecked ||
|
if ( item->child( i )->isSelected() == Qt::Unchecked ||
|
||||||
item->child( i )->isCritical() != isCritical )
|
item->child( i )->isCritical() != isCritical )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -216,9 +210,9 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent )
|
||||||
const YAML::Node itemDefinition = *it;
|
const YAML::Node itemDefinition = *it;
|
||||||
|
|
||||||
QString name(
|
QString name(
|
||||||
tr( CalamaresUtils::yamlToVariant( itemDefinition["name"] ).toByteArray() ) );
|
tr( CalamaresUtils::yamlToVariant( itemDefinition["name"] ).toByteArray() ) );
|
||||||
QString description(
|
QString description(
|
||||||
tr( CalamaresUtils::yamlToVariant( itemDefinition["description"] ).toByteArray() ) );
|
tr( CalamaresUtils::yamlToVariant( itemDefinition["description"] ).toByteArray() ) );
|
||||||
|
|
||||||
PackageTreeItem::ItemData itemData;
|
PackageTreeItem::ItemData itemData;
|
||||||
itemData.name = name;
|
itemData.name = name;
|
||||||
|
@ -230,12 +224,12 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent )
|
||||||
if ( itemDefinition["post-install"] )
|
if ( itemDefinition["post-install"] )
|
||||||
itemData.postScript =
|
itemData.postScript =
|
||||||
CalamaresUtils::yamlToVariant( itemDefinition["post-install"] ).toString();
|
CalamaresUtils::yamlToVariant( itemDefinition["post-install"] ).toString();
|
||||||
PackageTreeItem* item = new PackageTreeItem(itemData, parent );
|
PackageTreeItem* item = new PackageTreeItem( itemData, parent );
|
||||||
|
|
||||||
if ( itemDefinition["selected"] )
|
if ( itemDefinition["selected"] )
|
||||||
item->setSelected(
|
item->setSelected(
|
||||||
CalamaresUtils::yamlToVariant( itemDefinition["selected"] ).toBool() ?
|
CalamaresUtils::yamlToVariant( itemDefinition["selected"] ).toBool() ?
|
||||||
Qt::Checked : Qt::Unchecked );
|
Qt::Checked : Qt::Unchecked );
|
||||||
else
|
else
|
||||||
item->setSelected( parent->isSelected() ); // Inherit from it's parent
|
item->setSelected( parent->isSelected() ); // Inherit from it's parent
|
||||||
|
|
||||||
|
@ -249,8 +243,8 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent )
|
||||||
|
|
||||||
for ( YAML::const_iterator packageIt = itemDefinition["packages"].begin();
|
for ( YAML::const_iterator packageIt = itemDefinition["packages"].begin();
|
||||||
packageIt != itemDefinition["packages"].end(); ++packageIt )
|
packageIt != itemDefinition["packages"].end(); ++packageIt )
|
||||||
item->appendChild(
|
item->appendChild(
|
||||||
new PackageTreeItem( CalamaresUtils::yamlToVariant( *packageIt ).toString(), item ) );
|
new PackageTreeItem( CalamaresUtils::yamlToVariant( *packageIt ).toString(), item ) );
|
||||||
|
|
||||||
if ( itemDefinition["subgroups"] )
|
if ( itemDefinition["subgroups"] )
|
||||||
setupModelData( itemDefinition["subgroups"], item );
|
setupModelData( itemDefinition["subgroups"], item );
|
||||||
|
|
|
@ -34,31 +34,31 @@ class PackageModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PackageModel( const YAML::Node& data, const QVariantList& columnHeadings,
|
explicit PackageModel( const YAML::Node& data, const QVariantList& columnHeadings,
|
||||||
QObject* parent = 0 );
|
QObject* parent = 0 );
|
||||||
~PackageModel();
|
~PackageModel();
|
||||||
|
|
||||||
QVariant data( const QModelIndex& index, int role ) const Q_DECL_OVERRIDE;
|
QVariant data( const QModelIndex& index, int role ) const Q_DECL_OVERRIDE;
|
||||||
bool setData( const QModelIndex& index, const QVariant& value,
|
bool setData( const QModelIndex& index, const QVariant& value,
|
||||||
int role = Qt::EditRole) Q_DECL_OVERRIDE;
|
int role = Qt::EditRole ) Q_DECL_OVERRIDE;
|
||||||
Qt::ItemFlags flags( const QModelIndex& index ) const Q_DECL_OVERRIDE;
|
Qt::ItemFlags flags( const QModelIndex& index ) const Q_DECL_OVERRIDE;
|
||||||
QVariant headerData( int section, Qt::Orientation orientation,
|
QVariant headerData( int section, Qt::Orientation orientation,
|
||||||
int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE;
|
int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE;
|
||||||
QModelIndex index( int row, int column,
|
QModelIndex index( int row, int column,
|
||||||
const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE;
|
const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE;
|
||||||
QModelIndex parent( const QModelIndex& index ) const Q_DECL_OVERRIDE;
|
QModelIndex parent( const QModelIndex& index ) const Q_DECL_OVERRIDE;
|
||||||
int rowCount( const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE;
|
int rowCount( const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE;
|
||||||
int columnCount( const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE;
|
int columnCount( const QModelIndex& parent = QModelIndex() ) const Q_DECL_OVERRIDE;
|
||||||
QList<QVariant> getPackages( bool isCritical ) const;
|
QList<QVariant> getPackages( bool isCritical ) const;
|
||||||
QList<PackageTreeItem*> getItemPackages( PackageTreeItem* item, bool isCritical ) const;
|
QList<PackageTreeItem*> getItemPackages( PackageTreeItem* item, bool isCritical ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupModelData( const YAML::Node& data, PackageTreeItem* parent );
|
void setupModelData( const YAML::Node& data, PackageTreeItem* parent );
|
||||||
|
|
||||||
PackageTreeItem* m_rootItem;
|
PackageTreeItem* m_rootItem;
|
||||||
QList<PackageTreeItem*> m_hiddenItems;
|
QList<PackageTreeItem*> m_hiddenItems;
|
||||||
QVariantList m_columnHeadings;
|
QVariantList m_columnHeadings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PACKAGEMODEL_H
|
#endif // PACKAGEMODEL_H
|
||||||
|
|
|
@ -81,14 +81,14 @@ PackageTreeItem::data( int column ) const
|
||||||
return QVariant( packageName() );
|
return QVariant( packageName() );
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
switch( column ) // group
|
switch ( column ) // group
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return QVariant( prettyName() );
|
return QVariant( prettyName() );
|
||||||
case 1:
|
case 1:
|
||||||
return QVariant( description() );
|
return QVariant( description() );
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ PackageTreeItem::setSelected( Qt::CheckState isSelected )
|
||||||
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
|
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
|
||||||
isChildPartiallySelected = true;
|
isChildPartiallySelected = true;
|
||||||
}
|
}
|
||||||
if ( !childrenSelected && !isChildPartiallySelected)
|
if ( !childrenSelected && !isChildPartiallySelected )
|
||||||
currentItem->m_selected = Qt::Unchecked;
|
currentItem->m_selected = Qt::Unchecked;
|
||||||
else if ( childrenSelected == currentItem->childCount() )
|
else if ( childrenSelected == currentItem->childCount() )
|
||||||
currentItem->m_selected = Qt::Checked;
|
currentItem->m_selected = Qt::Checked;
|
||||||
|
|
|
@ -27,53 +27,54 @@
|
||||||
|
|
||||||
class PackageTreeItem : public QStandardItem
|
class PackageTreeItem : public QStandardItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct ItemData {
|
struct ItemData
|
||||||
QString name;
|
{
|
||||||
QString description;
|
QString name;
|
||||||
QString preScript;
|
QString description;
|
||||||
QString postScript;
|
QString preScript;
|
||||||
};
|
QString postScript;
|
||||||
explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = 0 );
|
};
|
||||||
explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = 0 );
|
explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = 0 );
|
||||||
explicit PackageTreeItem( PackageTreeItem* parent = 0 );
|
explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = 0 );
|
||||||
~PackageTreeItem();
|
explicit PackageTreeItem( PackageTreeItem* parent = 0 );
|
||||||
|
~PackageTreeItem();
|
||||||
|
|
||||||
void appendChild( PackageTreeItem* child );
|
void appendChild( PackageTreeItem* child );
|
||||||
PackageTreeItem* child( int row );
|
PackageTreeItem* child( int row );
|
||||||
int childCount() const;
|
int childCount() const;
|
||||||
int columnCount() const;
|
int columnCount() const;
|
||||||
QVariant data( int column ) const Q_DECL_OVERRIDE;
|
QVariant data( int column ) const Q_DECL_OVERRIDE;
|
||||||
int row() const;
|
int row() const;
|
||||||
PackageTreeItem* parentItem();
|
PackageTreeItem* parentItem();
|
||||||
QString prettyName() const;
|
QString prettyName() const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
QString preScript() const;
|
QString preScript() const;
|
||||||
QString packageName() const;
|
QString packageName() const;
|
||||||
QString postScript() const;
|
QString postScript() const;
|
||||||
bool isHidden() const;
|
bool isHidden() const;
|
||||||
void setHidden( bool isHidden);
|
void setHidden( bool isHidden );
|
||||||
bool isCritical() const;
|
bool isCritical() const;
|
||||||
void setCritical( bool isCritical);
|
void setCritical( bool isCritical );
|
||||||
Qt::CheckState isSelected() const;
|
Qt::CheckState isSelected() const;
|
||||||
void setSelected( Qt::CheckState isSelected );
|
void setSelected( Qt::CheckState isSelected );
|
||||||
void setChildrenSelected( Qt::CheckState isSelected );
|
void setChildrenSelected( Qt::CheckState isSelected );
|
||||||
int type() const Q_DECL_OVERRIDE;
|
int type() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
static const int PreScriptRole = Qt::UserRole;
|
static const int PreScriptRole = Qt::UserRole;
|
||||||
static const int PackageNameRole = Qt::UserRole + 1;
|
static const int PackageNameRole = Qt::UserRole + 1;
|
||||||
static const int PostScriptRole = Qt::UserRole + 2;
|
static const int PostScriptRole = Qt::UserRole + 2;
|
||||||
private:
|
private:
|
||||||
QList<PackageTreeItem*> m_childItems;
|
QList<PackageTreeItem*> m_childItems;
|
||||||
ItemData m_data;
|
ItemData m_data;
|
||||||
QString m_packageName;
|
QString m_packageName;
|
||||||
|
|
||||||
// See README.md for a description of these two fields.
|
// See README.md for a description of these two fields.
|
||||||
Qt::CheckState m_selected = Qt::Unchecked;
|
Qt::CheckState m_selected = Qt::Unchecked;
|
||||||
bool m_hidden = false;
|
bool m_hidden = false;
|
||||||
bool m_critical = false;
|
bool m_critical = false;
|
||||||
const int m_columns = 2; // Name, description
|
const int m_columns = 2; // Name, description
|
||||||
PackageTreeItem* m_parentItem;
|
PackageTreeItem* m_parentItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PACKAGETREEITEM_H
|
#endif // PACKAGETREEITEM_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue