worked on Kivy fixes part 2

This commit is contained in:
navjot 2019-12-13 21:50:27 +05:30
parent 31100e9a45
commit 4390a68b30
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
2 changed files with 27 additions and 28 deletions

View File

@ -20,7 +20,7 @@ def search_sql(xAddress="toaddress", account=None, folder="inbox", where=None, w
sqlStatementBase = '''SELECT label, address From addressbook ''' sqlStatementBase = '''SELECT label, address From addressbook '''
else: else:
sqlStatementBase = ( sqlStatementBase = (
'''SELECT folder, msgid, toaddress, message, fromaddress, subject,''' '''SELECT folder, toaddress, message, fromaddress, subject,'''
''' received, read FROM inbox ''') ''' received, read FROM inbox ''')
sqlStatementParts = [] sqlStatementParts = []

View File

@ -237,8 +237,7 @@ class Inbox(Screen):
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""Delete inbox mail from inbox listing""" """Delete inbox mail from inbox listing"""
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index)
data_index))
try: try:
msg_count_objs = ( msg_count_objs = (
self.parent.parent.parent.parent.children[2].children[0].ids) self.parent.parent.parent.parent.children[2].children[0].ids)
@ -267,8 +266,7 @@ class Inbox(Screen):
def archive(self, data_index, instance, *args): def archive(self, data_index, instance, *args):
"""Archive inbox mail from inbox listing""" """Archive inbox mail from inbox listing"""
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", data_index)
data_index))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
@ -601,11 +599,11 @@ class DropDownWidget(BoxLayout):
fromAddress, fromAddress,
subject, subject,
message, message,
str(state.send_draft_mail)) state.send_draft_mail)
self.parent.parent.screens[15].clear_widgets() self.parent.parent.screens[15].clear_widgets()
self.parent.parent.screens[15].add_widget(Draft()) self.parent.parent.screens[15].add_widget(Draft())
state.detailPageType = '' # state.detailPageType = ''
state.send_draft_mail = None # state.send_draft_mail = None
else: else:
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
@ -645,6 +643,12 @@ class DropDownWidget(BoxLayout):
state.check_sent_acc = fromAddress state.check_sent_acc = fromAddress
state.msg_counter_objs = self.parent.parent.parent.parent\ state.msg_counter_objs = self.parent.parent.parent.parent\
.parent.parent.children[2].children[0].ids .parent.parent.children[2].children[0].ids
if state.detailPageType == 'draft' \
and state.send_draft_mail:
state.draft_count = str(int(state.draft_count) - 1)
state.msg_counter_objs.draft_cnt.badge_text = state.draft_count
state.detailPageType = ''
state.send_draft_mail = None
# self.parent.parent.screens[0].ids.ml.clear_widgets() # self.parent.parent.screens[0].ids.ml.clear_widgets()
# self.parent.parent.screens[0].loadMessagelist(state.association) # self.parent.parent.screens[0].loadMessagelist(state.association)
self.parent.parent.screens[3].update_sent_messagelist() self.parent.parent.screens[3].update_sent_messagelist()
@ -681,7 +685,7 @@ class DropDownWidget(BoxLayout):
msg_dialog.open() msg_dialog.open()
@staticmethod @staticmethod
def callback_for_menu_items(text_item): def callback_for_menu_items(text_item, *arg):
"""Callback of alert box""" """Callback of alert box"""
toast(text_item) toast(text_item)
@ -1068,7 +1072,7 @@ class Sent(Screen):
state.all_count = str(int(state.all_count) - 1) state.all_count = str(int(state.all_count) - 1)
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash'" "UPDATE sent SET folder = 'trash'"
" WHERE ackdata = ?;", str(data_index)) " WHERE ackdata = ?;", data_index)
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
toast('Deleted') toast('Deleted')
self.update_trash() self.update_trash()
@ -1077,7 +1081,7 @@ class Sent(Screen):
"""Archive sent mail from sent mail listing""" """Archive sent mail from sent mail listing"""
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash'" "UPDATE sent SET folder = 'trash'"
" WHERE ackdata = ?;", str(data_index)) " WHERE ackdata = ?;", data_index)
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
self.update_trash() self.update_trash()
@ -1099,7 +1103,7 @@ class Trash(Screen):
"""Trash Screen uses screen to show widgets of screens""" """Trash Screen uses screen to show widgets of screens"""
trash_messages = ListProperty() trash_messages = ListProperty()
has_refreshed = True has_refreshed = True
delete_index = StringProperty() # delete_index = StringProperty()
table_name = StringProperty() table_name = StringProperty()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -1214,7 +1218,7 @@ class Trash(Screen):
events_callback=self.callback_for_delete_msg) events_callback=self.callback_for_delete_msg)
delete_msg_dialog.open() delete_msg_dialog.open()
def callback_for_delete_msg(self, text_item): def callback_for_delete_msg(self, text_item, *arg):
"""Getting the callback of alert box""" """Getting the callback of alert box"""
if text_item == 'Yes': if text_item == 'Yes':
self.delete_message_from_trash() self.delete_message_from_trash()
@ -1225,11 +1229,9 @@ class Trash(Screen):
"""Deleting message from trash""" """Deleting message from trash"""
self.children[1].active = True self.children[1].active = True
if self.table_name == 'inbox': if self.table_name == 'inbox':
sqlExecute("DELETE FROM inbox WHERE msgid = ?;", str( sqlExecute("DELETE FROM inbox WHERE msgid = ?;", self.delete_index)
self.delete_index))
elif self.table_name == 'sent': elif self.table_name == 'sent':
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str( sqlExecute("DELETE FROM sent WHERE ackdata = ?;", self.delete_index)
self.delete_index))
msg_count_objs = state.kivyapp.root.children[2].children[0].ids msg_count_objs = state.kivyapp.root.children[2].children[0].ids
if int(state.trash_count) > 0: if int(state.trash_count) > 0:
msg_count_objs.trash_cnt.badge_text = str( msg_count_objs.trash_cnt.badge_text = str(
@ -1956,7 +1958,7 @@ class MailDetail(Screen):
2].children[1].ids.search_field.text = '' 2].children[1].ids.search_field.text = ''
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash' WHERE" "UPDATE sent SET folder = 'trash' WHERE"
" ackdata = ?;", str(state.mail_id)) " ackdata = ?;", state.mail_id)
msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1) msg_count_objs.send_cnt.badge_text = str(int(state.sent_count) - 1)
state.sent_count = str(int(state.sent_count) - 1) state.sent_count = str(int(state.sent_count) - 1)
self.parent.screens[3].ids.ml.clear_widgets() self.parent.screens[3].ids.ml.clear_widgets()
@ -1968,7 +1970,7 @@ class MailDetail(Screen):
1].ids.search_field.text = '' 1].ids.search_field.text = ''
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE" "UPDATE inbox SET folder = 'trash' WHERE"
" msgid = ?;", str(state.mail_id)) " msgid = ?;", state.mail_id)
msg_count_objs.inbox_cnt.badge_text = str( msg_count_objs.inbox_cnt.badge_text = str(
int(state.inbox_count) - 1) int(state.inbox_count) - 1)
state.inbox_count = str(int(state.inbox_count) - 1) state.inbox_count = str(int(state.inbox_count) - 1)
@ -1976,8 +1978,7 @@ class MailDetail(Screen):
self.parent.screens[0].loadMessagelist(state.association) self.parent.screens[0].loadMessagelist(state.association)
elif state.detailPageType == 'draft': elif state.detailPageType == 'draft':
sqlExecute("DELETE FROM sent WHERE ackdata = ?;", str( sqlExecute("DELETE FROM sent WHERE ackdata = ?;", state.mail_id)
state.mail_id))
msg_count_objs.draft_cnt.badge_text = str( msg_count_objs.draft_cnt.badge_text = str(
int(state.draft_count) - 1) int(state.draft_count) - 1)
state.draft_count = str(int(state.draft_count) - 1) state.draft_count = str(int(state.draft_count) - 1)
@ -1993,8 +1994,8 @@ class MailDetail(Screen):
int(state.all_count) - 1) int(state.all_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
state.all_count = str(int(state.all_count) - 1) state.all_count = str(int(state.all_count) - 1)
self.parent.screens[4].ids.ml.clear_widgets() self.parent.screens[4].clear_widgets()
self.parent.screens[4].init_ui(dt=0) self.parent.screens[4].add_widget(Trash())
self.parent.screens[16].ids.ml.clear_widgets() self.parent.screens[16].ids.ml.clear_widgets()
self.parent.screens[16].init_ui(dt=0) self.parent.screens[16].init_ui(dt=0)
Clock.schedule_once(self.callback_for_delete, 4) Clock.schedule_once(self.callback_for_delete, 4)
@ -2012,7 +2013,7 @@ class MailDetail(Screen):
"""Reply inbox messages""" """Reply inbox messages"""
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message from inbox where" "select toaddress, fromaddress, subject, message from inbox where"
" msgid = ?;", str(state.mail_id)) " msgid = ?;", state.mail_id)
composer_obj = self.parent.screens[2].children[1].ids composer_obj = self.parent.screens[2].children[1].ids
composer_obj.ti.text = data[0][0] composer_obj.ti.text = data[0][0]
composer_obj.btn.text = data[0][0] composer_obj.btn.text = data[0][0]
@ -2485,12 +2486,10 @@ class Allmails(Screen):
"""Delete inbox mail from all mail listing""" """Delete inbox mail from all mail listing"""
if folder == 'inbox': if folder == 'inbox':
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", str( "UPDATE inbox SET folder = 'trash' WHERE msgid = ?;", unique_id)
unique_id))
else: else:
sqlExecute( sqlExecute(
"UPDATE sent SET folder = 'trash' WHERE ackdata = ?;", str( "UPDATE sent SET folder = 'trash' WHERE ackdata = ?;", unique_id)
unique_id))
self.ids.ml.remove_widget(instance.parent.parent) self.ids.ml.remove_widget(instance.parent.parent)
try: try:
msg_count_objs = self.parent.parent.parent.parent.parent.children[ msg_count_objs = self.parent.parent.parent.parent.parent.children[