Skip to content

Commit 91e7ac6

Browse files
committedMar 24, 2023
Fix clang-tidy warnings
1 parent d2b226c commit 91e7ac6

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed
 

‎src/app/devtools/querylogger/qgsappquerylogger.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void QgsAppQueryLogger::queryFinished( const QgsDatabaseQueryLogEntry &query )
7474
queryGroup->setSql( query.query );
7575
}
7676

77-
const long long newMaxCost = std::max< long long >( query.finishedTime - query.startedTime, mMaxCost );
77+
const long long newMaxCost = std::max< long long >( static_cast< long long >( query.finishedTime - query.startedTime ), mMaxCost );
7878

7979
// Calculate the number of children: if error or not fetched rows 1 row is added else 2 rows are added
8080
beginInsertRows( requestIndex, queryGroup->childCount(), queryGroup->childCount() + ( query.fetchedRows != -1 ? 1 : 0 ) );
@@ -217,8 +217,6 @@ QVariant QgsAppQueryLogger::data( const QModelIndex &index, int role ) const
217217
switch ( role )
218218
{
219219
case Qt::DisplayRole:
220-
return node->data( QgsDevToolsModelNode::RoleElapsedTime );
221-
222220
case QgsDevToolsModelNode::RoleElapsedTime:
223221
return node->data( QgsDevToolsModelNode::RoleElapsedTime );
224222

@@ -307,29 +305,29 @@ bool QgsDatabaseQueryLoggerProxyModel::filterAcceptsRow( int source_row, const Q
307305
// QueryCostDelegate
308306
//
309307

310-
QueryCostDelegate::QueryCostDelegate( quint32 sortRole, quint32 totalCostRole, QObject *parent )
308+
QueryCostDelegate::QueryCostDelegate( int sortRole, int totalCostRole, QObject *parent )
311309
: QStyledItemDelegate( parent )
312-
, m_sortRole( sortRole )
313-
, m_totalCostRole( totalCostRole )
310+
, mSortRole( sortRole )
311+
, mTotalCostRole( totalCostRole )
314312
{
315313
}
316314

317315
QueryCostDelegate::~QueryCostDelegate() = default;
318316

319317
void QueryCostDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
320318
{
321-
const auto cost = index.data( m_sortRole ).toDouble();
319+
const auto cost = index.data( mSortRole ).toDouble();
322320
if ( cost <= 0 )
323321
{
324322
QStyledItemDelegate::paint( painter, option, index );
325323
return;
326324
}
327325

328-
const auto totalCost = index.data( m_totalCostRole ).toDouble();
326+
const auto totalCost = index.data( mTotalCostRole ).toDouble();
329327
const auto fraction = std::abs( float( cost ) / totalCost );
330328

331329
auto rect = option.rect;
332-
rect.setWidth( rect.width() * fraction );
330+
rect.setWidth( static_cast< int >( rect.width() * fraction ) );
333331

334332
const auto &brush = painter->brush();
335333
const auto &pen = painter->pen();
@@ -344,7 +342,7 @@ void QueryCostDelegate::paint( QPainter *painter, const QStyleOptionViewItem &op
344342
painter->drawRect( option.rect );
345343
}
346344

347-
const auto color = QColor::fromHsv( 120 - fraction * 120, 255, 255, ( -( ( fraction - 1 ) * ( fraction - 1 ) ) ) * 120 + 120 );
345+
const auto color = QColor::fromHsv( static_cast< int >( 120 - fraction * 120 ), 255, 255, static_cast< int >( ( -( ( fraction - 1 ) * ( fraction - 1 ) ) ) * 120 + 120 ) );
348346
painter->setBrush( color );
349347
painter->drawRect( rect );
350348

‎src/app/devtools/querylogger/qgsappquerylogger.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,14 @@ class QueryCostDelegate : public QStyledItemDelegate
141141
{
142142
Q_OBJECT
143143
public:
144-
explicit QueryCostDelegate( quint32 sortRole, quint32 totalCostRole, QObject *parent = nullptr );
144+
explicit QueryCostDelegate( int sortRole, int totalCostRole, QObject *parent = nullptr );
145145
~QueryCostDelegate();
146146

147147
void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
148148

149149
private:
150-
quint32 m_sortRole;
151-
quint32 m_totalCostRole;
150+
int mSortRole = 0;
151+
int mTotalCostRole = 0;
152152
};
153153

154154
#endif // QGSAPPQUERYLOGGER_H

0 commit comments

Comments
 (0)
Please sign in to comment.