mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-01 18:49:38 +12:00
Adds some docstrings on editor/view classes, because I never remember who they are and what they do...
This commit is contained in:
parent
a44dd41f00
commit
1a8d4c5c72
|
@ -11,6 +11,31 @@ from manuskript.ui.views.textEditView import textEditView
|
|||
|
||||
|
||||
class editorWidget(QWidget, Ui_editorWidget_ui):
|
||||
"""
|
||||
`editorWidget` is a class responsible for displaying and editing one
|
||||
`outlineItem`. This item can be a folder or a text.
|
||||
|
||||
It has four views (see `self.setView`)
|
||||
|
||||
- For folders: "text", "outline" or "cork" (set in `self.folderView`)
|
||||
|
||||
Text: displays a list of `textEditView` in a scroll area
|
||||
|
||||
Outline: displays an outline, using an `outlineView`
|
||||
|
||||
Cork: displays flash cards, using a `corkView`
|
||||
|
||||
- For text: item is simply displayed in a `textEditView`
|
||||
|
||||
All those views are contained in `editorWidget` single widget: `self.stack`.
|
||||
|
||||
`editorWidget` are managed in `tabSplitted` (that allow to open several
|
||||
`outlineItem`s, either in Tabs or in split views.
|
||||
|
||||
`tabSplitted` are in turn managed by the `mainEditor`, which is unique and
|
||||
gives UI buttons to manage all those views.
|
||||
"""
|
||||
|
||||
toggledSpellcheck = pyqtSignal(bool)
|
||||
dictChanged = pyqtSignal(str)
|
||||
|
||||
|
@ -212,6 +237,10 @@ class editorWidget(QWidget, Ui_editorWidget_ui):
|
|||
self.setView()
|
||||
|
||||
def updateIndexFromID(self):
|
||||
"""
|
||||
Index might have changed (through drag an drop), so we keep current
|
||||
item's ID and update index.
|
||||
"""
|
||||
idx = self.mw.mdlOutline.getIndexByID(self.currentID)
|
||||
if idx != self.currentIndex:
|
||||
self.currentIndex = idx
|
||||
|
|
|
@ -19,6 +19,45 @@ locale.setlocale(locale.LC_ALL, '')
|
|||
|
||||
|
||||
class mainEditor(QWidget, Ui_mainEditor):
|
||||
"""
|
||||
`mainEditor` is responsible for opening `outlineItem`s and offering informations
|
||||
and commands about those `outlineItem`s to the used.
|
||||
|
||||
It contains two main elements:
|
||||
|
||||
1. A `tabSplitter`, which can open any numer of `outlineItem`s either in tabs
|
||||
(in `QTabWidget`) and/or in splitted views (children `tabSplitter`s).
|
||||
2. An horizontal layout contain a number of buttons and informations:
|
||||
|
||||
- Go up button
|
||||
- Select folder view: either "text", "cork" or "outline" (see `editorWidget`)
|
||||
- Zoom slider for "cork" view
|
||||
- Label showing stats about displayed `outlineItem`
|
||||
- Fullscreen button
|
||||
|
||||
`mainEditor` is responsible for opening indexes, propagating event to relevent
|
||||
views, opening and closing tabs, etc.
|
||||
|
||||
+---------------------------| mainEditor |--------------------------------+
|
||||
| |
|
||||
| +--------| tabSplitter |----------------------------------------------+ |
|
||||
| | +----------| tabSplitter |---------+ | |
|
||||
| | | | | |
|
||||
| | +-----| editorWidget |----+ | +-------| editorWidget |-----+ | | |
|
||||
| | | | | | | | | |
|
||||
| | +-------------------------+ | +----------------------------+ | | |
|
||||
| | | | | |
|
||||
| | +-----| editorWidget |----+ | +-------| editorWidget |-----+ | | |
|
||||
| | | | | | | | | |
|
||||
| | +-------------------------+ | +----------------------------+ | | |
|
||||
| | +----------------------------------+ | |
|
||||
| +---------------------------------------------------------------------+ |
|
||||
| |
|
||||
+-------------------------------------------------------------------------+
|
||||
| ## ## ## ## toolbar ## ## |
|
||||
+-------------------------------------------------------------------------+
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
|
@ -152,7 +191,7 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
def openIndexes(self, indexes, newTab=False):
|
||||
for i in indexes:
|
||||
self.setCurrentModelIndex(i, newTab)
|
||||
|
||||
|
||||
def goToParentItem(self):
|
||||
idx = self.currentEditor().currentIndex
|
||||
from manuskript.functions import MW
|
||||
|
|
|
@ -12,6 +12,26 @@ from manuskript.ui.editors.tabSplitter_ui import Ui_tabSplitter
|
|||
|
||||
|
||||
class tabSplitter(QWidget, Ui_tabSplitter):
|
||||
"""
|
||||
`tabSplitter` is used to have mutliple `outlineItem`s open, either in tabs
|
||||
and/or in splitted views. Each tab contains an `editorWidget` which is responsible
|
||||
for showing one single `outlineItem` in several ways.
|
||||
|
||||
`tabSplitter` is managed mainly through the `mainEditor` which is responsible
|
||||
for opening indexes and such.
|
||||
|
||||
`tabSplitter` main widget is a `QSplitter` named `self.splitter`. It contains one
|
||||
`QTabWidget` called `self.tab`. A second `tabSplitter` can be loaded through
|
||||
`self.split` in `self.splitter`. That way, a single `tabSplitter` can split
|
||||
indefinitely.
|
||||
|
||||
`tabSplitter` also has two buttons:
|
||||
|
||||
1. `self.btnSplit`: used to split and unsplit
|
||||
2. `self.btnTarget`: toggles whether `self.tab` is a target to open any
|
||||
selected outlineItem in any other views.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None, mainEditor=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
|
|
Loading…
Reference in a new issue