コード例 #1
0
ファイル: restore.py プロジェクト: EdwardBetts/frescobaldi
 def populate(self):
     """Puts the deleted/changed snippets in the tree."""
     self.deletedItem.takeChildren()
     self.deletedItem.setExpanded(True)
     self.deletedItem.setCheckState(0, Qt.Unchecked)
     self.changedItem.takeChildren()
     self.changedItem.setExpanded(True)
     self.changedItem.setCheckState(0, Qt.Unchecked)
     
     builtins = list(builtin.builtin_snippets)
     builtins.sort(key = snippets.title)
     
     names = frozenset(snippets.names())
     
     for name in builtins:
         if name in names:
             if snippets.isoriginal(name):
                 continue
             parent = self.changedItem
         else:
             parent = self.deletedItem
         
         item = QTreeWidgetItem(parent)
         item.name = name
         item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
         item.setCheckState(0, Qt.Unchecked)
         item.setText(0, snippets.title(name))
     
     self.deletedItem.setDisabled(self.deletedItem.childCount() == 0)
     self.changedItem.setDisabled(self.changedItem.childCount() == 0)
     self.checkOkButton()
コード例 #2
0
ファイル: SelectMimeTypes.py プロジェクト: kzwkt/dff
 def populate(self):
     self.tree.connect(self.tree,
                       SIGNAL("itemClicked(QTreeWidgetItem *, int)"),
                       self.clicked)
     self.tree.connect(self.tree,
                       SIGNAL("itemPressed(QTreeWidgetItem *, int)"),
                       self.clicked)
     for mimetype, mimecontent in self.mm.mimetypes.iteritems():
         mimetypeItem = QTreeWidgetItem(self.tree, [mimetype])
         mimetypeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled
                               | Qt.ItemIsSelectable)
         mimetypeItem.setCheckState(0, Qt.Unchecked)
         rCheckBox = RootCheckBox()
         rCheckBox.setEnabled(False)
         self.tree.setItemWidget(mimetypeItem, 1, rCheckBox)
         self.typeItems.append(mimetypeItem)
         for value in mimecontent:
             filetypeItem = QTreeWidgetItem(mimetypeItem, [value])
             filetypeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled
                                   | Qt.ItemIsSelectable)
             filetypeItem.setCheckState(0, Qt.Unchecked)
             checkBox = QCheckBox()
             checkBox.setEnabled(False)
             rCheckBox.addChild(checkBox)
             rCheckBox.connect(checkBox, SIGNAL("stateChanged(int)"),
                               rCheckBox.update)
             self.tree.setItemWidget(filetypeItem, 1, checkBox)
     self.tree.resizeColumnToContents(0)
コード例 #3
0
    def __init__(self):
        super(ShortcutSection, self).__init__()
        container = QVBoxLayout(self)
        self.tree = QTreeWidget()
        self.tree.setHeaderLabels([self.tr("Keys"), self.tr("Description")])
        self.tree.header().setStretchLastSection(True)
        self.tree.setColumnWidth(0, 200)
        container.addWidget(self.tree)

        self.items = {
            "new": "Create a new editor to work in a file",
            "new-project": "Create a new project",
            "open": "Open one or more files",
            "open-project": "Opens an existing project Edis",
            "reload": "Reload file",
            "save": "Save file"
        }

        for i, e in list(self.items.items()):
            item = QTreeWidgetItem(self.tree,
                                   [keymap.get_keymap(i).toString(), e])
            item.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled)

        self.tree.itemDoubleClicked.connect(self._change_shortcut)
        # Install
        EnvironmentConfiguration.install_widget(self.tr("Shortcuts"), self)
コード例 #4
0
    def setAnnotations(self, gds):
        self._annotationsUpdating = True
        self.annotationsTree.clear()

        annotations = defaultdict(set)
        subsetscount = {}
        for desc in gds["subsets"]:
            annotations[desc["type"]].add(desc["description"])
            subsetscount[desc["description"]] = str(len(desc["sample_id"]))

        for type, subsets in annotations.items():
            key = (gds["dataset_id"], type)
            subsetItem = QTreeWidgetItem(self.annotationsTree, [type])
            subsetItem.setFlags(subsetItem.flags() | Qt.ItemIsUserCheckable
                                | Qt.ItemIsTristate)
            subsetItem.setCheckState(
                0, self.gdsSelectionStates.get(key, Qt.Checked))
            subsetItem.key = key
            for subset in subsets:
                key = (gds["dataset_id"], type, subset)
                item = QTreeWidgetItem(
                    subsetItem, [subset, subsetscount.get(subset, "")])
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                item.setCheckState(
                    0, self.gdsSelectionStates.get(key, Qt.Checked))
                item.key = key
        self._annotationsUpdating = False
        self.annotationsTree.expandAll()
        for i in range(self.annotationsTree.columnCount()):
            self.annotationsTree.resizeColumnToContents(i)
コード例 #5
0
    def createActionItem(self, key):
        """
        Creates a new action item for the inputed key.
        
        :param      key | <str>
        
        :return     <QTreeWidgetItem>
        """
        action = self._actions.get(key)
        if (not action):
            text = 'Missing Action: %s' % key
            item = QTreeWidgetItem([text])
            ico = projexui.resources.find('img/log/warning.png')
            item.setIcon(0, QIcon(ico))
        else:
            item = QTreeWidgetItem([str(action.text()).replace('&', '')])
            item.setIcon(0, action.icon())

        item.setSizeHint(0, QSize(120, 20))
        item.setData(0, Qt.UserRole, qt.wrapVariant(key))

        flags = item.flags()
        flags ^= Qt.ItemIsDropEnabled
        item.setFlags(flags)

        return item
コード例 #6
0
 def _populate_datasets_tree(self):
     """
     Initialize the tree widget of datasets and volumes.
     """
     self._data_treewidget.clear()
     
     if self._repos_info is None:
         return
     
     for dset_uuid, dset_info in sorted(self._repos_info.items()):
         dset_item = QTreeWidgetItem( self._data_treewidget, QStringList( dset_uuid ) )
         dset_item.setData( 0, Qt.UserRole, (dset_uuid, "") )
         for data_name in dset_info["DataInstances"].keys():
             data_item = QTreeWidgetItem( dset_item, QStringList( data_name ) )
             data_item.setData( 0, Qt.UserRole, (dset_uuid, data_name) )
             if self._mode == 'specify_new':
                 # If we're in specify_new mode, only the dataset parent items are selectable.
                 flags = data_item.flags()
                 flags &= ~Qt.ItemIsSelectable
                 flags &= ~Qt.ItemIsEnabled
                 data_item.setFlags( flags )
     
     # Expand everything
     self._data_treewidget.expandAll()
     
     # Select the first item by default.
     if self._mode == "select_existing":
         first_item = self._data_treewidget.topLevelItem(0).child(0)
     else:
         first_item = self._data_treewidget.topLevelItem(0)            
     self._data_treewidget.setCurrentItem( first_item, 0 )
コード例 #7
0
ファイル: mainwindow.py プロジェクト: hmartinet/sshkeyman
 def add_server_tree_item(self, label, parent=None, is_leaf=False):
     item = QTreeWidgetItem(parent)
     item.setText(0, unicode(label))
     if is_leaf:
         item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
     self.server_tree.addTopLevelItem(item)
     return item      
