Пример #1
0
    def showPackageCaps(self, pkg):
        self.CapsListView.clear()
        self.ReqsListView.clear()
        self.CnflListView.clear()

        caps = pkg.provides()
        if caps:
            for c in caps:
                item = qt.QListViewItem(self.CapsListView, str(c))

        caps = pkg.requires()
        if caps:
            for c in caps:
                type = ''
                if c.is_prereq():
                    type += 'pre'

                if c.is_prereq_un():
                    if len(type): type += ', '
                    type += 'preun'

                if c.is_autodirreq():
                    type = 'dir'

                item = qt.QListViewItem(self.ReqsListView, str(c), type)

        caps = pkg.conflicts()
        if caps:
            for c in caps:
                type = 'conflict'
                if c.is_obsl():
                    type = 'obsolete'

                item = qt.QListViewItem(self.CnflListView, str(c), type)
Пример #2
0
 def fillTargets(self):
     self._targetsview.clear()
     if self._flag:
         names = pkgconf.getFlagTargets(self._flag)
         namelst = names.keys()
         namelst.sort()
         for name in namelst:
             for relation, version in names[name]:
                 if relation and version:
                     item = qt.QListViewItem(self._targetsview)
                     item.setText(0, "%s %s %s" % (name, relation, version))
                 else:
                     qt.QListViewItem(self._targetsview).setText(0, name)
Пример #3
0
    def __init__(self, parent, node, key):
        series = node.series[key]
        seqs = [
            (base.PriceSizeLookup[key], series),
        ]
        seqs += series.index_map.items()
        start = [
            ('Series', -1, alignRight),
        ]
        middle = [(s, -1, alignRight) for s, seq in seqs]

        self.columnDefs = start + middle
        BaseNodeListView.__init__(self, parent, node)

        for i in range(len(series)):
            item = qt.QListViewItem(self, '%s' % i)
            for colidx, seq in enumerate(seqs):
                try:
                    v = seq[1][i] or ''
                except (IndexError, ):
                    v = seq
                try:
                    v = '%2.6f' % v
                except (TypeError, ):
                    pass
                item.setText(colidx + 1, '%s' % (v, ))
Пример #4
0
    def setupNode(self):
        """ setupNode() -> build this object

        """
        self.clear()

        for k, v in self.node.current_data.items():
            try:
                throwaway = float(v)
                if int(throwaway) == -1:
                    raise TypeError('foo!')
            except (
                    TypeError,
                    ValueError,
            ):
                item = qt.QListViewItem(self, k, '%s' % (v, ))
            else:
                item = AccountValueListViewItem(self, k)
                item.setText(1, '%s' % v)
                pxm = qt.QPixmap(*self.swatchSize)
                color = self.plotDefs.get(k, qt.Qt.gray)
                pxm.fill(color)
                item.setPixmap(2, pxm)
                item.pixmapColor = color
                if k in self.plotDefs:
                    item.setOn(True)
Пример #5
0
 def __init__(self, parent, notifications):
     qt.QListView.__init__(self, parent)
     self.addColumn("New notifications")
     self.setColumnWidthMode(0, qt.QListView.Maximum)
     for n in notifications:
         notif_item = qt.QListViewItem(self)
         notif_item.setText(0, qt.QString(n.getMessage()))
