diff options
-rw-r--r-- | bass_player.rb | 18 | ||||
-rw-r--r-- | main.qml | 2 | ||||
-rw-r--r-- | migrations/initial.rb | 6 | ||||
-rw-r--r-- | models.rb | 5 |
4 files changed, 15 insertions, 16 deletions
diff --git a/bass_player.rb b/bass_player.rb index 6cb73c4..b625523 100644 --- a/bass_player.rb +++ b/bass_player.rb @@ -12,7 +12,7 @@ module BassPlayer property(:duration) { '' } property(:current_song) { 0 } property(:model) { QML::ArrayModel.new(:title, :duration) } - property(:part_model) { + property(:segment_model) { QML::ArrayModel.new(:name, :from, :to) } @@ -54,23 +54,23 @@ module BassPlayer self.current_song = model[song][:title] puts "Setting current song to #{self.current_song}" end - part_model.clear - parts = Song.first(title: self.current_song).parts.map do |part| + segment_model.clear + segments = Song.first(title: self.current_song).segments.map do |segment| { - name: part.name, - from: ms_to_time(part.from), - to: ms_to_time(part.to) + name: segment.name, + from: ms_to_time(segment.from), + to: ms_to_time(segment.to) } end - for part in parts - part_model << part + for segment in segments + segment_model << segment end end def add_segment(name, from, to) song = Song.first(title: current_song) - Part.create( + Segment.create( name: name, from: from, to: to, song_id: song.id ) @@ -43,7 +43,7 @@ ApplicationWindow { TableView { id: songPartTable - model: song.part_model + model: song.segment_model Layout.fillHeight: true Layout.fillWidth: true Layout.alignment: Qt.AlignTop diff --git a/migrations/initial.rb b/migrations/initial.rb index b19aba3..a882142 100644 --- a/migrations/initial.rb +++ b/migrations/initial.rb @@ -7,14 +7,12 @@ DB.create_table(:songs) do String :title Integer :duration String :path - - foreign_key :song_id, :songs end -DB.create_table(:parts) do +DB.create_table(:segments) do primary_key :id String :name Integer :from Integer :to - Integer :song_id + foreign_key :song_id, :songs end @@ -2,8 +2,9 @@ require 'sequel' DB = Sequel.connect('sqlite:///tmp/bass-player.db') class Song < Sequel::Model - one_to_many :parts + one_to_many :segments end -class Part < Sequel::Model +class Segment < Sequel::Model + many_to_one :song end |