[q-lang-cvs] qcalc qcalc.q,1.131,1.132
Brought to you by:
agraef
From: Albert G. <ag...@us...> - 2007-11-12 18:16:41
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2957 Modified Files: qcalc.q Log Message: undo/redo for cell spanning, bugfixes Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** qcalc.q 12 Nov 2007 16:26:54 -0000 1.131 --- qcalc.q 12 Nov 2007 18:16:34 -0000 1.132 *************** *** 712,717 **** handled automatically by Qt. */ ! check_focus N X = qt TABLE "setCurrentCell" (I,J) || ! qt TABLE "clearSelection" () if (I,J)<>current_cell where (I,J) = qt_data X; --- 712,716 ---- handled automatically by Qt. */ ! check_focus N X = set_current_cell (I,J) if (I,J)<>current_cell where (I,J) = qt_data X; *************** *** 917,922 **** get_table_item (I,J) if not is_nil IT where IT:QtObject = qt TABLE "item" (I,J): ! = if not is_gui_elem (I,J) then clear_gui_elem (I,J) || ! IT where (_,_,_|_) = qt_data IT; = qt IT "setText" S || qt IT "setPixmap" PM || IT where S = cell_text (I,J), PM = cell_pixmap (I,J), --- 916,920 ---- get_table_item (I,J) if not is_nil IT where IT:QtObject = qt TABLE "item" (I,J): ! = IT where (_,_,_|_) = qt_data IT; = qt IT "setText" S || qt IT "setPixmap" PM || IT where S = cell_text (I,J), PM = cell_pixmap (I,J), *************** *** 927,944 **** qt_val "QTableItem" "OnTyping"; - clear_gui_elem (I,J) - where (X,Y,F|_) = qt_data IT if not is_nil IT - where IT:QtObject = qt TABLE "item" (I,J): - = do (uncurry (qt_set_cb IT)) - [("createEditor",create_editor), - ("setContentFromEditor",content_from_editor)] || - qt_set_data IT (X,Y,F); - spanned_table_item (I,J) (N,M) = qt IT "setSpan" (N,M) || IT - where (I0,J0) = real_index (I,J), - (N,M) = (N+I-I0,M+J-J0), (I,J) = (I0,J0) if not is_nil IT ! where IT:QtObject = get_table_item (I,J); make_table_item (I,J|DATA) ET --- 925,934 ---- qt_val "QTableItem" "OnTyping"; spanned_table_item (I,J) (N,M) = qt IT "setSpan" (N,M) || IT if not is_nil IT ! where (I0,J0) = real_index (I,J), ! (N,M) = (N+I-I0,M+J-J0), (I,J) = (I0,J0), ! IT:QtObject = get_table_item (I,J); make_table_item (I,J|DATA) ET *************** *** 1065,1068 **** --- 1055,1064 ---- = real_index current_cell; + set_current_cell (I,J) + = qt TABLE "setCurrentCell" (I,J) || + // Qt sometimes munges the selection here, so we try to + // force it to a sane value + qt TABLE "clearSelection" (); + clear_cell (I,J) where (I,J) = real_index (I,J): *************** *** 1180,1189 **** where X:QtObject = gui_elem (I,J); = accept S D A || ! qt TABLE "setCurrentCell" ! (if I+M<N then (I+M,J) else (0,J+1)) || ! // Qt sometimes munges the selection here, so we force it to ! // a sane value ! qt TABLE "clearSelection" () || ! qt TABLE "repaintSelections" () where (M,_) = cell_span (I,J) if (qt TABLE "hasFocus" () or else --- 1176,1180 ---- where X:QtObject = gui_elem (I,J); = accept S D A || ! set_current_cell (if I+M<N then (I+M,J) else (0,J+1)) where (M,_) = cell_span (I,J) if (qt TABLE "hasFocus" () or else *************** *** 1202,1207 **** if is_global and then not is_recursive and then not is_nil X: = if (I,J)<>real_current_cell then ! (qt TABLE "setCurrentCell" (I,J) || ! qt TABLE "clearSelection" ()) || process_gui (I,J) X || digest_loop; --- 1193,1197 ---- if is_global and then not is_recursive and then not is_nil X: = if (I,J)<>real_current_cell then ! set_current_cell (I,J) || process_gui (I,J) X || digest_loop; *************** *** 1380,1385 **** merge_cells _ _ _ if is_global: ! = updatemsg (I,J) ! where IT:QtObject = spanned_table_item (I,J) (N,M) if not null SEL and then all is_empty SEL where SEL = check_editing || sel_cellvals selection, --- 1370,1377 ---- merge_cells _ _ _ if is_global: ! = save_undo (I,J;N,M) ! where (I,J) = real_index (I,J), (N,M) = cell_span (I,J) ! where IT:QtObject = set_current_cell (I,J) || ! spanned_table_item (I,J) (N,M) if not null SEL and then all is_empty SEL where SEL = check_editing || sel_cellvals selection, *************** *** 1389,1399 **** dissociate_cells _ _ _ if is_global: ! = qt_set_cb IT "createEditor" || ! qt_set_cb IT "setContentFromEditor" || ! qt IT "setSpan" (1,1) ! if ((N>1) or else (M>1)) ! where N = qt IT "rowSpan" (), M = qt IT "colSpan" () ! if not is_nil IT where (_,_;I,J;_,_) = check_editing || selection, IT:QtObject = qt TABLE "item" (I,J) if qt TABW "currentPageIndex" () = 0; --- 1381,1389 ---- dissociate_cells _ _ _ if is_global: ! = set_current_cell (I,J) || qt IT "setSpan" (1,1) || ! save_undo (I,J;1,1) ! if not is_nil IT and then ((N>1) or else (M>1)) where (_,_;I,J;_,_) = check_editing || selection, + (I,J) = real_index (I,J), (N,M) = cell_span (I,J), IT:QtObject = qt TABLE "item" (I,J) if qt TABW "currentPageIndex" () = 0; *************** *** 1949,1952 **** --- 1939,1943 ---- if RES then digest_loop || do (uncurry spanned_table_item) SPANS || + mark_spans SPANS || statusmsg "Done" || qt TIMER "start" 300 || *************** *** 2623,2635 **** /* Undo/redo. **************************************************************/ ! def LAST_SAVE = ref 0; mark_save = LAST_SAVE := #get UNDO_LIST; mark_undo L = //printf "*** mark undo: %s\n" (str L) || ! LAST_SAVE := 1 || UNDO_LIST := [L] || REDO_LIST := [] where L = zip (map (flip (flip sub 0) 1) L) (map (!2) L); ! save_undo L = //printf "*** save undo: %s\n" (str L) || if #get UNDO_LIST < get LAST_SAVE then LAST_SAVE := 0 || UNDO_LIST := [L|get UNDO_LIST] || REDO_LIST := [] --- 2614,2636 ---- /* Undo/redo. **************************************************************/ ! def LAST_SAVE = ref 0, SPANS = ref emptyhdict; mark_save = LAST_SAVE := #get UNDO_LIST; mark_undo L = //printf "*** mark undo: %s\n" (str L) || ! LAST_SAVE := 1 || UNDO_LIST := [L] || REDO_LIST := [] || ! SPANS := emptyhdict where L = zip (map (flip (flip sub 0) 1) L) (map (!2) L); ! mark_spans L = //printf "*** mark spans: %s\n" (str L) || ! SPANS := hdict L; ! ! save_undo (I,J;N,M) ! = //printf "*** save undo: %s\n" (str (I,J;N,M)) || ! if #get UNDO_LIST < get LAST_SAVE then LAST_SAVE := 0 || ! UNDO_LIST := [(I,J;N,M)|get UNDO_LIST] || REDO_LIST := []; ! ! save_undo L:List ! = //printf "*** save undo: %s\n" (str L) || if #get UNDO_LIST < get LAST_SAVE then LAST_SAVE := 0 || UNDO_LIST := [L|get UNDO_LIST] || REDO_LIST := [] *************** *** 2637,2641 **** where L = undo_cellvals L; ! merge_undo L = //printf "*** merge undo: %s ++ %s\n" (str L0,str L) || UNDO_LIST := [L0++L|UL] where [L0|UL] = get UNDO_LIST --- 2638,2643 ---- where L = undo_cellvals L; ! merge_undo L:List ! = //printf "*** merge undo: %s ++ %s\n" (str L0,str L) || UNDO_LIST := [L0++L|UL] where [L0|UL] = get UNDO_LIST *************** *** 2654,2657 **** --- 2656,2663 ---- = (I,J,"") otherwise; + undo_span SP (I,J) + = (N,M) where (N,M) = SP!(I,J); + = (1,1) otherwise; + undo = //printf "*** undo: %s\n" (str W) || adjust_table (N,M) || *************** *** 2660,2664 **** EDITED := (#UL<>get LAST_SAVE) || update_title || digest_loop ! where D = foldl (foldl insert) emptyhdict (reverse UL), W = map (undo_cell D.fst) L, N = foldl max (MIN_ROWS-1) --- 2666,2671 ---- EDITED := (#UL<>get LAST_SAVE) || update_title || digest_loop ! where D = foldl (foldl insert) emptyhdict $ ! filter islist $ reverse UL, W = map (undo_cell D.fst) L, N = foldl max (MIN_ROWS-1) *************** *** 2668,2672 **** W = filter (valid_cell (N,M)) W if not null UL ! where [L|UL] = get UNDO_LIST; redo = //printf "*** redo: %s\n" (str W) || --- 2675,2688 ---- W = filter (valid_cell (N,M)) W if not null UL ! where [L:List|UL] = get UNDO_LIST; ! ! undo = //printf "*** undo: %s\n" (str (I,J;N,M)) || ! set_current_cell (I,J) || spanned_table_item (I,J) (N1,M1) || ! UNDO_LIST := UL || REDO_LIST := [(I,J;N,M)|get REDO_LIST] || ! EDITED := (#UL<>get LAST_SAVE) || update_title ! where [(I,J;N,M)|UL] = get UNDO_LIST, ! SP = foldl insert (get SPANS) $ ! filter istuple $ reverse UL, ! (N1,M1) = undo_span SP (I,J); redo = //printf "*** redo: %s\n" (str W) || *************** *** 2676,2680 **** EDITED := (#UL+1<>get LAST_SAVE) || update_title || digest_loop ! where [L|RL] = get REDO_LIST, UL = get UNDO_LIST, (KEYS,VALS) = unzip L, W = zipwith append KEYS VALS, --- 2692,2696 ---- EDITED := (#UL+1<>get LAST_SAVE) || update_title || digest_loop ! where [L:List|RL] = get REDO_LIST, UL = get UNDO_LIST, (KEYS,VALS) = unzip L, W = zipwith append KEYS VALS, *************** *** 2685,2688 **** --- 2701,2710 ---- W = filter (valid_cell (N,M)) W; + redo = //printf "*** redo: %s\n" (str (I,J;N,M)) || + set_current_cell (I,J) || spanned_table_item (I,J) (N,M) || + UNDO_LIST := [(I,J;N,M)|UL] || REDO_LIST := RL || + EDITED := (#UL+1<>get LAST_SAVE) || update_title + where [(I,J;N,M)|RL] = get REDO_LIST, UL = get UNDO_LIST; + /* Syntax highlighting. ****************************************************/ |