Пример #6
0
    def __init__(self, parent, name, values, layout_margin=0, layout_spacing=-1, modal=True):
        qt.QDialog.__init__(self, parent, name, modal)
        if layout_spacing == -1:
            layout_spacing =  self.fontMetrics().height()

        self.list_layout = qt.QVBoxLayout()
        self.listview = qt.QListView(self)
        self.listview.setSelectionMode(qt.QListView.Extended)
        self.listview.addColumn(name)
        self.listview.setColumnWidthMode(0, qt.QListView.Maximum)
        for value in values:
            view_item = qt.QListViewItem(self.listview)
            view_item.setText(0, qt.QString(value))

        self.list_layout.addWidget(self.listview)

        self.button_box = qt.QVBoxLayout()
        self.add_button = qt.QPushButton("Add", self)
        self.add_button.setMaximumSize(qt.QSize(100, 100))
        self.connect(self.add_button, qt.SIGNAL('clicked()'), self.addValue)
        self.remove_button = qt.QPushButton("Remove", self)
        self.remove_button.setMaximumSize(qt.QSize(100, 100))
        self.connect(self.remove_button, qt.SIGNAL('clicked()'), self.removeValue)
        self.close_button = qt.QPushButton("Close", self)
        self.close_button.setMaximumSize(qt.QSize(100, 100))
        self.connect(self.close_button, qt.SIGNAL('clicked()'), self.close)
        self.button_box.addWidget(self.add_button)
        self.button_box.addWidget(self.remove_button)
        self.button_box.addStretch(2)
        self.button_box.addWidget(self.close_button)

        self.main_layout = qt.QHBoxLayout(self, layout_margin, layout_spacing, "main_layout")
        self.main_layout.addLayout(self.list_layout)
        self.main_layout.addLayout(self.button_box)
Пример #7
0
    def __createPolygon(self, nb):
        try:
            showgButton = self._widgetTree.child('__showGrab')
            showgButton.setOn(True)
            grabButton = self._widgetTree.child('__grabButton')
            grabButton.setOn(False)

            polygon = QubPolygoneDrawingMgr(self._view.canvas(),
                                            self._view.matrix())
            polygon.setActionInfo('Drawing mask plygon %d' % self.__polyNb)
            polygon.setEndDrawCallBack(self.__polygonCBK)
            polygon.setAutoDisconnectEvent(True)
            drawingObject = QubCanvasCloseLinePolygone(self._view.canvas())
            polygon.addDrawingObject(drawingObject)
            self._view.addDrawingMgr(polygon)
            polygon.setColor(self._view.foregroundColor())
            newItem = qt.QListViewItem(self.__polygonListWidget)
            newItem.setText(0, 'Polygon %d' % self.__polyNb)
            newItem.setPixmap(0, Icons.load('Plus2'))
            newItem.drawingManager = polygon
            newItem.includeMode = True
            self.__polyNb += 1
            polygon.startDrawing()
        except:
            import traceback
            traceback.print_exc()
Пример #8
0
    def _createTable(self):

        self._clearTable()
        if self.device is not None:
            # self._show_empty_slots = self.widget.ckShowEmptySlots.isOn()
            self.list.setRootIsDecorated(True)
            self.list.setSorting(-1)
            self.list.addColumn("Element", 150)
            self.list.addColumn("Status", 60)
            self.list.addColumn("ID", 60)
            for prop in self.device.getSampleProperties():
                self.list.addColumn(str(prop), 60)
            # How can we align the header?
            # for i in range (1,self.list.columns()):
            #    self.list.setColumnAlignment(i,qt.Qt.AlignHCenter)

            # self.list.setColumnWidthMode (0,qt.QListView.Maximum)
            root_name = self.device.getAddress()
            self.root = qt.QListViewItem(self.list, root_name, "",
                                         self._getRootID())
            for element in reversed(self.device.getComponents()):
                self._addElement(self.root, element)

            self.root.setOpen(True)

            self._checkVisibility(self.root,
                                  self.widget.ckShowEmptySlots.isOn())
Пример #9
0
    def __add_drawing(self):
        self.__item_counter += 1
        name = ("Grid - %i" % self.__item_counter)
        width = str(self.__cell_width)
        height = str(self.__cell_height)
        list_view_item = qt.QListViewItem(self.__list_view, name, width,
                                          height)
        self.__list_view.setSelected(list_view_item, True)
        self.__list_items[list_view_item] = self.__drawing_mgr
        self.__drawing_mgr.stopDrawing()

        num_cells = self.__drawing_mgr._drawingObjects[0].get_nummer_of_cells()
        data = {}

        for cell in range(1, num_cells + 1):
            random.seed()
            data[cell] = (cell, (255, random.randint(0, 255), 0))

        self.__drawing_mgr._drawingObjects[0].set_data(data)

        print self.__drawing_mgr._drawingObjects[0].get_cell_locations()

        self.__drawing_mgr = Qub2PointSurfaceDrawingMgr(
            self.__canvas, self.__matrix)
        self.__start_surface_drawing()
