Ejemplo n.º 1
0
def symbolSelectableModelFactory(editor):
    # Data function    
    def symbolData():
        return [dict(data = block, display = editor.blockUserData(block).symbol, image = editor.resources().get_icon("symbol-class")) for block in editor.symbolListModel.blocks]

    return selectableModelFactory(editor, symbolData, 
        filterFunction = lambda text, item: item["display"].find(text) != -1)
Ejemplo n.º 2
0
def bookmarkSelectableModelFactory(editor):
    # Data function
    def bookmarkData():
        return [dict(bookmark=editor.bookmarkListModel.bookmark(row),
                display=editor.bookmarkListModel.data(editor.bookmarkListModel.index(row)),
                image=editor.resources().get_icon('bookmarks')) 
            for row in range(len(editor.bookmarkListModel.bookmarks))]

    return selectableModelFactory(editor, bookmarkData, 
        filterFunction = lambda text, item: item["display"].find(text) != -1)
Ejemplo n.º 3
0
def tabSelectableModelFactory(mainWindow):
    """
    Shows select tab, and change to selected
    """
    def dataFunction():
        return [dict(data=tab,
                template="<table width='100%%'><tr><td><h4>%(name)s</h4></td></tr><tr><td><small>%(file)s</small></td></tr></table>",
                display={"name": tab.tabTitle(), "file": tab.filePath()},
                image=tab.tabIcon()) for tab in mainWindow.centralWidget().allWidgets()]

    return selectableModelFactory(
        mainWindow, dataFunction, 
        filterFunction=lambda text, item: \
            item["display"]["name"].find(text) != -1)
Ejemplo n.º 4
0
def bundleItemSelectableModelFactory(editor):
    # Data function    
    def bundleItemData():
        leftScope, rightScope = editor.scope()
        return [dict(data=bundleItem, 
                template="<table width='100%%'><tr><td>%(name)s - %(bundle)s</td><td align='right'>%(trigger)s</td></tr></table>",
                display={ 
                    "name": bundleItem.name, 
                    "bundle": bundleItem.bundle.name,
                    "trigger": bundleItem.trigger()
                },
                match=bundleItem.name.upper(),
                image=editor.resources().get_icon("bundle-item-%s" % bundleItem.type())) for bundleItem in editor.application.supportManager.getActionItemsByScope(leftScope, rightScope)]

    # Filter function        
    def bundleItemFilter(pattern, item):
        return text.fuzzy_match(pattern.upper(), item["match"])

    return selectableModelFactory(editor, bundleItemData, filterFunction=bundleItemFilter)