diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2021-11-21 18:03:11 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@eddy.dev> | 2021-11-29 22:24:37 +0100 |
commit | 9d92121a67188995ced4aa2cc26d320475bb8c94 (patch) | |
tree | 0625499feaa11638e2df2139e87982c839b3c371 /ablist.py | |
parent | fa5b0f760892bcbc2548ec0e516a716bd854ceef (diff) |
Fixed some bugs, added some midi buttons
Diffstat (limited to 'ablist.py')
-rw-r--r-- | ablist.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ablist.py b/ablist.py new file mode 100644 index 0000000..f37905b --- /dev/null +++ b/ablist.py @@ -0,0 +1,22 @@ + +def hhmmss(ms): + # s = 1000 + # m = 60000 + # h = 360000 + h, r = divmod(ms, 36000) + m, r = divmod(r, 60000) + s, _ = divmod(r, 1000) + return ("%d:%02d:%02d" % (h,m,s)) if h else ("%d:%02d" % (m,s)) + +class AbListModel(QAbstractListModel): + def __init__(self, *args, **kwargs): + super(AbListModel, self).__init__(*args, **kwargs) + self.abList = list() + + def data(self, index, role): + if role == Qt.DisplayRole: + ab = self.abList[index.row()] + return f"{hhmmss(ab[0])} - {hhmmss(ab[1])}" + + def rowCount(self, index): + return len(self.abList) |