def createHTMLForPackages(self, packages, checkBox): result = '' template =''' <!-- package start --> <div class="disabled"> ''' if checkBox: template += '''<div class="checkboks" style="%s"><input type="checkbox" checked name="%s"></div>''' template += ''' <div class="package_title_disabled" style="%s"> <img src="%s" style="float:left;" width="%dpx" height="%dpx"> <b>%s</b><br><span style="color:#303030">%s%s<br>%s</span><br> </div></div> <!-- package end --> ''' style = "background-color:%s" % KGlobalSettings.baseColor().name() packages.sort(key=string.lower) for app in packages: package = self.basket.getPackage(app) size = Globals.humanReadableSize(self.basket.getPackageSize(package)) iconPath = getIconPath(package.icon) summary = package.summary iconSize = getIconSize() if checkBox: result += template % (style,app,style,iconPath,iconSize,iconSize,app,i18n("Size: "),size,summary) else: result += template % (style,iconPath,iconSize,iconSize,app,i18n("Size: "),size,summary) return result
def createExtraPackagesList(self): self.parent.basket.update() if self.basket.packages: self.applyButton.setEnabled(True) else: self.applyButton.setEnabled(False) if self.basket.extraPackages: self.extraLabel.show() self.depHBox.show() self.createHTML(self.basket.extraPackages, self.depHtmlPart, False) else: self.extraLabel.hide() self.depHBox.hide() size = Globals.humanReadableSize(self.basket.getBasketSize()) self.totalSizeLabel.setText(i18n("Total Size: <b>%1</b>").arg(size))
def updateStatusBar(self): Globals.setWaitCursor() try: self.basket.update() finally: Globals.setNormalCursor() if not self.basket.packages: text = i18n("Currently your basket is empty.") elif self.state == install_state or self.state == upgrade_state: text = i18n("Currently there are <b>%1</b> selected package(s) of total <b>%2</b> of size ").arg(len(self.basket.packages)).arg(Globals.humanReadableSize(self.basket.packagesSize)) if self.basket.extraPackages: text += i18n("with <b>%3</b> extra dependencies of total <b>%4</b> of size ").arg(len(self.basket.extraPackages)).arg(Globals.humanReadableSize(self.basket.extraPackagesSize)) text += i18n("in your basket.") elif self.state == remove_state: text = i18n("Currently there are <b>%1</b> selected package(s) of total <b>%2</b> of size ").arg(len(self.basket.packages)).arg(Globals.humanReadableSize(self.basket.packagesSize)) if self.basket.extraPackages: text += i18n("with <b>%3</b> reverse dependencies of total <b>%4</b> of size ").arg(len(self.basket.extraPackages)).arg(Globals.humanReadableSize(self.basket.extraPackagesSize)) text += i18n("in your basket.") self.parent.updateStatusBarText(text)
def createListForPackages(self, packages): result = "" template =''' <!-- package start --> <div> <!-- checkbox --> %s <!-- checkbox --> <div class="package_title" style="%s" id="package_t%d" onclick="showHideContent(this)"> <img src="%s" style="float:left;" width="%dpx" height="%dpx"> <b>%s</b><br><span style="color:%s">%s</span><br> </div> <div class="package_info" style="%s" id="package_i%d"> <div style="margin-left:25px;" class="package_info_content" id="package_ic%d"> <p><b>%s</b> %s<br> <b>%s</b>%s<br><b>%s</b>%s<br><b>%s</b>%s<br><b>%s</b><a href=\"%s\">%s</a> </p> </div> </div> </div> <!-- package end --> ''' index = 0 titleStyle = "" style = "" packages.sort(lambda x,y: x.name.lower() > y.name.lower() or (x.name.lower() < y.name.lower() and -1)) alternativeColor = KGlobalSettings.alternateBackgroundColor().name() baseColor = KGlobalSettings.baseColor().name() selectedBaseColor = "#678DB2" summaryColor = "#303030" for app in packages: if index % 2 == 0: style = "background-color:%s" % alternativeColor else: style = "background-color:%s" % baseColor titleStyle = style if app.name in self.selected: titleStyle = "background-color:%s" % selectedBaseColor checkState = "checked" else: checkState = "" curindex = index + 1 if app.name in self.disabled: checkbox = """<div class="checkboks" style="%s" id="checkboks_t%d"><input type="checkbox" \ disabled %s name="%s id="checkboks%d"></div>""" % (titleStyle,curindex,checkState,app.name,curindex) else: checkbox = """<div class="checkboks" style="%s" id="checkboks_t%d"><input type="checkbox" \ %s onclick="changeBackgroundColor(this)" name="%s" id="checkboks%d"></div>""" % (titleStyle,curindex,checkState,app.name,curindex) iconSize = getIconSize() iconPath = getIconPath(app.icon) result += template % (checkbox, titleStyle, curindex, iconPath, iconSize, iconSize, app.name, summaryColor, app.summary, style, curindex, curindex, i18n("Description: "), app.description, i18n("Version: "), app.version, i18n("Repository: "), app.repo, i18n("Package Size: "), Globals.humanReadableSize(app.size), i18n("Homepage: "), app.source.homepage, app.source.homepage) index += 1 return result
def getCurrentDownloadedSize(self): totaldownloaded = Globals.humanReadableSize(self.totalDownloaded + self.curPkgDownloaded, ".2") totalsize = Globals.humanReadableSize(self.totalSize, ".2") return (totaldownloaded, totalsize)