329 @signal apiPreparationFinished() emitted after the API preparation has finished |
329 @signal apiPreparationFinished() emitted after the API preparation has finished |
330 @signal apiPreparationStarted() emitted after the API preparation has started |
330 @signal apiPreparationStarted() emitted after the API preparation has started |
331 @signal apiPreparationCancelled() emitted after the API preparation has been |
331 @signal apiPreparationCancelled() emitted after the API preparation has been |
332 cancelled |
332 cancelled |
333 """ |
333 """ |
|
334 apiPreparationFinished = pyqtSignal() |
|
335 apiPreparationStarted = pyqtSignal() |
|
336 apiPreparationCancelled = pyqtSignal() |
|
337 |
334 DB_VERSION = 3 |
338 DB_VERSION = 3 |
335 |
339 |
336 create_mgmt_stmt = """ |
340 create_mgmt_stmt = """ |
337 CREATE TABLE mgmt |
341 CREATE TABLE mgmt |
338 (format INTEGER) |
342 (format INTEGER) |
406 """ |
410 """ |
407 mgmt_insert_stmt = """ |
411 mgmt_insert_stmt = """ |
408 INSERT INTO mgmt (format) VALUES ({0:d}) |
412 INSERT INTO mgmt (format) VALUES ({0:d}) |
409 """.format(DB_VERSION) |
413 """.format(DB_VERSION) |
410 |
414 |
411 def __init__(self, language, parent = None): |
415 def __init__(self, language, newStyle, parent = None): |
412 """ |
416 """ |
413 Constructor |
417 Constructor |
414 |
418 |
415 @param language language of the APIs object (string) |
419 @param language language of the APIs object (string) |
|
420 @param newStyle flag indicating usage of new style signals (bool) |
416 @param parent reference to the parent object (QObject) |
421 @param parent reference to the parent object (QObject) |
417 """ |
422 """ |
418 QObject.__init__(self, parent) |
423 QObject.__init__(self, parent) |
419 self.setObjectName("DbAPIs_{0}".format(language)) |
424 self.setObjectName("DbAPIs_{0}".format(language)) |
420 |
425 |
|
426 self.__newStyle = newStyle |
421 self.__inPreparation = False |
427 self.__inPreparation = False |
422 self.__worker = None |
428 self.__worker = None |
423 self.__workerQueue = [] |
429 self.__workerQueue = [] |
424 |
430 |
425 self.__language = language |
431 self.__language = language |
433 Private method to initialize as a project API object. |
439 Private method to initialize as a project API object. |
434 """ |
440 """ |
435 self.__lexer = None |
441 self.__lexer = None |
436 |
442 |
437 self.__project = e5App().getObject("Project") |
443 self.__project = e5App().getObject("Project") |
438 self.connect(self.__project, SIGNAL("projectOpened"), self.__projectOpened) |
444 if self.__newStyle: |
439 self.connect(self.__project, SIGNAL("newProject"), self.__projectOpened) |
445 self.__project.projectOpened.connect(self.__projectOpened) |
440 self.connect(self.__project, SIGNAL("projectClosed"), self.__projectClosed) |
446 self.__project.newProject.connect(self.__projectOpened) |
|
447 self.__project.projectClosed.connect(self.__projectClosed) |
|
448 else: |
|
449 self.connect(self.__project, SIGNAL("projectOpened"), self.__projectOpened) |
|
450 self.connect(self.__project, SIGNAL("newProject"), self.__projectOpened) |
|
451 self.connect(self.__project, SIGNAL("projectClosed"), self.__projectClosed) |
441 if self.__project.isOpen(): |
452 if self.__project.isOpen(): |
442 self.__projectOpened() |
453 self.__projectOpened() |
443 |
454 |
444 def __initAsLanguage(self): |
455 def __initAsLanguage(self): |
445 """ |
456 """ |
764 @param evt reference to the event object (QEvent) |
775 @param evt reference to the event object (QEvent) |
765 @return flag indicating, if the event was handled (boolean) |
776 @return flag indicating, if the event was handled (boolean) |
766 """ |
777 """ |
767 if evt.type() == WorkerStarted: |
778 if evt.type() == WorkerStarted: |
768 self.__inPreparation = True |
779 self.__inPreparation = True |
769 self.emit(SIGNAL('apiPreparationStarted()')) |
780 if self.__newStyle: |
|
781 self.apiPreparationStarted.emit() |
|
782 else: |
|
783 self.emit(SIGNAL('apiPreparationStarted()')) |
770 return True |
784 return True |
771 |
785 |
772 elif evt.type() == WorkerFinished: |
786 elif evt.type() == WorkerFinished: |
773 self.__inPreparation = False |
787 self.__inPreparation = False |
774 self.emit(SIGNAL('apiPreparationFinished()')) |
788 if self.__newStyle: |
|
789 self.apiPreparationFinished.emit() |
|
790 else: |
|
791 self.emit(SIGNAL('apiPreparationFinished()')) |
775 QTimer.singleShot(0, self.__processQueue) |
792 QTimer.singleShot(0, self.__processQueue) |
776 return True |
793 return True |
777 |
794 |
778 elif evt.type() == WorkerAborted: |
795 elif evt.type() == WorkerAborted: |
779 self.__inPreparation = False |
796 self.__inPreparation = False |
780 self.emit(SIGNAL('apiPreparationCancelled()')) |
797 if self.__newStyle: |
|
798 self.apiPreparationCancelled.emit() |
|
799 else: |
|
800 self.emit(SIGNAL('apiPreparationCancelled()')) |
781 QTimer.singleShot(0, self.__processQueue) |
801 QTimer.singleShot(0, self.__processQueue) |
782 return True |
802 return True |
783 |
803 |
784 else: |
804 else: |
785 return QObject.event(self, evt) |
805 return QObject.event(self, evt) |
818 class APIsManager(QObject): |
838 class APIsManager(QObject): |
819 """ |
839 """ |
820 Class implementing the APIsManager class, which is the central store for |
840 Class implementing the APIsManager class, which is the central store for |
821 API information used by autocompletion and calltips. |
841 API information used by autocompletion and calltips. |
822 """ |
842 """ |
823 def __init__(self, parent = None): |
843 def __init__(self, newStyle, parent = None): |
824 """ |
844 """ |
825 Constructor |
845 Constructor |
826 |
846 |
|
847 @param newStyle flag indicating usage of new style signals (bool) |
827 @param parent reference to the parent object (QObject) |
848 @param parent reference to the parent object (QObject) |
828 """ |
849 """ |
829 QObject.__init__(self, parent) |
850 QObject.__init__(self, parent) |
830 self.setObjectName("APIsManager") |
851 self.setObjectName("APIsManager") |
|
852 |
|
853 self.__newStyle = newStyle |
831 |
854 |
832 # initialize the apis dictionary |
855 # initialize the apis dictionary |
833 self.__apis = {} |
856 self.__apis = {} |
834 |
857 |
835 def reloadAPIs(self): |
858 def reloadAPIs(self): |
853 return self.__apis[language] |
876 return self.__apis[language] |
854 except KeyError: |
877 except KeyError: |
855 if language in QScintilla.Lexers.getSupportedLanguages() or \ |
878 if language in QScintilla.Lexers.getSupportedLanguages() or \ |
856 language == ApisNameProject: |
879 language == ApisNameProject: |
857 # create the api object |
880 # create the api object |
858 self.__apis[language] = DbAPIs(language) |
881 self.__apis[language] = DbAPIs(language, self.__newStyle) |
859 return self.__apis[language] |
882 return self.__apis[language] |
860 else: |
883 else: |
861 return None |
884 return None |
862 |
885 |
863 def deactivate(self): |
886 def deactivate(self): |