mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
implement suggestion titles, search in history, show bookmark as icon indicator
This commit is contained in:
parent
2b2ffd00de
commit
73c35d25d8
8 changed files with 71 additions and 19 deletions
|
|
@ -27,10 +27,10 @@ impl History {
|
|||
// Actions
|
||||
|
||||
/// Create new history record
|
||||
pub fn open(&self, request: GString) {
|
||||
pub fn open(&self, request: GString, title: Option<GString>) {
|
||||
let mut memory = self.memory.borrow_mut();
|
||||
if !memory.open(&request) {
|
||||
memory.add(Item::create(0, request)) // @TODO
|
||||
memory.add(Item::create(0, request, title)) // @TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,4 +50,9 @@ impl History {
|
|||
pub fn recently_closed(&self, limit: Option<usize>) -> Vec<Item> {
|
||||
self.memory.borrow().recently_closed(limit)
|
||||
}
|
||||
|
||||
/// Get unordered Items vector contains `request`
|
||||
pub fn contains_request(&self, request: &str, limit: Option<usize>) -> Vec<Item> {
|
||||
self.memory.borrow().contains_request(request, limit)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use gtk::glib::{DateTime, GString};
|
|||
pub struct Item {
|
||||
pub id: i64,
|
||||
pub request: GString,
|
||||
pub title: Option<GString>,
|
||||
pub opened: Vec<DateTime>,
|
||||
pub closed: Vec<DateTime>,
|
||||
}
|
||||
|
|
@ -11,10 +12,11 @@ pub struct Item {
|
|||
impl Item {
|
||||
// Constructors
|
||||
|
||||
pub fn create(id: i64, request: GString) -> Self {
|
||||
pub fn create(id: i64, request: GString, title: Option<GString>) -> Self {
|
||||
Self {
|
||||
id,
|
||||
request,
|
||||
title,
|
||||
opened: vec![now()],
|
||||
closed: vec![],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,20 @@ impl Memory {
|
|||
}
|
||||
recent
|
||||
}
|
||||
|
||||
/// Get unordered Items vector contains `request`
|
||||
pub fn contains_request(&self, request: &str, limit: Option<usize>) -> Vec<Item> {
|
||||
let mut items: Vec<Item> = Vec::new();
|
||||
for (i, item) in self.0.iter().enumerate() {
|
||||
if limit.is_some_and(|l| i > l) {
|
||||
break;
|
||||
}
|
||||
if item.request.contains(request) {
|
||||
items.push(item.clone())
|
||||
}
|
||||
}
|
||||
items
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Memory {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue