lensfun: properly group lenses by maker in the UI

This commit is contained in:
Alberto Griggio 2017-09-09 22:31:59 +02:00
parent 03ec1abca8
commit 0f197bf1a4
3 changed files with 24 additions and 14 deletions

View File

@ -184,6 +184,16 @@ bool LFLens::ok() const
}
Glib::ustring LFLens::getMake() const
{
if (data_) {
return data_->Maker;
} else {
return "";
}
}
Glib::ustring LFLens::getLens() const
{
if (data_) {

View File

@ -73,6 +73,7 @@ class LFLens {
public:
LFLens();
bool ok() const;
Glib::ustring getMake() const;
Glib::ustring getLens() const;
Glib::ustring getDisplayString() const { return getLens(); }
private:

View File

@ -360,12 +360,8 @@ void LensProfilePanel::fillLensfunLenses()
std::map<Glib::ustring, std::set<Glib::ustring>> lenses;
auto lenslist = LFDatabase::getInstance()->getLenses();
for (auto &l : lenslist) {
auto name = l.getDisplayString();
auto pos = name.find_first_of(' ');
Glib::ustring make = "(Unknown)";
if (pos != Glib::ustring::npos) {
make = name.substr(0, pos);
}
auto name = l.getLens();
auto make = l.getMake();
lenses[make].insert(name);
}
for (auto &p : lenses) {
@ -415,15 +411,8 @@ bool LensProfilePanel::setLensfunLens(const Glib::ustring &lens)
return true;
}
// search for the active row
auto pos = lens.find_first_of(' ');
Glib::ustring make = "(Unknown)";
if (pos != Glib::ustring::npos) {
make = lens.substr(0, pos);
}
for (auto row : lensfunLensModel->children()) {
if (row[lensfunModelLens.lens] == make) {
if (lens.find(row[lensfunModelLens.lens]) == 0) {
auto &c = row.children();
for (auto it = c.begin(), end = c.end(); it != end; ++it) {
auto &childrow = *it;
@ -502,6 +491,16 @@ void LensProfilePanel::onCorrModeChanged()
ckbUseVign->set_sensitive(true);
ckbUseCA->set_sensitive(false);
if (metadata) {
disableListener();
const LFDatabase *db = LFDatabase::getInstance();
LFCamera c = db->findCamera(metadata->getMake(), metadata->getModel());
LFLens l = db->findLens(c, metadata->getLens());
setLensfunCamera(c.getMake(), c.getModel());
setLensfunLens(l.getLens());
enableListener();
}
mode = M("LENSPROFILE_CORRECTION_AUTOMATCH");
} else if (corrLensfunManual->get_active()) {
useLensfunChanged = true;