• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

paulmthompson / WhiskerToolbox / 17621333818

10 Sep 2025 02:29PM UTC coverage: 71.842% (+0.04%) from 71.805%
17621333818

push

github

paulmthompson
Merge branch 'main' of https://github.com/paulmthompson/WhiskerToolbox

510 of 568 new or added lines in 5 files covered. (89.79%)

224 existing lines in 3 files now uncovered.

37074 of 51605 relevant lines covered (71.84%)

1307.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/src/WhiskerToolbox/TableDesignerWidget/TableJSONWidget.cpp
1
#include "TableJSONWidget.hpp"
2
#include "ui_TableJSONWidget.h"
3

4
#include <QFileDialog>
5
#include <QFile>
6
#include <QTextStream>
7
#include <QMessageBox>
8

9
TableJSONWidget::TableJSONWidget(QWidget * parent)
16✔
10
    : QWidget(parent), ui(new Ui::TableJSONWidget) {
16✔
11
    ui->setupUi(this);
16✔
12
    connect(ui->load_json_btn, &QPushButton::clicked, this, &TableJSONWidget::onLoadJsonClicked);
16✔
13
    connect(ui->apply_json_btn, &QPushButton::clicked, this, &TableJSONWidget::onUpdateTableClicked);
16✔
14
    connect(ui->save_json_btn, &QPushButton::clicked, this, &TableJSONWidget::onSaveJsonClicked);
16✔
15
}
16✔
16

17
TableJSONWidget::~TableJSONWidget() { delete ui; }
32✔
18

19
void TableJSONWidget::setJsonText(QString const & text) {
4✔
20
    if (ui->json_text_edit) ui->json_text_edit->setPlainText(text);
4✔
21
}
4✔
22

23
QString TableJSONWidget::getJsonText() const {
7✔
24
    return ui->json_text_edit ? ui->json_text_edit->toPlainText() : QString();
7✔
25
}
26

27
void TableJSONWidget::onLoadJsonClicked() {
1✔
28
    QString filename = m_forcedLoadPath;
1✔
29
    if (filename.isEmpty()) {
1✔
NEW
30
        filename = QFileDialog::getOpenFileName(this, "Load Table JSON", QString(), "JSON Files (*.json);;All Files (*)");
×
31
    }
32
    if (filename.isEmpty()) return;
1✔
33
    QFile file(filename);
1✔
34
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
1✔
NEW
35
        QMessageBox::warning(this, "Error", QString("Could not open file: %1").arg(filename));
×
NEW
36
        return;
×
37
    }
38
    QTextStream in(&file);
1✔
39
    QString text = in.readAll();
1✔
40
    file.close();
1✔
41
    setJsonText(text);
1✔
42
}
1✔
43

44
void TableJSONWidget::onUpdateTableClicked() {
7✔
45
    emit updateRequested(getJsonText());
7✔
46
}
7✔
47

48
void TableJSONWidget::setForcedLoadPathForTests(QString const & path) {
1✔
49
    m_forcedLoadPath = path;
1✔
50
}
1✔
51

NEW
52
void TableJSONWidget::onSaveJsonClicked() {
×
NEW
53
    QString filename = QFileDialog::getSaveFileName(this, "Save Table JSON", QString(), "JSON Files (*.json);;All Files (*)");
×
NEW
54
    if (filename.isEmpty()) return;
×
NEW
55
    if (!filename.endsWith(".json", Qt::CaseInsensitive)) filename += ".json";
×
NEW
56
    QFile file(filename);
×
NEW
57
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
×
NEW
58
        QMessageBox::warning(this, "Error", QString("Could not open file for writing: %1").arg(filename));
×
NEW
59
        return;
×
60
    }
NEW
61
    QTextStream out(&file);
×
NEW
62
    out << getJsonText();
×
NEW
63
    file.close();
×
NEW
64
}
×
65

66

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc