mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-18 20:50:09 +08:00
Use full config to compare profiles
This commit is contained in:
parent
61f747361e
commit
312d6d3a27
@ -8,7 +8,6 @@ namespace Configs {
|
||||
static void Uniq(
|
||||
const QList<std::shared_ptr<ProxyEntity>> &in,
|
||||
QList<std::shared_ptr<ProxyEntity>> &out,
|
||||
bool by_address = false, // def by bean
|
||||
bool keep_last = false // def keep first
|
||||
);
|
||||
|
||||
@ -16,15 +15,13 @@ namespace Configs {
|
||||
const QList<std::shared_ptr<ProxyEntity>> &src,
|
||||
const QList<std::shared_ptr<ProxyEntity>> &dst,
|
||||
QList<std::shared_ptr<ProxyEntity>> &outSrc,
|
||||
QList<std::shared_ptr<ProxyEntity>> &outDst,
|
||||
bool by_address = false // def by bean
|
||||
QList<std::shared_ptr<ProxyEntity>> &outDst
|
||||
);
|
||||
|
||||
static void OnlyInSrc(
|
||||
const QList<std::shared_ptr<ProxyEntity>> &src,
|
||||
const QList<std::shared_ptr<ProxyEntity>> &dst,
|
||||
QList<std::shared_ptr<ProxyEntity>> &out,
|
||||
bool by_address = false // def by bean
|
||||
QList<std::shared_ptr<ProxyEntity>> &out
|
||||
);
|
||||
|
||||
static void OnlyInSrc_ByPointer(
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -2,19 +2,17 @@
|
||||
|
||||
namespace Configs {
|
||||
|
||||
QString ProfileFilter_ent_key(const std::shared_ptr<Configs::ProxyEntity> &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<Configs::ProxyEntity> &ent) {
|
||||
return ent->outbound->ExportJsonLink();
|
||||
}
|
||||
|
||||
void ProfileFilter::Uniq(const QList<std::shared_ptr<ProxyEntity>> &in,
|
||||
QList<std::shared_ptr<ProxyEntity>> &out,
|
||||
bool by_address, bool keep_last) {
|
||||
bool keep_last) {
|
||||
QMap<QString, std::shared_ptr<ProxyEntity>> 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<std::shared_ptr<ProxyEntity>> &src,
|
||||
const QList<std::shared_ptr<ProxyEntity>> &dst,
|
||||
QList<std::shared_ptr<ProxyEntity>> &outSrc,
|
||||
QList<std::shared_ptr<ProxyEntity>> &outDst,
|
||||
bool by_address) {
|
||||
QList<std::shared_ptr<ProxyEntity>> &outDst) {
|
||||
QMap<QString, std::shared_ptr<ProxyEntity>> 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<std::shared_ptr<ProxyEntity>> &src,
|
||||
const QList<std::shared_ptr<ProxyEntity>> &dst,
|
||||
QList<std::shared_ptr<ProxyEntity>> &out,
|
||||
bool by_address) {
|
||||
QList<std::shared_ptr<ProxyEntity>> &out) {
|
||||
QMap<QString, bool> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1706,7 +1706,7 @@ void MainWindow::on_menu_delete_repeat_triggered () {
|
||||
QList<std::shared_ptr<Configs::ProxyEntity>> out;
|
||||
QList<std::shared_ptr<Configs::ProxyEntity>> 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 ;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user