Пример #10
0
    def refreshNode(self):
        """refreshNode() -> update list view contents from node subject

        """
        self.clear()
        for k, v in self.node.items():
            qt.QListViewItem(self, shortStr(k), shortStr(v))
Пример #11
0
    def refreshNode(self):
        """refreshNode() -> update list view contents from node subject

        """
        self.clear()
        for idx, val in enumerate(self.node):
            qt.QListViewItem(self, shortStr(idx), shortStr(val))
Пример #12
0
 def __add_drawing(self):
     if self.__drawing_mgr.isVisible()[0]:
         self.__item_counter += 1
         name = "Grid - %i" % self.__item_counter
         beam_width = str(self.__beam_pos[2] * 1000)
         beam_height = str(self.__beam_pos[3] * 1000)
         vspace, hspace = self.__get_cell_dim()
         vspace = vspace * 1000
         hspace = hspace * 1000
         list_view_item = qt.QListViewItem(
             self.__list_view,
             name,
             beam_width,
             beam_height,
             str(hspace),
             str(vspace),
         )
         self.__list_items[list_view_item] = self.__drawing_mgr
         self.__drawing_mgr.stopDrawing()
         self.__drawing_mgr.set_label(name)
         self.__list_view.setSelected(list_view_item, True)
         self.__drawing_mgr = Qub2PointSurfaceDrawingMgr(
             self.__canvas, self.__matrix
         )
         self.__start_surface_drawing()
Пример #13
0
 def addrow(self, data):
     t = data[0]
     i = qt.QListViewItem(self.this)
     for j in range(len(t)):
         i.setText(j, t[j])
     key = str(self.cntr)
     self.cntr += 1
     i.setText(j + 1, key)  # hidden
     self.zdict[key] = data
Пример #14
0
    def setupItem(self, contract, execution):
        """setupItem(...) -> build a list item

        """
        item = qt.QListViewItem(self)
        item.setPixmap(1, util.loadIcon(contract.symbol.lower()))
        vals = self.valueList(contract, execution)
        for c, v in enumerate(vals):
            item.setText(c, v)
Пример #15
0
    def fillPackageList(self, list):
        for p in list:
            evr = "%s-%s" % (p.ver, p.rel)
            item = qt.QListViewItem(self.PackageListView, p.name, evr,
                                    "%ldK" % (p.size / 1024))
            item.__package = p

        self.connect(self.PackageListView,
                     qt.SIGNAL("selectionChanged(QListViewItem *)"),
                     self.selectedSlot)
Пример #16
0
    def showPackageFiles(self, pkg):
        self.FileListView.clear()

        it = pkg.get_flist_it()

        fi = it.get_tuple()
        while fi:
            item = qt.QListViewItem(self.FileListView, fi[0], "%o" % fi[2],
                                    "%i" % fi[1])
            fi = it.get_tuple()
Пример #17
0
    def refreshNode(self):
        """ refreshNode() -> refresh callback

        """
        self.clear()

        items = self.node.items()
        items.sort()
        for key, value in items:
            index = time.ctime(key).split()[3]
            qt.QListViewItem(self, index, shortStr(value))
Пример #18
0
 def __init__(self, parent, node):
     BaseNodeListView.__init__(self, parent, node)
     for sym, pos in node.items():
         positems = [pos.position, pos.marketprice, pos.marketvalue]
         args = [
             self,
             sym,
         ] + [str(s) for s in positems]
         item = qt.QListViewItem(*args)
         item.setPixmap(0, util.loadIcon(sym.lower()))
     self.connect(self, util.sigDoubleClicked, self.handleShowTicker)
