VirtualBox

Changeset 65422 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 24, 2017 1:55:14 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
113035
Message:

WuiListContentBase: Indicate sorting direction (weekly meeting again).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/ValidationKit/testmanager/webui/wuicontentbase.py

    r65352 r65422  
    940940        return sNavigation;
    941941
    942     def _isSortingByColumnAscending(self, aiColumns):
    943         """ Checks if we're already sorting by this column in ascending order """
    944         # Just compare the first sorting column spec for now.
    945         #if self._aiSelectedSortColumns is not None and len(aiColumns) <= len(self._aiSelectedSortColumns):
    946         if  len(aiColumns) <= len(self._aiSelectedSortColumns):
    947             if list(aiColumns) == list(self._aiSelectedSortColumns[:len(aiColumns)]):
    948                 return True;
    949         return False;
     942    def _checkSortingByColumnAscending(self, aiColumns):
     943        """
     944        Checks if we're sorting by this column.
     945
     946        Returns 0 if not sorting by this, negative if descending, positive if ascending.  The
     947        value indicates the priority (nearer to 0 is higher).
     948        """
     949        if len(aiColumns) <= len(self._aiSelectedSortColumns):
     950            aiColumns    = list(aiColumns);
     951            aiNegColumns = list([-i for i in aiColumns]);
     952            i = 0;
     953            while i + len(aiColumns) <= len(self._aiSelectedSortColumns):
     954                aiSub = list(self._aiSelectedSortColumns[i : i + len(aiColumns)]);
     955                if aiSub == aiColumns:
     956                    return 1 + i;
     957                if aiSub == aiNegColumns:
     958                    return -1 - i;
     959                i += 1;
     960        return 0;
    950961
    951962    def _generateTableHeaders(self):
     
    962973            elif iHeader < len(self._aaiColumnSorting) and self._aaiColumnSorting[iHeader] is not None:
    963974                sHtml += '<th>'
    964                 if not self._isSortingByColumnAscending(self._aaiColumnSorting[iHeader]):
     975                iSorting = self._checkSortingByColumnAscending(self._aaiColumnSorting[iHeader]);
     976                if iSorting > 0:
     977                    sDirection  = '&nbsp;&#x25b4;' if iSorting == 1  else '<small>&nbsp;&#x25b5;</small>';
     978                    sSortParams = ','.join([str(-i) for i in self._aaiColumnSorting[iHeader]]);
     979                else:
     980                    sDirection = '';
     981                    if iSorting < 0:
     982                        sDirection  = '&nbsp;&#x25be;' if iSorting == -1 else '<small>&nbsp;&#x25bf;</small>'
    965983                    sSortParams = ','.join([str(i) for i in self._aaiColumnSorting[iHeader]]);
    966                 else:
    967                     sSortParams = ','.join([str(-i) for i in self._aaiColumnSorting[iHeader]]);
    968984                sHtml += '<a href="javascript:ahrefActionSortByColumns(\'%s\',[%s]);">' \
    969985                       % (WuiDispatcherBase.ksParamSortColumns, sSortParams);
    970                 sHtml += webutils.escapeElem(oHeader) + '</a></th>';
     986                sHtml += webutils.escapeElem(oHeader) + '</a>' + sDirection +  '</th>';
    971987            else:
    972988                sHtml += '<th>' + webutils.escapeElem(oHeader) + '</th>';
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette