def addRowToReportData(self, l): if not self.qry_.isValid(): return row = QtXml.QDomElement(self.q_.rptXmlData().createElement("Row")) row.setAttribute("level", l) imgFieldsBack = [] i = 0 for it in self.qFieldList_: rawVal = self.qry_.value(i, True) empty = len(self.qImgFields_) == 0 if not empty and self.qImgFields_.top() == i: strVal = str(rawVal) imgFieldsBack.push_front(self.qImgFields_.pop()) if not strVal or strVal == "": row.setAttribute(it, strVal) continue imgFile = FLDiskCache.AQ_DISKCACHE_DIRPATH + "/" imgFile += strVal + ".png" if not QtCore.QFile.exists(imgFile): pix = QtGui.QPixmap() # pix.loadFromData(str(self.qry_.value(i))) #FIXME? pix.loadFromData(self.qry_.value(i).toCString()) pix.save(imgFile, "PNG") row.setAttribute(it, imgFile) else: row.setAttribute(it, str(rawVal)) i += 1 self.rows_.appendChild(row) self.qImgFields_ = imgFieldsBack
def addRowToReportData(self, l): if not self.qry_.isValid(): return row = QtXml.QDomElement(self.q_.rptXmlData().createElement("Row")) row.setAttribute("level", l) imgFieldsBack = [] i = 0 for it in self.qFieldList_: strVal = str(self.qry_.value(i, False)) if self.qImgFields_ and self.qImgFields_[len(self.qImgFields_) - 1] == i: imgFieldsBack.append(self.qImgFields_.pop()) if strVal in ["", "None"]: row.setAttribute(it, strVal) continue imgFile = filedir("../tempdata") imgFile += "/%s.png" % strVal if not os.path.exists(imgFile): #print("Creando", imgFile) #print(self.qry_.value(i, True)) pix = QtGui.QPixmap(self.qry_.value(i, True)) if not pix.save(imgFile): print("FLReportEngine::No se ha podido guardar", imgFile) row.setAttribute(it, imgFile) else: row.setAttribute(it, strVal) i += 1 self.rows_.appendChild(row) self.qImgFields_ = imgFieldsBack
def setReportData(self, q): if isinstance(q, FLDomNodeInterface): return self.setFLReportData(q.obj()) if not q: return if not self.rd: self.rd = QtXml.QDomDocument("KUGAR_DATA") tmpDoc = QtXml.QDomDocument("KUGAR_DATA") self.d_.rows_ = tmpDoc.createDocumentFragment() self.d_.setQuery(q) q.setForwardOnly(True) if not q.exec_(): return False if not q.next(): return False g = self.d_.qGroupDict_ if not g: while True: self.d_.addRowToReportData(0) if not q.next(): break else: vA = QtCore.QStringListModel().stringList() for i in range(10): vA.append("") while True: self.d_.groupBy(len(g), vA) if not q.next(): break data = QtXml.QDomElement(tmpDoc.createElement("KugarData")) data.appendChild(self.d_.rows_) tmpDoc.appendChild(data) self.rd = tmpDoc self.d_.rows_.clear() self.initData() return True