# Path: OpenNumismat/Collection/CollectionFields.py
# class FieldTypes():
# class Status(dict):
# class CollectionField():
# class CollectionFieldsBase(QObject):
# class CollectionFields(CollectionFieldsBase):
#     def toSql(type_):
#     def __init__(self):
#     def keys(self):
#     def items(self):
#     def values(self):
#     def __getitem__(self, key):
#     def __init__(self, id_, name, title, type_):
#     def __init__(self, parent=None):
#     def field(self, id_):
#     def __iter__(self):
#     def __next__(self):
#     def __init__(self, db, parent=None):
#     def getCustomTitle(self, name):
#     def save(self):
#     def create(db=QSqlDatabase()):
# 
# Path: OpenNumismat/Settings.py
# class Settings(BaseSettings):
#     default_template = os.path.join(OpenNumismat.PRJ_PATH, 'templates', 'full')
#     Default = {'locale': _getLocale(),
#                'backup': OpenNumismat.HOME_PATH + "/backup/",
#                'autobackup': True,
#                'autobackup_depth': 25,
#                'reference': OpenNumismat.HOME_PATH + "/reference.ref",
#                'error': True,
#                'speedup': 1,
#                'updates': False,
#                'template': default_template,
#                'check_coin_title': True,
#                'check_coin_duplicate': True,
#                'images_by_default': 2,
#                'colnect_enabled': True,
#                'colnect_locale': _getLocale(),
#                'colnect_autoclose': False,
#                'colnect_skip_currency': True,
#                'map_type': 0,
#                'built_in_viewer': True,
#                'font_size': 0}
# 
#     def __init__(self, autoSave=False):
#         super().__init__(autoSave)
# 
#         self.settings = QSettings()
# 
#     def keys(self):
#         return self.Default.keys()
# 
#     def _getValue(self, key):
#         if key in ('error', 'updates', 'autobackup',
#                    'check_coin_title', 'check_coin_duplicate',
#                    'colnect_enabled', 'colnect_autoclose',
#                    'colnect_skip_currency', 'built_in_viewer'):
#             value = self.settings.value('mainwindow/' + key, self.Default[key],
#                                         type=bool)
#         elif key in ('images_by_default', 'autobackup_depth',
#                      'speedup', 'map_type', 'font_size'):
#             value = self.settings.value('mainwindow/' + key, self.Default[key],
#                                         type=int)
#         else:
#             value = self.settings.value('mainwindow/' + key, self.Default[key])
# 
#             if key == 'template':
#                 if not os.path.isdir(value):
#                     value = self.default_template
# 
#         return value
# 
#     def _saveValue(self, key, val):
#         self.settings.setValue('mainwindow/' + key, val)
# 
# Path: OpenNumismat/Tools/Gui.py
# def statusIcon(status):
#     return QIcon(":/%s.png" % status)
# 
# Path: OpenNumismat/Tools/Converters.py
# def numberWithFraction(string, enabled=True):
#     if enabled:
#         try:
#             if float(string) == 0.25:
#                 return '¼', True
#             elif float(string) == 0.33:
#                 return '⅓', True
#             elif float(string) == 0.5:
#                 return '½', True
#             elif float(string) == 0.75:
#                 return '¾', True
#             elif float(string) == 1.25:
#                 return '1¼', True
#             elif float(string) == 1.5:
#                 return '1½', True
#             elif float(string) == 2.5:
#                 return '2½', True
#         except (ValueError, TypeError):
#             pass
# 
#     return string, False
# 
# def htmlToPlainText(text):
#     RICH_PREFIX = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" '\
#                   '"http://www.w3.org/TR/REC-html40/strict.dtd">'
#     if text.startswith(RICH_PREFIX):
#         document = QTextDocument()
#         document.setHtml(text)
#         text = document.toPlainText()
# 
#     return text


import locale
import re
from PyQt5.QtCore import QMargins, QUrl, QDate, Qt, pyqtSignal
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from OpenNumismat.Collection.CollectionFields import Statuses
from OpenNumismat.Settings import Settings
from OpenNumismat.Tools.Gui import statusIcon
from OpenNumismat.Tools.Converters import numberWithFraction, htmlToPlainText

                self.addItem(statusIcon(status), statusTitle, status)

    def data(self):
        return self.currentData()

    def clear(self):
        self.setCurrentIndex(-1)

    def setCurrentValue(self, value):
        old_index = self.currentIndex()
        index = self.findData(value)
        self.setCurrentIndex(index)
        if old_index == index:
            self.currentIndexChanged.emit(index)


class StatusBrowser(QLineEdit):
    currentIndexChanged = pyqtSignal(object)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setMinimumWidth(100)
        self.data = ''

    def setCurrentValue(self, value):
        self.setText(Statuses[value])
        self.home(False)

        for act in self.actions():
            self.removeAction(act)

