Fixes in treeview broke listview, now fixed
simplified unicode/str casting columnorder working svn: r19990
This commit is contained in:
parent
4c5470492f
commit
9e400a2ca3
@ -62,7 +62,7 @@ from gen.db import (DbBsddbRead, DbWriteBase, BSDDBTxn,
|
|||||||
find_surname_name, DbUndoBSDDB as DbUndo)
|
find_surname_name, DbUndoBSDDB as DbUndo)
|
||||||
from gen.db.dbconst import *
|
from gen.db.dbconst import *
|
||||||
from gen.utils.callback import Callback
|
from gen.utils.callback import Callback
|
||||||
from gen.utils.cast import (conv_unicode_tosrtkey_ongtk, conv_dbstr_to_unicode)
|
from gen.utils.cast import (conv_unicode_tosrtkey, conv_dbstr_to_unicode)
|
||||||
from gen.updatecallback import UpdateCallback
|
from gen.updatecallback import UpdateCallback
|
||||||
from gen.errors import DbError
|
from gen.errors import DbError
|
||||||
from gen.constfunc import win
|
from gen.constfunc import win
|
||||||
@ -1428,7 +1428,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
|||||||
self.emit('person-groupname-rebuild', (name, grouppar))
|
self.emit('person-groupname-rebuild', (name, grouppar))
|
||||||
|
|
||||||
def sort_surname_list(self):
|
def sort_surname_list(self):
|
||||||
self.surname_list.sort(key=conv_unicode_tosrtkey_ongtk)
|
self.surname_list.sort(key=conv_unicode_tosrtkey)
|
||||||
|
|
||||||
@catch_db_error
|
@catch_db_error
|
||||||
def build_surname_list(self):
|
def build_surname_list(self):
|
||||||
@ -1440,7 +1440,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
|||||||
#TODO GTK3: Why double conversion? Convert to a list of str objects!
|
#TODO GTK3: Why double conversion? Convert to a list of str objects!
|
||||||
self.surname_list = sorted(
|
self.surname_list = sorted(
|
||||||
map(conv_dbstr_to_unicode, set(self.surnames.keys())),
|
map(conv_dbstr_to_unicode, set(self.surnames.keys())),
|
||||||
key=conv_unicode_tosrtkey_ongtk)
|
key=conv_unicode_tosrtkey)
|
||||||
|
|
||||||
def add_to_surname_list(self, person, batch_transaction):
|
def add_to_surname_list(self, person, batch_transaction):
|
||||||
"""
|
"""
|
||||||
|
@ -43,15 +43,22 @@ from gen.datehandler import codeset
|
|||||||
"""
|
"""
|
||||||
strxfrm needs it's unicode argument correctly cast before used.
|
strxfrm needs it's unicode argument correctly cast before used.
|
||||||
"""
|
"""
|
||||||
conv_unicode_tosrtkey = lambda x: locale.strxfrm(x.encode('utf-8', 'replace'))
|
|
||||||
|
|
||||||
conv_unicode_tosrtkey_ongtk = lambda x: locale.strxfrm(x.encode(
|
conv_unicode_tosrtkey = lambda x: locale.strxfrm(x.encode(codeset, 'replace'))
|
||||||
|
|
||||||
|
if codeset == 'UTF-8':
|
||||||
|
conv_str_tosrtkey = lambda x: locale.strxfrm(x)
|
||||||
|
else:
|
||||||
|
conv_str_tosrtkey = lambda x: locale.strxfrm(unicode(x,'UTF-8').encode(
|
||||||
codeset, 'replace'))
|
codeset, 'replace'))
|
||||||
|
|
||||||
conv_str_tosrtkey_ongtk = lambda x: locale.strxfrm(unicode(x,'utf-8').encode(
|
def conv_tosrtkey(value):
|
||||||
codeset, 'replace'))
|
if isinstance(value, unicode):
|
||||||
|
return conv_unicode_tosrtkey(value)
|
||||||
|
return conv_str_tosrtkey(value)
|
||||||
|
|
||||||
conv_dbstr_to_unicode = lambda x: unicode(x, 'utf-8')
|
#strings in database are utf-8
|
||||||
|
conv_dbstr_to_unicode = lambda x: unicode(x, 'UTF-8')
|
||||||
|
|
||||||
def cast_to_bool(val):
|
def cast_to_bool(val):
|
||||||
if val == str(True):
|
if val == str(True):
|
||||||
|
@ -82,7 +82,7 @@ class ColumnOrder(Gtk.VBox):
|
|||||||
self.config = config
|
self.config = config
|
||||||
self.on_apply = on_apply
|
self.on_apply = on_apply
|
||||||
|
|
||||||
self.pack_start(Gtk.Label(' ', True, True, 0), expand=False, fill=False)
|
self.pack_start(Gtk.Label(label=' '), False, False, 0)
|
||||||
|
|
||||||
self.startrow = 0
|
self.startrow = 0
|
||||||
if self.treeview:
|
if self.treeview:
|
||||||
@ -90,15 +90,15 @@ class ColumnOrder(Gtk.VBox):
|
|||||||
_('Tree View: first column "%s" cannot be changed') %
|
_('Tree View: first column "%s" cannot be changed') %
|
||||||
column_names[0])
|
column_names[0])
|
||||||
self.startrow = 1
|
self.startrow = 1
|
||||||
self.pack_start(label, expand=False, fill=False)
|
self.pack_start(label, False, False, 0)
|
||||||
self.pack_start(Gtk.Label(' ', True, True, 0), expand=False, fill=False)
|
self.pack_start(Gtk.Label(label=' '), False, False, 0)
|
||||||
|
|
||||||
self.pack_start(Gtk.Label(_('Drag and drop the columns to change'
|
self.pack_start(Gtk.Label(label=_('Drag and drop the columns to change'
|
||||||
' the order', True, True, 0)), expand=False, fill=False)
|
' the order')), False, False, 0)
|
||||||
self.pack_start(Gtk.Label(' ', True, True, 0), expand=False, fill=False)
|
self.pack_start(Gtk.Label(label=' '), False, False,0)
|
||||||
hbox = Gtk.HBox()
|
hbox = Gtk.HBox()
|
||||||
hbox.set_spacing(10)
|
hbox.set_spacing(10)
|
||||||
hbox.pack_start(Gtk.Label(' ', True, True, 0))
|
hbox.pack_start(Gtk.Label(label=' '), True, True, 0)
|
||||||
scroll = Gtk.ScrolledWindow()
|
scroll = Gtk.ScrolledWindow()
|
||||||
scroll.set_size_request(300,300)
|
scroll.set_size_request(300,300)
|
||||||
hbox.pack_start(scroll, True, True, 0)
|
hbox.pack_start(scroll, True, True, 0)
|
||||||
|
@ -176,14 +176,14 @@ class SurnameTab(EmbeddedList):
|
|||||||
for idx in range(len(self.model)):
|
for idx in range(len(self.model)):
|
||||||
node = self.model.get_iter(idx)
|
node = self.model.get_iter(idx)
|
||||||
surn = self.model.get_value(node, 5)
|
surn = self.model.get_value(node, 5)
|
||||||
surn.set_prefix(unicode(self.model.get_value(node, 0)))
|
surn.set_prefix(unicode(self.model.get_value(node, 0), 'UTF-8'))
|
||||||
surn.set_surname(unicode(self.model.get_value(node, 1)))
|
surn.set_surname(unicode(self.model.get_value(node, 1), 'UTF-8'))
|
||||||
surn.set_connector(unicode(self.model.get_value(node, 2)))
|
surn.set_connector(unicode(self.model.get_value(node, 2), 'UTF-8'))
|
||||||
surn.get_origintype().set(unicode(self.model.get_value(node, 3)))
|
surn.get_origintype().set(unicode(self.model.get_value(node, 3), 'UTF-8'))
|
||||||
surn.set_primary(self.model.get_value(node, 4))
|
surn.set_primary(self.model.get_value(node, 4))
|
||||||
new_list += [surn]
|
new_list += [surn]
|
||||||
return new_list
|
return new_list
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""
|
"""
|
||||||
Store the present data in the model to the name object
|
Store the present data in the model to the name object
|
||||||
@ -203,7 +203,7 @@ class SurnameTab(EmbeddedList):
|
|||||||
prim = False
|
prim = False
|
||||||
if len(self.obj.get_surname_list()) == 0:
|
if len(self.obj.get_surname_list()) == 0:
|
||||||
prim = True
|
prim = True
|
||||||
node = self.model.append(row=['', '', '', NameOriginType(), prim,
|
node = self.model.append(row=['', '', '', str(NameOriginType()), prim,
|
||||||
Surname()])
|
Surname()])
|
||||||
self.selection.select_iter(node)
|
self.selection.select_iter(node)
|
||||||
path = self.model.get_path(node)
|
path = self.model.get_path(node)
|
||||||
|
@ -378,7 +378,7 @@ class ListView(NavigationView):
|
|||||||
|
|
||||||
if self.type_list() == LISTFLAT:
|
if self.type_list() == LISTFLAT:
|
||||||
# Flat
|
# Flat
|
||||||
iter = self.model.nodemap.new_iter(handle)
|
iter = self.model.node_map.new_iter(handle)
|
||||||
try:
|
try:
|
||||||
path = self.model.do_get_path(iter)
|
path = self.model.do_get_path(iter)
|
||||||
except:
|
except:
|
||||||
@ -543,7 +543,7 @@ class ListView(NavigationView):
|
|||||||
construct a list sel_list with all selected handles
|
construct a list sel_list with all selected handles
|
||||||
'''
|
'''
|
||||||
if store.do_get_flags() & Gtk.TreeModelFlags.LIST_ONLY:
|
if store.do_get_flags() & Gtk.TreeModelFlags.LIST_ONLY:
|
||||||
handle = store.node_map.get_handle(path)
|
handle = store.node_map.get_handle(path.get_indices()[0])
|
||||||
else:
|
else:
|
||||||
handle = store.get_handle(store.get_node_from_iter(iter))
|
handle = store.get_handle(store.get_node_from_iter(iter))
|
||||||
|
|
||||||
@ -1100,9 +1100,9 @@ class ListView(NavigationView):
|
|||||||
self.uistate.status_text(_("Updating display..."))
|
self.uistate.status_text(_("Updating display..."))
|
||||||
self.uistate.set_busy_cursor(True)
|
self.uistate.set_busy_cursor(True)
|
||||||
|
|
||||||
selected = self.selection.get_selected_rows()
|
store, selected = self.selection.get_selected_rows()
|
||||||
for path in selected[1]:
|
for path in selected:
|
||||||
self.list.expand_row(path, True)
|
self.list.expand_row(path, False)
|
||||||
|
|
||||||
self.uistate.set_busy_cursor(False)
|
self.uistate.set_busy_cursor(False)
|
||||||
self.uistate.modify_statusbar(self.dbstate)
|
self.uistate.modify_statusbar(self.dbstate)
|
||||||
@ -1113,8 +1113,8 @@ class ListView(NavigationView):
|
|||||||
:param obj: not used, present only to allow the use of the method in
|
:param obj: not used, present only to allow the use of the method in
|
||||||
event callback
|
event callback
|
||||||
"""
|
"""
|
||||||
selected = self.selection.get_selected_rows()
|
store, selected = self.selection.get_selected_rows()
|
||||||
for path in selected[1]:
|
for path in selected:
|
||||||
self.list.collapse_row(path)
|
self.list.collapse_row(path)
|
||||||
|
|
||||||
def can_configure(self):
|
def can_configure(self):
|
||||||
|
@ -74,7 +74,7 @@ from gi.repository import Gtk
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.filters import SearchFilter, ExactSearchFilter
|
from gen.filters import SearchFilter, ExactSearchFilter
|
||||||
from gen.utils.cast import conv_unicode_tosrtkey_ongtk
|
from gen.utils.cast import conv_unicode_tosrtkey, conv_tosrtkey
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -107,7 +107,7 @@ class FlatNodeMap(object):
|
|||||||
the path, and a dictionary mapping hndl to index.
|
the path, and a dictionary mapping hndl to index.
|
||||||
To obtain index given a path, method real_index() is available
|
To obtain index given a path, method real_index() is available
|
||||||
|
|
||||||
..Note: If a string sortkey is used, apply conv_unicode_tosrtkey_ongtk
|
..Note: If a string sortkey is used, apply conv_unicode_tosrtkey
|
||||||
on it , so as to have localized sort
|
on it , so as to have localized sort
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -563,13 +563,13 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
Return the (sort_key, handle) list of all data that can maximally
|
Return the (sort_key, handle) list of all data that can maximally
|
||||||
be shown.
|
be shown.
|
||||||
This list is sorted ascending, via localized string sort.
|
This list is sorted ascending, via localized string sort.
|
||||||
conv_unicode_tosrtkey_ongtk which uses strxfrm
|
conv_unicode_tosrtkey which uses strxfrm
|
||||||
"""
|
"""
|
||||||
# use cursor as a context manager
|
# use cursor as a context manager
|
||||||
with self.gen_cursor() as cursor:
|
with self.gen_cursor() as cursor:
|
||||||
#loop over database and store the sort field, and the handle, and
|
#loop over database and store the sort field, and the handle, and
|
||||||
#allow for a third iter
|
#allow for a third iter
|
||||||
return sorted((map(conv_unicode_tosrtkey_ongtk,
|
return sorted((map(conv_tosrtkey,
|
||||||
self.sort_func(data)), key) for key, data in cursor)
|
self.sort_func(data)), key) for key, data in cursor)
|
||||||
|
|
||||||
def _rebuild_search(self, ignore=None):
|
def _rebuild_search(self, ignore=None):
|
||||||
@ -639,7 +639,7 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
if self.node_map.get_path_from_handle(handle) is not None:
|
if self.node_map.get_path_from_handle(handle) is not None:
|
||||||
return # row is already displayed
|
return # row is already displayed
|
||||||
data = self.map(handle)
|
data = self.map(handle)
|
||||||
insert_val = (map(conv_unicode_tosrtkey_ongtk, self.sort_func(data)),
|
insert_val = (map(conv_tosrtkey, self.sort_func(data)),
|
||||||
handle)
|
handle)
|
||||||
if not self.search or \
|
if not self.search or \
|
||||||
(self.search and self.search.match(handle, self.db)):
|
(self.search and self.search.match(handle, self.db)):
|
||||||
@ -673,7 +673,7 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel):
|
|||||||
return # row is not currently displayed
|
return # row is not currently displayed
|
||||||
self.clear_cache(handle)
|
self.clear_cache(handle)
|
||||||
oldsortkey = self.node_map.get_sortkey(handle)
|
oldsortkey = self.node_map.get_sortkey(handle)
|
||||||
newsortkey = map(conv_unicode_tosrtkey_ongtk, self.sort_func(self.map(
|
newsortkey = map(conv_tosrtkey, self.sort_func(self.map(
|
||||||
handle)))
|
handle)))
|
||||||
if oldsortkey is None or oldsortkey != newsortkey:
|
if oldsortkey is None or oldsortkey != newsortkey:
|
||||||
#or the changed object is not present in the view due to filtering
|
#or the changed object is not present in the view due to filtering
|
||||||
|
@ -55,7 +55,7 @@ from gi.repository import Gtk
|
|||||||
# GRAMPS modules
|
# GRAMPS modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.utils.cast import conv_str_tosrtkey_ongtk, conv_unicode_tosrtkey_ongtk
|
from gen.utils.cast import conv_str_tosrtkey, conv_unicode_tosrtkey
|
||||||
import gui.widgets.progressdialog as progressdlg
|
import gui.widgets.progressdialog as progressdlg
|
||||||
from lru import LRU
|
from lru import LRU
|
||||||
from bisect import bisect_right
|
from bisect import bisect_right
|
||||||
@ -91,11 +91,11 @@ class Node(object):
|
|||||||
if isinstance(sortkey, unicode):
|
if isinstance(sortkey, unicode):
|
||||||
self.name = sortkey.encode('utf-8')
|
self.name = sortkey.encode('utf-8')
|
||||||
#sortkey must be localized sort, so
|
#sortkey must be localized sort, so
|
||||||
self.sortkey = conv_unicode_tosrtkey_ongtk(sortkey)
|
self.sortkey = conv_unicode_tosrtkey(sortkey)
|
||||||
else:
|
else:
|
||||||
self.name = sortkey
|
self.name = sortkey
|
||||||
#sortkey must be localized sort, so
|
#sortkey must be localized sort, so
|
||||||
self.sortkey = conv_str_tosrtkey_ongtk(sortkey)
|
self.sortkey = conv_str_tosrtkey(sortkey)
|
||||||
else:
|
else:
|
||||||
self.name = ''
|
self.name = ''
|
||||||
self.sortkey = None
|
self.sortkey = None
|
||||||
|
@ -76,7 +76,8 @@ class MenuToolButtonAction(Gtk.Action):
|
|||||||
@type tooltip: str
|
@type tooltip: str
|
||||||
|
|
||||||
"""
|
"""
|
||||||
GObject.GObject.__init__(self, name, label, tooltip, None)
|
GObject.GObject.__init__(self, name=name, label=label, tooltip=tooltip,
|
||||||
|
stock_id=None)
|
||||||
##TODO GTK3: following is deprecated, must be replaced by
|
##TODO GTK3: following is deprecated, must be replaced by
|
||||||
## Gtk.MenuToolButton.set_related_action(MenuToolButtonAction) in calling class?
|
## Gtk.MenuToolButton.set_related_action(MenuToolButtonAction) in calling class?
|
||||||
## self.set_tool_item_type(Gtk.MenuToolButton)
|
## self.set_tool_item_type(Gtk.MenuToolButton)
|
||||||
|
@ -55,7 +55,7 @@ from PySide import QtOpenGL
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gen.const import ROOT_DIR
|
from gen.const import ROOT_DIR
|
||||||
from gui.views.treemodels import conv_unicode_tosrtkey_ongtk
|
from gui.views.treemodels import conv_unicode_tosrtkey
|
||||||
from gen.ggettext import gettext as _
|
from gen.ggettext import gettext as _
|
||||||
from gen.display.name import displayer as name_displayer
|
from gen.display.name import displayer as name_displayer
|
||||||
from gen.lib import Name
|
from gen.lib import Name
|
||||||
@ -124,14 +124,14 @@ class QMLPersonListModel(QtCore.QAbstractListModel):
|
|||||||
Return the (sort_key, handle) list of all data that can maximally
|
Return the (sort_key, handle) list of all data that can maximally
|
||||||
be shown.
|
be shown.
|
||||||
This list is sorted ascending, via localized string sort.
|
This list is sorted ascending, via localized string sort.
|
||||||
conv_unicode_tosrtkey_ongtk which uses strxfrm, which is apparently
|
conv_unicode_tosrtkey which uses strxfrm, which is apparently
|
||||||
broken in Win ?? --> they should fix base lib, we need strxfrm, fix it
|
broken in Win ?? --> they should fix base lib, we need strxfrm, fix it
|
||||||
in the Utils module.
|
in the Utils module.
|
||||||
"""
|
"""
|
||||||
# use cursor as a context manager
|
# use cursor as a context manager
|
||||||
with self.gen_cursor() as cursor:
|
with self.gen_cursor() as cursor:
|
||||||
#loop over database and store the sort field, and the handle
|
#loop over database and store the sort field, and the handle
|
||||||
return sorted((map(conv_unicode_tosrtkey_ongtk,
|
return sorted((map(conv_unicode_tosrtkey,
|
||||||
self.sort_func(data)), key) for key, data in cursor)
|
self.sort_func(data)), key) for key, data in cursor)
|
||||||
|
|
||||||
def sort_name(self, data):
|
def sort_name(self, data):
|
||||||
|
@ -38,6 +38,7 @@ Base view for Place Views
|
|||||||
# GTK/Gnome modules
|
# GTK/Gnome modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
from gi.repository import Gdk
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -212,7 +213,7 @@ class PlaceBaseView(ListView):
|
|||||||
widget.set_stock_id(Gtk.STOCK_JUMP_TO)
|
widget.set_stock_id(Gtk.STOCK_JUMP_TO)
|
||||||
if self.drag_info():
|
if self.drag_info():
|
||||||
self.list.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
|
self.list.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK,
|
||||||
[('text/plain', 0, 0), self.drag_info().target()],
|
[('text/plain', 0, 0), self.drag_info().target_data()],
|
||||||
Gdk.DragAction.COPY)
|
Gdk.DragAction.COPY)
|
||||||
|
|
||||||
def __create_maps_menu_actions(self):
|
def __create_maps_menu_actions(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user