Exemple #1
0
    def dropEvent(self, e):
        paths = QStringList()
        for url in e.mimeData().urls():
            localFile = url.toLocalFile()
            if (not localFile.isEmpty()):
                paths.append(localFile)

        if (not paths.isEmpty()):
            self.tilesetsDropped.emit(paths)
            e.accept()
Exemple #2
0
    def parse(self, arguments):
        self.mFilesToOpen.clear()
        self.mShowHelp = False
        todo = QStringList(arguments)
        self.mCurrentProgramName = QFileInfo(todo.takeFirst()).fileName()
        index = 0
        noMoreArguments = False
        while (not todo.isEmpty()):
            index += 1
            arg = todo.takeFirst()
            if (arg.isEmpty()):
                continue
            if (noMoreArguments or arg.at(0) != '-'):
                self.mFilesToOpen.append(arg)
                continue

            if (arg.length() == 1):
                # Traditionally a single hyphen means read file from stdin,
                # write file to stdout. This isn't supported right now.
                qWarning(self.tr("Bad argument %d: lonely hyphen" % index))
                self.showHelp()
                return False

            # Long options
            if (arg.at(1) == '-'):
                # Double hypen "--" means no more options will follow
                if (arg.length() == 2):
                    noMoreArguments = True
                    continue

                if (not self.handleLongOption(arg)):
                    qWarning(
                        self.tr("Unknown long argument %d: %s" % (index, arg)))
                    self.mShowHelp = True
                    break

                continue

            # Short options
            for i in range(1, arg.length()):
                c = arg.at(i)
                if (not self.handleShortOption(c)):
                    qWarning(
                        self.tr("Unknown short argument %d.%d: %s" %
                                (index, i, c)))
                    self.mShowHelp = True
                    break

        if (self.mShowHelp):
            self.showHelp()
            return False

        return True
    def parse(self, arguments):
        self.mFilesToOpen.clear()
        self.mShowHelp = False
        todo = QStringList(arguments)
        self.mCurrentProgramName = QFileInfo(todo.takeFirst()).fileName()
        index = 0
        noMoreArguments = False
        while (not todo.isEmpty()):
            index += 1
            arg = todo.takeFirst()
            if (arg.isEmpty()):
                continue
            if (noMoreArguments or arg.at(0) != '-'):
                self.mFilesToOpen.append(arg)
                continue

            if (arg.length() == 1):
                # Traditionally a single hyphen means read file from stdin,
                # write file to stdout. This isn't supported right now.
                qWarning(self.tr("Bad argument %d: lonely hyphen"%index))
                self.showHelp()
                return False

            # Long options
            if (arg.at(1) == '-'):
                # Double hypen "--" means no more options will follow
                if (arg.length() == 2):
                    noMoreArguments = True
                    continue

                if (not self.handleLongOption(arg)):
                    qWarning(self.tr("Unknown long argument %d: %s"%(index, arg)))
                    self.mShowHelp = True
                    break

                continue

            # Short options
            for i in range(1, arg.length()):
                c = arg.at(i)
                if (not self.handleShortOption(c)):
                    qWarning(self.tr("Unknown short argument %d.%d: %s"%(index, i, c)))
                    self.mShowHelp = True
                    break

        if (self.mShowHelp):
            self.showHelp()
            return False

        return True