コード例 #1
0
 def itemClicked(self, item, column):
     """Adds the widget to the schema.  If shift is heald and only one widget is selected on the canvas then the new widget is connected to the selected widget."""
     if isinstance(item, WidgetTreeFolder):
         return
     
     if hasattr(self, 'busy'): return
     
     self.busy = 1
     newwidget = redRObjects.addWidget(item.widgetInfo)
     if (self.mouseRightClick or self.shiftPressed):
         if len(redRObjects.activeTab().getSelectedWidgets()) == 1:
             redRObjects.schemaDlg.addLine(redRObjects.activeTab().getSelectedWidgets()[0], redRObjects.getWidgetByIDActiveTabOnly(newwidget))
     delattr(self, 'busy')
コード例 #2
0
    def accept(self):
        # self.settings["widgetSelectedColor"] = self.selectedWidgetIcon.color.getRgb()
        # self.settings["widgetActiveColor"]   = self.activeWidgetIcon.color.getRgb()
        # self.settings["lineColor"]           = self.activeLineIcon.color.getRgb()
        
        # self.settings["exceptionLevel"] = int(self.exceptionLevel.value())
        # self.settings["minSeverity"] = int(self.otherLevel.value())
        
        # self.settings['helpMode'] = (str(self.helpModeSelection.getChecked()) in _('Show Help Icons'))
        self.settings['keepForXDays'] = int(self.numberOfDays.value())
        redREnviron.settings.update(self.settings)
        redREnviron.saveSettings()
        import redRLog
        redRLog.moveLogFile(redREnviron.settings['logFile'])
        # redRStyle.widgetSelectedColor = self.settings["widgetSelectedColor"]
        # redRStyle.widgetActiveColor   = self.settings["widgetActiveColor"]  
        # redRStyle.lineColor           = self.settings["lineColor"]          
        
        # update settings in widgets in current documents
        for widget in self.canvasDlg.schema.widgets():
            widget.instance()._owInfo      = redREnviron.settings["owInfo"]
            widget.instance()._owWarning   = redREnviron.settings["owWarning"]
            widget.instance()._owError     = redREnviron.settings["owError"]
            widget.instance()._owShowStatus= redREnviron.settings["owShow"]
            # widget.instance.updateStatusBarState()
            widget.resetWidgetSize()
            widget.updateWidgetState()
            widget.update()
        # update tooltips for lines in all documents
        for line in self.canvasDlg.schema.lines():
            line.showSignalNames = redREnviron.settings["showSignalNames"]
            line.updateTooltip()

        redRObjects.activeTab().repaint()
        qApp.canvasDlg.update()
        QDialog.accept(self)
コード例 #3
0
def collectIcons():
    global _tempWidgets
    redRLog.log(redRLog.REDRCORE, redRLog.DEBUG, _('Collecting Icons'))
    _tempWidgets = redRObjects.activeTab().getSelectedWidgets()
    redRLog.log(redRLog.REDRCORE, redRLog.DEBUG, _('Selected widgets are %s') % _tempWidgets)
    return _tempWidgets
コード例 #4
0
def collectIcons():
    global _tempWidgets
    redRLog.log(redRLog.REDRCORE, redRLog.DEBUG, _('Collecting Icons'))
    _tempWidgets = redRObjects.activeTab().getSelectedWidgets()
    redRLog.log(redRLog.REDRCORE, redRLog.DEBUG,
                _('Selected widgets are %s') % _tempWidgets)
