Set max. column count to 90

This commit is contained in:
Alex Spataru 2021-01-22 09:12:53 -05:00
parent d84d8a4a86
commit 08f4bfd0d0
8 changed files with 31 additions and 47 deletions

View File

@ -88,7 +88,7 @@ IndentWidth: 4
#StatementMacros ['Q_OBJECT', 'Q_UNUSED'] #StatementMacros ['Q_OBJECT', 'Q_UNUSED']
ColumnLimit: 80 ColumnLimit: 90

View File

@ -189,9 +189,8 @@ void CsvPlayer::toggle()
void CsvPlayer::openFile() void CsvPlayer::openFile()
{ {
// Get file name // Get file name
auto file = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Select CSV file"), auto file = QFileDialog::getOpenFileName(
QDir::homePath(), Q_NULLPTR, tr("Select CSV file"), QDir::homePath(), tr("CSV files") + " (*.csv)");
tr("CSV files") + " (*.csv)");
// Open CSV file // Open CSV file
if (!file.isEmpty()) if (!file.isEmpty())
@ -272,11 +271,10 @@ void CsvPlayer::openFile(const QString &filePath)
if (sm->connected()) if (sm->connected())
{ {
LOG_INFO() << "Serial device open, asking user what to do..."; LOG_INFO() << "Serial device open, asking user what to do...";
auto response auto response = NiceMessageBox(tr("Serial port open, do you want to continue?"),
= NiceMessageBox(tr("Serial port open, do you want to continue?"), tr("In order to use this feature, its necessary "
tr("In order to use this feature, its necessary " "to disconnect from the serial port"),
"to disconnect from the serial port"), qAppName(), QMessageBox::No | QMessageBox::Yes);
qAppName(), QMessageBox::No | QMessageBox::Yes);
if (response == QMessageBox::Yes) if (response == QMessageBox::Yes)
sm->disconnectDevice(); sm->disconnectDevice();
else else
@ -314,10 +312,9 @@ void CsvPlayer::openFile(const QString &filePath)
// Show error to the user // Show error to the user
else else
{ {
NiceMessageBox( NiceMessageBox(tr("There is an error with the data in the CSV file"),
tr("There is an error with the data in the CSV file"), tr("Please verify that the CSV file was created with Serial "
tr("Please verify that the CSV file was created with Serial " "Studio"));
"Studio"));
} }
} }
@ -583,8 +580,7 @@ QJsonDocument CsvPlayer::getJsonFrame(const int row)
auto dataset = datasets.at(j).toObject(); auto dataset = datasets.at(j).toObject();
if (dataset.value("t") == datasetKey) if (dataset.value("t") == datasetKey)
{ {
auto value = values.at( auto value = values.at(getDatasetIndex(groupKey, datasetKey));
getDatasetIndex(groupKey, datasetKey));
dataset.remove("v"); dataset.remove("v");
dataset.insert("v", value); 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 * Returns the column/index for the dataset key that belongs to the given
* group key. * group key.
*/ */
int CsvPlayer::getDatasetIndex(const QString &groupKey, int CsvPlayer::getDatasetIndex(const QString &groupKey, const QString &datasetKey)
const QString &datasetKey)
{ {
if (m_datasetIndexes.contains(groupKey)) if (m_datasetIndexes.contains(groupKey))
{ {

View File

@ -159,8 +159,7 @@ void DataProvider::update()
void DataProvider::resetData() void DataProvider::resetData()
{ {
// Stop if dev. man is not disconnected or if CSV file is open // Stop if dev. man is not disconnected or if CSV file is open
if (SerialManager::getInstance()->connected() if (SerialManager::getInstance()->connected() || CsvPlayer::getInstance()->isOpen())
|| CsvPlayer::getInstance()->isOpen())
return; return;
// Delete existing groups // Delete existing groups

View File

@ -142,8 +142,7 @@ void Export::openCurrentCsv()
RevealFile(m_csvFile.fileName()); RevealFile(m_csvFile.fileName());
else else
QMessageBox::critical(Q_NULLPTR, tr("CSV file not open"), QMessageBox::critical(Q_NULLPTR, tr("CSV file not open"),
tr("Cannot find CSV export file!"), tr("Cannot find CSV export file!"), QMessageBox::Ok);
QMessageBox::Ok);
} }
/** /**
@ -228,8 +227,7 @@ void Export::writeValues()
// Construct dataset title from group, dataset title & units // Construct dataset title from group, dataset title & units
QString title; QString title;
if (datasetUnits.isEmpty()) if (datasetUnits.isEmpty())
title title = QString("(%1) %2").arg(groupTitle).arg(datasetTitle);
= QString("(%1) %2").arg(groupTitle).arg(datasetTitle);
else else
title = QString("(%1) %2 [%3]") title = QString("(%1) %2 [%3]")
.arg(groupTitle) .arg(groupTitle)

View File

@ -57,8 +57,7 @@ GraphProvider::GraphProvider()
qRegisterMetaType<QAbstractAxis *>(); qRegisterMetaType<QAbstractAxis *>();
// Update graph values as soon as QML Bridge interprets data // Update graph values as soon as QML Bridge interprets data
connect(DataProvider::getInstance(), SIGNAL(updated()), this, connect(DataProvider::getInstance(), SIGNAL(updated()), this, SLOT(updateValues()));
SLOT(updateValues()));
// Avoid issues when CSV player goes backwards // Avoid issues when CSV player goes backwards
connect(CsvPlayer::getInstance(), SIGNAL(timestampChanged()), this, connect(CsvPlayer::getInstance(), SIGNAL(timestampChanged()), this,
@ -219,8 +218,7 @@ void GraphProvider::updateValues()
// Remove older items // Remove older items
if (m_points.at(i)->count() >= displayedPoints()) if (m_points.at(i)->count() >= displayedPoints())
m_points.at(i)->remove(0, m_points.at(i)->remove(0, m_points.at(i)->count() - displayedPoints());
m_points.at(i)->count() - displayedPoints());
// Add values // Add values
m_points.at(i)->append(getValue(i)); m_points.at(i)->append(getValue(i));

View File

@ -75,8 +75,7 @@ JsonGenerator::JsonGenerator()
m_dataFormatErrors = 0; m_dataFormatErrors = 0;
auto sm = SerialManager::getInstance(); auto sm = SerialManager::getInstance();
connect(sm, SIGNAL(portChanged()), this, SLOT(reset())); connect(sm, SIGNAL(portChanged()), this, SLOT(reset()));
connect(sm, SIGNAL(packetReceived(QByteArray)), this, connect(sm, SIGNAL(packetReceived(QByteArray)), this, SLOT(readData(QByteArray)));
SLOT(readData(QByteArray)));
LOG_INFO() << "Initialized JsonParser module"; LOG_INFO() << "Initialized JsonParser module";
} }
@ -149,9 +148,9 @@ JsonGenerator::OperationMode JsonGenerator::operationMode() const
*/ */
void JsonGenerator::loadJsonMap() void JsonGenerator::loadJsonMap()
{ {
auto file = QFileDialog::getOpenFileName( auto file
Q_NULLPTR, tr("Select JSON map file"), QDir::homePath(), = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Select JSON map file"),
tr("JSON files") + " (*.json)"); QDir::homePath(), tr("JSON files") + " (*.json)");
if (!file.isEmpty()) if (!file.isEmpty())
loadJsonMap(file); loadJsonMap(file);
@ -201,9 +200,9 @@ void JsonGenerator::loadJsonMap(const QString &path, const bool silent)
writeSettings(path); writeSettings(path);
m_jsonMapData = QString::fromUtf8(data); m_jsonMapData = QString::fromUtf8(data);
if (!silent) if (!silent)
NiceMessageBox(tr("JSON map file loaded successfully!"), NiceMessageBox(
tr("File \"%1\" loaded into memory") tr("JSON map file loaded successfully!"),
.arg(jsonMapFilename())); tr("File \"%1\" loaded into memory").arg(jsonMapFilename()));
} }
} }

View File

@ -35,10 +35,9 @@ static SerialManager *INSTANCE = nullptr;
* QStringList of all known control characters * QStringList of all known control characters
*/ */
static const QStringList CONTROL_STR static const QStringList CONTROL_STR
= { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", " BS", " HT", " LF",
" BS", " HT", " LF", " VT", " FF", " CR", " SO", " SI", " VT", " FF", " CR", " SO", " SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK",
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "SYN", "ETB", "CAN", " EM", "SUB", "ESC", " FS", " GS", " RS", " US" };
"CAN", " EM", "SUB", "ESC", " FS", " GS", " RS", " US" };
/** /**
* Returns a string that displays unknown characters in hexadecimal format * Returns a string that displays unknown characters in hexadecimal format
@ -481,8 +480,7 @@ void SerialManager::disconnectDevice()
// Disconnect signals/slots // Disconnect signals/slots
port()->disconnect(this, SLOT(onDataReceived())); port()->disconnect(this, SLOT(onDataReceived()));
port()->disconnect(this, SLOT(disconnectDevice())); port()->disconnect(this, SLOT(disconnectDevice()));
port()->disconnect(this, port()->disconnect(this, SLOT(handleError(QSerialPort::SerialPortError)));
SLOT(handleError(QSerialPort::SerialPortError)));
// Close & delete serial port handler // Close & delete serial port handler
port()->close(); port()->close();
@ -535,8 +533,7 @@ void SerialManager::sendData(const QString &data)
// Bytes not equal to data length // Bytes not equal to data length
if (bytes != bin.length()) if (bytes != bin.length())
LOG_WARNING() LOG_WARNING() << "Written data length not equal to request data length";
<< "Written data length not equal to request data length";
// Emit signals // Emit signals
else else
@ -615,8 +612,7 @@ void SerialManager::setPort(const quint8 portIndex)
if (port()->open(mode)) if (port()->open(mode))
{ {
emit connectedChanged(); emit connectedChanged();
LOG_INFO() << Q_FUNC_INFO LOG_INFO() << Q_FUNC_INFO << "Serial port opened successfully in RW mode";
<< "Serial port opened successfully in RW mode";
} }
// Close serial port on error // Close serial port on error

View File

@ -80,8 +80,7 @@ int main(int argc, char **argv)
// Begin logging // Begin logging
LOG_INFO() << QDateTime::currentDateTime(); LOG_INFO() << QDateTime::currentDateTime();
LOG_INFO() << APP_NAME << APP_VERSION; LOG_INFO() << APP_NAME << APP_VERSION;
LOG_INFO() << "Running on" LOG_INFO() << "Running on" << QSysInfo::prettyProductName().toStdString().c_str();
<< QSysInfo::prettyProductName().toStdString().c_str();
// Change application palette // Change application palette
QPalette palette; QPalette palette;