Exemplo n.º 1
0
class ImportDialog(QtGui.QDialog, Ui_ImportDialog):

    def __init__(self, dbname, directory, parent=None):
        super(ImportDialog, self).__init__(parent)
        self.found = 0
        self.processed = 0

        self.setupUi(self)
        desktopGeometry = QtGui.qApp.desktop().screenGeometry()
        self.move((desktopGeometry.width() - self.width()) / 2,
                  (desktopGeometry.height() - self.height()) / 2)

        self.importThread = ImportThread(dbname, directory)
        self.importThread.error.connect(self.textEdit.append)
        self.importThread.processed.connect(self.on_processed)
        self.importThread.start()
        self.finderThread = FinderThread(directory)
        self.finderThread.found.connect(self.on_found)
        self.finderThread.found.connect(self.importThread.addFilename)
        self.finderThread.start()
        self.finished.connect(self.importThread.quit)
        self.finished.connect(self.finderThread.quit)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateCounters)
        timer.start(100)

    def __del__(self):
        self.importThread.wait()
        self.finderThread.wait()

    def on_found(self, filename):
        self.found += 1

    def on_processed(self, filename):
        self.processed += 1

    def updateCounters(self):
        self.filesFoundLabel.setNum(self.found)
        self.filesProcessedLabel.setNum(self.processed)
        if self.found != 0:
            self.progressBar.setValue(100 * self.processed / self.found)
        if self.found == self.processed and not self.finderThread.isRunning():
            self.close()
Exemplo n.º 2
0
class ImportDialog(QtWidgets.QDialog, Ui_ImportDialog):

    def __init__(self, directory, parent=None):
        super(ImportDialog, self).__init__(parent)
        self.found = 0
        self.processed = 0

        self.setupUi(self)

        self.importThread = ImportThread(directory)
        self.importThread.error.connect(self.textEdit.append)
        self.importThread.processed.connect(self.on_processed)
        self.importThread.start()
        self.finderThread = FinderThread(directory)
        self.finderThread.found.connect(self.on_found)
        self.finderThread.found.connect(self.importThread.addFilename)
        self.finderThread.start()
        self.finished.connect(self.importThread.quit)
        self.finished.connect(self.finderThread.quit)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateCounters)
        timer.start(100)

    def __del__(self):
        self.importThread.wait()
        self.finderThread.wait()

    def on_found(self, filename):
        self.found += 1

    def on_processed(self, filename):
        self.processed += 1

    def updateCounters(self):
        self.filesFoundLabel.setNum(self.found)
        self.filesProcessedLabel.setNum(self.processed)
        if self.found != 0:
            self.progressBar.setValue(100 * self.processed / self.found)
        if self.found == self.processed and not self.finderThread.isRunning():
            if self.closeAfterCompletingBox.isChecked():
                self.close()
Exemplo n.º 3
0
class ImportDialog(QtGui.QDialog, Ui_ImportDialog):
    def __init__(self, directory, parent=None):
        super(ImportDialog, self).__init__(parent)
        self.found = 0
        self.processed = 0

        self.setupUi(self)

        self.importThread = ImportThread(directory)
        self.importThread.error.connect(self.textEdit.append)
        self.importThread.processed.connect(self.on_processed)
        self.importThread.start()
        self.finderThread = FinderThread(directory)
        self.finderThread.found.connect(self.on_found)
        self.finderThread.found.connect(self.importThread.addFilename)
        self.finderThread.start()
        self.finished.connect(self.importThread.quit)
        self.finished.connect(self.finderThread.quit)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateCounters)
        timer.start(100)

    def __del__(self):
        self.importThread.wait()
        self.finderThread.wait()

    def on_found(self, filename):
        self.found += 1

    def on_processed(self, filename):
        self.processed += 1

    def updateCounters(self):
        self.filesFoundLabel.setNum(self.found)
        self.filesProcessedLabel.setNum(self.processed)
        if self.found != 0:
            self.progressBar.setValue(100 * self.processed / self.found)
        if self.found == self.processed and not self.finderThread.isRunning():
            if self.closeAfterCompletingBox.isChecked():
                self.close()
Exemplo n.º 4
0
    def __init__(self, directory, parent=None):
        super(ImportDialog, self).__init__(parent)
        self.found = 0
        self.processed = 0

        self.setupUi(self)

        self.importThread = ImportThread(directory)
        self.importThread.error.connect(self.textEdit.append)
        self.importThread.processed.connect(self.on_processed)
        self.importThread.start()
        self.finderThread = FinderThread(directory)
        self.finderThread.found.connect(self.on_found)
        self.finderThread.found.connect(self.importThread.addFilename)
        self.finderThread.start()
        self.finished.connect(self.importThread.quit)
        self.finished.connect(self.finderThread.quit)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateCounters)
        timer.start(100)
Exemplo n.º 5
0
    def __init__(self, directory, parent=None):
        super(ImportDialog, self).__init__(parent)
        self.found = 0
        self.processed = 0

        self.setupUi(self)

        self.importThread = ImportThread(directory)
        self.importThread.error.connect(self.textEdit.append)
        self.importThread.processed.connect(self.on_processed)
        self.importThread.start()
        self.finderThread = FinderThread(directory)
        self.finderThread.found.connect(self.on_found)
        self.finderThread.found.connect(self.importThread.addFilename)
        self.finderThread.start()
        self.finished.connect(self.importThread.quit)
        self.finished.connect(self.finderThread.quit)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateCounters)
        timer.start(100)
Exemplo n.º 6
0
    def __init__(self, dbname, directory, parent=None):
        super(ImportDialog, self).__init__(parent)
        self.found = 0
        self.processed = 0

        self.setupUi(self)
        desktopGeometry = QtGui.qApp.desktop().screenGeometry()
        self.move((desktopGeometry.width() - self.width()) / 2,
                  (desktopGeometry.height() - self.height()) / 2)

        self.importThread = ImportThread(dbname, directory)
        self.importThread.error.connect(self.textEdit.append)
        self.importThread.processed.connect(self.on_processed)
        self.importThread.start()
        self.finderThread = FinderThread(directory)
        self.finderThread.found.connect(self.on_found)
        self.finderThread.found.connect(self.importThread.addFilename)
        self.finderThread.start()
        self.finished.connect(self.importThread.quit)
        self.finished.connect(self.finderThread.quit)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateCounters)
        timer.start(100)