1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use re_log_types::StoreKind;
use re_viewer_context::{UiLayout, ViewerContext};

use crate::item_ui::entity_db_button_ui;

impl crate::DataUi for re_smart_channel::SmartChannelSource {
    fn data_ui(
        &self,
        ctx: &ViewerContext<'_>,
        ui: &mut egui::Ui,
        ui_layout: UiLayout,
        _query: &re_chunk_store::LatestAtQuery,
        _db: &re_entity_db::EntityDb,
    ) {
        ui.label(self.to_string());

        if ui_layout.is_single_line() {
            return;
        }

        // TODO(emilk): show whether we're still connected to this data source

        // Find all stores from this data source
        // (e.g. find the recordings and blueprint in this .rrd file).
        let mut recordings = vec![];
        let mut blueprints = vec![];

        for other in ctx
            .store_context
            .bundle
            .entity_dbs()
            .filter(|db| db.data_source.as_ref() == Some(self))
        {
            let is_clone = other.cloned_from().is_some();
            if is_clone {
                // Clones are not really from this data source (e.g. a cloned blueprint
                continue;
            }

            match other.store_kind() {
                StoreKind::Recording => {
                    recordings.push(other);
                }
                StoreKind::Blueprint => {
                    blueprints.push(other);
                }
            }
        }

        recordings.sort_by_key(|entity_db| entity_db.store_info().map(|info| info.started));
        blueprints.sort_by_key(|entity_db| entity_db.store_info().map(|info| info.started));

        ui.scope(|ui| {
            ui.spacing_mut().item_spacing.y = 0.0;
            if !recordings.is_empty() {
                ui.add_space(8.0);
                ui.strong("Recordings from this data source");
                for entity_db in recordings {
                    entity_db_button_ui(ctx, ui, entity_db, true);
                }
            }

            if !blueprints.is_empty() {
                ui.add_space(8.0);
                ui.strong("Blueprints from this data source");
                for entity_db in blueprints {
                    entity_db_button_ui(ctx, ui, entity_db, true);
                }
            }
        });
    }
}