'Add a subcategory to the category \'on_category\'. If new_category_name is
None, then a default name is shown and the user is offered the
opportunity to edit the name.'

def do_add_subcategory(self, on_category_key, new_category_name=None):

    db = self.library_view.model().db
    user_cats = db.prefs.get(u'user_categories', {})
    i = 0
    if (new_category_name is not None):
        new_name = new_category_name.replace(u'.', u'')
    else:
        new_name = _(u'New    Category').replace(u'.', u'')
    n = new_name
    while True:
        new_cat = ((on_category_key[1:] + u'.') + n)
        if (new_cat not in user_cats):
            break
        i += 1
        n = (new_name + unicode(i))
    user_cats[new_cat] = []
    db.new_api.set_pref(u'user_categories', user_cats)
    self.tags_view.recount()
    m = self.tags_view.model()
    idx = m.index_for_path(m.find_category_node((u'@' + new_cat)))
    self.tags_view.show_item_at_index(idx)
    if (new_category_name is None):
        self.tags_view.edit(idx)
