Skip to content

Commit

Permalink
combine model files
Browse files Browse the repository at this point in the history
  • Loading branch information
bramtayl committed Nov 15, 2024
1 parent 0571f1f commit d9254b4
Show file tree
Hide file tree
Showing 21 changed files with 495 additions and 560 deletions.
4 changes: 2 additions & 2 deletions src/abstract_rational/AbstractRational.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ void add_abstract_rational_to_json(nlohmann::json &json_row,

template <std::derived_from<AbstractRational> SubRational>
auto json_field_to_abstract_rational(const nlohmann::json &json_row,
const char *field_name) -> SubRational {
const char *field_name) {
if (json_row.contains(field_name)) {
return SubRational(json_row[field_name]);
}
return {};
return SubRational();
}

void add_int_to_json(nlohmann::json &json_object, const char *field_name,
Expand Down
3 changes: 0 additions & 3 deletions src/other/justly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
#include "named/program/instrument/Instrument.hpp"
#include "named/program/percussion_set/PercussionSet.hpp"
#include "other/other.hpp"
#include "row/RowsModel.hpp"
#include "row/chord/ChordsModel.hpp"
#include "row/note/pitched_note/PitchedNotesModel.hpp"
#include "song/Player.hpp"
#include "song/Song.hpp"
#include "song/SongEditor.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/other/other.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "other/other.hpp"

#include <QWidget>
#include <cmath>

auto get_number_schema(const char *type, int minimum,
Expand Down
2 changes: 0 additions & 2 deletions src/other/other.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <QtGlobal>
#include <nlohmann/json.hpp>

class QWidget;

template <typename Thing>
[[nodiscard]] static auto get_reference(Thing *thing_pointer) -> Thing & {
Q_ASSERT(thing_pointer != nullptr);
Expand Down
1 change: 0 additions & 1 deletion src/row/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ add_subdirectory(chord)
add_subdirectory(note)

target_sources(JustlyLibrary PRIVATE
"RowsModel.hpp"
"Row.cpp"
"Row.hpp"
)
7 changes: 0 additions & 7 deletions src/row/Row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,3 @@ auto Row::get_fields_schema() -> nlohmann::json {
{"words", nlohmann::json({{"type", "string"}})}});
}

auto json_field_to_interval(const nlohmann::json &json_row) -> Interval {
return json_field_to_abstract_rational<Interval>(json_row, "interval");
}

void add_interval_to_json(nlohmann::json &json_row, const Interval &interval) {
add_abstract_rational_to_json(json_row, interval, "interval");
}
18 changes: 0 additions & 18 deletions src/row/Row.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <string>
#include <utility>

#include "abstract_rational/interval/Interval.hpp"
#include "abstract_rational/rational/Rational.hpp"
#include "named/Named.hpp"

Expand Down Expand Up @@ -100,30 +99,13 @@ auto get_rational_fields_schema() -> nlohmann::json;
void add_pitched_fields_to_schema(nlohmann::json &schema);
void add_unpitched_fields_to_schema(nlohmann::json &schema);

template <std::derived_from<Row> SubRow>
void add_pitched_fields_to_json(nlohmann::json &json_row, const SubRow& sub_row) {
add_named_to_json(json_row, sub_row.instrument_pointer);
add_interval_to_json(json_row, sub_row.interval);
}

template <std::derived_from<Row> SubRow>
void add_unpitched_fields_to_json(nlohmann::json &json_row, const SubRow& sub_row) {
add_named_to_json(json_row, sub_row.percussion_set_pointer);
add_named_to_json(json_row, sub_row.percussion_instrument_pointer);
}

template <std::derived_from<Row> SubRow>
void add_row_array_schema(nlohmann::json &schema) {
schema[SubRow::get_plural_field_for()] = nlohmann::json(
{{"type", "array"},
{"items", get_object_schema(SubRow::get_fields_schema())}});
}

[[nodiscard]] auto json_field_to_interval(const nlohmann::json &json_row) -> Interval;

void add_interval_to_json(nlohmann::json &json_row,
const Interval &interval);

template <typename SubType>
auto variant_to(const QVariant &variant) -> SubType {
Q_ASSERT(variant.canConvert<SubType>());
Expand Down
263 changes: 0 additions & 263 deletions src/row/RowsModel.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/row/chord/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
target_sources(JustlyLibrary PRIVATE
"Chord.cpp"
"Chord.hpp"
"ChordsModel.cpp"
"ChordsModel.hpp"
)
Loading

0 comments on commit d9254b4

Please sign in to comment.