Ejemplo n.º 1
0
    def setupModelData(self, bookmarks, parent):
        parents = [parent]

        for bookmark in bookmarks:

            if bookmark['childs'] and len(bookmark['childs']) >= 1:
                distance = None
                if self.currentSystem and self.currentSystem[
                        'posX'] and bookmark['childs'][0]['posX']:
                    distance = calcDistance(self.currentSystem["posX"],
                                            self.currentSystem["posY"],
                                            self.currentSystem["posZ"],
                                            bookmark['childs'][0]["posX"],
                                            bookmark['childs'][0]["posY"],
                                            bookmark['childs'][0]["posZ"])

            system = None
            if bookmark['Type'] == 1:
                system = bookmark['childs'][0]['System']

            data = [
                bookmark['id'], bookmark['Name'], system, distance, "", "", ""
            ]

            parents[-1].appendChild(BookmarkTreeItem(data, parents[-1]))

            if bookmark['Type'] != 1:

                # follow is a child
                parents.append(parents[-1].child(parents[-1].childCount() - 1))

                for i, child in enumerate(bookmark['childs']):
                    distance = None
                    if i + 1 < len(bookmark['childs']):
                        if bookmark['childs'][i + 1] and child['posX']:
                            distance = calcDistance(
                                bookmark['childs'][i + 1]["posX"],
                                bookmark['childs'][i + 1]["posY"],
                                bookmark['childs'][i + 1]["posZ"],
                                child["posX"], child["posY"], child["posZ"])
                    else:  # back hop
                        if bookmark['childs'][0] and child['posX']:
                            distance = calcDistance(
                                bookmark['childs'][0]["posX"],
                                bookmark['childs'][0]["posY"],
                                bookmark['childs'][0]["posZ"], child["posX"],
                                child["posY"], child["posZ"])

                    data = [
                        "", "", child['System'], distance, child['Station'],
                        child['name'], ""
                    ]

                    parents[-1].appendChild(
                        BookmarkChildTreeItem(data, parents[-1]))

                parents.pop()
Ejemplo n.º 2
0
    def setupModelData(self, bookmarks, parent):
        parents = [parent]

        for bookmark in bookmarks:

            if bookmark['childs'] and len(bookmark['childs']) >= 1:
                distance = None
                if self.currentSystem and self.currentSystem['posX'] and bookmark['childs'][0]['posX']:
                    distance = calcDistance(self.currentSystem["posX"], self.currentSystem["posY"], self.currentSystem["posZ"], bookmark['childs'][0]["posX"], bookmark['childs'][0]["posY"], bookmark['childs'][0]["posZ"])

            system = None
            if bookmark['Type'] == 1:
                system = bookmark['childs'][0]['System']

            data = [bookmark['id'], bookmark['Name'], system, distance, "", "", ""]

            parents[-1].appendChild(BookmarkTreeItem(data, parents[-1]))

            if bookmark['Type'] != 1:
            
                # follow is a child
                parents.append(parents[-1].child(parents[-1].childCount() - 1))
    
                for i, child in enumerate(bookmark['childs']):
                    distance = None
                    if i + 1 < len(bookmark['childs']):
                        if bookmark['childs'][i + 1] and child['posX']:
                            distance = calcDistance(bookmark['childs'][i + 1]["posX"], bookmark['childs'][i + 1]["posY"], bookmark['childs'][i + 1]["posZ"], child["posX"], child["posY"], child["posZ"])
                    else:  # back hop
                        if bookmark['childs'][0] and child['posX']:
                            distance = calcDistance(bookmark['childs'][0]["posX"], bookmark['childs'][0]["posY"], bookmark['childs'][0]["posZ"], child["posX"], child["posY"], child["posZ"])

                    data = ["", "", child['System'], distance, child['Station'], child['name'], ""]
    
                    parents[-1].appendChild(BookmarkChildTreeItem(data, parents[-1]))
    
                parents.pop()
