allow programmatically export an arbitrary set of columns

This commit is contained in:
qPCR4vir 2015-04-25 21:39:09 +02:00
parent 49378469ab
commit db0591a5db

View File

@ -351,15 +351,19 @@ namespace nana
bool first{true}; bool first{true};
for( size_type idx{}; idx<exp_opt.columns_order.size(); ++idx) for( size_type idx{}; idx<exp_opt.columns_order.size(); ++idx)
{ {
assert(exp_opt.columns_order[idx] == cont()[idx].index ); size_type index{exp_opt.columns_order[idx]};
assert(cont()[exp_opt.columns_order[idx]].visible || ! exp_opt.only_visible_columns); auto col = std::find_if(std::begin(cont()), std::end(cont()), [index](const column_t& col){return col.index == index;});
if(col == std::end(cont()) )
throw std::out_of_range("Trying to export from a lisboxt an inexisting column");
assert(col->visible || ! exp_opt.only_visible_columns);
if(first) if(first)
first=false; first=false;
else else
head_str += exp_opt.sep; head_str += exp_opt.sep;
head_str += cont()[idx].text; head_str += col->text;
} }
return head_str; return head_str;
} }