* 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
|
LED functionality; (SourceEditor.on_sourceok_clicked): Set date using
|
||||||
date object, instead of parsing text.
|
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>
|
2004-09-19 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
* src/Date.py (is_equal): Add method -- needed to compare dates
|
* src/Date.py (is_equal): Add method -- needed to compare dates
|
||||||
for being identical, since __cmp__ only compares the sorting value
|
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
|
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:
|
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)
|
non-compound date, the format is (DD,MM,YY,slash)
|
||||||
and for a compound date the tuple stores data as
|
and for a compound date the tuple stores data as
|
||||||
(DD,MM,YY,slash1,DD,MM,YY,slash2)
|
(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.
|
The sort value is recalculated.
|
||||||
"""
|
"""
|
||||||
@ -398,6 +400,8 @@ class Date:
|
|||||||
month = max(value[_POS_MON],1)
|
month = max(value[_POS_MON],1)
|
||||||
day = max(value[_POS_DAY],1)
|
day = max(value[_POS_DAY],1)
|
||||||
self.sortval = _calendar_convert[calendar](year,month,day)
|
self.sortval = _calendar_convert[calendar](year,month,day)
|
||||||
|
if text:
|
||||||
|
self.text = text
|
||||||
|
|
||||||
def convert_calendar(self,calendar):
|
def convert_calendar(self,calendar):
|
||||||
"""
|
"""
|
||||||
@ -430,8 +434,7 @@ class Date:
|
|||||||
|
|
||||||
def set_text_value(self,text):
|
def set_text_value(self,text):
|
||||||
"""
|
"""
|
||||||
Sets the day to a text string, and assigns the sort value
|
Sets the text string to a given text.
|
||||||
to zero.
|
|
||||||
"""
|
"""
|
||||||
self.text = text
|
self.text = text
|
||||||
|
|
||||||
@ -446,3 +449,15 @@ class Date:
|
|||||||
Returns True if the date is a date range or a date span.
|
Returns True if the date is a date range or a date span.
|
||||||
"""
|
"""
|
||||||
return self.modifier == MOD_RANGE or self.modifier == MOD_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.
|
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):
|
def quote_display(self,date):
|
||||||
"""
|
"""
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
"""
|
"""
|
||||||
Date editing module for GRAMPS.
|
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
|
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
|
Red means that the date is not valid, and will be viewed as a text string
|
||||||
instead of a date.
|
instead of a date.
|
||||||
|
|
||||||
@ -59,7 +59,6 @@ import gobject
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import Date
|
import Date
|
||||||
import DateDisplay
|
|
||||||
import DateHandler
|
import DateHandler
|
||||||
import const
|
import const
|
||||||
import Utils
|
import Utils
|
||||||
@ -83,13 +82,15 @@ QUAL_TEXT = (
|
|||||||
(Date.QUAL_ESTIMATED, _('Estimated')),
|
(Date.QUAL_ESTIMATED, _('Estimated')),
|
||||||
(Date.QUAL_CALCULATED, _('Calculated')) )
|
(Date.QUAL_CALCULATED, _('Calculated')) )
|
||||||
|
|
||||||
|
dd = DateHandler.create_display()
|
||||||
|
|
||||||
CAL_TO_MONTHS_NAMES = {
|
CAL_TO_MONTHS_NAMES = {
|
||||||
Date.CAL_GREGORIAN : DateDisplay.DateDisplay._MONS,
|
Date.CAL_GREGORIAN : dd._MONS,
|
||||||
Date.CAL_JULIAN : DateDisplay.DateDisplay._MONS,
|
Date.CAL_JULIAN : dd._MONS,
|
||||||
Date.CAL_HEBREW : DateDisplay.DateDisplay._hebrew,
|
Date.CAL_HEBREW : dd._hebrew,
|
||||||
Date.CAL_FRENCH : DateDisplay.DateDisplay._french,
|
Date.CAL_FRENCH : dd._french,
|
||||||
Date.CAL_PERSIAN : DateDisplay.DateDisplay._persian,
|
Date.CAL_PERSIAN : dd._persian,
|
||||||
Date.CAL_ISLAMIC : DateDisplay.DateDisplay._islamic }
|
Date.CAL_ISLAMIC : dd._islamic }
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -131,11 +132,11 @@ class DateEdit:
|
|||||||
Check current date object and display LED indicating the validity.
|
Check current date object and display LED indicating the validity.
|
||||||
"""
|
"""
|
||||||
if self.date_obj.get_modifier() == Date.MOD_TEXTONLY:
|
if self.date_obj.get_modifier() == Date.MOD_TEXTONLY:
|
||||||
self.pixmap_obj.set_from_pixbuf(DateEdit.bad)
|
self.pixmap_obj.set_from_pixbuf(self.bad)
|
||||||
# elif self.checkval.get_incomplete():
|
elif self.date_obj.is_regular():
|
||||||
# self.pixmap_obj.set_from_pixbuf(DateEdit.caution)
|
self.pixmap_obj.set_from_pixbuf(self.good)
|
||||||
else:
|
else:
|
||||||
self.pixmap_obj.set_from_pixbuf(DateEdit.good)
|
self.pixmap_obj.set_from_pixbuf(self.caution)
|
||||||
|
|
||||||
def parse_and_check(self,obj,val):
|
def parse_and_check(self,obj,val):
|
||||||
"""
|
"""
|
||||||
|
@ -73,7 +73,6 @@ import DbPrompter
|
|||||||
import TipOfDay
|
import TipOfDay
|
||||||
import ArgHandler
|
import ArgHandler
|
||||||
import Exporter
|
import Exporter
|
||||||
import DateDisplay
|
|
||||||
|
|
||||||
from QuestionDialog import *
|
from QuestionDialog import *
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user