making clazy happier

This commit is contained in:
Uwe Rathmann 2017-10-30 14:38:30 +01:00
parent 3504525840
commit 6db25ff7bc
18 changed files with 103 additions and 49 deletions

View File

@ -298,10 +298,10 @@ public:
// finally connect buttons/slider/labels // finally connect buttons/slider/labels
connect( plusButton, &QskPushButton::pressed, connect( plusButton, &QskPushButton::pressed,
[ this ]() { increment( 1 ); } ); this, [ this ]() { increment( 1 ); } );
connect( minusButton, &QskPushButton::pressed, connect( minusButton, &QskPushButton::pressed,
[ this ]() { increment( -1 ); } ); this, [ this ]() { increment( -1 ); } );
connect( m_slider, &QskSlider::valueChanged, connect( m_slider, &QskSlider::valueChanged,
this, &SliderBox::setValue ); this, &SliderBox::setValue );
@ -370,7 +370,7 @@ public:
setAlignment( button, Qt::AlignCenter ); setAlignment( button, Qt::AlignCenter );
connect( button, &QskPushButton::pressed, connect( button, &QskPushButton::pressed,
[ = ]() { shift( button->offset() ); } ); this, [ = ]() { shift( button->offset() ); } );
} }
} }

View File

@ -52,10 +52,10 @@ Theme::Theme( QObject* parent ):
m_accent( qskSetup->skin()->color( QskAspect::Color ) ) m_accent( qskSetup->skin()->color( QskAspect::Color ) )
{ {
connect( qskSetup, &QskSetup::skinChanged, connect( qskSetup, &QskSetup::skinChanged,
[this]( QskSkin* ) { updateColors(); } ); this, [this]( QskSkin* ) { updateColors(); } );
connect( qskSetup, &QskSetup::skinChanged, connect( qskSetup, &QskSetup::skinChanged,
[this]( QskSkin* ) { Q_EMIT skinChanged(); } ); this, [this]( QskSkin* ) { Q_EMIT skinChanged(); } );
} }
void Theme::setAccent( QColor color ) void Theme::setAccent( QColor color )

View File

@ -28,10 +28,11 @@ linux {
-isystem $$[QT_INSTALL_HEADERS] \ -isystem $$[QT_INSTALL_HEADERS] \
-isystem $$[QT_INSTALL_HEADERS]/QtCore \ -isystem $$[QT_INSTALL_HEADERS]/QtCore \
-isystem $$[QT_INSTALL_HEADERS]/QtGui \ -isystem $$[QT_INSTALL_HEADERS]/QtGui \
-isystem $$[QT_INSTALL_HEADERS]/QtGui/$$[QT_VERSION]/QtGui/private \ -isystem $$[QT_INSTALL_HEADERS]/QtGui/$$[QT_VERSION]/QtGui \
-isystem $$[QT_INSTALL_HEADERS]/QtQuick \ -isystem $$[QT_INSTALL_HEADERS]/QtQuick \
-isystem $$[QT_INSTALL_HEADERS]/QtQuick/$$[QT_VERSION]/QtQuick/private \ -isystem $$[QT_INSTALL_HEADERS]/QtQuick/$$[QT_VERSION]/QtQuick \
-isystem $$[QT_INSTALL_HEADERS]/QtQml -isystem $$[QT_INSTALL_HEADERS]/QtQml \
-isystem $$[QT_INSTALL_HEADERS]/QtQml/$$[QT_VERSION]/QtQml \
} }
} }

View File

@ -39,4 +39,20 @@
#define QSK_QT_PRIVATE_END \ #define QSK_QT_PRIVATE_END \
QT_WARNING_POP QT_WARNING_POP
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
#define qskAsConst qAsConst
#else
template <typename T> struct QskAddConst { typedef const T Type; };
template <typename T>
constexpr typename QskAddConst<T>::Type &qskAsConst( T &t ) noexcept { return t; }
template <typename T>
void qskAsConst( const T && ) = delete;
#endif
#endif #endif

