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