Exemplo n.º 1
0
    def fill_projects_to_menu(self):

        all_projects_dicts = []

        for project_name, project in env_inst.projects.iteritems():
            all_projects_dicts.append(project.info)

        projects_by_categories = gf.group_dict_by(all_projects_dicts, 'category')

        for cat_name, projects in projects_by_categories.iteritems():
            if cat_name:
                cat_name = gf.prettify_text(cat_name, True)
            else:
                cat_name = 'No Category'
            if cat_name != 'Template':
                category = self.menuProject.addMenu(cat_name)

            for e, project in enumerate(projects):
                if not project.get('is_template'):
                    project_code = project.get('code')

                    menu_action = QtGui.QAction(self)
                    menu_action.setCheckable(True)

                    if self.opened_projects:
                        if project_code in self.opened_projects:
                            menu_action.setChecked(True)
                    menu_action.setText(project.get('title'))
                    # Don't know why lambda did not work here
                    menu_action.triggered.connect(partial(self.create_project_dock, project_code))
                    category.addAction(menu_action)
Exemplo n.º 2
0
    def initial_fill(self):

        self.tree_widget.clear()

        all_projects_dicts = []

        for project_name, project in env_inst.projects.items():
            if project.get_code() != 'sthpw':
                all_projects_dicts.append(project.info)

        projects_by_categories = gf.group_dict_by(all_projects_dicts, 'category')

        for cat_name, projects in projects_by_categories.items():

            if cat_name:
                cat_name = gf.prettify_text(cat_name, True)
            else:
                cat_name = 'No Category'

            item_info = {
                'title': cat_name,
                'item_type': 'cat',
            }

            gf.add_project_item(
                tree_widget=self.tree_widget,
                projects=projects,
                item_info=item_info,
            )

        self.tree_widget.resizeColumnToContents(0)
    def add_items_to_stypes_tree(self):
        exclude_list = self.get_ignore_stypes_list()
        self.stypes_tree_widget.clear()

        all_stypes = []

        for stype in env_inst.projects[
                self.project.get_code()].stypes.itervalues():
            all_stypes.append(stype.info)

        grouped = gf.group_dict_by(all_stypes, 'type')

        for type_name, value in grouped.items():
            top_item = QtGui.QTreeWidgetItem()

            if not type_name:
                type_name = 'No Category'
            top_item.setText(0, type_name.capitalize())
            top_item.setCheckState(0, QtCore.Qt.Checked)
            self.stypes_tree_widget.addTopLevelItem(top_item)
            for item in value:
                child_item = QtGui.QTreeWidgetItem()

                stype = env_inst.projects[self.project.get_code()].stypes.get(
                    item.get('code'))

                item_code = stype.get_code()
                child_item.setText(0, stype.get_pretty_name())
                child_item.setText(1, item_code)
                child_item.setData(0, QtCore.Qt.UserRole, item)
                child_item.setCheckState(0, QtCore.Qt.Checked)
                if exclude_list:
                    if item_code in exclude_list:
                        child_item.setCheckState(0, QtCore.Qt.Unchecked)
                top_item.addChild(child_item)

            top_item.setExpanded(True)