Skip to content

Commit 4ce53cb

Browse files
committed
[gui]
starting to integrate filter stuff into gui
1 parent ba139a0 commit 4ce53cb

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

function-grep/src/filter/general_filters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ impl HasFilterInformation for FunctionWithParameterRust {
119119
}
120120

121121
fn description(&self) -> String {
122-
todo!()
122+
"Find a function with a given parameter".to_string()
123123
}
124124

125125
fn supports(&self) -> Self::Supports {
126126
Language("Rust".to_owned())
127127
}
128128

129129
fn attributes(&self) -> HashMap<Attribute, AttributeType> {
130-
todo!()
130+
HashMap::from([(Attribute("Name".to_string()), AttributeType::String)])
131131
}
132132

133133
type Supports = Language;

git-function-history-gui/src/lib.rs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod types;
22

3-
use std::{sync::mpsc, time::Duration};
3+
use std::{collections::HashMap, sync::mpsc, time::Duration};
44

55
use eframe::{
66
self,
@@ -407,17 +407,24 @@ impl eframe::App for MyEguiApp {
407407
ui.selectable_value(
408408
&mut self.history_filter_type,
409409
HistoryFilterType::PL(
410-
filter
411-
.1
412-
.attributes()
413-
.into_iter()
414-
.map(|(attr, kind)| {
415-
(
416-
attr.to_string(),
417-
kind.to_string(),
418-
)
419-
})
420-
.collect(),
410+
if let function_grep::filter::FilterType::All(filter) =
411+
filter.1
412+
{
413+
filter
414+
.attributes()
415+
.into_iter()
416+
.map(|(attr, kind)| {
417+
(
418+
attr.to_string(
419+
),
420+
kind.to_string(
421+
),
422+
)
423+
})
424+
.collect()
425+
} else {
426+
HashMap::new()
427+
},
421428
filter.1,
422429
),
423430
filter.0,
@@ -446,7 +453,23 @@ impl eframe::App for MyEguiApp {
446453
ui.label(desc.to_string());
447454
ui.add(TextEdit::singleline(field));
448455
});
449-
})
456+
if let function_grep::filter::FilterType::Many(_) = filters {
457+
458+
// TODO: update history filter type
459+
// hashmap to keep track of if a field
460+
// is removed
461+
let resp = ui.add(Button::new("-"));
462+
if resp.clicked() {
463+
}
464+
}
465+
});
466+
if let function_grep::filter::FilterType::Many(_) = filters {
467+
let resp = ui.add(Button::new("add field"));
468+
if resp.clicked() {
469+
let total = inputs.len()+ 1;
470+
inputs.insert(format!("field{total}"), String::new());
471+
}
472+
}
450473
}
451474
}
452475
let resp = ui.add(Button::new("Go"));

git-function-history-gui/src/types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ pub enum HistoryFilterType {
88
FileAbsolute(String),
99
FileRelative(String),
1010
Directory(String),
11+
// TODO: if filter type is a many and it has more than on filter
12+
// 1. if you can pick which language to use
13+
// 2. or you can add or remove a field to apply to the filter
1114
PL(HashMap<String, String>, FilterType<'static>),
1215
None,
1316
}

0 commit comments

Comments
 (0)