Remember line
This commit is contained in:
3
TODO
3
TODO
@@ -70,3 +70,6 @@ TODO
|
|||||||
✓ Define every widget in code
|
✓ Define every widget in code
|
||||||
✓ Include icons for emblems
|
✓ Include icons for emblems
|
||||||
Shift to logging instead of print statements
|
Shift to logging instead of print statements
|
||||||
|
Bugs:
|
||||||
|
If there are files open and the database is deleted, TypeErrors result
|
||||||
|
The auto scan doesn't work on a new database
|
@@ -33,6 +33,8 @@ class ItemProxyModel(QtCore.QSortFilterProxyModel):
|
|||||||
self.active_library_filters = active_library_filters
|
self.active_library_filters = active_library_filters
|
||||||
|
|
||||||
def filterAcceptsRow(self, row, parent):
|
def filterAcceptsRow(self, row, parent):
|
||||||
|
return True
|
||||||
|
|
||||||
model = self.sourceModel()
|
model = self.sourceModel()
|
||||||
|
|
||||||
this_index = model.index(row, 0)
|
this_index = model.index(row, 0)
|
||||||
@@ -171,6 +173,8 @@ class TableProxyModel(QtCore.QSortFilterProxyModel):
|
|||||||
self.active_library_filters = active_library_filters
|
self.active_library_filters = active_library_filters
|
||||||
|
|
||||||
def filterAcceptsRow(self, row_num, parent):
|
def filterAcceptsRow(self, row_num, parent):
|
||||||
|
return True
|
||||||
|
|
||||||
if self.filter_string is None or self.filter_columns is None:
|
if self.filter_string is None or self.filter_columns is None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -224,7 +228,10 @@ class MostExcellentFileSystemModel(QtWidgets.QFileSystemModel):
|
|||||||
0: 'Path',
|
0: 'Path',
|
||||||
4: 'Name',
|
4: 'Name',
|
||||||
5: 'Tags'}
|
5: 'Tags'}
|
||||||
return column_dict[col]
|
try:
|
||||||
|
return column_dict[col]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
if (index.column() in (4, 5)
|
if (index.column() in (4, 5)
|
||||||
|
41
widgets.py
41
widgets.py
@@ -422,23 +422,33 @@ class Tab(QtWidgets.QWidget):
|
|||||||
|
|
||||||
self.contentView.setOpenLinks(False) # TODO Change this when HTML navigation works
|
self.contentView.setOpenLinks(False) # TODO Change this when HTML navigation works
|
||||||
self.contentView.setHtml(chapter_content)
|
self.contentView.setHtml(chapter_content)
|
||||||
|
self.contentView.setReadOnly(True)
|
||||||
|
|
||||||
def set_scroll_value():
|
def set_scroll_value():
|
||||||
# self.window().tabWidget.blockSignals(True)
|
# TODO
|
||||||
|
# Stays in place upon switching tabs
|
||||||
|
|
||||||
previous_widget = self.window().tabWidget.currentWidget()
|
previous_widget = self.window().tabWidget.currentWidget()
|
||||||
self.window().tabWidget.setCurrentWidget(self)
|
self.window().tabWidget.setCurrentWidget(self)
|
||||||
|
|
||||||
scroll_position = int(
|
scroll_position = (
|
||||||
self.metadata['position']['scroll_value'] *
|
self.metadata['position']['scroll_value'] *
|
||||||
self.contentView.verticalScrollBar().maximum())
|
self.contentView.verticalScrollBar().maximum())
|
||||||
|
|
||||||
# print(self.contentView.verticalScrollBar().maximum(), scroll_position)
|
# Scroll a little ahead
|
||||||
# print(self.metadata['position'])
|
# This avoids confusion with potentially duplicate phrases
|
||||||
|
# And the found result is at the top of the window
|
||||||
|
self.contentView.verticalScrollBar().setValue(scroll_position * 1.1)
|
||||||
|
|
||||||
self.contentView.verticalScrollBar().setValue(scroll_position)
|
last_visible_text = self.metadata['position']['last_visible_text']
|
||||||
|
if last_visible_text:
|
||||||
|
self.contentView.find(last_visible_text)
|
||||||
|
|
||||||
|
text_cursor = self.contentView.textCursor()
|
||||||
|
text_cursor.clearSelection()
|
||||||
|
self.contentView.setTextCursor(text_cursor)
|
||||||
|
|
||||||
self.window().tabWidget.setCurrentWidget(previous_widget)
|
self.window().tabWidget.setCurrentWidget(previous_widget)
|
||||||
# self.window().tabWidget.blockSignals(False)
|
|
||||||
|
|
||||||
temp_hidden_button = QtWidgets.QToolButton(self)
|
temp_hidden_button = QtWidgets.QToolButton(self)
|
||||||
temp_hidden_button.setVisible(False)
|
temp_hidden_button.setVisible(False)
|
||||||
@@ -485,7 +495,8 @@ class Tab(QtWidgets.QWidget):
|
|||||||
'current_chapter': 1,
|
'current_chapter': 1,
|
||||||
'current_line': 0,
|
'current_line': 0,
|
||||||
'total_chapters': total_chapters,
|
'total_chapters': total_chapters,
|
||||||
'scroll_value': 0}
|
'scroll_value': 0,
|
||||||
|
'last_visible_text': None}
|
||||||
|
|
||||||
def generate_keyboard_shortcuts(self):
|
def generate_keyboard_shortcuts(self):
|
||||||
self.next_chapter = QtWidgets.QShortcut(
|
self.next_chapter = QtWidgets.QShortcut(
|
||||||
@@ -674,7 +685,6 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
|
|
||||||
if vertical == maximum:
|
if vertical == maximum:
|
||||||
self.common_functions.change_chapter(1, True)
|
self.common_functions.change_chapter(1, True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Increment by following value
|
# Increment by following value
|
||||||
scroll_increment = int((maximum - 0) / 2)
|
scroll_increment = int((maximum - 0) / 2)
|
||||||
@@ -699,6 +709,17 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
|||||||
def wheelEvent(self, event):
|
def wheelEvent(self, event):
|
||||||
self.parent.metadata['position']['scroll_value'] = (
|
self.parent.metadata['position']['scroll_value'] = (
|
||||||
self.verticalScrollBar().value() / self.verticalScrollBar().maximum())
|
self.verticalScrollBar().value() / self.verticalScrollBar().maximum())
|
||||||
|
|
||||||
|
cursor = self.cursorForPosition(QtCore.QPoint(0, 0))
|
||||||
|
bottom_right = QtCore.QPoint(self.viewport().width() - 1, self.viewport().height())
|
||||||
|
bottom_right_cursor = self.cursorForPosition(bottom_right).position()
|
||||||
|
cursor.setPosition(bottom_right_cursor, QtGui.QTextCursor.KeepAnchor)
|
||||||
|
visible_text = cursor.selectedText()
|
||||||
|
|
||||||
|
if len(visible_text) > 30:
|
||||||
|
visible_text = visible_text[:31]
|
||||||
|
self.parent.metadata['position']['last_visible_text'] = visible_text
|
||||||
|
|
||||||
self.common_functions.wheelEvent(event, False)
|
self.common_functions.wheelEvent(event, False)
|
||||||
|
|
||||||
def keyPressEvent(self, event):
|
def keyPressEvent(self, event):
|
||||||
@@ -711,10 +732,10 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
|||||||
if vertical == maximum:
|
if vertical == maximum:
|
||||||
self.common_functions.change_chapter(1, True)
|
self.common_functions.change_chapter(1, True)
|
||||||
else:
|
else:
|
||||||
QtWidgets.QTextBrowser.keyPressEvent(self, event)
|
QtWidgets.QTextEdit.keyPressEvent(self, event)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
QtWidgets.QTextBrowser.keyPressEvent(self, event)
|
QtWidgets.QTextEdit.keyPressEvent(self, event)
|
||||||
|
|
||||||
# def mouseMoveEvent(self, event):
|
# def mouseMoveEvent(self, event):
|
||||||
# TODO
|
# TODO
|
||||||
|
Reference in New Issue
Block a user