Clang: warnings-reduction

This commit is contained in:
Adriaan de Groot 2017-09-10 15:17:33 -04:00
parent 463615a1c0
commit 9116718448
6 changed files with 28 additions and 13 deletions

View File

@ -56,5 +56,10 @@ constexpr qint64 GiBtoBytes( double m )
return qint64(m * 1024 * 1024 * 1024); return qint64(m * 1024 * 1024 * 1024);
} }
constexpr int BytesToMiB( qint64 b )
{
return int( b / 1024 / 1024 );
}
} // namespace } // namespace
#endif #endif

View File

@ -43,7 +43,7 @@ static const int LABELS_MARGIN = LABEL_PARTITION_SQUARE_MARGIN;
static const int CORNER_RADIUS = 2; static const int CORNER_RADIUS = 2;
QStringList static QStringList
buildUnknownDisklabelTexts( Device* dev ) buildUnknownDisklabelTexts( Device* dev )
{ {
QStringList texts = { QObject::tr( "Unpartitioned space or unknown partition table" ), QStringList texts = { QObject::tr( "Unpartitioned space or unknown partition table" ),
@ -54,7 +54,7 @@ buildUnknownDisklabelTexts( Device* dev )
PartitionLabelsView::PartitionLabelsView( QWidget* parent ) PartitionLabelsView::PartitionLabelsView( QWidget* parent )
: QAbstractItemView( parent ) : QAbstractItemView( parent )
, canBeSelected( []( const QModelIndex& ) { return true; } ) , m_canBeSelected( []( const QModelIndex& ) { return true; } )
, m_extendedPartitionHidden( false ) , m_extendedPartitionHidden( false )
{ {
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
@ -100,6 +100,8 @@ PartitionLabelsView::sizeHint() const
void void
PartitionLabelsView::paintEvent( QPaintEvent* event ) PartitionLabelsView::paintEvent( QPaintEvent* event )
{ {
Q_UNUSED( event );
QPainter painter( viewport() ); QPainter painter( viewport() );
painter.fillRect( rect(), palette().window() ); painter.fillRect( rect(), palette().window() );
painter.setRenderHint( QPainter::Antialiasing ); painter.setRenderHint( QPainter::Antialiasing );
@ -292,7 +294,6 @@ PartitionLabelsView::drawLabels( QPainter* painter,
!modl->device()->partitionTable() ) // No disklabel or unknown !modl->device()->partitionTable() ) // No disklabel or unknown
{ {
QStringList texts = buildUnknownDisklabelTexts( modl->device() ); QStringList texts = buildUnknownDisklabelTexts( modl->device() );
QSize labelSize = sizeForLabel( texts );
QColor labelColor = ColorUtils::unknownDisklabelColor(); QColor labelColor = ColorUtils::unknownDisklabelColor();
drawLabel( painter, texts, labelColor, QPoint( rect.x(), rect.y() ), false /*can't be selected*/ ); 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 QRegion
PartitionLabelsView::visualRegionForSelection( const QItemSelection& selection ) const PartitionLabelsView::visualRegionForSelection( const QItemSelection& selection ) const
{ {
Q_UNUSED( selection );
return QRegion(); return QRegion();
} }
@ -516,7 +519,7 @@ PartitionLabelsView::setSelectionModel( QItemSelectionModel* selectionModel )
void void
PartitionLabelsView::setSelectionFilter( SelectionFilter canBeSelected ) PartitionLabelsView::setSelectionFilter( SelectionFilter canBeSelected )
{ {
this->canBeSelected = canBeSelected; m_canBeSelected = canBeSelected;
} }
@ -530,6 +533,9 @@ PartitionLabelsView::setExtendedPartitionHidden( bool hidden )
QModelIndex QModelIndex
PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers )
{ {
Q_UNUSED( cursorAction );
Q_UNUSED( modifiers );
return QModelIndex(); return QModelIndex();
} }
@ -537,6 +543,8 @@ PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifier
bool bool
PartitionLabelsView::isIndexHidden( const QModelIndex& index ) const PartitionLabelsView::isIndexHidden( const QModelIndex& index ) const
{ {
Q_UNUSED( index );
return false; return false;
} }
@ -545,7 +553,7 @@ void
PartitionLabelsView::setSelection( const QRect& rect, QItemSelectionModel::SelectionFlags flags ) PartitionLabelsView::setSelection( const QRect& rect, QItemSelectionModel::SelectionFlags flags )
{ {
QModelIndex eventIndex = indexAt( rect.topLeft() ); QModelIndex eventIndex = indexAt( rect.topLeft() );
if ( canBeSelected( eventIndex ) ) if ( m_canBeSelected( eventIndex ) )
selectionModel()->select( eventIndex, flags ); selectionModel()->select( eventIndex, flags );
} }
@ -567,7 +575,7 @@ PartitionLabelsView::mouseMoveEvent( QMouseEvent* event )
if ( oldHoveredIndex != m_hoveredIndex ) if ( oldHoveredIndex != m_hoveredIndex )
{ {
if ( m_hoveredIndex.isValid() && !canBeSelected( m_hoveredIndex ) ) if ( m_hoveredIndex.isValid() && !m_canBeSelected( m_hoveredIndex ) )
QGuiApplication::setOverrideCursor( Qt::ForbiddenCursor ); QGuiApplication::setOverrideCursor( Qt::ForbiddenCursor );
else else
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
@ -580,6 +588,8 @@ PartitionLabelsView::mouseMoveEvent( QMouseEvent* event )
void void
PartitionLabelsView::leaveEvent( QEvent* event ) PartitionLabelsView::leaveEvent( QEvent* event )
{ {
Q_UNUSED( event );
QGuiApplication::restoreOverrideCursor(); QGuiApplication::restoreOverrideCursor();
if ( m_hoveredIndex.isValid() ) if ( m_hoveredIndex.isValid() )
{ {
@ -593,7 +603,7 @@ void
PartitionLabelsView::mousePressEvent( QMouseEvent* event ) PartitionLabelsView::mousePressEvent( QMouseEvent* event )
{ {
QModelIndex candidateIndex = indexAt( event->pos() ); QModelIndex candidateIndex = indexAt( event->pos() );
if ( canBeSelected( candidateIndex ) ) if ( m_canBeSelected( candidateIndex ) )
QAbstractItemView::mousePressEvent( event ); QAbstractItemView::mousePressEvent( event );
else else
event->accept(); event->accept();

View File

@ -83,7 +83,7 @@ private:
QModelIndexList getIndexesToDraw( const QModelIndex& parent ) const; QModelIndexList getIndexesToDraw( const QModelIndex& parent ) const;
QStringList buildTexts( const QModelIndex& index ) const; QStringList buildTexts( const QModelIndex& index ) const;
SelectionFilter canBeSelected; SelectionFilter m_canBeSelected;
bool m_extendedPartitionHidden; bool m_extendedPartitionHidden;
QString m_customNewRootLabel; QString m_customNewRootLabel;

View File

@ -56,8 +56,8 @@
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_ui( new Ui_PartitionPage ) , m_ui( new Ui_PartitionPage )
, m_lastSelectedBootLoaderIndex(-1)
, m_core( core ) , m_core( core )
, m_lastSelectedBootLoaderIndex(-1)
, m_isEfi( false ) , m_isEfi( false )
{ {
m_isEfi = PartUtils::isEfiSystem(); m_isEfi = PartUtils::isEfiSystem();
@ -373,7 +373,7 @@ PartitionPage::updateFromCurrentDevice()
// Establish connection here because selection model is destroyed when // Establish connection here because selection model is destroyed when
// model changes // model changes
connect( m_ui->partitionTreeView->selectionModel(), &QItemSelectionModel::currentChanged, connect( m_ui->partitionTreeView->selectionModel(), &QItemSelectionModel::currentChanged,
[ this ]( const QModelIndex& index, const QModelIndex& oldIndex ) [ this ]( const QModelIndex&, const QModelIndex& )
{ {
updateButtons(); updateButtons();
} ); } );

View File

@ -22,6 +22,8 @@
#include "core/ColorUtils.h" #include "core/ColorUtils.h"
#include "core/KPMHelpers.h" #include "core/KPMHelpers.h"
#include "utils/Units.h"
// Qt // Qt
#include <QSpinBox> #include <QSpinBox>
@ -185,7 +187,7 @@ PartitionSizeController::doUpdateSpinBox()
{ {
if ( !m_spinBox ) if ( !m_spinBox )
return; 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 ); m_spinBox->setValue( mbSize );
if ( m_currentSpinBoxValue != -1 && //if it's not the first time we're setting it 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 m_currentSpinBoxValue != mbSize ) //and the operation changes the SB value

View File

@ -41,8 +41,6 @@
typedef QHash<QString, QString> UuidForPartitionHash; typedef QHash<QString, QString> UuidForPartitionHash;
static const char* UUID_DIR = "/dev/disk/by-uuid";
static UuidForPartitionHash static UuidForPartitionHash
findPartitionUuids( QList < Device* > devices ) findPartitionUuids( QList < Device* > devices )
{ {