Пример #1
0
class ViewWidgetSelect(QWidget):

    sig_selected = OrcSignal(dict)

    def __init__(self):

        QWidget.__init__(self)

        # Model
        self.__model = WidgetSelectModel()
        self.__model.usr_set_definition(def_view_widget_def)
        self.__model.usr_chk_able()

        # Control
        _control = WidgetSelectControl(def_view_widget_def)

        # Search condition widget
        self.__wid_search_cond = ViewSearch(def_view_widget_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="search", name=u"查询")])

        # 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.doubleClicked.connect(self.select)

    def search(self):
        _cond = self.__wid_search_cond.get_cond()
        self.__model.usr_search(_cond)

    def select(self, p_index):
        _node = self.__model.usr_get_node(p_index).content
        _id = _node["id"]
        _path = _node["widget_path"]
        _type = _node["widget_type"]
        self.sig_selected.emit(dict(id=str(_id), flag=_path, type=_type))
        self.close()

    def __operate(self, p_flag):

        if "search" == p_flag:
            self.search()
        else:
            pass
Пример #2
0
class PageContainer(QWidget):

    sig_selected = OrcSignal(str)

    def __init__(self):

        QWidget.__init__(self)

        self.title = u"页面"

        # Search condition widget
        self.__wid_search_cond = ViewSearch(def_view_page_def)
        self.__wid_search_cond.set_col_num(2)
        self.__wid_search_cond.create()

        # Column widget
        self.__wid_page_def = ViewPageDefMag()
        self.__wid_page_det = ViewPageDetMag()

        # Bottom layout
        _layout_bottom = QHBoxLayout()
        _layout_bottom.addWidget(self.__wid_page_def)
        _layout_bottom.addWidget(self.__wid_page_det)

        # Main layout
        _layout_main = QVBoxLayout()
        _layout_main.addWidget(self.__wid_search_cond)
        _layout_main.addLayout(_layout_bottom)

        _layout_main.setContentsMargins(0, 0, 0, 0)
        _layout_main.setSpacing(0)

        self.setLayout(_layout_main)

        self.__wid_page_def.sig_selected.connect(
            self.__wid_page_det.set_page_id)
        self.__wid_page_def.sig_search.connect(self.search_definition)
        self.__wid_page_def.sig_delete.connect(self.__wid_page_det.clean)
        self.__wid_page_det.sig_selected[str].connect(self.sig_selected.emit)

    def search_definition(self):
        _cond = self.__wid_search_cond.get_cond()
        self.__wid_page_def.search(_cond)
        self.__wid_page_det.clean()
Пример #3
0
class ViewReportMain(QWidget):
    def __init__(self):

        QWidget.__init__(self)

        self.title = u"执行"

        # View RunDef
        self.__wid_run_def = ViewRunDef()

        # View ReportDet
        self.__wid_report_det = ViewReportDet()

        # Search condition widget
        self.__wid_search_cond = ViewSearch(def_view_run_def)
        self.__wid_search_cond.create()

        # 底部 layout
        _layout_bottom = QSplitter()
        _layout_bottom.addWidget(self.__wid_run_def)
        _layout_bottom.addWidget(self.__wid_report_det)

        # main layout
        _layout = QVBoxLayout()
        _layout.addWidget(self.__wid_search_cond)
        _layout.addWidget(_layout_bottom)

        _layout.setContentsMargins(0, 0, 0, 0)

        self.setLayout(_layout)

        self.__wid_run_def.sig_search.connect(self.search)
        self.__wid_run_def.sig_selected.connect(
            self.__wid_report_det.usr_refresh)

    def search(self):

        _cond = self.__wid_search_cond.get_cond()
        self.__wid_run_def.search(_cond)
Пример #4
0
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)
Пример #5
0
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))
Пример #6
0
class ViewCaseSelMag(QWidget):

    sig_selected = OrcSignal([dict])

    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 __operate(self, p_flag):

        if "select" == p_flag:
            self.__select()
        elif "search" == p_flag:
            self.__search()
        elif "cancel" == p_flag:
            self.close()
        else:
            pass

    def __search(self):
        self.__model.usr_search(self.__wid_search_cond.get_cond())

    def __select(self):
        _res = self.__model.usr_get_checked()
        self.sig_selected[dict].emit(_res)
        self.close()

    def __select_one(self):
        _res = self.__model.usr_get_current_data().content["id"]
        self.sig_selected[dict].emit([_res])
        self.close()
