Skip to content

Commit

Permalink
Add parentheses around complex operands.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Dec 30, 2024
1 parent 53a2247 commit 1d7b431
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/ExportData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ bool ExportData::rowShouldBeSkipped(const QAbstractItemView& view, int row)
(QAbstractItemView::MultiSelection == view.selectionMode())};
const QItemSelectionModel* selectionModel{view.selectionModel()};

return multiSelection && !selectionModel->isSelected(model->index(row, 0));
return multiSelection &&
(!selectionModel->isSelected(model->index(row, 0)));
}

QByteArray ExportData::getContentEnding() { return {}; }
Expand Down
4 changes: 2 additions & 2 deletions src/ExportXlsx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ QByteArray ExportXlsx::generateRowContent(const QAbstractItemModel& model,
rowContent.append(ROW_NUMBER_CLOSE);
rowContent.append(getCellTypeTag(cell));
rowContent.append(VALUE_START);
if (cell.typeId() == QMetaType::QDate ||
cell.typeId() == QMetaType::QDateTime)
if ((cell.typeId() == QMetaType::QDate) ||
(cell.typeId() == QMetaType::QDateTime))
rowContent.append(QByteArray::number(
-1 * cell.toDate().daysTo(utilities::getStartOfExcelWorld())));
else
Expand Down
40 changes: 21 additions & 19 deletions src/ImportOds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,22 @@ std::pair<bool, QStringList> ImportOds::retrieveColumnNames(
xmlStreamReader.setDevice(&zipFile);
skipToSheet(xmlStreamReader, sheetName);

while (!xmlStreamReader.atEnd() && xmlStreamReader.name() != TABLE_ROW_TAG)
while ((!xmlStreamReader.atEnd()) &&
(xmlStreamReader.name() != TABLE_ROW_TAG))
xmlStreamReader.readNext();
xmlStreamReader.readNext();

QXmlStreamReader::TokenType lastToken{xmlStreamReader.tokenType()};
QStringList columnNames;

while (!xmlStreamReader.atEnd() && xmlStreamReader.name() != TABLE_ROW_TAG)
while (!xmlStreamReader.atEnd() &&
(xmlStreamReader.name() != TABLE_ROW_TAG))
{
if (isCellStart(xmlStreamReader) &&
getColumnRepeatCount(xmlStreamReader.attributes()) > 1)
(getColumnRepeatCount(xmlStreamReader.attributes()) > 1))
break;

if (xmlStreamReader.name().toString() == P_TAG &&
if ((xmlStreamReader.name().toString() == P_TAG) &&
xmlStreamReader.isStartElement())
{
while (xmlStreamReader.tokenType() != QXmlStreamReader::Characters)
Expand All @@ -241,7 +243,7 @@ std::pair<bool, QStringList> ImportOds::retrieveColumnNames(
}

if (isCellEnd(xmlStreamReader) &&
lastToken == QXmlStreamReader::StartElement)
(lastToken == QXmlStreamReader::StartElement))
columnNames << emptyColName_;

lastToken = xmlStreamReader.tokenType();
Expand Down Expand Up @@ -355,12 +357,12 @@ bool ImportOds::isRecognizedColumnType(
const QString columnType{
attributes.value(OFFICE_VALUE_TYPE_TAG).toString()};

return 0 == columnType.compare(STRING_TAG) ||
0 == columnType.compare(DATE_TAG) ||
0 == columnType.compare(FLOAT_TAG) ||
0 == columnType.compare(PERCENTAGE_TAG) ||
0 == columnType.compare(CURRENCY_TAG) ||
0 == columnType.compare(TIME_TAG);
return (0 == columnType.compare(STRING_TAG)) ||
(0 == columnType.compare(DATE_TAG)) ||
(0 == columnType.compare(FLOAT_TAG)) ||
(0 == columnType.compare(PERCENTAGE_TAG)) ||
(0 == columnType.compare(CURRENCY_TAG)) ||
(0 == columnType.compare(TIME_TAG));
}

unsigned int ImportOds::getColumnRepeatCount(
Expand All @@ -372,25 +374,25 @@ unsigned int ImportOds::getColumnRepeatCount(

bool ImportOds::isRowStart(const QXmlStreamReader& xmlStreamReader) const
{
return 0 == xmlStreamReader.name().compare(TABLE_ROW_TAG) &&
return (0 == xmlStreamReader.name().compare(TABLE_ROW_TAG)) &&
xmlStreamReader.isStartElement();
}

bool ImportOds::isRowEnd(const QXmlStreamReader& xmlStreamReader) const
{
return 0 == xmlStreamReader.name().compare(TABLE_ROW_TAG) &&
return (0 == xmlStreamReader.name().compare(TABLE_ROW_TAG)) &&
xmlStreamReader.isEndElement();
}

bool ImportOds::isCellStart(const QXmlStreamReader& xmlStreamReader) const
{
return 0 == xmlStreamReader.name().compare(TABLE_CELL_TAG) &&
return (0 == xmlStreamReader.name().compare(TABLE_CELL_TAG)) &&
xmlStreamReader.isStartElement();
}

bool ImportOds::isCellEnd(const QXmlStreamReader& xmlStreamReader) const
{
return xmlStreamReader.name().toString() == TABLE_CELL_TAG &&
return (xmlStreamReader.name().toString() == TABLE_CELL_TAG) &&
xmlStreamReader.isEndElement();
}

Expand All @@ -413,10 +415,10 @@ ColumnType ImportOds::recognizeColumnType(ColumnType currentType,
return ColumnType::STRING;
}

if (0 == xmlColTypeValue.compare(FLOAT_TAG) ||
0 == xmlColTypeValue.compare(PERCENTAGE_TAG) ||
0 == xmlColTypeValue.compare(CURRENCY_TAG) ||
0 == xmlColTypeValue.compare(TIME_TAG))
if ((0 == xmlColTypeValue.compare(FLOAT_TAG)) ||
(0 == xmlColTypeValue.compare(PERCENTAGE_TAG)) ||
(0 == xmlColTypeValue.compare(CURRENCY_TAG)) ||
(0 == xmlColTypeValue.compare(TIME_TAG)))
{
if (currentType == ColumnType::UNKNOWN)
return ColumnType::NUMBER;
Expand Down

0 comments on commit 1d7b431

Please sign in to comment.