to string take (uses) export options
This commit is contained in:
		
							parent
							
								
									2767fa75ca
								
							
						
					
					
						commit
						7fcd38816b
					
				@ -19,6 +19,7 @@
 | 
				
			|||||||
#include <stdexcept>
 | 
					#include <stdexcept>
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
#include <nana/system/dataexch.hpp>
 | 
					#include <nana/system/dataexch.hpp>
 | 
				
			||||||
 | 
					#include <cassert>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace nana
 | 
					namespace nana
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -344,20 +345,21 @@ namespace nana
 | 
				
			|||||||
                    return idx;
 | 
					                    return idx;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                nana::string to_string() const
 | 
					                nana::string to_string(const export_options& exp_opt) const
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    nana::string sep{STR(";")}, endl{STR("\n")}, head_str; 
 | 
					                    nana::string head_str; 
 | 
				
			||||||
                    bool first{true};
 | 
					                    bool first{true};
 | 
				
			||||||
					for(auto & i: cont())
 | 
					                    for( size_type idx{}; idx<exp_opt.columns_order.size(); ++idx)
 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						if(i.visible)
 | 
					 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
 | 
					                        assert(exp_opt.columns_order[idx] == cont()[idx].index );
 | 
				
			||||||
 | 
					                        assert(cont()[exp_opt.columns_order[idx]].visible || ! exp_opt.only_visible_columns);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if(first)
 | 
					                            if(first)
 | 
				
			||||||
                                first=false;
 | 
					                                first=false;
 | 
				
			||||||
                            else 
 | 
					                            else 
 | 
				
			||||||
                                head_str += sep;
 | 
					                            head_str += exp_opt.sep;
 | 
				
			||||||
							head_str += i.text;
 | 
					
 | 
				
			||||||
                        }
 | 
											head_str += cont()[idx].text;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
                    return head_str;
 | 
					                    return head_str;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -607,18 +609,18 @@ namespace nana
 | 
				
			|||||||
					return *this;
 | 
										return *this;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                nana::string to_string(const export_options::columns_indexs& col_order) const
 | 
					                nana::string to_string(const export_options& exp_opt) const
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    nana::string sep{STR(";")}, endl{STR("\n")}, item_str; 
 | 
					                    nana::string item_str; 
 | 
				
			||||||
                    bool first{true};
 | 
					                    bool first{true};
 | 
				
			||||||
                    for( size_type idx{}; idx<col_order.size(); ++idx)
 | 
					                    for( size_type idx{}; idx<exp_opt.columns_order.size(); ++idx)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
                            if(first)
 | 
					                            if(first)
 | 
				
			||||||
                                first=false;
 | 
					                                first=false;
 | 
				
			||||||
                            else 
 | 
					                            else 
 | 
				
			||||||
                                item_str += sep;
 | 
					                                item_str += exp_opt.sep;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							item_str += cells[col_order[idx]].text;
 | 
												item_str += cells[exp_opt.columns_order[idx]].text;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
                    return item_str;
 | 
					                    return item_str;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -695,7 +697,7 @@ namespace nana
 | 
				
			|||||||
					}
 | 
										}
 | 
				
			||||||
					return nullptr;
 | 
										return nullptr;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
                nana::string to_string() const;
 | 
					                nana::string to_string(const export_options& exp_opt) const;
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                /// each sort() ivalidate any existing reference from display position to absolute item, that is after sort() display offset point to different items
 | 
					                /// each sort() ivalidate any existing reference from display position to absolute item, that is after sort() display offset point to different items
 | 
				
			||||||
                void sort()
 | 
					                void sort()
 | 
				
			||||||
@ -1890,11 +1892,9 @@ namespace nana
 | 
				
			|||||||
					lister.fetch_ordering_comparer = std::bind(&es_header::fetch_comp, &header, std::placeholders::_1);
 | 
										lister.fetch_ordering_comparer = std::bind(&es_header::fetch_comp, &header, std::placeholders::_1);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                nana::string to_string() const
 | 
					                nana::string to_string(const export_options& exp_opt) const
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    nana::string sep{STR(";")}, endl{STR("\n")}; 
 | 
					                    return header.to_string(exp_opt) + exp_opt.endl + lister.to_string(exp_opt) ;
 | 
				
			||||||
                    lister.to_string();
 | 
					 | 
				
			||||||
                    return header.to_string() + endl + lister.to_string() ;
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const index_pair& scroll_y_abs() const
 | 
					                const index_pair& scroll_y_abs() const
 | 
				
			||||||
