diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 264b5149fb..163a9d8bd0 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -1568,6 +1568,8 @@ def main(args=sys.argv): QCoreApplication.setApplicationName(APP_UID) single_instance = None if SingleApplication is None else SingleApplication('calibre GUI') if not singleinstance('calibre GUI'): + if len(args) > 1: + args[1] = os.path.abspath(args[1]) if single_instance is not None and single_instance.is_running() and \ single_instance.send_message('launched:'+repr(args)): return 0 diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 3d11020626..da5790a621 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -157,6 +157,7 @@ class ResultCache(SearchQueryParser): def __init__(self): self._map = self._map_filtered = self._data = [] + self.first_sort = True SearchQueryParser.__init__(self) def __getitem__(self, row): @@ -269,25 +270,28 @@ class ResultCache(SearchQueryParser): if ans != 0: return ans return cmp(self._data[x][10], self._data[y][10]) - def cmp(self, loc, x, y, str=True): + def cmp(self, loc, x, y, str=True, subsort=False): try: ans = cmp(self._data[x][loc].lower(), self._data[y][loc].lower()) if str else\ cmp(self._data[x][loc], self._data[y][loc]) except AttributeError: # Some entries may be None ans = cmp(self._data[x][loc], self._data[y][loc]) - #if ans != 0: return ans - #return cmp(self._data[x][11].lower(), self._data[y][11].lower()) + if subsort and ans == 0: + return cmp(self._data[x][11].lower(), self._data[y][11].lower()) return ans - def sort(self, field, ascending): + def sort(self, field, ascending, subsort=False): field = field.lower().strip() if field in ('author', 'tag', 'comment'): field += 's' if field == 'date': field = 'timestamp' elif field == 'title': field = 'sort' elif field == 'authors': field = 'author_sort' + if self.first_sort: + subsort = True + self.first_sort = False fcmp = self.seriescmp if field == 'series' else \ - functools.partial(self.cmp, FIELD_MAP[field], + functools.partial(self.cmp, FIELD_MAP[field], subsort=subsort, str=field not in ('size', 'rating', 'timestamp')) self._map.sort(cmp=fcmp, reverse=not ascending)