def fill_multiple_tasks(self, query_result): if query_result: for code, tasks_sobjects in query_result.items(): groupped_tasks_sobjects = tc.group_sobject_by( tasks_sobjects, 'process') for task_widget in self.task_widgets_list: task_widget.add_tasks_sobjects( groupped_tasks_sobjects.get(task_widget.get_process()), self.sobjects_list) for task_widget in self.task_widgets_list: task_widget.init_with_multiple_tasks()
def fill_sctipts_tree_widget(self, async_run=True): # getting all the scripts from db # if async_run: # scripts_sobjects = yield env_inst.async_task(tc.get_custom_scripts) # else: scripts_sobjects = tc.get_custom_scripts() if scripts_sobjects: scripts_sobjects_by_folder = tc.group_sobject_by( scripts_sobjects, 'folder') # adding scripts to tree widget for folder_path, sobjects_list in scripts_sobjects_by_folder.items( ): paths_list = folder_path.split('/') exist_item = gf.check_tree_items_exists( self.scripts_tree_widget, paths_list[0]) if len(paths_list) > 1: paths_list.reverse() top_item_title = paths_list.pop() if exist_item: gf.recursive_add_items(exist_item, paths_list, sobjects_list) else: root_item = QtGui.QTreeWidgetItem( self.scripts_tree_widget) root_item.setText(0, top_item_title) root_item.setData(0, 12, top_item_title) root_item.setData(0, QtCore.Qt.UserRole, sobjects_list) root_item.setIcon( 0, gf.get_icon('folder', icons_set='mdi')) gf.recursive_add_items(root_item, paths_list, sobjects_list) self.scripts_tree_widget.addTopLevelItem(root_item) else: if exist_item: for sobject in sobjects_list: gf.add_child_items(exist_item, sobject) else: root_item = QtGui.QTreeWidgetItem( self.scripts_tree_widget) root_item.setText(0, folder_path) root_item.setData(0, 12, folder_path) root_item.setData(0, QtCore.Qt.UserRole, sobjects_list) root_item.setIcon( 0, gf.get_icon('folder', icons_set='mdi')) self.scripts_tree_widget.addTopLevelItem(root_item) for sobject in sobjects_list: gf.add_child_items(root_item, sobject)
def fill_notes(self, query_result): self.notes_sobjects, info = query_result notes_sobjects = list(self.notes_sobjects.values()) self.create_scroll_area() self.current_user = env_server.get_user() self.widgets_list = [] task_status_log = [] current_task_sobject = None if self.task_widget: current_task_sobject = self.task_widget.get_current_task_sobject() if current_task_sobject: task_status_log = current_task_sobject.get_status_log() status_and_notes = task_status_log + notes_sobjects status_and_notes_sorted = tc.group_sobject_by(status_and_notes, 'timestamp') for date, sobject in status_and_notes_sorted: # almost not possible to have same timestamp, so skip checking sobject = sobject[0] if sobject.info['login'] == self.current_user: message_type = 'out' else: message_type = 'in' if sobject.get_plain_search_type() == 'sthpw/note': note_widget = Ui_messageWidget(sobject, message_type, self.sobject, current_task_sobject, self) note_widget.show() self.lay.addWidget(note_widget) self.widgets_list.append(note_widget) else: status_widget = Ui_statusWidget(sobject, message_type, self.sobject, current_task_sobject, self) status_widget.show() self.lay.addWidget(status_widget) self.widgets_list.append(status_widget) if self.widgets_list: QtGui.QApplication.processEvents() self.conversationScrollArea.setWidgetResizable(True) self.conversationScrollArea.ensureWidgetVisible( self.widgets_list[-1]) self.resize(0, 0)
def fill_tasks(self, query_result): self.tasks_sobjects, info = query_result self.create_filler_tasks() groupped_tasks_sobjects = tc.group_sobject_by(self.tasks_sobjects, 'process') for process, task_sobjects in groupped_tasks_sobjects.items(): for task_widget in self.task_widgets_list: if task_widget.get_process() == process: task_widget.set_tasks_sobjects(task_sobjects) self.set_dock_title(u'Tasks For: {0}'.format(self.sobject.get_title()))
def create_assets_tree(self): stypes = env_inst.get_current_stypes() self.asstes_tree = tc.group_sobject_by(stypes, 'type') # self.asstes_tree = tc.query_assets_names() for name, value in self.asstes_tree.items(): self.top_item = QtGui.QTreeWidgetItem() if not name: name = 'Untyped' self.top_item.setText(0, name.capitalize()) self.assetsTreeWidget.addTopLevelItem(self.top_item) for item in value: # print(item) self.child_item = QtGui.QTreeWidgetItem() if item.info['title']: item_title = item.info['title'].capitalize() else: item_title = 'Unnamed' self.child_item.setText(0, item_title) self.child_item.setData(0, QtCore.Qt.UserRole, item.info) self.top_item.addChild(self.child_item)