Change const auto to just auto

This commit is contained in:
Alex Spataru 2022-01-02 10:15:58 -05:00
parent 05d248385f
commit 9a50e2097d
27 changed files with 144 additions and 144 deletions

View File

@ -41,8 +41,8 @@
CSV::Export::Export() CSV::Export::Export()
: m_exportEnabled(true) : m_exportEnabled(true)
{ {
const auto io = &IO::Manager::instance(); auto io = &IO::Manager::instance();
const auto te = &Misc::TimerEvents::instance(); auto te = &Misc::TimerEvents::instance();
connect(io, &IO::Manager::connectedChanged, this, &Export::closeFile); connect(io, &IO::Manager::connectedChanged, this, &Export::closeFile);
connect(io, &IO::Manager::frameReceived, this, &Export::registerFrame); connect(io, &IO::Manager::frameReceived, this, &Export::registerFrame);
connect(te, &Misc::TimerEvents::timeout1Hz, this, &Export::writeValues); connect(te, &Misc::TimerEvents::timeout1Hz, this, &Export::writeValues);
@ -132,7 +132,7 @@ void CSV::Export::closeFile()
void CSV::Export::writeValues() void CSV::Export::writeValues()
{ {
// Get separator sequence // Get separator sequence
const auto sep = IO::Manager::instance().separatorSequence(); auto sep = IO::Manager::instance().separatorSequence();
// Write each frame // Write each frame
for (int i = 0; i < m_frames.count(); ++i) for (int i = 0; i < m_frames.count(); ++i)
@ -168,7 +168,7 @@ void CSV::Export::writeValues()
void CSV::Export::createCsvFile(const CSV::RawFrame &frame) void CSV::Export::createCsvFile(const CSV::RawFrame &frame)
{ {
// Get project title // Get project title
const auto projectTitle = UI::Dashboard::instance().title(); auto projectTitle = UI::Dashboard::instance().title();
// Get file name // Get file name
const QString fileName = frame.rxDateTime.toString("HH-mm-ss") + ".csv"; const QString fileName = frame.rxDateTime.toString("HH-mm-ss") + ".csv";
@ -206,8 +206,8 @@ void CSV::Export::createCsvFile(const CSV::RawFrame &frame)
#endif #endif
// Get number of fields // Get number of fields
const auto sep = IO::Manager::instance().separatorSequence(); auto sep = IO::Manager::instance().separatorSequence();
const auto fields = QString::fromUtf8(frame.data).split(sep); auto fields = QString::fromUtf8(frame.data).split(sep);
// Add table titles // Add table titles
m_textStream << "RX Date/Time,"; m_textStream << "RX Date/Time,";

View File

@ -385,10 +385,10 @@ void CSV::Player::updateData()
// No error, calculate difference & schedule update // No error, calculate difference & schedule update
if (!error) if (!error)
{ {
const auto format = "yyyy/MM/dd/ HH:mm:ss::zzz"; // Same as in Export.cpp auto format = "yyyy/MM/dd/ HH:mm:ss::zzz"; // Same as in Export.cpp
const auto currDateTime = QDateTime::fromString(currTime, format); auto currDateTime = QDateTime::fromString(currTime, format);
const auto nextDateTime = QDateTime::fromString(nextTime, format); auto nextDateTime = QDateTime::fromString(nextTime, format);
const auto msecsToNextF = currDateTime.msecsTo(nextDateTime); auto msecsToNextF = currDateTime.msecsTo(nextDateTime);
// clang-format off // clang-format off
QTimer::singleShot(msecsToNextF, QTimer::singleShot(msecsToNextF,
@ -425,8 +425,8 @@ bool CSV::Player::validateRow(const int position)
return false; return false;
// Get titles & value list // Get titles & value list
const auto titles = m_csvData.at(0); auto titles = m_csvData.at(0);
const auto list = m_csvData.at(position); auto list = m_csvData.at(position);
// Check that row value count is the same // Check that row value count is the same
if (titles.count() != list.count()) if (titles.count() != list.count())
@ -438,7 +438,7 @@ bool CSV::Player::validateRow(const int position)
// Check that this CSV is valid by checking the time title, this value must // Check that this CSV is valid by checking the time title, this value must
// be the same one that is used in Export.cpp // be the same one that is used in Export.cpp
const auto rxTitle = "RX Date/Time"; auto rxTitle = "RX Date/Time";
if (titles.first() != rxTitle) if (titles.first() != rxTitle)
{ {
qWarning() << "Invalid CSV file (title format does not match)"; qWarning() << "Invalid CSV file (title format does not match)";
@ -458,7 +458,7 @@ bool CSV::Player::validateRow(const int position)
QByteArray CSV::Player::getFrame(const int row) QByteArray CSV::Player::getFrame(const int row)
{ {
QByteArray frame; QByteArray frame;
const auto sep = IO::Manager::instance().separatorSequence(); auto sep = IO::Manager::instance().separatorSequence();
if (m_csvData.count() > row) if (m_csvData.count() > row)
{ {

View File

@ -92,7 +92,7 @@ IO::Console::Console()
clear(); clear();
// Read received data automatically // Read received data automatically
const auto dm = &Manager::instance(); auto dm = &Manager::instance();
connect(dm, &Manager::dataSent, this, &IO::Console::onDataSent); connect(dm, &Manager::dataSent, this, &IO::Console::onDataSent);
connect(dm, &Manager::dataReceived, this, &IO::Console::onDataReceived); connect(dm, &Manager::dataReceived, this, &IO::Console::onDataReceived);
} }
@ -520,7 +520,7 @@ void IO::Console::append(const QString &string, const bool addTimestamp)
if (m_isStartingLine) if (m_isStartingLine)
processedString.append(timestamp); processedString.append(timestamp);
const auto token = tokens.first(); auto token = tokens.first();
processedString.append(token); processedString.append(token);
m_isStartingLine = (token == "\n"); m_isStartingLine = (token == "\n");
tokens.removeFirst(); tokens.removeFirst();
@ -579,9 +579,9 @@ QByteArray IO::Console::hexToBytes(const QString &data)
QByteArray array; QByteArray array;
for (int i = 0; i < withoutSpaces.length(); i += 2) for (int i = 0; i < withoutSpaces.length(); i += 2)
{ {
const auto chr1 = withoutSpaces.at(i); auto chr1 = withoutSpaces.at(i);
const auto chr2 = withoutSpaces.at(i + 1); auto chr2 = withoutSpaces.at(i + 1);
const auto byte = QString("%1%2").arg(chr1, chr2).toInt(Q_NULLPTR, 16); auto byte = QString("%1%2").arg(chr1, chr2).toInt(Q_NULLPTR, 16);
array.append(byte); array.append(byte);
} }

View File

@ -68,8 +68,8 @@ IO::Manager::Manager()
setMaxBufferSize(1024 * 1024); setMaxBufferSize(1024 * 1024);
// Configure signals/slots // Configure signals/slots
const auto serial = &DataSources::Serial::instance(); auto serial = &DataSources::Serial::instance();
const auto netwrk = &DataSources::Network::instance(); auto netwrk = &DataSources::Network::instance();
connect(netwrk, SIGNAL(portChanged()), this, SIGNAL(configurationChanged())); connect(netwrk, SIGNAL(portChanged()), this, SIGNAL(configurationChanged()));
connect(netwrk, SIGNAL(addressChanged()), this, SIGNAL(configurationChanged())); connect(netwrk, SIGNAL(addressChanged()), this, SIGNAL(configurationChanged()));
connect(this, SIGNAL(dataSourceChanged()), this, SIGNAL(configurationChanged())); connect(this, SIGNAL(dataSourceChanged()), this, SIGNAL(configurationChanged()));
@ -220,7 +220,7 @@ qint64 IO::Manager::writeData(const QByteArray &data)
if (dataSource() == DataSource::Network) if (dataSource() == DataSource::Network)
{ {
// Write to UDP socket // Write to UDP socket
const auto network = &DataSources::Network::instance(); auto network = &DataSources::Network::instance();
if (network->socketType() == QAbstractSocket::UdpSocket) if (network->socketType() == QAbstractSocket::UdpSocket)
{ {
bytes = network->udpSocket()->writeDatagram( bytes = network->udpSocket()->writeDatagram(
@ -448,8 +448,8 @@ void IO::Manager::readFrames()
auto bytes = 0; auto bytes = 0;
auto prevBytes = 0; auto prevBytes = 0;
auto cursor = m_dataBuffer; auto cursor = m_dataBuffer;
const auto start = startSequence().toUtf8(); auto start = startSequence().toUtf8();
const auto finish = finishSequence().toUtf8(); auto finish = finishSequence().toUtf8();
while (cursor.contains(start) && cursor.contains(finish)) while (cursor.contains(start) && cursor.contains(finish))
{ {
// Remove the part of the buffer prior to, and including, the start sequence. // Remove the part of the buffer prior to, and including, the start sequence.
@ -463,7 +463,7 @@ void IO::Manager::readFrames()
// Checksum verification & Q_EMIT RX frame // Checksum verification & Q_EMIT RX frame
int chop = 0; int chop = 0;
const auto result = integrityChecks(frame, cursor, &chop); auto result = integrityChecks(frame, cursor, &chop);
if (result == ValidationStatus::FrameOk) if (result == ValidationStatus::FrameOk)
Q_EMIT frameReceived(frame); Q_EMIT frameReceived(frame);
@ -512,7 +512,7 @@ void IO::Manager::onDataReceived()
if (DataSources::Network::instance().socketType() == QAbstractSocket::UdpSocket) if (DataSources::Network::instance().socketType() == QAbstractSocket::UdpSocket)
{ {
udpConnection = true; udpConnection = true;
const auto udpSocket = DataSources::Network::instance().udpSocket(); auto udpSocket = DataSources::Network::instance().udpSocket();
while (udpSocket->hasPendingDatagrams()) while (udpSocket->hasPendingDatagrams())
{ {
QByteArray datagram; QByteArray datagram;
@ -579,17 +579,17 @@ IO::Manager::ValidationStatus IO::Manager::integrityChecks(const QByteArray &fra
int *bytes) int *bytes)
{ {
// Get finish sequence as byte array // Get finish sequence as byte array
const auto finish = finishSequence().toUtf8(); auto finish = finishSequence().toUtf8();
const auto crc8Header = finish + "crc8:"; auto crc8Header = finish + "crc8:";
const auto crc16Header = finish + "crc16:"; auto crc16Header = finish + "crc16:";
const auto crc32Header = finish + "crc32:"; auto crc32Header = finish + "crc32:";
// Check CRC-8 // Check CRC-8
if (cursor.contains(crc8Header)) if (cursor.contains(crc8Header))
{ {
// Enable the CRC flag // Enable the CRC flag
m_enableCrc = true; m_enableCrc = true;
const auto offset = cursor.indexOf(crc8Header) + crc8Header.length() - 1; auto offset = cursor.indexOf(crc8Header) + crc8Header.length() - 1;
// Check if we have enough data in the buffer // Check if we have enough data in the buffer
if (cursor.length() >= offset + 1) if (cursor.length() >= offset + 1)
@ -613,7 +613,7 @@ IO::Manager::ValidationStatus IO::Manager::integrityChecks(const QByteArray &fra
{ {
// Enable the CRC flag // Enable the CRC flag
m_enableCrc = true; m_enableCrc = true;
const auto offset = cursor.indexOf(crc16Header) + crc16Header.length() - 1; auto offset = cursor.indexOf(crc16Header) + crc16Header.length() - 1;
// Check if we have enough data in the buffer // Check if we have enough data in the buffer
if (cursor.length() >= offset + 2) if (cursor.length() >= offset + 2)
@ -639,7 +639,7 @@ IO::Manager::ValidationStatus IO::Manager::integrityChecks(const QByteArray &fra
{ {
// Enable the CRC flag // Enable the CRC flag
m_enableCrc = true; m_enableCrc = true;
const auto offset = cursor.indexOf(crc32Header) + crc32Header.length() - 1; auto offset = cursor.indexOf(crc32Header) + crc32Header.length() - 1;
// Check if we have enough data in the buffer // Check if we have enough data in the buffer
if (cursor.length() >= offset + 4) if (cursor.length() >= offset + 4)

View File

@ -155,18 +155,18 @@ bool JSON::Dataset::read(const QJsonObject &object)
{ {
if (!object.isEmpty()) if (!object.isEmpty())
{ {
const auto fft = object.value("fft").toBool(); auto fft = object.value("fft").toBool();
const auto led = object.value("led").toBool(); auto led = object.value("led").toBool();
const auto log = object.value("log").toBool(); auto log = object.value("log").toBool();
const auto min = object.value("min").toDouble(); auto min = object.value("min").toDouble();
const auto max = object.value("max").toDouble(); auto max = object.value("max").toDouble();
const auto alarm = object.value("alarm").toDouble(); auto alarm = object.value("alarm").toDouble();
const auto graph = object.value("graph").toBool(); auto graph = object.value("graph").toBool();
const auto title = object.value("title").toString(); auto title = object.value("title").toString();
const auto value = object.value("value").toString(); auto value = object.value("value").toString();
const auto units = object.value("units").toString(); auto units = object.value("units").toString();
const auto widget = object.value("widget").toString(); auto widget = object.value("widget").toString();
const auto fftSamples = object.value("fftSamples").toInt(); auto fftSamples = object.value("fftSamples").toInt();
if (!value.isEmpty() && !title.isEmpty()) if (!value.isEmpty() && !title.isEmpty())
{ {

View File

@ -275,7 +275,7 @@ bool JSON::Editor::saveJsonFile()
else else
{ {
const auto ret = Misc::Utilities::showMessageBox( auto ret = Misc::Utilities::showMessageBox(
tr("Warning - Group %1, Dataset %2").arg(i + 1).arg(j + 1), tr("Warning - Group %1, Dataset %2").arg(i + 1).arg(j + 1),
tr("Dataset contains duplicate frame index position! Continue?"), tr("Dataset contains duplicate frame index position! Continue?"),
APP_NAME, QMessageBox::Yes | QMessageBox::No); APP_NAME, QMessageBox::Yes | QMessageBox::No);
@ -289,8 +289,8 @@ bool JSON::Editor::saveJsonFile()
// Get file save path // Get file save path
if (jsonFilePath().isEmpty()) if (jsonFilePath().isEmpty())
{ {
const auto path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save JSON project"), auto path = QFileDialog::getSaveFileName(Q_NULLPTR, tr("Save JSON project"),
jsonProjectsPath(), "*.json"); jsonProjectsPath(), "*.json");
if (path.isEmpty()) if (path.isEmpty())
return false; return false;
@ -694,7 +694,7 @@ void JSON::Editor::openJsonFile(const QString &path)
for (int g = 0; g < groups.count(); ++g) for (int g = 0; g < groups.count(); ++g)
{ {
// Get JSON group data // Get JSON group data
const auto group = groups.at(g).toObject(); auto group = groups.at(g).toObject();
// Register group with C++ model // Register group with C++ model
addGroup(); addGroup();

View File

@ -78,8 +78,8 @@ bool JSON::Frame::read(const QJsonObject &object)
clear(); clear();
// Get title & groups array // Get title & groups array
const auto title = object.value("title").toString(); auto title = object.value("title").toString();
const auto groups = object.value("groups").toArray(); auto groups = object.value("groups").toArray();
// We need to have a project title and at least one group // We need to have a project title and at least one group
if (!title.isEmpty() && !groups.isEmpty()) if (!title.isEmpty() && !groups.isEmpty())

View File

@ -82,9 +82,9 @@ bool JSON::Group::read(const QJsonObject &object)
{ {
if (!object.isEmpty()) if (!object.isEmpty())
{ {
const auto title = object.value("title").toString(); auto title = object.value("title").toString();
const auto array = object.value("datasets").toArray(); auto array = object.value("datasets").toArray();
const auto widget = object.value("widget").toString(); auto widget = object.value("widget").toString();
if (!title.isEmpty() && !array.isEmpty()) if (!title.isEmpty() && !array.isEmpty())
{ {
@ -94,7 +94,7 @@ bool JSON::Group::read(const QJsonObject &object)
for (auto i = 0; i < array.count(); ++i) for (auto i = 0; i < array.count(); ++i)
{ {
const auto object = array.at(i).toObject(); auto object = array.at(i).toObject();
if (!object.isEmpty()) if (!object.isEmpty())
{ {
Dataset dataset; Dataset dataset;

View File

@ -43,8 +43,8 @@ MQTT::Client::Client()
regenerateClient(); regenerateClient();
// Send data periodically & reset statistics when disconnected/connected to a device // Send data periodically & reset statistics when disconnected/connected to a device
const auto io = &IO::Manager::instance(); auto io = &IO::Manager::instance();
const auto te = &Misc::TimerEvents::instance(); auto te = &Misc::TimerEvents::instance();
connect(te, &Misc::TimerEvents::timeout1Hz, this, &MQTT::Client::sendData); connect(te, &Misc::TimerEvents::timeout1Hz, this, &MQTT::Client::sendData);
connect(io, &IO::Manager::frameReceived, this, &MQTT::Client::onFrameReceived); connect(io, &IO::Manager::frameReceived, this, &MQTT::Client::onFrameReceived);
connect(io, &IO::Manager::connectedChanged, this, &MQTT::Client::resetStatistics); connect(io, &IO::Manager::connectedChanged, this, &MQTT::Client::resetStatistics);

View File

@ -163,25 +163,25 @@ bool Misc::ModuleManager::autoUpdaterEnabled()
void Misc::ModuleManager::initializeQmlInterface() void Misc::ModuleManager::initializeQmlInterface()
{ {
// Initialize modules // Initialize modules
const auto csvExport = &CSV::Export::instance(); auto csvExport = &CSV::Export::instance();
const auto csvPlayer = &CSV::Player::instance(); auto csvPlayer = &CSV::Player::instance();
const auto ioManager = &IO::Manager::instance(); auto ioManager = &IO::Manager::instance();
const auto ioConsole = &IO::Console::instance(); auto ioConsole = &IO::Console::instance();
const auto jsonEditor = &JSON::Editor::instance(); auto jsonEditor = &JSON::Editor::instance();
const auto mqttClient = &MQTT::Client::instance(); auto mqttClient = &MQTT::Client::instance();
const auto uiDashboard = &UI::Dashboard::instance(); auto uiDashboard = &UI::Dashboard::instance();
const auto jsonGenerator = &JSON::Generator::instance(); auto jsonGenerator = &JSON::Generator::instance();
const auto pluginsBridge = &Plugins::Server::instance(); auto pluginsBridge = &Plugins::Server::instance();
const auto miscUtilities = &Misc::Utilities::instance(); auto miscUtilities = &Misc::Utilities::instance();
const auto miscMacExtras = &Misc::MacExtras::instance(); auto miscMacExtras = &Misc::MacExtras::instance();
const auto miscTranslator = &Misc::Translator::instance(); auto miscTranslator = &Misc::Translator::instance();
const auto ioSerial = &IO::DataSources::Serial::instance(); auto ioSerial = &IO::DataSources::Serial::instance();
const auto miscTimerEvents = &Misc::TimerEvents::instance(); auto miscTimerEvents = &Misc::TimerEvents::instance();
const auto ioNetwork = &IO::DataSources::Network::instance(); auto ioNetwork = &IO::DataSources::Network::instance();
const auto miscThemeManager = &Misc::ThemeManager::instance(); auto miscThemeManager = &Misc::ThemeManager::instance();
// Initialize third-party modules // Initialize third-party modules
const auto updater = QSimpleUpdater::getInstance(); auto updater = QSimpleUpdater::getInstance();
// Operating system flags // Operating system flags
bool isWin = false; bool isWin = false;

View File

@ -132,7 +132,7 @@ void Misc::ThemeManager::loadTheme(const int id)
return; return;
// Read theme data into JSON // Read theme data into JSON
const auto document = QJsonDocument::fromJson(file.readAll()); auto document = QJsonDocument::fromJson(file.readAll());
if (document.isEmpty()) if (document.isEmpty())
return; return;
@ -244,11 +244,11 @@ void Misc::ThemeManager::populateThemes()
QFile file(QString(":/themes/%1").arg(themeList.at(i))); QFile file(QString(":/themes/%1").arg(themeList.at(i)));
if (file.open(QFile::ReadOnly)) if (file.open(QFile::ReadOnly))
{ {
const auto data = file.readAll(); auto data = file.readAll();
file.close(); file.close();
const auto document = QJsonDocument::fromJson(data); auto document = QJsonDocument::fromJson(data);
const auto name = document.object().value("name").toString(); auto name = document.object().value("name").toString();
if (!name.isEmpty()) if (!name.isEmpty())
{ {
m_availableThemes.append(name); m_availableThemes.append(name);

View File

@ -228,7 +228,7 @@ void Plugins::Server::sendProcessedData()
QJsonObject object; QJsonObject object;
object.insert("frames", array); object.insert("frames", array);
const QJsonDocument document(object); const QJsonDocument document(object);
const auto json = document.toJson(QJsonDocument::Compact) + "\n"; auto json = document.toJson(QJsonDocument::Compact) + "\n";
// Send data to each plugin // Send data to each plugin
Q_FOREACH (auto socket, m_sockets) Q_FOREACH (auto socket, m_sockets)

View File

@ -668,7 +668,7 @@ void UI::Dashboard::updatePlots()
// Create list with datasets that need to be graphed // Create list with datasets that need to be graphed
for (int i = 0; i < m_latestFrame.groupCount(); ++i) for (int i = 0; i < m_latestFrame.groupCount(); ++i)
{ {
const auto group = m_latestFrame.groups().at(i); auto group = m_latestFrame.groups().at(i);
for (int j = 0; j < group.datasetCount(); ++j) for (int j = 0; j < group.datasetCount(); ++j)
{ {
auto dataset = group.getDataset(j); auto dataset = group.getDataset(j);
@ -753,7 +753,7 @@ void UI::Dashboard::processLatestJSON(const JFI_Object &frameInfo)
const int accelerometerC = accelerometerCount(); const int accelerometerC = accelerometerCount();
// Save previous title // Save previous title
const auto pTitle = title(); auto pTitle = title();
// Try to read latest frame for widget updating // Try to read latest frame for widget updating
if (!m_latestFrame.read(frameInfo.jsonDocument.object())) if (!m_latestFrame.read(frameInfo.jsonDocument.object()))

View File

@ -34,8 +34,8 @@ Widgets::Accelerometer::Accelerometer(const int index)
: m_index(index) : m_index(index)
{ {
// Get pointers to Serial Studio modules // Get pointers to Serial Studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->accelerometerCount()) if (m_index < 0 || m_index >= dash->accelerometerCount())
@ -43,8 +43,8 @@ Widgets::Accelerometer::Accelerometer(const int index)
// Get needle & knob color // Get needle & knob color
QString needleColor; QString needleColor;
const auto colors = theme->widgetColors(); auto colors = theme->widgetColors();
const auto knobColor = theme->widgetControlBackground(); auto knobColor = theme->widgetControlBackground();
if (colors.count() > m_index) if (colors.count() > m_index)
needleColor = colors.at(m_index); needleColor = colors.at(m_index);
else else
@ -85,7 +85,7 @@ void Widgets::Accelerometer::updateData()
return; return;
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->accelerometerCount()) if (m_index < 0 || m_index >= dash->accelerometerCount())
return; return;

View File

@ -33,8 +33,8 @@ Widgets::Bar::Bar(const int index)
: m_index(index) : m_index(index)
{ {
// Get pointers to serial studio modules // Get pointers to serial studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->barCount()) if (m_index < 0 || m_index >= dash->barCount())
@ -53,7 +53,7 @@ Widgets::Bar::Bar(const int index)
// Get thermo color // Get thermo color
QString color; QString color;
const auto colors = theme->widgetColors(); auto colors = theme->widgetColors();
if (colors.count() > m_index) if (colors.count() > m_index)
color = colors.at(m_index); color = colors.at(m_index);
else else
@ -92,13 +92,13 @@ void Widgets::Bar::updateData()
return; return;
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->barCount()) if (m_index < 0 || m_index >= dash->barCount())
return; return;
// Update bar level // Update bar level
auto dataset = dash->getBar(m_index); auto dataset = dash->getBar(m_index);
const auto value = dataset.value().toDouble(); auto value = dataset.value().toDouble();
m_thermo.setValue(value); m_thermo.setValue(value);
setValue(QString("%1 %2").arg( setValue(QString("%1 %2").arg(
QString::number(value, 'f', UI::Dashboard::instance().precision()), QString::number(value, 'f', UI::Dashboard::instance().precision()),

View File

@ -105,7 +105,7 @@ void AttitudeIndicator::setAngle(const double &angle)
void AttitudeIndicator::setGradient(const double &gradient) void AttitudeIndicator::setGradient(const double &gradient)
{ {
const auto grad = qMin(1.0, qMax(gradient, -1.0)); auto grad = qMin(1.0, qMax(gradient, -1.0));
if (m_gradient != grad) if (m_gradient != grad)
{ {

View File

@ -36,7 +36,7 @@ Widgets::BaseWidget::BaseWidget()
// Set window palette // Set window palette
QPalette palette; QPalette palette;
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
palette.setColor(QPalette::Base, theme->widgetWindowBackground()); palette.setColor(QPalette::Base, theme->widgetWindowBackground());
palette.setColor(QPalette::Window, theme->widgetWindowBackground()); palette.setColor(QPalette::Window, theme->widgetWindowBackground());
setPalette(palette); setPalette(palette);
@ -46,7 +46,7 @@ Widgets::BaseWidget::BaseWidget()
// Set stylesheets // Set stylesheets
// clang-format off // clang-format off
const auto valueQSS = QSS("background-color:%1; color:%2; border:1px solid %3;", auto valueQSS = QSS("background-color:%1; color:%2; border:1px solid %3;",
theme->base(), theme->base(),
theme->widgetForegroundPrimary(), theme->widgetForegroundPrimary(),
theme->widgetIndicator()); theme->widgetIndicator());

View File

@ -35,8 +35,8 @@ Widgets::Compass::Compass(const int index)
: m_index(index) : m_index(index)
{ {
// Get pointers to serial studio modules // Get pointers to serial studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->compassCount()) if (m_index < 0 || m_index >= dash->compassCount())
@ -84,7 +84,7 @@ void Widgets::Compass::update()
return; return;
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->compassCount()) if (m_index < 0 || m_index >= dash->compassCount())
return; return;

View File

@ -46,8 +46,8 @@ Widgets::DataGroup::DataGroup(const int index)
: m_index(index) : m_index(index)
{ {
// Get pointers to serial studio modules // Get pointers to serial studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->groupCount()) if (m_index < 0 || m_index >= dash->groupCount())
@ -57,10 +57,10 @@ Widgets::DataGroup::DataGroup(const int index)
auto group = dash->getGroups(m_index); auto group = dash->getGroups(m_index);
// Generate widget stylesheets // Generate widget stylesheets
const auto titleQSS = QSS("color:%1", theme->widgetTextPrimary()); auto titleQSS = QSS("color:%1", theme->widgetTextPrimary());
const auto unitsQSS = QSS("color:%1", theme->widgetTextSecondary()); auto unitsQSS = QSS("color:%1", theme->widgetTextSecondary());
const auto valueQSS = QSS("color:%1", theme->widgetForegroundPrimary()); auto valueQSS = QSS("color:%1", theme->widgetForegroundPrimary());
const auto iconsQSS = QSS("color:%1; font-weight:600;", theme->widgetTextSecondary()); auto iconsQSS = QSS("color:%1; font-weight:600;", theme->widgetTextSecondary());
// Set window palette // Set window palette
QPalette windowPalette; QPalette windowPalette;
@ -191,7 +191,7 @@ void Widgets::DataGroup::updateData()
return; return;
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->groupCount()) if (m_index < 0 || m_index >= dash->groupCount())
return; return;

View File

@ -32,8 +32,8 @@ Widgets::FFTPlot::FFTPlot(const int index)
, m_index(index) , m_index(index)
{ {
// Get pointers to serial studio modules // Get pointers to serial studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Initialize pointers to NULL // Initialize pointers to NULL
m_fft = Q_NULLPTR; m_fft = Q_NULLPTR;

View File

@ -34,8 +34,8 @@ Widgets::GPS::GPS(const int index)
: m_index(index) : m_index(index)
{ {
// Get pointers to serial studio modules // Get pointers to serial studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->gpsCount()) if (m_index < 0 || m_index >= dash->gpsCount())
@ -116,7 +116,7 @@ void Widgets::GPS::updateData()
return; return;
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->gpsCount()) if (m_index < 0 || m_index >= dash->gpsCount())
return; return;
@ -142,9 +142,9 @@ void Widgets::GPS::updateData()
m_mapControl.setView(QPointF(lon, lat)); m_mapControl.setView(QPointF(lon, lat));
// Update map title // Update map title
const auto latstr = QString::number(lat, 'f', dash->precision()); auto latstr = QString::number(lat, 'f', dash->precision());
const auto lonstr = QString::number(lon, 'f', dash->precision()); auto lonstr = QString::number(lon, 'f', dash->precision());
const auto altstr = QString::number(alt, 'f', dash->precision()); auto altstr = QString::number(alt, 'f', dash->precision());
// clang-format off // clang-format off
m_label->setText(QString("<u>POS:</u><i> %1,%2</i>&nbsp;<u>ALT:</u><i> %3 m</i>") m_label->setText(QString("<u>POS:</u><i> %1,%2</i>&nbsp;<u>ALT:</u><i> %3 m</i>")
@ -160,8 +160,8 @@ void Widgets::GPS::updateData()
*/ */
void Widgets::GPS::resizeEvent(QResizeEvent *event) void Widgets::GPS::resizeEvent(QResizeEvent *event)
{ {
const auto width = event->size().width(); auto width = event->size().width();
const auto height = event->size().height(); auto height = event->size().height();
m_mapControl.resize(QSize(width - 28, height - 26 - m_titleWidget.height())); m_mapControl.resize(QSize(width - 28, height - 26 - m_titleWidget.height()));
event->accept(); event->accept();
} }

View File

@ -31,8 +31,8 @@ Widgets::Gauge::Gauge(const int index)
: m_index(index) : m_index(index)
{ {
// Get pointers to Serial Studio modules // Get pointers to Serial Studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->gaugeCount()) if (m_index < 0 || m_index >= dash->gaugeCount())
@ -40,8 +40,8 @@ Widgets::Gauge::Gauge(const int index)
// Get needle & knob color // Get needle & knob color
QString needleColor; QString needleColor;
const auto colors = theme->widgetColors(); auto colors = theme->widgetColors();
const auto knobColor = theme->widgetControlBackground(); auto knobColor = theme->widgetControlBackground();
if (colors.count() > m_index) if (colors.count() > m_index)
needleColor = colors.at(m_index); needleColor = colors.at(m_index);
else else
@ -84,7 +84,7 @@ void Widgets::Gauge::updateData()
return; return;
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->gaugeCount()) if (m_index < 0 || m_index >= dash->gaugeCount())
return; return;

View File

@ -35,8 +35,8 @@ Widgets::Gyroscope::Gyroscope(const int index)
, m_displayNum(0) , m_displayNum(0)
{ {
// Get pointers to Serial Studio modules // Get pointers to Serial Studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->gyroscopeCount()) if (m_index < 0 || m_index >= dash->gyroscopeCount())
@ -74,7 +74,7 @@ void Widgets::Gyroscope::updateData()
return; return;
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->gyroscopeCount()) if (m_index < 0 || m_index >= dash->gyroscopeCount())
return; return;

View File

@ -33,8 +33,8 @@ Widgets::LEDPanel::LEDPanel(const int index)
: m_index(index) : m_index(index)
{ {
// Get pointers to serial studio modules // Get pointers to serial studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->ledCount()) if (m_index < 0 || m_index >= dash->ledCount())
@ -44,7 +44,7 @@ Widgets::LEDPanel::LEDPanel(const int index)
auto group = dash->getLED(m_index); auto group = dash->getLED(m_index);
// Generate widget stylesheets // Generate widget stylesheets
const auto titleQSS = QSS("color:%1", theme->widgetTextPrimary()); auto titleQSS = QSS("color:%1", theme->widgetTextPrimary());
// Set window palette // Set window palette
QPalette windowPalette; QPalette windowPalette;
@ -153,7 +153,7 @@ void Widgets::LEDPanel::updateData()
return; return;
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->ledCount()) if (m_index < 0 || m_index >= dash->ledCount())
return; return;
@ -164,7 +164,7 @@ void Widgets::LEDPanel::updateData()
for (int i = 0; i < group.datasetCount(); ++i) for (int i = 0; i < group.datasetCount(); ++i)
{ {
// Get dataset value (we compare with 0.1 for low voltages) // Get dataset value (we compare with 0.1 for low voltages)
const auto value = group.getDataset(i).value().toDouble(); auto value = group.getDataset(i).value().toDouble();
if (qAbs(value) < 0.10) if (qAbs(value) < 0.10)
m_leds.at(i)->off(); m_leds.at(i)->off();
else else
@ -180,10 +180,10 @@ void Widgets::LEDPanel::updateData()
*/ */
void Widgets::LEDPanel::resizeEvent(QResizeEvent *event) void Widgets::LEDPanel::resizeEvent(QResizeEvent *event)
{ {
const auto width = event->size().width(); auto width = event->size().width();
QFont font = UI::Dashboard::instance().monoFont(); QFont font = UI::Dashboard::instance().monoFont();
font.setPixelSize(qMax(8, width / 24)); font.setPixelSize(qMax(8, width / 24));
const auto fHeight = QFontMetrics(font).height() * 1.5; auto fHeight = QFontMetrics(font).height() * 1.5;
for (int i = 0; i < m_titles.count(); ++i) for (int i = 0; i < m_titles.count(); ++i)
{ {

View File

@ -32,8 +32,8 @@ Widgets::MultiPlot::MultiPlot(const int index)
: m_index(index) : m_index(index)
{ {
// Get pointers to serial studio modules // Get pointers to serial studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->multiPlotCount()) if (m_index < 0 || m_index >= dash->multiPlotCount())
@ -134,7 +134,7 @@ Widgets::MultiPlot::MultiPlot(const int index)
void Widgets::MultiPlot::updateData() void Widgets::MultiPlot::updateData()
{ {
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->multiPlotCount()) if (m_index < 0 || m_index >= dash->multiPlotCount())
return; return;
@ -148,15 +148,15 @@ void Widgets::MultiPlot::updateData()
auto dataset = group.getDataset(i); auto dataset = group.getDataset(i);
// Add point to plot data // Add point to plot data
const auto count = m_yData[i].count(); auto count = m_yData[i].count();
memmove(m_yData[i].data(), m_yData[i].data() + 1, count * sizeof(double)); memmove(m_yData[i].data(), m_yData[i].data() + 1, count * sizeof(double));
// Normalize dataset value // Normalize dataset value
if (dataset.max() > dataset.min()) if (dataset.max() > dataset.min())
{ {
const auto vmin = dataset.min(); auto vmin = dataset.min();
const auto vmax = dataset.max(); auto vmax = dataset.max();
const auto v = dataset.value().toDouble(); auto v = dataset.value().toDouble();
m_yData[i][count - 1] = (v - vmin) / (vmax - vmin); m_yData[i][count - 1] = (v - vmin) / (vmax - vmin);
} }
@ -186,7 +186,7 @@ void Widgets::MultiPlot::updateData()
void Widgets::MultiPlot::updateRange() void Widgets::MultiPlot::updateRange()
{ {
// Invalid index, abort update // Invalid index, abort update
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
if (m_index < 0 || m_index >= dash->multiPlotCount()) if (m_index < 0 || m_index >= dash->multiPlotCount())
return; return;

View File

@ -35,8 +35,8 @@ Widgets::Plot::Plot(const int index)
, m_autoscale(true) , m_autoscale(true)
{ {
// Get pointers to serial studio modules // Get pointers to serial studio modules
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
// Invalid index, abort initialization // Invalid index, abort initialization
if (m_index < 0 || m_index >= dash->plotCount()) if (m_index < 0 || m_index >= dash->plotCount())
@ -88,8 +88,8 @@ Widgets::Plot::Plot(const int index)
// Update graph scale // Update graph scale
auto dataset = UI::Dashboard::instance().getPlot(m_index); auto dataset = UI::Dashboard::instance().getPlot(m_index);
const auto max = dataset.max(); auto max = dataset.max();
const auto min = dataset.min(); auto min = dataset.min();
if (max > min) if (max > min)
{ {
m_max = max; m_max = max;
@ -145,7 +145,7 @@ void Widgets::Plot::updateData()
bool changed = false; bool changed = false;
for (int i = 0; i < plotData.at(m_index).count(); ++i) for (int i = 0; i < plotData.at(m_index).count(); ++i)
{ {
const auto v = plotData.at(m_index).at(i); auto v = plotData.at(m_index).at(i);
if (v > m_max) if (v > m_max)
{ {
m_max = v + 1; m_max = v + 1;
@ -210,7 +210,7 @@ void Widgets::Plot::updateData()
void Widgets::Plot::updateRange() void Widgets::Plot::updateRange()
{ {
// Get pointer to dashboard manager // Get pointer to dashboard manager
const auto dash = &UI::Dashboard::instance(); auto dash = &UI::Dashboard::instance();
// Clear Y-axis data // Clear Y-axis data
PlotData tempYData; PlotData tempYData;

View File

@ -54,7 +54,7 @@ Widgets::Terminal::Terminal(QQuickItem *parent)
// Set widget palette // Set widget palette
QPalette palette; QPalette palette;
const auto theme = &Misc::ThemeManager::instance(); auto theme = &Misc::ThemeManager::instance();
palette.setColor(QPalette::Text, theme->consoleText()); palette.setColor(QPalette::Text, theme->consoleText());
palette.setColor(QPalette::Base, theme->consoleBase()); palette.setColor(QPalette::Base, theme->consoleBase());
palette.setColor(QPalette::Button, theme->consoleButton()); palette.setColor(QPalette::Button, theme->consoleButton());