mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
add option filter ab by intersection
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -229,6 +229,22 @@ class _AddressBookState extends State<AddressBook> {
|
||||
);
|
||||
}
|
||||
|
||||
@protected
|
||||
MenuEntryBase<String> filterMenuItem() {
|
||||
return MenuEntrySwitch<String>(
|
||||
switchType: SwitchType.scheckbox,
|
||||
text: translate('Filter by intersection'),
|
||||
getter: () async {
|
||||
return filterAbTagByIntersection();
|
||||
},
|
||||
setter: (bool v) async {
|
||||
bind.mainSetLocalOption(key: filterAbTagOption, value: v ? 'Y' : '');
|
||||
gFFI.abModel.filterByIntersection.value = v;
|
||||
},
|
||||
dismissOnClicked: true,
|
||||
);
|
||||
}
|
||||
|
||||
void _showMenu(RelativeRect pos) {
|
||||
final items = [
|
||||
getEntry(translate("Add ID"), abAddId),
|
||||
@@ -236,6 +252,7 @@ class _AddressBookState extends State<AddressBook> {
|
||||
getEntry(translate("Unselect all tags"), gFFI.abModel.unsetSelectedTags),
|
||||
sortMenuItem(),
|
||||
syncMenuItem(),
|
||||
filterMenuItem(),
|
||||
];
|
||||
|
||||
mod_menu.showMenu(
|
||||
|
||||
@@ -450,12 +450,21 @@ class AddressBookPeersView extends BasePeersView {
|
||||
if (selectedTags.isEmpty) {
|
||||
return true;
|
||||
}
|
||||
for (final tag in selectedTags) {
|
||||
if (idents.contains(tag)) {
|
||||
return true;
|
||||
if (gFFI.abModel.filterByIntersection.value) {
|
||||
for (final tag in selectedTags) {
|
||||
if (!idents.contains(tag)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
for (final tag in selectedTags) {
|
||||
if (idents.contains(tag)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ bool shouldSortTags() {
|
||||
return bind.mainGetLocalOption(key: sortAbTagsOption).isNotEmpty;
|
||||
}
|
||||
|
||||
final filterAbTagOption = 'filter-ab-by-intersection';
|
||||
bool filterAbTagByIntersection() {
|
||||
return bind.mainGetLocalOption(key: filterAbTagOption).isNotEmpty;
|
||||
}
|
||||
|
||||
class AbModel {
|
||||
final abLoading = false.obs;
|
||||
final pullError = "".obs;
|
||||
@@ -31,6 +36,7 @@ class AbModel {
|
||||
final RxMap<String, int> tagColors = Map<String, int>.fromEntries([]).obs;
|
||||
final peers = List<Peer>.empty(growable: true).obs;
|
||||
final sortTags = shouldSortTags().obs;
|
||||
final filterByIntersection = filterAbTagByIntersection().obs;
|
||||
final retrying = false.obs;
|
||||
bool get emtpy => peers.isEmpty && tags.isEmpty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user