Code cleanup
This commit is contained in:
parent
4310ee3c34
commit
c3a4472587
|
@ -23,8 +23,7 @@ public:
|
|||
|
||||
QskRadioBox::QskRadioBox( QQuickItem* parent ) :
|
||||
Inherited( parent ),
|
||||
m_data( new PrivateData{} )
|
||||
{
|
||||
m_data( new PrivateData{} ) {
|
||||
setFocusPolicy( Qt::NoFocus );
|
||||
setAcceptedMouseButtons( Qt::LeftButton );
|
||||
|
||||
|
@ -41,16 +40,13 @@ QskRadioBox::QskRadioBox( QQuickItem* parent ) :
|
|||
}
|
||||
|
||||
QskRadioBox::QskRadioBox( const QStringList& list, QQuickItem* parent ) :
|
||||
QskRadioBox( parent )
|
||||
{
|
||||
QskRadioBox( parent ) {
|
||||
setItems( list );
|
||||
}
|
||||
|
||||
QskRadioBox::QskRadioBox( const QStringList& items,
|
||||
int selectedIndex,
|
||||
QQuickItem* parent ) :
|
||||
QskRadioBox( items, parent )
|
||||
{
|
||||
int selectedIndex, QQuickItem* parent ) :
|
||||
QskRadioBox( items, parent ) {
|
||||
if( selectedIndex >= 0 && selectedIndex < items.count() )
|
||||
{
|
||||
m_data->selectedIndex = selectedIndex;
|
||||
|
@ -59,7 +55,6 @@ QskRadioBox::QskRadioBox( const QStringList& items,
|
|||
|
||||
QRectF QskRadioBox::focusIndicatorRect() const {
|
||||
if( m_data->focusedIndex > -1) {
|
||||
|
||||
auto textRect = effectiveSkinlet()->sampleRect( this,
|
||||
contentsRect(), QskRadioBox::Text, m_data->focusedIndex );
|
||||
|
||||
|
@ -146,7 +141,8 @@ void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
|||
return;
|
||||
case Qt::Key_Down:
|
||||
case Qt::Key_Right:
|
||||
m_data->selectedIndex = qMin(m_data->selectedIndex + 1, items().size() - 1);
|
||||
m_data->selectedIndex = qMin( m_data->selectedIndex + 1,
|
||||
items().size() - 1 );
|
||||
setFocusedIndex( m_data->selectedIndex );
|
||||
event->setAccepted( true );
|
||||
update();
|
||||
|
@ -174,8 +170,7 @@ void QskRadioBox::keyPressEvent( QKeyEvent* event )
|
|||
const auto aspect = Ripple | QskAspect::Metric | QskAspect::Position;
|
||||
auto hint = animationHint(aspect | skinStates());
|
||||
if( hint.isValid()) {
|
||||
startTransition( aspect,
|
||||
hint,
|
||||
startTransition( aspect, hint,
|
||||
( float ) currentTabIndex, ( float ) nextTabIndex );
|
||||
}
|
||||
|
||||
|
@ -235,8 +230,9 @@ int QskRadioBox::indexAt( const QPointF& target ) const {
|
|||
auto itemHeight = contentsRect().height() / items().size();
|
||||
auto index = target.y() / itemHeight;
|
||||
|
||||
if( index < 0 || index >= items().size() )
|
||||
if( index < 0 || index >= items().size() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
|
|
@ -77,8 +77,7 @@ QSizeF QskRadioBoxSkinlet::sizeHint( const QskSkinnable* skinnable,
|
|||
|
||||
auto spacing = radio->spacingHint( Q::Panel );
|
||||
return QSizeF( maxTextWidth + qMax( buttonWidth, symbolWidth ),
|
||||
( lineHeight( radio ) + spacing ) * radio->items().size()
|
||||
- spacing );
|
||||
( lineHeight( radio ) + spacing ) * radio->items().size() - spacing );
|
||||
}
|
||||
|
||||
QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
||||
|
@ -103,7 +102,8 @@ QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable,
|
|||
case RippleRole:
|
||||
{
|
||||
QskSkinStateChanger changer( radio );
|
||||
changer.setStates( statesForIndex( radio, radio->positionHint( Q::Ripple ) ) );
|
||||
auto ripplePosition = radio->positionHint( Q::Ripple );
|
||||
changer.setStates( statesForIndex( radio, ripplePosition ) );
|
||||
|
||||
return updateBoxNode( radio, node, Q::Ripple );
|
||||
}
|
||||
|
@ -122,8 +122,7 @@ qreal QskRadioBoxSkinlet::lineHeight(const QskRadioBox* target) const {
|
|||
return qMax( strutHight, fontHeight );
|
||||
}
|
||||
|
||||
int QskRadioBoxSkinlet::sampleCount( const QskSkinnable* skinnable,
|
||||
QskAspect::Subcontrol ) const {
|
||||
int QskRadioBoxSkinlet::sampleCount( const QskSkinnable* skinnable, QskAspect::Subcontrol ) const {
|
||||
const auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||
return radio->items().count();
|
||||
}
|
||||
|
@ -140,8 +139,7 @@ QSizeF QskRadioBoxSkinlet::buttonSymbolSize( const QskRadioBox* radio ) const {
|
|||
qMax( buttonStrut.height(), symbolStrut.height() ) );
|
||||
}
|
||||
|
||||
QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio,
|
||||
const QRectF& rect ) const {
|
||||
QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio, const QRectF& rect ) const {
|
||||
auto ripplePosition = radio->positionHint( Q::Ripple );
|
||||
|
||||
if( ripplePosition < 0 ) {
|
||||
|
@ -157,8 +155,7 @@ QRectF QskRadioBoxSkinlet::rippleRect( const QskRadioBox* radio,
|
|||
}
|
||||
|
||||
QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radio,
|
||||
const QskAspect::Subcontrol target,
|
||||
const QRectF& rect, double index ) const {
|
||||
const QskAspect::Subcontrol target, const QRectF& rect, double index ) const {
|
||||
if( index < 0 ) {
|
||||
return QRectF();
|
||||
}
|
||||
|
@ -237,8 +234,8 @@ QRectF QskRadioBoxSkinlet::textRect( const QskRadioBox* radio,
|
|||
}
|
||||
|
||||
QRectF QskRadioBoxSkinlet::sampleRect( const QskSkinnable* skinnable,
|
||||
const QRectF& rect, QskAspect::Subcontrol subcontrol,
|
||||
int index ) const {
|
||||
const QRectF& rect, QskAspect::Subcontrol subcontrol, int index ) const {
|
||||
|
||||
const auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||
|
||||
if( subcontrol == Q::Text ) {
|
||||
|
@ -250,6 +247,7 @@ QRectF QskRadioBoxSkinlet::sampleRect( const QskSkinnable* skinnable,
|
|||
|
||||
QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnable,
|
||||
QskAspect::Subcontrol subControl, int index ) const {
|
||||
|
||||
auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||
auto states = Inherited::sampleStates( skinnable, subControl, index );
|
||||
|
||||
|
@ -258,23 +256,17 @@ QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnabl
|
|||
|
||||
QSGNode* QskRadioBoxSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
||||
QskAspect::Subcontrol subcontrol, int index, QSGNode* node ) const {
|
||||
|
||||
auto radio = static_cast< const QskRadioBox* >( skinnable );
|
||||
|
||||
auto rect = sampleRect( skinnable, radio->contentsRect(),
|
||||
subcontrol, index );
|
||||
|
||||
if( subcontrol == Q::Text ) {
|
||||
return QskSkinlet::updateTextNode( radio,
|
||||
node,
|
||||
rect,
|
||||
Qt::AlignLeft,
|
||||
radio->items()[index],
|
||||
subcontrol);
|
||||
return QskSkinlet::updateTextNode( radio, node, rect, Qt::AlignLeft,
|
||||
radio->items()[ index ], subcontrol );
|
||||
} else if ( subcontrol == Q::Button ) {
|
||||
return QskSkinlet::updateBoxNode( radio,
|
||||
node,
|
||||
rect,
|
||||
subcontrol );
|
||||
return QskSkinlet::updateBoxNode( radio, node, rect, subcontrol );
|
||||
} else if( subcontrol == Q::Symbol ) {
|
||||
auto symbol = QskStandardSymbol::NoSymbol;
|
||||
auto color = radio->color( subcontrol ).rgb();
|
||||
|
|
|
@ -39,7 +39,8 @@ class QSK_EXPORT QskRadioBoxSkinlet : public QskSkinlet
|
|||
|
||||
QSizeF buttonSymbolSize( const QskRadioBox* radio ) const;
|
||||
QRectF textRect( const QskRadioBox*, const QRectF&, int ) const;
|
||||
QRectF buttonRect( const QskRadioBox*, const QskAspect::Subcontrol target, const QRectF&, double ) const;
|
||||
QRectF buttonRect( const QskRadioBox*, const QskAspect::Subcontrol target, const QRectF&,
|
||||
double ) const;
|
||||
QRectF rippleRect( const QskRadioBox*, const QRectF& ) const;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue