def setup_ui(self): super(AtlasUI, self).setup_ui() image_clear_btn = QPushButton(text="清空") image_clear_btn.clicked.connect(self.on_image_clear_btn_clicked) image_listview = QListView() image_listview.setAcceptDrops(True) image_list_model = QStandardItemModel(image_listview) image_list_model.itemChanged.connect(self.on_image_changed) image_listview.setModel(image_list_model) self.main_layout.addWidget(image_clear_btn, 0, 0, 1, 1, QtCore.Qt.AlignLeft) self.main_layout.addWidget(image_listview, 1, 0, 1, 1) self.image_clear_btn = image_clear_btn self.image_listview = image_listview self.image_list_model = image_list_model self.refresh_images()
def addOutputFolder(self, name: str): listview = QListView(self) listview.setObjectName("tab_" + name.lower()) listview.setSelectionMode(QListView.ExtendedSelection) listview.setAcceptDrops(True) listview.setMouseTracking(True) listview.setModel( TargetListModel(listview, self._network, self._shared_states)) listview.pressed.connect(self.updateSelectedOutput) listview.entered.connect(self.updateHighlightOutput) listview.enterEvent = self.listOutputViewEnter listview.leaveEvent = self.listOutputViewLeave listview.setContextMenuPolicy(Qt.CustomContextMenu) listview.customContextMenuRequested.connect( lambda pos: self.outputContextMenu(listview, pos)) self._meta.folders[name] = FolderMeta() self.tab_folders.addTab(listview, name.upper()) self.updateFolderNames()