Пример #19
0
    def expose(self, topic, percent, subkey, subtopic, subpercent, data, done):
        if self._currentThread() != self._mainthread:
            # Note: it's NOT safe to use Qt from threads other than main
            return

        qt.QDialog.show(self)
        if not self._beenshown:
            centerWindow(self)
            self._beenshown = True
        self.raiseW()

        if self._hassub and subkey:
            if subkey in self._subiters:
                iter = self._subiters[subkey]
            else:
                iter = qt.QListViewItem(self._listview)
                self._subiters[subkey] = iter
                self._listview.ensureItemVisible(iter)

            current = data.get("current", "")
            if current:
                self._listview.setColumnWidth(self._currentcolumn, 110)
            total = data.get("total", "")
            if total:
                self._listview.setColumnWidth(self._totalcolumn, 110)
            if done:
                speed = ""
                eta = ""
                subpercent = 100
            else:
                speed = data.get("speed", "")
                if speed:
                    self._listview.setColumnWidth(self._speedcolumn, 110)
                eta = data.get("eta", "")
                if eta:
                    self._listview.setColumnWidth(self._etacolumn, 110)
            if current or total or speed or eta:
                iter.setText(1, current)
                iter.setText(2, total)
                iter.setText(3, speed)
                iter.setText(4, eta)
                subtopic = self._shorturl.get(subtopic)
            iter.setText(0, str(subpercent) + "%")
            iter.setText(5, subtopic)
            iter.widthChanged(self._desccolumn)
            self._listview.insertItem(iter)
        else:
            self._topic.setText('<b>' + topic + '</b>')
            self._progressbar.setProgress(percent, 100)
            if self._hassub:
                self._listview.update()

        while qt.QApplication.eventLoop().hasPendingEvents():
            qt.QApplication.eventLoop().processEvents(qt.QEventLoop.AllEvents)
Пример #20
0
 def addrow(self, data, expand=None):
     t = data[0]
     if expand:
         i = ___qttree___.ritem(self.root[-1], self, expand)
     else:
         i = qt.QListViewItem(self.root[-1])
     self.last = i
     for j in range(len(t)):
         i.setText(j, t[j])
     key = str(self.cntr)
     self.cntr += 1
     i.setText(j + 1, key)  # hidden
     self.zdict[key] = data
Пример #21
0
    def __init__(self, parent=None):
        super(UpdatePage, self).__init__(parent)

        updateGroup = qt.QVGroupBox("Package selection", self)
        systemCheckBox = qt.QCheckBox("Update system", updateGroup)
        appsCheckBox = qt.QCheckBox("Update applications", updateGroup)
        docsCheckBox = qt.QCheckBox("Update documentation", updateGroup)

        packageGroup = qt.QHGroupBox("Existing packages", self)
        packageList = qt.QListView(packageGroup)
        packageList.addColumn("")
        packageList.setColumnWidthMode(0, qt.QListView.Maximum)
        packageList.setColumnWidth(0, packageList.width())

        qtItem = qt.QListViewItem(packageList)
        qtItem.setText(0, "Qt")
        qsaItem = qt.QListViewItem(packageList)
        qsaItem.setText(0, "QSA")
        teamBuilderItem = qt.QListViewItem(packageList)
        teamBuilderItem.setText(0, "Teambuilder")
        self.setSpacing(12)
        startUpdateButton = qt.QPushButton("Start update", self)
Пример #22
0
    def refreshNode(self):
        """ refreshNode() -> 

        """
        self.clear()
        node = self.node[:]
        node.reverse()
        for values in node:
            values = list(values)
            values[0] = time.ctime(values[0]).split()[3]
            values = [
                self,
            ] + ['%s' % value for value in values]
            qt.QListViewItem(*values)
Пример #23
0
    def appendItem(self, parentItem, column1_text, column2_text, icon=None):
        newListItem = qt.QListViewItem(parentItem, column1_text, column2_text)
        _moveToLast(newListItem, parentItem)

        newListItem.setDragEnabled(True)
        newListItem.setDropEnabled(True)
        
        if icon is not None:
            newListItem.setPixmap(0, Icons.load(icon))

        #qt.QObject.disconnect(self.treeLayout, qt.SIGNAL('selectionChanged(QListViewItem *)'), self.itemSelected)
        self.treeLayout.setCurrentItem(newListItem)
        self.treeLayout.ensureItemVisible(newListItem)
        #qt.QObject.connect(self.treeLayout, qt.SIGNAL('selectionChanged(QListViewItem *)'), self.itemSelected)
        
        return newListItem
