]> git.sesse.net Git - nageru/blobdiff - mainwindow.h
Serialize state to disk between runs, using SQLite.
[nageru] / mainwindow.h
index 24eea609e03bbdf24049018b03cb9193b15cfa38..3621d32ce65f8467ad99d3941f78a7d2e3c16672 100644 (file)
@@ -5,7 +5,8 @@
 #include <sys/types.h>
 #include <QMainWindow>
 
-#include "clip_list.h"
+#include "db.h"
+#include "state.pb.h"
 
 namespace Ui {
 class MainWindow;
@@ -25,6 +26,7 @@ public:
 
 private:
        Player *preview_player, *live_player;
+       DB db;
 
        // State when doing a scrub operation on a timestamp with the mouse.
        bool scrubbing = false;
@@ -40,6 +42,22 @@ private:
        int last_mousewheel_camera_row = -1;
        int leftover_angle_degrees = 0;
 
+       // Some operations, notably scrubbing and scrolling, happen in so large increments
+       // that we want to group them instead of saving to disk every single time.
+       // If they happen (ie., we get a callback from the model that it's changed) while
+       // currently_deferring_model_changes, we fire off this timer. If it manages to elapse
+       // before some other event happens, we count the event. (If the other event is of the
+       // same kind, we just fire off the timer anew instead of taking any action.)
+       QTimer *defer_timeout;
+       std::string deferred_change_id;
+       StateProto deferred_state;
+
+       // Before a change that should be deferred (see above), currently_deferring_model_changes
+       // must be set to true, and current_change_id must be given contents describing what's
+       // changed to avoid accidental grouping.
+       bool currently_deferring_model_changes = false;
+       std::string current_change_id;
+
        void cue_in_clicked();
        void cue_out_clicked();
        void queue_clicked();
@@ -52,6 +70,10 @@ private:
        void playlist_remove();
        void playlist_move(int delta);
 
+       void defer_timer_expired();
+       void content_changed();  // In clip_list or play_list.
+       void state_changed(const StateProto &state);  // Called post-filtering.
+
        enum Rounding { FIRST_AT_OR_AFTER, LAST_BEFORE };
        void preview_single_frame(int64_t pts, unsigned stream_idx, Rounding rounding);