# Path: OpenNumismat/Collection/CollectionFields.py
# class FieldTypes():
# class Status(dict):
# class CollectionField():
# class CollectionFieldsBase(QObject):
# class CollectionFields(CollectionFieldsBase):
#     def toSql(type_):
#     def __init__(self):
#     def keys(self):
#     def items(self):
#     def values(self):
#     def __getitem__(self, key):
#     def __init__(self, id_, name, title, type_):
#     def __init__(self, parent=None):
#     def field(self, id_):
#     def __iter__(self):
#     def __next__(self):
#     def __init__(self, db, parent=None):
#     def getCustomTitle(self, name):
#     def save(self):
#     def create(db=QSqlDatabase()):
# 
# Path: OpenNumismat/Settings.py
# class Settings(BaseSettings):
#     default_template = os.path.join(OpenNumismat.PRJ_PATH, 'templates', 'full')
#     Default = {'locale': _getLocale(),
#                'backup': OpenNumismat.HOME_PATH + "/backup/",
#                'autobackup': True,
#                'autobackup_depth': 25,
#                'reference': OpenNumismat.HOME_PATH + "/reference.ref",
#                'error': True,
#                'speedup': 1,
#                'updates': False,
#                'template': default_template,
#                'check_coin_title': True,
#                'check_coin_duplicate': True,
#                'images_by_default': 2,
#                'colnect_enabled': True,
#                'colnect_locale': _getLocale(),
#                'colnect_autoclose': False,
#                'colnect_skip_currency': True,
#                'map_type': 0,
#                'built_in_viewer': True,
#                'font_size': 0}
# 
#     def __init__(self, autoSave=False):
#         super().__init__(autoSave)
# 
#         self.settings = QSettings()
# 
#     def keys(self):
#         return self.Default.keys()
# 
#     def _getValue(self, key):
#         if key in ('error', 'updates', 'autobackup',
#                    'check_coin_title', 'check_coin_duplicate',
#                    'colnect_enabled', 'colnect_autoclose',
#                    'colnect_skip_currency', 'built_in_viewer'):
#             value = self.settings.value('mainwindow/' + key, self.Default[key],
#                                         type=bool)
#         elif key in ('images_by_default', 'autobackup_depth',
#                      'speedup', 'map_type', 'font_size'):
#             value = self.settings.value('mainwindow/' + key, self.Default[key],
#                                         type=int)
#         else:
#             value = self.settings.value('mainwindow/' + key, self.Default[key])
# 
#             if key == 'template':
#                 if not os.path.isdir(value):
#                     value = self.default_template
# 
#         return value
# 
#     def _saveValue(self, key, val):
#         self.settings.setValue('mainwindow/' + key, val)
# 
# Path: OpenNumismat/Tools/Gui.py
# def statusIcon(status):
#     return QIcon(":/%s.png" % status)
# 
# Path: OpenNumismat/Tools/Converters.py
# def numberWithFraction(string, enabled=True):
#     if enabled:
#         try:
#             if float(string) == 0.25:
#                 return '¼', True
#             elif float(string) == 0.33:
#                 return '⅓', True
#             elif float(string) == 0.5:
#                 return '½', True
#             elif float(string) == 0.75:
#                 return '¾', True
#             elif float(string) == 1.25:
#                 return '1¼', True
#             elif float(string) == 1.5:
#                 return '1½', True
#             elif float(string) == 2.5:
#                 return '2½', True
#         except (ValueError, TypeError):
#             pass
# 
#     return string, False
# 
# def htmlToPlainText(text):
#     RICH_PREFIX = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" '\
#                   '"http://www.w3.org/TR/REC-html40/strict.dtd">'
#     if text.startswith(RICH_PREFIX):
#         document = QTextDocument()
#         document.setHtml(text)
#         text = document.toPlainText()
# 
#     return text


# Path: OpenNumismat/EditCoinDialog/FormItems.py
import locale
import re
from PyQt5.QtCore import QMargins, QUrl, QDate, Qt, pyqtSignal
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from OpenNumismat.Collection.CollectionFields import Statuses
from OpenNumismat.Settings import Settings
from OpenNumismat.Tools.Gui import statusIcon
from OpenNumismat.Tools.Converters import numberWithFraction, htmlToPlainText

                self.addItem(statusIcon(status), statusTitle, status)

    def data(self):
        return self.currentData()

    def clear(self):
        self.setCurrentIndex(-1)

    def setCurrentValue(self, value):
        old_index = self.currentIndex()
        index = self.findData(value)
        self.setCurrentIndex(index)
        if old_index == index:
            self.currentIndexChanged.emit(index)


class StatusBrowser(QLineEdit):
    currentIndexChanged = pyqtSignal(object)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setMinimumWidth(100)
        self.data = ''

    def setCurrentValue(self, value):
        self.setText(Statuses[value])
        self.home(False)

        for act in self.actions():
            self.removeAction(act)

        icon = statusIcon(value)
