'Open the \'manage_X\' dialog where X == category. If tag is not None, the
dialog will position the editor on that item.'

def do_tags_list_edit(self, tag, category):

    db = self.current_db
    data = db.new_api.get_categories()
    if (category in data):
        result = [(t.id, t.original_name, t.count) for t in data[category] if (t.count > 0)]
    else:
        result = None
    if (result is None):
        return
    if (category == u'series'):
        key = (lambda x: sort_key(title_sort(x)))
    else:
        key = sort_key
    d = TagListEditor(self, cat_name=db.field_metadata[category][u'name'], tag_to_match=tag, data=result, sorter=key)
    d.exec_()
    if (d.result() == d.Accepted):
        to_rename = d.to_rename
        to_delete = d.to_delete
        orig_name = d.original_names
        if ((category in [u'tags', u'series', u'publisher']) or db.new_api.field_metadata.is_custom_field(category)):
            m = self.tags_view.model()
            for item in to_delete:
                m.delete_item_from_all_user_categories(orig_name[item], category)
            for old_id in to_rename:
                m.rename_item_in_all_user_categories(orig_name[old_id], category, unicode(to_rename[old_id]))
            db.new_api.remove_items(category, to_delete)
            db.new_api.rename_items(category, to_rename, change_index=False)
            self.do_tag_item_renamed()
            self.tags_view.recount()