Пример #24
0
    def __init__(self, *args, **kwargs):
        qt.QWidget.__init__(self, *args)

        self.configuration = Configuration.Configuration()
      
        self.setCaption("GUI Editor")

        tb = qt.QHBox(self)
        toolsBox = qt.QGrid(6, tb)
        HorizontalSpacer(tb)
        toolsBox.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)
        self.cmdAddWindow = ToolButton(toolsBox, "window_new", self.addWindow, "add a new window (container)")
        self.cmdAddTab=ToolButton(toolsBox, "tab", self.addTab, "add a new tab (container)")
        self.cmdAddHBox=ToolButton(toolsBox, "add_hbox", self.addHBox, "add a new horizontal box (container)")
        self.cmdAddVBox=ToolButton(toolsBox, "add_vbox", self.addVBox, "add a new vertical box (container)")
        self.cmdAddHGroupBox=ToolButton(toolsBox, "hgroupbox", self.addHGroupBox, "add a new horizontal group box (container)")
        self.cmdAddVGroupBox=ToolButton(toolsBox, "vgroupbox", self.addVGroupBox, "add a new vertical group box (container)")
        self.cmdAddHSpacer=ToolButton(toolsBox, "add_hspacer", self.addHSpacer, "add a new horizontal spacer")
        self.cmdAddVSpacer=ToolButton(toolsBox, "add_vspacer", self.addVSpacer, "add a new vertical spacer")
        self.cmdAddHSplitter=ToolButton(toolsBox, "hsplitter", self.addHSplitter, "add a new horizontal splitter (container)")
        self.cmdAddVSplitter=ToolButton(toolsBox, "vsplitter", self.addVSplitter, "add a new vertical splitter (container)")
        self.cmdAddIcon=ToolButton(toolsBox, "icon", self.addIcon, "add a new icon")
        self.cmdAddLabel=ToolButton(toolsBox, "label", self.addLabel, "add a new label")
        treeHandlingBox = qt.QHBox(self)
        treeHandlingBox.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)
        self.cmdShowConnections=ToolButton(treeHandlingBox, "connect_creating", self.showConnections, "manage connections between items")
        HorizontalSpacer(treeHandlingBox,size=20)
        self.cmdMoveUp=ToolButton(treeHandlingBox, "Up2", self.moveUp, "move an item up")
        self.cmdMoveDown=ToolButton(treeHandlingBox, "Down2", self.moveDown, "move an item down")
        HorizontalSpacer(treeHandlingBox, size=10)
        self.cmdRemoveItem=ToolButton(treeHandlingBox, "delete_small", self.removeItem, "delete an item")
        HorizontalSpacer(treeHandlingBox)
        
        self.treeLayout = GUIListView(self)
        self.rootElement = qt.QListViewItem(self.treeLayout, "GUI tree", "")
        self.rootElement.setOpen(True)

        qt.QObject.connect(self.treeLayout, qt.SIGNAL('selectionChanged(QListViewItem *)'), self.itemSelected)
        qt.QObject.connect(self.treeLayout, qt.SIGNAL('doubleClicked(QListViewItem *, const QPoint &, int)'), self.itemDoubleClicked)
        qt.QObject.connect(self.treeLayout, qt.SIGNAL('itemRenamed(QListViewItem *, int)'), self.itemRenamed)
        qt.QObject.connect(self.treeLayout, qt.PYSIGNAL('dragdrop'), self.itemDragDropped)
        qt.QObject.connect(self.treeLayout, qt.PYSIGNAL('contextMenuRequested'), self.itemRightClicked)
     
        qt.QVBoxLayout(self, 0, 10)
        self.layout().addWidget(tb)
        self.layout().addWidget(treeHandlingBox)
        self.layout().addWidget(self.treeLayout)
