Skip to content

Commit

Permalink
add csv and fix linux
Browse files Browse the repository at this point in the history
Signed-off-by: swurl <swurl@swurl.xyz>
  • Loading branch information
crueter committed Jan 2, 2025
1 parent 7d1e9df commit 1679b3c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@ jobs:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'

- name: Install Qt ${{ matrix.qt_version }} (Windows, macOS)
if: runner.os != 'Linux'
- name: Install Qt ${{ matrix.qt_version }} (Host)
uses: Kidev/install-qt-action@v4.2.0
with:
cache: on
version: ${{ matrix.qt_version }}

- name: Install Qt ${{ matrix.qt_version }} (Linux)
if: runner.os == 'Linux'
- name: Install Qt ${{ matrix.qt_version }} (Wasm/Android)
if: runner.os == 'Linux' && matrix.qt_arch != 'gcc_64'
uses: Kidev/install-qt-action@v4.2.0
with:
cache: on
Expand All @@ -102,7 +101,6 @@ jobs:
arch: ${{ matrix.qt_arch }}
set-env: true
aqtsource: 'git+https://github.com/Kidev/aqtinstall.git@wasm'
extra: '--autodesktop'

- name: Install Build Dependencies (macOS)
if: runner.os == 'macOS'
Expand Down
4 changes: 4 additions & 0 deletions include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class ScouterConfig : public QObject
QJsonObject object() const;
void setObject(const QJsonObject &newObject);

#if !defined(Q_OS_WASM) && !defined(Q_OS_ANDROID)
void saveCsv() const;
#endif

PhaseDataModel *autoModel() const;

PhaseDataModel *teleModel() const;
Expand Down
45 changes: 44 additions & 1 deletion src/Config.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Config.h"

#include <QDir>
#include <QFile>
#include <QJsonDocument>

Expand All @@ -23,8 +24,12 @@ ScouterConfig::ScouterConfig(QObject *parent)

m_autoModel = new PhaseDataModel(pages.value("auto").toArray(), this);
m_teleModel = new PhaseDataModel(pages.value("tele").toArray(), this);
m_endModel = new PhaseDataModel(pages.value("end").toArray(), this);
m_endModel = new PhaseDataModel(pages.value("end").toArray(), this); // unused for now
m_scalesModel = new ScalesModel(pages.value("scales").toArray(), this);

#if !defined(Q_OS_WASM) && !defined(Q_OS_ANDROID)
saveCsv();
#endif
}

QJsonObject ScouterConfig::object() const
Expand All @@ -40,6 +45,44 @@ void ScouterConfig::setObject(const QJsonObject &newObject)
emit objectChanged();
}

#if !defined(Q_OS_WASM) && !defined(Q_OS_ANDROID)
void ScouterConfig::saveCsv() const
{
QStringList csv;
csv << "Scouter Initials"
<< "Match Number"
<< "Team Number";

QJsonObject pages = m_object.value("pages").toObject();
QJsonArray autoPage = pages.value("auto").toArray();
QJsonArray telePage = pages.value("tele").toArray();
QJsonArray scalesPage = pages.value("scales").toArray();

for (QJsonValueConstRef ref : autoPage) {
csv << ("Auto " + ref.toObject().value("text").toString());
}

for (QJsonValueConstRef ref : telePage) {
csv << ("Teleop " + ref.toObject().value("text").toString());
}

for (QJsonValueConstRef ref : scalesPage) {
csv << ref.toObject().value("title").toString();
}

// save to home directory for easy access
QDir home = QDir::home();
QFile file(home.absoluteFilePath("data.csv"));

if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
qCritical() << "Failed to write CSV.";
} else {
file.write(csv.join(",").toUtf8());
file.close();
}
}
#endif

PhaseDataModel *ScouterConfig::autoModel() const
{
return m_autoModel;
Expand Down

0 comments on commit 1679b3c

Please sign in to comment.