コード例 #8
0
    def __init__(self):
        super(ShortcutSection, self).__init__()
        container = QVBoxLayout(self)
        self.tree = QTreeWidget()
        self.tree.setHeaderLabels([self.tr("Keys"), self.tr("Description")])
        self.tree.header().setStretchLastSection(True)
        self.tree.setColumnWidth(0, 200)
        container.addWidget(self.tree)

        self.items = {
            "new": "Create a new editor to work in a file",
            "new-project": "Create a new project",
            "open": "Open one or more files",
            "open-project": "Opens an existing project Edis",
            "reload": "Reload file",
            "save": "Save file"
            }

        for i, e in list(self.items.items()):
            item = QTreeWidgetItem(self.tree,
                                   [keymap.get_keymap(i).toString(), e])
            item.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled)

        self.tree.itemDoubleClicked.connect(self._change_shortcut)
        # Install
        EnvironmentConfiguration.install_widget(self.tr("Shortcuts"), self)
コード例 #9
0
ファイル: OWGEODatasets.py プロジェクト: nikicc/orange-bio
    def setAnnotations(self, gds):
        self._annotationsUpdating = True
        self.annotationsTree.clear()

        annotations = defaultdict(set)
        subsetscount = {}
        for desc in gds["subsets"]:
            annotations[desc["type"]].add(desc["description"])
            subsetscount[desc["description"]] = str(len(desc["sample_id"]))

        for type, subsets in annotations.items():
            key = (gds["dataset_id"], type)
            subsetItem = QTreeWidgetItem(self.annotationsTree, [type])
            subsetItem.setFlags(subsetItem.flags() | Qt.ItemIsUserCheckable |
                                Qt.ItemIsTristate)
            subsetItem.setCheckState(
                0, self.gdsSelectionStates.get(key, Qt.Checked)
            )
            subsetItem.key = key
            for subset in subsets:
                key = (gds["dataset_id"], type, subset)
                item = QTreeWidgetItem(
                    subsetItem, [subset, subsetscount.get(subset, "")]
                )
                item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                item.setCheckState(
                    0, self.gdsSelectionStates.get(key, Qt.Checked)
                )
                item.key = key
        self._annotationsUpdating = False
        self.annotationsTree.expandAll()
        for i in range(self.annotationsTree.columnCount()):
            self.annotationsTree.resizeColumnToContents(i)
コード例 #10
0
    def __init__(self, featureDict, selectedFeatures=None, parent=None):
        QDialog.__init__(self, parent)
        self.featureDict = featureDict
        if selectedFeatures is None or len(selectedFeatures) == 0:
            selectedFeatures = defaultdict(list)
        self.selectedFeatures = selectedFeatures
        self.setWindowTitle("Object Features")
        ui_class, widget_class = uic.loadUiType(os.path.split(__file__)[0] + "/featureSelection.ui")
        self.ui = ui_class()
        self.ui.setupUi(self)
        self.ui.buttonBox.accepted.connect(self.accept)
        self.ui.buttonBox.rejected.connect(self.reject)

        self.ui.allButton.pressed.connect(self.handleAll)
        self.ui.noneButton.pressed.connect(self.handleNone)

        self.ui.treeWidget.setColumnCount(1)
        for pluginName, features in featureDict.iteritems():
            parent = QTreeWidgetItem(self.ui.treeWidget)
            parent.setText(0, pluginName)
            parent.setExpanded(True)
            for name in sorted(features):
                item = QTreeWidgetItem(parent)
                item.setText(0, name)
                item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                if pluginName in self.selectedFeatures:
                    if name in self.selectedFeatures[pluginName]:
                        item.setCheckState(0, Qt.Checked)
                    else:
                        item.setCheckState(0, Qt.Unchecked)
コード例 #11
0
    def generate_tree_model(self, data_dict):
        """Generate a tree model for specified dictionary

        :param data_dict: A dictionary
        :type data_dict: dict
        :return: list of QTreeWidgetItem
        :rtype list:
        """
        widget_items = []
        font = QFont()
        font.setBold(True)
        for key in data_dict.keys():
            entry = data_dict[key]
            key_item = QTreeWidgetItem()
            key_item.setText(0, str(key))
            key_item.setFont(0, font)
            if isinstance(entry, dict):
                items = self.generate_tree_model(entry)
                key_item.addChildren(items)
            else:
                # value_item = QTreeWidgetItem()
                key_item.setText(1, str(entry))
                key_item.setFlags(key_item.flags() | Qt.ItemIsEditable)
                # key_item.addChild(key_item)
            widget_items.append(key_item)

        return widget_items
コード例 #12
0
 def __add_themen(self):
     self.ui.TREE_THEMEN.headerItem().setText(0, '')
     #TODO: resize column to contents
     #all of these don't work??
     self.ui.TREE_THEMEN.header().resizeSection(0, 250)
     self.ui.TREE_THEMEN.header().setResizeMode(
         QHeaderView.ResizeToContents)
     self.ui.TREE_THEMEN.header().setStretchLastSection(True)
     themen = self.json_settings.themen()
     for thema_name, thema in themen.iteritems():
         tree_thema = QTreeWidgetItem(self.ui.TREE_THEMEN)
         tree_thema.setText(0, thema_name)
         tree_thema.setData(0, Qt.UserRole, thema)
         tree_thema.setFlags(tree_thema.flags() | Qt.ItemIsUserCheckable)
         if thema_name == 'DKM':
             tree_thema.setCheckState(0, Qt.Checked)
         else:
             tree_thema.setCheckState(0, Qt.Unchecked)
         if not thema.subthemen is None:
             for subthema in thema.subthemen:
                 if VRP_DEBUG is True:
                     QgsMessageLog.logMessage(
                         u'Subthema: {0}'.format(subthema.name),
                         DLG_CAPTION)
                 tree_subthema = QTreeWidgetItem()
                 tree_subthema.setText(0, subthema.name)
                 tree_subthema.setData(0, Qt.UserRole, subthema)
                 tree_subthema.setFlags(tree_subthema.flags()
                                        | Qt.ItemIsUserCheckable)
                 tree_subthema.setCheckState(0, Qt.Unchecked)
                 tree_thema.addChild(tree_subthema)
コード例 #13
0
ファイル: pages_list.py プロジェクト: maximerobin/Ufwi
    def loadPagesList(self, checkable=False):
        self.clear()
        for section in self.user_settings['pagesindex'].sections:
            root = QTreeWidgetItem([section.title])
            root.setData(0, Qt.UserRole, QVariant(QString(section.name)))
            root.setData(0, Qt.DecorationRole, QVariant(QIcon(section.icon)))
            self.addTopLevelItem(root)

            for page_id, page in section.pages:
                if not page:
                    page = self.getPage(page_id)
                if page.title:
                    page_title = page.title
                else:
                    page_title = tr('(No name)')
                item = QTreeWidgetItem([page_title])
                item.setData(0, Qt.UserRole ,QVariant(QString(page_id)))
                if checkable:
                    item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
                    item.setCheckState(0, Qt.Unchecked)
                root.addChild(item)
                if page == self.window.current_page:
                    f = QFont()
                    f.setWeight(QFont.Bold)
                    item.setData(0, Qt.FontRole, QVariant(f))
                    self.setCurrentItem(item)

        self.expandAll()
