--- a/src/eric7/WebBrowser/PersonalInformationManager/PersonalInformationManager.py Sun Jan 07 11:42:41 2024 +0100 +++ b/src/eric7/WebBrowser/PersonalInformationManager/PersonalInformationManager.py Sun Jan 07 12:40:00 2024 +0100 @@ -8,6 +8,7 @@ fields. """ +import enum import functools from PyQt6.QtCore import QObject, QPoint, Qt @@ -19,13 +20,11 @@ from ..WebBrowserPage import WebBrowserPage -class PersonalInformationManager(QObject): +class PersonalInformationType(enum.Enum): """ - Class implementing the personal information manager used to complete form - fields. + Class defining the personal information types. """ - # TODO: change this to an enum FullName = 0 LastName = 1 FirstName = 2 @@ -42,9 +41,17 @@ Special2 = 13 Special3 = 14 Special4 = 15 + Max = 16 Invalid = 256 + +class PersonalInformationManager(QObject): + """ + Class implementing the personal information manager used to complete form + fields. + """ + def __init__(self, parent=None): """ Constructor @@ -66,52 +73,84 @@ """ Private method to load the settings. """ - self.__allInfo[self.FullName] = Preferences.getWebBrowser("PimFullName") - self.__allInfo[self.LastName] = Preferences.getWebBrowser("PimLastName") - self.__allInfo[self.FirstName] = Preferences.getWebBrowser("PimFirstName") - self.__allInfo[self.Email] = Preferences.getWebBrowser("PimEmail") - self.__allInfo[self.Mobile] = Preferences.getWebBrowser("PimMobile") - self.__allInfo[self.Phone] = Preferences.getWebBrowser("PimPhone") - self.__allInfo[self.Address] = Preferences.getWebBrowser("PimAddress") - self.__allInfo[self.City] = Preferences.getWebBrowser("PimCity") - self.__allInfo[self.Zip] = Preferences.getWebBrowser("PimZip") - self.__allInfo[self.State] = Preferences.getWebBrowser("PimState") - self.__allInfo[self.Country] = Preferences.getWebBrowser("PimCountry") - self.__allInfo[self.HomePage] = Preferences.getWebBrowser("PimHomePage") - self.__allInfo[self.Special1] = Preferences.getWebBrowser("PimSpecial1") - self.__allInfo[self.Special2] = Preferences.getWebBrowser("PimSpecial2") - self.__allInfo[self.Special3] = Preferences.getWebBrowser("PimSpecial3") - self.__allInfo[self.Special4] = Preferences.getWebBrowser("PimSpecial4") + self.__allInfo[PersonalInformationType.FullName] = Preferences.getWebBrowser( + "PimFullName" + ) + self.__allInfo[PersonalInformationType.LastName] = Preferences.getWebBrowser( + "PimLastName" + ) + self.__allInfo[PersonalInformationType.FirstName] = Preferences.getWebBrowser( + "PimFirstName" + ) + self.__allInfo[PersonalInformationType.Email] = Preferences.getWebBrowser( + "PimEmail" + ) + self.__allInfo[PersonalInformationType.Mobile] = Preferences.getWebBrowser( + "PimMobile" + ) + self.__allInfo[PersonalInformationType.Phone] = Preferences.getWebBrowser( + "PimPhone" + ) + self.__allInfo[PersonalInformationType.Address] = Preferences.getWebBrowser( + "PimAddress" + ) + self.__allInfo[PersonalInformationType.City] = Preferences.getWebBrowser( + "PimCity" + ) + self.__allInfo[PersonalInformationType.Zip] = Preferences.getWebBrowser( + "PimZip" + ) + self.__allInfo[PersonalInformationType.State] = Preferences.getWebBrowser( + "PimState" + ) + self.__allInfo[PersonalInformationType.Country] = Preferences.getWebBrowser( + "PimCountry" + ) + self.__allInfo[PersonalInformationType.HomePage] = Preferences.getWebBrowser( + "PimHomePage" + ) + self.__allInfo[PersonalInformationType.Special1] = Preferences.getWebBrowser( + "PimSpecial1" + ) + self.__allInfo[PersonalInformationType.Special2] = Preferences.getWebBrowser( + "PimSpecial2" + ) + self.__allInfo[PersonalInformationType.Special3] = Preferences.getWebBrowser( + "PimSpecial3" + ) + self.__allInfo[PersonalInformationType.Special4] = Preferences.getWebBrowser( + "PimSpecial4" + ) - self.__translations[self.FullName] = self.tr("Full Name") - self.__translations[self.LastName] = self.tr("Last Name") - self.__translations[self.FirstName] = self.tr("First Name") - self.__translations[self.Email] = self.tr("E-mail") - self.__translations[self.Mobile] = self.tr("Mobile") - self.__translations[self.Phone] = self.tr("Phone") - self.__translations[self.Address] = self.tr("Address") - self.__translations[self.City] = self.tr("City") - self.__translations[self.Zip] = self.tr("ZIP Code") - self.__translations[self.State] = self.tr("State/Region") - self.__translations[self.Country] = self.tr("Country") - self.__translations[self.HomePage] = self.tr("Home Page") - self.__translations[self.Special1] = self.tr("Custom 1") - self.__translations[self.Special2] = self.tr("Custom 2") - self.__translations[self.Special3] = self.tr("Custom 3") - self.__translations[self.Special4] = self.tr("Custom 4") + self.__translations[PersonalInformationType.FullName] = self.tr("Full Name") + self.__translations[PersonalInformationType.LastName] = self.tr("Last Name") + self.__translations[PersonalInformationType.FirstName] = self.tr("First Name") + self.__translations[PersonalInformationType.Email] = self.tr("E-mail") + self.__translations[PersonalInformationType.Mobile] = self.tr("Mobile") + self.__translations[PersonalInformationType.Phone] = self.tr("Phone") + self.__translations[PersonalInformationType.Address] = self.tr("Address") + self.__translations[PersonalInformationType.City] = self.tr("City") + self.__translations[PersonalInformationType.Zip] = self.tr("ZIP Code") + self.__translations[PersonalInformationType.State] = self.tr("State/Region") + self.__translations[PersonalInformationType.Country] = self.tr("Country") + self.__translations[PersonalInformationType.HomePage] = self.tr("Home Page") + self.__translations[PersonalInformationType.Special1] = self.tr("Custom 1") + self.__translations[PersonalInformationType.Special2] = self.tr("Custom 2") + self.__translations[PersonalInformationType.Special3] = self.tr("Custom 3") + self.__translations[PersonalInformationType.Special4] = self.tr("Custom 4") - self.__infoMatches[self.FullName] = ["fullname", "realname"] - self.__infoMatches[self.LastName] = ["lastname", "surname"] - self.__infoMatches[self.FirstName] = ["firstname", "name"] - self.__infoMatches[self.Email] = ["email", "e-mail", "mail"] - self.__infoMatches[self.Mobile] = ["mobile", "mobilephone"] - self.__infoMatches[self.Phone] = ["phone", "telephone"] - self.__infoMatches[self.Address] = ["address"] - self.__infoMatches[self.City] = ["city"] - self.__infoMatches[self.Zip] = ["zip"] - self.__infoMatches[self.State] = ["state", "region"] - self.__infoMatches[self.Country] = ["country"] - self.__infoMatches[self.HomePage] = ["homepage", "www"] + self.__infoMatches[PersonalInformationType.FullName] = ["fullname", "realname"] + self.__infoMatches[PersonalInformationType.LastName] = ["lastname", "surname"] + self.__infoMatches[PersonalInformationType.FirstName] = ["firstname", "name"] + self.__infoMatches[PersonalInformationType.Email] = ["email", "e-mail", "mail"] + self.__infoMatches[PersonalInformationType.Mobile] = ["mobile", "mobilephone"] + self.__infoMatches[PersonalInformationType.Phone] = ["phone", "telephone"] + self.__infoMatches[PersonalInformationType.Address] = ["address"] + self.__infoMatches[PersonalInformationType.City] = ["city"] + self.__infoMatches[PersonalInformationType.Zip] = ["zip"] + self.__infoMatches[PersonalInformationType.State] = ["state", "region"] + self.__infoMatches[PersonalInformationType.Country] = ["country"] + self.__infoMatches[PersonalInformationType.HomePage] = ["homepage", "www"] self.__loaded = True