Helpviewer/OfflineStorage/WebDatabasesModel.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3190
a9a94491c4fd
child 3656
441956d8fce5
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
25 25
26 @param parent reference to the parent object (QObject) 26 @param parent reference to the parent object (QObject)
27 """ 27 """
28 super(WebDatabasesModel, self).__init__(parent) 28 super(WebDatabasesModel, self).__init__(parent)
29 self.__headers = [ 29 self.__headers = [
30 self.trUtf8("Name"), 30 self.tr("Name"),
31 self.trUtf8("Size") 31 self.tr("Size")
32 ] 32 ]
33 33
34 self.__data = [] 34 self.__data = []
35 for origin in QWebSecurityOrigin.allOrigins(): 35 for origin in QWebSecurityOrigin.allOrigins():
36 self.__data.append([origin, origin.databases()]) 36 self.__data.append([origin, origin.databases()])
97 if not parent.isValid(): 97 if not parent.isValid():
98 # security origin 98 # security origin
99 origin = self.__data[index.row()][0] 99 origin = self.__data[index.row()][0]
100 if index.column() == 0: 100 if index.column() == 0:
101 if origin.host() == "": 101 if origin.host() == "":
102 return self.trUtf8("Local") 102 return self.tr("Local")
103 elif origin.port() == 0: 103 elif origin.port() == 0:
104 return "{0}://{1}".format( 104 return "{0}://{1}".format(
105 origin.scheme(), 105 origin.scheme(),
106 origin.host(), 106 origin.host(),
107 ) 107 )
115 return self.__dataString(origin.databaseUsage()) 115 return self.__dataString(origin.databaseUsage())
116 else: 116 else:
117 # web database 117 # web database
118 db = self.__data[parent.row()][1][index.row()] 118 db = self.__data[parent.row()][1][index.row()]
119 if index.column() == 0: 119 if index.column() == 0:
120 return self.trUtf8("{0} ({1})").format( 120 return self.tr("{0} ({1})").format(
121 db.displayName(), db.name()) 121 db.displayName(), db.name())
122 elif index.column() == 1: 122 elif index.column() == 1:
123 return self.__dataString(db.size()) 123 return self.__dataString(db.size())
124 124
125 def columnCount(self, parent=QModelIndex()): 125 def columnCount(self, parent=QModelIndex()):
204 @param size size to be formatted (integer) 204 @param size size to be formatted (integer)
205 @return formatted data string (string) 205 @return formatted data string (string)
206 """ 206 """
207 unit = "" 207 unit = ""
208 if size < 1024: 208 if size < 1024:
209 unit = self.trUtf8("bytes") 209 unit = self.tr("bytes")
210 elif size < 1024 * 1024: 210 elif size < 1024 * 1024:
211 size /= 1024 211 size /= 1024
212 unit = self.trUtf8("kB") 212 unit = self.tr("kB")
213 else: 213 else:
214 size /= 1024 * 1024 214 size /= 1024 * 1024
215 unit = self.trUtf8("MB") 215 unit = self.tr("MB")
216 return "{0:.1f} {1}".format(size, unit) 216 return "{0:.1f} {1}".format(size, unit)

eric ide

mercurial