From c43eca998adbf37fda42c6069f99d34706cd4fc9 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 9 Jan 2017 14:17:58 +0000 Subject: [PATCH] GridCtrl: Pasting into column with Convert based EditField now uses Convert to convert the pasted text git-svn-id: svn://ultimatepp.org/upp/trunk@10686 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/GridCtrl/GridCtrl.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/uppsrc/GridCtrl/GridCtrl.cpp b/uppsrc/GridCtrl/GridCtrl.cpp index 52957dfad..4f8b7b06b 100644 --- a/uppsrc/GridCtrl/GridCtrl.cpp +++ b/uppsrc/GridCtrl/GridCtrl.cpp @@ -825,10 +825,10 @@ void GridCtrl::Paste(int mode) { int pr = 0; bool new_row = false; - + for(int i = 0; i < lines.GetCount(); i++) { - String line = TrimRight(lines[i]); + String line = TrimRight(lines[i]); Vector cells = Upp::Split(line, '\t', false); for(int j = 0; j < cells.GetCount(); j++) { @@ -849,7 +849,7 @@ void GridCtrl::Paste(int mode) rowidx = lr; new_row = lr >= tr || mode > 0; - + if(fixed_paste && new_row) break; @@ -2773,8 +2773,9 @@ void GridCtrl::SetFixedCols(int n) } } -void GridCtrl::Set0(int r, int c, const Value &val, bool paste) +void GridCtrl::Set0(int r, int c, const Value &val_, bool paste) { + Value val = val_; if(c > total_cols - 1) return; if(r > total_rows - 1) @@ -2785,18 +2786,25 @@ void GridCtrl::Set0(int r, int c, const Value &val, bool paste) int ri = vitems[r].id; Item &it = items[ri][c]; - if(it.isjoined) - { + if(it.isjoined) { ri = it.idy; c = it.idx; } - Ctrl * ctrl = items[ri][c].ctrl; - if(ctrl) - ctrl->SetData(val); - else - { + + Ctrl *ctrl = items[ri][c].ctrl; + bool setctrl = true; + if(!ctrl) { ctrl = edits[c].ctrl; - if(ctrl && ctrlid.y == ri) + setctrl = ctrlid.y == ri; + } + + if(ctrl) { + if(paste && IsString(val)) { + Convert *cv = dynamic_cast(ctrl); + if(cv) + val = cv->Scan(val); + } + if(setctrl) ctrl->SetData(val); }