# Path: eclectusqt/forms/ComponentPageUI.py
# class Ui_Form(object):
#     def setupUi(self, Form):
#     def retranslateUi(self, Form):
# 
# Path: eclectusqt/util.py
# def getIcon(fileName):
# def getData(fileName):
# def getLocalData(fileName):
# def getDataPaths():
# def readConfigString(config, option, default=None):
# def _readConfig(config, option, default, conversionFunc):
# def readConfigInt(config, option, default=None):
#     def __init__(self, parent):
#     def javaScriptConsoleMessage(self, message, lineNumber, sourceID):
#     def javaScriptAlert(self, frame, msg):
# class HandyWebpage(QWebPage):
# 
# Path: libeclectus/componentview.py
# class ComponentView:
#     def __init__(self, charDbInst=None, **options):
#         self.charDB = charDbInst or chardb.CharacterDB(**options)
# 
#         self.radicalFormEquivalentCharacterMap \
#             = self.charDB.radicalFormEquivalentCharacterMap
# 
#     def getComponentSearchTable(self, components=[],
#         includeEquivalentRadicalForms=False, includeSimilarCharacters=False):
#         """
#         Gets a table of minimal components for searching characters by
#         component. Annotates given characters and characters that would
#         result in zero results if selected.
#         """
#         componentsByStrokeCount = self.charDB.minimalCharacterComponents
# 
#         # TODO replace
#         selected = components
#         #selected = set([self.charDB.preferRadicalFormForCharacter(char) \
#             #for char in components])
# 
#         if components:
#             currentResultRadicals = self.charDB.getComponentsWithResults(
#                 components,
#                 includeEquivalentRadicalForms=includeEquivalentRadicalForms,
#                 includeSimilarCharacters=includeSimilarCharacters)
#         else:
#             currentResultRadicals = None
# 
#         htmlList = []
#         htmlList.append('<table class="component">')
# 
#         strokeCountList = componentsByStrokeCount.keys()
#         strokeCountList.sort()
#         for strokeCount in strokeCountList:
#             htmlList.append('<tr><th>%d</th><td>' % strokeCount)
#             for form in sorted(componentsByStrokeCount[strokeCount]):
#                 if form in selected:
#                     formClass = 'selectedComponent'
#                 elif currentResultRadicals != None \
#                     and form not in currentResultRadicals:
#                     formClass = 'zeroResultComponent'
#                 else:
#                     formClass = ''
# 
#                 formBase64 = util.encodeBase64(form)
#                 htmlList.append(
#                     '<a class="character" href="#component(%s)">' % formBase64 \
#                     + '<span class="component %s" id="c%s">%s</span>' \
#                         % (formClass, formBase64, form) \
#                     + '</a>')
#             htmlList.append('</td></tr>')
#         htmlList.append('</table>')
# 
#         return "\n".join(htmlList)
# 
#     def getComponentSearchResult(self, components,
#         includeEquivalentRadicalForms=False, includeSimilarCharacters=False):
#         """Gets a list of characters containing the given components."""
#         chars = self.charDB.getCharactersForComponents(components,
#             includeEquivalentRadicalForms=includeEquivalentRadicalForms,
#             includeSimilarCharacters=includeSimilarCharacters)
# 
#         if chars:
#             charLinks = []
#             for char in chars:
#                 charLinks.append(
#                     '<a class="character" href="#lookup(%s)">%s</a>' \
#                         % (util.encodeBase64(char), char))
#             html = '<span class="character">%s</span>' % ' '.join(charLinks)
#         else:
#             html = '<p class="meta">%s</p>' % gettext('No entries')
# 
#         return html, len(chars)
# 
# Path: libeclectus/util.py
# def decodeBase64(string):
#     return base64.b64decode(string).decode('utf8')


