avoid warnings about narrowing size_t to int
This commit is contained in:
parent
3f818470e8
commit
8680423c33
@ -195,6 +195,13 @@ namespace
|
||||
QRect m_grid;
|
||||
bool m_isSpacer;
|
||||
};
|
||||
|
||||
class ElementsVector : public std::vector< Element >
|
||||
{
|
||||
public:
|
||||
// to avoid warnings when assigning size_t to int
|
||||
inline int count() const { return static_cast< int >( size() ); }
|
||||
};
|
||||
}
|
||||
|
||||
Element::Element( QQuickItem* item, const QRect& grid )
|
||||
@ -304,8 +311,7 @@ class QskGridLayoutEngine::PrivateData
|
||||
public:
|
||||
inline Element* elementAt( int index ) const
|
||||
{
|
||||
const int count = this->elements.size();
|
||||
if ( index < 0 || index >= count )
|
||||
if ( index < 0 || index >= this->elements.count() )
|
||||
return nullptr;
|
||||
|
||||
return const_cast< Element* >( &this->elements[index] );
|
||||
@ -340,7 +346,7 @@ class QskGridLayoutEngine::PrivateData
|
||||
rowCount = qMax( rowCount, grid.bottom() + 1 );
|
||||
columnCount = qMax( columnCount, grid.right() + 1 );
|
||||
|
||||
return this->elements.size() - 1;
|
||||
return this->elements.count() - 1;
|
||||
}
|
||||
|
||||
QRect effectiveGrid( const Element& element ) const
|
||||
@ -363,7 +369,7 @@ class QskGridLayoutEngine::PrivateData
|
||||
? that->columnSettings : that->rowSettings;
|
||||
}
|
||||
|
||||
std::vector< Element > elements;
|
||||
ElementsVector elements;
|
||||
|
||||
Settings rowSettings;
|
||||
Settings columnSettings;
|
||||
@ -383,7 +389,7 @@ QskGridLayoutEngine::~QskGridLayoutEngine()
|
||||
|
||||
int QskGridLayoutEngine::count() const
|
||||
{
|
||||
return m_data->elements.size();
|
||||
return m_data->elements.count();
|
||||
}
|
||||
|
||||
bool QskGridLayoutEngine::setStretchFactor(
|
||||
@ -626,7 +632,7 @@ void QskGridLayoutEngine::setupChain( Qt::Orientation orientation,
|
||||
before adding those that occupy more than one cell
|
||||
*/
|
||||
QVarLengthArray< const Element* > postponed;
|
||||
postponed.reserve( m_data->elements.size() );
|
||||
postponed.reserve( m_data->elements.count() );
|
||||
|
||||
for ( const auto& element : m_data->elements )
|
||||
{
|
||||
|
@ -50,6 +50,13 @@ namespace
|
||||
int m_stretch = -1;
|
||||
bool m_isSpacer;
|
||||
};
|
||||
|
||||
class ElementsVector : public std::vector< Element >
|
||||
{
|
||||
public:
|
||||
// to avoid warnings when assigning size_t to int
|
||||
inline int count() const { return static_cast< int >( size() ); }
|
||||
};
|
||||
}
|
||||
|
||||
Element::Element( QQuickItem* item )
|
||||
@ -164,14 +171,13 @@ class QskLinearLayoutEngine::PrivateData
|
||||
|
||||
inline Element* elementAt( int index ) const
|
||||
{
|
||||
const int count = this->elements.size();
|
||||
if ( ( index < 0 ) || ( index >= count ) )
|
||||
if ( ( index < 0 ) || ( index >= this->elements.count() ) )
|
||||
return nullptr;
|
||||
|
||||
return const_cast< Element* >( &this->elements[index] );
|
||||
}
|
||||
|
||||
std::vector< Element > elements;
|
||||
ElementsVector elements;
|
||||
|
||||
uint dimension;
|
||||
|
||||
@ -230,7 +236,7 @@ uint QskLinearLayoutEngine::dimension() const
|
||||
|
||||
int QskLinearLayoutEngine::count() const
|
||||
{
|
||||
return m_data->elements.size();
|
||||
return m_data->elements.count();
|
||||
}
|
||||
|
||||
bool QskLinearLayoutEngine::setStretchFactorAt( int index, int stretchFactor )
|
||||
@ -266,7 +272,7 @@ int QskLinearLayoutEngine::insertItem( QQuickItem* item, int index )
|
||||
|
||||
if ( index < 0 || index > count() )
|
||||
{
|
||||
index = elements.size();
|
||||
index = elements.count();
|
||||
elements.emplace_back( item );
|
||||
}
|
||||
else
|
||||
@ -286,7 +292,7 @@ int QskLinearLayoutEngine::insertSpacerAt( int index, qreal spacing )
|
||||
|
||||
if ( index < 0 || index > count() )
|
||||
{
|
||||
index = elements.size();
|
||||
index = elements.count();
|
||||
elements.emplace_back( spacing );
|
||||
}
|
||||
else
|
||||
@ -416,7 +422,7 @@ int QskLinearLayoutEngine::effectiveCount() const
|
||||
}
|
||||
}
|
||||
|
||||
return m_data->elements.size() - m_data->sumIgnored;
|
||||
return m_data->elements.count() - m_data->sumIgnored;
|
||||
}
|
||||
|
||||
void QskLinearLayoutEngine::invalidateElementCache()
|
||||
|
Loading…
x
Reference in New Issue
Block a user