Пример #1
0
    def __init__(self, debug=False):
        QMainWindow.__init__(self)
        # initialise filename
        self.filename = None
        # make the data store
        from xmlstore import Store
        self.store = Store(debug=debug)
        # view the current table
        self.tableView = TableView(self)
        #self.tableView.setDragEnabled(True);
        #self.tableView.setDragDropMode(QAbstractItemView.InternalMove)
        #self.tableView.setAcceptDrops(True);
        #self.tableView.setDropIndicatorShown(True);
        self.tableView.verticalHeader().sectionMoved.connect(self.sectionMoved)
        self.tableView.verticalHeader().setMovable(True)

        self.setCentralWidget(self.tableView)
        # add a custom delegate to it
        self.delegate = ComboBoxDelegate()
        self.tableView.setItemDelegate(self.delegate)
        # dock the table selection on the left
        self.dock1 = QDockWidget(self)
        self.listView = ListView(self)
        self.listView.setDragEnabled(True)
        self.listView.setDragDropMode(QAbstractItemView.InternalMove)
        self.listView.setDropIndicatorShown(True)
        self.dock1.setWidget(self.listView)
        self.dock1.setFeatures(QDockWidget.DockWidgetFloatable
                               | QDockWidget.DockWidgetMovable)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dock1)
        # connect it to the populate method
        self.connect(self.listView,
                     SIGNAL('activated ( const QModelIndex & )'),
                     self.populate)
        self.connect(self.listView, SIGNAL('clicked ( const QModelIndex & )'),
                     self.populate)
        # dock the undoView on the left
        self.dock2 = QDockWidget(self)
        self.undoView = QUndoView(self.store.stack)
        self.dock2.setWidget(self.undoView)
        self.dock2.setFeatures(QDockWidget.DockWidgetFloatable
                               | QDockWidget.DockWidgetMovable)
        self.dock2.setWindowTitle('Undo Stack')
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dock2)
        # create a menubar
        self.menu = self.menuBar()
        # create file menu headings
        self.menuFile = self.menu.addMenu('File')
        self.menuFile.addAction('New', self.New).setShortcut('CTRL+N')
        self.menuFile.addAction('Open...', self.Open).setShortcut('CTRL+O')
        self.menuFile.addAction('Reload', self.Reload)
        self.menuFile.addAction('Save', self.Save).setShortcut('CTRL+S')
        self.menuFile.addAction('Save As...', self.SaveAs)
        self.menuFile.addSeparator()
        self.menuFile.addAction('Set Architecture...', self.setArch)
        self.menuFile.addSeparator()
        self.menuFile.addAction('Quit', self.closeEvent).setShortcuts(
            ['CTRL+Q', 'ALT+F4'])
        # create edit menu headings
        self.menuEdit = self.menu.addMenu('Edit')
        self.menuEdit.addAction('Insert Row',
                                self.tableView.insertRow).setShortcut('CTRL+I')
        self.menuEdit.addAction(
            'Insert Row Under',
            self.tableView.insertRowUnder).setShortcut('CTRL+U')
        self.menuEdit.addAction('Remove Row', self.tableView.removeRow)
        self.menuEdit.addSeparator()
        self.menuEdit.addAction('Cut',
                                self.tableView.cut).setShortcut('CTRL+X')
        self.menuEdit.addAction('Copy', self.tableView.copy).setShortcuts(
            ['CTRL+C', 'CTRL+INS'])
        self.menuEdit.addAction('Paste', self.tableView.paste).setShortcuts(
            ['CTRL+V', 'SHIFT+INS'])
        self.menuEdit.addAction('Clear',
                                self.tableView.menuClear).setShortcut('CTRL+D')
        self.menuEdit.addSeparator()
        self.menuEdit.addAction('Fill Cells',
                                self.tableView.fillCells).setShortcut('CTRL+L')
        self.menuEdit.addAction(
            'Fill Cells and Increment',
            self.tableView.fillCellsInc).setShortcut('CTRL+R')
        self.menuEdit.addAction(
            'Python Code...', self.tableView.pythonCode).setShortcut('CTRL+P')
        self.tableView.codeBox = pythonCode()
        self.menuEdit.addSeparator()
        self.menuEdit.addAction('Undo', self.store.stack,
                                SLOT('undo()')).setShortcut('CTRL+Z')
        self.menuEdit.addAction('Redo', self.store.stack,
                                SLOT('redo()')).setShortcut('CTRL+SHIFT+Z')
        # create component menu
        self.menuComponents = self.menu.addMenu('Components')
        self.resize(QSize(1000, 500))
