can now browse books by category
This commit is contained in:
parent
83ffb5502d
commit
259fe99b4a
15
browser.py
15
browser.py
|
@ -347,6 +347,10 @@ class bookBrowser(browserWindow):
|
|||
self.entries = db.getBooks()
|
||||
self.selected = map(lambda x:False, self.entries)
|
||||
|
||||
def refreshBooksInCategory(self,cat):
|
||||
self.entries = db.getBooksByCategory(cat)
|
||||
self.selected = map(lambda x:False, self.entries)
|
||||
|
||||
def handleInput(self,ch):
|
||||
browserWindow.handleInput(self,ch)
|
||||
if ch == 117: #update on 'u'
|
||||
|
@ -393,6 +397,14 @@ class categoryBrowser(browserWindow):
|
|||
db.addCategory(c)
|
||||
cf.clear()
|
||||
|
||||
def viewCategory(self):
|
||||
w = curses.newwin(20,80,20,20)
|
||||
b = bookBrowser(w,self.hb)
|
||||
self.centreChild(w)
|
||||
b.refreshBooksInCategory(self.entries[self.hl])
|
||||
b.eventLoop()
|
||||
b.clear()
|
||||
|
||||
def delSelected(self):
|
||||
categories = []
|
||||
for sel,cat in zip(self.selected, self.entries):
|
||||
|
@ -406,6 +418,9 @@ class categoryBrowser(browserWindow):
|
|||
self.addCategory()
|
||||
self.refreshCategories()
|
||||
self.refresh()
|
||||
if ch ==10:
|
||||
self.viewCategory()
|
||||
self.refresh()
|
||||
if ch==100:
|
||||
count=0
|
||||
for s in self.selected[0:self.hl-1]:
|
||||
|
|
|
@ -145,7 +145,7 @@ def getBooks():
|
|||
def getBooksByCategory(cat):
|
||||
conn = sqlite3.connect(dbFile)
|
||||
c = conn.cursor()
|
||||
query = "SELECT "+",".join(mapt(colify,columns))+" FROM "+bookTable+" JOIN "+bookCategoryTable+" USING (id) WHERE cat_id = :id;"
|
||||
query = "SELECT "+",".join(map(colify,columns))+" FROM "+bookTable+" JOIN "+bookCategoryTable+" USING (id) WHERE cat_id = :id;"
|
||||
c.execute(query,cat)
|
||||
books = []
|
||||
for b in c:
|
||||
|
|
Loading…
Reference in New Issue