[Replay] Refactor: extract replay playback logic into single class (#7060)

* [Replay] Refactor: consolidate replay logic into single class

* fixes
This commit is contained in:
RickyRister 2026-08-02 19:22:33 -07:00 • committed by GitHub
parent ca1c063687
commit b44dcf5951
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 320 additions and 237 deletions

View file

@ -18,57 +18,25 @@ class QTimer;
class ReplayTimelineWidget : public QWidget
{
Q_OBJECT
signals:
void processNextEvent(EventProcessingOptions options);
void replayFinished();
void rewound();
void timeClicked(int newTime);
private:
enum PlaybackMode
{
NORMAL_PLAYBACK,
FORWARD_SKIP,
BACKWARD_SKIP
};
static constexpr int TIMER_INTERVAL_MS = 200;
static constexpr int BIN_LENGTH = 5000;
QTimer *replayTimer;
QTimer *rewindBufferingTimer;
QList<int> replayTimeline;
QList<int> histogram;
int maxBinValue, maxTime;
qreal timeScaleFactor;
int currentVisualTime; // time currently displayed by the timeline
int currentProcessedTime; // time that events are currently processed up to. Could differ from visual time due to
// rewind buffering
int currentEvent;
int maxBinValue = 1;
int maxTime = 1;
void skipToTime(int newTime, bool doRewindBuffering);
void handleBackwardsSkip(bool doRewindBuffering);
void processRewind();
void processNewEvents(PlaybackMode playbackMode);
private slots:
void replayTimerTimeout();
int currentTime = 0;
public:
static constexpr int SMALL_SKIP_MS = 1000;
static constexpr int BIG_SKIP_MS = 10000;
explicit ReplayTimelineWidget(QWidget *parent = nullptr);
void setTimeline(const QList<int> &_replayTimeline);
void setTimeline(const QList<int> &replayTimeline);
[[nodiscard]] QSize sizeHint() const override;
[[nodiscard]] QSize minimumSizeHint() const override;
void setTimeScaleFactor(qreal _timeScaleFactor);
[[nodiscard]] int getCurrentEvent() const
{
return currentEvent;
}
public slots:
void startReplay();
void stopReplay();
void skipByAmount(int amount); // use a negative amount to skip backwards
void setCurrentTime(int time);
protected:
void paintEvent(QPaintEvent *event) override;