[system/kconfigeditor] src: Merge duplicate groups
Nicolas Fella <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 9c80719fae7536e9cec42d7bebbf3b28e78eb276 by Nicolas Fella.
Committed on 23/07/2026 at 14:42.
Pushed by nicolasfella into branch 'master'.
Merge duplicate groups
M +11 -4 src/groupsmodel.rs
https://invent.kde.org/system/kconfigeditor/-/commit/9c80719fae7536e9cec42d7bebbf3b28e78eb276
diff --git a/src/groupsmodel.rs b/src/groupsmodel.rs
index 8d90533..61a2e8f 100644
--- a/src/groupsmodel.rs
+++ b/src/groupsmodel.rs
@@ -7,6 +7,7 @@ use groupsmodel::GroupsRoles;
use std::path::PathBuf;
use std::pin::Pin;
+use std::collections::HashSet;
use std::fs;
use crate::config;
@@ -82,7 +83,7 @@ mod groupsmodel {
}
pub struct GroupsModelRust {
- groups: Vec<Group>,
+ groups: Vec<QString>,
file_name: QString,
location: QString,
}
@@ -111,7 +112,7 @@ impl groupsmodel::GroupsModel {
if let Some(group) = self.groups.get(index.row() as usize) {
match role {
GroupsRoles::Name => {
- return QVariant::from(&QString::from(&group.name));
+ return QVariant::from(group);
}
_ => {}
}
@@ -146,12 +147,18 @@ impl groupsmodel::GroupsModel {
})
.collect();
- self.as_mut().rust_mut().groups = configs
+ let groups: Vec<Group> = configs
.iter()
.flat_map(|config| config.group.clone())
.collect();
- // TODO merge duplicate groups
+ self.as_mut().rust_mut().groups = groups
+ .iter()
+ .map(|group| group.name.clone())
+ .collect::<HashSet<_>>()
+ .iter()
+ .map(|s| QString::from(s))
+ .collect();
self.end_reset_model();
}