コード例 #14
0
 def __add_themen(self):
     self.ui.TREE_THEMEN.headerItem().setText(0, '')
     #TODO: resize column to contents
     #all of these don't work??
     self.ui.TREE_THEMEN.header().resizeSection(0, 250)
     self.ui.TREE_THEMEN.header().setResizeMode(QHeaderView.ResizeToContents);
     self.ui.TREE_THEMEN.header().setStretchLastSection(True);
     themen = self.json_settings.themen()
     for thema_name, thema in themen.iteritems():
         tree_thema = QTreeWidgetItem(self.ui.TREE_THEMEN)
         tree_thema.setText(0, thema_name)
         tree_thema.setData(0, Qt.UserRole, thema)
         tree_thema.setFlags(tree_thema.flags() | Qt.ItemIsUserCheckable)
         if thema_name == 'DKM':
             tree_thema.setCheckState(0, Qt.Checked)
         else:
             tree_thema.setCheckState(0, Qt.Unchecked)
         if not thema.subthemen is None:
             for subthema in thema.subthemen:
                 if VRP_DEBUG is True: QgsMessageLog.logMessage(u'Subthema: {0}'.format(subthema.name), DLG_CAPTION)
                 tree_subthema = QTreeWidgetItem()
                 tree_subthema.setText(0, subthema.name)
                 tree_subthema.setData(0, Qt.UserRole, subthema)
                 tree_subthema.setFlags(tree_subthema.flags() | Qt.ItemIsUserCheckable)
                 tree_subthema.setCheckState(0, Qt.Unchecked)
                 tree_thema.addChild(tree_subthema)
コード例 #15
0
 def OpenProjectFromFile(self, name):
     self.demands = {}
     self.project = Project()
     
     #try:
     self.project.Load(name)
     #except :
         # TODO: proper exceptioning
     #    QMessageBox.critical(self, self.tr("An error occured"), self.tr("File is not a valid project file: ") + name)
     #    return
     self.projectFile = name
     self.resourcesGraphEditor.setData(self.project.resources)
     self.ui.demands.clear()
     for d in self.project.demands:
         it = QTreeWidgetItem(self.ui.demands, QStringList([d.id, str(d.startTime), str(d.endTime), self.tr("No") if d.critical else self.tr("Yes"), self.tr("Yes") if d.assigned else self.tr("No")]))
         cb = QComboBox()
         cb.addItems([self.tr("No"),self.tr("Yes")])
         cb.setCurrentIndex(0 if d.critical else 1)
         QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged)
         self.ui.demands.setItemWidget(it,3,cb)
         it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
         self.demands[it] = d
     self.UpdateRecentFiles()
     self.setWindowTitle(self.project.name + " - " + self.basename)
     self.ui.projectname.setText(self.project.name)
     self.showStats()
     self.backupTimer.start()
     self.autosaveTimer.start()
コード例 #16
0
ファイル: contents_browser.py プロジェクト: thatcher/pydvid
    def _populate_datasets_tree(self):
        """
        Initialize the tree widget of datasets and volumes.
        """
        self._data_treewidget.clear()

        if self._repos_info is None:
            return

        for dset_uuid, dset_info in sorted(self._repos_info.items()):
            dset_item = QTreeWidgetItem(self._data_treewidget,
                                        QStringList(dset_uuid))
            dset_item.setData(0, Qt.UserRole, (dset_uuid, ""))
            for data_name in dset_info["DataInstances"].keys():
                data_item = QTreeWidgetItem(dset_item, QStringList(data_name))
                data_item.setData(0, Qt.UserRole, (dset_uuid, data_name))
                if self._mode == 'specify_new':
                    # If we're in specify_new mode, only the dataset parent items are selectable.
                    flags = data_item.flags()
                    flags &= ~Qt.ItemIsSelectable
                    flags &= ~Qt.ItemIsEnabled
                    data_item.setFlags(flags)

        # Expand everything
        self._data_treewidget.expandAll()

        # Select the first item by default.
        if self._mode == "select_existing":
            first_item = self._data_treewidget.topLevelItem(0).child(0)
        else:
            first_item = self._data_treewidget.topLevelItem(0)
        self._data_treewidget.setCurrentItem(first_item, 0)
コード例 #17
0
ファイル: restore.py プロジェクト: shimpe/frescobaldi
    def populate(self):
        """Puts the deleted/changed snippets in the tree."""
        self.deletedItem.takeChildren()
        self.deletedItem.setExpanded(True)
        self.deletedItem.setCheckState(0, Qt.Unchecked)
        self.changedItem.takeChildren()
        self.changedItem.setExpanded(True)
        self.changedItem.setCheckState(0, Qt.Unchecked)

        builtins = list(builtin.builtin_snippets)
        builtins.sort(key=snippets.title)

        names = frozenset(snippets.names())

        for name in builtins:
            if name in names:
                if snippets.isoriginal(name):
                    continue
                parent = self.changedItem
            else:
                parent = self.deletedItem

            item = QTreeWidgetItem(parent)
            item.name = name
            item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            item.setCheckState(0, Qt.Unchecked)
            item.setText(0, snippets.title(name))

        self.deletedItem.setDisabled(self.deletedItem.childCount() == 0)
        self.changedItem.setDisabled(self.changedItem.childCount() == 0)
        self.checkOkButton()
コード例 #18
0
    def _populate_repo_tree(self):
        """
        Initialize the tree widget of repos and volumes.
        """
        self._repo_treewidget.clear()
        
        if self._repos_info is None:
            return
        
        for repo_uuid, repo_info in sorted(self._repos_info.items()):
            if repo_info is None:
                continue
            repo_column_dict = collections.defaultdict(str)
            repo_column_dict["Alias"] = repo_info["Alias"]
            repo_column_dict["Details"] = "Created: " + repo_info["Created"]
            repo_column_dict["UUID"] = repo_uuid
            repo_column_values = [repo_column_dict[k] for k in TREEVIEW_COLUMNS]
            repo_item = QTreeWidgetItem( self._repo_treewidget, QStringList( repo_column_values ) )
            repo_item.setData( 0, Qt.UserRole, (repo_uuid, "", "") )
            for data_name, data_info in repo_info["DataInstances"].items():
                data_instance_dict = collections.defaultdict(str)
                data_instance_dict["Alias"] = data_name
                typename = data_info["Base"]["TypeName"]
                data_instance_dict["TypeName"] = typename

                is_voxels = (typename in VOXEL_TYPENAMES)
                if is_voxels:
                    start_coord = data_info["Extended"]["MinPoint"]
                    if start_coord:
                        start_coord = tuple(start_coord)
                    stop_coord = data_info["Extended"]["MaxPoint"]
                    if stop_coord:
                        stop_coord = tuple(x+1 for x in stop_coord)
                    if start_coord and stop_coord:
                        shape = tuple(b - a for a,b in zip(start_coord, stop_coord))
                    else:
                        shape = None
                    data_instance_dict["Details"] = "Size={} | Start={} | Stop={}".format( shape, start_coord, stop_coord )

                data_column_values = [data_instance_dict[k] for k in TREEVIEW_COLUMNS]
                data_item = QTreeWidgetItem( repo_item, data_column_values )
                data_item.setData( 0, Qt.UserRole, (repo_uuid, data_name, typename) )

                # If we're in specify_new mode, only the
                # repo parent items are selectable.
                # Also, non-volume items aren't selectable.
                if self._mode == 'specify_new' or typename not in self._selectable_types:
                    flags = data_item.flags()
                    flags &= ~Qt.ItemIsSelectable
                    flags &= ~Qt.ItemIsEnabled
                    data_item.setFlags( flags )
        
        self._repo_treewidget.collapseAll()
        self._repo_treewidget.setSortingEnabled(True)

        if self._hostname in self._default_nodes:
            self._select_node_uuid(self._default_nodes[self._hostname])

        self._repo_treewidget.resizeColumnToContents(0)
        self._repo_treewidget.setFocus()
コード例 #19
0
 def _loadCardGroup( self, groupName, records, parent = None ):
     if ( not groupName ):
         groupName = 'None'
     
     cards  = self.cardWidget()
     factory = self.factory()
     
     # create the group item
     group_item = QTreeWidgetItem(parent, [groupName])
     font = group_item.font(0)
     font.setBold(True)
     font.setPointSize(font.pointSize() + 2)
     group_item.setFont(0, font)
     group_item.setFlags(Qt.ItemIsEnabled)
     
     # load sub-groups
     if ( type(records) == dict ):
         for subgroup, records in sorted(records.items()):
             self._loadCardGroup(subgroup, records, group_item)
     else:
         for record in records:
             widget = factory.createCard(cards, record)
             if ( not widget ):
                 continue
             
             widget.adjustSize()
             
             # create the card item
             item = QTreeWidgetItem(group_item)
             item.setSizeHint(0, QSize(0, widget.height()))
             cards.setItemWidget(item, 0, widget)
     
     group_item.setExpanded(True)
コード例 #20
0
 def RandomDemand(self):
     d = self.randomDialog
     types = []
     for v in self.project.resources.vertices:
         if isinstance(v, Storage) and (types.count(v.type) == 0):
             types.append(v.type)
     if len(types) == 1:  #only type 0
         d.ui.cc1.setEnabled(False)
         d.ui.cc2.setEnabled(False)
     d.exec_()
     if d.result() == QDialog.Accepted:
         dict = d.GetResult()
         dict["types"] = types
         for i in range(dict["n"]):
             demand = self.project.CreateRandomDemand(dict)
             it = QTreeWidgetItem(
                 self.ui.demands,
                 QStringList([
                     demand.id,
                     str(demand.startTime),
                     str(demand.endTime),
                     self.tr("No"),
                     self.tr("No")
                 ]))
             cb = QComboBox()
             cb.addItems([self.tr("No"), self.tr("Yes")])
             self.ui.demands.setItemWidget(it, 3, cb)
             QObject.connect(cb, SIGNAL("currentIndexChanged(int)"),
                             it.emitDataChanged)
             it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled
                         | Qt.ItemIsSelectable)
             self.demands[it] = demand
コード例 #21
0
 def GenerateRequests(self):
     generator = self.generators[self.sender()]
     data = generator.GetSettings()
     d = ParamsDialog(data, self,
                      generator.GetName() == "Tightly coupled",
                      generator.GetName() == "Tightly coupled")
     d.exec_()
     if d.result() == QDialog.Accepted:
         generator.UpdateSettings(d.data)
         #TODO: populate the table with new demands
         self.project.demands = generator.Generate(self.project.resources)
         self.ui.demands.clear()
         self.demands = {}
         for demand in self.project.demands:
             it = QTreeWidgetItem(
                 self.ui.demands,
                 QStringList([
                     demand.id,
                     str(demand.startTime),
                     str(demand.endTime),
                     self.tr("No"),
                     self.tr("No")
                 ]))
             cb = QComboBox()
             cb.addItems([self.tr("No"), self.tr("Yes")])
             self.ui.demands.setItemWidget(it, 3, cb)
             QObject.connect(cb, SIGNAL("currentIndexChanged(int)"),
                             it.emitDataChanged)
             it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled
                         | Qt.ItemIsSelectable)
             self.demands[it] = demand
コード例 #22
0
    def _add_symbol_to_tree_widget(self, symbol):
        """ Add the given symbol to the tree widget. If this
        is a new category create it, otherwise append it
        to the already existing one.

        """

        # find category
        category = symbol["category"]
        categoryItems = self.availableSymbolsWidget.findItems(category,
                                                Qt.MatchExactly, 0)

        name = symbol["name"]
        symbolItem = QTreeWidgetItem([name])
        symbolItem.setData(0, Qt.UserRole, name)
        symbolItem.setFlags(Qt.ItemIsSelectable |
                            Qt.ItemIsUserCheckable |
                            Qt.ItemIsEnabled)

        if categoryItems:
            categoryItems[0].addChild(symbolItem)
        else:
            categoryItem = QTreeWidgetItem(self.availableSymbolsWidget,
                                           [category])
            categoryItem.setFlags(Qt.ItemIsEnabled)
            categoryItem.addChild(symbolItem)

        self.availableSymbolsWidget.resizeColumnToContents(0)
        self.availableSymbolsWidget.sortItems(0, Qt.AscendingOrder)
        self.availableSymbolsWidget.setCurrentItem(symbolItem)
コード例 #23
0
    def generate_tree_model(self, data_dict):
        """Generate a tree model for specified dictionary

        :param data_dict: A dictionary
        :type data_dict: dict
        :return: list of QTreeWidgetItem
        :rtype list:
        """
        widget_items = []
        font = QFont()
        font.setBold(True)
        for key in data_dict.keys():
            entry = data_dict[key]
            key_item = QTreeWidgetItem()
            key_item.setText(0, str(key))
            key_item.setFont(0, font)
            if isinstance(entry, dict):
                items = self.generate_tree_model(entry)
                key_item.addChildren(items)
            else:
                # value_item = QTreeWidgetItem()
                key_item.setText(1, str(entry))
                key_item.setFlags(key_item.flags() | Qt.ItemIsEditable)
                # key_item.addChild(key_item)
            widget_items.append(key_item)

        return widget_items
コード例 #24
0
class QNGWItem(QTreeWidgetItem):
    def __init__(self):
        QTreeWidgetItem.__init__(self)
        
        self.locked_item = QTreeWidgetItem(["loading..."])
        self.locked_item.setFlags(Qt.NoItemFlags)
        self.locked_item.setDisabled(True)

        self.release()

    def lock(self):
        self.__isLock = True
        self.setFlags(Qt.NoItemFlags)

        self.addChild(
            self.locked_item
        )

    def is_locked(self):
        return self.__isLock

    def release(self):
        self.__isLock = False
        self.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

        self.removeChild(
            self.locked_item
        )

    def ngw_resource_children_count(self):
        raise NotImplementedError()
コード例 #25
0
    def _loadCardGroup(self, groupName, records, parent=None):
        if (not groupName):
            groupName = 'None'

        cards = self.cardWidget()
        factory = self.factory()

        # create the group item
        group_item = QTreeWidgetItem(parent, [groupName])
        font = group_item.font(0)
        font.setBold(True)
        font.setPointSize(font.pointSize() + 2)
        group_item.setFont(0, font)
        group_item.setFlags(Qt.ItemIsEnabled)

        # load sub-groups
        if (type(records) == dict):
            for subgroup, records in sorted(records.items()):
                self._loadCardGroup(subgroup, records, group_item)
        else:
            for record in records:
                widget = factory.createCard(cards, record)
                if (not widget):
                    continue

                widget.adjustSize()

                # create the card item
                item = QTreeWidgetItem(group_item)
                item.setSizeHint(0, QSize(0, widget.height()))
                cards.setItemWidget(item, 0, widget)

        group_item.setExpanded(True)
コード例 #26
0
    def _add_symbol_to_tree_widget(self, symbol):
        """ Add the given symbol to the tree widget. If this
        is a new category create it, otherwise append it
        to the already existing one.

        """

        # find category
        category = symbol["category"]
        categoryItems = self.availableSymbolsWidget.findItems(
            category, Qt.MatchExactly, 0)

        name = symbol["name"]
        symbolItem = QTreeWidgetItem([name])
        symbolItem.setData(0, Qt.UserRole, name)
        symbolItem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable
                            | Qt.ItemIsEnabled)

        if categoryItems:
            categoryItems[0].addChild(symbolItem)
        else:
            categoryItem = QTreeWidgetItem(self.availableSymbolsWidget,
                                           [category])
            categoryItem.setFlags(Qt.ItemIsEnabled)
            categoryItem.addChild(symbolItem)

        self.availableSymbolsWidget.resizeColumnToContents(0)
        self.availableSymbolsWidget.sortItems(0, Qt.AscendingOrder)
        self.availableSymbolsWidget.setCurrentItem(symbolItem)