@ -2318,48 +2318,6 @@ namespace nana
 | 
				
			|||||||
                    API::refresh_window(lister.wd_ptr()->handle());
 | 
					                    API::refresh_window(lister.wd_ptr()->handle());
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
#if ( 0 )   
 | 
					 | 
				
			||||||
                void update_selection_range(index_pair to, const arg_mouse& arg)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					using item_state = essence_t::item_state;
 | 
					 | 
				
			||||||
					using parts = essence_t::parts;
 | 
					 | 
				
			||||||
					bool update = false;
 | 
					 | 
				
			||||||
					index_pair item_pos;
 | 
					 | 
				
			||||||
					bool sel = true;
 | 
					 | 
				
			||||||
					if (!lister.single_selection())
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						if (arg.shift)
 | 
					 | 
				
			||||||
							lister.select_display_range(lister.last_selected, item_pos, sel);
 | 
					 | 
				
			||||||
						else if (arg.ctrl)
 | 
					 | 
				
			||||||
							    sel = !item_proxy(essence_, index_pair (item_pos.cat, lister.absolute(item_pos))).selected();  
 | 
					 | 
				
			||||||
							else
 | 
					 | 
				
			||||||
								lister.select_for_all(false);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					else
 | 
					 | 
				
			||||||
						sel = !item_proxy(essence_, index_pair (item_pos.cat, lister.absolute(item_pos))).selected();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						item_ptr->flags.selected = sel;
 | 
					 | 
				
			||||||
						index_pair last_selected(item_pos.cat, lister.absolute(item_pos)); 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						arg_listbox arg{item_proxy{essence_, last_selected}, sel};
 | 
					 | 
				
			||||||
						lister.wd_ptr()->events().selected.emit(arg);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        if (item_ptr->flags.selected)
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
							lister.cancel_others_if_single_enabled(true, last_selected);
 | 
					 | 
				
			||||||
							essence_->lister.last_selected = last_selected;
 | 
					 | 
				
			||||||
								
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else if (essence_->lister.last_selected == last_selected)
 | 
					 | 
				
			||||||
								essence_->lister.last_selected.set_both(npos);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					else if(!lister.single_selection())
 | 
					 | 
				
			||||||
							lister.categ_selected(item_pos.cat, true);
 | 
					 | 
				
			||||||
					update = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
#endif			
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            void es_lister::scroll_refresh()
 | 
					            void es_lister::scroll_refresh()
 | 
				
			||||||
@ -2450,24 +2408,23 @@ namespace nana
 | 
				
			|||||||
						else break;
 | 
											else break;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
            nana::string es_lister::to_string() const
 | 
					            nana::string es_lister::to_string(const export_options& exp_opt) const
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                nana::string sep{STR(";")}, endl{STR("\n")}, list_str; 
 | 
					                nana::string list_str; 
 | 
				
			||||||
                auto col_order = ess_->header.all_headers(true);
 | 
					 | 
				
			||||||
                bool first{true};
 | 
					                bool first{true};
 | 
				
			||||||
				for(auto & cat: cat_container())
 | 
									for(auto & cat: cat_container())
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
                    if(first)
 | 
					                    if(first)
 | 
				
			||||||
                            first=false;
 | 
					                            first=false;
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
 						list_str += (cat.text + endl);
 | 
					 						list_str += (cat.text + exp_opt.endl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    bool first_item{true};
 | 
					                    bool first_item{true};
 | 
				
			||||||
                    for (auto i : cat.sorted)
 | 
					                    for (auto i : cat.sorted)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        auto& it= cat.items[i] ;
 | 
					                        auto& it= cat.items[i] ;
 | 
				
			||||||
                        if(it.flags.selected)
 | 
					                        if(it.flags.selected || !exp_opt.only_selected_items)
 | 
				
			||||||
                            list_str += (it.to_string(col_order) + endl);
 | 
					                            list_str += (it.to_string(exp_opt) + exp_opt.endl);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
                return list_str ;
 | 
					                return list_str ;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user