Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a button to remove duplicates across all profiles. #1378

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions db/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ namespace NekoGui {
_add(new configItem("groups", &groupsTabOrder, itemType::integerList));
}

QList<std::shared_ptr<ProxyEntity>> ProfileManager::Profiles() const {
QList<std::shared_ptr<ProxyEntity>> ret;
for (const auto &[_, profile]: profiles) {
ret += profile;
}
return ret;
}

QList<int> filterIntJsonFile(const QString &path) {
QList<int> result;
QDir dr(path);
Expand Down
2 changes: 2 additions & 0 deletions db/Database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace NekoGui {

[[nodiscard]] static std::shared_ptr<Group> NewGroup();

QList<std::shared_ptr<ProxyEntity>> Profiles() const;

bool AddProfile(const std::shared_ptr<ProxyEntity> &ent, int gid = -1);

void DeleteProfile(int id);
Expand Down
9 changes: 7 additions & 2 deletions ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,11 +1358,12 @@ void MainWindow::on_menu_select_all_triggered() {
ui->proxyListTable->selectAll();
}

void MainWindow::on_menu_delete_repeat_triggered() {
void MainWindow::on_menu_delete_repeat_triggered(bool const search_across_all_profiles) {
QList<std::shared_ptr<NekoGui::ProxyEntity>> out;
QList<std::shared_ptr<NekoGui::ProxyEntity>> out_del;

NekoGui::ProfileFilter::Uniq(NekoGui::profileManager->CurrentGroup()->Profiles(), out, true, false);
auto const profiles = search_across_all_profiles ? NekoGui::profileManager->Profiles() : NekoGui::profileManager->CurrentGroup()->Profiles();
NekoGui::ProfileFilter::Uniq(profiles, out, true, false);
NekoGui::ProfileFilter::OnlyInSrc_ByPointer(NekoGui::profileManager->CurrentGroup()->Profiles(), out, out_del);

int remove_display_count = 0;
Expand All @@ -1384,6 +1385,10 @@ void MainWindow::on_menu_delete_repeat_triggered() {
}
}

void MainWindow::on_menu_delete_duplicates_global_triggered() {
return on_menu_delete_repeat_triggered(true);
}

bool mw_sub_updating = false;

void MainWindow::on_menu_update_subscription_triggered() {
Expand Down
4 changes: 3 additions & 1 deletion ui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ private slots:

void on_menu_select_all_triggered();

void on_menu_delete_repeat_triggered();
void on_menu_delete_repeat_triggered(bool const search_across_all_profiles = false);

void on_menu_delete_duplicates_global_triggered();

void on_menu_remove_unavailable_triggered();

Expand Down
9 changes: 9 additions & 0 deletions ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
<addaction name="separator"/>
<addaction name="menu_remove_unavailable"/>
<addaction name="menu_delete_repeat"/>
<addaction name="menu_delete_duplicates_global"/>
<addaction name="separator"/>
<addaction name="menu_update_subscription"/>
</widget>
Expand Down Expand Up @@ -729,6 +730,14 @@
<string notr="true">Ctrl+Shift+D</string>
</property>
</action>
<action name="menu_delete_duplicates_global">
<property name="text">
<string>Remove Duplicates Across All Groups</string>
</property>
<property name="shortcut">
<string notr="true"></string>
</property>
</action>
<action name="actionfake">
<property name="text">
<string>fake</string>
Expand Down