wokred on addressbook search functionality implementation
This commit is contained in:
parent
27dbbe4b30
commit
d5f99cc209
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -18,3 +18,5 @@ dist
|
||||||
docs/_*/*
|
docs/_*/*
|
||||||
docs/autodoc/
|
docs/autodoc/
|
||||||
pyan/
|
pyan/
|
||||||
|
.buildozer/
|
||||||
|
bin/
|
|
@ -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,15 +27,16 @@ 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 None:
|
if folder is not "addressbook":
|
||||||
if folder == "new":
|
if folder is not None:
|
||||||
folder = "inbox"
|
if folder == "new":
|
||||||
unreadOnly = True
|
folder = "inbox"
|
||||||
sqlStatementParts.append("folder = ? ")
|
unreadOnly = True
|
||||||
sqlArguments.append(folder)
|
sqlStatementParts.append("folder = ? ")
|
||||||
else:
|
sqlArguments.append(folder)
|
||||||
sqlStatementParts.append("folder != ?")
|
else:
|
||||||
sqlArguments.append("trash")
|
sqlStatementParts.append("folder != ?")
|
||||||
|
sqlArguments.append("trash")
|
||||||
if what is not None:
|
if what is not None:
|
||||||
for colmns in where:
|
for colmns in where:
|
||||||
if len(where) > 1:
|
if len(where) > 1:
|
||||||
|
|
|
@ -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):
|
||||||
|
|
Reference in New Issue
Block a user