Skip to content

Commit

Permalink
m: Cppcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
ElTh0r0 committed Nov 7, 2024
1 parent 1cd8c98 commit 581da72
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
12 changes: 6 additions & 6 deletions block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void Block::moveBlock(const bool bRelease) {

void Block::rotateBlock(const int nDelta) {
static const quint8 RIGHTANGLE = 90;
if (m_bActive || !this->isAnyBlockActive()) {
if (m_bActive || !this->isAnyBlockActive(m_pListBlocks)) {
qint8 nAngle(0);
qreal nTranslateX(0);
qreal nTranslateY(0);
Expand All @@ -260,7 +260,7 @@ void Block::rotateBlock(const int nDelta) {
// qDebug() << "After rot.:" << m_PolyShape;
}

if (!this->isAnyBlockActive()) {
if (!this->isAnyBlockActive(m_pListBlocks)) {
this->checkBlockIntersection();
}
}
Expand All @@ -269,7 +269,7 @@ void Block::rotateBlock(const int nDelta) {
// ---------------------------------------------------------------------------

void Block::flipBlock() {
if (m_bActive || !this->isAnyBlockActive()) {
if (m_bActive || !this->isAnyBlockActive(m_pListBlocks)) {
this->prepareGeometryChange();
// qDebug() << "Before flip" << m_nID << "-" << m_PolyShape;
QTransform transform = QTransform::fromScale(-1, 1);
Expand All @@ -278,7 +278,7 @@ void Block::flipBlock() {
// qDebug() << "After flip:" << m_PolyShape;
}

if (!this->isAnyBlockActive()) {
if (!this->isAnyBlockActive(m_pListBlocks)) {
this->checkBlockIntersection();
}
}
Expand Down Expand Up @@ -390,8 +390,8 @@ void Block::rescaleBlock(const quint16 nNewScale) {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------

auto Block::isAnyBlockActive() -> bool {
for (auto &pBlock : *m_pListBlocks) {
auto Block::isAnyBlockActive(const QList<Block *> *listBlocks) -> bool {
for (const auto pBlock : *listBlocks) {
if (pBlock->isActive()) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion block.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Block : public QGraphicsObject {
void checkBlockIntersection();
auto snapToGrid(const QPointF point) const -> QPointF;
void resetBrushStyle() const;
auto isAnyBlockActive() -> bool;
auto isAnyBlockActive(const QList<Block *> *listBlocks) -> bool;

void moveBlock(const bool bRelease = false);
void rotateBlock(const int nDelta = -1);
Expand Down
7 changes: 3 additions & 4 deletions board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ auto Board::setupBlocks() -> bool {

auto Board::createBlocks() -> bool {
const quint8 nMaxNumOfBlocks(250);
QSettings *tmpSet = m_pBoardConf;
const QSettings *tmpSet = m_pBoardConf;
if (m_bSavedGame) {
tmpSet = m_pSavedConf;
}
Expand Down Expand Up @@ -321,7 +321,6 @@ auto Board::readColor(const QString &sKey,

auto Board::readPolygon(const QSettings *tmpSet, const QString &sKey,
const bool bScale) -> QPolygonF {
QStringList sList;
QStringList sListPoint;
QString sValue(tmpSet->value(sKey, "").toString());
quint16 nScale(1);
Expand All @@ -330,10 +329,10 @@ auto Board::readPolygon(const QSettings *tmpSet, const QString &sKey,
}

Board::checkOrthogonality(QPointF(-99999, -99999));
sList << sValue.split('|');
const QStringList sList(sValue.split('|'));
QPolygonF polygon;
polygon.reserve(sList.size());
for (auto &s : sList) {
for (const auto &s : sList) {
sListPoint.clear();
sListPoint << s.split(',');
if (2 == sListPoint.size()) {
Expand Down
3 changes: 1 addition & 2 deletions boardselection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ BoardSelection::BoardSelection(QWidget *pParent, const QString &sBoardsDir,
int nRow = 0;
quint16 nSolved = 0;
quint16 nSum = 0;
bool bSolved;
for (const auto &board : boardfiles) {
QString sFile(sSubfolder + "/" + board);
bSolved = !m_sListAllUnsolved.contains(sFile);
bool bSolved = !m_sListAllUnsolved.contains(sFile);
m_pListBoards << new BoardPreview(m_sBoardsDir + "/" + sFile, bSolved,
m_previewsize);
m_pListTabLayouts.last()->addWidget(m_pListBoards.last(), nRow, nCol);
Expand Down

0 comments on commit 581da72

Please sign in to comment.