コード例 #27
0
 def createActionItem( self, key ):
     """
     Creates a new action item for the inputed key.
     
     :param      key | <str>
     
     :return     <QTreeWidgetItem>
     """
     action = self._actions.get(key)
     if ( not action ):
         text = 'Missing Action: %s' % key
         item = QTreeWidgetItem([text])
         ico = projexui.resources.find('img/log/warning.png')
         item.setIcon(0, QIcon(ico))
     else:
         item = QTreeWidgetItem([str(action.text()).replace('&', '')])
         item.setIcon(0, action.icon())
     
     item.setSizeHint(0, QSize(120, 20))
     item.setData(0, Qt.UserRole, qt.wrapVariant(key))
     
     flags = item.flags()
     flags ^= Qt.ItemIsDropEnabled
     item.setFlags(flags)
     
     return item
コード例 #28
0
ファイル: shortcut_manager.py プロジェクト: LeoYao/ninja-ide
 def _load_shortcuts(self):
     for action in resources.CUSTOM_SHORTCUTS:
         shortcut_action = resources.get_shortcut(action)
         #populate the tree widget
         tree_data = [self.shortcuts_text[action],
             shortcut_action.toString(QKeySequence.NativeText), action]
         item = QTreeWidgetItem(self.result_widget, tree_data)
         item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
コード例 #29
0
 def addNode(self, parent, text="", data=""):
     node = QTreeWidgetItem(parent)
     node.setText(0, text)
     node.setCheckState(0, Qt.Unchecked)
     node.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled
                   | Qt.ItemIsSelectable)
     node.setData(0, Qt.UserRole, data)
     return node
コード例 #30
0
ファイル: shortcut_manager.py プロジェクト: manuq/ninja-ide
 def _load_shortcuts(self):
     for action in resources.CUSTOM_SHORTCUTS:
         shortcut_action = resources.get_shortcut(action)
         #populate the tree widget
         tree_data = [self.shortcuts_text[action],
             shortcut_action.toString(QKeySequence.NativeText), action]
         item = QTreeWidgetItem(self.result_widget, tree_data)
         item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
コード例 #31
0
    def _populate_reporting_tab(self):
        """Populate trees about layers."""
        self.tree.clear()
        self.add_layer.setEnabled(False)
        self.remove_layer.setEnabled(False)
        self.move_up.setEnabled(False)
        self.move_down.setEnabled(False)
        self.tree.setColumnCount(1)
        self.tree.setRootIsDecorated(False)
        self.tree.setHeaderHidden(True)

        analysis_branch = QTreeWidgetItem(self.tree.invisibleRootItem(),
                                          [FROM_ANALYSIS['name']])
        analysis_branch.setFont(0, bold_font)
        analysis_branch.setExpanded(True)
        analysis_branch.setFlags(Qt.ItemIsEnabled)

        if self._multi_exposure_if:
            expected = self._multi_exposure_if.output_layers_expected()
            for group, layers in expected.iteritems():
                group_branch = QTreeWidgetItem(analysis_branch, [group])
                group_branch.setFont(0, bold_font)
                group_branch.setExpanded(True)
                group_branch.setFlags(Qt.ItemIsEnabled)

                for layer in layers:
                    layer = definition(layer)
                    if layer.get('allowed_geometries', None):
                        item = QTreeWidgetItem(group_branch,
                                               [layer.get('name')])
                        item.setData(0, LAYER_ORIGIN_ROLE,
                                     FROM_ANALYSIS['key'])
                        item.setData(0, LAYER_PARENT_ANALYSIS_ROLE, group)
                        item.setData(0, LAYER_PURPOSE_KEY_OR_ID_ROLE,
                                     layer['key'])
                        item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

        canvas_branch = QTreeWidgetItem(self.tree.invisibleRootItem(),
                                        [FROM_CANVAS['name']])
        canvas_branch.setFont(0, bold_font)
        canvas_branch.setExpanded(True)
        canvas_branch.setFlags(Qt.ItemIsEnabled)

        # List layers from the canvas
        loaded_layers = QgsMapLayerRegistry.instance().mapLayers().values()
        canvas_layers = self.iface.mapCanvas().layers()
        flag = setting('visibleLayersOnlyFlag', expected_type=bool)
        for loaded_layer in loaded_layers:
            if flag and loaded_layer not in canvas_layers:
                continue

            title = loaded_layer.name()
            item = QTreeWidgetItem(canvas_branch, [title])
            item.setData(0, LAYER_ORIGIN_ROLE, FROM_CANVAS['key'])
            item.setData(0, LAYER_PURPOSE_KEY_OR_ID_ROLE, loaded_layer.id())
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

        self.tree.resizeColumnToContents(0)
コード例 #32
0
ファイル: Vis.py プロジェクト: DanielZorin/DataCenters
 def setData(self, project):
     self.project = project
     self.canvas.Clear()
     self.ui.info.setText("")
     self.ui.assignedTenants.clear()
     for d in self.project.tenants:
         it = QTreeWidgetItem(self.ui.assignedTenants, [d.name])
         it.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
     self.canvas.Visualize(self.project.resources)
コード例 #33
0
 def _load_defaults_shortcuts(self):
     self.result_widget.clear()
     for name, action in resources.SHORTCUTS.iteritems():
         shortcut_action = action
         #populate the tree widget
         tree_data = [self.shortcuts_text[name],
             shortcut_action.toString(QKeySequence.NativeText)]
         item = QTreeWidgetItem(self.result_widget, tree_data)
         item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
コード例 #34
0
    def makeTree(self):
        self.tree.clear()
        arr = Valid().pullData('datas', '', {'pubID': self.titleID})
        self.hold_data = {}
        self.hold_mdata = {}
        self.hold_data_add = {}
        self.hold_data_add_item = {}

        if self.titleSub and self.titleSub > 0:
            if arr and len(arr) > 0:
                for val in arr:
                    ch = Valid().pullData('datas', '', {'subID': val['id']})
                    child = QTreeWidgetItem(self.tree)
                    child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                    child.setText(0, str(val['name']).upper())
                    child.setText(1, str(val['abbrv']).upper())
                    self.hold_data[val['id']] = child
                    self.hold_mdata[val['id']] = child
                    if (val['active'] == 0):
                        child.setCheckState(0, Qt.Checked)
                    else:
                        child.setCheckState(0, Qt.Unchecked)

                    for va in ch:
                        child1 = QTreeWidgetItem(child)
                        child1.setFlags(child1.flags()
                                        | Qt.ItemIsUserCheckable)
                        child1.setText(0, str(va['name']).upper())
                        child1.setText(1, str(va['abbrv']).upper())
                        self.hold_data[va['id']] = child1
                        if (va['active'] == 0):
                            child1.setCheckState(0, Qt.Checked)
                        else:
                            child1.setCheckState(0, Qt.Unchecked)

                    child1 = QTreeWidgetItem(child)
                    child1.setFlags(child1.flags() | Qt.ItemIsUserCheckable)
                    child1.setText(0, 'Add New Item')
                    self.hold_data_add_item[val['id']] = child1
        else:
            if arr and len(arr) > 0:
                for val in arr:
                    child = QTreeWidgetItem(self.tree)
                    child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                    child.setText(0, str(val['name']).upper())
                    child.setText(1, str(val['abbrv']).upper())
                    self.hold_data[val['id']] = child
                    if (val['active'] == 0):
                        child.setCheckState(0, Qt.Checked)
                    else:
                        child.setCheckState(0, Qt.Unchecked)

        child = QTreeWidgetItem(self.tree)
        child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
        child.setText(0, 'Add New')
        self.hold_data_add['addnew'] = child
