26 from datetime
import datetime
28 from datetime
import datetime
29 from PyQt4
import QtCore, QtGui
30 from gradient_info_handler
import GradientInfoHandler
31 from gradient_list_model
import GradientListModel
37 def __init__(self, gradient_edit, parent=None):
38 QtGui.QWidget.__init__(self, parent)
52 self.list_view_.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
54 preset_label = QtGui.QLabel(self.
text_)
55 font = preset_label.font()
59 self.add_action.setIcon(QtGui.QIcon(GradientPresetWidget.ICONS_DIR+
"add_icon.png"))
61 QtCore.QObject.connect(self.
add_action, QtCore.SIGNAL(
"triggered()"), self.
Add)
64 self.add_button_.setIconSize(QtCore.QSize(20,20))
65 self.add_button_.setDefaultAction(self.
add_action)
67 grid = QtGui.QGridLayout()
68 grid.setContentsMargins(0,5,0,0)
69 grid.addWidget(preset_label, 0, 0, 1, 1)
70 qhbox = QtGui.QHBoxLayout()
75 self.list_view_.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
80 QtCore.QObject.connect(self.
list_view_, QtCore.SIGNAL(
"doubleClicked(const QModelIndex)"), self.
Load)
85 self.immucontextMenu_.addAction(self.
load_)
93 self.contextMenu_.addAction(self.
load_)
94 self.contextMenu_.addAction(self.
remove_)
95 self.contextMenu_.addAction(self.
rename_)
97 QtCore.QObject.connect(self.
remove_, QtCore.SIGNAL(
"triggered()"), self.
Remove)
98 QtCore.QObject.connect(self.
rename_, QtCore.SIGNAL(
"triggered()"), self.
Rename)
102 index = self.list_view_.indexAt(pos)
104 if self.list_model_.IsEditable(index.row()):
105 self.contextMenu_.popup(QtGui.QCursor.pos())
107 self.immucontextMenu_.popup(QtGui.QCursor.pos())
110 if(self.list_view_.currentIndex().isValid()):
111 self.list_view_.closePersistentEditor(self.list_view_.currentIndex())
112 row = self.list_model_.GetLastRow()
113 if self.list_model_.AddItem(datetime.now().isoformat(
' '), self.gradient_edit_.GetGradient(), row,
True,
True):
114 index = self.list_model_.index(row)
115 self.list_view_.setCurrentIndex(index)
118 QtGui.QMessageBox.information(self,
"Gradient not added",
"The gradient could not be added!")
121 if(self.list_view_.currentIndex().isValid()):
122 ret = QtGui.QMessageBox.warning(self,
"Delete Gradient",
124 QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
125 if ret == QtGui.QMessageBox.Yes:
126 self.list_model_.RemoveItem(self.list_view_.currentIndex().row())
129 if(self.list_view_.currentIndex().isValid()):
130 self.
Load(self.list_view_.currentIndex())
134 self.emit(QtCore.SIGNAL(
"gradientSelected"),self.list_model_.GetGradient(index))
137 if(self.list_view_.currentIndex().isValid()):
138 self.list_view_.edit(self.list_view_.currentIndex())
String DLLEXPORT_OST_BASE GetSharedDataPath()