feat: populate all table columns
This commit is contained in:
@@ -28,14 +28,16 @@
|
||||
};
|
||||
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
|
||||
libPath = with pkgs; lib.makeLibraryPath [
|
||||
libxkbcommon
|
||||
libGL
|
||||
wayland
|
||||
fontconfig
|
||||
libinput
|
||||
libgbm
|
||||
];
|
||||
libPath =
|
||||
with pkgs;
|
||||
lib.makeLibraryPath [
|
||||
libxkbcommon
|
||||
libGL
|
||||
wayland
|
||||
fontconfig
|
||||
libinput
|
||||
libgbm
|
||||
];
|
||||
|
||||
in
|
||||
{
|
||||
@@ -55,8 +57,8 @@
|
||||
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${libPath}";
|
||||
|
||||
shellHook = ''
|
||||
exec fish
|
||||
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>> {
|
||||
let ui = AppWindow::new()?;
|
||||
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();
|
||||
ui.on_request_text_input(move |text| {
|
||||
@@ -23,13 +23,25 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
let elapsed_time = now.elapsed();
|
||||
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
|
||||
.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(),
|
||||
|
||||
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);
|
||||
@@ -46,17 +58,11 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
|
||||
fn add_rows(
|
||||
items: &Rc<VecModel<StandardListViewItem>>,
|
||||
items: &Rc<VecModel<[StandardListViewItem; 4]>>,
|
||||
table_model: &Rc<VecModel<ModelRc<StandardListViewItem>>>,
|
||||
) {
|
||||
for item in items.iter() {
|
||||
let row = Rc::new(VecModel::from(vec![
|
||||
item.clone(),
|
||||
StandardListViewItem::from("placeholder column 1"),
|
||||
StandardListViewItem::from("placeholder column 2"),
|
||||
StandardListViewItem::from("placeholder column 3"),
|
||||
]));
|
||||
|
||||
table_model.push(ModelRc::from(row.clone()));
|
||||
let row = Rc::new(VecModel::from(item.to_vec()));
|
||||
table_model.push(ModelRc::from(row));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ pub struct Software {
|
||||
#[tokio::main]
|
||||
pub async fn search(value: &str) -> Result<Vec<Software>, reqwest::Error> {
|
||||
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 v: Value = serde_json::from_str(&text).expect("Failed to parse JSON");
|
||||
|
||||
Reference in New Issue
Block a user