summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Linares <matias.linares@comprandoengrupo.net>2022-06-24 09:37:33 -0300
committerMatias Linares <matias.linares@comprandoengrupo.net>2022-06-24 09:37:33 -0300
commitb0d2b24c6f552b5a54b0f3c3c2b00d596a5ad9c1 (patch)
treebb1a45adc32956e3174024db0f69ad0b7b977c5a
parent51510f09b4bcaf21f75c3133aa6ecbe97c8139b8 (diff)
downloadbass-player-b0d2b24c6f552b5a54b0f3c3c2b00d596a5ad9c1.tar.gz
Change model Part to Segment
-rw-r--r--bass_player.rb18
-rw-r--r--main.qml2
-rw-r--r--migrations/initial.rb6
-rw-r--r--models.rb5
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
)
diff --git a/main.qml b/main.qml
index d0dda5b..ab7a07a 100644
--- a/main.qml
+++ b/main.qml
@@ -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
diff --git a/models.rb b/models.rb
index 8548fc6..777a50f 100644
--- a/models.rb
+++ b/models.rb
@@ -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