From 08f4bfd0d047b621c184935451a9b4a64284f22a Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Fri, 22 Jan 2021 09:12:53 -0500 Subject: [PATCH] Set max. column count to 90 --- .clang-format | 2 +- src/CsvPlayer.cpp | 27 +++++++++++---------------- src/DataProvider.cpp | 3 +-- src/Export.cpp | 6 ++---- src/GraphProvider.cpp | 6 ++---- src/JsonGenerator.cpp | 15 +++++++-------- src/SerialManager.cpp | 16 ++++++---------- src/main.cpp | 3 +-- 8 files changed, 31 insertions(+), 47 deletions(-) diff --git a/.clang-format b/.clang-format index 8ec505c1..45c826c3 100644 --- a/.clang-format +++ b/.clang-format @@ -88,7 +88,7 @@ IndentWidth: 4 #StatementMacros ['Q_OBJECT', 'Q_UNUSED'] -ColumnLimit: 80 +ColumnLimit: 90 diff --git a/src/CsvPlayer.cpp b/src/CsvPlayer.cpp index ab87a5ae..0baa336b 100644 --- a/src/CsvPlayer.cpp +++ b/src/CsvPlayer.cpp @@ -189,9 +189,8 @@ void CsvPlayer::toggle() void CsvPlayer::openFile() { // Get file name - auto file = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Select CSV file"), - QDir::homePath(), - tr("CSV files") + " (*.csv)"); + auto file = QFileDialog::getOpenFileName( + Q_NULLPTR, tr("Select CSV file"), QDir::homePath(), tr("CSV files") + " (*.csv)"); // Open CSV file if (!file.isEmpty()) @@ -272,11 +271,10 @@ void CsvPlayer::openFile(const QString &filePath) if (sm->connected()) { LOG_INFO() << "Serial device open, asking user what to do..."; - auto response - = NiceMessageBox(tr("Serial port open, do you want to continue?"), - tr("In order to use this feature, its necessary " - "to disconnect from the serial port"), - qAppName(), QMessageBox::No | QMessageBox::Yes); + auto response = NiceMessageBox(tr("Serial port open, do you want to continue?"), + tr("In order to use this feature, its necessary " + "to disconnect from the serial port"), + qAppName(), QMessageBox::No | QMessageBox::Yes); if (response == QMessageBox::Yes) sm->disconnectDevice(); else @@ -314,10 +312,9 @@ void CsvPlayer::openFile(const QString &filePath) // Show error to the user else { - NiceMessageBox( - tr("There is an error with the data in the CSV file"), - tr("Please verify that the CSV file was created with Serial " - "Studio")); + NiceMessageBox(tr("There is an error with the data in the CSV file"), + tr("Please verify that the CSV file was created with Serial " + "Studio")); } } @@ -583,8 +580,7 @@ QJsonDocument CsvPlayer::getJsonFrame(const int row) auto dataset = datasets.at(j).toObject(); if (dataset.value("t") == datasetKey) { - auto value = values.at( - getDatasetIndex(groupKey, datasetKey)); + auto value = values.at(getDatasetIndex(groupKey, datasetKey)); dataset.remove("v"); dataset.insert("v", value); } @@ -638,8 +634,7 @@ QString CsvPlayer::getCellValue(int row, int column, bool *error) * Returns the column/index for the dataset key that belongs to the given * group key. */ -int CsvPlayer::getDatasetIndex(const QString &groupKey, - const QString &datasetKey) +int CsvPlayer::getDatasetIndex(const QString &groupKey, const QString &datasetKey) { if (m_datasetIndexes.contains(groupKey)) { diff --git a/src/DataProvider.cpp b/src/DataProvider.cpp index 7b9a9258..dd473905 100644 --- a/src/DataProvider.cpp +++ b/src/DataProvider.cpp @@ -159,8 +159,7 @@ void DataProvider::update() void DataProvider::resetData() { // Stop if dev. man is not disconnected or if CSV file is open - if (SerialManager::getInstance()->connected() - || CsvPlayer::getInstance()->isOpen()) + if (SerialManager::getInstance()->connected() || CsvPlayer::getInstance()->isOpen()) return; // Delete existing groups diff --git a/src/Export.cpp b/src/Export.cpp index f99bd14b..3136a79d 100644 --- a/src/Export.cpp +++ b/src/Export.cpp @@ -142,8 +142,7 @@ void Export::openCurrentCsv() RevealFile(m_csvFile.fileName()); else QMessageBox::critical(Q_NULLPTR, tr("CSV file not open"), - tr("Cannot find CSV export file!"), - QMessageBox::Ok); + tr("Cannot find CSV export file!"), QMessageBox::Ok); } /** @@ -228,8 +227,7 @@ void Export::writeValues() // Construct dataset title from group, dataset title & units QString title; if (datasetUnits.isEmpty()) - title - = QString("(%1) %2").arg(groupTitle).arg(datasetTitle); + title = QString("(%1) %2").arg(groupTitle).arg(datasetTitle); else title = QString("(%1) %2 [%3]") .arg(groupTitle) diff --git a/src/GraphProvider.cpp b/src/GraphProvider.cpp index 7b6fd164..c96eba41 100644 --- a/src/GraphProvider.cpp +++ b/src/GraphProvider.cpp @@ -57,8 +57,7 @@ GraphProvider::GraphProvider() qRegisterMetaType(); // Update graph values as soon as QML Bridge interprets data - connect(DataProvider::getInstance(), SIGNAL(updated()), this, - SLOT(updateValues())); + connect(DataProvider::getInstance(), SIGNAL(updated()), this, SLOT(updateValues())); // Avoid issues when CSV player goes backwards connect(CsvPlayer::getInstance(), SIGNAL(timestampChanged()), this, @@ -219,8 +218,7 @@ void GraphProvider::updateValues() // Remove older items if (m_points.at(i)->count() >= displayedPoints()) - m_points.at(i)->remove(0, - m_points.at(i)->count() - displayedPoints()); + m_points.at(i)->remove(0, m_points.at(i)->count() - displayedPoints()); // Add values m_points.at(i)->append(getValue(i)); diff --git a/src/JsonGenerator.cpp b/src/JsonGenerator.cpp index 27800753..bd6ed768 100644 --- a/src/JsonGenerator.cpp +++ b/src/JsonGenerator.cpp @@ -75,8 +75,7 @@ JsonGenerator::JsonGenerator() m_dataFormatErrors = 0; auto sm = SerialManager::getInstance(); connect(sm, SIGNAL(portChanged()), this, SLOT(reset())); - connect(sm, SIGNAL(packetReceived(QByteArray)), this, - SLOT(readData(QByteArray))); + connect(sm, SIGNAL(packetReceived(QByteArray)), this, SLOT(readData(QByteArray))); LOG_INFO() << "Initialized JsonParser module"; } @@ -149,9 +148,9 @@ JsonGenerator::OperationMode JsonGenerator::operationMode() const */ void JsonGenerator::loadJsonMap() { - auto file = QFileDialog::getOpenFileName( - Q_NULLPTR, tr("Select JSON map file"), QDir::homePath(), - tr("JSON files") + " (*.json)"); + auto file + = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Select JSON map file"), + QDir::homePath(), tr("JSON files") + " (*.json)"); if (!file.isEmpty()) loadJsonMap(file); @@ -201,9 +200,9 @@ void JsonGenerator::loadJsonMap(const QString &path, const bool silent) writeSettings(path); m_jsonMapData = QString::fromUtf8(data); if (!silent) - NiceMessageBox(tr("JSON map file loaded successfully!"), - tr("File \"%1\" loaded into memory") - .arg(jsonMapFilename())); + NiceMessageBox( + tr("JSON map file loaded successfully!"), + tr("File \"%1\" loaded into memory").arg(jsonMapFilename())); } } diff --git a/src/SerialManager.cpp b/src/SerialManager.cpp index 9f2cd601..7960be6d 100644 --- a/src/SerialManager.cpp +++ b/src/SerialManager.cpp @@ -35,10 +35,9 @@ static SerialManager *INSTANCE = nullptr; * QStringList of all known control characters */ static const QStringList CONTROL_STR - = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", - " BS", " HT", " LF", " VT", " FF", " CR", " SO", " SI", - "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", - "CAN", " EM", "SUB", "ESC", " FS", " GS", " RS", " US" }; + = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", " BS", " HT", " LF", + " VT", " FF", " CR", " SO", " SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", + "SYN", "ETB", "CAN", " EM", "SUB", "ESC", " FS", " GS", " RS", " US" }; /** * Returns a string that displays unknown characters in hexadecimal format @@ -481,8 +480,7 @@ void SerialManager::disconnectDevice() // Disconnect signals/slots port()->disconnect(this, SLOT(onDataReceived())); port()->disconnect(this, SLOT(disconnectDevice())); - port()->disconnect(this, - SLOT(handleError(QSerialPort::SerialPortError))); + port()->disconnect(this, SLOT(handleError(QSerialPort::SerialPortError))); // Close & delete serial port handler port()->close(); @@ -535,8 +533,7 @@ void SerialManager::sendData(const QString &data) // Bytes not equal to data length if (bytes != bin.length()) - LOG_WARNING() - << "Written data length not equal to request data length"; + LOG_WARNING() << "Written data length not equal to request data length"; // Emit signals else @@ -615,8 +612,7 @@ void SerialManager::setPort(const quint8 portIndex) if (port()->open(mode)) { emit connectedChanged(); - LOG_INFO() << Q_FUNC_INFO - << "Serial port opened successfully in RW mode"; + LOG_INFO() << Q_FUNC_INFO << "Serial port opened successfully in RW mode"; } // Close serial port on error diff --git a/src/main.cpp b/src/main.cpp index e724196e..89fe2a4e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,8 +80,7 @@ int main(int argc, char **argv) // Begin logging LOG_INFO() << QDateTime::currentDateTime(); LOG_INFO() << APP_NAME << APP_VERSION; - LOG_INFO() << "Running on" - << QSysInfo::prettyProductName().toStdString().c_str(); + LOG_INFO() << "Running on" << QSysInfo::prettyProductName().toStdString().c_str(); // Change application palette QPalette palette;