Пример #2
0
def main():
    parser = OptionParser('usage: %prog [options] <xml-file>')
    parser.add_option('-d',
                      action='store_true',
                      dest='debug',
                      help='Print lots of debug information')
    parser.add_option('-D',
                      action='store_true',
                      dest='DbOnly',
                      help='Only output files destined for the Db dir')
    parser.add_option('-o',
                      dest='out',
                      default=os.path.join('..', '..', 'iocs'),
                      help='Output directory for ioc')
    parser.add_option(
        '--doc',
        dest='doc',
        help='Write out information in format for doxygen build instructions')
    parser.add_option(
        '--sim',
        dest='simarch',
        help='Create an ioc with arch=SIMARCH in simulation mode')
    parser.add_option(
        '-e',
        action='store_true',
        dest='edm_screen',
        help='Try to create a set of edm screens for this module')
    parser.add_option('-c',
                      action='store_true',
                      dest='no_check_release',
                      help='Set CHECK_RELEASE to FALSE')
    parser.add_option(
        '-b', action='store_true', dest='no_substitute_boot',
        help='Don\'t substitute .src file to make a .boot file, copy it and '\
        ' create an envPaths file to load')

    # parse arguments
    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error('*** Error: Incorrect number of arguments - '
                     'you must supply one input file (.xml)')

    # define parameters
    if options.debug:
        debug = True
    else:
        debug = False
    if options.DbOnly:
        DbOnly = True
    else:
        DbOnly = False

    # setup the store
    xml_file = args[0]
    store = Store(debug=debug, DbOnly=DbOnly, doc=options.doc)
    if options.debug:
        print '--- Parsing %s ---' % xml_file

    # read the xml text for the architecture
    xml_text = open(xml_file).read()
    xml_root = xml.dom.minidom.parseString(xml_text)
    components = [
        n for n in xml_root.childNodes if n.nodeType == n.ELEMENT_NODE
    ][0]
    if options.simarch is not None:
        store.architecture = patch_arch(options.simarch)
        store.simarch = store.architecture
    else:
        store.architecture = patch_arch(
            str(components.attributes['arch'].value))
        store.simarch = None

    # Now create a new store, loading the release file from this xml file
    store.New(xml_file)
    store.iocbuilder.SetSource(os.path.realpath(xml_file))

    # create iocbuilder objects from the xml text
    store.iocbuilder.includeXml.instantiateXml(xml_text)

    if options.doc:
        iocpath = options.doc
    elif DbOnly:
        iocpath = os.path.abspath(".")
        if options.simarch:
            store.iocname += '_sim'
    else:
        # write the iocs
        root = os.path.abspath(options.out)
        iocpath = os.path.join(root, store.iocname)
        if options.simarch:
            iocpath += '_sim'


#            store.iocbuilder.SetEpicsPort(6064)

    substitute_boot = not options.no_substitute_boot
    if store.architecture == "win32-x86":
        substitute_boot = False
    if debug:
        print "Writing ioc to %s" % iocpath
    store.iocbuilder.WriteNamedIoc(iocpath,
                                   store.iocname,
                                   check_release=not options.no_check_release,
                                   substitute_boot=substitute_boot,
                                   edm_screen=options.edm_screen)
    if debug:
        print "Done"