Beispiel #1
0
    def _build_string(self):
        widget = QtWidgets.QWidget()
        v_layout = create_box_layout(ORIENTATION.VERTICAL, margin=5,
                                     spacing=10)
        widget.setLayout(v_layout)
        self._tab_widget.addTab(widget, "Names")

        h_layout1 = create_box_layout(ORIENTATION.HORIZONTAL, margin=0,
                                      spacing=0)
        h_layout1.addWidget(create_label("String Replacement: ", width=115))
        self._str_repl_table = QtWidgets.QTableWidget(self)
        self._str_repl_table.setRowCount(1)
        self._str_repl_table.setColumnCount(2)
        self._str_repl_table.setHorizontalHeaderLabels(["From", "To"])
        self._str_repl_table.setColumnWidth(0, 125)
        self._str_repl_table.horizontalHeader().setStretchLastSection(True)
        self._str_repl_table.horizontalHeader().setSectionsClickable(False)
        self._str_repl_table.verticalHeader().setVisible(False)
        self._str_repl_table.setAlternatingRowColors(True)
        self._str_repl_table.setSelectionMode(
            QtWidgets.QAbstractItemView.SingleSelection)
        self._str_repl_table.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        h_layout1.addWidget(self._str_repl_table)
        v_layout.addLayout(h_layout1)

        self._str_repl_menu = QtWidgets.QMenu(self)
        self._str_repl_add_row = self._str_repl_menu.addAction("Add Row")
        self._str_repl_del_row = self._str_repl_menu.addAction("Delete Row")
        self._str_repl_del_all = self._str_repl_menu.addAction("Delete All")

        h_layout2 = create_box_layout(ORIENTATION.HORIZONTAL, margin=0,
                                      spacing=0)
        h_layout2.addWidget(create_label("Prefix To Add: ", width=115))
        self._prefix = QtWidgets.QLineEdit()
        h_layout2.addWidget(self._prefix)
        v_layout.addLayout(h_layout2)

        h_layout3 = create_box_layout(ORIENTATION.HORIZONTAL, margin=0,
                                      spacing=0)
        h_layout3.addWidget(create_label("Suffix To Add: ", width=115))
        self._suffix = QtWidgets.QLineEdit()
        h_layout3.addWidget(self._suffix)
        v_layout.addLayout(h_layout3)
Beispiel #2
0
    def __init__(self,
                 root=None,
                 show_channels=True,
                 show_chunks=False,
                 parent=None,
                 facade=None):
        super(DataTreeWidget, self).__init__(parent)

        self._show_channels = show_channels
        self._show_chunks = show_chunks

        self._facade = facade

        self._model = DataTreeModel(root=root,
                                    show_channels=show_channels,
                                    show_chunks=show_chunks)
        self._sorting_model = DataTreeSortProxyFilterModel()
        self._sorting_model.setSourceModel(self._model)
        self._sorting_model.setDynamicSortFilter(False)
        self.setModel(self._sorting_model)

        self.header().setSectionsClickable(False)

        self.setColumnWidth(0, 250)

        if self._facade:
            self._menu = QtWidgets.QMenu(self)
            self._sel_item_a = self._menu.addAction("Map To Selected Item")
            self._sel_chan_a = self._menu.addAction("Map To Selected Channel")
            self._unmap_a = self._menu.addAction("Remove Mapping")
            self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
            self.customContextMenuRequested.connect(self._show_menu)
            self._menu.triggered.connect(self._action_triggered)

        if root is not None:
            self.set_root(root)