From 312d6d3a273f9ff950e7a92998013d4f61f55615 Mon Sep 17 00:00:00 2001 From: Nova Date: Mon, 8 Dec 2025 15:43:39 +0330 Subject: [PATCH] Use full config to compare profiles --- include/dataStore/ProfileFilter.hpp | 7 ++----- src/configs/sub/GroupUpdater.cpp | 2 +- src/dataStore/ProfileFilter.cpp | 24 ++++++++++-------------- src/ui/mainwindow.cpp | 2 +- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/include/dataStore/ProfileFilter.hpp b/include/dataStore/ProfileFilter.hpp index 66157d6..0ac8e8d 100644 --- a/include/dataStore/ProfileFilter.hpp +++ b/include/dataStore/ProfileFilter.hpp @@ -8,7 +8,6 @@ namespace Configs { static void Uniq( const QList> &in, QList> &out, - bool by_address = false, // def by bean bool keep_last = false // def keep first ); @@ -16,15 +15,13 @@ namespace Configs { const QList> &src, const QList> &dst, QList> &outSrc, - QList> &outDst, - bool by_address = false // def by bean + QList> &outDst ); static void OnlyInSrc( const QList> &src, const QList> &dst, - QList> &out, - bool by_address = false // def by bean + QList> &out ); static void OnlyInSrc_ByPointer( diff --git a/src/configs/sub/GroupUpdater.cpp b/src/configs/sub/GroupUpdater.cpp index cd30530..d1a0c80 100644 --- a/src/configs/sub/GroupUpdater.cpp +++ b/src/configs/sub/GroupUpdater.cpp @@ -461,7 +461,7 @@ namespace Subscription { Configs::ProfileFilter::OnlyInSrc_ByPointer(out_all, in, out); Configs::ProfileFilter::OnlyInSrc(in, out, only_in); Configs::ProfileFilter::OnlyInSrc(out, in, only_out); - Configs::ProfileFilter::Common(in, out, update_keep, update_del, false); + Configs::ProfileFilter::Common(in, out, update_keep, update_del); QString notice_added; QString notice_deleted; if (only_out.size() < 1000) diff --git a/src/dataStore/ProfileFilter.cpp b/src/dataStore/ProfileFilter.cpp index 35d3f5d..1296a6e 100644 --- a/src/dataStore/ProfileFilter.cpp +++ b/src/dataStore/ProfileFilter.cpp @@ -2,19 +2,17 @@ namespace Configs { - QString ProfileFilter_ent_key(const std::shared_ptr &ent, bool by_address) { - by_address &= ent->type != "custom"; - return by_address ? (ent->outbound->DisplayAddress() + ent->outbound->DisplayType()) - : QJsonObject2QString(ent->outbound->ToJson({"c_cfg", "c_out"}), true) + ent->outbound->DisplayType(); + QString ProfileFilter_ent_key(const std::shared_ptr &ent) { + return ent->outbound->ExportJsonLink(); } void ProfileFilter::Uniq(const QList> &in, QList> &out, - bool by_address, bool keep_last) { + bool keep_last) { QMap> hashMap; for (const auto &ent: in) { - QString key = ProfileFilter_ent_key(ent, by_address); + QString key = ProfileFilter_ent_key(ent); if (hashMap.contains(key)) { if (keep_last) { out.removeAll(hashMap[key]); @@ -31,16 +29,15 @@ namespace Configs { void ProfileFilter::Common(const QList> &src, const QList> &dst, QList> &outSrc, - QList> &outDst, - bool by_address) { + QList> &outDst) { QMap> hashMap; for (const auto &ent: src) { - QString key = ProfileFilter_ent_key(ent, by_address); + QString key = ProfileFilter_ent_key(ent); hashMap[key] = ent; } for (const auto &ent: dst) { - QString key = ProfileFilter_ent_key(ent, by_address); + QString key = ProfileFilter_ent_key(ent); if (hashMap.contains(key)) { outDst += ent; outSrc += hashMap[key]; @@ -50,16 +47,15 @@ namespace Configs { void ProfileFilter::OnlyInSrc(const QList> &src, const QList> &dst, - QList> &out, - bool by_address) { + QList> &out) { QMap hashMap; for (const auto &ent: dst) { - QString key = ProfileFilter_ent_key(ent, by_address); + QString key = ProfileFilter_ent_key(ent); hashMap[key] = true; } for (const auto &ent: src) { - QString key = ProfileFilter_ent_key(ent, by_address); + QString key = ProfileFilter_ent_key(ent); if (!hashMap.contains(key)) out += ent; } } diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 9137be5..c75e90d 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -1706,7 +1706,7 @@ void MainWindow::on_menu_delete_repeat_triggered () { QList> out; QList> out_del; - Configs::ProfileFilter::Uniq (Configs::profileManager-> CurrentGroup ()-> GetProfileEnts (), out, true , false ); + Configs::ProfileFilter::Uniq (Configs::profileManager-> CurrentGroup ()-> GetProfileEnts (), out, false ); Configs::ProfileFilter::OnlyInSrc_ByPointer (Configs::profileManager-> CurrentGroup ()-> GetProfileEnts (), out, out_del); int remove_display_count = 0 ;