コード例 #35
0
ファイル: initialconditions.py プロジェクト: economou/gpunit
    def treeAddParticle(self):
        item = QTreeWidgetItem(
                ("0.0", "0.0", "0.0", "AU",
                    "0.0", "0.0", "0.0", "km/s",
                    "0.0", "MSun",
                    "0.0", "km"
                    ))

        item.setFlags(item.flags() | Qt.ItemIsEditable)
        self.ui.particlesTree.addTopLevelItem(item)
コード例 #36
0
ファイル: expand.py プロジェクト: Alwnikrotikz/lilykde
 def createItem(self, name, description):
     """ Create a new item. """
     item = QTreeWidgetItem(self.treeWidget)
     item.groupName = name
     item.setFont(0, QFont("monospace"))
     item.setText(0, name)
     item.setText(1, description)
     item.setText(2, self.manager.shortcutText(name))
     item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled)
     return item
コード例 #37
0
ファイル: shortcut_manager.py プロジェクト: manuq/ninja-ide
 def _load_defaults_shortcuts(self):
     #clean custom shortcuts and UI widget
     resources.clean_custom_shortcuts()
     self.result_widget.clear()
     for name, action in list(resources.SHORTCUTS.items()):
         shortcut_action = action
         #populate the tree widget
         tree_data = [self.shortcuts_text[name],
             shortcut_action.toString(QKeySequence.NativeText), name]
         item = QTreeWidgetItem(self.result_widget, tree_data)
         item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
コード例 #38
0
 def _load_defaults_shortcuts(self):
     self.result_widget.clear()
     for name, action in resources.SHORTCUTS.iteritems():
         shortcut_action = action
         #populate the tree widget
         tree_data = [
             self.tr(name),
             shortcut_action.toString(QKeySequence.NativeText)
         ]
         item = QTreeWidgetItem(self.result_widget, tree_data)
         item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
コード例 #39
0
 def _addRequirements(self):
     for requirement, component, reason, optional in self._requirements:
         item = QTreeWidgetItem()
         item.setCheckState(0, Qt.Checked)
         if not optional:
             item.setFlags(Qt.ItemFlags(int(item.flags()) & ~Qt.ItemIsEnabled))
         item.setText(0, requirement)
         item.setText(1, reason)
         item.setText(2, component)
         item.setData(0, self._REQUIREMENT_ROLE, QVariant(requirement))
         self._reqTable.addTopLevelItem(item)
コード例 #40
0
def build_tree_widget_item(parent, name, is_checkable=True):
    child = QTreeWidgetItem(parent)
    if is_checkable:
        child.setFlags(child.flags() | QtCore.Qt.ItemIsUserCheckable
                       | QtCore.Qt.ItemIsTristate)
        child.setCheckState(0, QtCore.Qt.Unchecked)
    else:
        child.setFlags(QtCore.Qt.ItemIsEnabled)
    child.setText(0, name)

    return child
コード例 #41
0
ファイル: main.py プロジェクト: dev-platypus/marche
    def fill(self):
        self.clear()
        services = self._client.getServices()
        try:
            descrs = self._client.getServiceDescriptions(services)
        except Exception:
            descrs = {}
        self._client.startPoller(self.updateStatus)

        for service, instances in iteritems(services):
            serviceItem = QTreeWidgetItem([service])
            serviceItem.setForeground(1, QBrush(QColor('white')))
            serviceItem.setTextAlignment(1, Qt.AlignCenter)
            serviceItem.setFlags(Qt.ItemIsEnabled)
            serviceItem.setForeground(3, QBrush(QColor('red')))
            self.addTopLevelItem(serviceItem)

            btns = []
            has_empty_instance = None
            for instance in instances:
                if not instance:
                    has_empty_instance = True
                    continue
                instanceItem = QTreeWidgetItem([instance])
                instanceItem.setForeground(1, QBrush(QColor('white')))
                instanceItem.setTextAlignment(1, Qt.AlignCenter)
                instanceItem.setFlags(Qt.ItemIsEnabled)
                instanceItem.setForeground(3, QBrush(QColor('red')))
                if descrs.get((service, instance)):
                    instanceItem.setText(0, descrs[service, instance])
                serviceItem.addChild(instanceItem)

                btn = JobButtons(self._client, service, instance,
                                 instanceItem)
                btns.append(btn)
                self.setItemWidget(instanceItem, 2, btn)
                self._items[service, instance] = instanceItem
            if has_empty_instance:
                btn = JobButtons(self._client, service, '',
                                 serviceItem)
                btn.setMinimumSize(QSize(30, 40))
                self.setItemWidget(serviceItem, 2, btn)
                if descrs.get((service, '')):
                    serviceItem.setText(0, descrs[service, ''])
                self._items[service, ''] = serviceItem
            else:
                # create "virtual" job with buttons that start/stop all
                # instances of the service
                self._virt_items[service] = serviceItem
                multibtn = MultiJobButtons(btns)
                self.setItemWidget(serviceItem, 2, multibtn)

        self.expandAll()
コード例 #42
0
 def populate(self, items, selected):
     for item in items:
         treeItem = QTreeWidgetItem(self.treeWidget)
         treeItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled
                           | Qt.ItemIsSelectable)
         if item in selected:
             treeItem.setCheckState(0, Qt.Checked)
         else:
             treeItem.setCheckState(0, Qt.Unchecked)
         treeItem.setText(0, item)
         self.items.append(treeItem)
     self.treeWidget.resizeColumnToContents(0)
コード例 #43
0
ファイル: advanced.py プロジェクト: vit88/ldoce5viewer
        def add_children(child_nodes, parent):
            children = []
            for node in child_nodes:
                twitem = QTreeWidgetItem((node['label'], ))
                twitem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                twitem.setCheckState(0, Qt.Unchecked)
                twitem.setData(0, Qt.UserRole, node)
                if 'children' in node:
                    add_children(node['children'], twitem)
                children.append(twitem)

            parent.addChildren(children)
