417 |
417 |
418 class DbAPIs(QObject): |
418 class DbAPIs(QObject): |
419 """ |
419 """ |
420 Class implementing an API storage entity. |
420 Class implementing an API storage entity. |
421 |
421 |
422 @signal apiPreparationFinished() emitted after the API preparation has finished |
422 @signal apiPreparationFinished(language) emitted after the API preparation has finished |
423 @signal apiPreparationStarted() emitted after the API preparation has started |
423 @signal apiPreparationStarted(language) emitted after the API preparation has started |
424 @signal apiPreparationCancelled() emitted after the API preparation has been |
424 @signal apiPreparationCancelled(language) emitted after the API preparation has been |
425 cancelled |
425 cancelled |
426 """ |
426 """ |
427 apiPreparationFinished = pyqtSignal() |
427 apiPreparationFinished = pyqtSignal(str) |
428 apiPreparationStarted = pyqtSignal() |
428 apiPreparationStarted = pyqtSignal(str) |
429 apiPreparationCancelled = pyqtSignal() |
429 apiPreparationCancelled = pyqtSignal(str) |
430 |
430 |
431 DB_VERSION = 4 |
431 DB_VERSION = 4 |
432 |
432 |
433 create_mgmt_stmt = """ |
433 create_mgmt_stmt = """ |
434 CREATE TABLE mgmt |
434 CREATE TABLE mgmt |
955 @param evt reference to the event object (QEvent) |
955 @param evt reference to the event object (QEvent) |
956 @return flag indicating, if the event was handled (boolean) |
956 @return flag indicating, if the event was handled (boolean) |
957 """ |
957 """ |
958 if evt.type() == WorkerStarted: |
958 if evt.type() == WorkerStarted: |
959 self.__inPreparation = True |
959 self.__inPreparation = True |
960 self.apiPreparationStarted.emit() |
960 self.apiPreparationStarted.emit(self.__language) |
961 return True |
961 return True |
962 |
962 |
963 elif evt.type() == WorkerFinished: |
963 elif evt.type() == WorkerFinished: |
964 self.__inPreparation = False |
964 self.__inPreparation = False |
965 self.apiPreparationFinished.emit() |
965 self.apiPreparationFinished.emit(self.__language) |
966 QTimer.singleShot(0, self.__processQueue) |
966 QTimer.singleShot(0, self.__processQueue) |
967 return True |
967 return True |
968 |
968 |
969 elif evt.type() == WorkerAborted: |
969 elif evt.type() == WorkerAborted: |
970 self.__inPreparation = False |
970 self.__inPreparation = False |
971 self.apiPreparationCancelled.emit() |
971 self.apiPreparationCancelled.emit(self.__language) |
972 QTimer.singleShot(0, self.__processQueue) |
972 QTimer.singleShot(0, self.__processQueue) |
973 return True |
973 return True |
974 |
974 |
975 else: |
975 else: |
976 return QObject.event(self, evt) |
976 return QObject.event(self, evt) |
1019 class APIsManager(QObject): |
1019 class APIsManager(QObject): |
1020 """ |
1020 """ |
1021 Class implementing the APIsManager class, which is the central store for |
1021 Class implementing the APIsManager class, which is the central store for |
1022 API information used by autocompletion and calltips. |
1022 API information used by autocompletion and calltips. |
1023 """ |
1023 """ |
1024 def __init__(self, parent=None): |
1024 def __init__(self, mainWindow, parent=None): |
1025 """ |
1025 """ |
1026 Constructor |
1026 Constructor |
1027 |
1027 |
|
1028 @param mainWindow reference to the main eric5 window (QMainWindow) |
1028 @param parent reference to the parent object (QObject) |
1029 @param parent reference to the parent object (QObject) |
1029 """ |
1030 """ |
1030 QObject.__init__(self, parent) |
1031 QObject.__init__(self, parent) |
1031 self.setObjectName("APIsManager") |
1032 self.setObjectName("APIsManager") |
|
1033 |
|
1034 self.__mw = mainWindow |
1032 |
1035 |
1033 # initialize the apis dictionary |
1036 # initialize the apis dictionary |
1034 self.__apis = {} |
1037 self.__apis = {} |
1035 |
1038 |
1036 def reloadAPIs(self): |
1039 def reloadAPIs(self): |
1054 return self.__apis[language] |
1057 return self.__apis[language] |
1055 except KeyError: |
1058 except KeyError: |
1056 if language in QScintilla.Lexers.getSupportedLanguages() or \ |
1059 if language in QScintilla.Lexers.getSupportedLanguages() or \ |
1057 language == ApisNameProject: |
1060 language == ApisNameProject: |
1058 # create the api object |
1061 # create the api object |
1059 self.__apis[language] = DbAPIs(language) |
1062 api = DbAPIs(language) |
|
1063 api.apiPreparationFinished.connect(self.__apiPreparationFinished) |
|
1064 api.apiPreparationStarted.connect(self.__apiPreparationStarted) |
|
1065 api.apiPreparationCancelled.connect(self.__apiPreparationCancelled) |
|
1066 self.__apis[language] = api |
1060 return self.__apis[language] |
1067 return self.__apis[language] |
1061 else: |
1068 else: |
1062 return None |
1069 return None |
1063 |
1070 |
1064 def deactivate(self): |
1071 def deactivate(self): |
1065 """ |
1072 """ |
1066 Public method to perform actions upon deactivation. |
1073 Public method to perform actions upon deactivation. |
1067 """ |
1074 """ |
1068 for apiLang in self.__apis: |
1075 for apiLang in self.__apis: |
1069 self.__apis[apiLang].close() |
1076 self.__apis[apiLang].close() |
|
1077 self.__apis[apiLang].deleteLater() |
1070 self.__apis[apiLang] = None |
1078 self.__apis[apiLang] = None |
|
1079 |
|
1080 def __showMessage(self, msg): |
|
1081 """ |
|
1082 Private message to show a message in the main windows status bar. |
|
1083 |
|
1084 @param msg message to be shown (string) |
|
1085 """ |
|
1086 self.__mw.statusBar().showMessage(msg, 2000) |
|
1087 |
|
1088 def __apiPreparationFinished(self, language): |
|
1089 """ |
|
1090 Private slot handling the preparation finished signal of an API object. |
|
1091 |
|
1092 @param language language of the API (string) |
|
1093 """ |
|
1094 if language == ApisNameProject: |
|
1095 language = self.trUtf8("Project") |
|
1096 self.__showMessage(self.trUtf8("Preparation of '{0}' APIs finished.") |
|
1097 .format(language)) |
|
1098 |
|
1099 def __apiPreparationStarted(self, language): |
|
1100 """ |
|
1101 Private slot handling the preparation started signal of an API object. |
|
1102 |
|
1103 @param language language of the API (string) |
|
1104 """ |
|
1105 if language == ApisNameProject: |
|
1106 language = self.trUtf8("Project") |
|
1107 self.__showMessage(self.trUtf8("Preparation of '{0}' APIs started.") |
|
1108 .format(language)) |
|
1109 |
|
1110 def __apiPreparationCancelled(self, language): |
|
1111 """ |
|
1112 Private slot handling the preparation cancelled signal of an API object. |
|
1113 |
|
1114 @param language language of the API (string) |
|
1115 """ |
|
1116 if language == ApisNameProject: |
|
1117 language = self.trUtf8("Project") |
|
1118 self.__showMessage(self.trUtf8("Preparation of '{0}' APIs cancelled.") |
|
1119 .format(language)) |