import re
from PyQt4.QtCore import Qt, SIGNAL, QByteArray
from PyQt4.QtGui import QWidget, QIcon
from PyQt4.QtWebKit import QWebPage
from PyKDE4.kdeui import KIcon
from PyKDE4.kdecore import i18n
from eclectusqt.forms import ComponentPageUI
from eclectusqt import util
from libeclectus.componentview import ComponentView
from libeclectus.util import decodeBase64

        # connect to the widgets
        self.connect(self.includeVariantsButton, SIGNAL("clicked(bool)"),
            self.componentIncludeVariants)
        self.connect(self.includeSimilarButton, SIGNAL("clicked(bool)"),
            self.componentIncludeSimilar)

        self.connect(self.componentView, SIGNAL("linkClicked(const QUrl &)"),
            self.componentClicked)
        self.connect(self.componentView, SIGNAL("loadFinished(bool)"),
            self.componentViewLoaded)
        self.connect(self.componentResultView,
            SIGNAL("linkClicked(const QUrl &)"), self.componentResultClicked)
        self.connect(self.componentEdit,
            SIGNAL("textChanged(const QString &)"),
            self.componentEditChanged)

        self.componentView.page().setLinkDelegationPolicy(
            QWebPage.DelegateAllLinks)
        self.componentResultView.page().setLinkDelegationPolicy(
            QWebPage.DelegateAllLinks)

        self.initialised = False

    def showEvent(self, event):
        if not self.initialised:
            self.initialised = True
            self.includeSimilarButton.setIcon(
                QIcon(util.getIcon('similarforms.png')))
            self.includeVariantsButton.setIcon(

# Path: eclectusqt/forms/ComponentPageUI.py
# class Ui_Form(object):
#     def setupUi(self, Form):
#     def retranslateUi(self, Form):
# 
# Path: eclectusqt/util.py
# def getIcon(fileName):
# def getData(fileName):
# def getLocalData(fileName):
# def getDataPaths():
# def readConfigString(config, option, default=None):
# def _readConfig(config, option, default, conversionFunc):
# def readConfigInt(config, option, default=None):
#     def __init__(self, parent):
#     def javaScriptConsoleMessage(self, message, lineNumber, sourceID):
#     def javaScriptAlert(self, frame, msg):
# class HandyWebpage(QWebPage):
# 
# Path: libeclectus/componentview.py
# class ComponentView:
#     def __init__(self, charDbInst=None, **options):
#         self.charDB = charDbInst or chardb.CharacterDB(**options)
# 
#         self.radicalFormEquivalentCharacterMap \
#             = self.charDB.radicalFormEquivalentCharacterMap
# 
#     def getComponentSearchTable(self, components=[],
#         includeEquivalentRadicalForms=False, includeSimilarCharacters=False):
#         """
#         Gets a table of minimal components for searching characters by
#         component. Annotates given characters and characters that would
#         result in zero results if selected.
#         """
#         componentsByStrokeCount = self.charDB.minimalCharacterComponents
# 
#         # TODO replace
#         selected = components
#         #selected = set([self.charDB.preferRadicalFormForCharacter(char) \
#             #for char in components])
# 
#         if components:
#             currentResultRadicals = self.charDB.getComponentsWithResults(
#                 components,
#                 includeEquivalentRadicalForms=includeEquivalentRadicalForms,
#                 includeSimilarCharacters=includeSimilarCharacters)
#         else:
#             currentResultRadicals = None
# 
#         htmlList = []
#         htmlList.append('<table class="component">')
# 
#         strokeCountList = componentsByStrokeCount.keys()
#         strokeCountList.sort()
#         for strokeCount in strokeCountList:
#             htmlList.append('<tr><th>%d</th><td>' % strokeCount)
#             for form in sorted(componentsByStrokeCount[strokeCount]):
#                 if form in selected:
#                     formClass = 'selectedComponent'
#                 elif currentResultRadicals != None \
#                     and form not in currentResultRadicals:
#                     formClass = 'zeroResultComponent'
#                 else:
#                     formClass = ''
# 
#                 formBase64 = util.encodeBase64(form)
#                 htmlList.append(
#                     '<a class="character" href="#component(%s)">' % formBase64 \
#                     + '<span class="component %s" id="c%s">%s</span>' \
#                         % (formClass, formBase64, form) \
#                     + '</a>')
#             htmlList.append('</td></tr>')
#         htmlList.append('</table>')
# 
#         return "\n".join(htmlList)
# 
#     def getComponentSearchResult(self, components,
#         includeEquivalentRadicalForms=False, includeSimilarCharacters=False):
#         """Gets a list of characters containing the given components."""
#         chars = self.charDB.getCharactersForComponents(components,
#             includeEquivalentRadicalForms=includeEquivalentRadicalForms,
#             includeSimilarCharacters=includeSimilarCharacters)
# 
#         if chars:
#             charLinks = []
#             for char in chars:
#                 charLinks.append(
#                     '<a class="character" href="#lookup(%s)">%s</a>' \
#                         % (util.encodeBase64(char), char))
#             html = '<span class="character">%s</span>' % ' '.join(charLinks)
#         else:
#             html = '<p class="meta">%s</p>' % gettext('No entries')
# 
#         return html, len(chars)
# 
# Path: libeclectus/util.py
# def decodeBase64(string):
#     return base64.b64decode(string).decode('utf8')


# Path: eclectusqt/componentpage.py
import re
from PyQt4.QtCore import Qt, SIGNAL, QByteArray
from PyQt4.QtGui import QWidget, QIcon
from PyQt4.QtWebKit import QWebPage
from PyKDE4.kdeui import KIcon
from PyKDE4.kdecore import i18n
from eclectusqt.forms import ComponentPageUI
from eclectusqt import util
from libeclectus.componentview import ComponentView
from libeclectus.util import decodeBase64


        # connect to the widgets
        self.connect(self.includeVariantsButton, SIGNAL("clicked(bool)"),
            self.componentIncludeVariants)
        self.connect(self.includeSimilarButton, SIGNAL("clicked(bool)"),
            self.componentIncludeSimilar)

        self.connect(self.componentView, SIGNAL("linkClicked(const QUrl &)"),
            self.componentClicked)
        self.connect(self.componentView, SIGNAL("loadFinished(bool)"),
            self.componentViewLoaded)
        self.connect(self.componentResultView,
            SIGNAL("linkClicked(const QUrl &)"), self.componentResultClicked)
        self.connect(self.componentEdit,
            SIGNAL("textChanged(const QString &)"),
            self.componentEditChanged)

        self.componentView.page().setLinkDelegationPolicy(
            QWebPage.DelegateAllLinks)
        self.componentResultView.page().setLinkDelegationPolicy(
            QWebPage.DelegateAllLinks)

        self.initialised = False

    def showEvent(self, event):
        if not self.initialised:
            self.initialised = True
            self.includeSimilarButton.setIcon(
                QIcon(util.getIcon('similarforms.png')))
            self.includeVariantsButton.setIcon(

                QIcon(util.getIcon('radicalvariant.png')))