24 from datetime
import datetime
25 from PyQt5
import QtCore, QtWidgets, QtGui
26 from .scene_selection_helper
import SelHelper
27 from .preset_list_model
import PresetListModel
28 from .preset_editor_widget
import PresetEditor
29 from .preset
import Preset
35 QtWidgets.QWidget.__init__(self, parent)
45 self.list_view_.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
48 self.add_action.setIcon(QtGui.QIcon(PresetWidget.ICONS_DIR+
"add_icon.png"))
50 self.add_action.triggered.connect(self.
Add)
53 self.add_button_.setIconSize(QtCore.QSize(20,20))
54 self.add_button_.setDefaultAction(self.
add_action)
58 grid = QtWidgets.QGridLayout()
59 grid.setContentsMargins(0,5,0,0)
64 self.list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
69 self.list_view_.doubleClicked.connect(self.
Load)
71 self.setMinimumSize(250,200)
76 self.immucontext_menu_.addAction(self.
load_)
85 self.context_menu_.addAction(self.
load_)
86 self.context_menu_.addAction(self.
remove_)
87 self.context_menu_.addAction(self.
rename_)
88 self.context_menu_.addAction(self.
edit_)
90 self.remove_.triggered.connect(self.
Remove)
91 self.rename_.triggered.connect(self.
Rename)
92 self.edit_.triggered.connect(self.
Edit)
96 index = self.list_view_.indexAt(pos)
98 if self.list_model_.IsEditable(index.row()):
99 self.context_menu_.popup(QtWidgets.QCursor.pos())
101 self.immucontext_menu_.popup(QtWidgets.QCursor.pos())
104 row = self.list_model_.GetLastRow()
105 preset = Preset(datetime.now().isoformat(
' '))
106 self.preset_editor_.SetPreset(preset)
107 if(self.preset_editor_.exec_()):
108 if self.list_model_.AddItem(preset, row,
True,
True):
109 index = self.list_model_.index(row)
110 self.list_view_.setCurrentIndex(index)
114 if(self.list_view_.currentIndex().isValid()):
115 ret = QtWidgets.QMessageBox.warning(self,
"Delete Preset",
117 QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
118 if ret == QtWidgets.QMessageBox.Yes:
119 self.list_model_.RemoveItem(self.list_view_.currentIndex().row())
122 if(self.list_view_.currentIndex().isValid()):
123 preset = self.list_model_.GetPreset(self.list_view_.currentIndex())
124 self.preset_editor_.SetPreset(preset)
125 if(self.preset_editor_.exec_()):
126 row = self.list_view_.currentIndex().row()
127 self.list_model_.RemoveItem(row)
128 self.list_model_.AddItem(preset, row,
True,
True)
131 if(self.list_view_.currentIndex().isValid()):
132 self.
Load(self.list_view_.currentIndex())
136 scene_selection = gui.SceneSelection.Instance()
137 preset=self.list_model_.GetPreset(index)
138 for i
in range(0,scene_selection.GetActiveNodeCount()):
139 node = scene_selection.GetActiveNode(i)
148 self.setEnabled(
True)
149 if SelHelper().CheckAllFlags(SelHelper.NO_SELECTION):
150 self.setEnabled(
False)
153 if SelHelper().CheckNotFlags(SelHelper.HAS_ENTITY | SelHelper.IS_ONE_TYPE):
154 self.setEnabled(
False)
158 if(self.list_view_.currentIndex().isValid()):
159 self.list_view_.edit(self.list_view_.currentIndex())
graphical rendering of mol::EntityHandle entites
String DLLEXPORT_OST_BASE GetSharedDataPath()