Added delete() in helper_sent, common method for empty screen in common.py and called in draft.py

This commit is contained in:
shekhar-cis 2022-04-21 19:54:33 +05:30
parent 3369379eba
commit 293e171a47
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7
4 changed files with 34 additions and 16 deletions

View File

@ -17,6 +17,7 @@ from kivy.properties import (
StringProperty StringProperty
) )
from kivymd.uix.label import MDLabel
ThemeClsColor = [0.12, 0.58, 0.95, 1] ThemeClsColor = [0.12, 0.58, 0.95, 1]
@ -142,3 +143,16 @@ class CutsomSwipeToDeleteItem(MDCardSwipe):
cla = Window.size[0] / 2 cla = Window.size[0] / 2
swipe_distance = NumericProperty(cla) swipe_distance = NumericProperty(cla)
opening_time = NumericProperty(0.5) 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

View File

@ -24,7 +24,7 @@ from kivy.uix.screenmanager import Screen
from bitmessagekivy import kivy_helper_search from bitmessagekivy import kivy_helper_search
from bitmessagekivy.baseclass.common import ( from bitmessagekivy.baseclass.common import (
showLimitedCnt, toast, ThemeClsColor, showLimitedCnt, toast, ThemeClsColor,
SwipeToDeleteItem, ShowTimeHistoy SwipeToDeleteItem, ShowTimeHistoy, empty_screen_label
) )
from bitmessagekivy.baseclass.maildetail import MailDetail from bitmessagekivy.baseclass.maildetail import MailDetail
from bitmessagekivy.baseclass.draft_widgets import HelperDraft from bitmessagekivy.baseclass.draft_widgets import HelperDraft
@ -34,7 +34,7 @@ from addresses import decodeAddress
import state import state
from helper_sql import sqlExecute from helper_sql import sqlExecute
import helper_sent
class Draft(Screen, HelperDraft): class Draft(Screen, HelperDraft):
"""Draft screen class for kivy Ui""" """Draft screen class for kivy Ui"""
@ -85,7 +85,8 @@ class Draft(Screen, HelperDraft):
# halign='center', # halign='center',
# size_hint_y=None, # size_hint_y=None,
# valign='top') # 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): def draftDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20):
"""This methosd is for retrieving draft messages""" """This methosd is for retrieving draft messages"""
@ -160,7 +161,7 @@ class Draft(Screen, HelperDraft):
def delete_draft(self, data_index, instance, *args): def delete_draft(self, data_index, instance, *args):
"""Delete draft message permanently""" """Delete draft message permanently"""
sqlExecute("DELETE FROM sent WHERE ackdata = ?", data_index) helper_sent.delete(data_index)
if int(state.draft_count) > 0: if int(state.draft_count) > 0:
state.draft_count = str(int(state.draft_count) - 1) state.draft_count = str(int(state.draft_count) - 1)
self.set_draftCnt(state.draft_count) self.set_draftCnt(state.draft_count)

View File

@ -16,15 +16,15 @@ class HelperDraft(object):
def __init__(self): def __init__(self):
pass pass
@staticmethod # @staticmethod
def default_label_when_empty(): # def default_label_when_empty():
"""This function returns default message while no address is there.""" # """This function returns default message while no address is there."""
empty_screen_msg = "yet no message for this account!!!!!!!!!!!!!" # empty_screen_msg = "yet no message for this account!!!!!!!!!!!!!"
content = MDLabel( # content = MDLabel(
font_style='Caption', # font_style='Caption',
theme_text_color='Primary', # theme_text_color='Primary',
text=empty_screen_msg, # text=empty_screen_msg,
halign='center', # halign='center',
size_hint_y=None, # size_hint_y=None,
valign='top') # valign='top')
return content # return content

View File

@ -7,3 +7,6 @@ from helper_sql import sqlExecute
def insert(t): def insert(t):
"""Perform an insert into the `sent` table""" """Perform an insert into the `sent` table"""
sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t) sqlExecute('''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
def delete(data_index):
sqlExecute("DELETE FROM sent WHERE ackdata = ?", data_index)