属性添加界面显示位置字段,同组属性将优先按该字段排序
This commit is contained in:
parent
123a0c5a31
commit
51b93c08df
|
@ -91,9 +91,6 @@ char* sane_opt_provider::get_value(const char* name, void* value, size_t* size,
|
|||
}
|
||||
int sane_opt_provider::set_value(const char* name, void* val)
|
||||
{
|
||||
if (following_.count(name))
|
||||
return following_[name]->set_value(name, val);
|
||||
else
|
||||
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
||||
}
|
||||
void sane_opt_provider::enable(const char* name, bool able)
|
||||
|
|
|
@ -1152,13 +1152,42 @@ void device_option::insert_option(gb_json* opt, sane_opt_provider* from, const c
|
|||
}
|
||||
else
|
||||
{
|
||||
int index = -1;
|
||||
int index = -1, pos = -1;
|
||||
|
||||
if (group)
|
||||
index = insert_group(group, group);
|
||||
index = next_group(index + 1);
|
||||
|
||||
// insert poisition according to 'ui-pos'
|
||||
if (!opt->get_value("ui-pos", pos) || pos == -1)
|
||||
{
|
||||
index = next_group(index + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (index++; index < origin_->children(); ++index)
|
||||
{
|
||||
gb_json* sib = origin_->child(index);
|
||||
std::string t("");
|
||||
int sit = -1;
|
||||
|
||||
if (!sib->get_value("type", t) || t == JSON_SANE_TYPE_GROUP)
|
||||
{
|
||||
sib->release();
|
||||
break;
|
||||
}
|
||||
if (!sib->get_value("ui-pos", sit) || sit == -1)
|
||||
{
|
||||
sib->release();
|
||||
break;
|
||||
}
|
||||
sib->release();
|
||||
|
||||
if (pos < sit)
|
||||
break;
|
||||
}
|
||||
}
|
||||
origin_->insert(index, opt->key().c_str(), opt);
|
||||
|
||||
src_[opt->key()] = from;
|
||||
from->add_ref();
|
||||
}
|
||||
|
@ -1920,7 +1949,7 @@ std::string device_option::get_name_by_sane_id(int sane_ind)
|
|||
|
||||
return std::move(value);
|
||||
}
|
||||
std::string device_option::get_option_value_type(const char* name)
|
||||
std::string device_option::get_option_value_type(const char* name, size_t* size)
|
||||
{
|
||||
std::string value("");
|
||||
gb_json* jsn = now_ ? now_ : origin_;
|
||||
|
@ -1933,6 +1962,12 @@ std::string device_option::get_option_value_type(const char* name)
|
|||
if (child)
|
||||
{
|
||||
child->get_value("type", value);
|
||||
if (size)
|
||||
{
|
||||
int v = 0;
|
||||
child->get_value("size", v);
|
||||
*size = v;
|
||||
}
|
||||
child->release();
|
||||
}
|
||||
}
|
||||
|
@ -2009,7 +2044,7 @@ std::string device_option::get_option_field_string(const char* name, const char*
|
|||
|
||||
return std::move(value);
|
||||
}
|
||||
std::string device_option::get_option_value_type(int sane_ind)
|
||||
std::string device_option::get_option_value_type(int sane_ind, size_t* size)
|
||||
{
|
||||
std::string value("");
|
||||
gb_json* jsn = now_ ? now_ : origin_;
|
||||
|
@ -2018,6 +2053,12 @@ std::string device_option::get_option_value_type(int sane_ind)
|
|||
{
|
||||
gb_json* child = now_->child(sane_ind - 1);
|
||||
child->get_value("type", value);
|
||||
if (size)
|
||||
{
|
||||
int v = 0;
|
||||
child->get_value("size", v);
|
||||
*size = v;
|
||||
}
|
||||
child->release();
|
||||
}
|
||||
|
||||
|
|
|
@ -362,8 +362,8 @@ public:
|
|||
int count(void); // return option count
|
||||
bool is_auto_restore_default(const char* name);
|
||||
std::string get_name_by_sane_id(int sane_ind);
|
||||
std::string get_option_value_type(const char* name);
|
||||
std::string get_option_value_type(int sane_ind);
|
||||
std::string get_option_value_type(const char* name, size_t* size = nullptr);
|
||||
std::string get_option_value_type(int sane_ind, size_t* size = nullptr);
|
||||
std::string get_option_field_string(const char* name, const char* key);
|
||||
std::string get_option_value(const char* name, int type/*OPT_VAL_xxx*/, int* size = nullptr, void* in_data = nullptr); // return whole json-text if name was null
|
||||
std::string get_option_value(int sane_ind, int type/*OPT_VAL_xxx*/, int* size = nullptr, void* in_data = nullptr); // return whole json-text if name was null
|
||||
|
|
Loading…
Reference in New Issue