<commit_before># -*- coding: utf-8 -*-
"""
Created on Sun Feb 26 22:36:35 2017

@author: Aeolitus
"""

from PyQt5 import QtWidgets, QtCore
import CharakterBeschreibungWrapper
import CharakterAttributeWrapper
import CharakterEquipmentWrapper
import CharakterFertigkeitenWrapper
import CharakterUebernatuerlichWrapper
import CharakterFreieFertWrapper
import CharakterVorteileWrapper
import CharakterItemsWrapper
import CharakterEPWrapper
import Charakter
import Datenbank
from Wolke import Wolke
import os.path
import pdfMeister as pdfM
from pdfMeister import CharakterbogenInfo
import logging
from EventBus import EventBus

class Editor(object):
    '''
    Main class for the character editing window. Mostly puts together the
    different parts of the GUI and handles the communication inbetween.
    '''
    def __init__(self, savePathUpdatedCallback, CharacterName=""):
        super().__init__()
        Wolke.DB = Datenbank.Datenbank()
        self.pdfMeister = pdfM.pdfMeister()
        self.savepath = CharacterName
        self.changed = False
        self.savePathUpdatedCallback = savePathUpdatedCallback
        if Wolke.DB.loaded:
            self.noDatabase = False
            self.finishInit()
        else:
            self.noDatabase = True
        
    def finishInit(self):
        Wolke.Char = Charakter.Char() 
        if self.savepath != "":
            Wolke.Char.xmlLesen(self.savepath)
        Wolke.Char.aktualisieren() # A bit later because it needs access to itself
        
        EventBus.doAction("charakter_geladen")
        self.ignoreModified = False
        
    def setupMainForm(self, plugins):      
        self.updateEP()
        
        self.BeschrWrapper = CharakterBeschreibungWrapper.BeschrWrapper()
        self.AttrWrapper = CharakterAttributeWrapper.AttrWrapper()
        self.FertWrapper = CharakterFertigkeitenWrapper.FertigkeitenWrapper()
        self.FreiWrapper = CharakterFreieFertWrapper.CharakterFreieFertWrapper()
        self.UebernatuerlichWrapper = CharakterUebernatuerlichWrapper.UebernatuerlichWrapper()
        self.EquipWrapper = CharakterEquipmentWrapper.EquipWrapper()
        self.VortWrapper = CharakterVorteileWrapper.CharakterVorteileWrapper()
        self.ItmWrapper = CharakterItemsWrapper.CharakterItemsWrapper()
        self.EPWrapper = CharakterEPWrapper.EPWrapper()
        
        tabs = []
        tabs.append((10, self.BeschrWrapper.formBeschr, "Beschreibung"))
        tabs.append((30, self.AttrWrapper.formAttr, "Attribute"))
        tabs.append((40, self.VortWrapper.formVor, "Vorteile"))
        tabs.append((50, self.FertWrapper.formFert, "Fertigkeiten"))
        tabs.append((60, self.FreiWrapper.formFert, "Freie Fertigkeiten"))
        tabs.append((70, self.UebernatuerlichWrapper.formFert, "Übernatürliches"))
        tabs.append((80, self.EquipWrapper.formEq, "Ausrüstung"))   
        tabs.append((90, self.ItmWrapper.formIt, "Inventar"))
        tabs.append((100, self.EPWrapper.formEP, "EP-Verteilung"))

        for plugin in plugins:
            if hasattr(plugin, "getCharakterTabs"):
                for tab in plugin.getCharakterTabs():
                   tabs.append((tab[0], tab[1], tab[2]))
        
        tabs = sorted(tabs, key=lambda tab: tab[0])
        tabPadding = "    "
        if len(tabs) > 9:
            tabPadding = ""
        for tab in tabs:
            self.ui.tabs.addTab(tab[1], tabPadding + tab[2] + tabPadding)

        self.BeschrWrapper.modified.connect(self.onModified)
        self.AttrWrapper.modified.connect(self.onModified)
        self.FertWrapper.modified.connect(self.onModified)
        self.FreiWrapper.modified.connect(self.onModified)
        self.UebernatuerlichWrapper.modified.connect(self.onModified)
        self.EquipWrapper.modified.connect(self.onModified)
        self.VortWrapper.modified.connect(self.onModified)
        self.ItmWrapper.modified.connect(self.onModified)
        self.EPWrapper.modified.connect(self.onModified)<commit_msg>Plugin support: now checking for modified event in plugin character editor tabs.<commit_after># -*- coding: utf-8 -*-
