wokred on addressbook search functionality implementation

This commit is contained in:
cis 2019-08-07 21:09:46 +05:30
parent 27dbbe4b30
commit d5f99cc209
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
3 changed files with 35 additions and 19 deletions

2
.gitignore vendored
View File

@ -18,3 +18,5 @@ dist
docs/_*/* docs/_*/*
docs/autodoc/ docs/autodoc/
pyan/ pyan/
.buildozer/
bin/

View File

@ -11,9 +11,12 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
sqlStatementBase = ''' sqlStatementBase = '''
SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime
FROM sent ''' FROM sent '''
elif folder == "addressbook":
sqlStatementBase = '''SELECT label, address From addressbook '''
else: else:
sqlStatementBase = '''SELECT folder, msgid, toaddress, message, fromaddress, subject, received, read sqlStatementBase = '''SELECT folder, msgid, toaddress, message, fromaddress, subject, received, read
FROM inbox ''' FROM inbox '''
sqlStatementParts = [] sqlStatementParts = []
sqlArguments = [] sqlArguments = []
if account is not None: if account is not None:
@ -24,6 +27,7 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
else: else:
sqlStatementParts.append(xAddress + " = ? ") sqlStatementParts.append(xAddress + " = ? ")
sqlArguments.append(account) sqlArguments.append(account)
if folder is not "addressbook":
if folder is not None: if folder is not None:
if folder == "new": if folder == "new":
folder = "inbox" folder = "inbox"

View File

@ -290,10 +290,20 @@ class AddressBook(Screen):
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method inbox accounts.""" """Clock Schdule for method AddressBook"""
data = sqlQuery("SELECT label, address from addressbook") self.loadAddresslist(None, 'All', '')
if data: print(dt)
for item in data:
def loadAddresslist(self, account, where="", what=""):
"""Clock Schdule for method AddressBook"""
if state.searcing_text:
where = ['label', 'address']
what = state.searcing_text
xAddress = ''
queryreturn = kivy_helper_search.search_sql(
xAddress, account, "addressbook", where, what, False)
if queryreturn:
for item in queryreturn:
meny = TwoLineAvatarIconListItem( meny = TwoLineAvatarIconListItem(
text=item[0], text=item[0],
secondary_text=item[1], secondary_text=item[1],
@ -1088,6 +1098,9 @@ class NavigateApp(App):
if state.search_screen == 'inbox': if state.search_screen == 'inbox':
self.root.ids.sc1.clear_widgets() self.root.ids.sc1.clear_widgets()
self.root.ids.sc1.add_widget(Inbox()) self.root.ids.sc1.add_widget(Inbox())
elif state.search_screen == 'addressbook':
self.root.ids.sc11.clear_widgets()
self.root.ids.sc11.add_widget(AddressBook())
else: else:
self.root.ids.sc4.clear_widgets() self.root.ids.sc4.clear_widgets()
self.root.ids.sc4.add_widget(Sent()) self.root.ids.sc4.add_widget(Sent())
@ -1095,7 +1108,7 @@ class NavigateApp(App):
def check_search_screen(self, instance): def check_search_screen(self, instance):
"""Method show search button only on inbox or sent screen.""" """Method show search button only on inbox or sent screen."""
if instance.text == 'Inbox' or instance.text == 'Sent': if instance.text in ['Inbox', 'Sent', 'Address Book']:
if not self.root.ids.search_bar.children: if not self.root.ids.search_bar.children:
self.root.ids.search_bar.add_widget( self.root.ids.search_bar.add_widget(
MDIconButton(icon='magnify')) MDIconButton(icon='magnify'))
@ -1103,13 +1116,10 @@ class NavigateApp(App):
id='search_field', hint_text='Search icon') id='search_field', hint_text='Search icon')
text_field.bind(text=self.searchQuery) text_field.bind(text=self.searchQuery)
self.root.ids.search_bar.add_widget(text_field) self.root.ids.search_bar.add_widget(text_field)
state.searcing_text = '' self.root.ids.search_bar.children[0].text = ''
self.root.ids.sc1.clear_widgets()
self.root.ids.sc4.clear_widgets()
self.root.ids.sc1.add_widget(Inbox())
self.root.ids.sc4.add_widget(Sent())
else: else:
self.root.ids.search_bar.clear_widgets() self.root.ids.search_bar.clear_widgets()
state.searcing_text = ''
return return
def add_search_bar(self): def add_search_bar(self):