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

paulmthompson / WhiskerToolbox / 17816075334

18 Sep 2025 02:21AM UTC coverage: 71.944% (-0.06%) from 72.003%
17816075334

push

github

paulmthompson
clang tidy fixes

9 of 15 new or added lines in 4 files covered. (60.0%)

194 existing lines in 7 files now uncovered.

39627 of 55080 relevant lines covered (71.94%)

1299.21 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 <QFile>
5
#include <QFileDialog>
6
#include <QMessageBox>
7
#include <QTextStream>
8

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

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

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

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

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

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

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

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