Skip to content

Commit e396a9a

Browse files
committed
Editor OK
1 parent 2f8fa9d commit e396a9a

13 files changed

+427
-385
lines changed

editor/checkpoint.ui

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
<slot>accept()</slot>
6363
<hints>
6464
<hint type="sourcelabel">
65-
<x>248</x>
66-
<y>254</y>
65+
<x>190</x>
66+
<y>190</y>
6767
</hint>
6868
<hint type="destinationlabel">
6969
<x>157</x>
@@ -78,8 +78,8 @@
7878
<slot>reject()</slot>
7979
<hints>
8080
<hint type="sourcelabel">
81-
<x>316</x>
82-
<y>260</y>
81+
<x>190</x>
82+
<y>190</y>
8383
</hint>
8484
<hint type="destinationlabel">
8585
<x>286</x>

editor/content_table_editor.py

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ def __init__(self, parent):
2727
self.button_box.button(QtWidgets.QDialogButtonBox.Cancel).setText(lng['Editor']['ContentTableWindow']['btnCancel'])
2828

2929
def open_exec(self, text: str = None):
30-
if text is not None:
31-
self.line_edit.setText(text)
32-
ret = self.exec_()
33-
if ret == 1:
34-
print('name = ', self.line_edit.text())
35-
return self.line_edit.text()
36-
else:
37-
return None
30+
try:
31+
if text is not None:
32+
self.line_edit.setText(text)
33+
ret = self.exec_()
34+
if ret == 1:
35+
print('name = ', self.line_edit.text())
36+
return self.line_edit.text()
37+
else:
38+
return None
39+
except Exception:
40+
traceback.print_exc()
3841

3942

4043
class ContentTableWindow(QDialog):
@@ -73,52 +76,55 @@ def __init__(self, parent, folder: str):
7376
self.files = []
7477

7578
def open_exec(self, text: str = None, url: str = None):
76-
self.list_content.clear()
77-
self.addindex_combobox.clear()
78-
79-
self.files = common.files.list_directory_tree(self.folder, 'html|xhtml')
80-
files = common.files.list_directory(self.folder, 'html|xhtml')
81-
self.addindex_combobox.addItem("")
82-
83-
print(self.files)
84-
for file in files:
85-
self.addindex_combobox.addItem(file.replace(self.folder, ""))
86-
87-
li = common.files.list_directory(self.folder, "opf")
88-
data = ''
89-
with open(li[0]) as myfile:
90-
data = myfile.read()
91-
toc_type, chapters = parse_content_table(
92-
data,
93-
li[0].replace(self.folder, '').replace(li[0][li[0].rindex(os.sep) + 1:], '').replace(os.sep, '/'),
94-
self.folder
95-
)
96-
for chapter in chapters:
97-
try:
98-
item = QtWidgets.QListWidgetItem()
99-
item.setText(chapter['name'] + " (" + chapter['src'] + ")")
100-
item.setData(97, chapter['name'])
101-
item.setData(98, chapter['src'])
102-
103-
self.list_content.addItem(item)
104-
except Exception:
105-
traceback.print_exc()
106-
107-
ret = self.exec_()
108-
109-
content_table = []
110-
max = self.list_content.count()
111-
i = 0
112-
while i < max:
113-
child = self.list_content.item(i)
114-
content_table.append({'name': child.data(97), 'url': child.data(98).replace("\\", "/")})
115-
i += 1
116-
117-
print(content_table)
118-
if ret == 1:
119-
return content_table
120-
else:
121-
return None
79+
try:
80+
self.list_content.clear()
81+
self.addindex_combobox.clear()
82+
83+
self.files = common.files.list_directory_tree(self.folder, 'html|xhtml')
84+
files = common.files.list_directory(self.folder, 'html|xhtml')
85+
self.addindex_combobox.addItem("")
86+
87+
print(self.files)
88+
for file in files:
89+
self.addindex_combobox.addItem(file.replace(self.folder, ""))
90+
91+
li = common.files.list_directory(self.folder, "opf")
92+
data = ''
93+
with open(li[0]) as myfile:
94+
data = myfile.read()
95+
toc_type, chapters = parse_content_table(
96+
data,
97+
li[0].replace(self.folder, '').replace(li[0][li[0].rindex(os.sep) + 1:], '').replace(os.sep, '/'),
98+
self.folder
99+
)
100+
for chapter in chapters:
101+
try:
102+
item = QtWidgets.QListWidgetItem()
103+
item.setText(chapter['name'] + " (" + chapter['src'] + ")")
104+
item.setData(97, chapter['name'])
105+
item.setData(98, chapter['src'])
106+
107+
self.list_content.addItem(item)
108+
except Exception:
109+
traceback.print_exc()
110+
111+
ret = self.exec_()
112+
113+
content_table = []
114+
max = self.list_content.count()
115+
i = 0
116+
while i < max:
117+
child = self.list_content.item(i)
118+
content_table.append({'name': child.data(97), 'url': child.data(98).replace("\\", "/")})
119+
i += 1
120+
121+
print(content_table)
122+
if ret == 1:
123+
return content_table
124+
else:
125+
return None
126+
except Exception:
127+
traceback.print_exc()
122128

123129
def new_index(self):
124130
# self.addindex_line_edit = QLineEdit()

editor/content_table_editor.ui

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@
329329
<slot>accept()</slot>
330330
<hints>
331331
<hint type="sourcelabel">
332-
<x>248</x>
333-
<y>254</y>
332+
<x>522</x>
333+
<y>339</y>
334334
</hint>
335335
<hint type="destinationlabel">
336336
<x>157</x>
@@ -345,8 +345,8 @@
345345
<slot>reject()</slot>
346346
<hints>
347347
<hint type="sourcelabel">
348-
<x>316</x>
349-
<y>260</y>
348+
<x>522</x>
349+
<y>339</y>
350350
</hint>
351351
<hint type="destinationlabel">
352352
<x>286</x>

0 commit comments

Comments
 (0)