コード例 #44
0
    def populate_classified_values(self, unassigned_values, assigned_values,
                                   default_classes):
        """Populate lstUniqueValues and treeClasses.from the parameters.

        :param unassigned_values: List of values that haven't been assigned
            to a class. It will be put in self.lstUniqueValues.
        :type unassigned_values: list

        :param assigned_values: Dictionary with class as the key and list of
            value as the value of the dictionary. It will be put in
            self.treeClasses.
        :type assigned_values: dict

        :param default_classes: Default classes from unit.
        :type default_classes: list
        """
        # Populate the unique values list
        self.lstUniqueValues.clear()
        self.lstUniqueValues.setSelectionMode(
            QAbstractItemView.ExtendedSelection)
        for value in unassigned_values:
            value_as_string = value is not None and unicode(value) or 'NULL'
            list_item = QListWidgetItem(self.lstUniqueValues)
            list_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable
                               | Qt.ItemIsDragEnabled)
            list_item.setData(Qt.UserRole, value)
            list_item.setText(value_as_string)
            self.lstUniqueValues.addItem(list_item)
        # Populate assigned values tree
        self.treeClasses.clear()
        self.treeClasses.invisibleRootItem().setFlags(Qt.ItemIsEnabled)
        for default_class in default_classes:
            # Create branch for class
            tree_branch = QTreeWidgetItem(self.treeClasses)
            tree_branch.setFlags(Qt.ItemIsDropEnabled | Qt.ItemIsEnabled)
            tree_branch.setExpanded(True)
            tree_branch.setFont(0, bold_font)
            if 'name' in default_class:
                default_class_name = default_class['name']
            else:
                default_class_name = default_class['key']
            tree_branch.setText(0, default_class_name)
            tree_branch.setData(0, Qt.UserRole, default_class['key'])
            if 'description' in default_class:
                tree_branch.setToolTip(0, default_class['description'])
            # Assign known values
            for value in assigned_values[default_class['key']]:
                string_value = value is not None and unicode(value) or 'NULL'
                tree_leaf = QTreeWidgetItem(tree_branch)
                tree_leaf.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable
                                   | Qt.ItemIsDragEnabled)
                tree_leaf.setData(0, Qt.UserRole, value)
                tree_leaf.setText(0, string_value)
コード例 #45
0
ファイル: ModelerDialog.py プロジェクト: FrancisGauthier/QGIS
 def fillInputsTree(self):
     icon = QIcon(os.path.join(pluginPath, 'images', 'input.png'))
     parametersItem = QTreeWidgetItem()
     parametersItem.setText(0, self.tr('Parameters'))
     for paramType in ModelerParameterDefinitionDialog.paramTypes:
         paramItem = QTreeWidgetItem()
         paramItem.setText(0, paramType)
         paramItem.setIcon(0, icon)
         paramItem.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled)
         parametersItem.addChild(paramItem)
     self.inputsTree.addTopLevelItem(parametersItem)
     parametersItem.setExpanded(True)
コード例 #46
0
 def _load_defaults_shortcuts(self):
     """Method to load the default builtin shortcuts"""
     #clean custom shortcuts and UI widget
     resources.clean_custom_shortcuts()
     self.result_widget.clear()
     for name, action in list(resources.SHORTCUTS.items()):
         shortcut_action = action
         #populate the tree widget
         tree_data = [self.shortcuts_text[name],
             shortcut_action.toString(QKeySequence.NativeText), name]
         item = QTreeWidgetItem(self.result_widget, tree_data)
         item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
コード例 #47
0
 def fillInputsTree(self):
     icon = QIcon(os.path.join(pluginPath, 'images', 'input.png'))
     parametersItem = QTreeWidgetItem()
     parametersItem.setText(0, self.tr('Parameters'))
     for paramType in ModelerParameterDefinitionDialog.paramTypes:
         paramItem = QTreeWidgetItem()
         paramItem.setText(0, paramType)
         paramItem.setIcon(0, icon)
         paramItem.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled)
         parametersItem.addChild(paramItem)
     self.inputsTree.addTopLevelItem(parametersItem)
     parametersItem.setExpanded(True)
コード例 #48
0
ファイル: advanced.py プロジェクト: rubyu/ldoce5viewer
        def add_children(child_nodes, parent):
            children = []
            for node in child_nodes:
                twitem = QTreeWidgetItem((node['label'], ))
                twitem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                twitem.setCheckState(0, Qt.Unchecked)
                twitem.setData(0, Qt.UserRole, node)
                if 'children' in node:
                    add_children(node['children'], twitem)
                children.append(twitem)

            parent.addChildren(children)
コード例 #49
0
ファイル: MainWindow.py プロジェクト: DanielZorin/DataCenters
 def AddTenant(self):
     d = self.project.CreateTenant()
     it = QTreeWidgetItem(self.ui.tenants, QStringList(["New_tenant", self.tr("No"), self.tr("No")]))
     cb = QComboBox()
     cb.addItems([self.tr("No"),self.tr("Yes")])
     self.ui.tenants.setItemWidget(it,1,cb)
     QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged)
     it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
     self.tenants[it] = d
     self.ui.tenants.editItem(it)
     self.tenants[it].name = unicode(it.text(0))
     self.tenants[it].critical = False if self.ui.tenants.itemWidget(it,1).currentText() == self.tr("Yes") else True
     self.UpdateTenant(it)
コード例 #50
0
    def __init__(self, parent=None):
        super(OfflineDialog, self).__init__(parent)
        
        self.pagetitle = 'Offline Back Up' 
        stylesheet = Valid().background() + Valid().font()

        
        self.hold_data = {}
        self.tree = QTreeWidget()
        self.tree.setHeaderLabel("Choose Sessions to Back-up")
        self.tree.headerItem().setText(0, 'Name')
        #self.tree.setStyleSheet(treeStyleSheet)
        arr = Db().selectn('session','', 5)
        if arr and len(arr) > 0:
               for val in arr:
                 child = QTreeWidgetItem(self.tree)
                 child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
                 child.setText(0, str(val['name']).upper())
                 self.hold_data[val['id']] = child
                 child.setCheckState(0, Qt.Checked)
                
        
        
        self.pb = QPushButton()
        self.pb.setObjectName("Add")
        self.pb.setText("Save")
        
        self.pb1 = QPushButton()
        self.pb1.setObjectName("Cancel")
        self.pb1.setText("Close")
        
        hbo = QHBoxLayout()
        hbo.addWidget(self.pb1)
        hbo.addStretch()
        hbo.addWidget(self.pb)
        
        groupBox2 = QGroupBox('')
        groupBox2.setLayout(hbo)
            
        grid = QGridLayout()
        grid.addWidget(self.tree, 0, 0)
        grid.addWidget(groupBox2, 1, 0)
        
        self.setLayout(grid)
        self.connect(self.pb, SIGNAL("clicked()"), lambda: self.button_click())
        self.connect(self.pb1, SIGNAL("clicked()"), lambda: self.button_close(self))
        
        self.setStyleSheet(stylesheet)
        #self.setWindowIcon(QIcon(self.titleIcon))
        self.setWindowTitle(self.pagetitle)
コード例 #51
0
 def AddDemand(self):
     d = self.project.CreateDemand()
     it = QTreeWidgetItem(self.ui.demands, QStringList(["New_demand", "0", "1", self.tr("No"), self.tr("No")]))
     cb = QComboBox()
     cb.addItems([self.tr("No"),self.tr("Yes")])
     self.ui.demands.setItemWidget(it,3,cb)
     QObject.connect(cb, SIGNAL("currentIndexChanged(int)"), it.emitDataChanged)
     it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
     self.demands[it] = d
     self.ui.demands.editItem(it)
     self.demands[it].id = unicode(it.text(0))
     self.demands[it].startTime = int(it.text(1))
     self.demands[it].endTime = int(it.text(2))
     self.demands[it].critical = False if self.ui.demands.itemWidget(it,3).currentText() == self.tr("Yes") else True
コード例 #52
0
 def treeMenuSetupRecur(self, curStruct, parent=None):
     item = QTreeWidgetItem(parent)
     item.setText(0, curStruct["text"])
     if "flags" in curStruct:
         item.setFlags(curStruct["flags"])
     if "children" in curStruct:
         children = []
         for child in curStruct["children"]:
             children.append(self.treeMenuSetupRecur(child, item))
         item.addChildren(children)
     if "expanded" in curStruct:
         print(curStruct["expanded"])
         item.setExpanded(curStruct["expanded"])
         print(item.isExpanded())
     return item
