Exemplo n.º 1
0
 def _standingsUpdate(self, standings):
     for pilot, newpos in standings:
         for oldpos, oldpilot in self.__positions.iteritems():
             if oldpilot == pilot:
                 if newpos > oldpos:
                     PilotInfo.get(pilot).setIcon(self.__arrowDown)
                 elif newpos < oldpos:
                     PilotInfo.get(pilot).setIcon(self.__arrowUp)
                 break
     for pilot, newpos in standings:
         self.__positions[newpos] = pilot
     self.reset()
Exemplo n.º 2
0
 def data(self, index, role):
     if role == Qt.DisplayRole:
         try:
             i = self.__positions[index.row() + 1]
             if index.column() == 0:
                 return QVariant(i)
             elif index.column() == 1:
                 return QVariant(PilotInfo.get(i).name())
             elif index.column() == 2:
                 return QVariant(PilotInfo.get(i).state())
         except KeyError:
             pass
     elif role == Qt.TextAlignmentRole:
         if index.column() == 0 or index.column() == 2:
             return QVariant(Qt.AlignCenter)
     return QVariant()
Exemplo n.º 3
0
 def data(self, index, role):
     if role == Qt.DisplayRole:
         try:
             t = self.__data[self.__lap][self.__intermediate][index.row()]
             if index.column() == 0:
                 return QVariant(PilotInfo.get(t[0]).name())
             elif index.column() == 1:
                 return QVariant(PilotInfo.get(t[0]).teamName())
             elif index.column() == 2:
                 if index.row() == 0:
                     return QVariant("%s (%s)" % (secondsToString(t[1]),
                                                  secondsToString(t[2])))
                 else:
                     return QVariant("+ " + secondsToString(t[1]))
         except KeyError:
             pass
     elif role == Qt.TextAlignmentRole:
         if index.column() == 2:
             return QVariant(Qt.AlignRight | Qt.AlignVCenter)
     return QVariant()
Exemplo n.º 4
0
 def __init__(self):
     QMainWindow.__init__(self)
     self.setupUi(self)
     self.positionsDock = PositionsDock(self)
     self.telemetryDock = TelemetryDock(self)
     self.addDockWidget(Qt.RightDockWidgetArea, self.positionsDock)
     self.addDockWidget(Qt.RightDockWidgetArea, self.telemetryDock)
     self.__playIcon = QIcon(":/icons/play.png")
     self.__pauseIcon = QIcon(":/icons/pause.png")
     self.__lapTimeRecord = None
     self.__speedRecord = None
     PilotInfo.init(self.reloadPilotInfo)
     handlers = {('init', 'best_lap'): self._newBestLap,
                 ('init', 'speed_record'): self._newBestSpeed,
                 ('init', 'race_state'): self._setRaceState,
                 ('init', 'speedup'): self._setSpeedup}
     SubscriberApplication.registerMsgHandlers(handlers)
     SubscriberApplication.instance().subscribed.connect(self.statusBar().clearMessage)
     SubscriberApplication.instance().subscriptionError.connect(self._subscriptionError)
     SubscriberApplication.instance().subscribe()
Exemplo n.º 5
0
Arquivo: Car.py Projeto: Pesa/forse
 def refreshState(self):
     p = PilotInfo.get(self._id)
     if p.state() != self._state:
         self._state = p.state()
         self._outside = self._state == "ended" or self._state == "retired"
         self._pen = QPen(self.colorMap[self._state], self.carSize, Qt.SolidLine, Qt.RoundCap)
         self._translateToNewPos()
         self.update()
     tooltip = "Car %i\n" % self._id
     tooltip += "%s - %s\n" % (p.name(), p.teamName())
     tooltip += "State: %s" % self._state
     if self._state == "retired":
         tooltip += "\nReason for retirement: %s" % p.retireReason()
     self.setToolTip(tooltip)
Exemplo n.º 6
0
 def headerData(self, section, orientation, role):
     if role == Qt.DisplayRole:
         if orientation == Qt.Horizontal:
             if section == 0:
                 return QVariant("ID")
             elif section == 1:
                 return QVariant("Pilot")
             elif section == 2:
                 return QVariant("State")
         else:
             return QVariant(section + 1)
     elif role == Qt.DecorationRole:
         if orientation == Qt.Vertical:
             try:
                 return QVariant(PilotInfo.get(self.__positions[section + 1]).icon())
             except KeyError:
                 pass
     elif role == Qt.TextAlignmentRole:
         if orientation == Qt.Vertical:
             return QVariant(Qt.AlignCenter)
     return QVariant()
Exemplo n.º 7
0
 def _updateBestSpeedLabel(self, car, intermediate, lap, speed):
     s = "%s (%s in intermediate %i of lap %i)" % (mpsToString(speed),
                                                   PilotInfo.get(car).name(),
                                                   intermediate,
                                                   lap)
     self.bestSpeedLabel.setText(s)
Exemplo n.º 8
0
 def _updateBestLapLabel(self, car, lap, time):
     self.bestLapLabel.setText("%s (%s in lap %i)" % (secondsToString(time),
                                                      PilotInfo.get(car).name(),
                                                      lap))