From 9116718448833e9231771fdad990dea985d9bf6d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 10 Sep 2017 15:17:33 -0400 Subject: [PATCH] Clang: warnings-reduction --- src/libcalamares/utils/Units.h | 5 ++++ .../partition/gui/PartitionLabelsView.cpp | 24 +++++++++++++------ .../partition/gui/PartitionLabelsView.h | 2 +- src/modules/partition/gui/PartitionPage.cpp | 4 ++-- .../partition/gui/PartitionSizeController.cpp | 4 +++- .../partition/jobs/FillGlobalStorageJob.cpp | 2 -- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/libcalamares/utils/Units.h b/src/libcalamares/utils/Units.h index 81e2a9bca..391d67194 100644 --- a/src/libcalamares/utils/Units.h +++ b/src/libcalamares/utils/Units.h @@ -56,5 +56,10 @@ constexpr qint64 GiBtoBytes( double m ) return qint64(m * 1024 * 1024 * 1024); } +constexpr int BytesToMiB( qint64 b ) +{ + return int( b / 1024 / 1024 ); +} + } // namespace #endif diff --git a/src/modules/partition/gui/PartitionLabelsView.cpp b/src/modules/partition/gui/PartitionLabelsView.cpp index d7364fb5f..c0b7fdd41 100644 --- a/src/modules/partition/gui/PartitionLabelsView.cpp +++ b/src/modules/partition/gui/PartitionLabelsView.cpp @@ -43,7 +43,7 @@ static const int LABELS_MARGIN = LABEL_PARTITION_SQUARE_MARGIN; static const int CORNER_RADIUS = 2; -QStringList +static QStringList buildUnknownDisklabelTexts( Device* dev ) { QStringList texts = { QObject::tr( "Unpartitioned space or unknown partition table" ), @@ -54,7 +54,7 @@ buildUnknownDisklabelTexts( Device* dev ) PartitionLabelsView::PartitionLabelsView( QWidget* parent ) : QAbstractItemView( parent ) - , canBeSelected( []( const QModelIndex& ) { return true; } ) + , m_canBeSelected( []( const QModelIndex& ) { return true; } ) , m_extendedPartitionHidden( false ) { setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); @@ -100,6 +100,8 @@ PartitionLabelsView::sizeHint() const void PartitionLabelsView::paintEvent( QPaintEvent* event ) { + Q_UNUSED( event ); + QPainter painter( viewport() ); painter.fillRect( rect(), palette().window() ); painter.setRenderHint( QPainter::Antialiasing ); @@ -292,7 +294,6 @@ PartitionLabelsView::drawLabels( QPainter* painter, !modl->device()->partitionTable() ) // No disklabel or unknown { QStringList texts = buildUnknownDisklabelTexts( modl->device() ); - QSize labelSize = sizeForLabel( texts ); QColor labelColor = ColorUtils::unknownDisklabelColor(); drawLabel( painter, texts, labelColor, QPoint( rect.x(), rect.y() ), false /*can't be selected*/ ); } @@ -467,6 +468,8 @@ PartitionLabelsView::visualRect( const QModelIndex& idx ) const QRegion PartitionLabelsView::visualRegionForSelection( const QItemSelection& selection ) const { + Q_UNUSED( selection ); + return QRegion(); } @@ -516,7 +519,7 @@ PartitionLabelsView::setSelectionModel( QItemSelectionModel* selectionModel ) void PartitionLabelsView::setSelectionFilter( SelectionFilter canBeSelected ) { - this->canBeSelected = canBeSelected; + m_canBeSelected = canBeSelected; } @@ -530,6 +533,9 @@ PartitionLabelsView::setExtendedPartitionHidden( bool hidden ) QModelIndex PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) { + Q_UNUSED( cursorAction ); + Q_UNUSED( modifiers ); + return QModelIndex(); } @@ -537,6 +543,8 @@ PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifier bool PartitionLabelsView::isIndexHidden( const QModelIndex& index ) const { + Q_UNUSED( index ); + return false; } @@ -545,7 +553,7 @@ void PartitionLabelsView::setSelection( const QRect& rect, QItemSelectionModel::SelectionFlags flags ) { QModelIndex eventIndex = indexAt( rect.topLeft() ); - if ( canBeSelected( eventIndex ) ) + if ( m_canBeSelected( eventIndex ) ) selectionModel()->select( eventIndex, flags ); } @@ -567,7 +575,7 @@ PartitionLabelsView::mouseMoveEvent( QMouseEvent* event ) if ( oldHoveredIndex != m_hoveredIndex ) { - if ( m_hoveredIndex.isValid() && !canBeSelected( m_hoveredIndex ) ) + if ( m_hoveredIndex.isValid() && !m_canBeSelected( m_hoveredIndex ) ) QGuiApplication::setOverrideCursor( Qt::ForbiddenCursor ); else QGuiApplication::restoreOverrideCursor(); @@ -580,6 +588,8 @@ PartitionLabelsView::mouseMoveEvent( QMouseEvent* event ) void PartitionLabelsView::leaveEvent( QEvent* event ) { + Q_UNUSED( event ); + QGuiApplication::restoreOverrideCursor(); if ( m_hoveredIndex.isValid() ) { @@ -593,7 +603,7 @@ void PartitionLabelsView::mousePressEvent( QMouseEvent* event ) { QModelIndex candidateIndex = indexAt( event->pos() ); - if ( canBeSelected( candidateIndex ) ) + if ( m_canBeSelected( candidateIndex ) ) QAbstractItemView::mousePressEvent( event ); else event->accept(); diff --git a/src/modules/partition/gui/PartitionLabelsView.h b/src/modules/partition/gui/PartitionLabelsView.h index fef453d44..c5646a417 100644 --- a/src/modules/partition/gui/PartitionLabelsView.h +++ b/src/modules/partition/gui/PartitionLabelsView.h @@ -83,7 +83,7 @@ private: QModelIndexList getIndexesToDraw( const QModelIndex& parent ) const; QStringList buildTexts( const QModelIndex& index ) const; - SelectionFilter canBeSelected; + SelectionFilter m_canBeSelected; bool m_extendedPartitionHidden; QString m_customNewRootLabel; diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index 5d541c4e2..62e7a97a1 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -56,8 +56,8 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) : QWidget( parent ) , m_ui( new Ui_PartitionPage ) - , m_lastSelectedBootLoaderIndex(-1) , m_core( core ) + , m_lastSelectedBootLoaderIndex(-1) , m_isEfi( false ) { m_isEfi = PartUtils::isEfiSystem(); @@ -373,7 +373,7 @@ PartitionPage::updateFromCurrentDevice() // Establish connection here because selection model is destroyed when // model changes connect( m_ui->partitionTreeView->selectionModel(), &QItemSelectionModel::currentChanged, - [ this ]( const QModelIndex& index, const QModelIndex& oldIndex ) + [ this ]( const QModelIndex&, const QModelIndex& ) { updateButtons(); } ); diff --git a/src/modules/partition/gui/PartitionSizeController.cpp b/src/modules/partition/gui/PartitionSizeController.cpp index d01924e8b..3cf915c7d 100644 --- a/src/modules/partition/gui/PartitionSizeController.cpp +++ b/src/modules/partition/gui/PartitionSizeController.cpp @@ -22,6 +22,8 @@ #include "core/ColorUtils.h" #include "core/KPMHelpers.h" +#include "utils/Units.h" + // Qt #include @@ -185,7 +187,7 @@ PartitionSizeController::doUpdateSpinBox() { if ( !m_spinBox ) return; - qint64 mbSize = m_partition->length() * m_device->logicalSize() / 1024 / 1024; + int mbSize = CalamaresUtils::BytesToMiB( m_partition->length() * m_device->logicalSize() ); m_spinBox->setValue( mbSize ); if ( m_currentSpinBoxValue != -1 && //if it's not the first time we're setting it m_currentSpinBoxValue != mbSize ) //and the operation changes the SB value diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index 5662f5e57..09eaf232d 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -41,8 +41,6 @@ typedef QHash UuidForPartitionHash; -static const char* UUID_DIR = "/dev/disk/by-uuid"; - static UuidForPartitionHash findPartitionUuids( QList < Device* > devices ) {