[gnumeric] GUI: Improve elapsed-time entry. 628082.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Improve elapsed-time entry. 628082.
- Date: Tue, 31 Aug 2010 20:09:47 +0000 (UTC)
commit 85fb56099b73bfa6189b343a38db9fe0cdb06bb7
Author: Morten Welinder <terra gnome org>
Date: Tue Aug 31 16:09:18 2010 -0400
GUI: Improve elapsed-time entry. 628082.
ChangeLog | 16 ++++++++++-
NEWS | 1 +
src/clipboard.c | 2 +-
src/number-match.c | 68 ++++++++++++++++++++++++++++++++++++++++++++-------
4 files changed, 74 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 66f6e8f..c4ffba3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-30 Morten Welinder <terra gnome org>
+
+ * src/clipboard.c (paste_cell): Also translate dates with
+ time-of-day.
+
+2010-08-27 Morten Welinder <terra gnome org>
+
+ * src/number-match.c (valid_hms): Fix the case of elapsed minutes
+ and second. Take extra argument identifying what kind of elapsed
+ format might be used. Communicate whether the format needs to be
+ elapsed back to caller. All callers changed.
+
2010-08-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* configure.in: raise goffice requirement to 0.8.10
@@ -9,14 +21,14 @@
* src/gui-util.c (gnumeric_go_error_info_list_dialog_new): new
(gnumeric_go_error_info_list_dialog_show): new, maily code from
gnumeric_go_error_info_dialog_new
- (gnumeric_go_error_info_dialog_new): use
+ (gnumeric_go_error_info_dialog_new): use
gnumeric_go_error_info_list_dialog_show
* src/io-context-gtk.c (icg_error_error_info_list): new
(icg_set_num_files): connect icg_error_error_info_list
* src/wbc-gtk.c (wbcg_error_error_info_list): new
(wbcg_gnm_cmd_context_init): connect wbcg_error_error_info_list
* src/workbook-control.c (wbc_cmd_context_init): insert reminder stub
-
+
2010-08-24 Morten Welinder <terra gnome org>
* src/gnm-plugin.c (plugin_service_function_group_read_xml)
diff --git a/NEWS b/NEWS
index 6c6fee4..4efc8d1 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ Morten:
* Extend domain of IMPOWER. [#627775]
* Allow use of glib's memory profiler.
* Fix some confusion of char vs. xmlChar.
+ * Fix elapsed-time entry. [#628082]
--------------------------------------------------------------------------
Gnumeric 1.10.9
diff --git a/src/clipboard.c b/src/clipboard.c
index 8d94cf0..3add725 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -247,7 +247,7 @@ paste_cell (int target_col, int target_row,
GOFormat const *fmt = VALUE_FMT (oldval)
? VALUE_FMT (oldval)
: gnm_style_get_format (gnm_cell_get_style (dst));
- if (go_format_is_date (fmt) == +1) {
+ if (go_format_is_date (fmt) > 0) {
gnm_float fnew = go_date_conv_translate
(value_get_as_float (oldval),
dat->cr->date_conv,
diff --git a/src/number-match.c b/src/number-match.c
index 9b068cd..59a0c39 100644
--- a/src/number-match.c
+++ b/src/number-match.c
@@ -449,11 +449,33 @@ fixup_hour_ampm (gnm_float *hour, const GORegmatch *pm)
}
static gboolean
-valid_hms (gnm_float h, gnm_float m, gnm_float s, gboolean allow_elapsed)
+valid_hms (gnm_float h, gnm_float m, gnm_float s,
+ gboolean allow_elapsed, char *elapsed)
{
- return h >= 0 && (allow_elapsed || h < 24) &&
- m >= 0 && m < 60 &&
- s >= 0 && s < 60;
+ gboolean h_ok = h >= 0 && h < 24;
+ gboolean m_ok = m >= 0 && m < 60;
+ gboolean s_ok = s >= 0 && s < 60;
+
+ /* Boring old clock time. */
+ if (h_ok && m_ok && s_ok) {
+ if (elapsed)
+ *elapsed = 0;
+ return TRUE;
+ }
+
+ if (!allow_elapsed)
+ return FALSE;
+
+ if (*elapsed == 'h' && m_ok && s_ok)
+ return TRUE;
+
+ if (*elapsed == 'm' && h == 0 && s_ok)
+ return TRUE;
+
+ if (*elapsed == 's' && h == 0 && m == 0)
+ return TRUE;
+
+ return FALSE;
}
#define DO_SIGN(sign,uc,action) \
@@ -496,7 +518,7 @@ format_match_time (char const *text, gboolean allow_elapsed,
fixup_hour_ampm (&hour, match + 8);
minute = handle_float (text, match + 3);
second = handle_float (text, match + 5);
- if (valid_hms (hour, minute, second, FALSE)) {
+ if (valid_hms (hour, minute, second, FALSE, NULL)) {
time_format = "h:mm:ss AM/PM";
goto got_time;
}
@@ -513,11 +535,19 @@ format_match_time (char const *text, gboolean allow_elapsed,
/* ^(((\d+):)?(\d+):)?(\d+.\d*)\s*$ */
/* 123 4 5 */
if (go_regexec (&datetime_locale.re_hhmmssds, text, G_N_ELEMENTS (match), match, 0) == 0) {
+ char elapsed =
+ match[3].rm_so != match[3].rm_eo
+ ? 'h'
+ : (match[4].rm_so != match[4].rm_eo
+ ? 'm'
+ : 's');
+
hour = handle_float (text, match + 3);
minute = handle_float (text, match + 4);
second = handle_float (text, match + 5);
- if (valid_hms (hour, minute, second, allow_elapsed)) {
- time_format = "h:mm:ss";
+
+ if (valid_hms (hour, minute, second, allow_elapsed, &elapsed)) {
+ time_format = elapsed ? "[h]:mm:ss" : "h:mm:ss";
goto got_time;
}
}
@@ -526,21 +556,30 @@ format_match_time (char const *text, gboolean allow_elapsed,
/* 1 2 3 4 */
if (go_regexec (&datetime_locale.re_hhmmss1, text, G_N_ELEMENTS (match), match, 0) == 0) {
gboolean has_all = (match[4].rm_so != match[4].rm_eo);
+ char elapsed;
+ const char *time_format_elapsed;
if (prefer_hour || has_all) {
hour = handle_float (text, match + 1);
minute = handle_float (text, match + 2);
second = handle_float (text, match + 4);
time_format = has_all ? "h:mm:ss" : "h:mm";
+ time_format_elapsed = has_all ? "[h]:mm:ss" : "[h]:mm";
+ elapsed = 'h';
} else {
hour = 0;
minute = handle_float (text, match + 1);
second = handle_float (text, match + 2);
time_format = "mm:ss";
+ time_format_elapsed = "[m]:ss";
+ elapsed = 'm';
}
- if (valid_hms (hour, minute, second, allow_elapsed))
+ if (valid_hms (hour, minute, second, allow_elapsed, &elapsed)) {
+ if (elapsed)
+ time_format = time_format_elapsed;
goto got_time;
+ }
}
/* ^(\d\d)(\d\d)(\d\d)?(\.\d*)?\s*$ */
@@ -548,21 +587,30 @@ format_match_time (char const *text, gboolean allow_elapsed,
if (go_regexec (&datetime_locale.re_hhmmss2, text, G_N_ELEMENTS (match), match, 0) == 0) {
gboolean has3 = (match[3].rm_so != match[3].rm_eo);
gboolean hasfrac = (match[4].rm_so != match[4].rm_eo);
+ char elapsed;
+ const char *time_format_elapsed;
if ((prefer_hour && !hasfrac) || has3) {
hour = handle_float (text, match + 1);
minute = handle_float (text, match + 2);
second = handle_float (text, match + 3) + handle_float (text, match + 4);
time_format = "h:mm:ss";
+ time_format_elapsed = "[h]:mm:ss";
+ elapsed = 'h';
} else {
hour = 0;
minute = handle_float (text, match + 1);
second = handle_float (text, match + 2) + handle_float (text, match + 4);
time_format = "mm:ss";
+ time_format_elapsed = "[m]:ss";
+ elapsed = 'm';
}
- if (valid_hms (hour, minute, second, allow_elapsed))
+ if (valid_hms (hour, minute, second, allow_elapsed, &elapsed)) {
+ if (elapsed)
+ time_format = time_format_elapsed;
goto got_time;
+ }
}
return NULL;
@@ -570,7 +618,7 @@ format_match_time (char const *text, gboolean allow_elapsed,
got_time:
time_val = (second + 60 * (minute + 60 * hour)) / (24 * 60 * 60);
if (sign == '-')
- time_val = -time_val;
+ time_val = 0 - time_val;
v = value_new_float (time_val);
if (add_format) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]