using auto, where it makes sense

This commit is contained in:
Uwe Rathmann 2019-02-26 21:49:39 +01:00
parent 72a7e7f8e7
commit 9989ae85d3
13 changed files with 32 additions and 31 deletions

View File

@ -43,7 +43,7 @@ ButtonBar::ButtonBar( QQuickItem* parentItem )
void ButtonBar::addIndicator( const char* name )
{
auto* label = new IndicatorLabel( this );
auto label = new IndicatorLabel( this );
/*
The label should adjust vertically and be stretched horizontally

View File

@ -10,10 +10,10 @@ class SkinFactory : public QskSkinFactory
public:
enum GraphicRoles
{
// to be visisble on a button
// to be visible on a button
Button,
// to be visisble on header/footer
// to be visible on header/footer
Indicator,
// in contrast to the background pixmap

View File

@ -210,7 +210,7 @@ class StackedControl final : public QskControl
for ( int a = 0; a < children().count(); a++ )
{
QskControl* control = static_cast< QskControl* >( children().at( a ) );
auto control = static_cast< QskControl* >( children().at( a ) );
if ( control->objectName() == "verticalBar" )
{
@ -250,7 +250,7 @@ class SectionTitleBar final : public QskLinearBox
{
setSpacing( 10 );
auto* label = new QskTextLabel( title );
auto label = new QskTextLabel( title );
label->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
addItem( new QskSeparator() );
@ -275,7 +275,7 @@ class SliderBox final : public QskLinearBox
label->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
m_numberLabel->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
auto* plusButton = new ControlButton( '+' );
auto plusButton = new ControlButton( '+' );
auto minusButton = new ControlButton( '-' );
m_slider = new QskSlider( Qt::Vertical );

View File

@ -79,11 +79,11 @@ void Theme::setSkin( const QString& skinName )
if ( skinName == qskSetup->skinName() )
return;
QskSkin* oldSkin = qskSetup->skin();
auto oldSkin = qskSetup->skin();
if ( oldSkin->parent() == qskSetup )
oldSkin->setParent( nullptr ); // otherwise setSkin deletes it
QskSkin* newSkin = qskSetup->setSkin( skinName );
auto newSkin = qskSetup->setSkin( skinName );
SkinTransition transition( m_accent );

View File

@ -16,8 +16,9 @@ ButtonBox::ButtonBox( QQuickItem* parent )
void ButtonBox::addButton(
const QString& text, std::function< void() > func, bool autoRepeat )
{
QskPushButton* button = new QskPushButton( text );
auto button = new QskPushButton( text );
button->setAutoRepeat( autoRepeat );
QObject::connect( button, &QskPushButton::clicked, func );
addItem( button );

View File

@ -128,10 +128,11 @@ DynamicConstraintsPage::DynamicConstraintsPage( QQuickItem* parent )
setMargins( 10 );
setBackgroundColor( QskRgbValue::LightSteelBlue );
Box* box = new Box();
auto box = new Box();
QskPushButton* button = new QskPushButton( "Flip" );
auto button = new QskPushButton( "Flip" );
button->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
QObject::connect( button, &QskPushButton::clicked, box, &Box::flip );
addItem( button, Qt::AlignTop | Qt::AlignLeft );

View File

@ -75,8 +75,9 @@ namespace
private:
void addRectangle( const char* colorName )
{
TestRectangle* rect = new TestRectangle( colorName );
auto rect = new TestRectangle( colorName );
rect->setText( QString::number( itemCount() + 1 ) );
addItem( rect, Qt::AlignCenter );
}
};
@ -88,9 +89,9 @@ FlowLayoutPage::FlowLayoutPage( QQuickItem* parent )
setMargins( 10 );
setBackgroundColor( QskRgbValue::LightSteelBlue );
Box* box = new Box();
auto box = new Box();
ButtonBox* buttonBox = new ButtonBox();
auto buttonBox = new ButtonBox();
buttonBox->addButton( "Flip", [ box ]() { box->transpose(); } );
buttonBox->addButton( "Mirror", [ box ]() { box->mirror(); } );
buttonBox->addButton( "Rotate", [ box ]() { box->rotate(); } );

View File

@ -72,7 +72,7 @@ namespace
private:
void addRectangle( const char* colorName )
{
TestRectangle* rect = new TestRectangle( colorName );
auto rect = new TestRectangle( colorName );
rect->setText( QString::number( itemCount() + 1 ) );
addItem( rect, Qt::AlignCenter );
@ -86,9 +86,9 @@ LinearLayoutPage::LinearLayoutPage( QQuickItem* parent )
setMargins( 10 );
setBackgroundColor( QskRgbValue::LightSteelBlue );
Box* box = new Box();
auto box = new Box();
ButtonBox* buttonBox = new ButtonBox();
auto buttonBox = new ButtonBox();
buttonBox->addButton( "Flip", [ box ]() { box->transpose(); } );
buttonBox->addButton( "Mirror", [ box ]() { box->mirror(); } );
buttonBox->addButton( "Rotate", [ box ]() { box->rotate(); } );

View File

@ -35,8 +35,7 @@ namespace
for ( int i = 0; i < itemCount(); i += 2 )
{
QskControl* control = qobject_cast< QskControl* >( itemAtIndex( i ) );
if ( control )
if ( auto control = qobject_cast< QskControl* >( itemAtIndex( i ) ) )
control->setFixedSize( 200, 200 );
}
}

View File

@ -51,7 +51,7 @@ int main( int argc, char* argv[] )
SkinnyFont::init( &app );
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
QskTabView* tabView = new QskTabView();
auto tabView = new QskTabView();
tabView->setMargins( 10 );
tabView->setOrientation( Qt::Horizontal );
tabView->addTab( "Grid Layout", new DummyLabel( "Grid Layout - TODO ..." ) );
@ -59,7 +59,7 @@ int main( int argc, char* argv[] )
tabView->addTab( "Linear Layout", new LinearLayoutPage() );
int dynamicIndex = tabView->addTab( "Dynamic\nConstraints", new DynamicConstraintsPage() );
QskTabButton* button = tabView->buttonAt( dynamicIndex );
auto button = tabView->buttonAt( dynamicIndex );
QskTextOptions textOptions = button->textOptions();
textOptions.setWrapMode( QskTextOptions::WordWrap );
button->setTextOptions( textOptions );

View File

@ -131,7 +131,7 @@ int main( int argc, char* argv[] )
qskDialog->setPolicy( QskDialog::EmbeddedBox );
ButtonBox* box = new ButtonBox();
auto box = new ButtonBox();
/*
To avoid losing the focus, when a message box is executed

View File

@ -70,8 +70,7 @@ class HandleNode : public QSGGeometryNode
if ( rect != m_rect || peakPos != m_peakPos )
{
QSGGeometry::Point2D* p =
reinterpret_cast< QSGGeometry::Point2D* >( m_geometry.vertexData() );
auto p = reinterpret_cast< QSGGeometry::Point2D* >( m_geometry.vertexData() );
const qreal y0 = rect.y() + qskPeak;

View File

@ -136,7 +136,7 @@ class SliderBox : public QskLinearBox
for ( int i = 0; i < itemCount(); i++ )
{
if ( QskSlider* slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
if ( auto slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
{
slider->setObjectName( "Slider " + QString::number( i + 1 ) );
slider->setValue( slider->minimum() +
@ -156,7 +156,7 @@ class SliderBox : public QskLinearBox
for ( int i = 0; i < itemCount(); i++ )
{
if ( QskSlider* slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
if ( auto slider = qobject_cast< QskSlider* >( itemAtIndex( i ) ) )
{
const Qt::Orientation orientation = inverted( slider->orientation() );
@ -170,7 +170,7 @@ class SliderBox : public QskLinearBox
slider->setVisible( orientation == Qt::Horizontal );
}
}
else if ( QskSeparator* separator = qobject_cast< QskSeparator* >( itemAtIndex( i ) ) )
else if ( auto separator = qobject_cast< QskSeparator* >( itemAtIndex( i ) ) )
{
separator->setOrientation( inverted( separator->orientation() ) );
}
@ -195,24 +195,24 @@ int main( int argc, char* argv[] )
SkinnyFont::init( &app );
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
QskPushButton* buttonFlip = new QskPushButton( "Flip" );
auto buttonFlip = new QskPushButton( "Flip" );
buttonFlip->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
buttonFlip->setFocus( true );
SliderBox* sliderBox = new SliderBox();
auto sliderBox = new SliderBox();
sliderBox->setBackgroundColor( QskRgbValue::PeachPuff );
QObject::connect( buttonFlip, &QskPushButton::clicked,
sliderBox, &SliderBox::flip );
QskLinearBox* mainBox = new QskLinearBox( Qt::Vertical );
auto mainBox = new QskLinearBox( Qt::Vertical );
mainBox->setMargins( 10 );
mainBox->setSpacing( 10 );
mainBox->addItem( buttonFlip, Qt::AlignLeft );
mainBox->addItem( sliderBox );
mainBox->setStretchFactor( sliderBox, 10 );
QskFocusIndicator* focusIndicator = new QskFocusIndicator();
auto focusIndicator = new QskFocusIndicator();
focusIndicator->setObjectName( "FocusIndicator" );
QskWindow window;