Skip to main content

How to add a new feature

This tutorial explains how to extend Validrive with new functionality. Validrive is structured into four main layers: UI, Data, Automation, and Integration (signals/slots). Depending on your feature, u will touch one or more of these layers.

1. UI layer

  • Located in PySide6 classes (MainWindow, FilterPanel, dialogs).
  • Add buttons, menus, or dialogs for new actions.
  • Store new widgets as self.<name> so they can be updated later.

Example: Adding a new filter button

btn_custom = QPushButton("Custom Filter")
btn_custom.clicked.connect(self.apply_custom_filter)
self.filter_panel.layout().addWidget(btn_custom)

2. Data layer

  • Located in pandas helpers (read_csv_safely, normalize_numeric_columns, save_df).
  • Add new columns, validators, or data transformations.
  • Use df_backup and undo_last_change() to keep undo functionality consistent.

Example: Adding a derived column

df["speed_kmh"] = df["speed_mps"] * 3.6

3. Automation layer (Selenium)

  • Located in SeleniumController and related helpers (init_driver, create_list, play_video).
  • Extend this layer if your feature interacts with Daredeevil (new navigation, scraping, or playback logic).
  • Add new methods as controller slots so they can run in the background thread.

Example: Adding a new replay mode

def replay_slowmotion(self, caps_number, start_time):
self.go_to_event(caps_number, start_time)
self.driver.execute_script("setPlaybackRate(0.5);")

4. Signals & integration

  • Signals connect UI actions to the background automation.
  • Define a new sig_... in the UI and handle it in the controller.
  • Keep names consistent (sig_feature, on_feature).

Example: Adding a new signal

# in MainWindow
self.sig_custom_action.emit(caps_number, start_time)

# in SeleniumController
@Slot(str, float)
def on_custom_action(self, caps_number, start_time):
self.replay_slowmotion(caps_number, start_time)

5. Putting it together

When adding a feature:

  1. UI → Add button/menu/dialog.
  2. Data → Adjust DataFrame if needed.
  3. Automation → Extend SeleniumController if browser interaction is required.
  4. Signals → Connect UI events to automation methods.

Example walkthroughs:

  • New filter: add UI control in FilterPanel, implement filter logic on df, update preview.
  • New event action: add button in MainWindow, add signal, implement slot in SeleniumController