diff options
author | Chris Xiong <chirs241097@gmail.com> | 2022-09-25 21:40:50 -0400 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2022-09-25 21:40:50 -0400 |
commit | c65b59662e0fb16969eea5cf0ce7a69610e4cadd (patch) | |
tree | 2a8bae20a75084e51e04ffba8aa838daeffd0a26 /qdeduper | |
parent | 9ea7dc1800497d6807b4a14ca301551539078162 (diff) | |
download | deduper-c65b59662e0fb16969eea5cf0ce7a69610e4cadd.tar.xz |
Implement mark all within directory.
Diffstat (limited to 'qdeduper')
-rw-r--r-- | qdeduper/mingui.cpp | 39 | ||||
-rw-r--r-- | qdeduper/sigdb_qt.cpp | 8 | ||||
-rw-r--r-- | qdeduper/sigdb_qt.hpp | 1 |
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); |