Several files astylized.
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
using namespace rtengine;
|
||||
using namespace rtengine::procparams;
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
const int ISO_MAX = 512000;
|
||||
const double FNUMBER_MAX = 100.0;
|
||||
@@ -38,14 +39,15 @@ const double EXPCOMP_MAX = 20.0;
|
||||
|
||||
DynamicProfileRules dynamicProfileRules;
|
||||
|
||||
bool DynamicProfileRule::Optional::operator()(const Glib::ustring &val) const
|
||||
bool DynamicProfileRule::Optional::operator() (const Glib::ustring &val) const
|
||||
{
|
||||
if (!enabled) {
|
||||
return true;
|
||||
}
|
||||
if (value.find("re:") == 0) {
|
||||
|
||||
if (value.find ("re:") == 0) {
|
||||
// this is a regexp
|
||||
return Glib::Regex::match_simple(value.substr(3), val, Glib::REGEX_CASELESS);
|
||||
return Glib::Regex::match_simple (value.substr (3), val, Glib::REGEX_CASELESS);
|
||||
} else {
|
||||
// normal string comparison
|
||||
return value.casefold() == val.casefold();
|
||||
@@ -54,75 +56,79 @@ bool DynamicProfileRule::Optional::operator()(const Glib::ustring &val) const
|
||||
|
||||
|
||||
DynamicProfileRule::DynamicProfileRule():
|
||||
serial_number(0),
|
||||
iso(0, ISO_MAX),
|
||||
fnumber(0, FNUMBER_MAX),
|
||||
focallen(0, FOCALLEN_MAX),
|
||||
shutterspeed(0, SHUTTERSPEED_MAX),
|
||||
expcomp(EXPCOMP_MIN, EXPCOMP_MAX)
|
||||
serial_number (0),
|
||||
iso (0, ISO_MAX),
|
||||
fnumber (0, FNUMBER_MAX),
|
||||
focallen (0, FOCALLEN_MAX),
|
||||
shutterspeed (0, SHUTTERSPEED_MAX),
|
||||
expcomp (EXPCOMP_MIN, EXPCOMP_MAX)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool DynamicProfileRule::operator<(const DynamicProfileRule &other) const
|
||||
bool DynamicProfileRule::operator< (const DynamicProfileRule &other) const
|
||||
{
|
||||
return serial_number < other.serial_number;
|
||||
}
|
||||
|
||||
|
||||
bool DynamicProfileRule::matches(const rtengine::ImageMetaData *im) const
|
||||
bool DynamicProfileRule::matches (const rtengine::ImageMetaData *im) const
|
||||
{
|
||||
return (iso(im->getISOSpeed())
|
||||
&& fnumber(im->getFNumber())
|
||||
&& focallen(im->getFocalLen())
|
||||
&& shutterspeed(im->getShutterSpeed())
|
||||
&& expcomp(im->getExpComp())
|
||||
&& camera(im->getCamera())
|
||||
&& lens(im->getLens()));
|
||||
return (iso (im->getISOSpeed())
|
||||
&& fnumber (im->getFNumber())
|
||||
&& focallen (im->getFocalLen())
|
||||
&& shutterspeed (im->getShutterSpeed())
|
||||
&& expcomp (im->getExpComp())
|
||||
&& camera (im->getCamera())
|
||||
&& lens (im->getLens()));
|
||||
}
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
|
||||
void get_int_range(DynamicProfileRule::Range<int> &dest,
|
||||
void get_int_range (DynamicProfileRule::Range<int> &dest,
|
||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key)
|
||||
{
|
||||
try {
|
||||
int min = kf.get_integer (group, key + "_min");
|
||||
int max = kf.get_integer (group, key + "_max");
|
||||
|
||||
if (min <= max) {
|
||||
dest.min = min;
|
||||
dest.max = max;
|
||||
}
|
||||
} catch (Glib::KeyFileError &e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void get_double_range (DynamicProfileRule::Range<double> &dest,
|
||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key)
|
||||
{
|
||||
try {
|
||||
double min = kf.get_double (group, key + "_min");
|
||||
double max = kf.get_double (group, key + "_max");
|
||||
|
||||
if (min <= max) {
|
||||
dest.min = min;
|
||||
dest.max = max;
|
||||
}
|
||||
} catch (Glib::KeyFileError &e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void get_optional (DynamicProfileRule::Optional &dest,
|
||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key)
|
||||
{
|
||||
try {
|
||||
int min = kf.get_integer(group, key + "_min");
|
||||
int max = kf.get_integer(group, key + "_max");
|
||||
if (min <= max) {
|
||||
dest.min = min;
|
||||
dest.max = max;
|
||||
}
|
||||
} catch (Glib::KeyFileError &e) {
|
||||
}
|
||||
}
|
||||
bool e = kf.get_boolean (group, key + "_enabled");
|
||||
|
||||
|
||||
void get_double_range(DynamicProfileRule::Range<double> &dest,
|
||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key)
|
||||
{
|
||||
try {
|
||||
double min = kf.get_double(group, key + "_min");
|
||||
double max = kf.get_double(group, key + "_max");
|
||||
if (min <= max) {
|
||||
dest.min = min;
|
||||
dest.max = max;
|
||||
}
|
||||
} catch (Glib::KeyFileError &e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void get_optional(DynamicProfileRule::Optional &dest,
|
||||
const Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key)
|
||||
{
|
||||
try {
|
||||
bool e = kf.get_boolean(group, key + "_enabled");
|
||||
if (e) {
|
||||
Glib::ustring s = kf.get_string(group, key + "_value");
|
||||
Glib::ustring s = kf.get_string (group, key + "_value");
|
||||
dest.enabled = e;
|
||||
dest.value = s;
|
||||
}
|
||||
@@ -130,28 +136,28 @@ void get_optional(DynamicProfileRule::Optional &dest,
|
||||
}
|
||||
}
|
||||
|
||||
void set_int_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
void set_int_range (Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key,
|
||||
const DynamicProfileRule::Range<int> &val)
|
||||
{
|
||||
kf.set_integer (group, key + "_min", val.min);
|
||||
kf.set_integer (group, key + "_max", val.max);
|
||||
}
|
||||
|
||||
void set_double_range (Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key,
|
||||
const DynamicProfileRule::Range<double> &val)
|
||||
{
|
||||
kf.set_double (group, key + "_min", val.min);
|
||||
kf.set_double (group, key + "_max", val.max);
|
||||
}
|
||||
|
||||
void set_optional (Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key,
|
||||
const DynamicProfileRule::Range<int> &val)
|
||||
const DynamicProfileRule::Optional &val)
|
||||
{
|
||||
kf.set_integer(group, key + "_min", val.min);
|
||||
kf.set_integer(group, key + "_max", val.max);
|
||||
}
|
||||
|
||||
void set_double_range(Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key,
|
||||
const DynamicProfileRule::Range<double> &val)
|
||||
{
|
||||
kf.set_double(group, key + "_min", val.min);
|
||||
kf.set_double(group, key + "_max", val.max);
|
||||
}
|
||||
|
||||
void set_optional(Glib::KeyFile &kf, const Glib::ustring &group,
|
||||
const Glib::ustring &key,
|
||||
const DynamicProfileRule::Optional &val)
|
||||
{
|
||||
kf.set_boolean(group, key + "_enabled", val.enabled);
|
||||
kf.set_string(group, key + "_value", val.value);
|
||||
kf.set_boolean (group, key + "_enabled", val.enabled);
|
||||
kf.set_string (group, key + "_value", val.value);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -160,48 +166,57 @@ bool DynamicProfileRules::loadRules()
|
||||
{
|
||||
dynamicRules.clear();
|
||||
Glib::KeyFile kf;
|
||||
|
||||
try {
|
||||
if (!kf.load_from_file(Glib::build_filename(Options::rtdir, "dynamicprofile.cfg"))) {
|
||||
if (!kf.load_from_file (Glib::build_filename (Options::rtdir, "dynamicprofile.cfg"))) {
|
||||
return false;
|
||||
}
|
||||
} catch (Glib::Error &e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.rtSettings.verbose) {
|
||||
printf("loading dynamic profiles...\n");
|
||||
printf ("loading dynamic profiles...\n");
|
||||
}
|
||||
|
||||
auto groups = kf.get_groups();
|
||||
|
||||
for (auto group : groups) {
|
||||
// groups are of the form "rule N", where N is a positive integer
|
||||
if (group.find("rule ") != 0) {
|
||||
if (group.find ("rule ") != 0) {
|
||||
return false;
|
||||
}
|
||||
std::istringstream buf(group.c_str() + 5);
|
||||
int serial = 0;
|
||||
if (!(buf >> serial) || !buf.eof()) {
|
||||
return false;
|
||||
}
|
||||
if (options.rtSettings.verbose) {
|
||||
printf(" loading rule %d\n", serial);
|
||||
}
|
||||
|
||||
dynamicRules.emplace_back(DynamicProfileRule());
|
||||
std::istringstream buf (group.c_str() + 5);
|
||||
int serial = 0;
|
||||
|
||||
if (! (buf >> serial) || !buf.eof()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.rtSettings.verbose) {
|
||||
printf (" loading rule %d\n", serial);
|
||||
}
|
||||
|
||||
dynamicRules.emplace_back (DynamicProfileRule());
|
||||
DynamicProfileRule &rule = dynamicRules.back();
|
||||
rule.serial_number = serial;
|
||||
get_int_range(rule.iso, kf, group, "iso");
|
||||
get_double_range(rule.fnumber, kf, group, "fnumber");
|
||||
get_double_range(rule.focallen, kf, group, "focallen");
|
||||
get_double_range(rule.shutterspeed, kf, group, "shutterspeed");
|
||||
get_double_range(rule.expcomp, kf, group, "expcomp");
|
||||
get_optional(rule.camera, kf, group, "camera");
|
||||
get_optional(rule.lens, kf, group, "lens");
|
||||
get_int_range (rule.iso, kf, group, "iso");
|
||||
get_double_range (rule.fnumber, kf, group, "fnumber");
|
||||
get_double_range (rule.focallen, kf, group, "focallen");
|
||||
get_double_range (rule.shutterspeed, kf, group, "shutterspeed");
|
||||
get_double_range (rule.expcomp, kf, group, "expcomp");
|
||||
get_optional (rule.camera, kf, group, "camera");
|
||||
get_optional (rule.lens, kf, group, "lens");
|
||||
|
||||
try {
|
||||
rule.profilepath = kf.get_string(group, "profilepath");
|
||||
rule.profilepath = kf.get_string (group, "profilepath");
|
||||
} catch (Glib::KeyFileError &) {
|
||||
dynamicRules.pop_back();
|
||||
}
|
||||
}
|
||||
std::sort(dynamicRules.begin(), dynamicRules.end());
|
||||
|
||||
std::sort (dynamicRules.begin(), dynamicRules.end());
|
||||
rulesLoaded = true;
|
||||
return true;
|
||||
}
|
||||
@@ -209,23 +224,26 @@ bool DynamicProfileRules::loadRules()
|
||||
bool DynamicProfileRules::storeRules()
|
||||
{
|
||||
if (options.rtSettings.verbose) {
|
||||
printf("saving dynamic profiles...\n");
|
||||
printf ("saving dynamic profiles...\n");
|
||||
}
|
||||
|
||||
Glib::KeyFile kf;
|
||||
|
||||
for (auto &rule : dynamicRules) {
|
||||
std::ostringstream buf;
|
||||
buf << "rule " << rule.serial_number;
|
||||
Glib::ustring group = buf.str();
|
||||
set_int_range(kf, group, "iso", rule.iso);
|
||||
set_double_range(kf, group, "fnumber", rule.fnumber);
|
||||
set_double_range(kf, group, "focallen", rule.focallen);
|
||||
set_double_range(kf, group, "shutterspeed", rule.shutterspeed);
|
||||
set_double_range(kf, group, "expcomp", rule.expcomp);
|
||||
set_optional(kf, group, "camera", rule.camera);
|
||||
set_optional(kf, group, "lens", rule.lens);
|
||||
kf.set_string(group, "profilepath", rule.profilepath);
|
||||
set_int_range (kf, group, "iso", rule.iso);
|
||||
set_double_range (kf, group, "fnumber", rule.fnumber);
|
||||
set_double_range (kf, group, "focallen", rule.focallen);
|
||||
set_double_range (kf, group, "shutterspeed", rule.shutterspeed);
|
||||
set_double_range (kf, group, "expcomp", rule.expcomp);
|
||||
set_optional (kf, group, "camera", rule.camera);
|
||||
set_optional (kf, group, "lens", rule.lens);
|
||||
kf.set_string (group, "profilepath", rule.profilepath);
|
||||
}
|
||||
return kf.save_to_file(Glib::build_filename(Options::rtdir, "dynamicprofile.cfg"));
|
||||
|
||||
return kf.save_to_file (Glib::build_filename (Options::rtdir, "dynamicprofile.cfg"));
|
||||
}
|
||||
|
||||
const std::vector<DynamicProfileRule> &DynamicProfileRules::getRules() const
|
||||
@@ -233,7 +251,7 @@ const std::vector<DynamicProfileRule> &DynamicProfileRules::getRules() const
|
||||
return dynamicRules;
|
||||
}
|
||||
|
||||
void DynamicProfileRules::setRules(const std::vector<DynamicProfileRule> &r)
|
||||
void DynamicProfileRules::setRules (const std::vector<DynamicProfileRule> &r)
|
||||
{
|
||||
dynamicRules = r;
|
||||
}
|
||||
|
||||
@@ -23,15 +23,16 @@
|
||||
#include <vector>
|
||||
#include "../rtgui/options.h"
|
||||
|
||||
class DynamicProfileRule {
|
||||
class DynamicProfileRule
|
||||
{
|
||||
public:
|
||||
template <class T>
|
||||
struct Range {
|
||||
T min;
|
||||
T max;
|
||||
explicit Range(T l=T(), T u=T()): min(l), max(u) {}
|
||||
explicit Range (T l = T(), T u = T()): min (l), max (u) {}
|
||||
|
||||
bool operator()(T val) const
|
||||
bool operator() (T val) const
|
||||
{
|
||||
return val >= min && val <= max;
|
||||
}
|
||||
@@ -40,15 +41,15 @@ public:
|
||||
struct Optional {
|
||||
Glib::ustring value;
|
||||
bool enabled;
|
||||
explicit Optional(const Glib::ustring v="", bool e=false):
|
||||
value(v), enabled(e) {}
|
||||
explicit Optional (const Glib::ustring v = "", bool e = false):
|
||||
value (v), enabled (e) {}
|
||||
|
||||
bool operator()(const Glib::ustring &val) const;
|
||||
bool operator() (const Glib::ustring &val) const;
|
||||
};
|
||||
|
||||
DynamicProfileRule();
|
||||
bool matches(const rtengine::ImageMetaData *im) const;
|
||||
bool operator<(const DynamicProfileRule &other) const;
|
||||
bool matches (const rtengine::ImageMetaData *im) const;
|
||||
bool operator< (const DynamicProfileRule &other) const;
|
||||
|
||||
int serial_number;
|
||||
Range<int> iso;
|
||||
@@ -61,7 +62,8 @@ public:
|
||||
Glib::ustring profilepath;
|
||||
};
|
||||
|
||||
class DynamicProfileRules {
|
||||
class DynamicProfileRules
|
||||
{
|
||||
protected:
|
||||
/** cache for dynamic profile rules */
|
||||
std::vector<DynamicProfileRule> dynamicRules;
|
||||
@@ -71,7 +73,7 @@ public:
|
||||
bool loadRules();
|
||||
bool storeRules();
|
||||
const std::vector<DynamicProfileRule> &getRules() const;
|
||||
void setRules(const std::vector<DynamicProfileRule> &r);
|
||||
void setRules (const std::vector<DynamicProfileRule> &r);
|
||||
};
|
||||
|
||||
#endif // _DYNAMICPROFILE_H_
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
using namespace rtengine;
|
||||
using namespace rtengine::procparams;
|
||||
|
||||
ProfileStore::ProfileStore () : storeState(STORESTATE_NOTINITIALIZED), internalDefaultProfile(nullptr), internalDefaultEntry(nullptr), internalDynamicEntry(nullptr), loadAll(true)
|
||||
ProfileStore::ProfileStore () : storeState (STORESTATE_NOTINITIALIZED), internalDefaultProfile (nullptr), internalDefaultEntry (nullptr), internalDynamicEntry (nullptr), loadAll (true)
|
||||
{
|
||||
internalDefaultProfile = new AutoPartialProfile();
|
||||
internalDefaultProfile->set(true);
|
||||
internalDefaultProfile->set (true);
|
||||
}
|
||||
|
||||
ProfileStore* ProfileStore::getInstance()
|
||||
@@ -65,14 +65,14 @@ ProfileStore::~ProfileStore ()
|
||||
storeState = STORESTATE_DELETED;
|
||||
|
||||
{
|
||||
MyMutex::MyLock lock(parseMutex);
|
||||
MyMutex::MyLock lock (parseMutex);
|
||||
|
||||
clearProfileList ();
|
||||
partProfiles.clear ();
|
||||
clearFileList();
|
||||
delete internalDefaultProfile;
|
||||
delete internalDefaultEntry;
|
||||
delete internalDynamicEntry;
|
||||
clearProfileList ();
|
||||
partProfiles.clear ();
|
||||
clearFileList();
|
||||
delete internalDefaultProfile;
|
||||
delete internalDefaultEntry;
|
||||
delete internalDynamicEntry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,14 +107,14 @@ void ProfileStore::_parseProfiles ()
|
||||
clearFileList();
|
||||
clearProfileList ();
|
||||
|
||||
folders.push_back("<<< ROOT >>>"); // Fake path, so parentFolderId == 0 will be used to attach a ProfileStoreEntry to the root container, not sub-menu
|
||||
folders.push_back ("<<< ROOT >>>"); // Fake path, so parentFolderId == 0 will be used to attach a ProfileStoreEntry to the root container, not sub-menu
|
||||
|
||||
Glib::ustring p1 = options.getUserProfilePath();
|
||||
Glib::ustring p2 = options.getGlobalProfilePath();
|
||||
bool displayLevel0 = options.useBundledProfiles && !p1.empty() && !p2.empty() && p1 != p2;
|
||||
|
||||
Glib::ustring virtualPath("${U}");
|
||||
Glib::ustring currDir("${U}");
|
||||
Glib::ustring virtualPath ("${U}");
|
||||
Glib::ustring currDir ("${U}");
|
||||
parseDir (p1, virtualPath, currDir, 0, 0, displayLevel0);
|
||||
|
||||
if (displayLevel0) {
|
||||
@@ -124,35 +124,35 @@ void ProfileStore::_parseProfiles ()
|
||||
}
|
||||
|
||||
// sort profiles
|
||||
std::sort(entries.begin(), entries.end(), SortProfiles() );
|
||||
std::sort (entries.begin(), entries.end(), SortProfiles() );
|
||||
|
||||
// entries and partProfiles are empty, but the entry and profiles already exist (they have survived to clearFileList and clearProfileList)
|
||||
if (!internalDefaultEntry) {
|
||||
internalDefaultEntry = new ProfileStoreEntry(Glib::ustring("(") + M("PROFILEPANEL_PINTERNAL") + Glib::ustring(")"), PSET_FILE, 0, 0);
|
||||
internalDefaultEntry = new ProfileStoreEntry (Glib::ustring ("(") + M ("PROFILEPANEL_PINTERNAL") + Glib::ustring (")"), PSET_FILE, 0, 0);
|
||||
}
|
||||
|
||||
entries.push_back(internalDefaultEntry);
|
||||
entries.push_back (internalDefaultEntry);
|
||||
partProfiles[internalDefaultEntry] = internalDefaultProfile;
|
||||
|
||||
if (!internalDynamicEntry) {
|
||||
internalDynamicEntry = new ProfileStoreEntry(Glib::ustring("(") + M("PROFILEPANEL_PDYNAMIC") + Glib::ustring(")"), PSET_FILE, 0, 0);
|
||||
internalDynamicEntry = new ProfileStoreEntry (Glib::ustring ("(") + M ("PROFILEPANEL_PDYNAMIC") + Glib::ustring (")"), PSET_FILE, 0, 0);
|
||||
// do not add it to the entries. This is here only for the preferences dialog
|
||||
}
|
||||
|
||||
// Check if the default profiles has been found.
|
||||
if (findEntryFromFullPathU(options.defProfRaw) == nullptr) {
|
||||
options.setDefProfRawMissing(true);
|
||||
if (findEntryFromFullPathU (options.defProfRaw) == nullptr) {
|
||||
options.setDefProfRawMissing (true);
|
||||
|
||||
if (options.rtSettings.verbose) {
|
||||
printf("WARNING: Default profile \"%s\" for raw images not found!\n", options.defProfRaw.c_str());
|
||||
printf ("WARNING: Default profile \"%s\" for raw images not found!\n", options.defProfRaw.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (findEntryFromFullPathU(options.defProfImg) == nullptr) {
|
||||
options.setDefProfImgMissing(true);
|
||||
if (findEntryFromFullPathU (options.defProfImg) == nullptr) {
|
||||
options.setDefProfImgMissing (true);
|
||||
|
||||
if (options.rtSettings.verbose) {
|
||||
printf("WARNING: Default profile \"%s\" for standard images not found!\n", options.defProfImg.c_str());
|
||||
printf ("WARNING: Default profile \"%s\" for standard images not found!\n", options.defProfImg.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,23 +163,23 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
||||
bool fileFound = false;
|
||||
|
||||
// reload the available profiles from the profile dir
|
||||
if (!realPath.empty() && Glib::file_test(realPath, Glib::FILE_TEST_EXISTS) && Glib::file_test (realPath, Glib::FILE_TEST_IS_DIR)) {
|
||||
if (!realPath.empty() && Glib::file_test (realPath, Glib::FILE_TEST_EXISTS) && Glib::file_test (realPath, Glib::FILE_TEST_IS_DIR)) {
|
||||
unsigned int folder = 0; // folder's own Id
|
||||
|
||||
// add this entry to the folder list
|
||||
folders.push_back(virtualPath);
|
||||
folder = (unsigned int)(folders.size()) - 1;
|
||||
folders.push_back (virtualPath);
|
||||
folder = (unsigned int) (folders.size()) - 1;
|
||||
|
||||
if (level > 0 || displayLevel0) {
|
||||
// replace the virtual folder name by a localized text
|
||||
if (currDir == "${U}") {
|
||||
currDir = M("PROFILEPANEL_MYPROFILES");
|
||||
currDir = M ("PROFILEPANEL_MYPROFILES");
|
||||
} else if (currDir == "${G}") {
|
||||
currDir = M("PROFILEPANEL_GLOBALPROFILES");
|
||||
currDir = M ("PROFILEPANEL_GLOBALPROFILES");
|
||||
}
|
||||
|
||||
// add this localized text to the file list
|
||||
entries.push_back( new ProfileStoreEntry(currDir, PSET_FOLDER, parentId, folder) );
|
||||
entries.push_back ( new ProfileStoreEntry (currDir, PSET_FOLDER, parentId, folder) );
|
||||
}
|
||||
|
||||
// walking through the directory
|
||||
@@ -193,22 +193,22 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
||||
continue;
|
||||
}
|
||||
|
||||
Glib::ustring fname = Glib::build_filename(realPath, currDir);
|
||||
Glib::ustring fname = Glib::build_filename (realPath, currDir);
|
||||
|
||||
if (Glib::file_test (fname, Glib::FILE_TEST_IS_DIR)) {
|
||||
Glib::ustring vp(Glib::build_filename(virtualPath, currDir));
|
||||
Glib::ustring rp(Glib::build_filename(realPath, currDir));
|
||||
Glib::ustring vp (Glib::build_filename (virtualPath, currDir));
|
||||
Glib::ustring rp (Glib::build_filename (realPath, currDir));
|
||||
fileFound = parseDir (rp, vp, currDir, folder, level + 1, 0);
|
||||
} else {
|
||||
size_t lastdot = currDir.find_last_of ('.');
|
||||
|
||||
if (lastdot != Glib::ustring::npos && lastdot == currDir.length() - 4 && currDir.substr(lastdot).casefold() == paramFileExtension) {
|
||||
if (lastdot != Glib::ustring::npos && lastdot == currDir.length() - 4 && currDir.substr (lastdot).casefold() == paramFileExtension) {
|
||||
// file found
|
||||
if( options.rtSettings.verbose ) {
|
||||
if ( options.rtSettings.verbose ) {
|
||||
printf ("Processing file %s...", fname.c_str());
|
||||
}
|
||||
|
||||
Glib::ustring name = currDir.substr(0, lastdot);
|
||||
Glib::ustring name = currDir.substr (0, lastdot);
|
||||
|
||||
// create the partial profile
|
||||
AutoPartialProfile *pProf = new AutoPartialProfile();
|
||||
@@ -217,18 +217,18 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
||||
if (!res && pProf->pparams->ppVersion >= 220) {
|
||||
fileFound = true;
|
||||
|
||||
if( options.rtSettings.verbose ) {
|
||||
if ( options.rtSettings.verbose ) {
|
||||
printf ("OK\n");
|
||||
}
|
||||
|
||||
// adding this file to the list
|
||||
ProfileStoreEntry* filePSE = new ProfileStoreEntry(name, PSET_FILE, folder, 0);
|
||||
entries.push_back(filePSE);
|
||||
ProfileStoreEntry* filePSE = new ProfileStoreEntry (name, PSET_FILE, folder, 0);
|
||||
entries.push_back (filePSE);
|
||||
|
||||
// map the partial profile
|
||||
partProfiles[filePSE] = pProf;
|
||||
//partProfiles.insert( std::pair<ProfileStoreEntry*, rtengine::procparams::AutoPartialProfile*> (filePSE, pProf) );
|
||||
} else if( options.rtSettings.verbose ) {
|
||||
} else if ( options.rtSettings.verbose ) {
|
||||
printf ("failed!\n");
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
|
||||
return fileFound;
|
||||
}
|
||||
|
||||
int ProfileStore::findFolderId(const Glib::ustring &path)
|
||||
int ProfileStore::findFolderId (const Glib::ustring &path)
|
||||
{
|
||||
// initialization must have been done when calling this
|
||||
for (std::vector<Glib::ustring>::iterator i = folders.begin(); i != folders.end(); ++i) {
|
||||
@@ -265,7 +265,7 @@ int ProfileStore::findFolderId(const Glib::ustring &path)
|
||||
* but have to begin with a virtual location ( ${G} or ${U} )
|
||||
* Will return null on invalid path or if the entry can't be found
|
||||
*/
|
||||
const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path)
|
||||
const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU (Glib::ustring path)
|
||||
{
|
||||
if (path.empty()) {
|
||||
return nullptr;
|
||||
@@ -281,37 +281,37 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
|
||||
|
||||
// consistently apply casefold() to make sure dot position is correct
|
||||
const Glib::ustring casefolded_path = path.casefold();
|
||||
const Glib::ustring::size_type lastdot_pos = casefolded_path.find_last_of('.');
|
||||
const Glib::ustring::size_type lastdot_pos = casefolded_path.find_last_of ('.');
|
||||
|
||||
if (
|
||||
lastdot_pos != Glib::ustring::npos
|
||||
&& lastdot_pos <= casefolded_path.size() - 4
|
||||
&& !casefolded_path.compare(lastdot_pos, 4, paramFileExtension)
|
||||
&& !casefolded_path.compare (lastdot_pos, 4, paramFileExtension)
|
||||
) {
|
||||
// removing the extension
|
||||
// now use dot position without casefold()
|
||||
path = path.substr(0, path.find_last_of('.'));
|
||||
path = path.substr (0, path.find_last_of ('.'));
|
||||
}
|
||||
|
||||
// dir separator may come from options file and may be \ or /, we convert them to G_DIR_SEPARATOR_S
|
||||
if (path.size() > 4 && (path[4] == '/' || path[4] == '\\')) {
|
||||
path = path.substr(0, 4) + G_DIR_SEPARATOR_S + path.substr(5);
|
||||
path = path.substr (0, 4) + G_DIR_SEPARATOR_S + path.substr (5);
|
||||
}
|
||||
|
||||
// removing the filename
|
||||
Glib::ustring fName = Glib::path_get_basename(path);
|
||||
Glib::ustring fName = Glib::path_get_basename (path);
|
||||
|
||||
if (!fName.empty()) {
|
||||
path = path.substr(0, path.length() - fName.length());
|
||||
path = path.substr (0, path.length() - fName.length());
|
||||
} else {
|
||||
// path is malformed, returning NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
path = Glib::path_get_dirname(path);
|
||||
path = Glib::path_get_dirname (path);
|
||||
|
||||
// 1. find the path in the folder list
|
||||
int parentFolderId = findFolderId(path);
|
||||
int parentFolderId = findFolderId (path);
|
||||
|
||||
if (parentFolderId == -1) {
|
||||
return nullptr;
|
||||
@@ -330,10 +330,10 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
|
||||
}
|
||||
|
||||
/** Protected version of findEntryFromFullPathU */
|
||||
const ProfileStoreEntry* ProfileStore::findEntryFromFullPath(Glib::ustring path)
|
||||
const ProfileStoreEntry* ProfileStore::findEntryFromFullPath (Glib::ustring path)
|
||||
{
|
||||
MyMutex::MyLock lock(parseMutex);
|
||||
return findEntryFromFullPathU(path);
|
||||
MyMutex::MyLock lock (parseMutex);
|
||||
return findEntryFromFullPathU (path);
|
||||
}
|
||||
|
||||
const PartialProfile* ProfileStore::getProfile (Glib::ustring path)
|
||||
@@ -343,13 +343,13 @@ const PartialProfile* ProfileStore::getProfile (Glib::ustring path)
|
||||
parseProfiles();
|
||||
}
|
||||
|
||||
const ProfileStoreEntry *pse = findEntryFromFullPath(path);
|
||||
const ProfileStoreEntry *pse = findEntryFromFullPath (path);
|
||||
|
||||
if (!pse) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return getProfile(pse);
|
||||
return getProfile (pse);
|
||||
}
|
||||
|
||||
const PartialProfile* ProfileStore::getProfile (const ProfileStoreEntry* entry)
|
||||
@@ -359,20 +359,20 @@ const PartialProfile* ProfileStore::getProfile (const ProfileStoreEntry* entry)
|
||||
parseProfiles();
|
||||
}
|
||||
|
||||
MyMutex::MyLock lock(parseMutex);
|
||||
MyMutex::MyLock lock (parseMutex);
|
||||
|
||||
if (entry == internalDefaultEntry) {
|
||||
return internalDefaultProfile;
|
||||
}
|
||||
|
||||
std::map<const ProfileStoreEntry*, rtengine::procparams::AutoPartialProfile*>::iterator iter = partProfiles.find(entry);
|
||||
std::map<const ProfileStoreEntry*, rtengine::procparams::AutoPartialProfile*>::iterator iter = partProfiles.find (entry);
|
||||
|
||||
if (iter != partProfiles.end()) {
|
||||
return iter->second;
|
||||
} else {
|
||||
// This shouldn't happen!
|
||||
#ifndef NDEBUG
|
||||
printf("WARNING! Profile not found!\n");
|
||||
printf ("WARNING! Profile not found!\n");
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
@@ -440,10 +440,10 @@ const PartialProfile* ProfileStore::getDefaultPartialProfile (bool isRaw)
|
||||
return pProf;
|
||||
}
|
||||
|
||||
const Glib::ustring ProfileStore::getPathFromId(int folderId)
|
||||
const Glib::ustring ProfileStore::getPathFromId (int folderId)
|
||||
{
|
||||
// initialization must have been done when calling this
|
||||
return folders.at(folderId);
|
||||
return folders.at (folderId);
|
||||
}
|
||||
|
||||
|
||||
@@ -469,60 +469,63 @@ void ProfileStore::clearProfileList()
|
||||
partProfiles.clear();
|
||||
}
|
||||
|
||||
void ProfileStore::addListener(ProfileStoreListener *listener)
|
||||
void ProfileStore::addListener (ProfileStoreListener *listener)
|
||||
{
|
||||
listeners.push_back(listener);
|
||||
listeners.push_back (listener);
|
||||
}
|
||||
|
||||
void ProfileStore::removeListener(ProfileStoreListener *listener)
|
||||
void ProfileStore::removeListener (ProfileStoreListener *listener)
|
||||
{
|
||||
listeners.remove(listener);
|
||||
listeners.remove (listener);
|
||||
}
|
||||
|
||||
void ProfileStore::dumpFolderList()
|
||||
{
|
||||
printf("Folder list:\n------------\n");
|
||||
printf ("Folder list:\n------------\n");
|
||||
|
||||
for (unsigned int i = 0; i < folders.size(); i++) {
|
||||
printf(" #%3ud - %s\n", i, folders.at(i).c_str());
|
||||
printf (" #%3ud - %s\n", i, folders.at (i).c_str());
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
PartialProfile *ProfileStore::loadDynamicProfile(const ImageMetaData *im)
|
||||
PartialProfile *ProfileStore::loadDynamicProfile (const ImageMetaData *im)
|
||||
{
|
||||
if (storeState == STORESTATE_NOTINITIALIZED) {
|
||||
parseProfiles();
|
||||
}
|
||||
|
||||
PartialProfile *ret = new PartialProfile(true, true);
|
||||
PartialProfile *ret = new PartialProfile (true, true);
|
||||
|
||||
if (!rulesLoaded) {
|
||||
loadRules();
|
||||
}
|
||||
|
||||
for (auto rule : dynamicRules) {
|
||||
if (rule.matches(im)) {
|
||||
if (rule.matches (im)) {
|
||||
if (options.rtSettings.verbose) {
|
||||
printf("found matching profile %s\n", rule.profilepath.c_str());
|
||||
printf ("found matching profile %s\n", rule.profilepath.c_str());
|
||||
}
|
||||
const PartialProfile *p = getProfile(rule.profilepath);
|
||||
|
||||
const PartialProfile *p = getProfile (rule.profilepath);
|
||||
|
||||
if (p != nullptr) {
|
||||
p->applyTo(ret->pparams);
|
||||
p->applyTo (ret->pparams);
|
||||
} else {
|
||||
printf("ERROR loading matching profile from: %s\n", rule.profilepath.c_str());
|
||||
printf ("ERROR loading matching profile from: %s\n", rule.profilepath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ProfileStoreEntry::ProfileStoreEntry() : label(""), type(PSET_FOLDER), parentFolderId(0), folderId(0) {}
|
||||
ProfileStoreEntry::ProfileStoreEntry() : label (""), type (PSET_FOLDER), parentFolderId (0), folderId (0) {}
|
||||
|
||||
ProfileStoreEntry::ProfileStoreEntry(Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder) : label(label), type(type), parentFolderId(parentFolder), folderId(folder) {}
|
||||
ProfileStoreEntry::ProfileStoreEntry (Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder) : label (label), type (type), parentFolderId (parentFolder), folderId (folder) {}
|
||||
|
||||
void ProfileStoreEntry::setValues(Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder)
|
||||
void ProfileStoreEntry::setValues (Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder)
|
||||
{
|
||||
this->label = label;
|
||||
this->type = type;
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
* @param parentFolder index of the elements's path in the folder list
|
||||
* @param folder index of the folder's own path in the folder list
|
||||
*/
|
||||
ProfileStoreEntry(Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder);
|
||||
ProfileStoreEntry (Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder);
|
||||
|
||||
/** @brief Set the values of the object after its instantiation
|
||||
* @param label Label to be used in menu or combobox; also used as profile's filename
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
* @param parentFolder index of the elements's path in the folder list
|
||||
* @param folder index of the folder's own path in the folder list
|
||||
*/
|
||||
void setValues(Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder);
|
||||
void setValues (Glib::ustring label, PSEType type, unsigned short parentFolder, unsigned short folder);
|
||||
};
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class ProfileStore : public rtengine::NonCopyable, public DynamicProfileRules
|
||||
|
||||
private:
|
||||
struct SortProfiles {
|
||||
bool operator ()(const ProfileStoreEntry* const a1, const ProfileStoreEntry* const a2)
|
||||
bool operator () (const ProfileStoreEntry* const a1, const ProfileStoreEntry* const a2)
|
||||
{
|
||||
return a1->parentFolderId == a2->parentFolderId ? a1->label < a2->label : a1->parentFolderId < a2->parentFolderId;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ private:
|
||||
void _parseProfiles ();
|
||||
void clearFileList ();
|
||||
void clearProfileList ();
|
||||
const ProfileStoreEntry* findEntryFromFullPathU(Glib::ustring path);
|
||||
const ProfileStoreEntry* findEntryFromFullPathU (Glib::ustring path);
|
||||
|
||||
public:
|
||||
|
||||
@@ -167,15 +167,15 @@ public:
|
||||
|
||||
bool init (bool loadAll = true);
|
||||
void parseProfiles ();
|
||||
int findFolderId(const Glib::ustring &path);
|
||||
const ProfileStoreEntry* findEntryFromFullPath(Glib::ustring path);
|
||||
int findFolderId (const Glib::ustring &path);
|
||||
const ProfileStoreEntry* findEntryFromFullPath (Glib::ustring path);
|
||||
const rtengine::procparams::PartialProfile* getProfile (Glib::ustring path);
|
||||
const rtengine::procparams::PartialProfile* getProfile (const ProfileStoreEntry* entry);
|
||||
const std::vector<const ProfileStoreEntry*>* getFileList ();
|
||||
void releaseFileList ();
|
||||
const rtengine::procparams::ProcParams* getDefaultProcParams (bool isRaw);
|
||||
const rtengine::procparams::PartialProfile* getDefaultPartialProfile (bool isRaw);
|
||||
const Glib::ustring getPathFromId(int folderId);
|
||||
const Glib::ustring getPathFromId (int folderId);
|
||||
const ProfileStoreEntry* getInternalDefaultPSE()
|
||||
{
|
||||
return internalDefaultEntry;
|
||||
@@ -186,10 +186,10 @@ public:
|
||||
return internalDynamicEntry;
|
||||
}
|
||||
|
||||
void addListener(ProfileStoreListener *listener);
|
||||
void removeListener(ProfileStoreListener *listener);
|
||||
void addListener (ProfileStoreListener *listener);
|
||||
void removeListener (ProfileStoreListener *listener);
|
||||
|
||||
rtengine::procparams::PartialProfile* loadDynamicProfile(const rtengine::ImageMetaData *im);
|
||||
rtengine::procparams::PartialProfile* loadDynamicProfile (const rtengine::ImageMetaData *im);
|
||||
|
||||
void dumpFolderList();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user