diff --git a/examples/kefia/0001-Fix-compile-with-stable.patch b/examples/kefia/0001-Fix-compile-with-stable.patch index 9500acd4..26ac6ab0 100644 --- a/examples/kefia/0001-Fix-compile-with-stable.patch +++ b/examples/kefia/0001-Fix-compile-with-stable.patch @@ -1,7 +1,7 @@ -From 8356d25ae66ebe130a73e9782a9e3134b94a293d Mon Sep 17 00:00:00 2001 +From 5385434a287fb862ea224dc7131418060e382b2f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 28 Feb 2018 17:57:59 +0100 -Subject: [PATCH 1/2] Fix compile with stable +Subject: [PATCH 1/8] Fix compile with stable --- Cargo.lock | 18 +++++++++--------- @@ -76,5 +76,5 @@ index 3b80ca6..162d6ab 100644 }; let selected = Some(&self.selected); -- -2.17.1 +2.32.0 diff --git a/examples/kefia/0002-Port-to-qmetaobject-rs.patch b/examples/kefia/0002-Port-to-qmetaobject-rs.patch index 138474c7..1349306d 100644 --- a/examples/kefia/0002-Port-to-qmetaobject-rs.patch +++ b/examples/kefia/0002-Port-to-qmetaobject-rs.patch @@ -1,7 +1,7 @@ -From 5c2c980b83a571523206e494313b8c6d6b306aaf Mon Sep 17 00:00:00 2001 +From 1bb942f9ef45e278fb05680cd24a6422c501d6bd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 4 Jun 2018 18:00:30 +0200 -Subject: [PATCH 2/2] Port to qmetaobject-rs +Subject: [PATCH 2/8] Port to qmetaobject-rs --- Cargo.toml | 2 +- @@ -294,5 +294,5 @@ index 162d6ab..c0ad025 100644 } } -- -2.21.0 +2.32.0 diff --git a/examples/kefia/0003-Update-to-2018-edition-upgrade-deps-and-fix-warnings.patch b/examples/kefia/0003-Update-to-2018-edition-upgrade-deps-and-fix-warnings.patch new file mode 100644 index 00000000..327415b5 --- /dev/null +++ b/examples/kefia/0003-Update-to-2018-edition-upgrade-deps-and-fix-warnings.patch @@ -0,0 +1,398 @@ +From b8ce8c6bdcd2cd40496f7caef3182a2dbe17930c Mon Sep 17 00:00:00 2001 +From: ivan tkachenko +Date: Thu, 15 Jul 2021 14:24:08 +0300 +Subject: [PATCH 3/8] Update to 2018 edition, upgrade deps and fix warnings + +--- + Cargo.lock | 216 +++++++++++++++++++++++++++++++++------------------- + Cargo.toml | 5 +- + src/main.rs | 21 +---- + src/view.rs | 6 +- + 4 files changed, 146 insertions(+), 102 deletions(-) + +diff --git a/Cargo.lock b/Cargo.lock +index 49cdf47..3bd71bb 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -1,150 +1,210 @@ ++# This file is automatically @generated by Cargo. ++# It is not intended for manual editing. + [[package]] + name = "aho-corasick" +-version = "0.6.1" ++version = "0.7.18" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" + dependencies = [ +- "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ++ "memchr", + ] + + [[package]] +-name = "kefia" +-version = "0.1.0" +-dependencies = [ +- "lazysort 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +- "qml 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)", +- "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +-] ++name = "byteorder" ++version = "1.4.3" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + + [[package]] +-name = "kernel32-sys" +-version = "0.2.2" ++name = "cc" ++version = "1.0.69" + source = "registry+https://github.com/rust-lang/crates.io-index" +-dependencies = [ +- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +- "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +-] ++checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" + + [[package]] +-name = "lazy_static" +-version = "0.2.2" ++name = "cfg-if" ++version = "1.0.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + + [[package]] +-name = "lazysort" +-version = "0.1.1" ++name = "cpp" ++version = "0.5.6" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "4875a08600be48dcc9cb6ee07f104a3e0752e95184dede6a30044d6480bf50e8" + dependencies = [ +- "rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", ++ "cpp_macros", + ] + + [[package]] +-name = "libc" +-version = "0.2.20" ++name = "cpp_build" ++version = "0.5.6" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "762705b71f4a8c5b65148de0e76bf18770c724ca2759f04ca29be9d508e1230d" ++dependencies = [ ++ "cc", ++ "cpp_common", ++ "lazy_static", ++ "proc-macro2", ++ "regex", ++ "syn", ++ "unicode-xid", ++] + + [[package]] +-name = "memchr" +-version = "1.0.1" ++name = "cpp_common" ++version = "0.5.6" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "df78ad28e5fe814285016779fb3d3b874520c799a847e6190bf2b834cc4ff283" + dependencies = [ +- "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ++ "lazy_static", ++ "proc-macro2", ++ "syn", + ] + + [[package]] +-name = "qml" +-version = "0.0.9" ++name = "cpp_macros" ++version = "0.5.6" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "4f93a21e618c10abc84ebb63ffa5952e1f7a4568b8141d542d5ef860e4a8fc25" + dependencies = [ +- "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +- "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ++ "aho-corasick", ++ "byteorder", ++ "cpp_common", ++ "if_rust_version", ++ "lazy_static", ++ "proc-macro2", ++ "quote", ++ "syn", + ] + + [[package]] +-name = "rand" +-version = "0.3.15" ++name = "if_rust_version" ++version = "1.0.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "46dbcb333e86939721589d25a3557e180b52778cb33c7fdfe9e0158ff790d5ec" ++ ++[[package]] ++name = "kefia" ++version = "0.1.0" + dependencies = [ +- "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ++ "lazysort", ++ "qmetaobject", ++ "regex", + ] + + [[package]] +-name = "regex" ++name = "lazy_static" ++version = "1.4.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" ++ ++[[package]] ++name = "lazysort" + version = "0.2.1" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "d0e22ff43b231e0e2f87d74984e53ebc73b90ae13397e041214fb07efc64168f" ++ ++[[package]] ++name = "log" ++version = "0.4.14" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" + dependencies = [ +- "aho-corasick 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", +- "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +- "regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +- "thread_local 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +- "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ++ "cfg-if", + ] + + [[package]] +-name = "regex-syntax" +-version = "0.4.0" ++name = "memchr" ++version = "2.4.0" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + + [[package]] +-name = "thread-id" +-version = "3.0.0" ++name = "proc-macro2" ++version = "1.0.27" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" + dependencies = [ +- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +- "libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", ++ "unicode-xid", + ] + + [[package]] +-name = "thread_local" +-version = "0.3.2" +-source = "registry+https://github.com/rust-lang/crates.io-index" ++name = "qmetaobject" ++version = "0.2.2" ++dependencies = [ ++ "cpp", ++ "cpp_build", ++ "lazy_static", ++ "log", ++ "qmetaobject_impl", ++ "qttypes", ++ "semver", ++] ++ ++[[package]] ++name = "qmetaobject_impl" ++version = "0.2.2" ++dependencies = [ ++ "proc-macro2", ++ "quote", ++ "syn", ++] ++ ++[[package]] ++name = "qttypes" ++version = "0.2.2" + dependencies = [ +- "thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +- "unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ++ "cpp", ++ "cpp_build", ++ "semver", + ] + + [[package]] +-name = "unreachable" +-version = "0.1.1" ++name = "quote" ++version = "1.0.9" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" + dependencies = [ +- "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ++ "proc-macro2", + ] + + [[package]] +-name = "utf8-ranges" +-version = "1.0.0" ++name = "regex" ++version = "1.5.4" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" ++dependencies = [ ++ "aho-corasick", ++ "memchr", ++ "regex-syntax", ++] + + [[package]] +-name = "void" +-version = "1.0.2" ++name = "regex-syntax" ++version = "0.6.25" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + + [[package]] +-name = "winapi" +-version = "0.2.8" ++name = "semver" ++version = "1.0.3" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "5f3aac57ee7f3272d8395c6e4f502f434f0e289fcd62876f70daa008c20dcabe" + + [[package]] +-name = "winapi-build" +-version = "0.1.1" ++name = "syn" ++version = "1.0.73" + source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" ++dependencies = [ ++ "proc-macro2", ++ "quote", ++ "unicode-xid", ++] + +-[metadata] +-"checksum aho-corasick 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f660b942762979b56c9f07b4b36bb559776fbad102f05d6771e1b629e8fd5bf" +-"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +-"checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" +-"checksum lazysort 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee054c4bd7fb801da8a7489e79af348e27c8ce95ec754875a80047f2b2600bb" +-"checksum libc 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "684f330624d8c3784fb9558ca46c4ce488073a8d22450415c5eb4f4cfb0d11b5" +-"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" +-"checksum qml 0.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5b41634e0699593958a59f2b574d09b18681aff08844afdfaebc7cdaffcbc6" +-"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d" +-"checksum regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4278c17d0f6d62dfef0ab00028feb45bd7d2102843f80763474eeb1be8a10c01" +-"checksum regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9191b1f57603095f105d317e375d19b1c9c5c3185ea9633a99a6dcbed04457" +-"checksum thread-id 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4437c97558c70d129e40629a5b385b3fb1ffac301e63941335e4d354081ec14a" +-"checksum thread_local 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7793b722f0f77ce716e7f1acf416359ca32ff24d04ffbac4269f44a4a83be05d" +-"checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91" +-"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" +-"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +-"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +-"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" ++[[package]] ++name = "unicode-xid" ++version = "0.2.2" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +diff --git a/Cargo.toml b/Cargo.toml +index 7a03132..dce8802 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -1,6 +1,7 @@ + [package] + name = "kefia" + version = "0.1.0" ++edition = "2018" + authors = ["White-Oak "] + exclude = [ + "res/*" +@@ -13,6 +14,6 @@ categories = ["gui"] + license = "MIT" + + [dependencies] +-regex = "0.2.1" +-lazysort = "0.1.1" ++regex = "1.5" ++lazysort = "0.2" + qmetaobject = { path = "../qmetaobject-rs/qmetaobject/"} +diff --git a/src/main.rs b/src/main.rs +index e32654f..b2f7f76 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -1,16 +1,12 @@ +-extern crate regex; +-#[macro_use] +-extern crate lazysort; +-extern crate qmetaobject; +- + use lazysort::*; + + use std::process::Command; ++ + use regex::*; + +-mod view; ++use self::view::*; + +-pub use view::*; ++mod view; + + fn main() { + let output = Command::new("yaourt") +@@ -45,14 +41,3 @@ pub struct Package { + pub meta: Vec, + pub selected: bool, + } +- +-//impl Into for (String, String, String, String) { +-// fn into(self) -> Package { +-// Package { +-// name: self.0, +-// group: self.1 +-// version: self.2 +-// meta: +-// } +-// } +-//} +diff --git a/src/view.rs b/src/view.rs +index c0ad025..4a69519 100644 +--- a/src/view.rs ++++ b/src/view.rs +@@ -1,7 +1,5 @@ +-use qmetaobject; + use qmetaobject::*; + use lazysort::*; +-use std; + + use super::Package; + +@@ -66,7 +64,7 @@ pub struct SelectedPackages { + } + + fn filter_for_qml(vec: &[Package], +- filter: &Fn(&&Package) -> bool, ++ filter: &dyn Fn(&&Package) -> bool, + selecteds: Option<&SelectedPackages>) + -> Vec { + vec.into_iter() +@@ -139,7 +137,7 @@ impl Packages { + fn decide_and_update(&mut self) { + let data = { + let s = &self; +- let closure: Box bool> = match (self.chosen_repo, self.chosen_group) { ++ let closure: Box bool> = match (self.chosen_repo, self.chosen_group) { + (-1, -1) => Box::new( |_| true ), + (-1, group) => Box::new( move |pkg| pkg.meta.contains(&s.groups[group as usize])), + (repo, -1) => Box::new( move |pkg| pkg.group == s.repos[repo as usize]), +-- +2.32.0 + diff --git a/examples/kefia/0004-Get-rid-of-lazysort-dependency.patch b/examples/kefia/0004-Get-rid-of-lazysort-dependency.patch new file mode 100644 index 00000000..23c69949 --- /dev/null +++ b/examples/kefia/0004-Get-rid-of-lazysort-dependency.patch @@ -0,0 +1,96 @@ +From 2fbab0b42edb7c2321b64b2a9c4ed1b54cc434ba Mon Sep 17 00:00:00 2001 +From: ivan tkachenko +Date: Thu, 15 Jul 2021 14:14:15 +0300 +Subject: [PATCH 4/8] Get rid of lazysort dependency + +It was't even used to its full potential, and in current state only made +code bulky. +--- + Cargo.lock | 7 ------- + Cargo.toml | 1 - + src/main.rs | 4 +--- + src/view.rs | 4 ++-- + 4 files changed, 3 insertions(+), 13 deletions(-) + +diff --git a/Cargo.lock b/Cargo.lock +index 3bd71bb..6e447d7 100644 +--- a/Cargo.lock ++++ b/Cargo.lock +@@ -88,7 +88,6 @@ checksum = "46dbcb333e86939721589d25a3557e180b52778cb33c7fdfe9e0158ff790d5ec" + name = "kefia" + version = "0.1.0" + dependencies = [ +- "lazysort", + "qmetaobject", + "regex", + ] +@@ -99,12 +98,6 @@ version = "1.4.0" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +-[[package]] +-name = "lazysort" +-version = "0.2.1" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "d0e22ff43b231e0e2f87d74984e53ebc73b90ae13397e041214fb07efc64168f" +- + [[package]] + name = "log" + version = "0.4.14" +diff --git a/Cargo.toml b/Cargo.toml +index dce8802..cb25762 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -15,5 +15,4 @@ license = "MIT" + + [dependencies] + regex = "1.5" +-lazysort = "0.2" + qmetaobject = { path = "../qmetaobject-rs/qmetaobject/"} +diff --git a/src/main.rs b/src/main.rs +index b2f7f76..c298f5c 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -1,5 +1,3 @@ +-use lazysort::*; +- + use std::process::Command; + + use regex::*; +@@ -28,7 +26,7 @@ fn main() { + selected: false + }); + } +- let pkgs: Vec = pkgs.into_iter().sorted_by(|a, b| a.group.cmp(&b.group)).collect(); ++ pkgs.sort_by_key(|k| k.group.clone()); + + show(pkgs); + } +diff --git a/src/view.rs b/src/view.rs +index 4a69519..ce4fba3 100644 +--- a/src/view.rs ++++ b/src/view.rs +@@ -1,5 +1,4 @@ + use qmetaobject::*; +-use lazysort::*; + + use super::Package; + +@@ -8,12 +7,13 @@ pub fn show(gathered: Vec) { + let list = std::cell::RefCell::new(form_list(&gathered)); + + let mut repos = gathered.iter().map(|p| p.group.clone().into()).collect::>(); ++ repos.sort(); + repos.dedup(); + let mut groups = gathered.iter() + .flat_map(|p| p.meta.iter()) +- .sorted() + .cloned() + .collect::>(); ++ groups.sort(); + groups.dedup(); + let qrepos = repos.iter().map(|s| QString::from(&**s)).collect::(); + let qgroups = groups.iter() +-- +2.32.0 + diff --git a/examples/kefia/0005-Update-patch-away-from-obsolete-QObjectBox.patch b/examples/kefia/0005-Update-patch-away-from-obsolete-QObjectBox.patch new file mode 100644 index 00000000..33cc207a --- /dev/null +++ b/examples/kefia/0005-Update-patch-away-from-obsolete-QObjectBox.patch @@ -0,0 +1,35 @@ +From 37b9b4f3ad62f15ec77ccd3889e43ddc9656bc8f Mon Sep 17 00:00:00 2001 +From: ivan tkachenko +Date: Thu, 15 Jul 2021 14:09:31 +0300 +Subject: [PATCH 5/8] Update patch away from obsolete QObjectBox + +--- + src/view.rs | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/view.rs b/src/view.rs +index ce4fba3..f0a8807 100644 +--- a/src/view.rs ++++ b/src/view.rs +@@ -26,7 +26,7 @@ pub fn show(gathered: Vec) { + }) + .collect::(); + +- let qpckgs = QObjectBox::new(Packages { ++ let packages = std::cell::RefCell::new(Packages { + vec: gathered, + list: list, + repos: repos, +@@ -36,7 +36,8 @@ pub fn show(gathered: Vec) { + selected: SelectedPackages::new(), + ..Default::default() + }); +- engine.set_object_property("qpkgs".into(), qpckgs.pinned()); ++ let packages_pinned = unsafe { QObjectPinned::new(&packages) }; ++ engine.set_object_property("qpkgs".into(), packages_pinned); + engine.set_property("repos".into(), qrepos.into()); + engine.set_property("groups".into(), qgroups.into()); + engine.load_data(include_str!("view.qml").into()); +-- +2.32.0 + diff --git a/examples/kefia/0006-Replace-yaourt-with-expac.patch b/examples/kefia/0006-Replace-yaourt-with-expac.patch new file mode 100644 index 00000000..623ca643 --- /dev/null +++ b/examples/kefia/0006-Replace-yaourt-with-expac.patch @@ -0,0 +1,39 @@ +From 6b69adc1abd4f9a481ccf23a06217bb41e6c8681 Mon Sep 17 00:00:00 2001 +From: ivan tkachenko +Date: Thu, 15 Jul 2021 14:20:08 +0300 +Subject: [PATCH 6/8] Replace yaourt with expac + +Not an exact replacement, since it lists all packages in all repos +instead of only locally installed, but the is no easy workaround. +--- + src/main.rs | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/src/main.rs b/src/main.rs +index c298f5c..095e33e 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -7,15 +7,16 @@ use self::view::*; + mod view; + + fn main() { +- let output = Command::new("yaourt") +- .arg("-Qe") ++ // Emulate behavior of `yaourt -Qe`, to avoid changing code even more. ++ let output = Command::new("expac") ++ .args(&["-Q", "--sync", "--", "%r/%n %v (%G)"]) + .output() + .unwrap_or_else(|e| panic!("failed to execute process: {}", e)); +- let hello = ::std::str::from_utf8(&output.stdout).unwrap(); ++ let stdout = std::str::from_utf8(&output.stdout).unwrap(); + + let re = Regex::new(r"(?m)^(\S+)/(\S+) (\S+)(?: \((.*)\))?$").unwrap(); + let mut pkgs = Vec::new(); +- for cap in re.captures_iter(hello) { ++ for cap in re.captures_iter(stdout) { + let from = cap.get(4).map_or("", |m| m.as_str()); + + pkgs.push(Package { +-- +2.32.0 + diff --git a/examples/kefia/0007-Rename-group-to-repo-and-meta-to-groups.patch b/examples/kefia/0007-Rename-group-to-repo-and-meta-to-groups.patch new file mode 100644 index 00000000..adf9e5de --- /dev/null +++ b/examples/kefia/0007-Rename-group-to-repo-and-meta-to-groups.patch @@ -0,0 +1,118 @@ +From 04d625720f37a39f7f316e28636e5a0d472dc8b0 Mon Sep 17 00:00:00 2001 +From: ivan tkachenko +Date: Thu, 15 Jul 2021 14:23:11 +0300 +Subject: [PATCH 7/8] Rename group to repo, and meta to groups + +Because that's what it was meant to be. +--- + src/main.rs | 12 ++++++------ + src/view.rs | 22 +++++++++++----------- + 2 files changed, 17 insertions(+), 17 deletions(-) + +diff --git a/src/main.rs b/src/main.rs +index 095e33e..9906406 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -17,26 +17,26 @@ fn main() { + let re = Regex::new(r"(?m)^(\S+)/(\S+) (\S+)(?: \((.*)\))?$").unwrap(); + let mut pkgs = Vec::new(); + for cap in re.captures_iter(stdout) { +- let from = cap.get(4).map_or("", |m| m.as_str()); ++ let groups = cap.get(4).map_or("", |m| m.as_str()); + + pkgs.push(Package { ++ repo: cap.get(1).map_or("", |m| m.as_str()).into(), + name: cap.get(2).map_or("", |m| m.as_str()).into(), +- group: cap.get(1).map_or("", |m| m.as_str()).into(), + version: cap.get(3).map_or("", |m| m.as_str()).into(), +- meta: from.split_whitespace().map(|s| s.into()).collect(), ++ groups: groups.split_whitespace().map(|s| s.into()).collect(), + selected: false + }); + } +- pkgs.sort_by_key(|k| k.group.clone()); ++ pkgs.sort_by_key(|k| k.repo.clone()); + + show(pkgs); + } + + #[derive(Debug, Clone, PartialEq)] + pub struct Package { ++ pub repo: String, + pub name: String, +- pub group: String, + pub version: String, +- pub meta: Vec, ++ pub groups: Vec, + pub selected: bool, + } +diff --git a/src/view.rs b/src/view.rs +index f0a8807..c7b9eef 100644 +--- a/src/view.rs ++++ b/src/view.rs +@@ -6,11 +6,11 @@ pub fn show(gathered: Vec) { + let mut engine = QmlEngine::new(); + let list = std::cell::RefCell::new(form_list(&gathered)); + +- let mut repos = gathered.iter().map(|p| p.group.clone().into()).collect::>(); ++ let mut repos = gathered.iter().map(|p| p.repo.clone().into()).collect::>(); + repos.sort(); + repos.dedup(); + let mut groups = gathered.iter() +- .flat_map(|p| p.meta.iter()) ++ .flat_map(|p| p.groups.iter()) + .cloned() + .collect::>(); + groups.sort(); +@@ -47,9 +47,9 @@ pub fn show(gathered: Vec) { + + #[derive(Default, Clone, SimpleListItem)] + pub struct QPackage { ++ pub repo: QString, + pub name: QString, + pub version: QString, +- pub repo: QString, + pub group: QString, + pub selected: bool + } +@@ -71,7 +71,7 @@ fn filter_for_qml(vec: &[Package], + vec.into_iter() + .filter(filter) + .map(|pkg| { +- let meta = match pkg.meta.first() { ++ let groups = match pkg.groups.first() { + Some(k) => k.clone(), + None => "".into(), + }; +@@ -83,8 +83,8 @@ fn filter_for_qml(vec: &[Package], + QPackage { + name: (&*pkg.name).into(), + version: (&*pkg.version).into(), +- repo: (&*pkg.group).into(), // !!sic +- group: (&*meta).into(), // !! sic ++ repo: (&*pkg.repo).into(), // !!sic ++ group: (&*groups).into(), // !! sic + selected: selected + } + }) +@@ -140,12 +140,12 @@ impl Packages { + let s = &self; + let closure: Box bool> = match (self.chosen_repo, self.chosen_group) { + (-1, -1) => Box::new( |_| true ), +- (-1, group) => Box::new( move |pkg| pkg.meta.contains(&s.groups[group as usize])), +- (repo, -1) => Box::new( move |pkg| pkg.group == s.repos[repo as usize]), ++ (-1, group) => Box::new(move |pkg| pkg.groups.contains(&s.groups[group as usize])), ++ (repo, -1) => Box::new(move |pkg| pkg.repo == s.repos[repo as usize]), + (repo, group) => { +- Box::new( move |pkg| { +- pkg.group == s.repos[repo as usize] && +- pkg.meta.contains(&s.groups[group as usize]) ++ Box::new(move |pkg| { ++ pkg.repo == s.repos[repo as usize] && ++ pkg.groups.contains(&s.groups[group as usize]) + }) + } + }; +-- +2.32.0 + diff --git a/examples/kefia/0008-Fix-UI-layout-and-connections-setup.patch b/examples/kefia/0008-Fix-UI-layout-and-connections-setup.patch new file mode 100644 index 00000000..b704b971 --- /dev/null +++ b/examples/kefia/0008-Fix-UI-layout-and-connections-setup.patch @@ -0,0 +1,197 @@ +From 79103088af5181e0321b2e94b9bda8d62c556cc6 Mon Sep 17 00:00:00 2001 +From: ivan tkachenko +Date: Thu, 15 Jul 2021 14:31:06 +0300 +Subject: [PATCH 8/8] Fix UI layout and connections setup + +--- + src/view.qml | 95 ++++++++++++++++++++++++++++------------------------ + 1 file changed, 51 insertions(+), 44 deletions(-) + +diff --git a/src/view.qml b/src/view.qml +index 74be2e6..b55cffc 100644 +--- a/src/view.qml ++++ b/src/view.qml +@@ -6,42 +6,46 @@ ApplicationWindow { + id: app + visible: true + title: "Kefia" ++ + property real margin: 10 +- minimumWidth: total.width +- maximumWidth: total.width +- width: total.width ++ ++ minimumWidth: root.implicitWidth ++ maximumWidth: root.implicitWidth ++ width: root.implicitWidth + minimumHeight: 600 +- height: 600 +- x: 400 +- y: 100 ++ height: minimumHeight ++ + Item { +- anchors.fill: parent ++ id: root ++ ++ implicitWidth: total.implicitWidth ++ height: parent.height + anchors.margins: app.margin +- GridLayout{ ++ ++ ColumnLayout { + id: total +- columns: 2 +- rows: 2 +- columnSpacing: 10 +- rowSpacing: 10 ++ ++ spacing: 10 + height: parent.height +- RowLayout{ ++ ++ RowLayout { + id: allGroupsLayout +- Layout.minimumHeight: repoGroup.height +- Layout.maximumHeight: repoGroup.height +- Layout.column: 1 +- Layout.row: 1 ++ Layout.fillWidth: true ++ + GroupBox { + title: "Repository" + id: repoGroup + + GridLayout { + columns: 2 +- rows: 2 ++ + RadioButton { + id: allRepos +- text: " All" +- checked: true ++ + Layout.columnSpan: 2 ++ ++ text: "All" ++ checked: true + onClicked: { + repoCB.enabled = false + someRepos.checked = false +@@ -59,11 +63,12 @@ ApplicationWindow { + } + ComboBox { + id: repoCB ++ + Layout.minimumWidth: 200 + Layout.maximumWidth: 200 + Layout.preferredWidth: 200 +- anchors.left: someRepos.right +- anchors.verticalCenter: someRepos.verticalCenter ++ Layout.alignment: Qt.AlignBaseline ++ + enabled: false + model: repos + Component.onCompleted: activated.connect(qpkgs.request_update_repo) +@@ -75,13 +80,14 @@ ApplicationWindow { + + GridLayout { + columns: 2 +- rows: 2 + + RadioButton { + id: allGroups +- text: " All" +- checked: true ++ + Layout.columnSpan: 2 ++ ++ text: "All" ++ checked: true + onClicked: { + groupCB.enabled = false + someGroups.checked = false +@@ -99,14 +105,15 @@ ApplicationWindow { + } + ComboBox { + id: groupCB ++ + Layout.minimumWidth: 200 + Layout.maximumWidth: 200 + Layout.preferredWidth: 200 +- anchors.left: someGroups.right +- anchors.verticalCenter: someGroups.verticalCenter ++ Layout.alignment: Qt.AlignBaseline ++ + enabled: false + model: groups +- Component.onCompleted: activated.connect(qpkgs.request_update_group) ++ onActivated: qpkgs.request_update_group(index) + } + } + } +@@ -114,14 +121,18 @@ ApplicationWindow { + + ScrollView { + id: mainScrollView ++ + Layout.alignment: Qt.AlignBottom + Layout.fillHeight: true + Layout.fillWidth: true +- Layout.column: 1 +- Layout.row: 2 ++ + ListView { + id: mainList +- model: qpkgs.list ++ // While the app shuts down, QQmlApplicationEngine unloads context ++ // properties before the root component, so using this simple check ++ // we avoid `TypeError: Cannot read property 'list' of null`. ++ model: qpkgs ? qpkgs.list : null ++ + delegate: + Rectangle { + width: mainList.width +@@ -131,12 +142,11 @@ ApplicationWindow { + x: mainList.x + 5 + width: mainList.width - 10 + Text { +- id: text + text: name + } + Text { +- anchors.right: parent.right +- text: " (" + version + ")" ++ Layout.alignment: Qt.AlignRight ++ text: "(" + version + ")" + color: "gray" + } + } +@@ -176,17 +186,14 @@ ApplicationWindow { + + TextArea { + id: packagesJoinedTextField +- Layout.minimumWidth: allGroupsLayout.width ++ + Layout.fillWidth: true +- Layout.column: 2 +- Layout.row: 2 +- Layout.rowSpan: 2 +- Layout.alignment: Qt.AlignBottom +- Component.onCompleted: { +- function setText(text) { +- packagesJoinedTextField.text = text +- } +- qpkgs.notify_packages_changed.connect(setText) ++ ++ Connections { ++ target: qpkgs ++ function onNotify_packages_changed(text) { ++ packagesJoinedTextField.text = text; ++ } + } + } + } +-- +2.32.0 + diff --git a/qmetaobject/src/lib.rs b/qmetaobject/src/lib.rs index 2ad22317..3de0cff3 100644 --- a/qmetaobject/src/lib.rs +++ b/qmetaobject/src/lib.rs @@ -215,7 +215,7 @@ pub mod webengine; pub mod prelude { pub use crate::{ qml_register_type, qrc, qt_base_class, qt_method, qt_plugin, qt_property, qt_signal, - QAbstractListModel, QByteArray, QColor, QDate, QDateTime, QModelIndex, QObject, QObjectBox, + QAbstractListModel, QByteArray, QColor, QDate, QDateTime, QModelIndex, QObject, QPointer, QQmlExtensionPlugin, QQuickItem, QQuickView, QRectF, QString, QTime, QVariant, QmlEngine, }; @@ -547,27 +547,6 @@ impl<'pin, T: QObject + 'pin> From> for QVariant { } } -/// A wrapper around RefCell, whose content cannot be move in memory -pub struct QObjectBox(Box>); - -impl QObjectBox { - pub fn new(obj: T) -> Self { - QObjectBox(Box::new(RefCell::new(obj))) - } -} - -impl Default for QObjectBox { - fn default() -> Self { - Self::new(Default::default()) - } -} - -impl QObjectBox { - pub fn pinned(&self) -> QObjectPinned { - unsafe { QObjectPinned::new(&self.0) } - } -} - /// Create the C++ object and return a C++ pointer to a QObject. /// /// The ownership is given to CPP, the resulting QObject* ptr need to be used somewhere