コード例 #53
0
ファイル: program_utils.py プロジェクト: makerpc/brickv
    def add_item(self, texts, edit_item=False, select_item=False):
        item = QTreeWidgetItem(texts)
        item.setFlags(item.flags() | Qt.ItemIsEditable)

        self.tree_items.addTopLevelItem(item)

        if edit_item:
            self.tree_items.setCurrentItem(item)
            self.tree_items.setFocus()
            self.tree_items.editItem(item)
        elif select_item:
            self.tree_items.setCurrentItem(item)
            self.tree_items.setFocus()

        self.update_ui_state()
コード例 #54
0
    def populate(self):
        self.ui.treeWidget.setColumnCount(1)
        for pluginName, features in self.featureDict.iteritems():
            if pluginName == "TestFeatures" and not ilastik_config.getboolean(
                    "ilastik", "debug"):
                continue
            parent = QTreeWidgetItem(self.ui.treeWidget)
            parent.setText(0, pluginName)
            parent.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            # hack to ensure checkboxes visible
            parent.setCheckState(0, Qt.Checked)
            parent.setCheckState(0, Qt.Unchecked)
            parent.setExpanded(False)
            self.countChecked[pluginName] = 0
            self.countAll[pluginName] = len(self.featureDict[pluginName])
            advanced_names = []
            simple_names = []
            for name in sorted(features.keys()):
                parameters = features[name]
                if 'advanced' in parameters:
                    advanced_names.append(name)
                else:
                    simple_names.append(name)

            for name in simple_names + advanced_names:
                parameters = features[name]

                item = QTreeWidgetItem(parent)
                item.setText(0, name)
                item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                if 'tooltip' in parameters:
                    item.setToolTip(0, parameters['tooltip'])
                # hack to ensure checkboxes visible
                item.setCheckState(0, Qt.Checked)
                item.setCheckState(0, Qt.Unchecked)
                if pluginName in self.selectedFeatures:
                    if name in self.selectedFeatures[pluginName]:
                        item.setCheckState(0, Qt.Checked)
                        self.countChecked[pluginName] += 1
            if self.countChecked[pluginName] == 0:
                parent.setCheckState(0, Qt.Unchecked)
            elif self.countChecked[pluginName] == self.countAll[pluginName]:
                parent.setCheckState(0, Qt.Checked)
            else:
                parent.setCheckState(0, Qt.PartiallyChecked)
            self.updateToolTip(parent)
        # facilitates switching of the CheckBox when clicking on the Text of a QTreeWidgetItem
        self.ui.treeWidget.setCurrentItem(None)
コード例 #55
0
    def createSeparatorItem(self):
        """
        Creates a new separator item.
        
        :return     <QTreeWidgetItem>
        """
        item = QTreeWidgetItem(['                                    '])
        font = item.font(0)
        font.setStrikeOut(True)
        item.setFont(0, font)
        item.setData(0, Qt.UserRole, qt.wrapVariant('separator'))
        flags = item.flags()
        flags ^= Qt.ItemIsDropEnabled
        item.setFlags(flags)

        return item
コード例 #56
0
 def createSeparatorItem( self ):
     """
     Creates a new separator item.
     
     :return     <QTreeWidgetItem>
     """
     item = QTreeWidgetItem(['                                    '])
     font = item.font(0)
     font.setStrikeOut(True)
     item.setFont(0, font)
     item.setData(0, Qt.UserRole, qt.wrapVariant('separator'))
     flags = item.flags()
     flags ^= Qt.ItemIsDropEnabled
     item.setFlags(flags)
     
     return item
コード例 #57
0
ファイル: initialconditions.py プロジェクト: economou/gpunit
    def setupDialog(self):
        for particle in self.particles:
            pos = particle.position.number
            vel = particle.velocity.number
            mass = particle.mass.number
            radius = particle.radius.number

            item = QTreeWidgetItem((
                str(pos[0]), str(pos[1]), str(pos[2]), str(particle.position.unit),
                str(vel[0]), str(vel[1]), str(vel[2]), str(particle.velocity.unit),
                str(mass), str(particle.mass.unit),
                str(radius), str(particle.radius.unit)
                ))

            item.setFlags(item.flags() | Qt.ItemIsEditable)
            self.ui.particlesTree.addTopLevelItem(item)
コード例 #58
0
 def setData(self, project):
     self.project = project
     self.canvas.Clear()
     r = self.project.resources.GetTimeBounds()
     self.time = r[0]
     self.ui.timeSpinBox.setValue(r[0])
     self.ui.timeSpinBox.setMinimum(r[0])
     self.ui.timeSpinBox.setMaximum(r[1])
     self.ui.timeSlider.setValue(r[0])
     self.ui.timeSlider.setMinimum(r[0])
     self.ui.timeSlider.setMaximum(r[1])
     self.ui.info.setText("")
     timeInt = self.project.resources.GetTimeInterval(self.time)
     self.ui.assignedDemands.clear()
     for d in self.project.demands:
         if d.assigned and (d.startTime <= self.time) and (d.endTime >=
                                                           self.time):
             it = QTreeWidgetItem(self.ui.assignedDemands, [d.id])
             it.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
     self.canvas.Visualize(self.project.resources, timeInt)
コード例 #59
0
 def AddDemand(self):
     d = self.project.CreateDemand()
     it = QTreeWidgetItem(
         self.ui.demands,
         QStringList(["New_demand", "0", "1",
                      self.tr("No"),
                      self.tr("No")]))
     cb = QComboBox()
     cb.addItems([self.tr("No"), self.tr("Yes")])
     self.ui.demands.setItemWidget(it, 3, cb)
     QObject.connect(cb, SIGNAL("currentIndexChanged(int)"),
                     it.emitDataChanged)
     it.setFlags(Qt.ItemIsEditable | Qt.ItemIsEnabled | Qt.ItemIsSelectable)
     self.demands[it] = d
     self.ui.demands.editItem(it)
     self.demands[it].id = unicode(it.text(0))
     self.demands[it].startTime = int(it.text(1))
     self.demands[it].endTime = int(it.text(2))
     self.demands[it].critical = False if self.ui.demands.itemWidget(
         it, 3).currentText() == self.tr("Yes") else True
コード例 #60
0
    def populate(self):
        self.ui.treeWidget.setColumnCount(1)
        for pluginName, features in self.featureDict.iteritems():
            if pluginName == "TestFeatures" and not ilastik_config.getboolean(
                    "ilastik", "debug"):
                continue

            parent = QTreeWidgetItem(self.ui.treeWidget)
            if pluginName == "Standard Object Features":
                parent.setText(0, pluginName)
                parent.setToolTip(
                    0,
                    'http://hci.iwr.uni-heidelberg.de/vigra/doc/vigra/group__FeatureAccumulators.html'
                )
            else:
                parent.setText(0, pluginName)
            parent.setExpanded(True)
            advanced_names = []
            simple_names = []
            for name in sorted(features.keys()):
                parameters = features[name]
                if 'advanced' in parameters:
                    advanced_names.append(name)
                else:
                    simple_names.append(name)

            for name in simple_names + advanced_names:
                parameters = features[name]

                item = QTreeWidgetItem(parent)
                item.setText(0, name)
                item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
                if 'tooltip' in parameters:
                    item.setToolTip(0, parameters['tooltip'])
                # hack to ensure checkboxes visible
                item.setCheckState(0, Qt.Checked)
                item.setCheckState(0, Qt.Unchecked)

                if pluginName in self.selectedFeatures:
                    if name in self.selectedFeatures[pluginName]:
                        item.setCheckState(0, Qt.Checked)