130 lines
3.8 KiB
Python
130 lines
3.8 KiB
Python
|
|
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 *
|
|
|
|
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
|
|
|
|
self.books = import_clips()
|
|
|
|
# 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())
|
|
ui.actionhomepage.triggered.connect(lambda: self.homepage())
|
|
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 import_kindle(self,bks):
|
|
print("call slot importkindle()")
|
|
print(bks)
|
|
pass
|
|
|
|
def import_local(self):
|
|
print("call slot importlocal()")
|
|
pass
|
|
|
|
def config(self):
|
|
print("call slot config()")
|
|
pass
|
|
|
|
def words(self):
|
|
print("call slot words()")
|
|
pass
|
|
|
|
def statistic(self):
|
|
print("call slot statistic()")
|
|
pass
|
|
|
|
def homepage(self):
|
|
print("call slot homepage()")
|
|
pass
|
|
|
|
def about(self):
|
|
print("call slot about()")
|
|
pass
|
|
|
|
def flush(self):
|
|
print("call slot flush()")
|
|
pass
|
|
|
|
def messageBox(self, showInfo):
|
|
box = QMessageBox.about(self, 'Kindle Management', showInfo)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
from PySide2.QtWidgets import QApplication, QLabel
|
|
|
|
app = QApplication(sys.argv)
|
|
kmw = kmanWindow()
|
|
kmw.resize(900, 600)
|
|
kmw.show()
|
|
app.exec_()
|
|
|