From 293e171a478df7e4be9a1bfb70c1cb7c5ec99b21 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Thu, 21 Apr 2022 19:54:33 +0530 Subject: [PATCH] Added delete() in helper_sent, common method for empty screen in common.py and called in draft.py --- src/bitmessagekivy/baseclass/common.py | 14 +++++++++++ src/bitmessagekivy/baseclass/draft.py | 9 +++---- src/bitmessagekivy/baseclass/draft_widgets.py | 24 +++++++++---------- src/helper_sent.py | 3 +++ 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/bitmessagekivy/baseclass/common.py b/src/bitmessagekivy/baseclass/common.py index 70b750fd..48417bed 100644 --- a/src/bitmessagekivy/baseclass/common.py +++ b/src/bitmessagekivy/baseclass/common.py @@ -17,6 +17,7 @@ from kivy.properties import ( StringProperty ) +from kivymd.uix.label import MDLabel ThemeClsColor = [0.12, 0.58, 0.95, 1] @@ -142,3 +143,16 @@ class CutsomSwipeToDeleteItem(MDCardSwipe): cla = Window.size[0] / 2 swipe_distance = NumericProperty(cla) opening_time = NumericProperty(0.5) + + +def empty_screen_label(label_str): + """This function returns default message while no address is there.""" + # empty_screen_msg = "yet no message for this account!!!!!!!!!!!!!" + content = MDLabel( + font_style='Caption', + theme_text_color='Primary', + text=label_str, + halign='center', + size_hint_y=None, + valign='top') + return content diff --git a/src/bitmessagekivy/baseclass/draft.py b/src/bitmessagekivy/baseclass/draft.py index fdbc1852..3ddbcd04 100644 --- a/src/bitmessagekivy/baseclass/draft.py +++ b/src/bitmessagekivy/baseclass/draft.py @@ -24,7 +24,7 @@ from kivy.uix.screenmanager import Screen from bitmessagekivy import kivy_helper_search from bitmessagekivy.baseclass.common import ( showLimitedCnt, toast, ThemeClsColor, - SwipeToDeleteItem, ShowTimeHistoy + SwipeToDeleteItem, ShowTimeHistoy, empty_screen_label ) from bitmessagekivy.baseclass.maildetail import MailDetail from bitmessagekivy.baseclass.draft_widgets import HelperDraft @@ -34,7 +34,7 @@ from addresses import decodeAddress import state from helper_sql import sqlExecute - +import helper_sent class Draft(Screen, HelperDraft): """Draft screen class for kivy Ui""" @@ -85,7 +85,8 @@ class Draft(Screen, HelperDraft): # halign='center', # size_hint_y=None, # valign='top') - self.ids.ml.add_widget(self.default_label_when_empty()) + label_str = "yet no message for this account!!!!!!!!!!!!!2" + self.ids.ml.add_widget(empty_screen_label(label_str)) def draftDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20): """This methosd is for retrieving draft messages""" @@ -160,7 +161,7 @@ class Draft(Screen, HelperDraft): def delete_draft(self, data_index, instance, *args): """Delete draft message permanently""" - sqlExecute("DELETE FROM sent WHERE ackdata = ?", data_index) + helper_sent.delete(data_index) if int(state.draft_count) > 0: state.draft_count = str(int(state.draft_count) - 1) self.set_draftCnt(state.draft_count) diff --git a/src/bitmessagekivy/baseclass/draft_widgets.py b/src/bitmessagekivy/baseclass/draft_widgets.py index 42d1782e..a22981cd 100644 --- a/src/bitmessagekivy/baseclass/draft_widgets.py +++ b/src/bitmessagekivy/baseclass/draft_widgets.py @@ -16,15 +16,15 @@ class HelperDraft(object): def __init__(self): pass - @staticmethod - def default_label_when_empty(): - """This function returns default message while no address is there.""" - empty_screen_msg = "yet no message for this account!!!!!!!!!!!!!" - content = MDLabel( - font_style='Caption', - theme_text_color='Primary', - text=empty_screen_msg, - halign='center', - size_hint_y=None, - valign='top') - return content + # @staticmethod + # def default_label_when_empty(): + # """This function returns default message while no address is there.""" + # empty_screen_msg = "yet no message for this account!!!!!!!!!!!!!" + # content = MDLabel( + # font_style='Caption', + # theme_text_color='Primary', + # text=empty_screen_msg, + # halign='center', + # size_hint_y=None, + # valign='top') + # return content diff --git a/src/helper_sent.py b/src/helper_sent.py index 47fc5bb4..e684f2eb 100644 --- a/src/helper_sent.py +++ b/src/helper_sent.py @@ -7,3 +7,6 @@ from helper_sql import sqlExecute def insert(t): """Perform an insert into the `sent` table""" sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t) + +def delete(data_index): + sqlExecute("DELETE FROM sent WHERE ackdata = ?", data_index) \ No newline at end of file