fix bug-467: 配置项初始状态,增加对父项禁用状态的判断
This commit is contained in:
parent
640c0c0617
commit
57104089e2
|
@ -1231,7 +1231,7 @@ SANE_Option_Descriptor* hg_sane_middleware::from_json(scanner_handle h, const st
|
||||||
// master = "";
|
// master = "";
|
||||||
// m->get_value_as_string("cur", master, integer);
|
// m->get_value_as_string("cur", master, integer);
|
||||||
// local_utility::trans_language_if_was_word_id(val);
|
// local_utility::trans_language_if_was_word_id(val);
|
||||||
so.enable_now = so.is_enable(so.master, (*it)->cur_vals);
|
so.enable_now = so.is_enable(h, so.master, (*it)->cur_vals);
|
||||||
if (!so.enable_now)
|
if (!so.enable_now)
|
||||||
ret->cap |= SANE_CAP_INACTIVE;
|
ret->cap |= SANE_CAP_INACTIVE;
|
||||||
//}
|
//}
|
||||||
|
@ -2107,7 +2107,7 @@ bool hg_sane_middleware::compare_val_not_between(const char* cur_val, const char
|
||||||
return !hg_sane_middleware::compare_val_between(cur_val, limit_l, limit_r);
|
return !hg_sane_middleware::compare_val_between(cur_val, limit_l, limit_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hg_sane_middleware::is_enable_and(const std::vector<MASTEROP>& master, std::vector<CURVAL>& curvals)
|
bool hg_sane_middleware::is_enable_and(scanner_handle hdev, const std::vector<MASTEROP>& master, std::vector<CURVAL>& curvals)
|
||||||
{
|
{
|
||||||
// NOTE: logical operator '&&' should get all master's value to check, here we only consider ONE master !!!!
|
// NOTE: logical operator '&&' should get all master's value to check, here we only consider ONE master !!!!
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
@ -2121,11 +2121,17 @@ bool hg_sane_middleware::is_enable_and(const std::vector<MASTEROP>& master, std:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
enabled &= master[i].compare_val(it->val.c_str(), master[i].limit_l.c_str(), master[i].limit_r.c_str());
|
enabled &= master[i].compare_val(it->val.c_str(), master[i].limit_l.c_str(), master[i].limit_r.c_str());
|
||||||
|
if (enabled) // whether parent is enabled
|
||||||
|
{
|
||||||
|
const SANE_Option_Descriptor* desc = hg_sane_middleware::instance()->find_stored_descriptor(hdev, master[i].name.c_str());
|
||||||
|
if (desc && (desc->cap & SANE_CAP_INACTIVE))
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
bool hg_sane_middleware::is_enable_or(const std::vector<MASTEROP>& master, std::vector<CURVAL>& curvals)
|
bool hg_sane_middleware::is_enable_or(scanner_handle hdev, const std::vector<MASTEROP>& master, std::vector<CURVAL>& curvals)
|
||||||
{
|
{
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
|
|
||||||
|
@ -2139,6 +2145,12 @@ bool hg_sane_middleware::is_enable_or(const std::vector<MASTEROP>& master, std::
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled |= master[i].compare_val(it->val.c_str(), master[i].limit_l.c_str(), master[i].limit_r.c_str());
|
enabled |= master[i].compare_val(it->val.c_str(), master[i].limit_l.c_str(), master[i].limit_r.c_str());
|
||||||
|
if (enabled) // whether parent is enabled
|
||||||
|
{
|
||||||
|
const SANE_Option_Descriptor* desc = hg_sane_middleware::instance()->find_stored_descriptor(hdev, master[i].name.c_str());
|
||||||
|
if (desc && (desc->cap & SANE_CAP_INACTIVE))
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return enabled;
|
return enabled;
|
||||||
|
@ -2334,7 +2346,7 @@ int hg_sane_middleware::something_after_do(LPDEVINST dev, const char* master_nam
|
||||||
bool enable = changed_options[i].enable;
|
bool enable = changed_options[i].enable;
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
// if (enable)
|
// if (enable)
|
||||||
enable = dev->slaves[slave].is_enable(dev->slaves[slave].master, dev->cur_vals);
|
enable = dev->slaves[slave].is_enable(dev->dev, dev->slaves[slave].master, dev->cur_vals);
|
||||||
if (enable == dev->slaves[slave].enable_now)
|
if (enable == dev->slaves[slave].enable_now)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ typedef struct _slave_option
|
||||||
std::string name;
|
std::string name;
|
||||||
bool enable_now;
|
bool enable_now;
|
||||||
std::vector<MASTEROP> master;
|
std::vector<MASTEROP> master;
|
||||||
bool (*is_enable)(const std::vector<MASTEROP>& master
|
bool (*is_enable)(scanner_handle hdev, const std::vector<MASTEROP>& master
|
||||||
, std::vector<CURVAL>& curvals/*参数全部字符串化*/); // logic 'and', 'or' opertions
|
, std::vector<CURVAL>& curvals/*参数全部字符串化*/); // logic 'and', 'or' opertions
|
||||||
}SLAVEOP;
|
}SLAVEOP;
|
||||||
typedef struct _opt_status
|
typedef struct _opt_status
|
||||||
|
@ -168,8 +168,8 @@ class hg_sane_middleware
|
||||||
static bool compare_val_between(const char* cur_val, const char* limit_l, const char* limit_r);
|
static bool compare_val_between(const char* cur_val, const char* limit_l, const char* limit_r);
|
||||||
static bool compare_val_not_between(const char* cur_val, const char* limit_l, const char* limit_r);
|
static bool compare_val_not_between(const char* cur_val, const char* limit_l, const char* limit_r);
|
||||||
|
|
||||||
static bool is_enable_and(const std::vector<MASTEROP>& master, std::vector<CURVAL>& curvals);
|
static bool is_enable_and(scanner_handle hdev, const std::vector<MASTEROP>& master, std::vector<CURVAL>& curvals);
|
||||||
static bool is_enable_or(const std::vector<MASTEROP>& master, std::vector<CURVAL>& curvals);
|
static bool is_enable_or(scanner_handle hdev, const std::vector<MASTEROP>& master, std::vector<CURVAL>& curvals);
|
||||||
//std::vector<SLAVEOP> slave_options_;
|
//std::vector<SLAVEOP> slave_options_;
|
||||||
//std::vector<std::string> master_options_;
|
//std::vector<std::string> master_options_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue