mirror of https://gitlab.com/pamhyr/pamhyr2
Pamhyr2: Minor change and method documentation.
parent
145c301eed
commit
acbd3537c0
|
|
@ -70,6 +70,7 @@ class SQLModel(SQL):
|
|||
return True
|
||||
|
||||
def _create(self):
|
||||
|
||||
raise NotImplementedMethodeError(self, self._create)
|
||||
|
||||
def _update_submodel(self, version):
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class PamhyrModelDict(SQLSubModel):
|
|||
def __len__(self):
|
||||
return len(self._dict)
|
||||
|
||||
def is_defined(self, key):
|
||||
def __contains__(self, key):
|
||||
return key in self._dict
|
||||
|
||||
def set(self, key, new):
|
||||
|
|
|
|||
|
|
@ -62,6 +62,14 @@ class PamhyrModelList(SQLSubModel):
|
|||
|
||||
@property
|
||||
def lst(self):
|
||||
"""Return the PamhyrList as a Python list
|
||||
|
||||
Return the PamhyrList as a Python list. This list is the
|
||||
current list used in the PamhyrList object. **If you need to
|
||||
modify it, please make a copy.**
|
||||
|
||||
Returns: The Python list
|
||||
"""
|
||||
return self._lst
|
||||
|
||||
def __len__(self):
|
||||
|
|
@ -70,11 +78,11 @@ class PamhyrModelList(SQLSubModel):
|
|||
def index(self, el):
|
||||
return self._lst.index(el)
|
||||
|
||||
def get(self, row):
|
||||
return self._lst[row]
|
||||
def get(self, index):
|
||||
return self._lst[index]
|
||||
|
||||
def set(self, row, new):
|
||||
self._lst[row] = new
|
||||
def set(self, index, new):
|
||||
self._lst[index] = new
|
||||
if self._status is not None:
|
||||
self._status.modified()
|
||||
|
||||
|
|
@ -96,6 +104,14 @@ class PamhyrModelList(SQLSubModel):
|
|||
self._status.modified()
|
||||
|
||||
def delete(self, lst):
|
||||
"""Delete a list of elements
|
||||
|
||||
Args:
|
||||
lst: The list of elements
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
for el in lst:
|
||||
self._lst.remove(el)
|
||||
|
||||
|
|
@ -103,6 +119,14 @@ class PamhyrModelList(SQLSubModel):
|
|||
self._status.modified()
|
||||
|
||||
def delete_i(self, indexes):
|
||||
"""Delete elements from list of indexes
|
||||
|
||||
Args:
|
||||
indexes: The elements indexes
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
lst = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
|
|
@ -178,16 +202,32 @@ class PamhyrModelListWithTab(SQLSubModel):
|
|||
################
|
||||
|
||||
def len(self, lst):
|
||||
"""Size of tab list
|
||||
|
||||
Args:
|
||||
lst: The tab name
|
||||
|
||||
Returns:
|
||||
The size of the tab list
|
||||
"""
|
||||
return len(self._tabs[lst])
|
||||
|
||||
def get_tab(self, lst):
|
||||
"""Get tab list (copy) from name
|
||||
|
||||
Args:
|
||||
lst: The tab name
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
return self._tabs[lst].copy()
|
||||
|
||||
def get(self, lst, row):
|
||||
return self._tabs[lst][row]
|
||||
def get(self, lst, index):
|
||||
return self._tabs[lst][index]
|
||||
|
||||
def set(self, lst, row, new):
|
||||
self._tabs[lst][row] = new
|
||||
def set(self, lst, index, new):
|
||||
self._tabs[lst][index] = new
|
||||
self._status.modified()
|
||||
|
||||
def new(self, lst, index):
|
||||
|
|
@ -203,15 +243,43 @@ class PamhyrModelListWithTab(SQLSubModel):
|
|||
raise NotImplementedMethodeError(self, self.new)
|
||||
|
||||
def insert(self, lst, index, new):
|
||||
"""Insert element in tab
|
||||
|
||||
Args:
|
||||
lst: The tab name
|
||||
index: The index of new element
|
||||
new: The new elements
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
self._tabs[lst].insert(index, new)
|
||||
self._status.modified()
|
||||
|
||||
def delete(self, lst, els):
|
||||
"""Delete elements from specific tab
|
||||
|
||||
Args:
|
||||
lst: The tab name
|
||||
els: The elements list
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
for el in els:
|
||||
self._tabs[lst].remove(el)
|
||||
self._status.modified()
|
||||
|
||||
def delete_i(self, lst, indexes):
|
||||
"""Delete elements from specific tab
|
||||
|
||||
Args:
|
||||
lst: The tab name
|
||||
indexes: The elements indexes
|
||||
|
||||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
els = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
|
|
|
|||
|
|
@ -77,30 +77,10 @@ class ReplWindow(PamhyrWindow):
|
|||
layout.insertWidget(0, self._editor)
|
||||
|
||||
def setup_connections(self):
|
||||
self._hup_sc = QShortcut(QKeySequence("ctrl+Up"), self)
|
||||
self._hdown_sc = QShortcut(QKeySequence("ctrl+Down"), self)
|
||||
self._hup_sc.activated.connect(self.history_up)
|
||||
self._hdown_sc.activated.connect(self.history_down)
|
||||
|
||||
self.find(QPushButton, "pushButton").clicked.connect(self.eval_python)
|
||||
|
||||
def history_up(self):
|
||||
if self._history_ind < len(self._history):
|
||||
self._history_ind += 1
|
||||
self._editor.setText(self._history[-self._history_ind])
|
||||
|
||||
def history_down(self):
|
||||
if self._history_ind > 0:
|
||||
self._history_ind -= 1
|
||||
self._editor.setText(self._history[-self._history_ind])
|
||||
else:
|
||||
self._editor.setText("")
|
||||
|
||||
def eval_python(self):
|
||||
code = self._editor.text()
|
||||
self._history.append(code)
|
||||
self._editor.setText("")
|
||||
self._history_ind = 0
|
||||
|
||||
# Code to rich_code
|
||||
rich_code = code.strip().split("\n")
|
||||
|
|
|
|||
Loading…
Reference in New Issue