View File

@ -50,13 +50,13 @@ public:
void addObject( QObject* object ) void addObject( QObject* object )
{ {
for ( auto counter : m_counterSet ) for ( auto counter : qskAsConst( m_counterSet ) )
counter->addObject( object ); counter->addObject( object );
} }
void removeObject( QObject* object ) void removeObject( QObject* object )
{ {
for ( auto counter : m_counterSet ) for ( auto counter : qskAsConst( m_counterSet ) )
counter->removeObject( object ); counter->removeObject( object );
} }

View File

@ -61,8 +61,6 @@ namespace
int current; int current;
int maximum; int maximum;
}; };
static Statistics qskStatistics;
} }
/* /*
@ -227,13 +225,15 @@ void QskAnimatorDriver::advanceAnimators( QQuickWindow* window )
} }
Q_GLOBAL_STATIC( QskAnimatorDriver, qskAnimatorDriver ) Q_GLOBAL_STATIC( QskAnimatorDriver, qskAnimatorDriver )
Q_GLOBAL_STATIC( Statistics, qskStatistics )
QskAnimator::QskAnimator(): QskAnimator::QskAnimator():
m_window( nullptr ), m_window( nullptr ),
m_duration( 200 ), m_duration( 200 ),
m_startTime( -1 ) m_startTime( -1 )
{ {
qskStatistics.increment(); if ( qskStatistics )
qskStatistics->increment();
} }
QskAnimator::~QskAnimator() QskAnimator::~QskAnimator()
@ -241,7 +241,8 @@ QskAnimator::~QskAnimator()
if ( qskAnimatorDriver ) if ( qskAnimatorDriver )
qskAnimatorDriver->unregisterAnimator( this ); qskAnimatorDriver->unregisterAnimator( this );
qskStatistics.decrement(); if ( qskStatistics )
qskStatistics->decrement();
} }
QQuickWindow* QskAnimator::window() const QQuickWindow* QskAnimator::window() const
@ -372,7 +373,8 @@ QMetaObject::Connection QskAnimator::addAdvanceHandler( QObject* receiver,
void QskAnimator::debugStatistics( QDebug debug ) void QskAnimator::debugStatistics( QDebug debug )
{ {
qskStatistics.debugStatistics( debug ); if ( qskStatistics )
qskStatistics->debugStatistics( debug );
} }
#endif #endif

View File

@ -13,6 +13,7 @@
#include <QLocale> #include <QLocale>
#include <QVector> #include <QVector>
#include <QGlobalStatic>
QSK_QT_PRIVATE_BEGIN QSK_QT_PRIVATE_BEGIN
#include <private/qquickitem_p.h> #include <private/qquickitem_p.h>
@ -99,7 +100,7 @@ namespace
}; };
} }
static QskWindowStore qskReleasedWindowCounter; Q_GLOBAL_STATIC( QskWindowStore, qskReleasedWindowCounter )
class QskControlPrivate : public QQuickItemPrivate class QskControlPrivate : public QQuickItemPrivate
{ {
@ -1045,7 +1046,7 @@ void QskControl::releaseResources()
// sequences to be able to provide the correct "oldWindow" // sequences to be able to provide the correct "oldWindow"
// in the WindowChange event. // in the WindowChange event.
qskReleasedWindowCounter.setWindow( window() ); qskReleasedWindowCounter->setWindow( window() );
} }
const QSGNode* QskControl::itemNode( const QQuickItem* item ) const QSGNode* QskControl::itemNode( const QQuickItem* item )
@ -1125,7 +1126,7 @@ void QskControl::itemChange( QQuickItem::ItemChange change,
} }
QskWindowChangeEvent event( QskWindowChangeEvent event(
qskReleasedWindowCounter.window(), value.window ); qskReleasedWindowCounter->window(), value.window );
QCoreApplication::sendEvent( this, &event ); QCoreApplication::sendEvent( this, &event );
break; break;

View File

@ -9,9 +9,9 @@
namespace namespace
{ {
static const QString factoryId = "QSkinny"; static const char factoryId[] = "qskinny";
static const QString squiekSkinName = "Squiek"; static const char squiekSkinName[] = "Squiek";
static const QString materialSkinName = "Material"; static const char materialSkinName[] = "Material";
class SkinFactory final : public QskSkinFactory class SkinFactory final : public QskSkinFactory
{ {
@ -53,7 +53,7 @@ static FactoryTable& qskGetFactoryTable()
if ( qskFactoryTable->isEmpty() ) if ( qskFactoryTable->isEmpty() )
{ {
static SkinFactory dummySkinFactory ( nullptr ); static SkinFactory dummySkinFactory ( nullptr );
qskFactoryTable->insert( factoryId.toLower(), &dummySkinFactory ); qskFactoryTable->insert( factoryId, &dummySkinFactory );
} }
return *qskFactoryTable; return *qskFactoryTable;

View File

@ -202,7 +202,8 @@ namespace
addControlAnimators( control, animatorHint, candidates ); addControlAnimators( control, animatorHint, candidates );
} }
for ( auto child : item->childItems() ) const auto children = item->childItems();
for ( auto child : children )
addAnimators( child, animatorHint, candidates, skin ); addAnimators( child, animatorHint, candidates, skin );
} }
@ -448,7 +449,8 @@ void QskSkinTransition::process()
each object. each object.
*/ */
for ( const auto window : qGuiApp->topLevelWindows() ) const auto windows = qGuiApp->topLevelWindows();
for ( const auto window : windows )
{ {
if ( auto quickWindow = qobject_cast< const QQuickWindow* >( window ) ) if ( auto quickWindow = qobject_cast< const QQuickWindow* >( window ) )
{ {

View File

@ -126,17 +126,19 @@ QskWindow::~QskWindow()
{ {
// When being used from Qml the item destruction would run in the most // When being used from Qml the item destruction would run in the most
// unefficient way, leading to lots of QQuickItem::ItemChildRemovedChange // unefficient way, leading to lots of QQuickItem::ItemChildRemovedChange
// depending operations. We change this. // depending operations. So let's remove the toplevel children manually.
QList<QQuickItem *> children; QList<QQuickItem *> items;
for ( auto child : contentItem()->childItems() )
const auto children = contentItem()->childItems();
for ( auto child : children )
{ {
if ( child->parent() == contentItem() ) if ( child->parent() == contentItem() )
children += child; items += child;
} }
for ( auto child : children ) for ( auto item : qskAsConst( items ) )
delete child; delete item;
} }
void QskWindow::resizeF( const QSizeF& size ) void QskWindow::resizeF( const QSizeF& size )
@ -156,7 +158,12 @@ bool QskWindow::deleteOnClose() const
void QskWindow::setDeleteOnClose( bool on ) void QskWindow::setDeleteOnClose( bool on )
{ {
Q_D( QskWindow ); Q_D( QskWindow );
d->deleteOnClose = on;
if ( on != d->deleteOnClose )
{
d->deleteOnClose = on;
Q_EMIT deleteOnCloseChanged();
}
} }
void QskWindow::setAutoLayoutChildren( bool on ) void QskWindow::setAutoLayoutChildren( bool on )
@ -377,7 +384,8 @@ void QskWindow::layoutItems()
const QSizeF sz( contentItem()->width(), contentItem()->height() ); const QSizeF sz( contentItem()->width(), contentItem()->height() );
for ( auto child : contentItem()->childItems() ) const auto children = contentItem()->childItems();
for ( auto child : children )
{ {
if ( !QskControl::isTransparentForPositioner( child ) ) if ( !QskControl::isTransparentForPositioner( child ) )
{ {

View File

@ -16,7 +16,8 @@ class QSK_EXPORT QskWindow : public QQuickWindow
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY( bool deleteOnClose READ deleteOnClose WRITE setDeleteOnClose FINAL ) Q_PROPERTY( bool deleteOnClose READ deleteOnClose
WRITE setDeleteOnClose NOTIFY deleteOnCloseChanged FINAL )
Q_PROPERTY( bool autoLayoutChildren READ autoLayoutChildren Q_PROPERTY( bool autoLayoutChildren READ autoLayoutChildren
WRITE setAutoLayoutChildren NOTIFY autoLayoutChildrenChanged FINAL ) WRITE setAutoLayoutChildren NOTIFY autoLayoutChildrenChanged FINAL )
@ -72,6 +73,7 @@ Q_SIGNALS:
void localeChanged( const QLocale& ); void localeChanged( const QLocale& );
void framebufferModeChanged( FramebufferMode ); void framebufferModeChanged( FramebufferMode );
void autoLayoutChildrenChanged(); void autoLayoutChildrenChanged();
void deleteOnCloseChanged();
public Q_SLOTS: public Q_SLOTS:
void setLocale( const QLocale& ); void setLocale( const QLocale& );

View File

@ -92,7 +92,7 @@ void QskDialogButtonBox::setOrientation( Qt::Orientation orientation )
for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
{ {
for ( QskPushButton* button : m_data->buttonLists[i] ) for ( QskPushButton* button : qskAsConst( m_data->buttonLists[i] ) )
{ {
// avoid that buttons get deleted // avoid that buttons get deleted
// together with the layout // together with the layout
@ -307,7 +307,7 @@ void QskDialogButtonBox::clear()
{ {
for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
{ {
for ( QQuickItem* button : m_data->buttonLists[i] ) for ( const QQuickItem* button : qskAsConst( m_data->buttonLists[i] ) )
delete button; delete button;
} }
@ -319,7 +319,7 @@ void QskDialogButtonBox::setStandardButtons(
{ {
for ( int i = 0; i < QskDialog::NButtonRoles; i++ ) for ( int i = 0; i < QskDialog::NButtonRoles; i++ )
{ {
for ( QQuickItem* button : m_data->buttonLists[i] ) for ( const QQuickItem* button : qskAsConst( m_data->buttonLists[i] ) )
delete button; delete button;
} }

View File

@ -910,7 +910,8 @@ void QskGraphic::updateState( const QPaintEngineState& state )
} }
else if ( auto gradient = pen.brush().gradient() ) else if ( auto gradient = pen.brush().gradient() )
{ {
for ( const auto& stop : gradient->stops() ) const auto stops = gradient->stops();
for ( const auto& stop : stops )
qskInsertColor( stop.second, m_data->colorTable ); qskInsertColor( stop.second, m_data->colorTable );
} }
} }
@ -925,7 +926,8 @@ void QskGraphic::updateState( const QPaintEngineState& state )
} }
else if ( auto gradient = brush.gradient() ) else if ( auto gradient = brush.gradient() )
{ {
for ( const auto& stop : gradient->stops() ) const auto stops = gradient->stops();
for ( const auto& stop : stops )
qskInsertColor( stop.second, m_data->colorTable ); qskInsertColor( stop.second, m_data->colorTable );
} }
} }

View File

@ -6,8 +6,8 @@
#include "QskGridBox.h" #include "QskGridBox.h"
#include "QskLayoutItem.h" #include "QskLayoutItem.h"
#include "QskLayoutEngine.h" #include "QskLayoutEngine.h"
#include <QtGui/private/qabstractlayoutstyleinfo_p.h> #include <private/qabstractlayoutstyleinfo_p.h>
#include <QtGui/private/qgridlayoutengine_p.h> #include <private/qgridlayoutengine_p.h>
class QskGridBox::PrivateData class QskGridBox::PrivateData
{ {

View File

@ -6,7 +6,17 @@
#ifndef QSK_LAYOUT_ENGINE_H #ifndef QSK_LAYOUT_ENGINE_H
#define QSK_LAYOUT_ENGINE_H #define QSK_LAYOUT_ENGINE_H
#include <QtGui/private/qgridlayoutengine_p.h> #include "QskGlobal.h"
QSK_QT_PRIVATE_BEGIN
/*
QskLayoutEngine.h should be hidden into some cpp file
as it needs private headers. TODO
*/
#include <private/qgridlayoutengine_p.h>
QSK_QT_PRIVATE_END
class QskLayoutItem; class QskLayoutItem;
class QQuickItem; class QQuickItem;

View File

@ -8,7 +8,15 @@
#include "QskGlobal.h" #include "QskGlobal.h"
#include "QskSizePolicy.h" #include "QskSizePolicy.h"
#include <QtGui/private/qgridlayoutengine_p.h>
QSK_QT_PRIVATE_BEGIN
/*
QskLayoutItem.h should be hidden into some cpp file
as it needs private headers. TODO
*/
#include <private/qgridlayoutengine_p.h>
QSK_QT_PRIVATE_END
class QQuickItem; class QQuickItem;

View File

@ -10,11 +10,11 @@
#include "QskBoxBorderColors.h" #include "QskBoxBorderColors.h"
#include "QskGradient.h" #include "QskGradient.h"
#include <QSGVertexColorMaterial> #include <QSGVertexColorMaterial>
#include <QSGFlatColorMaterial> #include <QSGFlatColorMaterial>
#include <QGlobalStatic>
static QSGVertexColorMaterial qskMaterialVertex; Q_GLOBAL_STATIC( QSGVertexColorMaterial, qskMaterialVertex )
static inline uint qskMetricsHash( const QskBoxShapeMetrics& shape, static inline uint qskMetricsHash( const QskBoxShapeMetrics& shape,
const QskBoxBorderMetrics& borderMetrics ) const QskBoxBorderMetrics& borderMetrics )
@ -38,13 +38,13 @@ QskBoxNode::QskBoxNode():
m_colorsHash( 0 ), m_colorsHash( 0 ),
m_geometry( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 ) m_geometry( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 )
{ {
setMaterial( &qskMaterialVertex ); setMaterial( qskMaterialVertex );
setGeometry( &m_geometry ); setGeometry( &m_geometry );
} }
QskBoxNode::~QskBoxNode() QskBoxNode::~QskBoxNode()
{ {
if ( material() != &qskMaterialVertex ) if ( material() != qskMaterialVertex )
delete material(); delete material();
} }
@ -167,7 +167,7 @@ void QskBoxNode::setMonochrome( bool on )
{ {
const auto material = this->material(); const auto material = this->material();
if ( on == ( material != &qskMaterialVertex ) ) if ( on == ( material != qskMaterialVertex ) )
return; return;
m_geometry.allocate( 0 ); m_geometry.allocate( 0 );
@ -181,7 +181,7 @@ void QskBoxNode::setMonochrome( bool on )
} }
else else
{ {
setMaterial( &qskMaterialVertex ); setMaterial( qskMaterialVertex );
delete material; delete material;
const QSGGeometry g( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 ); const QSGGeometry g( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 );

View File

@ -116,7 +116,9 @@ static void qskRenderText(
for ( int i = 0; i < layout->lineCount(); ++i ) for ( int i = 0; i < layout->lineCount(); ++i )
{ {
auto line = layout->lineAt( i ); auto line = layout->lineAt( i );
for ( const auto& glyphRun : line.glyphRuns() )
const auto glyphRuns = line.glyphRuns();
for ( const auto& glyphRun : glyphRuns )
{ {
const bool doCreate = !glyphNode; const bool doCreate = !glyphNode;
if ( doCreate ) if ( doCreate )