# Path: subdownloader/languages/language.py
# class UnknownLanguage(Language):
#     def __init__(self, code):
#         Language.__init__(self, 0)
#         self._code = code
# 
#     # FIXME: better name for & check generic logic
# 
#     @classmethod
#     def create_generic(cls):
#         """
#         Return a UnknownLanguage instance..
#         :return: UnknownLanguage instance.
#         """
#         return cls('unknown')  # NO internationalization!
# 
#     def name(self):
#         """
#         Return readable name of Language. Contains info about the unknown Language.
#         :return: Readable name as string
#         """
#         return _(self._code)
# 
#     def generic_name(self):
#         """
#         Return readable name of Language. Contains no info about the unknown Language.
#         :return: Readable name as string
#         """
#         return Language.name(self)
# 
#     def is_generic(self):
#         return self._code == 'unknown'  # NO internationalization!
# 
#     def __eq__(self, other):
#         """
#         Tests if other has the same type of this and the same unknown language code.
#         :return: True if other is of the same type and has the same unknown language code
#         """
#         if not Language.__eq__(self, other):
#             return False
#         return self._code == other._code
# 
#     def __hash__(self):
#         """
#         Return hash of this object.
#         :return: hash integer
#         """
#         return hash((self._id, self._code))
# 
#     def __repr__(self):
#         """
#         Return representation of this instance
#         :return: string representation of self
#         """
#         return '<UnknownLanguage:code={code}>'.format(code=self._code)


import logging
from subdownloader.languages.language import UnknownLanguage
from PyQt5.QtCore import QAbstractListModel, QModelIndex, QSize, Qt
from PyQt5.QtGui import QFont, QIcon
class LanguageModel(QAbstractListModel):
    def __init__(self, unknown_text, unknown_visible, languages):
        QAbstractListModel.__init__(self)
        self._unknown_visible = unknown_visible
        self._unknown_text = unknown_text

        self._languages = languages

    def set_unknown_visible(self, unknown_visible):
        if self._unknown_visible == unknown_visible:
            return

        if unknown_visible:
            self.beginInsertRows(QModelIndex(), 0, 0)
            self._unknown_visible = unknown_visible
            self.endInsertRows()
        else:
            self.beginRemoveRows(QModelIndex(), 0, 0)
            self._unknown_visible = unknown_visible
            self.endRemoveRows()

    def set_unknown_text(self, unknown_text):
        self._unknown_text = unknown_text
        if self._unknown_visible:
            index = self.index(0)
            self.dataChanged.emit(index, index)

    def language_at_index(self, index):
        if self._unknown_visible:
            if index == 0:

# Path: subdownloader/languages/language.py
# class UnknownLanguage(Language):
#     def __init__(self, code):
#         Language.__init__(self, 0)
#         self._code = code
# 
#     # FIXME: better name for & check generic logic
# 
#     @classmethod
#     def create_generic(cls):
#         """
#         Return a UnknownLanguage instance..
#         :return: UnknownLanguage instance.
#         """
#         return cls('unknown')  # NO internationalization!
# 
#     def name(self):
#         """
#         Return readable name of Language. Contains info about the unknown Language.
#         :return: Readable name as string
#         """
#         return _(self._code)
# 
#     def generic_name(self):
#         """
#         Return readable name of Language. Contains no info about the unknown Language.
#         :return: Readable name as string
#         """
#         return Language.name(self)
# 
#     def is_generic(self):
#         return self._code == 'unknown'  # NO internationalization!
# 
#     def __eq__(self, other):
#         """
#         Tests if other has the same type of this and the same unknown language code.
#         :return: True if other is of the same type and has the same unknown language code
#         """
#         if not Language.__eq__(self, other):
#             return False
#         return self._code == other._code
# 
#     def __hash__(self):
#         """
#         Return hash of this object.
#         :return: hash integer
#         """
#         return hash((self._id, self._code))
# 
#     def __repr__(self):
#         """
#         Return representation of this instance
#         :return: string representation of self
#         """
#         return '<UnknownLanguage:code={code}>'.format(code=self._code)


# Path: subdownloader/client/gui/models/language.py
import logging
from subdownloader.languages.language import UnknownLanguage
from PyQt5.QtCore import QAbstractListModel, QModelIndex, QSize, Qt
from PyQt5.QtGui import QFont, QIcon

class LanguageModel(QAbstractListModel):
    def __init__(self, unknown_text, unknown_visible, languages):
        QAbstractListModel.__init__(self)
        self._unknown_visible = unknown_visible
        self._unknown_text = unknown_text

        self._languages = languages

    def set_unknown_visible(self, unknown_visible):
        if self._unknown_visible == unknown_visible:
            return

        if unknown_visible:
            self.beginInsertRows(QModelIndex(), 0, 0)
            self._unknown_visible = unknown_visible
            self.endInsertRows()
        else:
            self.beginRemoveRows(QModelIndex(), 0, 0)
            self._unknown_visible = unknown_visible
            self.endRemoveRows()

    def set_unknown_text(self, unknown_text):
        self._unknown_text = unknown_text
        if self._unknown_visible:
            index = self.index(0)
            self.dataChanged.emit(index, index)

    def language_at_index(self, index):
        if self._unknown_visible:
            if index == 0:

                return UnknownLanguage.create_generic()