Blank lines at the end of each chapter

Improve searching
This commit is contained in:
BasioMeusPuga
2018-03-15 19:23:02 +05:30
parent 55545f62e7
commit 6ee135a52b
2 changed files with 16 additions and 6 deletions

View File

@@ -264,12 +264,12 @@ class EPUB:
for this_chapter in chapters: for this_chapter in chapters:
fallback_title = str(no_title_chapter) fallback_title = str(no_title_chapter)
self.book['book_list'].append( self.book['book_list'].append(
(fallback_title, this_chapter)) (fallback_title, this_chapter + ('<br>' * 8)))
no_title_chapter += 1 no_title_chapter += 1
else: else:
try: try:
self.book['book_list'].append( self.book['book_list'].append(
(self.book['navpoint_dict'][i], chapter_data)) (self.book['navpoint_dict'][i], chapter_data + ('<br>' * 8)))
except KeyError: except KeyError:
fallback_title = str(no_title_chapter) fallback_title = str(no_title_chapter)
self.book['book_list'].append( self.book['book_list'].append(
@@ -303,14 +303,14 @@ def get_split_content(chapter_data, split_by):
# As will all empty chapters # As will all empty chapters
if bs_obj.text == '\n' or bs_obj.text == '' or count == 0: if bs_obj.text == '\n' or bs_obj.text == '' or count == 0:
continue continue
bs_obj_string = str(bs_obj).replace('"&gt;', '', 1) bs_obj_string = str(bs_obj).replace('"&gt;', '', 1) + ('<br>' * 8)
return_list.append( return_list.append(
(chapter_titles[count - 1], bs_obj_string)) (chapter_titles[count - 1], bs_obj_string))
xml_string = this_split[1] xml_string = this_split[1]
bs_obj = BeautifulSoup(xml_string, 'lxml') bs_obj = BeautifulSoup(xml_string, 'lxml')
bs_obj_string = str(bs_obj).replace('"&gt;', '', 1) bs_obj_string = str(bs_obj).replace('"&gt;', '', 1) + ('<br>' * 8)
return_list.append( return_list.append(
(chapter_titles[-1], bs_obj_string)) (chapter_titles[-1], bs_obj_string))

View File

@@ -179,7 +179,7 @@ class Tab(QtWidgets.QWidget):
# This avoids confusion with potentially duplicate phrases # This avoids confusion with potentially duplicate phrases
# And the found result is at the top of the window # And the found result is at the top of the window
scroll_position = scroll_value * self.contentView.verticalScrollBar().maximum() scroll_position = scroll_value * self.contentView.verticalScrollBar().maximum()
self.contentView.verticalScrollBar().setValue(scroll_position * 1.1) self.contentView.verticalScrollBar().setValue(scroll_position * 1.02)
try: try:
search_text = self.metadata['position']['last_visible_text'] search_text = self.metadata['position']['last_visible_text']
@@ -187,7 +187,17 @@ class Tab(QtWidgets.QWidget):
search_text = search_data[1] search_text = search_data[1]
if search_text: if search_text:
self.contentView.find(search_text) find_backward = False
find_forward = self.contentView.find(search_text)
if not find_forward:
find_backward = self.contentView.find(
search_text, QtGui.QTextDocument.FindBackward)
if find_backward:
current_scroll_position = self.contentView.verticalScrollBar().value()
new_scroll_position = current_scroll_position * .98
self.contentView.verticalScrollBar().setValue(new_scroll_position)
text_cursor = self.contentView.textCursor() text_cursor = self.contentView.textCursor()
text_cursor.clearSelection() text_cursor.clearSelection()