예제 #1
0
 def saveReportSettings(self,file):
     #Helper for saving user report settings to file
     self.showhideProgressDialog(QApplication.translate("ReportBuilder","Saving Report Settings..."))
     
     #Create report config object
     rptConfig = STDMReportConfig(self.tabName)
     #Loop through all report elements' settings
     for i in range(self.stackedWidget.count()):
         w = self.stackedWidget.widget(i)
         
         #Get report element 
         rptEl = w.getSettings()
         
         #Group dialog settings are not added directly to the collection but through the DBField proxy
         if not rptEl.parent == "Groups":               
             #Check if it is a definition for database fields
             if rptEl.parent == "Fields":
                 df = DbField()   
                                
                 #copy attributes from ReportElement base to DbField object
                 copyattrs(rptEl,df,["dialogSettings","parent","name"])   
                                                              
                 #Set field configuration
                 fc = FieldConfig()
                 fc.sortInfo = self.sorting_getFieldConfig(rptEl.name)
                 
                 #Set grouping information
                 gi = self.grouping_getFieldConfig(rptEl.name)
                 if not gi == None:
                     gpDialog = self.__displayGetStWidget("gp_" + rptEl.name)
                     if gpDialog != None:                          
                         gi.dialogSettings = gpDialog.getSettings().dialogSettings
                         fc.groupingInfo = gi
                         
                 #Get field index
                 fc.reportOrder = self.rptFields.index(rptEl.name)
                 df.uiConfiguration = fc              
                 rptEl = df
             rptConfig.addElement(rptEl)   
                    
     rptConfig.setFilter(str(self.txtSqlParser.toPlainText()))
     rptConfig.setVersion(1.1)
     
     #Serialize to file 
     rptSerializer = ReportSerializer(file) 
     rptSerializer.serialize(rptConfig)
     self.showhideProgressDialog("",False)