"""
Created on Sun Feb 26 22:36:35 2017

@author: Aeolitus
"""

from PyQt5 import QtWidgets, QtCore
import CharakterBeschreibungWrapper
import CharakterAttributeWrapper
import CharakterEquipmentWrapper
import CharakterFertigkeitenWrapper
import CharakterUebernatuerlichWrapper
import CharakterFreieFertWrapper
import CharakterVorteileWrapper
import CharakterItemsWrapper
import CharakterEPWrapper
import Charakter
import Datenbank
from Wolke import Wolke
import os.path
import pdfMeister as pdfM
from pdfMeister import CharakterbogenInfo
import logging
from EventBus import EventBus

class Tab():
    def __init__(self, order, wrapper, form, name):
        self.order = order
        self.wrapper = wrapper
        self.form = form
        self.name = name

class Editor(object):
    '''
    Main class for the character editing window. Mostly puts together the
    different parts of the GUI and handles the communication inbetween.
    '''
    def __init__(self, savePathUpdatedCallback, CharacterName=""):
        super().__init__()
        Wolke.DB = Datenbank.Datenbank()
        self.pdfMeister = pdfM.pdfMeister()
        self.savepath = CharacterName
        self.changed = False
        self.savePathUpdatedCallback = savePathUpdatedCallback
        if Wolke.DB.loaded:
            self.noDatabase = False
            self.finishInit()
        else:
            self.noDatabase = True
        
    def finishInit(self):
        Wolke.Char = Charakter.Char() 
        if self.savepath != "":
            Wolke.Char.xmlLesen(self.savepath)
        Wolke.Char.aktualisieren() # A bit later because it needs access to itself
        
        EventBus.doAction("charakter_geladen")
        self.ignoreModified = False
        
    def setupMainForm(self, plugins):      
        self.updateEP()
        
        self.BeschrWrapper = CharakterBeschreibungWrapper.BeschrWrapper()
        self.AttrWrapper = CharakterAttributeWrapper.AttrWrapper()
        self.FertWrapper = CharakterFertigkeitenWrapper.FertigkeitenWrapper()
        self.FreiWrapper = CharakterFreieFertWrapper.CharakterFreieFertWrapper()
        self.UebernatuerlichWrapper = CharakterUebernatuerlichWrapper.UebernatuerlichWrapper()
        self.EquipWrapper = CharakterEquipmentWrapper.EquipWrapper()
        self.VortWrapper = CharakterVorteileWrapper.CharakterVorteileWrapper()
        self.ItmWrapper = CharakterItemsWrapper.CharakterItemsWrapper()
        self.EPWrapper = CharakterEPWrapper.EPWrapper()
        
        tabs = []
        tabs.append(Tab(10, self.BeschrWrapper, self.BeschrWrapper.formBeschr, "Beschreibung"))
        tabs.append(Tab(30, self.AttrWrapper, self.AttrWrapper.formAttr, "Attribute"))
        tabs.append(Tab(40, self.VortWrapper, self.VortWrapper.formVor, "Vorteile"))
        tabs.append(Tab(50, self.FertWrapper, self.FertWrapper.formFert, "Fertigkeiten"))
        tabs.append(Tab(60, self.FreiWrapper, self.FreiWrapper.formFert, "Freie Fertigkeiten"))
        tabs.append(Tab(70, self.UebernatuerlichWrapper, self.UebernatuerlichWrapper.formFert, "Übernatürliches"))
        tabs.append(Tab(80, self.EquipWrapper, self.EquipWrapper.formEq, "Ausrüstung"))   
        tabs.append(Tab(90, self.ItmWrapper, self.ItmWrapper.formIt, "Inventar"))
        tabs.append(Tab(100, self.EPWrapper, self.EPWrapper.formEP, "EP-Verteilung"))

        for plugin in plugins:
            if hasattr(plugin, "getCharakterTabs"):
                for tab in plugin.getCharakterTabs():
                   tabs.append(tab)
        
        tabs = sorted(tabs, key=lambda tab: tab.order)
        tabPadding = "    "
        if len(tabs) > 9:
            tabPadding = ""
        for tab in tabs:
            self.ui.tabs.addTab(tab.form, tabPadding + tab.name + tabPadding)
            if hasattr(tab.wrapper, "modified"):
                tab.wrapper.modified.connect(self.onModified)
{'fraction_non_alphanumeric': 0.09078369905956113, 'fraction_numerical': 0.009278996865203762, 'mean_word_length': 3.0944558521560577, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1257723', 'n_tokens_mistral': 2395, 'n_tokens_neox': 2375, 'n_words': 462}