kindle manager

This commit is contained in:
gavin
2020-06-28 21:16:21 +08:00
parent 616cef3061
commit 5cfab9c98e
4 changed files with 112 additions and 44 deletions

View File

@@ -372,10 +372,11 @@ class kmanWindow(QMainWindow):
def tree_item_clicked(self, modelidx):
# modelidx is a QModelIndex object
model_index_list = self.ui.treeView.selectedIndexes() # QModelIndexList
model_index = model_index_list[0] # QModelIndex
itemmodel = model_index.model() #QAbstractItemModel/QStandardItemModel
item = itemmodel.itemFromIndex(modelidx) #QStandardItem
item = itemmodel.itemFromIndex(model_index) #QStandardItem
self.tree_selected = item.accessibleDescription()
print(self.tree_selected, item.text())
@@ -491,28 +492,47 @@ class kmanWindow(QMainWindow):
# tableview item selected
if table_index_list:
model_index = table_index_list[0] # QModelIndex
print('contextMenuEvent pos {}'.format(event.globalPos()))
menu = QMenu()
copyAction = menu.addAction("Copy")
copy_action = menu.addAction(u"Copy")
action = menu.exec_(self.mapToGlobal(event.pos()))
if action ==copyAction:
self.copyAction(model_index.row(), model_index.column())
elif tree_index_list and self.tree_selected.split('_')[0]=='info':
if action ==copy_action:
self.copy_action(model_index.row(), model_index.column())
elif tree_index_list:
model_index = tree_index_list[0] # QModelIndex
print('contextMenuEvent pos {}'.format(event.globalPos()))
itemmodel = model_index.model() #QAbstractItemModel/QStandardItemModel
item = itemmodel.itemFromIndex(model_index) #QStandardItem
pp = self.tree_selected.split('_')[0]
menu = QMenu()
copyAction = menu.addAction("Copy")
action = menu.exec_(self.mapToGlobal(event.pos()))
if action ==copyAction:
self.copyAction(model_index.row(), model_index.column())
[copy_info_action, export_note_action, export_word_action] = \
[None, None, None]
if pp=='info':
copy_info_action = menu.addAction(u"Copy")
elif pp=='note':
export_note_action = menu.addAction(u"Export Notes")
elif pp=='word':
export_word_action = menu.addAction(u"Export Notes")
else: pass
def copyAction(self, row, column):
action = menu.exec_(self.mapToGlobal(event.pos()))
fn = self.tree_selected+item.text().split('(')[0].strip()
if action==copy_info_action:
action = menu.exec_(self.mapToGlobal(event.pos()))
self.copy_action(model_index.row(), model_index.column())
elif action==export_note_action: self.export_filter_notes(fn)
elif action==export_word_action: self.export_filter_words(fn)
else: pass
else: pass
print('contextMenuEvent pos {}'.format(event.globalPos()))
def copy_action(self, row, column):
import clipboard
clipboard.copy(self.copyinfo)
print('copyAction row {} column {}'.format(row, column))
print('copy_action row {} column {}'.format(row, column))
def search_return_press(self):
self.search_button_clicked()
@@ -725,18 +745,22 @@ class kmanWindow(QMainWindow):
pass
def export(self):
if self.tree_selected.split('_')[0]=='note':
self.export_filter_notes()
else:
self.export_filter_words()
pp = self.tree_selected.split('_')[0]
if pp=='note':
self.export_filter_notes('export')
elif pp=='word':
self.export_filter_words('export')
else: # info
pass
print("call export()")
def export_filter_notes(self):
self.km.export_notes(self.filter_books, 'export', ft='MD')
def export_filter_notes(self, fn):
self.km.export_notes(self.filter_books, fn, ft='MD')
pass
def export_filter_words(self):
self.km.export_words(self.words_data, self.filter_list, 'export', ft='MD')
def export_filter_words(self, fn):
self.km.export_words(self.words_data, self.filter_list, fn, ft='MD')
pass
def messagebox(self, ico=1, info=''):