diff --git a/src/Model/Tools/PamhyrDB.py b/src/Model/Tools/PamhyrDB.py index 9488eb80acbe3c9784ca6fcc0a5831cd633aa32c..94eab5430d87882b438e25eff104334771f92a10 100644 --- a/src/Model/Tools/PamhyrDB.py +++ b/src/Model/Tools/PamhyrDB.py @@ -70,6 +70,7 @@ class SQLModel(SQL): return True def _create(self): + raise NotImplementedMethodeError(self, self._create) def _update_submodel(self, version): diff --git a/src/Model/Tools/PamhyrDict.py b/src/Model/Tools/PamhyrDict.py index de96903d2ce0c86245967a4e209cd89ddf7dc789..93e563eb8384efade5f928b38b4e5bbac32f9a7c 100644 --- a/src/Model/Tools/PamhyrDict.py +++ b/src/Model/Tools/PamhyrDict.py @@ -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): diff --git a/src/Model/Tools/PamhyrList.py b/src/Model/Tools/PamhyrList.py index 024273cd0b11c4d68dc1fbe98a1c4aa18ce4591f..b0cc282de5b69e0a596e688dc4b1a2d89db2af3b 100644 --- a/src/Model/Tools/PamhyrList.py +++ b/src/Model/Tools/PamhyrList.py @@ -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], diff --git a/src/View/Debug/Window.py b/src/View/Debug/Window.py index 1755d3d095ca72d37c587440299e66591145a285..a7aafa53c652773b1dc0771abd680e15bb8d494e 100644 --- a/src/View/Debug/Window.py +++ b/src/View/Debug/Window.py @@ -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")