9 """ |
9 """ |
10 |
10 |
11 import os |
11 import os |
12 |
12 |
13 from PyQt4.QtCore import QObject, QThread, QMutex, QProcess, \ |
13 from PyQt4.QtCore import QObject, QThread, QMutex, QProcess, \ |
14 SIGNAL, Qt |
14 Qt, pyqtSignal |
15 from PyQt4.QtGui import QApplication, QMessageBox |
15 from PyQt4.QtGui import QApplication, QMessageBox |
16 |
16 |
17 import Preferences |
17 import Preferences |
18 |
18 |
19 class VersionControl(QObject): |
19 class VersionControl(QObject): |
26 |
26 |
27 @signal vcsStatusMonitorData(QStringList) emitted to update the VCS status |
27 @signal vcsStatusMonitorData(QStringList) emitted to update the VCS status |
28 @signal vcsStatusMonitorStatus(QString, QString) emitted to signal the status of the |
28 @signal vcsStatusMonitorStatus(QString, QString) emitted to signal the status of the |
29 monitoring thread (ok, nok, op, off) and a status message |
29 monitoring thread (ok, nok, op, off) and a status message |
30 """ |
30 """ |
|
31 vcsStatusMonitorData = pyqtSignal(list) |
|
32 vcsStatusMonitorStatus = pyqtSignal(str, str) |
31 |
33 |
32 canBeCommitted = 1 # Indicates that a file/directory is in the vcs. |
34 canBeCommitted = 1 # Indicates that a file/directory is in the vcs. |
33 canBeAdded = 2 # Indicates that a file/directory is not in vcs. |
35 canBeAdded = 2 # Indicates that a file/directory is not in vcs. |
34 |
36 |
35 def __init__(self, parent=None, name=None): |
37 def __init__(self, parent=None, name=None): |
594 It simply reemits the received status. |
596 It simply reemits the received status. |
595 |
597 |
596 @param status status of the monitoring thread (string, ok, nok or off) |
598 @param status status of the monitoring thread (string, ok, nok or off) |
597 @param statusMsg explanotory text for the signaled status (string) |
599 @param statusMsg explanotory text for the signaled status (string) |
598 """ |
600 """ |
599 self.emit(SIGNAL("vcsStatusMonitorStatus(QString, QString)"), status, statusMsg) |
601 self.vcsStatusMonitorStatus.emit(status, statusMsg) |
600 QApplication.flush() |
602 QApplication.flush() |
601 |
603 |
602 def __statusMonitorData(self, statusList): |
604 def __statusMonitorData(self, statusList): |
603 """ |
605 """ |
604 Private method to receive the status monitor status. |
606 Private method to receive the status monitor status. |
605 |
607 |
606 It simply reemits the received status list. |
608 It simply reemits the received status list. |
607 |
609 |
608 @param statusList list of status records (list of strings) |
610 @param statusList list of status records (list of strings) |
609 """ |
611 """ |
610 self.emit(SIGNAL("vcsStatusMonitorData(QStringList)"), statusList) |
612 self.vcsStatusMonitorData.emit(statusList) |
611 QApplication.flush() |
613 QApplication.flush() |
612 |
614 |
613 def startStatusMonitor(self, project): |
615 def startStatusMonitor(self, project): |
614 """ |
616 """ |
615 Public method to start the VCS status monitor thread. |
617 Public method to start the VCS status monitor thread. |
623 vcsStatusMonitorInterval = Preferences.getVCS("StatusMonitorInterval") |
625 vcsStatusMonitorInterval = Preferences.getVCS("StatusMonitorInterval") |
624 if vcsStatusMonitorInterval > 0: |
626 if vcsStatusMonitorInterval > 0: |
625 self.statusMonitorThread = \ |
627 self.statusMonitorThread = \ |
626 self._createStatusMonitorThread(vcsStatusMonitorInterval, project) |
628 self._createStatusMonitorThread(vcsStatusMonitorInterval, project) |
627 if self.statusMonitorThread is not None: |
629 if self.statusMonitorThread is not None: |
628 self.connect(self.statusMonitorThread, |
630 self.statusMonitorThread.vcsStatusMonitorData.connect( |
629 SIGNAL("vcsStatusMonitorData(QStringList)"), |
631 self.__statusMonitorData, Qt.QueuedConnection) |
630 self.__statusMonitorData, Qt.QueuedConnection) |
632 self.statusMonitorThread.vcsStatusMonitorStatus.connect( |
631 self.connect(self.statusMonitorThread, |
633 self.__statusMonitorStatus, Qt.QueuedConnection) |
632 SIGNAL("vcsStatusMonitorStatus(QString, QString)"), |
|
633 self.__statusMonitorStatus, Qt.QueuedConnection) |
|
634 self.statusMonitorThread.setAutoUpdate( |
634 self.statusMonitorThread.setAutoUpdate( |
635 Preferences.getVCS("AutoUpdate")) |
635 Preferences.getVCS("AutoUpdate")) |
636 self.statusMonitorThread.start() |
636 self.statusMonitorThread.start() |
637 else: |
637 else: |
638 self.statusMonitorThread = None |
638 self.statusMonitorThread = None |
642 """ |
642 """ |
643 Public method to stop the VCS status monitor thread. |
643 Public method to stop the VCS status monitor thread. |
644 """ |
644 """ |
645 if self.statusMonitorThread is not None: |
645 if self.statusMonitorThread is not None: |
646 self.__statusMonitorData(["--RESET--"]) |
646 self.__statusMonitorData(["--RESET--"]) |
647 self.disconnect(self.statusMonitorThread, |
647 self.statusMonitorThread.vcsStatusMonitorData.disconnect( |
648 SIGNAL("vcsStatusMonitorData(QStringList)"), |
|
649 self.__statusMonitorData) |
648 self.__statusMonitorData) |
650 self.disconnect(self.statusMonitorThread, |
649 self.statusMonitorThread.vcsStatusMonitorStatus.disconnect( |
651 SIGNAL("vcsStatusMonitorStatus(QString, QString)"), |
|
652 self.__statusMonitorStatus) |
650 self.__statusMonitorStatus) |
653 self.statusMonitorThread.stop() |
651 self.statusMonitorThread.stop() |
654 self.statusMonitorThread.wait(10000) |
652 self.statusMonitorThread.wait(10000) |
655 if not self.statusMonitorThread.isFinished(): |
653 if not self.statusMonitorThread.isFinished(): |
656 self.statusMonitorThread.terminate() |
654 self.statusMonitorThread.terminate() |