<commit_before># -*- coding: utf-8 -*-
"""
Created on Sat Mar 18 11:29:39 2017

@author: Aeolitus
"""
import sys
from PyQt5 import QtCore, QtWidgets, QtGui
import Fertigkeiten
import Datenbank
import DatenbankMain
import DatenbankEditFertigkeitWrapper
import DatenbankEditTalentWrapper
import DatenbankEditVorteilWrapper
import DatenbankSelectTypeWrapper
import DatenbankEditWaffeneigenschaftWrapper
import DatenbankEditWaffeWrapper
import DatenbankEditManoeverWrapper
import Objekte
import os
from Wolke import Wolke

class DatenbankEdit(object):
    def __init__(self):
        super().__init__()
        self.datenbank = Datenbank.Datenbank()
        self.savepath = self.datenbank.datei
        self.changed = False
        self.windowTitleDefault = ""
    
    def setupGUI(self):
        # GUI Mods
        self.model = QtGui.QStandardItemModel(self.ui.listDatenbank)
        self.ui.listDatenbank.setModel(self.model)
        self.ui.listDatenbank.doubleClicked["QModelIndex"].connect(self.editSelected)
        self.ui.listDatenbank.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
        self.ui.listDatenbank.selectionModel().selectionChanged.connect(self.listSelectionChanged)
        self.ui.showTalente.stateChanged.connect(self.updateGUI)
        self.ui.showVorteile.stateChanged.connect(self.updateGUI)
        self.ui.showFertigkeiten.stateChanged.connect(self.updateGUI)
        self.ui.showUebernatuerlicheFertigkeiten.stateChanged.connect(self.updateGUI)
        self.ui.showWaffeneigenschaften.stateChanged.connect(self.updateGUI)
        self.ui.showWaffen.stateChanged.connect(self.updateGUI)
        self.ui.showManoever.stateChanged.connect(self.updateGUI)
        self.ui.showUserAdded.stateChanged.connect(self.updateGUI)
        self.ui.showDeleted.stateChanged.connect(self.updateGUI)
        self.ui.nameFilterEdit.textChanged.connect(self.updateGUI)
        self.ui.buttonCloseDB.clicked.connect(self.closeDatenbank)
        self.ui.buttonLoadDB.clicked.connect(self.loadDatenbank)
        self.ui.buttonSaveDB.clicked.connect(self.saveDatenbank)
        self.ui.buttonQuicksave.clicked.connect(self.quicksaveDatenbank)
        self.ui.buttonEditieren.clicked.connect(self.editSelected)
        self.ui.buttonEditieren.setEnabled(False)
        self.ui.buttonLoeschen.clicked.connect(self.deleteSelected)
        self.ui.buttonLoeschen.setEnabled(False)
        self.ui.buttonLoeschen.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Delete))
        self.ui.buttonHinzufuegen.clicked.connect(self.hinzufuegen)
        self.ui.buttonWiederherstellen.clicked.connect(self.wiederherstellen)

        self.Form.closeEvent = self.closeEvent
        self.windowTitleDefault = self.Form.windowTitle()
        self.updateGUI()
        self.updateWindowTitleAndCloseButton()
    
    def listSelectionChanged(self):
        indexes = self.ui.listDatenbank.selectedIndexes()
        if not indexes:
            self.ui.buttonEditieren.setEnabled(False)
            self.ui.buttonLoeschen.setEnabled(False)
            self.ui.buttonLoeschen.setVisible(True)
            self.ui.buttonWiederherstellen.setVisible(False)
            return
        item = self.model.itemData(indexes[0])[0]
        if item.endswith(" (gelöscht)"):
            self.ui.buttonEditieren.setEnabled(False)
            self.ui.buttonLoeschen.setVisible(False)
            self.ui.buttonWiederherstellen.setVisible(True)
        else:
            self.ui.buttonEditieren.setEnabled(True)
            self.ui.buttonLoeschen.setEnabled(True)
            self.ui.buttonLoeschen.setVisible(True)
            self.ui.buttonWiederherstellen.setVisible(False)


    def cancelDueToPendingChanges(self, action):
        if self.changed:
            messagebox = QtWidgets.QMessageBox()
            messagebox.setWindowTitle(action)<commit_msg>Database edit: enable edit button when deleted element is selected<commit_after># -*- coding: utf-8 -*-
