Beispiel #1
0
 def returnPressed(self):
     text = self.formulaInput.text()
     row = self.table.currentRow()
     col = self.table.currentColumn()
     item = self.table.item(row, col)
     if not item:
         self.table.setItem(row, col, SpreadSheetItem(text))
     else:
         item.setData(QtCore.Qt.EditRole, text)
     self.table.viewport().update()
Beispiel #2
0
 def setupContents(self):
     titleBackground = QtGui.QColor(QtCore.Qt.lightGray)
     titleFont = self.table.font()
     titleFont.setBold(True)
     # column 0
     self.table.setItem(0, 0, SpreadSheetItem("Item"))
     self.table.item(0, 0).setBackground(titleBackground)
     self.table.item(0, 0).setToolTip("This column shows the purchased item/service")
     self.table.item(0, 0).setFont(titleFont)
     self.table.setItem(1, 0, SpreadSheetItem("AirportBus"))
     self.table.setItem(2, 0, SpreadSheetItem("Flight (Munich)"))
     self.table.setItem(3, 0, SpreadSheetItem("Lunch"))
     self.table.setItem(4, 0, SpreadSheetItem("Flight (LA)"))
     self.table.setItem(5, 0, SpreadSheetItem("Taxi"))
     self.table.setItem(6, 0, SpreadSheetItem("Dinner"))
     self.table.setItem(7, 0, SpreadSheetItem("Hotel"))
     self.table.setItem(8, 0, SpreadSheetItem("Flight (Oslo)"))
     self.table.setItem(9, 0, SpreadSheetItem("Total:"))
     self.table.item(9, 0).setFont(titleFont)
     self.table.item(9, 0).setBackground(QtCore.Qt.lightGray)
     # column 1
     self.table.setItem(0, 1, SpreadSheetItem("Date"))
     self.table.item(0, 1).setBackground(titleBackground)
     self.table.item(0, 1).setToolTip("This column shows the purchase date, double click to change")
     self.table.item(0, 1).setFont(titleFont)
     self.table.setItem(1, 1, SpreadSheetItem("15/6/2006"))
     self.table.setItem(2, 1, SpreadSheetItem("15/6/2006"))
     self.table.setItem(3, 1, SpreadSheetItem("15/6/2006"))
     self.table.setItem(4, 1, SpreadSheetItem("21/5/2006"))
     self.table.setItem(5, 1, SpreadSheetItem("16/6/2006"))
     self.table.setItem(6, 1, SpreadSheetItem("16/6/2006"))
     self.table.setItem(7, 1, SpreadSheetItem("16/6/2006"))
     self.table.setItem(8, 1, SpreadSheetItem("18/6/2006"))
     self.table.setItem(9, 1, SpreadSheetItem())
     self.table.item(9, 1).setBackground(QtCore.Qt.lightGray)
     # column 2
     self.table.setItem(0, 2, SpreadSheetItem("Price"))
     self.table.item(0, 2).setBackground(titleBackground)
     self.table.item(0, 2).setToolTip("This column shows the price of the purchase")
     self.table.item(0, 2).setFont(titleFont)
     self.table.setItem(1, 2, SpreadSheetItem("150"))
     self.table.setItem(2, 2, SpreadSheetItem("2350"))
     self.table.setItem(3, 2, SpreadSheetItem("-14"))
     self.table.setItem(4, 2, SpreadSheetItem("980"))
     self.table.setItem(5, 2, SpreadSheetItem("5"))
     self.table.setItem(6, 2, SpreadSheetItem("120"))
     self.table.setItem(7, 2, SpreadSheetItem("300"))
     self.table.setItem(8, 2, SpreadSheetItem("1240"))
     self.table.setItem(9, 2, SpreadSheetItem())
     self.table.item(9, 2).setBackground(QtCore.Qt.lightGray)
     # column 3
     self.table.setItem(0, 3, SpreadSheetItem("Currency"))
     self.table.item(0, 3).setBackgroundColor(titleBackground)
     self.table.item(0, 3).setToolTip("This column shows the currency")
     self.table.item(0, 3).setFont(titleFont)
     self.table.setItem(1, 3, SpreadSheetItem("NOK"))
     self.table.setItem(2, 3, SpreadSheetItem("NOK"))
     self.table.setItem(3, 3, SpreadSheetItem("EUR"))
     self.table.setItem(4, 3, SpreadSheetItem("EUR"))
     self.table.setItem(5, 3, SpreadSheetItem("USD"))
     self.table.setItem(6, 3, SpreadSheetItem("USD"))
     self.table.setItem(7, 3, SpreadSheetItem("USD"))
     self.table.setItem(8, 3, SpreadSheetItem("USD"))
     self.table.setItem(9, 3, SpreadSheetItem())
     self.table.item(9,3).setBackground(QtCore.Qt.lightGray)
     # column 4
     self.table.setItem(0, 4, SpreadSheetItem("Ex. Rate"))
     self.table.item(0, 4).setBackground(titleBackground)
     self.table.item(0, 4).setToolTip("This column shows the exchange rate to NOK")
     self.table.item(0, 4).setFont(titleFont)
     self.table.setItem(1, 4, SpreadSheetItem("1"))
     self.table.setItem(2, 4, SpreadSheetItem("1"))
     self.table.setItem(3, 4, SpreadSheetItem("8"))
     self.table.setItem(4, 4, SpreadSheetItem("8"))
     self.table.setItem(5, 4, SpreadSheetItem("7"))
     self.table.setItem(6, 4, SpreadSheetItem("7"))
     self.table.setItem(7, 4, SpreadSheetItem("7"))
     self.table.setItem(8, 4, SpreadSheetItem("7"))
     self.table.setItem(9, 4, SpreadSheetItem())
     self.table.item(9,4).setBackground(QtCore.Qt.lightGray)
     # column 5
     self.table.setItem(0, 5, SpreadSheetItem("NOK"))
     self.table.item(0, 5).setBackground(titleBackground)
     self.table.item(0, 5).setToolTip("This column shows the expenses in NOK")
     self.table.item(0, 5).setFont(titleFont)
     self.table.setItem(1, 5, SpreadSheetItem("* C2 E2"))
     self.table.setItem(2, 5, SpreadSheetItem("* C3 E3"))
     self.table.setItem(3, 5, SpreadSheetItem("* C4 E4"))
     self.table.setItem(4, 5, SpreadSheetItem("* C5 E5"))
     self.table.setItem(5, 5, SpreadSheetItem("* C6 E6"))
     self.table.setItem(6, 5, SpreadSheetItem("* C7 E7"))
     self.table.setItem(7, 5, SpreadSheetItem("* C8 E8"))
     self.table.setItem(8, 5, SpreadSheetItem("* C9 E9"))
     self.table.setItem(9, 5, SpreadSheetItem("sum F2 F9"))
     self.table.item(9,5).setBackground(QtCore.Qt.lightGray)