1) Add a tweak to turn on/off multi-character first-letter partioning in the tag browser

2) Change preferences.tweaks to add a "tweak number" to the tweak name string. This helps tell people which tweak to look at. To keep these valid, we should always add tweaks to the end.
This commit is contained in:
Charles Haley 2012-07-06 09:43:58 +02:00
parent 25712ea2cd
commit 3c664b7591
3 changed files with 19 additions and 4 deletions

View file

@ -515,3 +515,13 @@
# default_tweak_format = 'remember'
default_tweak_format = None
#: Enable multi-character first-letters in the tag browser
# Some languages have letters that can be represented by multiple characters.
# For example, Czech has a 'character' "ch" that sorts between "h" and "i".
# If this tweak is True, then the tag browser will take these characters into
# consideration when partitioning by first letter.
# Examples:
# enable_multicharacters_in_tag_browser = True
# enable_multicharacters_in_tag_browser = True
enable_multicharacters_in_tag_browser = True

View file

@ -39,7 +39,7 @@ def paint(self, p, opt, idx):
class Tweak(object): # {{{
def __init__(self, name, doc, var_names, defaults, custom):
def __init__(self, name, doc, var_names, defaults, custom, tweak_num):
translate = _
self.name = translate(name)
self.doc = doc.strip()
@ -53,6 +53,7 @@ def __init__(self, name, doc, var_names, defaults, custom):
for x in var_names:
if x in custom:
self.custom_values[x] = custom[x]
self.tweak_num = tweak_num
def __str__(self):
ans = ['#: ' + self.name]
@ -92,6 +93,10 @@ def restore_to_default(self):
def update(self, varmap):
self.custom_values.update(varmap)
@property
def name_with_position_number(self):
return "%d: %s"%(self.tweak_num, self.name)
# }}}
class Tweaks(QAbstractListModel, SearchQueryParser): # {{{
@ -113,7 +118,7 @@ def data(self, index, role):
except:
return NONE
if role == Qt.DisplayRole:
return textwrap.fill(tweak.name, 40)
return textwrap.fill(tweak.name_with_position_number, 40)
if role == Qt.FontRole and tweak.is_customized:
ans = QFont()
ans.setBold(True)
@ -182,7 +187,7 @@ def read_tweak(self, lines, pos, defaults, custom):
pos += 1
if not var_names:
raise ValueError('Failed to find any variables for %r'%name)
self.tweaks.append(Tweak(name, doc, var_names, defaults, custom))
self.tweaks.append(Tweak(name, doc, var_names, defaults, custom, len(self.tweaks)+1))
#print '\n\n', self.tweaks[-1]
return pos

View file

@ -260,7 +260,7 @@ def set_database(self, db):
db.prefs.set('tag_browser_hidden_categories', list(self.hidden_categories))
conts = contractions()
if len(conts) == 0:
if len(conts) == 0 or not tweaks['enable_multicharacters_in_tag_browser']:
self.do_contraction = False
else:
self.do_contraction = True