Skip to content

Commit

Permalink
better formatting of event times
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolcl committed Sep 8, 2024
1 parent 6283952 commit 065a0c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2024-09-08
* better formatting of event times in 'hh:mm:ss.zzz'

2023-12-25
* Release 1.4.0

Expand Down
15 changes: 6 additions & 9 deletions src/sequenceitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@ class SequenceItem
SequenceItem(double seconds,
unsigned int ticks,
unsigned int track,
drumstick::ALSA::SequencerEvent* ev):
m_seconds(seconds),
m_ticks(ticks),
m_track(track),
m_event(ev)
drumstick::ALSA::SequencerEvent *ev)
: m_seconds(seconds)
, m_ticks(ticks)
, m_track(track)
, m_event(ev)
{}

virtual ~SequenceItem()
{}

bool operator==(const SequenceItem& other) const;
bool operator==(const SequenceItem &other) const;

double getSeconds() const { return m_seconds; }
unsigned int getTicks() const { return m_ticks; }
Expand Down
12 changes: 11 additions & 1 deletion src/sequencemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,17 @@ SequenceModel::event_ticks(const SequencerEvent *ev) const
QString
SequenceModel::event_time(const SequenceItem& itm) const
{
return QString::number(itm.getSeconds(), 'f', 4);
constexpr quint64 onehour = 60 * 60 * 1000;
constexpr quint64 oneminute = 60 * 1000;
auto ms = static_cast<quint64>(itm.getSeconds() * 1000);
QTime t = QTime::fromMSecsSinceStartOfDay(ms);
if (ms >= onehour) {
return t.toString("h:mm:ss.zzz");
} else if (ms >= oneminute) {
return t.toString("m:ss.zzz");
} else {
return t.toString("s.zzz");
}
}

QString
Expand Down

0 comments on commit 065a0c7

Please sign in to comment.