def __init__(self): QWidget.__init__(self) # Current case id self.__step_id = None self.__win_operate = ViewOperate() # Model self.__model = StepDetModel() self.__model.usr_set_definition(def_view_step) # Control _control = StepDetControl(def_view_step) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Context menu _menu_def = [ dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data") ] _wid_display.create_context_menu(_menu_def) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK") ], "VER") # win_add self.__win_add = ViewAdd(def_view_step) self.__win_add.sig_operate.connect(self.__win_operate.show) self.__win_operate.sig_submit.connect(self.get_operate) # win add data self.__win_data = ViewDataAdd() # Layout _layout = QHBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) self.__win_add.sig_submit.connect(self.add) _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data)
def __init__(self): """ :return: """ ViewAdd.__init__(self, def_view_data) self.__service = DataService() self.__id = None self.sig_submit.connect(self.__save)
def __init__(self): QWidget.__init__(self) self.title = u"数据管理" # Model self.__model = DataModel() self.__model.usr_set_definition(def_view_data) # Control _control = DataControl(def_view_data) # Search condition widget self.__wid_search_cond = ViewSearch(def_view_data) self.__wid_search_cond.set_col_num(3) self.__wid_search_cond.create() # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK"), dict(id="search", name=u"查询") ]) # win_add self.__win_add = ViewAdd(def_view_data) # Layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) self.__win_add.sig_submit[dict].connect(self.add)
def __init__(self): QWidget.__init__(self) # Current page id self.__page_id = None # Model self.__model = PageDetModel() self.__model.usr_set_definition(def_view_page_det) # Control _control = PageDetControl(def_view_page_det) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK") ]) # win_add self.__win_add = ViewAdd(def_view_page_det) # Layout _layout = QVBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) _wid_display.clicked[QModelIndex].connect(self.__page_select) self.__win_add.sig_submit[dict].connect(self.add)
def __init__(self, p_type=None): QWidget.__init__(self) self.title = u"选择用例" self.__type = "MULTI" if p_type is None else p_type # Model self.__model = CaseSelModel() self.__model.usr_set_definition(def_view_case_def) if "SINGLE" == self.__type: self.__model.usr_chk_able() # Control _control = CaseSelControl(def_view_case_def) # Search condition widget self.__wid_search_cond = ViewSearch(def_view_case_def) self.__wid_search_cond.set_col_num(2) self.__wid_search_cond.create() # Data result display widget _wid_display = ViewTree() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Buttons widget if "SINGLE" == self.__type: button_def = [] else: button_def = [dict(id="select", name=u"选择")] button_def.extend([ dict(id="search", name=u"查询"), dict(id="cancel", name=u"取消")]) _wid_buttons = ViewButtons(button_def) # win_add self.__win_add = ViewAdd(def_view_case_def) # Layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) _wid_display.clicked.connect(self.__model.usr_set_current_data) _wid_display.doubleClicked.connect(self.__select_one)
def __init__(self): QWidget.__init__(self) self.title = u"选择用例" # Model self.__model = CaseSelModel() self.__model.usr_set_definition(def_view_case_def) # Control _control = CaseSelControl(def_view_case_def) # Search condition widget self.__wid_search_cond = ViewSearch(def_view_case_def) self.__wid_search_cond.set_col_num(2) self.__wid_search_cond.create() # Data result display widget _wid_display = ViewTree() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Buttons widget _wid_buttons = ViewButtons([ dict(id="select", name=u"选择"), dict(id="search", name=u"查询"), dict(id="cancel", name=u"取消") ]) # win_add self.__win_add = ViewAdd(def_view_case_def) # Layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate)
class ViewBatchDefMag(QWidget): sig_batch_det = OrcSignal(dict) def __init__(self): QWidget.__init__(self) self.title = u"计划管理" self.__service = BatchDefService() # Model self.__model = BatchDefModel() self.__model.usr_set_definition(def_view_batch_def) # Control _control = BatchDefControl(def_view_batch_def) # Search condition widget self.__wid_search_cond = ViewSearch(def_view_batch_def) self.__wid_search_cond.create() # Data result display widget _wid_display = ViewTree() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Context menu _wid_display.create_context_menu([ dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data"), dict(NAME=u"添加至运行", STR="sig_run") ]) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK"), dict(id="search", name=u"查询") ]) # win_add self.__win_add = ViewAdd(def_view_batch_def) # win add data self.__win_data = ViewDataAdd() # Layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) self.__win_add.sig_submit[dict].connect(self.add) _wid_display.doubleClicked[QModelIndex].connect(self.__batch_detail) _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data) def search(self): self.__model.usr_search(self.__wid_search_cond.get_cond()) def add(self, p_data): self.__model.usr_add(p_data) def __operate(self, p_flag): if "add" == p_flag: self.__win_add.show() elif "delete" == p_flag: self.__model.usr_delete() elif "update" == p_flag: self.__model.usr_editable() elif "search" == p_flag: self.search() else: pass def __batch_detail(self, p_index): if not self.__model.usr_get_editable(): _id = self.__model.usr_get_node(p_index).content["id"] _no = self.__model.usr_get_node(p_index).content["batch_no"] _data = dict(id=_id, no=_no) self.sig_batch_det[dict].emit(_data) def __context(self, p_flag): if "sig_data" == p_flag: _data = self.__model.usr_get_current_data() _path = _data.content["batch_no"] _id = _data.content["id"] self.__win_data.show() self.__win_data.set_type("BATCH") self.__win_data.set_path(_path) self.__win_data.set_id(_id) elif "sig_run" == p_flag: batch_id = self.__model.usr_get_current_data().content["id"] self.__service.add_to_run(batch_id)
def __init__(self, p_type=None): """ 支持选择类型,选择时按钮/查询条件/查询方式都有不同 :param p_type: :return: """ QWidget.__init__(self) self.__type = p_type # Model self.__model = WidgetDefModel() self.__model.usr_set_definition(def_view_widget_def) # Control _control = WidgetDefControl(def_view_widget_def) # Search if self.__type is not None: self.__wid_search_cond = ViewSearch(def_view_widget_def) self.__wid_search_cond.set_col_num(2) self.__wid_search_cond.create() else: self.__wid_search_cond = None # Data result display widget _wid_display = ViewTree() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Buttons window btn_definition = [] if self.__type is None: btn_definition.append(dict(id="add", name=u'增加')), btn_definition.append(dict(id="delete", name=u"删除")) btn_definition.append(dict(id="update", name=u"修改", type="CHECK")) btn_definition.append(dict(id="search", name=u"查询")) _wid_buttons = ViewButtons(btn_definition) _wid_buttons.align_back() # win_add self.__win_add = ViewAdd(def_view_widget_def) # Layout _layout = QVBoxLayout() if self.__type is not None: _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # connection self.__win_add.sig_submit[dict].connect(self.add) _wid_buttons.sig_clicked.connect(self.__operate) if self.__type is None: _wid_display.clicked[QModelIndex].connect(self.__widget_detail) else: _wid_display.doubleClicked[QModelIndex].connect( self.__widget_detail)
class ViewWidgetDef(QWidget): sig_selected = OrcSignal(str) sig_search = OrcSignal() sig_delete = OrcSignal() def __init__(self, p_type=None): """ 支持选择类型,选择时按钮/查询条件/查询方式都有不同 :param p_type: :return: """ QWidget.__init__(self) self.__type = p_type # Model self.__model = WidgetDefModel() self.__model.usr_set_definition(def_view_widget_def) # Control _control = WidgetDefControl(def_view_widget_def) # Search if self.__type is not None: self.__wid_search_cond = ViewSearch(def_view_widget_def) self.__wid_search_cond.set_col_num(2) self.__wid_search_cond.create() else: self.__wid_search_cond = None # Data result display widget _wid_display = ViewTree() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Buttons window btn_definition = [] if self.__type is None: btn_definition.append(dict(id="add", name=u'增加')), btn_definition.append(dict(id="delete", name=u"删除")) btn_definition.append(dict(id="update", name=u"修改", type="CHECK")) btn_definition.append(dict(id="search", name=u"查询")) _wid_buttons = ViewButtons(btn_definition) _wid_buttons.align_back() # win_add self.__win_add = ViewAdd(def_view_widget_def) # Layout _layout = QVBoxLayout() if self.__type is not None: _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # connection self.__win_add.sig_submit[dict].connect(self.add) _wid_buttons.sig_clicked.connect(self.__operate) if self.__type is None: _wid_display.clicked[QModelIndex].connect(self.__widget_detail) else: _wid_display.doubleClicked[QModelIndex].connect( self.__widget_detail) def __operate(self, p_flg): if "add" == p_flg: self.__win_add.show() elif "delete" == p_flg: self.__model.usr_delete() self.sig_delete.emit() elif "update" == p_flg: self.__model.usr_editable() elif "search" == p_flg: if self.__type is None: self.sig_search.emit() else: _cond = self.__wid_search_cond.get_cond() self.search(_cond) else: pass def search(self, p_cond): self.__model.usr_search(p_cond) def add(self, p_data): self.__model.usr_add(p_data) def __widget_detail(self, p_index): _widget_id = self.__model.usr_get_node(p_index).content["id"] self.sig_selected[str].emit(str(_widget_id))
class ViewStepDetMag(QWidget): def __init__(self): QWidget.__init__(self) # Current case id self.__step_id = None self.__win_operate = ViewOperate() # Model self.__model = StepDetModel() self.__model.usr_set_definition(def_view_step) # Control _control = StepDetControl(def_view_step) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Context menu _menu_def = [ dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data") ] _wid_display.create_context_menu(_menu_def) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK") ], "VER") # win_add self.__win_add = ViewAdd(def_view_step) self.__win_add.sig_operate.connect(self.__win_operate.show) self.__win_operate.sig_submit.connect(self.get_operate) # win add data self.__win_data = ViewDataAdd() # Layout _layout = QHBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) self.__win_add.sig_submit.connect(self.add) _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data) def add_show(self): if self.__step_id is not None: self.__win_add.show() def add(self, p_data): _data = p_data _data["step_id"] = self.__step_id self.__model.usr_add(_data) def set_step_id(self, p_step_id): self.__step_id = p_step_id self.__model.usr_search({"step_id": self.__step_id}) def clean(self): self.__step_id = None self.__model.usr_clean() def __operate(self, p_flag): if "add" == p_flag: self.__win_add.show() elif "delete" == p_flag: self.__model.usr_delete() elif "update" == p_flag: self.__model.usr_editable() else: pass def __context(self, p_flag): if "sig_data" == p_flag: _path = self.__model.usr_get_current_data()["item_no"] self.__win_data.show() self.__win_data.set_type("ITEM") self.__win_data.set_id(_path) def get_operate(self, p_data): # self. Todo self.__win_add.set_data("item_operate", p_data)
def __init__(self, p_id): QWidget.__init__(self) self.__case_id = p_id # Model self.__model = CaseDetModel() self.__model.usr_set_definition(def_view_case_det) self.__model.usr_search({"case_id": self.__case_id}) # Control _control = CaseDetControl(def_view_case_det) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # 界面列宽自适应 # _wid_display.resizeColumnsToContents() # Context menu _menu_def = [ dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data") ] _wid_display.create_context_menu(_menu_def) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK") ], "VER") # win_add self.__win_add = ViewAdd(def_view_case_det) # win add data self.__win_data = ViewDataAdd() # Layout _layout = QHBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) _wid_display.clicked.connect(self.__selected) self.__win_add.sig_submit.connect(self.add) _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data)
def __init__(self): QWidget.__init__(self) self.__step_id = None self.__service_step_def = StepService() # Current case id self.__step_type = None self.__win_operate = ViewOperate() # Model self.__model = ItemModel() self.__model.usr_set_definition(def_view_item) # Control _control = ItemControl(def_view_item) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Context menu _menu_def = [dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data")] _wid_display.create_context_menu(_menu_def) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK") ], "VER") # 新增 item 窗口 self.__win_add_item = ViewAdd(def_view_item) # 新增 func 窗口 self.__win_add_func = ViewCaseSelMag("SINGLE") # win add data self.__win_data = ViewDataAdd() # Layout _layout = QHBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection self.__win_add_item.sig_operate.connect(self.__win_operate.show) # 显示操作选择框 self.__win_add_item.sig_submit.connect(self.add_item) # 新增 self.__win_add_func.sig_selected.connect(self.add_func) # 新增 self.__win_operate.sig_submit.connect(self.get_operate) _wid_buttons.sig_clicked.connect(self.__operate) # 按钮点击 _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data) # 单击
class ItemView(QWidget): def __init__(self): QWidget.__init__(self) self.__step_id = None self.__service_step_def = StepService() # Current case id self.__step_type = None self.__win_operate = ViewOperate() # Model self.__model = ItemModel() self.__model.usr_set_definition(def_view_item) # Control _control = ItemControl(def_view_item) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Context menu _menu_def = [dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data")] _wid_display.create_context_menu(_menu_def) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK") ], "VER") # 新增 item 窗口 self.__win_add_item = ViewAdd(def_view_item) # 新增 func 窗口 self.__win_add_func = ViewCaseSelMag("SINGLE") # win add data self.__win_data = ViewDataAdd() # Layout _layout = QHBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection self.__win_add_item.sig_operate.connect(self.__win_operate.show) # 显示操作选择框 self.__win_add_item.sig_submit.connect(self.add_item) # 新增 self.__win_add_func.sig_selected.connect(self.add_func) # 新增 self.__win_operate.sig_submit.connect(self.get_operate) _wid_buttons.sig_clicked.connect(self.__operate) # 按钮点击 _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data) # 单击 def add_show(self): if self.__step_id is not None: _type = self.__service_step_def.view_get_step_type(self.__step_id) if "FUNC" == _type: self.__win_add_func.show() elif "NORMAL" == _type: self.__win_add_item.show() else: pass def add_item(self, p_data): _data = dict( type="ITEM", step_id=self.__step_id, data=p_data ) self.__model.usr_add(_data) def add_func(self, p_data): _data = dict( type="FUNC", step_id=self.__step_id, data=p_data[0], ) self.__model.usr_add(_data) def set_step_id(self, p_step_id): self.__step_id = p_step_id self.__model.usr_search({"step_id": self.__step_id}) def clean(self): self.__step_id = None self.__model.usr_clean() def __operate(self, p_flag): if "add" == p_flag: self.add_show() elif "delete" == p_flag: self.__model.usr_delete() elif "update" == p_flag: self.__model.usr_editable() else: pass def __context(self, p_flag): if "sig_data" == p_flag: _path = self.__model.usr_get_current_data()["item_no"] self.__win_data.show() self.__win_data.set_type("ITEM") self.__win_data.set_id(_path) def get_operate(self, p_data): # self. Todo self.__win_add_item.set_data("item_operate", p_data)
class ViewPageDefMag(QWidget): sig_selected = OrcSignal(str) sig_search = OrcSignal() sig_delete = OrcSignal() def __init__(self): QWidget.__init__(self) self.title = u"用例管理" # Model self.__model = PageDefModel() self.__model.usr_set_definition(def_view_page_def) # Control _control = PageDefControl(def_view_page_def) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK"), dict(id="search", name=u"查询") ]) # win_add self.__win_add = ViewAdd(def_view_page_def) # Layout _layout = QVBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) self.__win_add.sig_submit[dict].connect(self.add) _wid_display.clicked[QModelIndex].connect(self.__page_detail) def search(self, p_cond): self.__model.usr_search(p_cond) def add(self, p_data): self.__model.usr_add(p_data) def __operate(self, p_flag): if "add" == p_flag: self.__win_add.show() elif "delete" == p_flag: self.__model.usr_delete() self.sig_delete.emit() elif "update" == p_flag: self.__model.usr_editable() elif "search" == p_flag: self.sig_search.emit() else: pass def __page_detail(self, p_index): _page_id = self.__model.usr_get_data(p_index.row())["id"] self.sig_selected[str].emit(str(_page_id))
class ViewCaseDefMag(QWidget): sig_case_det = OrcSignal(dict) def __init__(self): QWidget.__init__(self) self.title = u"用例管理" self.__service = CaseDefService() # Model self.__model = CaseDefModel() self.__model.usr_set_definition(def_view_case_def) # Control _control = CaseDefControl(def_view_case_def) # Search condition widget self.__wid_search_cond = ViewSearch(def_view_case_def) self.__wid_search_cond.set_col_num(2) self.__wid_search_cond.create() # Data result display widget _wid_display = ViewTree() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Context menu _wid_display.create_context_menu([ dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data"), dict(NAME=u"添加至运行", STR="sig_run") ]) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK"), dict(id="search", name=u"查询") ]) # win add case self.__win_add = ViewAdd(def_view_case_def) # 选择控件 self.__win_widget_select = ViewWidgetSelect() # win add data self.__win_data = ViewDataAdd() # Layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) self.__win_add.sig_submit[dict].connect(self.add) # 增加用例 _wid_display.doubleClicked[QModelIndex].connect( self.__case_detail) # 打开用例详情窗 _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data) self.__win_data.widgets["data_flag"]["WIDGET"].clicked.connect( self.__win_widget_select.show) self.__win_widget_select.sig_selected.connect(self.set_widget) def set_widget(self, p_data): self.__win_data.set_data("data_flag", p_data["id"]) def search(self): """ 查询 :return: """ self.__model.usr_search(self.__wid_search_cond.get_cond()) def add(self, p_data): """ 增加用例 :param p_data: :return: """ self.__model.usr_add(p_data) def __operate(self, p_flag): if "add" == p_flag: self.__win_add.show() elif "delete" == p_flag: self.__model.usr_delete() elif "update" == p_flag: self.__model.usr_editable() elif "search" == p_flag: self.search() else: pass def __case_detail(self, p_index): if not self.__model.usr_get_editable(): _id = self.__model.usr_get_node(p_index).content["id"] _no = self.__model.usr_get_node(p_index).content["case_no"] _data = {"id": _id, "no": _no} self.sig_case_det[dict].emit(_data) def __context(self, p_flag): if "sig_data" == p_flag: _path = self.__model.usr_get_current_data().content["case_path"] _id = self.__model.usr_get_current_data().content["id"] self.__win_data.show() self.__win_data.set_type("CASE") self.__win_data.set_path(_path) self.__win_data.set_id(_id) # self.__win_data.set_enable("data_flag", False) elif "sig_run" == p_flag: case_id = self.__model.usr_get_current_data().content["id"] self.__service.add_to_run(case_id)
def __init__(self): QWidget.__init__(self) self.title = u"计划管理" self.__service = BatchDefService() # Model self.__model = BatchDefModel() self.__model.usr_set_definition(def_view_batch_def) # Control _control = BatchDefControl(def_view_batch_def) # Search condition widget self.__wid_search_cond = ViewSearch(def_view_batch_def) self.__wid_search_cond.create() # Data result display widget _wid_display = ViewTree() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Context menu _wid_display.create_context_menu([ dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data"), dict(NAME=u"添加至运行", STR="sig_run") ]) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK"), dict(id="search", name=u"查询") ]) # win_add self.__win_add = ViewAdd(def_view_batch_def) # win add data self.__win_data = ViewDataAdd() # Layout _layout = QVBoxLayout() _layout.addWidget(self.__wid_search_cond) _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) self.__win_add.sig_submit[dict].connect(self.add) _wid_display.doubleClicked[QModelIndex].connect(self.__batch_detail) _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data)
class ViewWidgetDetMag(QWidget): def __init__(self): QWidget.__init__(self) # Current widget id self.__widget_id = None # Model self.__model = WidgetDetModel() self.__model.usr_set_definition(def_view_widget_det) # Control _control = WidgetDetControl(def_view_widget_det) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK") ]) # win_add self.__win_add = ViewAdd(def_view_widget_det) # Layout _layout = QVBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) self.__win_add.sig_submit[dict].connect(self.add) def add_show(self): if self.__widget_id is not None: self.__win_add.show() def add(self, p_data): _data = p_data _data["widget_id"] = self.__widget_id self.__model.usr_add(_data) def set_widget_id(self, p_widget_id): self.__widget_id = p_widget_id self.__model.usr_search({"widget_id": self.__widget_id}) def clean(self): self.__widget_id = None self.__model.usr_clean() def __operate(self, p_flag): if "add" == p_flag: self.__win_add.show() elif "delete" == p_flag: self.__model.usr_delete() elif "update" == p_flag: self.__model.usr_editable() else: pass
class ViewCaseDetMag(QWidget): sig_select = OrcSignal(str) sig_search = OrcSignal() sig_delete = OrcSignal() def __init__(self, p_id): QWidget.__init__(self) self.__case_id = p_id # Model self.__model = CaseDetModel() self.__model.usr_set_definition(def_view_case_det) self.__model.usr_search({"case_id": self.__case_id}) # Control _control = CaseDetControl(def_view_case_det) # Data result display widget _wid_display = ViewTable() _wid_display.set_model(self.__model) _wid_display.set_control(_control) # 界面列宽自适应 # _wid_display.resizeColumnsToContents() # Context menu _menu_def = [ dict(NAME=u"增加", STR="sig_add"), dict(NAME=u"删除", STR="sig_del"), dict(NAME=u"增加数据", STR="sig_data") ] _wid_display.create_context_menu(_menu_def) # Buttons widget _wid_buttons = ViewButtons([ dict(id="add", name=u"增加"), dict(id="delete", name=u"删除"), dict(id="update", name=u"修改", type="CHECK") ], "VER") # win_add self.__win_add = ViewAdd(def_view_case_det) # win add data self.__win_data = ViewDataAdd() # Layout _layout = QHBoxLayout() _layout.addWidget(_wid_display) _layout.addWidget(_wid_buttons) _layout.setContentsMargins(0, 0, 0, 0) self.setLayout(_layout) # Connection _wid_buttons.sig_clicked.connect(self.__operate) _wid_display.clicked.connect(self.__selected) self.__win_add.sig_submit.connect(self.add) _wid_display.sig_context.connect(self.__context) # 右键菜单 _wid_display.clicked.connect(self.__model.usr_set_current_data) def add(self, p_data): _data = dict(case_det={"case_id": self.__case_id}, step=p_data) self.__model.usr_add(_data) def __operate(self, p_flag): if "add" == p_flag: self.__win_add.show() elif "delete" == p_flag: self.__model.usr_delete() self.sig_delete.emit() elif "update" == p_flag: self.__model.usr_editable() else: pass def __selected(self, p_index): _index = p_index.row() _step_id = self.__model.usr_get_data(_index)["step_id"] self.sig_select.emit(str(_step_id)) def __context(self, p_flag): if "sig_data" == p_flag: _path = self.__model.usr_get_current_data()["step_no"] self.__win_data.show() self.__win_data.set_type("STEP") self.__win_data.set_id(_path)