From 42c006416c8aa70ef5efe7e31988cb4143e32256 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 6 Jan 2017 10:14:26 +0000 Subject: [PATCH] CtrlLib: ArrayCtrl::SortingFrom, GateN issues git-svn-id: svn://ultimatepp.org/upp/trunk@10653 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Callback.h | 2 ++ uppsrc/CtrlLib/ArrayCtrl.cpp | 26 ++++++++-------------- uppsrc/CtrlLib/ArrayCtrl.h | 4 +++- uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp | 9 +++++++- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/uppsrc/Core/Callback.h b/uppsrc/Core/Callback.h index 7372368f8..c9578afa2 100644 --- a/uppsrc/Core/Callback.h +++ b/uppsrc/Core/Callback.h @@ -57,6 +57,8 @@ public: GateN(const GateN& a) : fn(a.fn) {} GateN& operator=(const GateN& a) { fn = a.fn; return *this; } + GateN(const Fn& src) : fn(src) {} + GateN(Fn&& src, int) : fn(pick(src)) {} GateN& operator=(GateN&& a) { fn = pick(a.fn); return *this; } diff --git a/uppsrc/CtrlLib/ArrayCtrl.cpp b/uppsrc/CtrlLib/ArrayCtrl.cpp index c2f56c0f7..f7bad2d3e 100644 --- a/uppsrc/CtrlLib/ArrayCtrl.cpp +++ b/uppsrc/CtrlLib/ArrayCtrl.cpp @@ -2416,22 +2416,6 @@ void ArrayCtrl::ReArrange(const Vector& order) SyncInfo(); } -void ArrayCtrl::Sort(const ArrayCtrl::Order& order) { - KillCursor(); - ClearSelection(); - ClearCache(); - SortPredicate sp; - sp.order = ℴ - if(ln.GetCount() || cellinfo.GetCount()) { - SortA(); - SortB(GetStableSortOrder(array, sp)); - } - else - StableSort(array, sp); - Refresh(); - SyncInfo(); -} - void ArrayCtrl::Sort(int from, int count, Gate2 order) { KillCursor(); @@ -2449,7 +2433,8 @@ void ArrayCtrl::Sort(int from, int count, Gate2 order) void ArrayCtrl::Sort(Gate2 order) { - Sort(0, array.GetCount(), order); + if(sorting_from < array.GetCount()) + Sort(sorting_from, array.GetCount() - sorting_from, order); } bool ArrayCtrl::OrderPred(int i1, int i2, const ArrayCtrl::Order *o) @@ -2462,6 +2447,12 @@ void ArrayCtrl::Sort(int from, int count, const ArrayCtrl::Order& order) Sort(from, count, THISBACK1(OrderPred, &order)); } +void ArrayCtrl::Sort(const ArrayCtrl::Order& order) +{ + if(sorting_from < array.GetCount()) + Sort(sorting_from, array.GetCount() - sorting_from, order); +} + struct sAC_ColumnSort : public ValueOrder { bool descending; const ValueOrder *order; @@ -2687,6 +2678,7 @@ void ArrayCtrl::Reset() { Clear(); sb.SetLine(linecy); columnsortsecondary = NULL; + sorting_from = 0; min_visible_line = 0; max_visible_line = INT_MAX; ctrl_low = ctrl_high = 0; diff --git a/uppsrc/CtrlLib/ArrayCtrl.h b/uppsrc/CtrlLib/ArrayCtrl.h index 923b8d8ec..fcc1b85d4 100644 --- a/uppsrc/CtrlLib/ArrayCtrl.h +++ b/uppsrc/CtrlLib/ArrayCtrl.h @@ -195,6 +195,7 @@ private: const Order *columnsortsecondary; int min_visible_line, max_visible_line; int ctrl_low, ctrl_high; + int sorting_from; Index id_ndx; int keypos; @@ -531,8 +532,8 @@ public: void ReArrange(const Vector& order); - void Sort(Gate2 order); void Sort(int from, int count, Gate2 order); + void Sort(Gate2 order); void Sort(const ArrayCtrl::Order& order); void Sort(int from, int count, const ArrayCtrl::Order& order); void Sort(int (*compare)(const Vector& v1, const Vector& v2)); @@ -681,6 +682,7 @@ public: ArrayCtrl& AllSorting(); ArrayCtrl& ColumnSortSecondary(const Order& order) { columnsortsecondary = ℴ return *this; } ArrayCtrl& NoColumnSortSecondary() { columnsortsecondary = NULL; return *this; } + ArrayCtrl& SortingFrom(int from) { sorting_from = from; return *this; } ArrayCtrl& ColumnWidths(const char *s); String GetColumnWidths(); diff --git a/uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp b/uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp index 5154817a5..8bb2abed6 100644 --- a/uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp @@ -1018,7 +1018,14 @@ they are ordered by this predicate.&] [s4; &] [s5;:ArrayCtrl`:`:NoColumnSortSecondary`(`): [_^ArrayCtrl^ ArrayCtrl][@(0.0.255) `&]_[* NoC olumnSortSecondary]()&] -[s2; Same as ColumnSortSecondary(false).&] +[s2; Removes secondary sorting predicate..&] +[s3; &] +[s4;%- &] +[s5;:Upp`:`:ArrayCtrl`:`:SortingFrom`(int`):%- [_^Upp`:`:ArrayCtrl^ ArrayCtrl][@(0.0.255) `& +]_[* SortingFrom]([@(0.0.255) int]_[*@3 from])&] +[s2; When ArrayCtrl is sorted (without specifying the range of lines), +specifies the first column sorted. This allows for easy header +or summation line.&] [s3; &] [s4; &] [s5;:ArrayCtrl`:`:ColumnWidths`(const char`*`): [_^ArrayCtrl^ ArrayCtrl][@(0.0.255) `&]_[* C