def testFormatInt(): assert formatInt(1000) == "1000" assert formatInt(1234) == "1.23\u2009k" assert formatInt(12345) == "12.3\u2009k" assert formatInt(123456) == "123\u2009k" assert formatInt(1234567) == "1.23\u2009M" assert formatInt(12345678) == "12.3\u2009M" assert formatInt(123456789) == "123\u2009M" assert formatInt(1234567890) == "1.23\u2009G"
def testBaseCommon_FormatInt(): """Test the formatInt function. """ assert formatInt(1000) == "1000" assert formatInt(1234) == "1.23\u2009k" assert formatInt(12345) == "12.3\u2009k" assert formatInt(123456) == "123\u2009k" assert formatInt(1234567) == "1.23\u2009M" assert formatInt(12345678) == "12.3\u2009M" assert formatInt(123456789) == "123\u2009M" assert formatInt(1234567890) == "1.23\u2009G"
def _populateList(self): """Populate the list box with recent project data. """ listOrder = [] listData = {} for projPath in self.mainConf.recentProj.keys(): theEntry = self.mainConf.recentProj[projPath] theTitle = "" theTime = 0 theWords = 0 if "title" in theEntry.keys(): theTitle = theEntry["title"] if "time" in theEntry.keys(): theTime = theEntry["time"] if "words" in theEntry.keys(): theWords = theEntry["words"] if theTime > 0: listOrder.append(theTime) listData[theTime] = [theTitle, theWords, projPath] self.listBox.clear() hasSelection = False for timeStamp in sorted(listOrder, reverse=True): newItem = QTreeWidgetItem([""] * 4) newItem.setIcon(self.C_NAME, self.theParent.theTheme.getIcon("proj_nwx")) newItem.setText(self.C_NAME, listData[timeStamp][0]) newItem.setData(self.C_NAME, Qt.UserRole, listData[timeStamp][2]) newItem.setText(self.C_COUNT, formatInt(listData[timeStamp][1])) newItem.setText( self.C_TIME, datetime.fromtimestamp(timeStamp).strftime("%x %X")) newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter) newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter) newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter) newItem.setFont(self.C_TIME, self.theTheme.guiFontFixed) self.listBox.addTopLevelItem(newItem) if not hasSelection: newItem.setSelected(True) hasSelection = True projColWidth = self.mainConf.getProjColWidths() if len(projColWidth) == 3: self.listBox.setColumnWidth(self.C_NAME, projColWidth[self.C_NAME]) self.listBox.setColumnWidth(self.C_COUNT, projColWidth[self.C_COUNT]) self.listBox.setColumnWidth(self.C_TIME, projColWidth[self.C_TIME]) return
def _populateList(self): """Populate the list box with recent project data. """ dataList = [] for projPath in self.mainConf.recentProj: theEntry = self.mainConf.recentProj[projPath] theTitle = theEntry.get("title", "") theTime = theEntry.get("time", 0) theWords = theEntry.get("words", 0) dataList.append([theTitle, theTime, theWords, projPath]) self.listBox.clear() sortList = sorted(dataList, key=lambda x: x[1], reverse=True) for theTitle, theTime, theWords, projPath in sortList: newItem = QTreeWidgetItem([""] * 4) newItem.setIcon(self.C_NAME, self.theParent.theTheme.getIcon("proj_nwx")) newItem.setText(self.C_NAME, theTitle) newItem.setData(self.C_NAME, Qt.UserRole, projPath) newItem.setText(self.C_COUNT, formatInt(theWords)) newItem.setText(self.C_TIME, datetime.fromtimestamp(theTime).strftime("%x %X")) newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter) newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter) newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter) newItem.setFont(self.C_TIME, self.theTheme.guiFontFixed) self.listBox.addTopLevelItem(newItem) if self.listBox.topLevelItemCount() > 0: self.listBox.topLevelItem(0).setSelected(True) projColWidth = self.mainConf.getProjColWidths() if len(projColWidth) == 3: self.listBox.setColumnWidth(self.C_NAME, projColWidth[self.C_NAME]) self.listBox.setColumnWidth(self.C_COUNT, projColWidth[self.C_COUNT]) self.listBox.setColumnWidth(self.C_TIME, projColWidth[self.C_TIME]) return