Hello community,

here is the log from the commit of package libyui-ncurses for openSUSE:Factory 
checked in at 2020-01-04 19:20:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libyui-ncurses (Old)
 and      /work/SRC/openSUSE:Factory/.libyui-ncurses.new.6675 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libyui-ncurses"

Sat Jan  4 19:20:42 2020 rev:52 rq:758469 version:2.54.4

Changes:
--------
--- /work/SRC/openSUSE:Factory/libyui-ncurses/libyui-ncurses.changes    
2019-12-14 12:04:58.971387319 +0100
+++ /work/SRC/openSUSE:Factory/.libyui-ncurses.new.6675/libyui-ncurses.changes  
2020-01-04 19:20:49.953123713 +0100
@@ -1,0 +2,21 @@
+Thu Dec 19 18:18:24 CET 2019 - [email protected]
+
+- handle new sort-key when sorting tables (bsc#1140018)
+- 2.54.4
+
+-------------------------------------------------------------------
+Mon Dec 16 17:31:52 CET 2019 - [email protected]
+
+- update selected item in table when changing sorting only if
+  multiselection mode is off (bsc#1159098)
+- 2.54.3
+
+-------------------------------------------------------------------
+Mon Dec 16 09:26:14 CET 2019 - [email protected]
+
+- sort new table content (unless keep-sorting flag is set) (part
+  of bsc#1140018 and part of #1159177)
+- update selected item in table when changing sorting (bsc#1159098)
+- 2.54.2
+
+-------------------------------------------------------------------

Old:
----
  libyui-ncurses-2.54.1.tar.bz2

New:
----
  libyui-ncurses-2.54.4.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libyui-ncurses-doc.spec ++++++
--- /var/tmp/diff_new_pack.Yr8kLc/_old  2020-01-04 19:20:51.317124318 +0100
+++ /var/tmp/diff_new_pack.Yr8kLc/_new  2020-01-04 19:20:51.317124318 +0100
@@ -20,7 +20,7 @@
 %define so_version 11
 
 Name:           %{parent}-doc
-Version:        2.54.1
+Version:        2.54.4
 Release:        0
 Source:         %{parent}-%{version}.tar.bz2
 

++++++ libyui-ncurses.spec ++++++
--- /var/tmp/diff_new_pack.Yr8kLc/_old  2020-01-04 19:20:51.329124323 +0100
+++ /var/tmp/diff_new_pack.Yr8kLc/_new  2020-01-04 19:20:51.333124325 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           libyui-ncurses
-Version:        2.54.1
+Version:        2.54.4
 Release:        0
 Source:         %{name}-%{version}.tar.bz2
 
@@ -33,8 +33,8 @@
 BuildRequires:  gcc-c++
 BuildRequires:  pkg-config
 
-# YCustomStatusItemSelector
-%define libyui_devel_version libyui-devel >= 3.9.0
+# YTableCell::sortKey
+%define libyui_devel_version libyui-devel >= 3.9.1
 BuildRequires:  %{libyui_devel_version}
 BuildRequires:  ncurses-devel
 

++++++ libyui-ncurses-2.54.1.tar.bz2 -> libyui-ncurses-2.54.4.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-ncurses-2.54.1/VERSION.cmake 
new/libyui-ncurses-2.54.4/VERSION.cmake
--- old/libyui-ncurses-2.54.1/VERSION.cmake     2019-12-13 15:51:24.000000000 
+0100
+++ new/libyui-ncurses-2.54.4/VERSION.cmake     2019-12-20 10:31:03.000000000 
+0100
@@ -1,6 +1,6 @@
 SET( VERSION_MAJOR "2" )
 SET( VERSION_MINOR "54" )
-SET( VERSION_PATCH "1" )
+SET( VERSION_PATCH "4" )
 SET( VERSION 
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${GIT_SHA1_VERSION}" )
 
 ##### This is need for the libyui core, ONLY.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libyui-ncurses-2.54.1/package/libyui-ncurses-doc.spec 
new/libyui-ncurses-2.54.4/package/libyui-ncurses-doc.spec
--- old/libyui-ncurses-2.54.1/package/libyui-ncurses-doc.spec   2019-12-13 
15:51:24.000000000 +0100
+++ new/libyui-ncurses-2.54.4/package/libyui-ncurses-doc.spec   2019-12-20 
10:31:03.000000000 +0100
@@ -19,7 +19,7 @@
 %define so_version 11
 
 Name:           %{parent}-doc
-Version:        2.54.1
+Version:        2.54.4
 Release:        0
 Source:         %{parent}-%{version}.tar.bz2
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-ncurses-2.54.1/package/libyui-ncurses.changes 
new/libyui-ncurses-2.54.4/package/libyui-ncurses.changes
--- old/libyui-ncurses-2.54.1/package/libyui-ncurses.changes    2019-12-13 
15:51:24.000000000 +0100
+++ new/libyui-ncurses-2.54.4/package/libyui-ncurses.changes    2019-12-20 
10:31:03.000000000 +0100
@@ -1,4 +1,25 @@
 -------------------------------------------------------------------
+Thu Dec 19 18:18:24 CET 2019 - [email protected]
+
+- handle new sort-key when sorting tables (bsc#1140018)
+- 2.54.4
+
+-------------------------------------------------------------------
+Mon Dec 16 17:31:52 CET 2019 - [email protected]
+
+- update selected item in table when changing sorting only if
+  multiselection mode is off (bsc#1159098)
+- 2.54.3
+
+-------------------------------------------------------------------
+Mon Dec 16 09:26:14 CET 2019 - [email protected]
+
+- sort new table content (unless keep-sorting flag is set) (part
+  of bsc#1140018 and part of #1159177)
+- update selected item in table when changing sorting (bsc#1159098)
+- 2.54.2
+
+-------------------------------------------------------------------
 Fri Dec 13 11:56:57 CET 2019 - [email protected]
 
 - save flag for reverse sorting in SortStrategyBase (needed for
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-ncurses-2.54.1/package/libyui-ncurses.spec 
new/libyui-ncurses-2.54.4/package/libyui-ncurses.spec
--- old/libyui-ncurses-2.54.1/package/libyui-ncurses.spec       2019-12-13 
15:51:24.000000000 +0100
+++ new/libyui-ncurses-2.54.4/package/libyui-ncurses.spec       2019-12-20 
10:31:03.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           libyui-ncurses
-Version:        2.54.1
+Version:        2.54.4
 Release:        0
 Source:         %{name}-%{version}.tar.bz2
 
@@ -33,8 +33,8 @@
 BuildRequires:  gcc-c++
 BuildRequires:  pkg-config
 
-# YCustomStatusItemSelector
-%define libyui_devel_version libyui-devel >= 3.9.0
+# YTableCell::sortKey
+%define libyui_devel_version libyui-devel >= 3.9.1
 BuildRequires:  %{libyui_devel_version}
 BuildRequires:  ncurses-devel
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-ncurses-2.54.1/src/NCTable.cc 
new/libyui-ncurses-2.54.4/src/NCTable.cc
--- old/libyui-ncurses-2.54.1/src/NCTable.cc    2019-12-13 15:51:24.000000000 
+0100
+++ new/libyui-ncurses-2.54.4/src/NCTable.cc    2019-12-20 10:31:03.000000000 
+0100
@@ -294,6 +294,15 @@
     {
        addItem( *it, true);
     }
+
+    if ( !keepSorting() )
+    {
+       myPad()->sort();
+
+       if (!multiselect)
+           selectCurrentItem();
+    }
+
     DrawPad();
 }
 
@@ -540,8 +549,13 @@
                        int column = dialog->post();
 
                        if ( column != -1 )
+                       {
                            myPad()->setOrder( column, true );  //enable 
sorting in reverse order
 
+                           if (!multiselect)
+                               selectCurrentItem();
+                       }
+
                        //remove the popup
                        YDialog::deleteTopmostDialog();
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-ncurses-2.54.1/src/NCTablePad.cc 
new/libyui-ncurses-2.54.4/src/NCTablePad.cc
--- old/libyui-ncurses-2.54.1/src/NCTablePad.cc 2019-12-13 15:51:24.000000000 
+0100
+++ new/libyui-ncurses-2.54.4/src/NCTablePad.cc 2019-12-20 10:31:03.000000000 
+0100
@@ -28,6 +28,79 @@
 #include "NCPopupMenu.h"
 
 #include <limits.h>
+#include <string>
+
+
+void
+NCTableSortDefault::sort ( std::vector<NCTableLine *>::iterator itemsBegin,
+                          std::vector<NCTableLine *>::iterator itemsEnd )
+{
+    std::sort ( itemsBegin, itemsEnd, Compare(getColumn(), isReverse()) );
+}
+
+
+bool
+NCTableSortDefault::Compare::operator() ( const NCTableLine * first,
+                                         const NCTableLine * second ) const
+{
+    std::wstring w1 = smartSortKey( first );
+    std::wstring w2 = smartSortKey( second );
+
+    bool ok1, ok2;
+    long long number1 = toNumber(w1, &ok1);
+    long long number2 = toNumber(w2, &ok2);
+
+    if ( ok1 && ok2 )
+    {
+       // both are numbers
+       return !reverse ? number1 < number2 : number1 > number2;
+    }
+    else if (ok1 && !ok2)
+    {
+       // int < string
+       return true;
+    }
+    else if (!ok1 && ok2)
+    {
+       // string > int
+       return false;
+    }
+    else
+    {
+       // compare strings using collating information
+       int result = std::wcscoll ( w1.c_str(), w2.c_str() );
+
+       return !reverse ? result < 0 : result > 0;
+    }
+}
+
+
+long long
+NCTableSortDefault::Compare::toNumber(const std::wstring& s, bool* ok) const
+{
+    try
+    {
+       *ok = true;
+       return std::stoll(s);
+    }
+    catch (...)
+    {
+       *ok = false;
+       return 0;
+    }
+}
+
+
+std::wstring
+NCTableSortDefault::Compare::smartSortKey( const NCTableLine * tableLine ) 
const
+{
+    const YTableCell* tableCell = tableLine->origItem()->cell(column);
+
+    if (tableCell->hasSortKey())
+       return NCstring(tableCell->sortKey()).str();
+    else
+       return tableLine->GetCol( column )->Label().getText().begin()->str();
+}
 
 
 NCTablePad::NCTablePad( int lines, int cols, const NCWidget & p )
@@ -350,29 +423,32 @@
     if ( col < 0 )
        return;
 
-    bool changed = false;
-
     if ( sortStrategy->getColumn() != col )
     {
        sortStrategy->setColumn( col );
        sortStrategy->setReverse( false );
-
-       changed = true;
     }
     else if ( do_reverse )
     {
        sortStrategy->setReverse( !sortStrategy->isReverse() );
-
-       changed = true;
     }
 
-    if (changed)
-    {
-       sortStrategy->sort( Items.begin(), Items.end() );
+    // libyui-ncurses-pkg relies on the fact that this function always
+    // does a sort
 
-       dirty = true;
-       update();
-    }
+    sort();
+}
+
+
+void NCTablePad::sort()
+{
+    if (sortStrategy->getColumn() < 0)
+       return;
+
+    sortStrategy->sort( Items.begin(), Items.end() );
+
+    dirty = true;
+    update();
 }
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-ncurses-2.54.1/src/NCTablePad.h 
new/libyui-ncurses-2.54.4/src/NCTablePad.h
--- old/libyui-ncurses-2.54.1/src/NCTablePad.h  2019-12-13 15:51:24.000000000 
+0100
+++ new/libyui-ncurses-2.54.4/src/NCTablePad.h  2019-12-20 10:31:03.000000000 
+0100
@@ -41,7 +41,8 @@
 {
 public:
 
-    NCTableSortStrategyBase() : _column(-1), _reverse(false) {}
+    NCTableSortStrategyBase() : _column(0), _reverse(false) {}
+    NCTableSortStrategyBase(int column) : _column(column), _reverse(false) {}
 
     virtual ~NCTableSortStrategyBase() {}
 
@@ -68,13 +69,8 @@
 class NCTableSortDefault : public NCTableSortStrategyBase
 {
 public:
-    virtual void sort (
-                      std::vector<NCTableLine *>::iterator itemsBegin,
-                      std::vector<NCTableLine *>::iterator itemsEnd
-                      ) override
-        {
-           std::sort ( itemsBegin, itemsEnd, Compare(getColumn(), isReverse()) 
);
-       }
+    virtual void sort ( std::vector<NCTableLine *>::iterator itemsBegin,
+                       std::vector<NCTableLine *>::iterator itemsEnd ) 
override;
 
 private:
     class Compare
@@ -84,35 +80,16 @@
            : column(column), reverse(reverse)
            {}
 
-       // TODO does the comparator always guarantee strict weak
-       // ordering, e.g. when mixing strings and numbers?
-
        bool operator() ( const NCTableLine * first,
-                         const NCTableLine * second ) const
-           {
-                std::wstring w1 = first->GetCol( column 
)->Label().getText().begin()->str();
-                std::wstring w2 = second->GetCol( column 
)->Label().getText().begin()->str();
-               wchar_t *endptr1 = 0;
-               wchar_t *endptr2 = 0;
-
-               long long number1 = std::wcstoll( w1.c_str(), &endptr1, 10 );
-               long long number2 = std::wcstoll( w2.c_str(), &endptr2, 10 );
-
-               if ( *endptr1 == L'\0' && *endptr2 == L'\0' )
-               {
-                   // both are numbers
-                   return !reverse ? number1 < number2 : number1 > number2;
-               }
-               else
-               {
-                   // compare strings using collating information
-                   int result = std::wcscoll ( w1.c_str(), w2.c_str() );
-
-                   return !reverse ? result < 0 : result > 0;
-               }
-           }
+                         const NCTableLine * second ) const;
 
     private:
+
+       // if available returns the sort key otherwise the first line of the 
label
+       std::wstring smartSortKey( const NCTableLine * tableLine ) const;
+
+       long long toNumber(const std::wstring& s, bool* ok) const;
+
        const int column;
        const bool reverse;
     };
@@ -229,6 +206,8 @@
 
     void setOrder( int column, bool do_reverse = false );
 
+    void sort();
+
 public:
 
     bool SetHeadline( const std::vector<NCstring> & head );


Reply via email to