feat: populate all table columns
This commit is contained in:
@@ -28,14 +28,16 @@
|
|||||||
};
|
};
|
||||||
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
|
||||||
libPath = with pkgs; lib.makeLibraryPath [
|
libPath =
|
||||||
libxkbcommon
|
with pkgs;
|
||||||
libGL
|
lib.makeLibraryPath [
|
||||||
wayland
|
libxkbcommon
|
||||||
fontconfig
|
libGL
|
||||||
libinput
|
wayland
|
||||||
libgbm
|
fontconfig
|
||||||
];
|
libinput
|
||||||
|
libgbm
|
||||||
|
];
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -55,8 +57,8 @@
|
|||||||
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${libPath}";
|
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${libPath}";
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
exec fish
|
|
||||||
echo Entered Rust dev shell for project SoftwareManager-rs
|
echo Entered Rust dev shell for project SoftwareManager-rs
|
||||||
|
exec fish
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
+19
-13
@@ -10,7 +10,7 @@ slint::include_modules!();
|
|||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let ui = AppWindow::new()?;
|
let ui = AppWindow::new()?;
|
||||||
let ui_weak = ui.as_weak();
|
let ui_weak = ui.as_weak();
|
||||||
let items = Rc::new(VecModel::<StandardListViewItem>::from(Vec::new()));
|
let items = Rc::new(VecModel::<[StandardListViewItem; 4]>::from(Vec::new()));
|
||||||
|
|
||||||
let items_clone = items.clone();
|
let items_clone = items.clone();
|
||||||
ui.on_request_text_input(move |text| {
|
ui.on_request_text_input(move |text| {
|
||||||
@@ -23,13 +23,25 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
let elapsed_time = now.elapsed();
|
let elapsed_time = now.elapsed();
|
||||||
println!("Search took {} seconds", elapsed_time.as_secs());
|
println!("Search took {} seconds", elapsed_time.as_secs());
|
||||||
|
|
||||||
let new_items: Vec<StandardListViewItem> = match response {
|
let new_items: Vec<[StandardListViewItem; 4]> = match response {
|
||||||
Ok(softwares) => softwares
|
Ok(softwares) => softwares
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|s| StandardListViewItem::from(s.title.as_str()))
|
.map(|s| {
|
||||||
|
[
|
||||||
|
StandardListViewItem::from(s.title.as_str()),
|
||||||
|
StandardListViewItem::from(s.author.as_str()),
|
||||||
|
StandardListViewItem::from(s.seeders.as_str()),
|
||||||
|
StandardListViewItem::from(s.leechers.as_str()),
|
||||||
|
]
|
||||||
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|
||||||
Err(e) => vec![StandardListViewItem::from(format!("Error: {}", e).as_str())],
|
Err(e) => vec![[
|
||||||
|
StandardListViewItem::from(format!("Error: {}", e).as_str()),
|
||||||
|
StandardListViewItem::from(format!("Error: {}", e).as_str()),
|
||||||
|
StandardListViewItem::from(format!("Error: {}", e).as_str()),
|
||||||
|
StandardListViewItem::from(format!("Error: {}", e).as_str()),
|
||||||
|
]],
|
||||||
};
|
};
|
||||||
|
|
||||||
items_clone.set_vec(new_items);
|
items_clone.set_vec(new_items);
|
||||||
@@ -46,17 +58,11 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_rows(
|
fn add_rows(
|
||||||
items: &Rc<VecModel<StandardListViewItem>>,
|
items: &Rc<VecModel<[StandardListViewItem; 4]>>,
|
||||||
table_model: &Rc<VecModel<ModelRc<StandardListViewItem>>>,
|
table_model: &Rc<VecModel<ModelRc<StandardListViewItem>>>,
|
||||||
) {
|
) {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
let row = Rc::new(VecModel::from(vec![
|
let row = Rc::new(VecModel::from(item.to_vec()));
|
||||||
item.clone(),
|
table_model.push(ModelRc::from(row));
|
||||||
StandardListViewItem::from("placeholder column 1"),
|
|
||||||
StandardListViewItem::from("placeholder column 2"),
|
|
||||||
StandardListViewItem::from("placeholder column 3"),
|
|
||||||
]));
|
|
||||||
|
|
||||||
table_model.push(ModelRc::from(row.clone()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ pub struct Software {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn search(value: &str) -> Result<Vec<Software>, reqwest::Error> {
|
pub async fn search(value: &str) -> Result<Vec<Software>, reqwest::Error> {
|
||||||
let api_url = "https://api.michijackson.xyz/search?q=".to_owned();
|
let api_url = "https://api.michijackson.xyz/search?q=".to_owned();
|
||||||
let results = reqwest::get(api_url + value).await?;
|
let results = reqwest::get(api_url + value).await?.error_for_status()?;
|
||||||
let text = results.text().await?;
|
let text = results.text().await?;
|
||||||
|
|
||||||
let v: Value = serde_json::from_str(&text).expect("Failed to parse JSON");
|
let v: Value = serde_json::from_str(&text).expect("Failed to parse JSON");
|
||||||
|
|||||||
Reference in New Issue
Block a user