aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qdeduper/mingui.cpp39
-rw-r--r--qdeduper/sigdb_qt.cpp8
-rw-r--r--qdeduper/sigdb_qt.hpp1
3 files changed, 47 insertions, 1 deletions
diff --git a/qdeduper/mingui.cpp b/qdeduper/mingui.cpp
index cbdc9b7..b245be4 100644
--- a/qdeduper/mingui.cpp
+++ b/qdeduper/mingui.cpp
@@ -383,7 +383,44 @@ void DeduperMainWindow::setup_menu()
menuact["mark_none"] = mnone;
this->addAction(mnone);
- mark->addAction("Mark All within...");
+ QAction *madir = mark->addAction("Mark All within directory...");
+ QObject::connect(madir, &QAction::triggered, [this] {
+ QString s = QFileDialog::getExistingDirectory(this, "Open");
+ if (s.isNull() || s.isEmpty()) return;
+ fs::path p = qstring_to_path(s);
+ for (auto &id : this->sdb->get_image_ids())
+ {
+ fs::path fp = this->sdb->get_image_path(id);
+ if (fp.parent_path() == p)
+ this->marked.insert(fp);
+ }
+ for (int i = 0; i < im->rowCount(); ++i)
+ {
+ ImageItem *itm = static_cast<ImageItem*>(im->item(i));
+ fs::path fp = qstring_to_path(itm->path());
+ itm->setCheckState(marked.find(fp) == marked.end() ? Qt::CheckState::Unchecked : Qt::CheckState::Checked);
+ }
+ });
+ menuact["mark_all_dir"] = madir;
+ QAction *madirr = mark->addAction("Mark All within directory and subdirectory...");
+ QObject::connect(madirr, &QAction::triggered, [this] {
+ QString s = QFileDialog::getExistingDirectory(this, "Open");
+ if (s.isNull() || s.isEmpty()) return;
+ fs::path p = qstring_to_path(s);
+ for (auto &id : this->sdb->get_image_ids())
+ {
+ fs::path fp = this->sdb->get_image_path(id);
+ if (!fsstr_to_qstring(fp.lexically_relative(p)).startsWith("../"))
+ this->marked.insert(fp);
+ }
+ for (int i = 0; i < im->rowCount(); ++i)
+ {
+ ImageItem *itm = static_cast<ImageItem*>(im->item(i));
+ fs::path fp = qstring_to_path(itm->path());
+ itm->setCheckState(marked.find(fp) == marked.end() ? Qt::CheckState::Unchecked : Qt::CheckState::Checked);
+ }
+ });
+ menuact["mark_all_dir_rec"] = madirr;
mark->addSeparator();
mark->addAction("Review Marked Images");
diff --git a/qdeduper/sigdb_qt.cpp b/qdeduper/sigdb_qt.cpp
index 4bcc7af..4609245 100644
--- a/qdeduper/sigdb_qt.cpp
+++ b/qdeduper/sigdb_qt.cpp
@@ -145,6 +145,14 @@ std::map<std::pair<size_t, size_t>, double> SignatureDB::group_distances(size_t
return ret;
}
+std::vector<size_t> SignatureDB::get_image_ids()
+{
+ std::vector<size_t> ret;
+ for (auto &f : fmap)
+ ret.push_back(f.first);
+ return ret;
+}
+
fs::path SignatureDB::get_image_path(size_t id)
{
if (fmap.find(id) == fmap.end())
diff --git a/qdeduper/sigdb_qt.hpp b/qdeduper/sigdb_qt.hpp
index 772c264..66159fd 100644
--- a/qdeduper/sigdb_qt.hpp
+++ b/qdeduper/sigdb_qt.hpp
@@ -40,6 +40,7 @@ public:
std::vector<size_t> get_group(size_t gid);
std::map<std::pair<size_t, size_t>, double> group_distances(size_t gid);
+ std::vector<size_t> get_image_ids();
fs::path get_image_path(size_t id);
size_t get_path_id(const fs::path &p);