Ejemplo n.º 3
0
    def showLog(self):

        firstrun = False
        if not self.listView.header().count():
            firstrun = True

        self.headerList = ["Id", "System", "Distance", "Date", "Comment", ""]

        model = QtGui.QStandardItemModel(0, len(self.headerList), self)
        for x, column in enumerate(self.headerList):
            model.setHeaderData(x, QtCore.Qt.Horizontal, column)

        lastLog = self.main.flyLogger.getLastLog()
        if not lastLog:
            return

        lastSystem = None

        utcDelta = datetime.now() - datetime.utcnow()

        for entry in lastLog:
            model.insertRow(0)
            model.setData(model.index(0, self.headerList.index("Id")),
                          entry["id"])
            model.item(0, self.headerList.index("Id")).setTextAlignment(
                QtCore.Qt.AlignRight)
            model.item(0, self.headerList.index("Id")).setEditable(False)

            if entry["System"]:
                model.setData(model.index(0, self.headerList.index("System")),
                              entry["System"])
            else:
                model.setData(model.index(0, self.headerList.index("System")),
                              entry["optionalSystemName"])
                model.item(0, self.headerList.index("System")).setBackground(
                    QtGui.QColor(255, 0, 0, 128))

            model.item(0, self.headerList.index("System")).setEditable(False)

            if entry["System"]:
                if lastSystem:
                    distance = calcDistance(lastSystem["posX"],
                                            lastSystem["posY"],
                                            lastSystem["posZ"], entry["posX"],
                                            entry["posY"], entry["posZ"])
                    model.setData(
                        model.index(0, self.headerList.index("Distance")),
                        distance)
                    model.item(
                        0, self.headerList.index("Distance")).setTextAlignment(
                            QtCore.Qt.AlignRight)
                    model.item(
                        0,
                        self.headerList.index("Distance")).setEditable(False)

                lastSystem = entry
            else:
                lastSystem = None

            model.setData(model.index(0, self.headerList.index("Date")),
                          QtCore.QDateTime(entry["DateTime"] + utcDelta))
            model.item(0, self.headerList.index("Date")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Comment")),
                          entry["Comment"])
            model.item(0, self.headerList.index("Comment")).setEditable(True)

        model.itemChanged.connect(self.saveItemEdit)

        self.proxyModel.setSourceModel(model)
        self.proxyModel.setFilterKeyColumn(self.headerList.index("System"))

        if firstrun:
            self.listView.sortByColumn(self.headerList.index("Id"),
                                       QtCore.Qt.SortOrder.DescendingOrder)

        for i in range(0, len(self.headerList)):
            self.listView.resizeColumnToContents(i)
