kindle manager
This commit is contained in:
63
kmanapp.py
63
kmanapp.py
@@ -2,6 +2,9 @@
|
||||
import sys
|
||||
from PySide2.QtWidgets import QApplication
|
||||
from PySide2.QtWidgets import QMainWindow
|
||||
from PySide2.QtGui import QStandardItemModel
|
||||
from PySide2.QtGui import QStandardItem
|
||||
|
||||
from mainwindow import Ui_MainWindow
|
||||
from kman import *
|
||||
|
||||
@@ -10,20 +13,22 @@ class kmanWindow(QMainWindow):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(kmanWindow, self).__init__(*args, **kwargs)
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(kmanWindow, self).__init__(parent)
|
||||
|
||||
self.stat_str = 'status information'
|
||||
self.search_str = ''
|
||||
|
||||
# create ui and initial it
|
||||
ui = Ui_MainWindow()
|
||||
ui.setupUi(self)
|
||||
self.ui = ui
|
||||
|
||||
books = import_clips()
|
||||
self.books = import_clips()
|
||||
|
||||
# connect action to slot functions
|
||||
ui.actionimportkindle.triggered.connect(lambda: self.importkindle(books))
|
||||
ui.actionimportlocal.triggered.connect(lambda: self.importlocal())
|
||||
# connect action/toolbutton to slot functions
|
||||
ui.actionimportkindle.triggered.connect(lambda: self.import_kindle(self.books))
|
||||
ui.actionimportlocal.triggered.connect(lambda: self.import_local())
|
||||
ui.actionconfig.triggered.connect(lambda: self.config())
|
||||
ui.actionwords.triggered.connect(lambda: self.words())
|
||||
ui.actionstatistic.triggered.connect(lambda: self.statistic())
|
||||
@@ -31,13 +36,56 @@ class kmanWindow(QMainWindow):
|
||||
ui.actionabout.triggered.connect(lambda: self.about())
|
||||
ui.actionflush.triggered.connect(lambda: self.flush())
|
||||
|
||||
ui.searchComboBox.currentIndexChanged.connect(self.search_scope_change)
|
||||
ui.searchToolButton.clicked.connect(self.search_button_clicked)
|
||||
ui.treeView.activated.connect(self.activated_items)
|
||||
|
||||
self.add_ui_component()
|
||||
#add_ui_component() ###! can not found this function
|
||||
|
||||
def add_ui_component(self):
|
||||
self.ui.searchComboBox.addItems(['ALL','bookname','content','author'])
|
||||
|
||||
#inert test data xxxxxxxx
|
||||
model = QStandardItemModel()
|
||||
rootItem = model.invisibleRootItem()
|
||||
for i in range(4):
|
||||
item = QStandardItem('item {}'.format(i))
|
||||
rootItem.appendRow(item)
|
||||
if i==0:
|
||||
parentItem = item
|
||||
parentItem.appendRows([QStandardItem('append rows {}'.format(i+10)) for i in range(5)])
|
||||
if i==3:
|
||||
parentItem = item
|
||||
for i in range(5):
|
||||
item = QStandardItem('another item {}'.format(i+4))
|
||||
#item.setEnabled(False)
|
||||
item.setEditable(False)
|
||||
parentItem.appendRow(item)
|
||||
|
||||
self.ui.treeView.setModel(model)
|
||||
|
||||
|
||||
def activated_items(self):
|
||||
print( 'call activated_items()' )
|
||||
|
||||
def search_button_clicked(self):
|
||||
print( 'call search_button_clicked()' )
|
||||
|
||||
def search_scope_change(self,t):
|
||||
p = {0:'ALL',1:'TITLE',2:'AUTHOR',3:'CONTENT'}
|
||||
s = self.ui.searchLineEdit.text()
|
||||
#print(self.books)
|
||||
#print(search_clip(self.books,s,'ALL',p[t]))
|
||||
print('call search_scope_change()')
|
||||
|
||||
# define slot functions
|
||||
def importkindle(self,bks):
|
||||
def import_kindle(self,bks):
|
||||
print("call slot importkindle()")
|
||||
print(bks)
|
||||
pass
|
||||
|
||||
def importlocal(self):
|
||||
def import_local(self):
|
||||
print("call slot importlocal()")
|
||||
pass
|
||||
|
||||
@@ -78,3 +126,4 @@ if __name__ == "__main__":
|
||||
kmw.resize(900, 600)
|
||||
kmw.show()
|
||||
app.exec_()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user