コード例 #5
0
def makeTemplate(filename=None, copy=False):
    ## this is different from saving.  We want to make a special file that only has the selected widgets, their connections, and settings.  No R data or tabs are saved.
    if copy and len(_tempWidgets) == 0: return
    elif len(_tempWidgets) == 0:
        mb = QMessageBox(
            _("Save Template"),
            _("No widgets are selected.\nTemplates require widgets to be selected before saving as template."
              ), QMessageBox.Information, QMessageBox.Ok | QMessageBox.Default,
            QMessageBox.No | QMessageBox.Escape, QMessageBox.NoButton)

        mb.exec_()
        return
    if not copy:
        if not filename:
            redRLog.log(
                redRLog.REDRCORE, redRLog.ERROR,
                _('orngDoc in makeTemplate; no filename specified, this is highly irregular!! Exiting from template save.'
                  ))
            return
        tempDialog = TemplateDialog()
        if tempDialog.exec_() == QDialog.Rejected:
            return
    else:
        filename = redREnviron.directoryNames['tempDir'] + '/copy.rrts'
    progressBar = startProgressBar(
        _('Saving ') + unicode(os.path.basename(filename)),
        _('Saving ') + unicode(os.path.basename(filename)),
        len(redRObjects.instances(wantType='list')) +
        len(redRObjects.lines().values()) + 3)
    progress = 0
    # create xml document
    (doc, schema, header, widgets, lines, settings, required, tabs,
     saveTagsList, saveDescription) = makeXMLDoc()
    requiredRLibraries = {}

    # save the widgets
    tempWidgets = {}
    if copy:
        for w in _tempWidgets:
            tempWidgets[w.instanceID] = w.instance()
    else:
        for w in redRObjects.activeTab().getSelectedWidgets():
            tempWidgets[w.instanceID] = w.instance()
    (widgets, settingsDict,
     requireRedRLibraries) = saveInstances(tempWidgets, widgets, doc,
                                           progressBar)
    # save the icons and the lines
    sw = redRObjects.activeTab().getSelectedWidgets()
    #redRLog.log(redRLog.REDRCORE, redRLog.ERROR, 'orngDoc makeTemplate; selected widgets: %s' % sw)
    temp = doc.createElement('tab')
    temp.setAttribute('name', 'template')

    ## set all of the widget icons on the tab
    widgetIcons = doc.createElement('widgetIcons')
    for wi in sw:
        saveIcon(widgetIcons, wi, doc)

    # tabLines = doc.createElement('tabLines')
    # for line in redRObjects.getLinesByTab()[redRObjects.activeTabName()]:
    # redRLog.log(redRLog.REDRCORE, redRLog.INFO, 'orngDoc makeTemplate; checking line %s, inWidget %s, outWidget %s' % (line, line.inWidget, line.outWidget))
    # if (line.inWidget not in sw) or (line.outWidget not in sw):
    # continue
    # saveLine(tabLines, line)

    temp.appendChild(
        widgetIcons)  ## append the widgetIcons XML to the global XML
    #temp.appendChild(tabLines)          ## append the tabLines XML to the global XML
    tabs.appendChild(temp)

    ## save the global settings ##
    settingsDict['_globalData'] = cPickle.dumps(globalData.globalData, 2)
    settingsDict['_requiredPackages'] = cPickle.dumps(
        {
            'R': requiredRLibraries.keys(),
            'RedR': requireRedRLibraries
        }, 2)
    #print requireRedRLibraries
    file = open(
        os.path.join(redREnviron.directoryNames['tempDir'], 'settings.pickle'),
        "wt")
    file.write(unicode(settingsDict))
    file.close()

    if not copy:
        taglist = unicode(tempDialog.tagsList.text())
        tempDescription = unicode(tempDialog.descriptionEdit.toPlainText())
        saveTagsList.setAttribute("tagsList", taglist)
        saveDescription.setAttribute("tempDescription", tempDescription)

    xmlText = doc.toprettyxml()
    progress += 1
    progressBar.setValue(progress)

    tempschema = os.path.join(redREnviron.directoryNames['tempDir'],
                              "tempSchema.tmp")
    file = open(tempschema, "wt")
    file.write(xmlText)
    file.close()
    zout = zipfile.ZipFile(filename, "w")
    zout.write(tempschema, "tempSchema.tmp")
    zout.write(
        os.path.join(redREnviron.directoryNames['tempDir'], 'settings.pickle'),
        'settings.pickle')
    zout.close()
    doc.unlink()
    if copy:
        loadTemplate(filename)

    progress += 1
    progressBar.setValue(progress)
    progressBar.close()
    #redRLog.log(redRLog.REDRCORE, redRLog.ERROR, _('Template saved successfully'))
    return True