Ejemplo n.º 4
0
    def showRares(self):

        firstrun = False
        if not self.listView.header().count():
            firstrun = True

        self.headerList = ["Id", "Name", "System", "Permit", "StarDist", "Station", "Distance", "Price", "Max Ava.", "Comment" ""]

        model = QtGui.QStandardItemModel(0, len(self.headerList), self)
        for x, column in enumerate(self.headerList):
            model.setHeaderData(x, QtCore.Qt.Horizontal, column)

        
        location = self.locationlineEdit.text()
        systemID = self.mydb.getSystemIDbyName(location)
        currentSystem = None
        if systemID:
            currentSystem = self.mydb.getSystemData(systemID)

        rareslist = self.rares.getRaresList()

        for rares in rareslist:
            model.insertRow(0)
            model.setData(model.index(0, self.headerList.index("Id")), rares["id"])
            model.item(0, self.headerList.index("Id")).setTextAlignment(QtCore.Qt.AlignRight)
            model.item(0, self.headerList.index("Id")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Name")), rares["Name"])
            model.item(0, self.headerList.index("Name")).setEditable(True)

            
            model.setData(model.index(0, self.headerList.index("System")), rares["System"])
            model.item(0, self.headerList.index("System")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Permit")), "No" if not rares["permit"] else "Yes")
            model.item(0, self.headerList.index("Permit")).setTextAlignment(QtCore.Qt.AlignCenter)
            model.item(0, self.headerList.index("Permit")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("StarDist")), rares["StarDist"])
            model.item(0, self.headerList.index("StarDist")).setTextAlignment(QtCore.Qt.AlignRight)
            model.item(0, self.headerList.index("StarDist")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Station")), rares["Station"])
            model.item(0, self.headerList.index("Station")).setEditable(False)

            if currentSystem and currentSystem["posX"] and rares["posX"]:
                distance = calcDistance(currentSystem["posX"], currentSystem["posY"], currentSystem["posZ"], rares["posX"], rares["posY"], rares["posZ"])
                model.setData(model.index(0, self.headerList.index("Distance")), distance)
                model.item(0, self.headerList.index("Distance")).setTextAlignment(QtCore.Qt.AlignRight)
                model.item(0, self.headerList.index("Distance")).setEditable(False)

            
            model.setData(model.index(0, self.headerList.index("Price")), rares["Price"])
            model.item(0, self.headerList.index("Price")).setTextAlignment(QtCore.Qt.AlignRight)

            model.setData(model.index(0, self.headerList.index("Max Ava.")), rares["MaxAvail"])
            model.item(0, self.headerList.index("Max Ava.")).setTextAlignment(QtCore.Qt.AlignRight)

            model.setData(model.index(0, self.headerList.index("Comment")), rares["comment"])
            model.item(0, self.headerList.index("Comment")).setEditable(True)

        model.itemChanged.connect(self.saveItemEdit)

        self.listView.setModel(model)

        if firstrun:
            self.listView.sortByColumn(self.headerList.index("Distance"), PySide.QtCore.Qt.SortOrder.AscendingOrder)

        for i in range(0, len(self.headerList)):
            self.listView.resizeColumnToContents(i)
Ejemplo n.º 5
0
    def showRares(self):

        firstrun = False
        if not self.listView.header().count():
            firstrun = True

        self.headerList = [
            "Id", "Name", "System", "Permit", "StarDist", "Station",
            "Distance", "Price", "Max Ava.", "Comment"
            ""
        ]

        model = QtGui.QStandardItemModel(0, len(self.headerList), self)
        for x, column in enumerate(self.headerList):
            model.setHeaderData(x, QtCore.Qt.Horizontal, column)

        location = self.locationlineEdit.text()
        systemID = self.mydb.getSystemIDbyName(location)
        currentSystem = None
        if systemID:
            currentSystem = self.mydb.getSystemData(systemID)

        rareslist = self.rares.getRaresList()

        for rares in rareslist:
            model.insertRow(0)
            model.setData(model.index(0, self.headerList.index("Id")),
                          rares["id"])
            model.item(0, self.headerList.index("Id")).setTextAlignment(
                QtCore.Qt.AlignRight)
            model.item(0, self.headerList.index("Id")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Name")),
                          rares["Name"])
            model.item(0, self.headerList.index("Name")).setEditable(True)

            model.setData(model.index(0, self.headerList.index("System")),
                          rares["System"])
            model.item(0, self.headerList.index("System")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Permit")),
                          "No" if not rares["permit"] else "Yes")
            model.item(0, self.headerList.index("Permit")).setTextAlignment(
                QtCore.Qt.AlignCenter)
            model.item(0, self.headerList.index("Permit")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("StarDist")),
                          rares["StarDist"])
            model.item(0, self.headerList.index("StarDist")).setTextAlignment(
                QtCore.Qt.AlignRight)
            model.item(0, self.headerList.index("StarDist")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Station")),
                          rares["Station"])
            model.item(0, self.headerList.index("Station")).setEditable(False)

            if currentSystem and currentSystem["posX"] and rares["posX"]:
                distance = calcDistance(currentSystem["posX"],
                                        currentSystem["posY"],
                                        currentSystem["posZ"], rares["posX"],
                                        rares["posY"], rares["posZ"])
                model.setData(
                    model.index(0, self.headerList.index("Distance")),
                    distance)
                model.item(0,
                           self.headerList.index("Distance")).setTextAlignment(
                               QtCore.Qt.AlignRight)
                model.item(
                    0, self.headerList.index("Distance")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Price")),
                          rares["Price"])
            model.item(0, self.headerList.index("Price")).setTextAlignment(
                QtCore.Qt.AlignRight)

            model.setData(model.index(0, self.headerList.index("Max Ava.")),
                          rares["MaxAvail"])
            model.item(0, self.headerList.index("Max Ava.")).setTextAlignment(
                QtCore.Qt.AlignRight)

            model.setData(model.index(0, self.headerList.index("Comment")),
                          rares["comment"])
            model.item(0, self.headerList.index("Comment")).setEditable(True)

        model.itemChanged.connect(self.saveItemEdit)

        self.listView.setModel(model)

        if firstrun:
            self.listView.sortByColumn(
                self.headerList.index("Distance"),
                PySide.QtCore.Qt.SortOrder.AscendingOrder)

        for i in range(0, len(self.headerList)):
            self.listView.resizeColumnToContents(i)
Ejemplo n.º 6
0
    def showLog(self):

        firstrun = False
        if not self.listView.header().count():
            firstrun = True

        self.headerList = ["Id", "System", "Distance", "Date", "Comment", ""]

        model = QtGui.QStandardItemModel(0, len(self.headerList), self)
        for x, column in enumerate(self.headerList):
            model.setHeaderData(x, QtCore.Qt.Horizontal, column)


        lastLog = self.main.flyLogger.getLastLog()
        if not lastLog:
            return

        lastSystem = None

        utcDelta = datetime.now() - datetime.utcnow()

        for entry in lastLog:
            model.insertRow(0)
            model.setData(model.index(0, self.headerList.index("Id")), entry["id"])
            model.item(0, self.headerList.index("Id")).setTextAlignment(QtCore.Qt.AlignRight)
            model.item(0, self.headerList.index("Id")).setEditable(False)

            if entry["System"]:
                model.setData(model.index(0, self.headerList.index("System")), entry["System"])
            else:
                model.setData(model.index(0, self.headerList.index("System")), entry["optionalSystemName"])
                model.item(0, self.headerList.index("System")).setBackground(QtGui.QColor(255, 0, 0, 128))

            model.item(0, self.headerList.index("System")).setEditable(False)

            if entry["System"]:
                if lastSystem:
                    distance = calcDistance(lastSystem["posX"], lastSystem["posY"], lastSystem["posZ"], entry["posX"], entry["posY"], entry["posZ"])
                    model.setData(model.index(0, self.headerList.index("Distance")), distance)
                    model.item(0, self.headerList.index("Distance")).setTextAlignment(QtCore.Qt.AlignRight)
                    model.item(0, self.headerList.index("Distance")).setEditable(False)

                lastSystem = entry
            else:
                lastSystem = None

            model.setData(model.index(0, self.headerList.index("Date")), QtCore.QDateTime(entry["DateTime"] + utcDelta))
            model.item(0, self.headerList.index("Date")).setEditable(False)

            model.setData(model.index(0, self.headerList.index("Comment")), entry["Comment"])
            model.item(0, self.headerList.index("Comment")).setEditable(True)

        model.itemChanged.connect(self.saveItemEdit)

        self.proxyModel.setSourceModel(model)
        self.proxyModel.setFilterKeyColumn(self.headerList.index("System"))

        if firstrun:
            self.listView.sortByColumn(self.headerList.index("Id"), QtCore.Qt.SortOrder.DescendingOrder)

        for i in range(0, len(self.headerList)):
            self.listView.resizeColumnToContents(i)