Пример #25
0
    def refreshNode(self):
        """refreshNode() -> update list view contents from node subject

        """
        import socket

        self.clear()
        socket_object = self.node
        func_attrs = ('fileno', 'getsockname', 'getpeername', 'gettimeout')

        for method_name in func_attrs:
            try:
                results = getattr(socket_object, method_name)()
            except (socket.error, ):
                pass
            else:
                qt.QListViewItem(self, method_name, str(results))
Пример #26
0
    def loadTickers(self, filename):
        obj = tools.load_object(filename)
        if obj.__class__.__name__ == 'TickerSupervisor':
            self.tickers = obj
            self.rebuiltTickers = {}
        else:
            print 'Could not load a pickled tickers from %s' % (filename, )
            return

        self.fileName = filename
        self.setCaption(self.title % filename)
        self.tickersListView.clear()

        for (tid, tsym), tobj in obj.items():
            item = qt.QListViewItem(self.tickersListView)
            item.setText(0, str(tid))
            item.setText(1, tsym)
            item.setText(2, str(len(tobj.series[1])))
Пример #27
0
    def setConfiguration(self, configuration):
        self.configuration = configuration
        #print 'configuration id is', id(configuration)

        self.treeLayout.blockSignals(True)
        self.treeLayout.takeItem(self.rootElement)
        self.rootElement = qt.QListViewItem(self.treeLayout, "GUI tree", "")
        self.rootElement.setOpen(True)
        
        self.emit(qt.PYSIGNAL('hideProperties'), ())

        def addChildren(children, parentItem):
            parent_name = str(parentItem.text(0))
            parent = self.configuration.findContainer(parent_name)
            
            for child in children:
                #print child["name"]
                if self.configuration.isContainer(child):
                    #print 'is container'
                    new_list_item = self.appendItem(parentItem, child["name"], child["type"], icon=child["type"])
                    addChildren(child["children"], new_list_item)
                    self.configuration.items[child["name"]].updateSlots()
                elif self.configuration.isSpacer(child):
                    #print 'is spacer'
                    new_list_item = self.appendItem(parentItem, child["name"], "spacer", icon=child["type"])
                elif self.configuration.isBrick(child):
                    #print 'is brick'
                    new_list_item = self.appendItem(parentItem, child["name"], child["type"], icon="brick")
                else:
                    #print 'is icon or label'
                    new_list_item = self.appendItem(parentItem, child["name"], child["type"], icon=child["type"])
                self.connectItem(parent, child, new_list_item)

        for window in self.configuration.windows_list:
            parentWindowItem = self.appendItem(self.rootElement, window.name, "window", icon="window_small")
            self.connectItem(None, window, parentWindowItem)
            
            addChildren(window["children"], parentWindowItem)

        self.treeLayout.blockSignals(False)
        self.treeLayout.triggerUpdate()

        self.treeLayout.setSelected(self.rootElement.itemBelow(),1)
        self.emit(qt.PYSIGNAL('showProperties'), ())
Пример #28
0
    def slotPortfolio(self, evt):
        """slotPortfolio(event) -> update the list view item

        """
        contract, position, market_price, market_value = \
            evt.contract, evt.position, evt.market_price, evt.market_value

        item = self.findItem(contract.symbol, 0)  # ExactMatch | CaseSensitive
        if not item:
            args = [
                self,
                contract.symbol,
            ]
            args += [str(s) for s in [position, market_price, market_value]]
            item = qt.QListViewItem(*args)
            item.setPixmap(0, util.loadIcon(contract.symbol.lower()))
        else:
            args = [position, market_price, market_value]
            for col, txt in enumerate([str(s) for s in args]):
                item.setText(col + 1, txt)
Пример #29
0
 def fillFlags(self):
     self._flagsview.clear()
     flaglst = pkgconf.getFlagNames()
     flaglst.sort()
     for flag in flaglst:
         qt.QListViewItem(self._flagsview).setText(0, flag)
Пример #30
0
 def addValue(self):
     text, ok = qt.QInputDialog.getText('New value', 'New value:')
     if not ok or text == '':
         return
     view_item = qt.QListViewItem(self.listview)
     view_item.setText(0, qt.QString(text))