"""
Created on Sat Mar 18 11:29:39 2017

@author: Aeolitus
"""
import sys
from PyQt5 import QtCore, QtWidgets, QtGui
import Fertigkeiten
import Datenbank
import DatenbankMain
import DatenbankEditFertigkeitWrapper
import DatenbankEditTalentWrapper
import DatenbankEditVorteilWrapper
import DatenbankSelectTypeWrapper
import DatenbankEditWaffeneigenschaftWrapper
import DatenbankEditWaffeWrapper
import DatenbankEditManoeverWrapper
import Objekte
import os
from Wolke import Wolke

class DatenbankEdit(object):
    def __init__(self):
        super().__init__()
        self.datenbank = Datenbank.Datenbank()
        self.savepath = self.datenbank.datei
        self.changed = False
        self.windowTitleDefault = ""
    
    def setupGUI(self):
        # GUI Mods
        self.model = QtGui.QStandardItemModel(self.ui.listDatenbank)
        self.ui.listDatenbank.setModel(self.model)
        self.ui.listDatenbank.doubleClicked["QModelIndex"].connect(self.editSelected)
        self.ui.listDatenbank.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
        self.ui.listDatenbank.selectionModel().selectionChanged.connect(self.listSelectionChanged)
        self.ui.showTalente.stateChanged.connect(self.updateGUI)
        self.ui.showVorteile.stateChanged.connect(self.updateGUI)
        self.ui.showFertigkeiten.stateChanged.connect(self.updateGUI)
        self.ui.showUebernatuerlicheFertigkeiten.stateChanged.connect(self.updateGUI)
        self.ui.showWaffeneigenschaften.stateChanged.connect(self.updateGUI)
        self.ui.showWaffen.stateChanged.connect(self.updateGUI)
        self.ui.showManoever.stateChanged.connect(self.updateGUI)
        self.ui.showUserAdded.stateChanged.connect(self.updateGUI)
        self.ui.showDeleted.stateChanged.connect(self.updateGUI)
        self.ui.nameFilterEdit.textChanged.connect(self.updateGUI)
        self.ui.buttonCloseDB.clicked.connect(self.closeDatenbank)
        self.ui.buttonLoadDB.clicked.connect(self.loadDatenbank)
        self.ui.buttonSaveDB.clicked.connect(self.saveDatenbank)
        self.ui.buttonQuicksave.clicked.connect(self.quicksaveDatenbank)
        self.ui.buttonEditieren.clicked.connect(self.editSelected)
        self.ui.buttonEditieren.setEnabled(False)
        self.ui.buttonLoeschen.clicked.connect(self.deleteSelected)
        self.ui.buttonLoeschen.setEnabled(False)
        self.ui.buttonLoeschen.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Delete))
        self.ui.buttonHinzufuegen.clicked.connect(self.hinzufuegen)
        self.ui.buttonWiederherstellen.clicked.connect(self.wiederherstellen)

        self.Form.closeEvent = self.closeEvent
        self.windowTitleDefault = self.Form.windowTitle()
        self.updateGUI()
        self.updateWindowTitleAndCloseButton()
    
    def listSelectionChanged(self):
        indexes = self.ui.listDatenbank.selectedIndexes()
        if not indexes:
            self.ui.buttonEditieren.setEnabled(False)
            self.ui.buttonLoeschen.setEnabled(False)
            self.ui.buttonLoeschen.setVisible(True)
            self.ui.buttonWiederherstellen.setVisible(False)
            return
        item = self.model.itemData(indexes[0])[0]
        if item.endswith(" (gelöscht)"):
            self.ui.buttonEditieren.setEnabled(True)
            self.ui.buttonLoeschen.setVisible(False)
            self.ui.buttonWiederherstellen.setVisible(True)
        else:
            self.ui.buttonEditieren.setEnabled(True)
            self.ui.buttonLoeschen.setEnabled(True)
            self.ui.buttonLoeschen.setVisible(True)
            self.ui.buttonWiederherstellen.setVisible(False)


    def cancelDueToPendingChanges(self, action):
        if self.changed:
            messagebox = QtWidgets.QMessageBox()
            messagebox.setWindowTitle(action)
{'fraction_non_alphanumeric': 0.09134366925064599, 'fraction_numerical': 0.004134366925064599, 'mean_word_length': 3.4284897025171626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1597834', 'n_tokens_mistral': 2401, 'n_tokens_neox': 2369, 'n_words': 268}