* src/gramps_main.py: Remov unused module.
* src/DateDisplay.py (verify_format): Correct check. * src/Date.py (is_regular): Add method to detect exact single non-empty dates; (set): Add text string as an optional argument. * src/DateEdit.py: Use DateHandler instead of low-level DateDisplay; (check): Display yellow LED for anything other than regular dates. svn: r3562
This commit is contained in:
parent
446449de7d
commit
8fffcbc87e
@ -10,6 +10,13 @@
|
||||
LED functionality; (SourceEditor.on_sourceok_clicked): Set date using
|
||||
date object, instead of parsing text.
|
||||
|
||||
* src/gramps_main.py: Remov unused module.
|
||||
* src/DateDisplay.py (verify_format): Correct check.
|
||||
* src/Date.py (is_regular): Add method to detect exact single
|
||||
non-empty dates; (set): Add text string as an optional argument.
|
||||
* src/DateEdit.py: Use DateHandler instead of low-level DateDisplay;
|
||||
(check): Display yellow LED for anything other than regular dates.
|
||||
|
||||
2004-09-19 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||
* src/Date.py (is_equal): Add method -- needed to compare dates
|
||||
for being identical, since __cmp__ only compares the sorting value
|
||||
|
21
src/Date.py
21
src/Date.py
@ -373,7 +373,7 @@ class Date:
|
||||
"""
|
||||
return self.text
|
||||
|
||||
def set(self,quality,modifier,calendar,value):
|
||||
def set(self,quality,modifier,calendar,value,text=None):
|
||||
"""
|
||||
Sets the date to the specified value. Parameters are:
|
||||
|
||||
@ -387,6 +387,8 @@ class Date:
|
||||
non-compound date, the format is (DD,MM,YY,slash)
|
||||
and for a compound date the tuple stores data as
|
||||
(DD,MM,YY,slash1,DD,MM,YY,slash2)
|
||||
text - A text string holding either the verbatim user input
|
||||
or a comment relating to the date.
|
||||
|
||||
The sort value is recalculated.
|
||||
"""
|
||||
@ -398,6 +400,8 @@ class Date:
|
||||
month = max(value[_POS_MON],1)
|
||||
day = max(value[_POS_DAY],1)
|
||||
self.sortval = _calendar_convert[calendar](year,month,day)
|
||||
if text:
|
||||
self.text = text
|
||||
|
||||
def convert_calendar(self,calendar):
|
||||
"""
|
||||
@ -430,8 +434,7 @@ class Date:
|
||||
|
||||
def set_text_value(self,text):
|
||||
"""
|
||||
Sets the day to a text string, and assigns the sort value
|
||||
to zero.
|
||||
Sets the text string to a given text.
|
||||
"""
|
||||
self.text = text
|
||||
|
||||
@ -446,3 +449,15 @@ class Date:
|
||||
Returns True if the date is a date range or a date span.
|
||||
"""
|
||||
return self.modifier == MOD_RANGE or self.modifier == MOD_SPAN
|
||||
|
||||
def is_regular(self):
|
||||
"""
|
||||
Returns True if the date is a regular date.
|
||||
|
||||
The regular date is a single exact, i.e. not text-only, not a range
|
||||
or a span, not estimated/calculated, not about/before/after date,
|
||||
and having year, month, and day other than zero.
|
||||
"""
|
||||
return self.modifier == MOD_NONE and self.quality == QUAL_NONE\
|
||||
and self.get_year_valid() and self.get_month_valid\
|
||||
and self.get_day_valid()
|
||||
|
@ -150,7 +150,7 @@ class DateDisplay:
|
||||
"""
|
||||
Verifies that the format value is within the correct range.
|
||||
"""
|
||||
assert(format < len(self.formats))
|
||||
assert(format < len(self.formats)-1)
|
||||
|
||||
def quote_display(self,date):
|
||||
"""
|
||||
|
@ -23,9 +23,9 @@
|
||||
"""
|
||||
Date editing module for GRAMPS.
|
||||
|
||||
The DateEdit.DateEdit provides two visual feedback to the user via a pixamp
|
||||
The DateEdit.DateEdit provides visual feedback to the user via a pixamp
|
||||
to indicate if the assocated GtkEntry box contains a valid date. Green
|
||||
means complete and valid date. Yellow means a valid, but incomplete date.
|
||||
means complete and regular date. Yellow means a valid, but not a regular date.
|
||||
Red means that the date is not valid, and will be viewed as a text string
|
||||
instead of a date.
|
||||
|
||||
@ -59,7 +59,6 @@ import gobject
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
import DateDisplay
|
||||
import DateHandler
|
||||
import const
|
||||
import Utils
|
||||
@ -83,13 +82,15 @@ QUAL_TEXT = (
|
||||
(Date.QUAL_ESTIMATED, _('Estimated')),
|
||||
(Date.QUAL_CALCULATED, _('Calculated')) )
|
||||
|
||||
dd = DateHandler.create_display()
|
||||
|
||||
CAL_TO_MONTHS_NAMES = {
|
||||
Date.CAL_GREGORIAN : DateDisplay.DateDisplay._MONS,
|
||||
Date.CAL_JULIAN : DateDisplay.DateDisplay._MONS,
|
||||
Date.CAL_HEBREW : DateDisplay.DateDisplay._hebrew,
|
||||
Date.CAL_FRENCH : DateDisplay.DateDisplay._french,
|
||||
Date.CAL_PERSIAN : DateDisplay.DateDisplay._persian,
|
||||
Date.CAL_ISLAMIC : DateDisplay.DateDisplay._islamic }
|
||||
Date.CAL_GREGORIAN : dd._MONS,
|
||||
Date.CAL_JULIAN : dd._MONS,
|
||||
Date.CAL_HEBREW : dd._hebrew,
|
||||
Date.CAL_FRENCH : dd._french,
|
||||
Date.CAL_PERSIAN : dd._persian,
|
||||
Date.CAL_ISLAMIC : dd._islamic }
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -131,11 +132,11 @@ class DateEdit:
|
||||
Check current date object and display LED indicating the validity.
|
||||
"""
|
||||
if self.date_obj.get_modifier() == Date.MOD_TEXTONLY:
|
||||
self.pixmap_obj.set_from_pixbuf(DateEdit.bad)
|
||||
# elif self.checkval.get_incomplete():
|
||||
# self.pixmap_obj.set_from_pixbuf(DateEdit.caution)
|
||||
self.pixmap_obj.set_from_pixbuf(self.bad)
|
||||
elif self.date_obj.is_regular():
|
||||
self.pixmap_obj.set_from_pixbuf(self.good)
|
||||
else:
|
||||
self.pixmap_obj.set_from_pixbuf(DateEdit.good)
|
||||
self.pixmap_obj.set_from_pixbuf(self.caution)
|
||||
|
||||
def parse_and_check(self,obj,val):
|
||||
"""
|
||||
|
@ -73,7 +73,6 @@ import DbPrompter
|
||||
import TipOfDay
|
||||
import ArgHandler
|
||||
import Exporter
|
||||
import DateDisplay
|
||||
|
||||
from QuestionDialog import *
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user