Sample Lyricist Tree Node script
Jump to navigation
Jump to search
' Sample Lyricist Tree script
'
' This script adds new Lyricist node that contains all lyricists in Library as its
' subnodes. The script further allows to edit individual lyricist or drag&drop tracks
' to lyricist nodes.
Sub OnStartup
Set Tree = SDB.MainTree
Set Node = Tree.CreateNode
Node.Caption = "Lyricist"
Node.IconIndex = 0
Node.UseScript = Script.ScriptPath
Node.OnFillChildren = "FillLyricists"
Tree.AddNode Tree.Node_Artist, Node, 1 ' Insert after the node
Node.HasChildren = True
End Sub
Sub FillLyricists( Node)
Set Tree = SDB.MainTree
Node.HasChildren = false ' To delete all old children
Set Iter = SDB.Database.OpenSQL( "SELECT DISTINCT TextData FROM AddSongInfo WHERE DataType=200 Order BY TextData")
While Not Iter.EOF
Set NewNode = Tree.CreateNode
NewNode.Caption = Iter.StringByIndex(0)
NewNode.CustomData = Iter.StringByIndex(0)
NewNode.IconIndex = 0
NewNode.UseScript = Script.ScriptPath
NewNode.OnFillTracksFunct = "FillLyricist"
NewNode.OnEdited = "LyricistEdited"
NewNode.OnDragDrop = "LyricistDragDrop"
Tree.AddNode Node, NewNode, 3 ' Add as the last child
Iter.Next
WEnd
End Sub
Sub FillLyricist( Node)
Set Trcks = SDB.MainTracksWindow
Trcks.AddTracksFromQuery( "and Songs.ID in (SELECT IDSong FROM AddSongInfo WHERE DataType=200 AND TextData='" & Node.CustomData & "')")
Trcks.FinishAdding
End Sub
Sub LyricistEdited( Node, NewText)
SDB.Database.ExecSQL( "UPDATE AddSongInfo SET TextData='" & NewText & "' WHERE DataType=200 and TextData='" & Node.CustomData & "'")
Node.CustomData = NewText
Node.Caption = NewText
End Sub
Function LyricistDragDrop( destNode, srcNode, SongList, DropType, Test)
If Test Then
LyricistDragDrop = 2 ' Move operation
Else
Dim i, itm
For i=0 To SongList.Count-1
Set itm = SongList.Item(i)
itm.Lyricist = destNode.CustomData
itm.UpdateDB
Next
End If
End Function