def __init__(self, tree, parent=None, mainwindow=None): super(NXTreeView, self).__init__(parent) self.tree = tree self.mainwindow = mainwindow self._model = QtGui.QStandardItemModel() self.proxymodel = NXSortModel(self) self.proxymodel.setSourceModel(self._model) self.proxymodel.setDynamicSortFilter(True) self.proxymodel.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive) self.setModel(self.proxymodel) self._model.setColumnCount(1) self._model.setHorizontalHeaderItem(0, QtGui.QStandardItem('NeXus Data')) self.setSortingEnabled(True) self.sortByColumn(0, QtCore.Qt.AscendingOrder) self.tree._item = self._model.invisibleRootItem() self.tree._item.node = self.tree self.tree._model = self._model self.tree._view = self self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.setExpandsOnDoubleClick(False) self.doubleClicked.connect(self.plot_data) # Popup Menu self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.on_context_menu) self.plot_data_action = QtGui.QAction("Plot", self, triggered=self.plot_data) self.plot_line_action = QtGui.QAction("Plot Line", self, triggered=self.plot_line) self.overplot_data_action = QtGui.QAction("Overplot", self, triggered=self.overplot_data) self.overplot_line_action = QtGui.QAction("Overplot Line", self, triggered=self.overplot_line) self.plot_image_action = QtGui.QAction("Plot RGB(A) Image", self, triggered=self.plot_image) self.add_action = QtGui.QAction("Add...", self, triggered=self.add_data) self.initialize_action = QtGui.QAction("Initialize...", self, triggered=self.initialize_data) self.rename_action = QtGui.QAction("Rename...", self, triggered=self.rename_data) self.copy_action = QtGui.QAction("Copy", self, triggered=self.copy_data) self.paste_action = QtGui.QAction("Paste", self, triggered=self.paste_data) self.pastelink_action = QtGui.QAction("Paste As Link", self, triggered=self.paste_link) self.delete_action = QtGui.QAction("Delete...", self, triggered=self.delete_data) self.link_action = QtGui.QAction("Show Link", self, triggered=self.show_link) self.signal_action = QtGui.QAction("Set Signal...", self, triggered=self.set_signal) self.fit_action = QtGui.QAction("Fit...", self, triggered=self.fit_data) self.savefile_action = QtGui.QAction("Save as...", self, triggered=self.save_file) self.duplicate_action = QtGui.QAction("Duplicate...", self, triggered=self.duplicate) self.reload_action = QtGui.QAction("Reload...", self, triggered=self.reload) self.remove_action = QtGui.QAction("Remove...", self, triggered=self.remove) self.lockfile_action = QtGui.QAction("Lock", self, triggered=self.lock_file) self.unlockfile_action = QtGui.QAction("Unlock...", self, triggered=self.unlock_file)
def exec_actions(parent, menu): menu.addAction(QtGui.QAction("Sleep", parent, triggered=exec_sleep)) menu.addAction(QtGui.QAction("CCTW", parent, triggered=exec_cctw))