Пример #7
0
class ViewBatchDetMag(QWidget):
    def __init__(self, p_data):

        QWidget.__init__(self)

        _batch_no = p_data["no"]
        self.__batch_id = p_data["id"]
        self.title = _batch_no

        # Model
        self.__model = BatchDetModel()
        self.__model.usr_set_definition(def_view_batch_det)

        # Control
        _control = BatchDetControl(def_view_batch_det)

        # Search condition widget
        self.__wid_search_cond = ViewSearch(def_view_batch_det)
        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="search", name=u"查询")
        ])

        # win_add
        self.__win_add = ViewCaseSelMag()

        # 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_selected.connect(self.add)

    def search(self):
        _cond = self.__wid_search_cond.get_cond()
        _cond["batch_id"] = self.__batch_id
        self.__model.usr_search(_cond)

    def add(self, p_data):
        _data = {"batch_id": self.__batch_id, "case": 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()
        elif "search" == p_flag:
            self.search()
        else:
            pass
Пример #8
0
class ViewWindow(QWidget):
    def __init__(self):

        QWidget.__init__(self)

        self.title = u"窗口"

        # Current window id
        self.__window_id = None

        # Model
        self.__model = WindowModel()
        self.__model.usr_set_definition(def_view_window_def)

        # Control
        _control = WindowControl(def_view_window_def)

        # Data result display window
        _wid_display = ViewTable()
        _wid_display.set_model(self.__model)
        _wid_display.set_control(_control)

        # Search condition
        self.__wid_search_cond = ViewSearch(def_view_window_def)
        self.__wid_search_cond.set_col_num(3)
        self.__wid_search_cond.create()

        # Buttons window
        _btn_definition = [
            dict(id="refresh", name=u'刷新'),
            dict(id="search", name=u"查询"),
            dict(id="update", name=u"修改", type="CHECK"),
            dict(id="delete", name=u"删除")
        ]
        _wid_buttons = ViewButtons(_btn_definition)
        _wid_buttons.align_back()

        # Layout
        _layout = QVBoxLayout()
        _layout.addWidget(self.__wid_search_cond)
        _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)

    def __operate(self, p_flg):

        if "search" == p_flg:
            _cond = self.__wid_search_cond.get_cond()
            self.__model.usr_search(_cond)
        elif "refresh" == p_flg:
            self.__model.usr_add(None)
        elif "update" == p_flg:
            self.__model.usr_editable()
        elif "delete" == p_flg:
            self.__model.usr_delete()
        else:
            pass

    def set_window_id(self, p_window_id):
        self.__window_id = p_window_id
        self.__model.usr_search({"window_id": self.__window_id})

    def clean(self):
        self.__window_id = None
        self.__model.usr_clean()
Пример #9
0
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)
Пример #10
0
class ViewCaseSelMag(QWidget):

    sig_selected = OrcSignal([dict])

    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)

    def __operate(self, p_flag):

        if "select" == p_flag:
            self.__select()
        elif "search" == p_flag:
            self.__search()
        elif "cancel" == p_flag:
            self.close()
        else:
            pass

    def __search(self):
        self.__model.usr_search(self.__wid_search_cond.get_cond())

    def __select(self):
        _res = self.__model.usr_get_checked()
        self.sig_selected[dict].emit(_res)
        self.close()
Пример #11
0
class ViewDataMag(QWidget):
    """
    View of table
    """
    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 __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 search(self):
        self.__model.usr_search(self.__wid_search_cond.get_cond())

    def add(self, p_data):
        self.__model.usr_add(p_data)
Пример #12
0
class ViewPageSelectMag(QWidget):

    sig_selected = OrcSignal(dict)

    def __init__(self):

        QWidget.__init__(self)

        self.title = u"用例管理"

        # Model
        self.__model = PageSelectModel()
        self.__model.usr_set_definition(def_view_page_def)

        # Control
        _control = PageSelectControl(def_view_page_def)

        # Search condition widget
        self.__wid_search_cond = ViewSearch(def_view_page_def)
        self.__wid_search_cond.set_col_num(2)
        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="search", name=u"查询")])

        # win_add
        self.__win_add = ViewAdd(def_view_page_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.doubleClicked.connect(self.select)

    def __operate(self, p_flag):

        if "search" == p_flag:
            self.search()
        else:
            pass

    def search(self):
        _cond = self.__wid_search_cond.get_cond()
        self.__model.usr_search(_cond)

    def select(self, p_index):

        _node = self.__model.usr_get_data(p_index.row())
        _id = _node["id"]
        _flag = _node["page_flag"]

        self.sig_selected.emit(dict(id=str(_id), flag=_flag))

        self.close()