def runGeotagging(self):
        self.mutex.lock()
        self.stopMe = 0
        self.mutex.unlock()

        self.process = QProcess()
        utils.setProcessEnvironment(self.process)
        self.process.error.connect(self.geotagError)

        rows = self.model.rowCount()

        # get total folder count for progress indicator
        count = 0
        for r in xrange(rows):
            lat = self.model.item(r, 1).text()
            lon = self.model.item(r, 2).text()
            item = self.model.item(r, 3)
            if (item and item.text() == "") or (lat == "" or lon == ""):
                continue

            count += 1

        self.rangeChanged.emit([self.tr("Geotagging: %p%"), count])
        for r in xrange(rows):
            item = self.model.item(r, 3)
            if item is None:
                continue
            if item and item.text() == "":
                continue

            lon = self.model.item(r, 1).text()
            lat = self.model.item(r, 2).text()
            dirName = self.model.item(r, 3).text()

            self.arguments[:] = []
            self.arguments.append("-GPSLongitudeRef=%s" % self.lonRef)
            self.arguments.append("-GPSLongitude=%s" % lon)
            self.arguments.append("-GPSLatitudeRef=%s" % self.latRef)
            self.arguments.append("-GPSLatitude=%s" % lat)
            self.arguments.append("-ext")
            self.arguments.append("jpg")
            self.arguments.append("-r")
            self.arguments.append(dirName)

            self.process.start(self.command, self.arguments,
                               QIODevice.ReadOnly)
            if not self.process.waitForFinished(-1):
                QgsMessageLog.logMessage("Failed to process directory " +
                                         dirName,
                                         tag='Geotag and import photos',
                                         level=QgsMessageLog.WARNING)

            self.updateProgress.emit()

            self.mutex.lock()
            s = self.stopMe
            self.mutex.unlock()
            if s == 1:
                self.interrupted = True
                break
    def runGeotagging(self):
        self.mutex.lock()
        self.stopMe = 0
        self.mutex.unlock()

        self.process = QProcess()
        utils.setProcessEnvironment(self.process)
        self.process.error.connect(self.geotagError)

        rows = self.model.rowCount()

        # get total folder count for progress indicator
        count = 0
        for r in xrange(rows):
            lat = self.model.item(r, 1).text()
            lon = self.model.item(r, 2).text()
            item = self.model.item(r, 3)
            if (item and item.text() == "") or (lat == "" or lon == ""):
                continue

            count += 1

        self.rangeChanged.emit([self.tr("Geotagging: %p%"), count])
        for r in xrange(rows):
            item = self.model.item(r, 3)
            if item is None:
                continue
            if item and item.text() == "":
                continue

            lon = self.model.item(r, 1).text()
            lat = self.model.item(r, 2).text()
            dirName = self.model.item(r, 3).text()

            self.arguments[:] = []
            self.arguments.append("-GPSLongitudeRef=%s" % self.lonRef)
            self.arguments.append("-GPSLongitude=%s" % lon)
            self.arguments.append("-GPSLatitudeRef=%s" % self.latRef)
            self.arguments.append("-GPSLatitude=%s" % lat)
            self.arguments.append("-ext")
            self.arguments.append("jpg")
            self.arguments.append("-r")
            self.arguments.append(dirName)

            self.process.start(self.command, self.arguments, QIODevice.ReadOnly)
            if not self.process.waitForFinished(-1):
                print "Failed to process directory", dirName

            self.updateProgress.emit()

            self.mutex.lock()
            s = self.stopMe
            self.mutex.unlock()
            if s == 1:
                self.interrupted = True
                break
    def run(self):
        self.mutex.lock()
        self.stopMe = 0
        self.mutex.unlock()

        self.process = QProcess()
        utils.setProcessEnvironment(self.process)
        self.process.error.connect(self.taggingError)

        rows = self.model.rowCount()

        # get total folder count for progress indicator
        count = 0
        for r in xrange(rows):
            tag = self.model.item(r, 0).text()
            val = self.model.item(r, 1).text()
            item = self.model.item(r, 2)
            if (item and item.text() == "") or (tag == "" or val == ""):
                continue

            count += 1

        self.rangeChanged.emit([self.tr("Tagging: %p%"), count])
        for r in xrange(rows):
            item = self.model.item(r, 0)
            if item is None:
                continue
            if item and item.text() == "":
                continue

            dirName = self.model.item(r, 0).text()
            tagName = self.model.item(r, 1).text()
            tagValue = self.model.item(r, 2).text()

            self.arguments[:] = []

            if self.configFile != "":
                self.arguments.append("-config")
                self.arguments.append(self.configFile)

            self.arguments.append("-%s=%s" % (tagName, tagValue))
            self.arguments.append("-ext")
            self.arguments.append("jpg")
            self.arguments.append("-r")
            self.arguments.append(dirName)

            self.process.start(self.command, self.arguments,
                               QIODevice.ReadOnly)
            if not self.process.waitForFinished(-1):
                QgsMessageLog.logMessage("Failed to process directory " +
                                         dirName,
                                         tag='Geotag and import photos',
                                         level=QgsMessageLog.WARNING)

            self.updateProgress.emit()

            self.mutex.lock()
            s = self.stopMe
            self.mutex.unlock()
            if s == 1:
                self.interrupted = True
                break

        if not self.interrupted:
            self.processFinished.emit()
        else:
            self.processInterrupted.emit()
    def run(self):
        self.mutex.lock()
        self.stopMe = 0
        self.mutex.unlock()

        self.process = QProcess()
        utils.setProcessEnvironment(self.process)
        self.process.error.connect(self.taggingError)

        rows = self.model.rowCount()

        # get total folder count for progress indicator
        count = 0
        for r in xrange(rows):
            tag = self.model.item(r, 0).text()
            val = self.model.item(r, 1).text()
            item = self.model.item(r, 2)
            if (item and item.text() == "") or (tag == "" or val == ""):
                continue

            count += 1

        self.rangeChanged.emit([self.tr("Tagging: %p%"), count])
        for r in xrange(rows):
            item = self.model.item(r, 0)
            if item is None:
                continue
            if item and item.text() == "":
                continue

            dirName = self.model.item(r, 0).text()
            tagName = self.model.item(r, 1).text()
            tagValue = self.model.item(r, 2).text()

            self.arguments[:] = []

            if self.configFile != "":
                self.arguments.append("-config")
                self.arguments.append(self.configFile)

            self.arguments.append("-%s=%s" % (tagName, tagValue))
            self.arguments.append("-ext")
            self.arguments.append("jpg")
            self.arguments.append("-r")
            self.arguments.append(dirName)

            self.process.start(self.command, self.arguments, QIODevice.ReadOnly)
            if not self.process.waitForFinished(-1):
                print "Failed to process directory", dirName

            self.updateProgress.emit()

            self.mutex.lock()
            s = self.stopMe
            self.mutex.unlock()
            if s == 1:
                self.interrupted = True
                break

        if not self.interrupted:
            self.processFinished.emit()
        else:
            self.processInterrupted.emit()