diff -Nru semantik-0.7.3/ChangeLog semantik-0.8.3/ChangeLog --- semantik-0.7.3/ChangeLog 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/ChangeLog 2012-10-21 10:09:17.000000000 +0000 @@ -1,3 +1,28 @@ +Semantik 0.8.3 +-------------- +* New dialog for exporting the map as a picture with a specific size +* More consistent gui elements (dialog buttons, menus) +* New UML shapes +* Straight arrows on the diagrams + +Semantik 0.8.2 +-------------- +* Fixed several crashes +* Fixe various LaTeX templates +* New actor and usecase elements + +Semantik 0.8.1 +-------------- +* Made the gui mode-less +* Enabled diagram, image and table export in the beamer template +* Fixed the Java applet generator + +Semantik 0.8.0 +-------------- + +* undo/redo actions +* select subtrees + Semantik 0.7.3 -------------- diff -Nru semantik-0.7.3/README semantik-0.8.3/README --- semantik-0.7.3/README 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/README 2012-10-21 10:09:17.000000000 +0000 @@ -1,5 +1,6 @@ -Semantik 0.7.3, Thomas Nagy +Semantik 0.8.3, Thomas Nagy contact: tnagy1024 at gmail dot com +http://code.google.com/p/semantik ----------------------------------------------- @@ -10,38 +11,37 @@ * the Qt development packages must be installed (Qt >= 4.3) To compile, run: -./waf configure -./waf +./waf configure build + +A few systems may require different options such as: +PYTHON=python2 PYTHON_VERSION=2.7 waf configure build Then run the following installation command as root (important - Semantik will only work if installed): ./waf install -To execute Semantik right from the source directory (developers): -./waf --exe - The generic command for creating a package is the following (packagers): -./waf configure --prefix=/usr; ./waf; DESTDIR=$fakeroot ./waf install +./waf configure clean build --prefix=/usr && DESTDIR=$fakeroot ./waf install ----------------------------------------------- 2. Getting started: * double-click to add an item -* when a leaf is selected, type 'enter' to start in-place editing, type 'enter' again to leave +* when a leaf is selected, type 'enter' to start in-place editing, type 'enter' again to save * left,right,up,down keys to navigate in the tree * alt+left,right,up,down keys to move the selection around * double-click on a leaf to add a ramification -* double-click on a link with the control key held to disconnect +* double-click on a link to disconnect Getting started with document generators: * look at the scripts in src/templates/ -* the naming is used for finding the files, be careful +* the naming is used for finding the files Getting started with the diagrams: -* in the map view, right click on a map item, and select "data type: diagram" -* now in the "data" dock widget, double-click to add a diagram item -* when holding the control key pressed and left-clicking on a diagram item, a connection arrow is created -* when holding the control key pressed, double-clicking on a connection thread deletes it +* right-click to select a component to add +* press enter to edit the properties +* use the + to start dragging a connection +* select a connection and move the points to change its dimensions More help in about->help @@ -49,19 +49,21 @@ 3. Document generators: -* the document generation is performed in two steps: variable substitution and preprocessing -* variables in the form @var_name@ are replaced by the corresponding document variables -* the core of the document is a variable itself -* a c-like preprocessor is then run on the resulting document, using (nested) conditionals such as: +* Be careful with documents that you have not created yourself, there are no security restrictions at the moment +* The document generation is performed in two steps: variable substitution and preprocessing +* Variables in the form @var_name@ are replaced by the corresponding document variables +* The core of the document is a variable itself +* A c-like preprocessor is then run on the resulting document, using (nested) conditionals such as: #if 0, #if !0, #ifdef var, #endif (the #elif construct is not supported yet) -* external viewers can be used, from the 'variables' panel, add code in the form +* External viewers can be used, from the 'variables' panel, add code in the form 'command_'+template_name=command_line, for example: command_html=kfmclient newTab %s command_odt=oowriter %s command_s5=firefox %s - this is only necessary for documents that do not have a kde component yet + this is only necessary for documents that do not have a KDE mapping for opening them +* LaTeX commands can be inserted by using all_latex=1 ----------------------------------------------- @@ -69,20 +71,18 @@ GPL V3 ------------------------------------------------ - -5. Logo: +Semantik does not Endorse non-free systems: -You may add the following code to your pages to show your interest in Semantik -(the logo can be found in src/data/semantik-logo.png) +- Due to restrictive Debian policies regarding "binary" files, Semantik cannot be +packaged on it. Fortunately, there are less restrictive Linux distributions around. - -semantik - +- Do not port Semantik to proprietary platforms (Windows, Mac). You may be free +to do it, but the author is also free to stop the development, or to keep the +next versions for himself. ----------------------------------------------- Enjoy Semantik -Thomas Nagy, 2007-2009 +Thomas Nagy, 2007-2012 diff -Nru semantik-0.7.3/TODO semantik-0.8.3/TODO --- semantik-0.7.3/TODO 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/TODO 2012-10-21 10:09:17.000000000 +0000 @@ -1,5 +1,13 @@ -ideas: +Priority: +--------- + +s5 default picture size? +crash: resize a box, unselect the diagram, then undo? +display pictures on the canvas... + +Ideas: ------ Import kdissert documents properly +Serialize undo operations diff -Nru semantik-0.7.3/debian/changelog semantik-0.8.3/debian/changelog --- semantik-0.7.3/debian/changelog 2012-06-01 15:20:01.000000000 +0000 +++ semantik-0.8.3/debian/changelog 2013-03-04 02:12:17.000000000 +0000 @@ -1,3 +1,15 @@ +semantik (0.8.3-0ubuntu1) raring; urgency=low + + * New upstream release. + * debian/patches/kubuntu_01_wscript_log.diff: Refresh. + * debian/patches/kubuntu_02_menu_entry_fix.diff: Drop, as it is no longer + necessary. + * debian/patches/ocaml-link-str.diff: Drop, as it is no longer necessary. + * debian/patches/qreal-arm.diff: Drop, as it is no longer necessary. + * debian/rules: Remove broken --want-rpath argument. + + -- Logan Rosen Sun, 03 Mar 2013 20:58:40 -0500 + semantik (0.7.3-0ubuntu7) quantal; urgency=low * Fixed typo: "targetted" to "targeted" in debian/control file. diff -Nru semantik-0.7.3/debian/patches/kubuntu_01_wscript_log.diff semantik-0.8.3/debian/patches/kubuntu_01_wscript_log.diff --- semantik-0.7.3/debian/patches/kubuntu_01_wscript_log.diff 2012-06-01 15:20:01.000000000 +0000 +++ semantik-0.8.3/debian/patches/kubuntu_01_wscript_log.diff 2013-03-04 02:00:27.000000000 +0000 @@ -1,25 +1,23 @@ ## kubuntu_01_wscript_log.dpatch by ## -Index: semantik-0.7.3/wscript -=================================================================== ---- semantik-0.7.3.orig/wscript 2009-08-30 07:35:35.000000000 -0400 -+++ semantik-0.7.3/wscript 2010-11-01 20:06:53.932666084 -0400 -@@ -179,7 +179,7 @@ +--- a/wscript ++++ b/wscript +@@ -116,7 +116,7 @@ else: icons = '/usr/share/icons:/usr:/etc/opt/kde3/share/icons/:/opt/kde3/share/icons/:/var/lib/mandriva/kde-profiles/powerpackplus/share/icons/:/usr/share/icons/' if not Options.options.icons: -- Logs.warn("For now Semantik uses a few kde icons - if you have problems seeing the icons install kde") -+ print ("For now Semantik uses a few kde icons - if you have problems seeing the icons install kde") +- Logs.warn("For now Semantik uses a few kde icons - if you have problems seeing the icons install kdebase") ++ print("For now Semantik uses a few kde icons - if you have problems seeing the icons install kdebase") if Options.options.icons: icons = Options.options.icons -@@ -192,7 +192,7 @@ +@@ -129,7 +129,7 @@ if not conf.env.PYTHON: conf.fatal('Semantik requires Python >= 2.5 (development package for the compilation)') conf.check_python_version((2,4,2)) conf.check_python_headers() - if not conf.env.PYTHON_VERSION in "2.4 2.5 2.6 2.7".split(): Logs.warn('Bad Python version %s ' % str(conf.env.PYTHON_VERSION)) + if not conf.env.PYTHON_VERSION in "2.4 2.5 2.6 2.7".split(): print('Bad Python version %s ' % str(conf.env.PYTHON_VERSION)) - conf.check_tool('ocaml') - if not conf.env.OCAMLOPT: conf.fatal('Semantik requires ocamlopt (compilation only)') + #ret = ctx.cmd_output('python-config --cflags').strip().split() + try: diff -Nru semantik-0.7.3/debian/patches/kubuntu_02_menu_entry_fix.diff semantik-0.8.3/debian/patches/kubuntu_02_menu_entry_fix.diff --- semantik-0.7.3/debian/patches/kubuntu_02_menu_entry_fix.diff 2012-06-01 15:20:01.000000000 +0000 +++ semantik-0.8.3/debian/patches/kubuntu_02_menu_entry_fix.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -## kubuntu_02_menu_entry_fix.dpatch by Michał Zając -## - -Index: semantik-0.7.3/src/data/semantik.desktop -=================================================================== ---- semantik-0.7.3.orig/src/data/semantik.desktop 2009-08-30 07:35:32.000000000 -0400 -+++ semantik-0.7.3/src/data/semantik.desktop 2010-11-01 20:06:41.000000000 -0400 -@@ -1,6 +1,7 @@ - [Desktop Entry] - Encoding=UTF-8 - Name=Semantik -+Exec=semantik - GenericName=Mind mapping software - GenericName[tr]=Zihin haritalama uygulaması - Type=Application diff -Nru semantik-0.7.3/debian/patches/ocaml-link-str.diff semantik-0.8.3/debian/patches/ocaml-link-str.diff --- semantik-0.7.3/debian/patches/ocaml-link-str.diff 2012-06-01 15:20:01.000000000 +0000 +++ semantik-0.8.3/debian/patches/ocaml-link-str.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -Description: remove unneeded link against nonexistant libstr.a - libstr.a does not exist in ocaml-nox 3.12.0-7 anymore. A str.a does - still exists, but it is not required. -Author: Julian Taylor -Index: semantik/wscript -=================================================================== ---- semantik.orig/wscript 2011-08-31 12:10:37.979872237 +0200 -+++ semantik/wscript 2011-08-31 12:10:45.989872138 +0200 -@@ -208,7 +208,7 @@ - conf.fatal('Compiling Semantik requires kde4 -devel') - - conf.env.OCALINKFLAGS_OPT_PP = 'str.cmxa' -- conf.env.LINKFLAGS_CAML = '-lasmrun -lstr -lnums'.split() -+ conf.env.LINKFLAGS_CAML = '-lasmrun -lnums'.split() - conf.env.LIBPATH_CAML = conf.env.OCAMLLIB - conf.env.LIB_CAML = "m".split() - conf.env.OCAMLFLAGS_TWT = '-pp default/util/ocamltwt'.split() #-unsafe -noassert -inline 10' diff -Nru semantik-0.7.3/debian/patches/qreal-arm.diff semantik-0.8.3/debian/patches/qreal-arm.diff --- semantik-0.7.3/debian/patches/qreal-arm.diff 2012-06-01 15:20:01.000000000 +0000 +++ semantik-0.8.3/debian/patches/qreal-arm.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Index: semantik-0.7.3/src/fig/box_view.cpp -=================================================================== ---- semantik-0.7.3.orig/src/fig/box_view.cpp 2009-08-30 07:35:31.000000000 -0400 -+++ semantik-0.7.3/src/fig/box_view.cpp 2012-03-02 00:45:10.829399944 -0500 -@@ -587,8 +587,8 @@ - { - QPointF l_o = m_oLastMovePoint - m_oLastPoint + m_oOffsetPoint; - box_item *l_oItem = (box_item*) m_oSelected[0]; -- l_o.setX(qMax(GRID_VALUE, l_o.x())); -- l_o.setY(qMax(GRID_VALUE, l_o.y())); -+ l_o.setX(qMax(static_cast(GRID_VALUE), l_o.x())); -+ l_o.setY(qMax(static_cast(GRID_VALUE), l_o.y())); - l_oItem->setRect(0, 0, int_val(l_o.x()), int_val(l_o.y())); - - // then update the links diff -Nru semantik-0.7.3/debian/patches/series semantik-0.8.3/debian/patches/series --- semantik-0.7.3/debian/patches/series 2012-06-01 15:20:01.000000000 +0000 +++ semantik-0.8.3/debian/patches/series 2013-03-04 02:03:29.000000000 +0000 @@ -1,4 +1 @@ kubuntu_01_wscript_log.diff -kubuntu_02_menu_entry_fix.diff -ocaml-link-str.diff -qreal-arm.diff diff -Nru semantik-0.7.3/debian/rules semantik-0.8.3/debian/rules --- semantik-0.7.3/debian/rules 2012-06-01 15:20:01.000000000 +0000 +++ semantik-0.8.3/debian/rules 2013-03-04 02:11:56.000000000 +0000 @@ -4,7 +4,7 @@ dh $@ override_dh_auto_configure: - PATH=$(PATH):/usr/lib/kde4/bin ./waf configure --prefix=/usr --want-rpath=0 + PATH=$(PATH):/usr/lib/kde4/bin ./waf configure --prefix=/usr override_dh_auto_build: docbook2x-man debian/semantik.1.docbook Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/example.sem and /tmp/YNuC9JdPw2/semantik-0.8.3/example.sem differ diff -Nru semantik-0.7.3/src/apis.ml semantik-0.8.3/src/apis.ml --- semantik-0.7.3/src/apis.ml 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/apis.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -(* - Thomas Nagy 2007-2009 GPLV3 -*) - -open Printf -open Hashtbl -open Random - -let cst_electric = 16.0 -let cst_spring = 190.0 -let cst_time = 0.1 -let pow = 1.82 -let maxiter = 2000 - -let do_trace = false - -let maxf x y = - if x > y then x else y - -let trace msg = - if do_trace then - Printf.fprintf stderr "%s\n" msg - flush_all() - else - () - -type box = { id: int; mutable x:float; mutable y:float; w:float; h:float; } -type pair = { a: int; b: int; } -type sbox = { mutable sx: float; mutable sy: float; mutable sw: float; mutable sh: float; -mutable vx: float; mutable vy: float; mutable fx: float; mutable fy: float; } - -type problem = { - mutable boxes: box list; - mutable links: pair list; - mutable id_to_idx: (int, int) Hashtbl.t; - mutable prob: sbox array; - mutable size: int; - mutable count: int; - mutable padres: (int, int array) Hashtbl.t; - mutable rel: (int, int) Hashtbl.t; - } - -let empty_problem () = - { - boxes = []; - links = []; - id_to_idx = Hashtbl.create 10; - prob = [||]; - size = 0; - count = 0; - padres = Hashtbl.create 10; - rel = Hashtbl.create 100; - } - -let container = empty_problem() -let cleanup () = - trace "cleanup"; - container.boxes <- [] - container.links <- [] - container.id_to_idx <- Hashtbl.create 10 - container.prob <- [||] - container.size <- 0 - container.count <- 0 - container.padres <- Hashtbl.create 10 - container.rel <- Hashtbl.create 100 - -let add_box_fun i a b c d = - container.boxes <- container.boxes @ [{id=i;x=a;y=b;w=c;h=d;}] - -let add_cstr_fun x y = - container.links <- container.links @ [{a=x; b=y;}] - -let get_x_fun id = - container.prob.(Hashtbl.find container.id_to_idx id).sx - -let get_y_fun id = - container.prob.(Hashtbl.find container.id_to_idx id).sy - -let debug_all() = - let toto = open_out "/tmp/debug.txt" - let debug_sbox a = - Printf.fprintf toto "%f %f %f %f %f %f %f %f\n" a.sx a.sy a.sw a.sh a.vx a.vy a.fx a.fy - Array.iter debug_sbox container.prob - close_out toto - -let ensure_init () = - - if container.count == 0 then - let sbox_ctor b = - {sx=b.x; sy=b.y; sw=b.w; sh=b.h; vx=0.; vy=0.; fx=0.; fy=0.;} - - let tmphash = Hashtbl.create 10 - let link_add b = - let x = Hashtbl.find container.id_to_idx b.a and y = Hashtbl.find container.id_to_idx b.b - Hashtbl.replace container.rel y x - try - let lst = Hashtbl.find tmphash x - Hashtbl.replace tmphash x (lst @ [y]) - with - | Not_found -> - Hashtbl.add tmphash x [y] - (*Hashtbl.add container.rel y x*) - - let lst_sbox = ref [] - let hash_add i b = - let _ = Hashtbl.add container.id_to_idx b.id i - lst_sbox := (!lst_sbox) @ [sbox_ctor b] - i + 1 - - container.size <- List.fold_left hash_add 0 container.boxes - container.prob <- Array.of_list (!lst_sbox) - List.iter link_add container.links - - let arrayze key value = - Hashtbl.replace container.padres key (Array.of_list value) - Hashtbl.iter arrayze tmphash - -Callback.register "cleanup_fun" cleanup -Callback.register "add_box_fun" add_box_fun -Callback.register "get_x_fun" get_x_fun -Callback.register "get_y_fun" get_y_fun -Callback.register "add_cstr_fun" add_cstr_fun - diff -Nru semantik-0.7.3/src/apis.mli semantik-0.8.3/src/apis.mli --- semantik-0.7.3/src/apis.mli 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/apis.mli 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -(* - Thomas Nagy 2007-2009 GPLV3 -*) - -val cst_electric : float -val cst_spring : float -val cst_time : float -val pow : float -val maxiter : int -val do_trace : bool -val trace : string -> unit -type box = { - id : int; - mutable x : float; - mutable y : float; - w : float; - h : float; -} -type pair = { a : int; b : int; } -type sbox = { - mutable sx : float; - mutable sy : float; - mutable sw : float; - mutable sh : float; - mutable vx : float; - mutable vy : float; - mutable fx : float; - mutable fy : float; -} -type problem = { - mutable boxes : box list; - mutable links : pair list; - mutable id_to_idx : (int, int) Hashtbl.t; - mutable prob : sbox array; - mutable size : int; - mutable count : int; - mutable padres : (int, int array) Hashtbl.t; - mutable rel : (int, int) Hashtbl.t; -} -val empty_problem : unit -> problem -val container : problem -val ensure_init : unit -> unit - -val debug_all : unit -> unit - diff -Nru semantik-0.7.3/src/aux.c semantik-0.8.3/src/aux.c --- semantik-0.7.3/src/aux.c 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/aux.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -// Thomas Nagy 2007-2009 GPLV3 - -#include "math.h" -#include -#include -#include -#include - -void iterate_pb(int v) -{ - static value *iterate_fun = NULL; - if (!iterate_fun) iterate_fun = caml_named_value("iterate_fun"); - if (!iterate_fun) return; - callback(*iterate_fun, Val_int(v)); -} - -void cleanup_pb() -{ - static value * cleanup_fun = NULL; - if (!cleanup_fun) cleanup_fun = caml_named_value("cleanup_fun"); - if (!cleanup_fun) return; - - callback(*cleanup_fun, Val_int(0)); -} - -void add_box(int pos, double x, double y, double w, double h) -{ - CAMLparam0(); - - static value * add_box_fun = NULL; - if (!add_box_fun) add_box_fun = caml_named_value("add_box_fun"); - - CAMLlocalN(va, 5); - - va[0] = Val_int(pos); - va[1] = copy_double(x); - va[2] = copy_double(y); - va[3] = copy_double(w); - va[4] = copy_double(h); - - callbackN(*add_box_fun, 5, va); - - CAMLreturn0; -} - -void add_cstr(int x, int y) -{ - static value * add_cstr_fun = NULL; - if (!add_cstr_fun) add_cstr_fun = caml_named_value("add_cstr_fun"); - callback2(*add_cstr_fun, Val_int(x), Val_int(y)); -} - -double get_x(int pos) -{ - static value * get_x_fun = NULL; - if (!get_x_fun) get_x_fun = caml_named_value("get_x_fun"); - double d = Double_val(callback(*get_x_fun, Val_int(pos))); - if (isnan(d)) d=0.; - if (d>55000.||d<-55000.) d=0.; - return d; -} - -double get_y(int pos) -{ - static value * get_y_fun = NULL; - if (!get_y_fun) get_y_fun = caml_named_value("get_y_fun"); - double d = (Double_val(callback(*get_y_fun, Val_int(pos)))); - if (isnan(d)) d=0.; - if (d>55000.||d<-55000.) d=0.; - return d; -} - -// something different -void set_rectangles(int ax1, int ax2, int ay1, int ay2, int ap, - int bx1, int bx2, int by1, int by2, int bp) -{ - CAMLparam0(); - - static value * set_rects_fun = NULL; - if (!set_rects_fun) set_rects_fun = caml_named_value("set_rects_fun"); - - CAMLlocalN(va, 10); - - va[0] = Val_int(ax1); - va[1] = Val_int(ax2); - va[2] = Val_int(ay1); - va[3] = Val_int(ay2); - va[4] = Val_int(ap); - va[5] = Val_int(bx1); - va[6] = Val_int(bx2); - va[7] = Val_int(by1); - va[8] = Val_int(by2); - va[9] = Val_int(bp); - - callbackN(*set_rects_fun, 10, va); - - CAMLreturn0; -} - -int get_vertex_x(int pos) -{ - static value * get_vx_fun = NULL; - if (!get_vx_fun) get_vx_fun = caml_named_value("get_vx_fun"); - int d = Int_val(callback(*get_vx_fun, Val_int(pos))); - if (isnan(d)) d=0.; - if (d>55000.||d<-55000.) d=0.; - return d; -} - -int get_vertex_y(int pos) -{ - static value * get_vy_fun = NULL; - if (!get_vy_fun) get_vy_fun = caml_named_value("get_vy_fun"); - int d = Int_val(callback(*get_vy_fun, Val_int(pos))); - if (isnan(d)) d=0.; - if (d>55000.||d<-55000.) d=0.; - return d; -} - -int num_seg() -{ - static value * num_seg_fun = NULL; - if (!num_seg_fun) num_seg_fun = caml_named_value("num_seg_fun"); - return Int_val(callback(*num_seg_fun, Val_int(0))); -} - diff -Nru semantik-0.7.3/src/browser.cpp semantik-0.8.3/src/browser.cpp --- semantik-0.7.3/src/browser.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/browser.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,3 +1,4 @@ +// Thomas Nagy 2007-2012 GPLV3 #include "browser.h" #include diff -Nru semantik-0.7.3/src/browser.h semantik-0.8.3/src/browser.h --- semantik-0.7.3/src/browser.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/browser.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,3 +1,5 @@ +// Thomas Nagy 2007-2012 GPLV3 + #include #ifndef _BROWSER_H diff -Nru semantik-0.7.3/src/canvas_chain.cpp semantik-0.8.3/src/canvas_chain.cpp --- semantik-0.7.3/src/canvas_chain.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/canvas_chain.cpp 2012-09-05 01:08:33.000000000 +0000 @@ -0,0 +1,31 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include "CON.h" +#include "canvas_chain.h" +#include "box_view.h" +#include "data_item.h" +#include + +#define PAD 1 + +canvas_chain::canvas_chain(canvas_view* i_oParent) : QGraphicsRectItem() +{ + m_oParent = i_oParent; + setVisible(false); + setRect(0, 0, 10, 10); +} + +void canvas_chain::paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *option, QWidget * i_oW) +{ + QPen l_oPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setWidth(1); + i_oPainter->setPen(l_oPen); + + i_oPainter->drawLine(QPoint(PAD, 5), QPoint(10-PAD, 5)); + i_oPainter->drawLine(QPoint(5, PAD), QPoint(5, 10-PAD)); +} + diff -Nru semantik-0.7.3/src/canvas_chain.h semantik-0.8.3/src/canvas_chain.h --- semantik-0.7.3/src/canvas_chain.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/canvas_chain.h 2012-09-05 01:08:33.000000000 +0000 @@ -0,0 +1,24 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef CANVAS_CHAIN_H +#define CANVAS_CHAIN_H + +#include +#include +#include +#include +#include +#include "con.h" +#include "canvas_view.h" + +class canvas_chain : public QGraphicsRectItem +{ + public: + canvas_chain(canvas_view *i_oGraphWidget); + canvas_view *m_oParent; + int type() const { return CANVAS_CHAIN_T; } + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); +}; + +#endif // CANVAS_CHAIN_H + diff -Nru semantik-0.7.3/src/canvas_flag.cpp semantik-0.8.3/src/canvas_flag.cpp --- semantik-0.7.3/src/canvas_flag.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/canvas_flag.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include @@ -14,7 +14,7 @@ #include #include "data_item.h" -#include "data_control.h" +#include "sem_mediator.h" #include "con.h" #include "canvas_item.h" #include "canvas_flag.h" @@ -31,8 +31,9 @@ /* set the z value to 51 */ setZValue(51); - i_oGraphWidget->scene()->addItem(this); + i_oGraphWidget->scene()->addItem(this); setParentItem(m_oItem); + setCacheMode(QGraphicsItem::DeviceCoordinateCache); } void canvas_flag::paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *i_oOption, QWidget * i_oW) @@ -42,14 +43,14 @@ { if (this == m_oItem->m_oFlags[i]) { l_iIndex = i; break; } } - data_item *l_oDataItem = m_oGraph->m_oControl->m_oItems.value(m_oItem->Id()); + data_item *l_oDataItem = m_oGraph->m_oMediator->m_oItems.value(m_oItem->Id()); QString l_sName = l_oDataItem->m_oFlags[l_iIndex]; - for (int i=0; im_oControl->m_oFlagSchemes.size(); ++i) + for (int i=0; im_oMediator->m_oFlagSchemes.size(); ++i) { - if (m_oGraph->m_oControl->m_oFlagSchemes[i]->m_sId == l_sName) + if (m_oGraph->m_oMediator->m_oFlagSchemes[i]->m_sId == l_sName) { - QSvgRenderer *l_o = m_oGraph->m_oControl->m_oFlagSchemes[i]->_renderer(); + QSvgRenderer *l_o = m_oGraph->m_oMediator->m_oFlagSchemes[i]->_renderer(); l_o->render(i_oPainter, boundingRect()); break; } diff -Nru semantik-0.7.3/src/canvas_flag.h semantik-0.8.3/src/canvas_flag.h --- semantik-0.7.3/src/canvas_flag.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/canvas_flag.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -/// Thomas Nagy 2007-2009 GPLV3 +/// Thomas Nagy 2007-2012 GPLV3 #ifndef CANVAS_FLAG_H #define CANVAS_FLAG_H @@ -19,8 +19,7 @@ public: canvas_flag(canvas_view *i_oGraphWidget, canvas_item *i_oFrom); - //enum { Type = gratype(797) }; - int type() const { return gratype(797); } + int type() const { return CANVAS_FLAG_T; } canvas_view *m_oGraph; canvas_item *m_oItem; void paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *i_oOption, QWidget * i_oW); diff -Nru semantik-0.7.3/src/canvas_item.cpp semantik-0.8.3/src/canvas_item.cpp --- semantik-0.7.3/src/canvas_item.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/canvas_item.cpp 2012-09-05 01:08:33.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -18,15 +18,17 @@ #include #include +#include "canvas_chain.h" #include "canvas_flag.h" #include "color_scheme.h" -#include "data_control.h" +#include "sem_mediator.h" #include "con.h" #include "data_item.h" #include "canvas_sort.h" #include "canvas_link.h" #include "canvas_item.h" #include "canvas_view.h" +#include "canvas_sort_toggle.h" #define square_size 5 #define item_padding 7. @@ -37,35 +39,27 @@ QColor canvas_item::s_oColorLeaf = QColor(171, 251, 199); QColor canvas_item::s_oColorSelect = QColor(255, 255, 255, 240); -canvas_item::canvas_item(canvas_view *i_oGraphWidget, int i_iId) : QGraphicsRectItem(), m_oGraph(i_oGraphWidget) +canvas_item::canvas_item(canvas_view *i_oGraphWidget, int i_iId) : QGraphicsTextItem(), m_oGraph(i_oGraphWidget) { - m_oDoc = new QTextDocument(); - -/* stupid word wrap */ -#if QT_VERSION >= 0x040290 - QTextOption l_oOpt; - l_oOpt.setWrapMode(QTextOption::WordWrap); - m_oDoc->setDefaultTextOption(l_oOpt); -#else - #warning "Using Qt 4.3 is recommended" -#endif - - m_oCursor = new QTextCursor(m_oDoc); + //QTextOption l_oOpt; + //l_oOpt.setWrapMode(QTextOption::WordWrap); + //setDefaultTextOption(l_oOpt); m_iId = i_iId; - m_bSel = false; m_bEdit = false; - m_sNum = "1"; + m_iNum = 1; - m_oDoc->setPlainText(m_oGraph->m_oControl->m_oItems.value(Id())->m_sSummary); - adjustSize(); + setPlainText(m_oGraph->m_oMediator->m_oItems.value(Id())->m_sSummary); + //adjustSize(); m_oSort = new canvas_sort(i_oGraphWidget, this); + m_oChain = new canvas_chain(i_oGraphWidget); + m_oChain->setParentItem(this); - //setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable); - //setFlags(ItemIsMovable | ItemIsSelectable); - setFlags(ItemIsMovable); + m_oSortToggle = new canvas_sort_toggle(i_oGraphWidget); + m_oSortToggle->setParentItem(this); + setFlags(ItemIsMovable | ItemIsSelectable); setZValue(100); //setRect(0, 0, 20, 20); @@ -74,482 +68,39 @@ m_oColorBackup = m_oColor; i_oGraphWidget->scene()->addItem(this); - m_oSort->hide(); + m_oChain->setPos(boundingRect().width() + 2, 0); + m_oSortToggle->setPos(boundingRect().width() + 2, m_oChain->boundingRect().height() + 2); update_flags(); -} - -bool canvas_item::moveKey(QKeyEvent* i_oEv) -{ - //const QTextCursor oldSelection = cursor; - //const int oldCursorPos = m_oCursor->position(); - - QTextCursor::MoveMode mode = QTextCursor::MoveAnchor; - QTextCursor::MoveOperation op = QTextCursor::NoMove; - if (i_oEv == QKeySequence::SelectAll) - { - m_oCursor->select(QTextCursor::Document); - return true; - } - if (i_oEv == QKeySequence::MoveToNextChar) - { - op = QTextCursor::Right; - } - else if (i_oEv == QKeySequence::MoveToPreviousChar) - { - op = QTextCursor::Left; - } - else if (i_oEv == QKeySequence::SelectNextChar) - { - op = QTextCursor::Right; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectPreviousChar) - { - op = QTextCursor::Left; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectNextWord) - { - op = QTextCursor::WordRight; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectPreviousWord) - { - op = QTextCursor::WordLeft; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectStartOfLine) - { - op = QTextCursor::StartOfLine; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectEndOfLine) - { - op = QTextCursor::EndOfLine; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectStartOfBlock) - { - op = QTextCursor::StartOfBlock; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectEndOfBlock) - { - op = QTextCursor::EndOfBlock; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectStartOfDocument) - { - op = QTextCursor::Start; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectEndOfDocument) - { - op = QTextCursor::End; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectPreviousLine) - { - op = QTextCursor::Up; - mode = QTextCursor::KeepAnchor; - } -#if 0 - else if (e == QKeySequence::SelectNextLine) { - op = QTextCursor::Down; - mode = QTextCursor::KeepAnchor; - { - QTextBlock block = cursor.block(); - QTextLine line = currentTextLine(cursor); - if (!block.next().isValid() - && line.isValid() - && line.lineNumber() == block.layout()->lineCount() - 1) - op = QTextCursor::End; - } - } - else if (e == QKeySequence::SelectNextLine) { - op = QTextCursor::Down; - mode = QTextCursor::KeepAnchor; - { - QTextBlock block = cursor.block(); - QTextLine line = currentTextLine(cursor); - if (!block.next().isValid() - && line.isValid() - && line.lineNumber() == block.layout()->lineCount() - 1) - op = QTextCursor::End; - } - } -#endif - else if (i_oEv == QKeySequence::MoveToNextWord) - { - op = QTextCursor::WordRight; - } - else if (i_oEv == QKeySequence::MoveToPreviousWord) - { - op = QTextCursor::WordLeft; - } - else if (i_oEv == QKeySequence::MoveToEndOfBlock) - { - op = QTextCursor::EndOfBlock; - } - else if (i_oEv == QKeySequence::MoveToStartOfBlock) - { - op = QTextCursor::StartOfBlock; - } - else if (i_oEv == QKeySequence::MoveToNextLine) - { - op = QTextCursor::Down; - } - else if (i_oEv == QKeySequence::MoveToPreviousLine) - { - op = QTextCursor::Up; - } - else if (i_oEv == QKeySequence::MoveToPreviousLine) - { - op = QTextCursor::Up; - } - else if (i_oEv == QKeySequence::MoveToStartOfLine) - { - op = QTextCursor::StartOfLine; - } - else if (i_oEv == QKeySequence::MoveToEndOfLine) - { - op = QTextCursor::EndOfLine; - } - else if (i_oEv == QKeySequence::MoveToStartOfDocument) - { - op = QTextCursor::Start; - } - else if (i_oEv == QKeySequence::MoveToEndOfDocument) - { - op = QTextCursor::End; - } - else - { - return false; - } - - /*const bool moved =*/ m_oCursor->movePosition(op, mode); -#if 0 - //m_oCursor->ensureCursorVisible(); - if (moved) - { - if (m_oCursor->position() != oldCursorPos) - emit q->cursorPositionChanged(); - emit q->microFocusChanged(); - } -#endif - - return true; + setCacheMode(QGraphicsItem::DeviceCoordinateCache); } -void canvas_item::keyPressEvent(QKeyEvent* i_oEv) -{ - // imitates qt +// (i_oEv == QKeySequence::DeleteEndOfWord) - if (moveKey(i_oEv)) goto accept; - - if (i_oEv->key() == Qt::Key_Backspace && !i_oEv->modifiers()) - { - QTextBlockFormat blockFmt = m_oCursor->blockFormat(); - QTextList *list = m_oCursor->currentList(); - if (list && m_oCursor->atBlockStart()) - { - list->remove(m_oCursor->block()); - } - else if (m_oCursor->atBlockStart() && blockFmt.indent() > 0) - { - blockFmt.setIndent(blockFmt.indent() - 1); - m_oCursor->setBlockFormat(blockFmt); - } - else - { - m_oCursor->deletePreviousChar(); - } - goto accept; - } - - if (i_oEv == QKeySequence::Undo) - { - m_oDoc->undo(); - } - else if (i_oEv == QKeySequence::Redo) - { - m_oDoc->redo(); - } - else if (i_oEv == QKeySequence::Copy) - { - if (m_oCursor->hasSelection()) - { - const QTextDocumentFragment l_oF(*m_oCursor); - QApplication::clipboard()->setText(l_oF.toPlainText()); - } - } - else if (i_oEv == QKeySequence::Cut) - { - if (m_oCursor->hasSelection()) - { - const QTextDocumentFragment l_oF(*m_oCursor); - QApplication::clipboard()->setText(l_oF.toPlainText()); - m_oCursor->removeSelectedText(); - } - } - else if (i_oEv == QKeySequence::Paste) - { - const QMimeData *l_oSource = QApplication::clipboard()->mimeData(); - if (l_oSource) - { - QString l_sText = l_oSource->text(); - if (!l_sText.isNull()) - { - m_oCursor->insertFragment(QTextDocumentFragment::fromPlainText(l_sText)); - } - } - } - else if (i_oEv == QKeySequence::Delete) - { - m_oCursor->deleteChar(); - } - else if (i_oEv == QKeySequence::DeleteEndOfWord) - { - m_oCursor->movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); - m_oCursor->deleteChar(); - } - else if (i_oEv == QKeySequence::DeleteStartOfWord) - { - m_oCursor->movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor); - m_oCursor->deleteChar(); - } -#if 0 - else if (i_oEv == QKeySequence::DeleteEndOfLine) - { - QTextBlock block = cursor.block(); - if (cursor.position() == block.position() + block.length() - 2) - cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor); - else - cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); - cursor.deleteChar(); - } -#endif - else - { - goto process; - } - goto accept; - - process: - { - bool overwriteMode = false; - QString text = i_oEv->text(); - if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) - { - if (overwriteMode && !m_oCursor->hasSelection() && !m_oCursor->atBlockEnd()) - m_oCursor->deleteChar(); - - m_oCursor->insertText(text); - //selectionChanged(); - } - else - { - i_oEv->ignore(); - return; - } - } - -accept: - - i_oEv->accept(); - - adjustSize(); - update(); - - //QGraphicsTextItem::keyPressEvent(i_oEv); - update_links(); -} - -void canvas_item::keyReleaseEvent(QKeyEvent* i_oEv) -{ - //ensureCursorVisible(); - //m_oCursor->movePosition(QTextCursor::End); - - if (i_oEv->key() == Qt::Key_Enter || i_oEv->key() == Qt::Key_Return) - { - return; - } - //QGraphicsTextItem::keyReleaseEvent(i_oEv); -} - -void canvas_item::focus_in() -{ - if (m_oDoc->toPlainText() == QObject::trUtf8("Empty")) m_oDoc->setPlainText(""); - m_bEdit = true; - m_oColorBackup = m_oColor; - m_oColor = s_oColorSelect; - //QKeyEvent l_oKeyEvent = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::NoModifier); - //keyPressEvent(&l_oKeyEvent); - update(); -} - -void canvas_item::focus_out(QFocusEvent *i_oEv) -{ - if (!m_bEdit) return; - - m_oColor = m_oColorBackup; - m_bEdit = false; - - if (m_oDoc->toPlainText().isEmpty()) m_oDoc->setPlainText(QObject::trUtf8("Empty")); - - data_item *l_o = m_oGraph->m_oControl->m_oItems.value(Id()); - QString l_s = m_oDoc->toPlainText(); - if (l_o->m_sSummary != l_s) m_oGraph->m_oControl->set_dirty(); - l_o->m_sSummary = l_s; - m_oGraph->m_oControl->update_item(Id(), view_canvas); - - //QGraphicsTextItem::focusOutEvent(i_oEv); - adjustSize(); - update_links(); - update(); -} - -void canvas_item::adjustSize() -{ - m_oDoc->adjustSize(); - QSizeF l_o = m_oDoc->size(); - QRectF l_oR = boundingRect(); - - data_item *l_oItem = m_oGraph->m_oControl->m_oItems.value(Id()); - - l_o.setWidth(_max(l_o.width(), l_oItem->m_oThumbnail.width())); - l_o.setHeight(l_o.height() + l_oItem->m_oThumbnail.height()); - - l_o.setWidth(l_o.width() + 2 * item_padding); - l_o.setHeight(l_o.height() + 2 * item_padding + 2.); - - setRect(l_oR.x(), l_oR.y(), l_o.width(), l_o.height()); -} +//void canvas_item::keyReleaseEvent(QKeyEvent* i_oEv) +// i_oEv->key() == Qt::Key_Enter || i_oEv->key() == Qt::Key_Return) void canvas_item::set_parent(canvas_item * i_o) { m_oParent = i_o; } -void canvas_item::paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *option, QWidget * i_oW) +QVariant canvas_item::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) { - data_item *l_oItem = m_oGraph->m_oControl->m_oItems.value(Id()); - color_scheme l_oColorScheme = l_oItem->get_color_scheme(); - - QPen l_oPen = QPen(Qt::SolidLine); - - l_oPen.setColor(l_oColorScheme.m_oBorderColor); - if (m_bSel) l_oPen.setWidth(2); - else l_oPen.setWidth(1); - - i_oPainter->setPen(l_oPen); - - - //m_oRenderer = new QSvgRenderer(QLatin1String("/home/waf/truc.svg")); - - QRectF l_oB = boundingRect(); - qreal w = l_oPen.width()/2.; - QRectF l_oRect = l_oB.adjusted(w, w, -w, -w); - - if (m_oGraph->m_oControl->parent_of(Id()) <= 0 && l_oItem->m_iColor > 1) - { - QLinearGradient l_oGradient(l_oRect.right()-40, 0, l_oRect.right()-10, 0); - l_oGradient.setColorAt(0., l_oColorScheme.m_oInnerColor); - l_oGradient.setColorAt(1., l_oItem->get_color_scheme_raw().m_oInnerColor); - - QBrush l_oBrush(l_oGradient); - i_oPainter->setBrush(l_oBrush); - } - else + if (scene()) { - i_oPainter->setBrush(l_oColorScheme.m_oInnerColor); - } - - if (m_bEdit) i_oPainter->setBrush(QColor(255, 255, 255)); - - //i_oPainter->drawRect(l_oRect); - i_oPainter->drawRoundRect(l_oRect, 40, 40); - - - //i_oPainter->drawRoundRect(boundingRect(), 2, 2); - - // if there is text, draw a triangle on the top-right corner - if (l_oItem->m_iTextLength > 0) - { - const QPointF points[4] = + if (i_oChange == ItemPositionHasChanged) { - l_oRect.topRight(), - l_oRect.topRight()-QPointF(5, 0), - l_oRect.topRight()+QPointF(0, 5), - }; - i_oPainter->setBrush(l_oColorScheme.m_oBorderColor); - i_oPainter->drawPolygon(points, 3); - i_oPainter->setBrush(l_oColorScheme.m_oInnerColor); - } - - // now draw the text - - //m_oRenderer->render(i_oPainter, l_oRect); - //i_oPainter->drawEllipse(l_oRect); - - if (!l_oItem->m_oThumbnail.isNull()) - { - i_oPainter->save(); - i_oPainter->translate(l_oB.width()/2 - l_oItem->m_oThumbnail.width() / 2, item_padding); - i_oPainter->drawPixmap(0, 0, l_oItem->m_oThumbnail.width(), l_oItem->m_oThumbnail.height(), l_oItem->m_oPix); - i_oPainter->restore(); - } - - - i_oPainter->save(); - i_oPainter->translate(item_padding, item_padding + l_oItem->m_oThumbnail.height() + 2.); - - QAbstractTextDocumentLayout::PaintContext ctx; - ctx.palette = QApplication::palette("QTextControl"); - - if (m_bEdit) - { - ctx.cursorPosition = m_oCursor->position(); - if (m_oCursor->hasSelection()) + update_links(); + } + else if (i_oChange == ItemSelectedHasChanged) { - QAbstractTextDocumentLayout::Selection selection; - selection.cursor = *m_oCursor; - QPalette::ColorGroup cg = QPalette::Active; - selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight)); - selection.format.setForeground(ctx.palette.brush(cg, QPalette::HighlightedText)); - ctx.selections.append(selection); + m_oChain->setVisible(isSelected()); + m_oSortToggle->setVisible(isSelected()); } } - else - { - ctx.cursorPosition = -1; - } - - m_oDoc->documentLayout()->draw(i_oPainter, ctx); - //m_oDoc->drawContents(i_oPainter); - i_oPainter->restore(); -} - -QVariant canvas_item::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) -{ - bool l_bChange = ((i_oChange == ItemPositionChange) && scene()); - - QVariant l_oRet = QGraphicsItem::itemChange(i_oChange, i_oValue); - - if (l_bChange) - { - update_links(); - } - - return l_oRet; -} - -bool canvas_item::hasFocus() const -{ - return m_bEdit; + return QGraphicsItem::itemChange(i_oChange, i_oValue); } void canvas_item::add_link(canvas_link* i_oL) @@ -566,9 +117,14 @@ void canvas_item::update_data() { - data_item *l_oItem = m_oGraph->m_oControl->m_oItems.value(Id()); + data_item *l_oItem = m_oGraph->m_oMediator->m_oItems.value(Id()); + if (l_oItem->m_iXX < -10000.0) { + l_oItem->m_iXX = m_oGraph->m_oLastPoint.x(); + l_oItem->m_iYY = m_oGraph->m_oLastPoint.y(); + } + setPos(QPointF(l_oItem->m_iXX, l_oItem->m_iYY)); - m_oDoc->setPlainText(l_oItem->m_sSummary); + setPlainText(l_oItem->m_sSummary); adjustSize(); update_links(); update_flags(); @@ -576,7 +132,7 @@ void canvas_item::update_color() { - int l_oP = m_oGraph->m_oControl->parent_of(Id()); + int l_oP = m_oGraph->m_oMediator->parent_of(Id()); if (l_oP < 0) m_oColor = s_oColorRoot; else m_oColor = s_oColorLeaf; m_oColorBackup = m_oColor; @@ -592,7 +148,7 @@ void canvas_item::update_flags() { - data_item *l_oItem = m_oGraph->m_oControl->m_oItems.value(Id()); + data_item *l_oItem = m_oGraph->m_oMediator->m_oItems.value(Id()); int l_iDiff = l_oItem->m_oFlags.size() - m_oFlags.size(); while (l_iDiff > 0) @@ -611,7 +167,7 @@ delete l_o; } - qreal l_iWidth = m_oDoc->textWidth(); + qreal l_iWidth = textWidth(); for (int i=0; ikey() == Qt::Key_Enter || e->key() == Qt::Key_Return) { - l_oLink->update_selected(); + m_oGraph->m_oEditAction->activate(QAction::Trigger); + return; + } + else if (e->key() == Qt::Key_Escape) + { + m_oGraph->m_oCancelEditAction->activate(QAction::Trigger); + return; } + + QGraphicsTextItem::keyPressEvent(e); + adjustSize(); + update_links(); } -void canvas_item::inputMethodEvent(QInputMethodEvent *e) -{ - if (!m_bEdit) +void canvas_item::adjustSize() { + QGraphicsTextItem::adjustSize(); + QRectF r = boundingRect(); + m_oChain->setPos(r.width() + 2, 0); + m_oSortToggle->setPos(r.width() + 2, m_oChain->boundingRect().height() + 2); + + // FIXME we do not really track the size of the item + data_item *l_oItem = m_oGraph->m_oMediator->m_oItems.value(Id()); + l_oItem->m_iWW = r.width(); + l_oItem->m_iHH = r.height(); +} + +void canvas_item::keyReleaseEvent(QKeyEvent* e) { + if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return || e->key() == Qt::Key_Escape) { - e->ignore(); return; } - m_oCursor->beginEditBlock(); - m_oCursor->removeSelectedText(); + QGraphicsTextItem::keyReleaseEvent(e); +} + +QRectF canvas_item::boundingRect() const { + QTextDocument *doc = document(); + QRectF rect(QPointF(0, 0), doc->size()); + return rect.adjusted(-OFF, -OFF, OFF, OFF); +} + +QPainterPath canvas_item::opaqueArea() const +{ + return shape(); +} - // insert commit string - if (!e->commitString().isEmpty() || e->replacementLength()) +void canvas_item::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + data_item *l_oItem = m_oGraph->m_oMediator->m_oItems.value(Id()); + color_scheme l_oColorScheme = l_oItem->get_color_scheme(); + + QPen l_oPen = QPen(Qt::SolidLine); + + l_oPen.setColor(l_oColorScheme.m_oBorderColor); + if (isSelected()) l_oPen.setStyle(Qt::DotLine); + l_oPen.setCosmetic(true); + + painter->setPen(l_oPen); + + if (textInteractionFlags() & Qt::TextEditorInteraction) { - QTextCursor c = *m_oCursor; - c.setPosition(c.position() + e->replacementStart()); - c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor); - c.insertText(e->commitString()); - } - - QTextBlock block = m_oCursor->block(); - QTextLayout *layout = block.layout(); - //layout->setPreeditArea(m_oCursor->position() - block.position(), e->preeditString()); - QList overrides; - //preeditCursor = e->preeditString().length(); - //hideCursor = false; - for (int i = 0; i < e->attributes().size(); ++i) - { - const QInputMethodEvent::Attribute &a = e->attributes().at(i); - ///*if (a.type == QInputMethodEvent::Cursor) { - // preeditCursor = a.start; - // //hideCursor = !a.length; - //} else*/ - if (a.type == QInputMethodEvent::TextFormat) + painter->setBrush(Qt::white); + } + else + { + if (m_oGraph->m_oMediator->parent_of(Id()) <= 0 && l_oItem->m_iColor > 1) + { + QLinearGradient l_oGradient(l_oRect.right()-40, 0, l_oRect.right()-10, 0); + l_oGradient.setColorAt(0., l_oColorScheme.m_oInnerColor); + l_oGradient.setColorAt(1., l_oItem->get_color_scheme_raw().m_oInnerColor); + + QBrush l_oBrush(l_oGradient); + painter->setBrush(l_oBrush); + } + else { - QTextCharFormat f = qvariant_cast(a.value).toCharFormat(); - if (f.isValid()) - { - QTextLayout::FormatRange o; - o.start = a.start + m_oCursor->position() - block.position(); - o.length = a.length; - o.format = f; - overrides.append(o); - } + painter->setBrush(l_oColorScheme.m_oInnerColor); } } - layout->setAdditionalFormats(overrides); - m_oCursor->endEditBlock(); - adjustSize(); - update(); + painter->drawRoundRect(l_oRect, 20, 20); + + // if there is text, draw a triangle on the top-right corner + if (m_oGraph->m_oMediator->m_oItems.value(Id())->m_sText.length() > 0) + { + const QPointF points[4] = + { + l_oRect.topRight(), + l_oRect.topRight()-QPointF(5, 0), + l_oRect.topRight()+QPointF(0, 5), + }; + painter->setBrush(l_oColorScheme.m_oBorderColor); + painter->drawPolygon(points, 3); + painter->setBrush(l_oColorScheme.m_oInnerColor); + } + //painter->translate(5, 5); + + + QAbstractTextDocumentLayout::PaintContext ctx; + if (textInteractionFlags() & Qt::TextEditorInteraction) { + QTextCursor cursor = textCursor(); + ctx.cursorPosition = cursor.position(); + QAbstractTextDocumentLayout::Selection selection; + selection.cursor = cursor; + selection.format.setBackground(ctx.palette.brush(QPalette::Active, QPalette::Highlight)); + selection.format.setForeground(ctx.palette.brush(QPalette::Active, QPalette::HighlightedText)); + ctx.selections.append(selection); + } + + ctx.clip = l_oRect; + document()->documentLayout()->draw(painter, ctx); + + painter->restore(); } diff -Nru semantik-0.7.3/src/canvas_item.h semantik-0.8.3/src/canvas_item.h --- semantik-0.7.3/src/canvas_item.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/canvas_item.h 2012-09-05 01:08:33.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 @@ -10,6 +10,9 @@ #include #include +#define OFF 3 +#define PAD 1 + class QTextDocument; class QColor; class QString; @@ -19,16 +22,19 @@ class canvas_link; class canvas_sort; class canvas_flag; +class canvas_chain; +class canvas_sort_toggle; -class canvas_item: public QGraphicsRectItem +class canvas_item: public QGraphicsTextItem { public: canvas_item(canvas_view *i_oGraphWidget, int i_iId); ~canvas_item(); - //enum { Type = gratype(7) }; - int type() const { return gratype(7); } + int type() const { return CANVAS_ITEM_T; } + QRectF boundingRect() const; + void adjustSize(); void update_flags(); QList m_oLinks; @@ -42,36 +48,24 @@ */ QVariant itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue); + QPainterPath opaqueArea() const; QColor get_color() {return m_oColor;} void set_color(QColor c) {m_oColor=c;} - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); - - void set_parent(canvas_item *); - void adjustSize(); + //void adjustSize(); int Id() const {return m_iId;}; - QTextDocument *m_oDoc; - QTextCursor *m_oCursor; - - bool m_bSel; bool m_bEdit; - QString m_sNum; - - void set_selected(bool); - - bool hasFocus() const; - - void keyPressEvent(QKeyEvent* i_oEv); - bool moveKey(QKeyEvent* i_oEv); - void keyReleaseEvent(QKeyEvent *i_oEv); - void focus_out(QFocusEvent *i_oEv); - void inputMethodEvent(QInputMethodEvent *); + int m_iNum; - void focus_in(); + void mousePressEvent(QGraphicsSceneMouseEvent* e); + void mouseReleaseEvent(QGraphicsSceneMouseEvent* e); + void keyPressEvent(QKeyEvent*); + void keyReleaseEvent(QKeyEvent*); + void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); static QColor s_oColorRect; static QColor s_oColorRoot; @@ -85,12 +79,14 @@ QList m_oFlags; - inline qreal const x2() {return x() + rect().width();} - inline qreal const y2() {return y() + rect().height();} + inline qreal const x2() {return x() + boundingRect().width();} + inline qreal const y2() {return y() + boundingRect().height();} canvas_view *m_oGraph; canvas_item *m_oParent; canvas_sort *m_oSort; + canvas_chain *m_oChain; + canvas_sort_toggle *m_oSortToggle; int m_iId; QColor m_oColor; diff -Nru semantik-0.7.3/src/canvas_link.cpp semantik-0.8.3/src/canvas_link.cpp --- semantik-0.7.3/src/canvas_link.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/canvas_link.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -/// Thomas Nagy 2007-2009 GPLV3 +/// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -10,14 +10,14 @@ #include -#include "data_control.h" +#include "sem_mediator.h" #include "con.h" #include "canvas_item.h" #include "canvas_link.h" #include "canvas_view.h" -canvas_link::canvas_link(canvas_view *i_oGraphWidget, canvas_item *i_oFrom, canvas_item *i_oTo) - : QGraphicsPathItem(), m_oGraph(i_oGraphWidget) + canvas_link::canvas_link(canvas_view *i_oGraphWidget, canvas_item *i_oFrom, canvas_item *i_oTo) +: QGraphicsPathItem(), m_oGraph(i_oGraphWidget) { setFlags(ItemIsMovable & ItemIsSelectable); @@ -38,12 +38,13 @@ setBrush(m_oColor); /* - QPen l_oPen; - l_oPen.setWidth(5); - setPen(l_oPen); - */ + QPen l_oPen; + l_oPen.setWidth(5); + setPen(l_oPen); + */ i_oGraphWidget->scene()->addItem(this); //setParentItem(m_oFrom); + setCacheMode(QGraphicsItem::DeviceCoordinateCache); } void canvas_link::rm_link() @@ -54,7 +55,7 @@ void canvas_link::update_pos() { - if (m_oFrom->m_oGraph->m_oControl->m_iConnType == 0) + if (m_oFrom->m_oGraph->m_oMediator->m_iConnType == 0) { update_triangle(); } @@ -66,7 +67,7 @@ void canvas_link::update_selected() { - bool l_b = (m_oFrom->m_bSel || m_oTo->m_bSel); + bool l_b = (m_oFrom->isSelected() || m_oTo->isSelected()); if (m_bSel != l_b) { m_bSel = l_b; @@ -77,18 +78,18 @@ void canvas_link::update_triangle() { QRectF l_oR1 = m_oFrom->boundingRect(); - QRectF l_oR2 = m_oTo->boundingRect(); + QRectF l_oR2 = m_oTo->boundingRect(); - double _x1 = m_oFrom->x() + l_oR1.width()/2.; - double _y1 = m_oFrom->y() + l_oR1.height()/2.; + double _x1 = m_oFrom->x() + l_oR1.width()/2. - OFF; + double _y1 = m_oFrom->y() + l_oR1.height()/2. - OFF; - double _x2 = m_oTo->x() + l_oR2.width()/2.; - double _y2 = m_oTo->y() + l_oR2.height()/2.; + double _x2 = m_oTo->x() + l_oR2.width()/2. - OFF; + double _y2 = m_oTo->y() + l_oR2.height()/2. - OFF; - double _X1 = _x2 - _x1; - double _Y1 = _y2 - _y1; + double _X1 = _x2 - _x1; + double _Y1 = _y2 - _y1; - double l_oDist = 1; + double l_oDist = 1; double _coeff = 0; if (_Y1*_Y1>_X1*_X1) _coeff = _Y1*_Y1/(_Y1*_Y1+_X1*_X1); else _coeff = 1 - _X1*_X1/(_Y1*_Y1+_X1*_X1); @@ -97,10 +98,10 @@ { QPolygonF _polygon; _polygon - <m_oGraph->m_oControl->m_dTriSize; + double _s = m_oFrom->m_oGraph->m_oMediator->m_dTriSize; QPolygonF _polygon; _polygon - <boundingRect(); - QRectF l_oR2 = m_oTo->boundingRect(); + QRectF l_oR2 = m_oTo->boundingRect(); - double _x1 = m_oFrom->x() + l_oR1.width()/2.; - double _y1 = m_oFrom->y() + l_oR1.height()/2.; + double _x1 = m_oFrom->x() + l_oR1.width()/2. - OFF; + double _y1 = m_oFrom->y() + l_oR1.height()/2. - OFF; - double _x2 = m_oTo->x() + l_oR2.width()/2.; - double _y2 = m_oTo->y() + l_oR2.height()/2.; + double _x2 = m_oTo->x() + l_oR2.width()/2. - OFF; + double _y2 = m_oTo->y() + l_oR2.height()/2. - OFF; - double _X1 = _x2 - _x1; - double _Y1 = _y2 - _y1; + double _X1 = _x2 - _x1; + double _Y1 = _y2 - _y1; - double l_oDist = 1; + double l_oDist = 1; double _coeff = 0; if (_Y1*_Y1>_X1*_X1) _coeff = _Y1*_Y1/(_Y1*_Y1+_X1*_X1); else _coeff = 1 - _X1*_X1/(_Y1*_Y1+_X1*_X1); @@ -154,10 +155,10 @@ { QPolygonF _polygon; _polygon - < #include @@ -25,6 +25,7 @@ //m_oColor = QColor("#FFFCD5"); //m_oColor = QColor("#ABFBC7"); + hide(); QPen l_oPen; l_oPen.setWidth(1); setPen(l_oPen); @@ -41,9 +42,18 @@ setParentItem(m_oFrom); } -void canvas_sort::paint(QPainter *_painter, const QStyleOptionGraphicsItem *_option, QWidget * i_oW) +void canvas_sort::paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *_option, QWidget * i_oW) { - QGraphicsEllipseItem::paint(_painter, _option, i_oW); - _painter->drawText(boundingRect().translated(0, 1), Qt::AlignCenter, m_oFrom->m_sNum); + if (m_oGraph->m_iSortCursor + 1 > m_oFrom->m_iNum) + { + i_oPainter->setBrush(QColor(0, 255, 0)); + } + else + { + i_oPainter->setBrush(QColor(255, 255, 0)); + } + + i_oPainter->drawEllipse(boundingRect().adjusted(1, 1, -1, -1)); + i_oPainter->drawText(boundingRect().translated(0, 1), Qt::AlignCenter, QString::number(m_oFrom->m_iNum)); } diff -Nru semantik-0.7.3/src/canvas_sort.h semantik-0.8.3/src/canvas_sort.h --- semantik-0.7.3/src/canvas_sort.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/canvas_sort.h 2012-09-05 01:08:33.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef CANVAS_SORT_H #define CANVAS_SORT_H @@ -17,16 +17,10 @@ { public: canvas_sort(canvas_view *i_oGraphWidget, canvas_item *i_oFrom); - - //enum { Type = gratype(19) }; - int type() const { return gratype(19); } - //private: + int type() const { return CANVAS_SORT_T; } canvas_view *m_oGraph; - - //public: canvas_item *m_oFrom; void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - }; #endif diff -Nru semantik-0.7.3/src/canvas_sort_toggle.cpp semantik-0.8.3/src/canvas_sort_toggle.cpp --- semantik-0.7.3/src/canvas_sort_toggle.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/canvas_sort_toggle.cpp 2012-09-05 01:08:33.000000000 +0000 @@ -0,0 +1,32 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include "CON.h" +#include "canvas_sort_toggle.h" +#include "box_view.h" +#include "data_item.h" +#include + +#define PAD 1 + +canvas_sort_toggle::canvas_sort_toggle(canvas_view* i_oParent) : QGraphicsRectItem() +{ + m_oParent = i_oParent; + setVisible(false); + setRect(0, 0, 10, 10); +} + +void canvas_sort_toggle::paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *option, QWidget * i_oW) +{ + QPen l_oPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setWidth(1); + i_oPainter->setPen(l_oPen); + + i_oPainter->setBrush(Qt::yellow); // yolo + + i_oPainter->drawEllipse(boundingRect().adjusted(PAD, PAD, -PAD, -PAD)); +} + diff -Nru semantik-0.7.3/src/canvas_sort_toggle.h semantik-0.8.3/src/canvas_sort_toggle.h --- semantik-0.7.3/src/canvas_sort_toggle.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/canvas_sort_toggle.h 2012-09-05 01:08:33.000000000 +0000 @@ -0,0 +1,23 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef CANVAS_SORT_TOGGLE_H +#define CANVAS_SORT_TOGGLE_H + +#include +#include +#include +#include +#include +#include "con.h" +#include "canvas_view.h" + +class canvas_sort_toggle : public QGraphicsRectItem +{ + public: + canvas_sort_toggle(canvas_view *i_oGraphWidget); + canvas_view *m_oParent; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); +}; + +#endif // CANVAS_SORT_TOGGLE_H + diff -Nru semantik-0.7.3/src/canvas_view.cpp semantik-0.8.3/src/canvas_view.cpp --- semantik-0.7.3/src/canvas_view.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/canvas_view.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -1,22 +1,29 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include "canvas_flag.h" #include "data_item.h" #include -#include "data_control.h" +#include "sem_mediator.h" #include "canvas_view.h" #include #include #include #include +#include +#include +#include #include #include "canvas_item.h" #include "canvas_link.h" #include +#include #include "canvas_sort.h" +#include +#include "canvas_sort_toggle.h" #include "semantik.h" #include #include +#include "canvas_chain.h" #include #include #include @@ -24,15 +31,25 @@ #include #include #include +#include +#include +#include "export_map_dialog.h" +#include "kurlrequester.h" + + #include #include -canvas_view::canvas_view(QWidget *i_oWidget, data_control *i_oControl) : QGraphicsView(i_oWidget) +canvas_view::canvas_view(QWidget *i_oWidget, sem_mediator *i_oControl) : QGraphicsView(i_oWidget) { m_oSemantikWindow = i_oWidget; + m_iSortId = NO_ITEM; + m_iSortCursor = 0; - m_oRubbery = new QRubberBand(QRubberBand::Rectangle, this); - m_oRubbery->setGeometry(QRect(0, 0, 0, 0)); + m_oLastPoint = QPointF(0, 0); + + //m_oRubbery = new QRubberBand(QRubberBand::Rectangle, this); + //m_oRubbery->setGeometry(QRect(0, 0, 0, 0)); QGraphicsScene *l_oScene = new QGraphicsScene(this); l_oScene->setSceneRect(-400, -400, 400, 400); @@ -41,51 +58,29 @@ //setCacheMode(CacheBackground); setRenderHint(QPainter::Antialiasing); -#ifndef Q_OS_DARWIN - - setDragMode(QGraphicsView::NoDrag); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setMinimumSize(200, 200); -#ifdef O - //setTransformationAnchor(AnchorUnderMouse); - //setResizeAnchor(AnchorViewCenter); -#endif - - /*QMatrix k(0, 1, 1, 0, 0, 0); - QMatrix kv(1, 0, 0, -1, 0, 0);*/ - m_oControl = i_oControl; - /*setMatrix(l_oMatrix); - scale(0.8, 0.8);*/ -#endif - - m_iMode = select_mode; - m_iLastMode = no_mode; + m_oMediator = i_oControl; m_bPressed = false; + m_bScroll = false; m_oRubberLine = new rubber_line(QRubberBand::Line, this); - QBrush l_oBrush = QBrush(); //QColor l_oColor = QColor("#000077"); //l_oColor.setAlpha(200); QColor l_oColor = QColor(0, 0, 150, 100); - //l_oBrush.setColor(l_oColor); + l_oBrush.setColor(l_oColor); //m_oRubber->setBrush(l_oBrush); QAction *l_o = NULL; - m_oEditAction = new QAction(trUtf8("Toggle edit"), this); - m_oEditAction->setShortcut(notr("Return")); - connect(m_oEditAction, SIGNAL(triggered()), this, SLOT(slot_edit())); - addAction(m_oEditAction); - - m_oAddItemAction = new QAction(trUtf8("Insert child"), this); + m_oAddItemAction = new QAction(trUtf8("Add an element"), this); m_oAddItemAction->setShortcut(notr("Ctrl+Return")); connect(m_oAddItemAction, SIGNAL(triggered()), this, SLOT(slot_add_item())); addAction(m_oAddItemAction); @@ -95,29 +90,46 @@ connect(m_oDeleteAction, SIGNAL(triggered()), this, SLOT(slot_delete())); addAction(m_oDeleteAction); - l_o = new QAction(trUtf8("Insert sibling"), this); + m_oInsertSiblingAction = l_o = new QAction(trUtf8("Insert a sibling"), this); l_o->setShortcut(notr("Shift+Return")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_add_sibling())); addAction(l_o); - l_o = new QAction(trUtf8("Move up"), this); l_o->setShortcut(notr("Alt+Up")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_move())); addAction(l_o); l_o->setData(QVariant(0)); - l_o = new QAction(trUtf8("Move down"), this); l_o->setShortcut(notr("Alt+Down")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_move())); addAction(l_o); l_o->setData(QVariant(1)); - l_o = new QAction(trUtf8("Move left"), this); l_o->setShortcut(notr("Alt+Left")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_move())); addAction(l_o); l_o->setData(QVariant(2)); - l_o = new QAction(trUtf8("Move right"), this); l_o->setShortcut(notr("Alt+Right")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_move())); addAction(l_o); l_o->setData(QVariant(3)); - - l_o = new QAction(trUtf8("Select up"), this); l_o->setShortcut(notr("Up")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_sel())); addAction(l_o); l_o->setData(QVariant(0)); - l_o = new QAction(trUtf8("Select down"), this); l_o->setShortcut(notr("Down")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_sel())); addAction(l_o); l_o->setData(QVariant(1)); - l_o = new QAction(trUtf8("Select left"), this); l_o->setShortcut(notr("Left")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_sel())); addAction(l_o); l_o->setData(QVariant(2)); - l_o = new QAction(trUtf8("Select right"), this); l_o->setShortcut(notr("Right")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_sel())); addAction(l_o); l_o->setData(QVariant(3)); + m_oMoveUpAction = l_o = new QAction(trUtf8("Move up"), this); l_o->setShortcut(notr("Alt+Up")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_move())); addAction(l_o); l_o->setData(QVariant(0)); + m_oMoveDownAction = l_o = new QAction(trUtf8("Move down"), this); l_o->setShortcut(notr("Alt+Down")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_move())); addAction(l_o); l_o->setData(QVariant(1)); + m_oMoveLeftAction = l_o = new QAction(trUtf8("Move left"), this); l_o->setShortcut(notr("Alt+Left")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_move())); addAction(l_o); l_o->setData(QVariant(2)); + m_oMoveRightAction = l_o = new QAction(trUtf8("Move right"), this); l_o->setShortcut(notr("Alt+Right")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_move())); addAction(l_o); l_o->setData(QVariant(3)); + + m_oSelectUpAction = l_o = new QAction(trUtf8("Select up"), this); l_o->setShortcut(notr("Up")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_sel())); addAction(l_o); l_o->setData(QVariant(0)); + m_oSelectDownAction = l_o = new QAction(trUtf8("Select down"), this); l_o->setShortcut(notr("Down")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_sel())); addAction(l_o); l_o->setData(QVariant(1)); + m_oSelectLeftAction = l_o = new QAction(trUtf8("Select left"), this); l_o->setShortcut(notr("Left")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_sel())); addAction(l_o); l_o->setData(QVariant(2)); + m_oSelectRightAction = l_o = new QAction(trUtf8("Select right"), this); l_o->setShortcut(notr("Right")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_sel())); addAction(l_o); l_o->setData(QVariant(3)); + + m_oSelectSubtreeAction = new QAction(trUtf8("Select subtree"), this); + connect(m_oSelectSubtreeAction, SIGNAL(triggered()), this, SLOT(slot_select_subtree())); + addAction(m_oSelectSubtreeAction); - l_o = new QAction(trUtf8("Next root"), this); l_o->setShortcut(notr("PgDown")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_hop())); addAction(l_o); l_o->setData(QVariant(1)); + m_oNextRootAction = l_o = new QAction(trUtf8("Next root"), this); l_o->setShortcut(notr("PgDown")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_next_root())); addAction(l_o); l_o->setData(QVariant(1)); + + + m_oEditAction = new QAction(trUtf8("Toggle edit"), this); + m_oEditAction->setShortcut(notr("Return")); + addAction(m_oEditAction); + connect(m_oEditAction, SIGNAL(triggered()), this, SLOT(slot_toggle_edit())); + + m_oCancelEditAction = new QAction(trUtf8("Cancel edit"), this); + m_oCancelEditAction->setShortcut(notr("Escape")); + addAction(m_oCancelEditAction); + connect(m_oCancelEditAction, SIGNAL(triggered()), this, SLOT(slot_cancel_edit())); + m_oCancelEditAction->setEnabled(false); m_oMenu = new QMenu(this); m_oMenu->addAction(m_oAddItemAction); - m_oMenu->addAction(m_oEditAction); + //m_oMenu->addAction(m_oEditAction); m_oMenu->addAction(m_oDeleteAction); + m_oMenu->addAction(m_oSelectSubtreeAction); QAction *fullAction = new QAction(trUtf8("Toggle fullscreen"), this); connect(fullAction, SIGNAL(triggered()), this, SLOT(toggle_fullscreen())); addAction(l_o); @@ -133,52 +145,232 @@ m_oDataMenu->addAction(l_o); \ l_o->setCheckable(true); - newAction(trUtf8("Text"), view_text, m_oTextType); - newAction(trUtf8("Diagram"), view_diag, m_oDiagramType); - newAction(trUtf8("Table"), view_table, m_oTableType); - newAction(trUtf8("Image"), view_img, m_oImageType); + newAction(trUtf8("Text"), VIEW_TEXT, m_oTextType); + newAction(trUtf8("Diagram"), VIEW_DIAG, m_oDiagramType); + newAction(trUtf8("Table"), VIEW_TABLE, m_oTableType); + newAction(trUtf8("Image"), VIEW_IMG, m_oImageType); + + m_bDeleting = false; + //connect(scene(), SIGNAL(selectionChanged()), this, SLOT(selection_changed())); // TODO check with m_bPressed + + setDragMode(QGraphicsView::RubberBandDrag); +} + +void canvas_view::check_selection() { + + if (m_bDeleting) return; + + QList lst; + foreach(canvas_item* k, selection()) { + lst.append(k->Id()); + } + + // stupid set intersection + QList unlst; + foreach(data_item* x, m_oMediator->m_oItems.values()) { + if (x->m_bSelected) { + unlst.append(x->m_iId); + } + } + + foreach(int i, lst) { + if (!unlst.contains(i)) + goto undo; + } + + foreach (int i, unlst) { + if (!lst.contains(i)) + goto undo; + } + + mem_sel *sel; + goto end; + undo: + sel = new mem_sel(m_oMediator); + sel->sel = lst; + sel->apply(); + //qDebug()<<"selected"<data().toInt()) { case 0: - if (m_oSelected.size()>1) deselect_all(); - m_oControl->prev_root(); + m_oMediator->prev_root(); break; case 1: - if (m_oSelected.size()>1) deselect_all(); - m_oControl->next_root(); + m_oMediator->next_root(); break; default: break; } - if (m_oSelected.size()==1) ensureVisible(m_oSelected[0]); + QList sel = selection(); + if (sel.size()==1) ensureVisible(sel[0]); +} + +void canvas_view::edit_off() { + canvas_item* sel = NULL; + foreach (QGraphicsItem *tmp, items()) { + if (tmp->type() == CANVAS_ITEM_T) { + sel = (canvas_item*) tmp; + + if (sel->textInteractionFlags() & Qt::TextEditorInteraction) { + + sel->setTextInteractionFlags(Qt::NoTextInteraction); + if (sel->toPlainText() == notr("")) { + sel->setPlainText(QObject::trUtf8("Empty")); + sel->update_links(); + } + + if (sel->toPlainText() != (*m_oMediator + sel->Id())->m_sSummary) { + mem_edit *ed = new mem_edit(m_oMediator); + ed->newSummary = sel->toPlainText(); + ed->apply(); + } + + m_oAddItemAction->setEnabled(true); + m_oInsertSiblingAction->setEnabled(true); + m_oDeleteAction->setEnabled(true); + m_oNextRootAction->setEnabled(true); + + m_oMoveUpAction->setEnabled(true); + m_oMoveDownAction->setEnabled(true); + m_oMoveLeftAction->setEnabled(true); + m_oMoveRightAction->setEnabled(true); + m_oSelectUpAction->setEnabled(true); + m_oSelectDownAction->setEnabled(true); + m_oSelectLeftAction->setEnabled(true); + m_oSelectRightAction->setEnabled(true); + m_oSelectSubtreeAction->setEnabled(true); + m_oMediator->check_undo(true); + } + } + } } -void canvas_view::slot_edit() +void canvas_view::slot_toggle_edit() { - if (m_oSelected.size() == 1) - { - if (m_oSelected[0]->m_bEdit) - { - QFocusEvent l_oEv = QFocusEvent(QEvent::FocusOut); - m_oSelected[0]->focus_out(&l_oEv); - m_oSelected[0]->update(); + if (!hasFocus()) { + return; + } + + canvas_item* sel = NULL; + foreach (QGraphicsItem *tmp, items()) { + if (tmp->type() == CANVAS_ITEM_T && tmp->isSelected()) { + if (sel) { + sel = NULL; + break; + } else { + sel = (canvas_item*) tmp; + } } - else - { - m_oSelected[0]->focus_in(); - m_oSelected[0]->update(); + } + + if (sel) { + if (sel->textInteractionFlags() & Qt::TextEditorInteraction) { + sel->setTextInteractionFlags(Qt::NoTextInteraction); + if (sel->toPlainText() == notr("")) { + sel->setPlainText(QObject::trUtf8("Empty")); + sel->update(); // seems to update faster + sel->update_links(); + + } + if (sel->toPlainText() != (*m_oMediator + sel->Id())->m_sSummary) { + mem_edit *ed = new mem_edit(m_oMediator); + ed->newSummary = sel->toPlainText(); + ed->apply(); + } + } else { + sel->setTextInteractionFlags(Qt::TextEditorInteraction); + if (sel->toPlainText() == QObject::trUtf8("Empty")) { + sel->setPlainText(""); + sel->update(); // seems to update faster + sel->update_links(); + } + sel->setFocus(); + + m_oAddItemAction->setEnabled(false); + m_oCancelEditAction->setEnabled(true); + m_oInsertSiblingAction->setEnabled(false); + m_oDeleteAction->setEnabled(false); + m_oNextRootAction->setEnabled(false); + + m_oMoveUpAction->setEnabled(false); + m_oMoveDownAction->setEnabled(false); + m_oMoveLeftAction->setEnabled(false); + m_oMoveRightAction->setEnabled(false); + m_oSelectUpAction->setEnabled(false); + m_oSelectDownAction->setEnabled(false); + m_oSelectLeftAction->setEnabled(false); + m_oSelectRightAction->setEnabled(false); + m_oSelectSubtreeAction->setEnabled(false); + m_oMediator->check_undo(false); + return; + } + } + + m_oAddItemAction->setEnabled(true); + m_oCancelEditAction->setEnabled(false); + m_oInsertSiblingAction->setEnabled(true); + m_oDeleteAction->setEnabled(true); + m_oNextRootAction->setEnabled(true); + + m_oMoveUpAction->setEnabled(true); + m_oMoveDownAction->setEnabled(true); + m_oMoveLeftAction->setEnabled(true); + m_oMoveRightAction->setEnabled(true); + m_oSelectUpAction->setEnabled(true); + m_oSelectDownAction->setEnabled(true); + m_oSelectLeftAction->setEnabled(true); + m_oSelectRightAction->setEnabled(true); + m_oSelectSubtreeAction->setEnabled(true); + m_oMediator->check_undo(true); +} + +void canvas_view::slot_cancel_edit() +{ + canvas_item* sel = NULL; + foreach (QGraphicsItem *tmp, items()) { + if (tmp->type() == CANVAS_ITEM_T && tmp->isSelected()) { + if (sel) { + sel = NULL; + break; + } else { + sel = (canvas_item*) tmp; + } } } + + if (sel && sel->textInteractionFlags() & Qt::TextEditorInteraction) { + sel->setTextInteractionFlags(Qt::NoTextInteraction); + sel->update_data(); + } + + m_oAddItemAction->setEnabled(true); + m_oCancelEditAction->setEnabled(false); + m_oInsertSiblingAction->setEnabled(true); + m_oDeleteAction->setEnabled(true); + m_oNextRootAction->setEnabled(true); + + m_oMoveUpAction->setEnabled(true); + m_oMoveDownAction->setEnabled(true); + m_oMoveLeftAction->setEnabled(true); + m_oMoveRightAction->setEnabled(true); + m_oSelectUpAction->setEnabled(true); + m_oSelectDownAction->setEnabled(true); + m_oSelectLeftAction->setEnabled(true); + m_oSelectRightAction->setEnabled(true); + m_oSelectSubtreeAction->setEnabled(true); + m_oMediator->check_undo(true); } void canvas_view::slot_move() { - if (m_oSelected.size() < 1) return; + QList sel = selection(); + if (sel.size() < 1) return; switch (((QAction*) QObject::sender())->data().toInt()) { case 0: move_sel(0, -20); break; @@ -191,76 +383,93 @@ void canvas_view::slot_sel() { - if (m_oSelected.size() != 1) return; - int l_iId = m_oSelected[0]->Id(); + QList sel = selection(); + if (sel.size() != 1) return; + int l_iId = sel[0]->Id(); switch (((QAction*) QObject::sender())->data().toInt()) { - case 0: m_oControl->select_item_keyboard(l_iId, 3); break; - case 1: m_oControl->select_item_keyboard(l_iId, 4); break; - case 2: m_oControl->select_item_keyboard(l_iId, 1); break; - case 3: m_oControl->select_item_keyboard(l_iId, 2); break; + case 0: m_oMediator->select_item_keyboard(l_iId, 3); break; + case 1: m_oMediator->select_item_keyboard(l_iId, 4); break; + case 2: m_oMediator->select_item_keyboard(l_iId, 1); break; + case 3: m_oMediator->select_item_keyboard(l_iId, 2); break; default: break; } - if (m_oSelected.size()==1) ensureVisible(m_oSelected[0]); + if (sel.size()==1) ensureVisible(sel[0]); } void canvas_view::slot_add_item() { - //if (m_oSelected.size() != 1) return; - int l_iId = 0; - if (m_oSelected.size()==1) l_iId = m_oSelected[0]->Id(); + QList sel = selection(); + int l_iId = NO_ITEM; + if (sel.size() == 1) { + l_iId = sel[0]->Id(); + } + deselect_all(); - m_oControl->add_item(l_iId); - m_oControl->do_reorganize(); - if (m_oSelected.size() == 1) m_oSelected[0]->focus_in(); + mem_add *add = new mem_add(m_oMediator); + add->init(); + add->item->m_iXX = m_oLastPoint.x(); + add->item->m_iYY = m_oLastPoint.y(); + add->parent = l_iId; + add->apply(); + + reorganize(); // this was here before } void canvas_view::slot_add_sibling() { - if (m_oSelected.size() != 1) return; - int l_iId = m_oControl->parent_of(m_oSelected[0]->Id()); + QList sel = selection(); + if (sel.size() != 1) return; + int l_iId = m_oMediator->parent_of(sel[0]->Id()); if (l_iId == NO_ITEM) return; deselect_all(); - m_oControl->add_item(l_iId); - m_oControl->do_reorganize(); - if (m_oSelected.size() == 1) m_oSelected[0]->focus_in(); + mem_add *add = new mem_add(m_oMediator); + add->init(); + add->item->m_iXX = m_oLastPoint.x(); + add->item->m_iYY = m_oLastPoint.y(); + add->parent = l_iId; + add->apply(); + reorganize(); // this was here before } void canvas_view::slot_delete() { QList l_oLst; - foreach (QGraphicsItem *l_oItem, m_oSelected) - { - if (l_oItem->type() != gratype(7)) continue; - canvas_item *l_oR = (canvas_item*) l_oItem; - l_oLst.push_back(l_oR->Id()); + foreach (canvas_item *l_oItem, selection()) { + l_oLst.push_back(l_oItem->Id()); } - foreach (int i_i, l_oLst) - { - m_oControl->remove_item(i_i); + + if (l_oLst.isEmpty()) { + return; } - m_oControl->select_item(NO_ITEM); + + mem_sel *sel = new mem_sel(m_oMediator); + sel->unsel = l_oLst; + sel->apply(); + + mem_delete *del = new mem_delete(m_oMediator); + del->init(l_oLst); + del->apply(); } void canvas_view::show_sort(int i_iId, bool i_b) { int j=0; - for (int i=0; im_oLinks.size(); i++) + for (int i=0; im_oLinks.size(); i++) { - QPoint l_oP = m_oControl->m_oLinks.at(i); + QPoint l_oP = m_oMediator->m_oLinks.at(i); if (l_oP.x() == i_iId) { ++j; canvas_item *l_oRect = m_oItems.value(l_oP.y()); - QString l_sNum = QString::number(j); - if (l_sNum != l_oRect->m_sNum) + if (j != l_oRect->m_iNum) { - l_oRect->m_sNum = l_sNum; - l_oRect->m_oSort->update(); + l_oRect->m_iNum = j; } + l_oRect->m_oSort->update(); l_oRect->m_oSort->setVisible(i_b); } } @@ -268,66 +477,10 @@ void canvas_view::move_sel(int i_iX, int i_iY) { + QList sel = selection(); check_canvas_size(); - foreach (canvas_item *l_oItem, m_oSelected) { l_oItem->moveBy(i_iX, i_iY); } - foreach (canvas_item *l_oItem, m_oSelected) { l_oItem->update_links(); ensureVisible(l_oItem); } -} - -void canvas_view::set_mode(mode_type i_iMode) -{ - deselect_all(); - - switch (i_iMode) - { - case select_mode: - viewport()->setCursor(Qt::ArrowCursor); - break; - case link_mode: - viewport()->setCursor(Qt::CrossCursor); - break; - case sort_mode: - viewport()->setCursor(Qt::ArrowCursor); - break; - case scroll_mode: - viewport()->setCursor(Qt::OpenHandCursor); - break; - default: - break; - qDebug()<<"unknown mode"<hide(); - m_oRubberLine->hide(); -} - -void canvas_view::keyReleaseEvent(QKeyEvent *i_oEvent) -{ -#if 0 - if (m_oSelected.size() == 1) - { - m_oSelected[0]->keyReleaseEvent(i_oEvent); - return; - } - QApplication::sendEvent(scene(), i_oEvent); -#endif - i_oEvent->accept(); -} - -void canvas_view::keyPressEvent(QKeyEvent *i_oEvent) -{ - if (m_oSelected.size() == 1) - { - canvas_item * l_oItem = m_oSelected[0]; - if (l_oItem->m_bEdit && i_oEvent->type() == QEvent::KeyPress) - { - l_oItem->keyPressEvent(i_oEvent); - i_oEvent->accept(); - } - } + foreach (canvas_item *l_oItem, sel) { l_oItem->moveBy(i_iX, i_iY); } + foreach (canvas_item *l_oItem, sel) { l_oItem->update_links(); ensureVisible(l_oItem); } } void canvas_view::zoom_in() @@ -358,299 +511,147 @@ centerOn(l_o + mapToScene(viewport()->rect().center()) - mapToScene(i_oEvent->pos())); } -bool canvas_view::event(QEvent *i_oEvent) -{ - //qDebug()<<"event type "<type(); - if (i_oEvent->type() == QEvent::ToolTip) +void canvas_view::notify_open_map() { + QRect l_oRect = viewport()->rect(); + if (m_oItems.size() < 1) // no rectangle { - QHelpEvent *l_oEv = static_cast(i_oEvent); - QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(l_oEv->pos())); - if (l_oItem && l_oItem->type() == gratype(7)) - { - data_item *l_o = *m_oControl + ((canvas_item*) l_oItem)->Id(); - if (l_o && l_o->m_iTextLength > 1) - { - QToolTip::showText(l_oEv->globalPos(), l_o->m_sText); - } - } + scene()->setSceneRect(QRectF(mapToScene(l_oRect.topLeft()), mapToScene(l_oRect.bottomRight()))); + return; } - else if (i_oEvent->type() == QEvent::InputMethod) - { - if (m_oSelected.size() == 1) + + check_canvas_size(); + fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); +} + +void canvas_view::notify_select(const QList& unsel, const QList& sel) { + + edit_off(); + foreach (int k, sel) { + Q_ASSERT(m_oItems[k] != NULL); + if (!m_oItems[k]->isSelected()) { - canvas_item * l_oItem = m_oSelected[0]; - if (l_oItem->m_bEdit) - { - l_oItem->inputMethodEvent((QInputMethodEvent*) i_oEvent); - } + m_oItems[k]->setSelected(true); } } - else if (i_oEvent->type() == QEvent::KeyPress - || i_oEvent->type() == QEvent::ShortcutOverride - || i_oEvent->type() == QEvent::Shortcut) - { - if (m_oSelected.size() == 1 && m_oSelected[0]->m_bEdit) - { - QKeyEvent *l_o = (QKeyEvent*) i_oEvent; - if (m_oEditAction->shortcut().matches(l_o->key())) - { - //qDebug()<<"matches"<key(); - return QGraphicsView::event(i_oEvent); - } - keyPressEvent(l_o); - return true; + foreach (int k, unsel) { + Q_ASSERT(m_oItems[k] != NULL); + if (m_oItems[k]->isSelected()) + { + m_oItems[k]->setSelected(false); } } - return QGraphicsView::event(i_oEvent); -} -void canvas_view::focusOutEvent(QFocusEvent *i_oEv) -{ - foreach (canvas_item *l_oItem, m_oSelected) + if (m_iSortId != NO_ITEM) { - l_oItem->focus_out(i_oEv); + show_sort(m_iSortId, false); + m_iSortCursor = 0; + m_iSortId = NO_ITEM; } - foreach (QAction* l_o, actions()) + + if (sel.size() == 1 && true) // { - l_o->setEnabled(false); + m_iSortId = sel.at(0); + m_iSortCursor = 0; } - if (m_oMenu->isVisible()) enable_menu_actions(); } -/*! - * eow this actually works - */ -void canvas_view::synchro_doc(const hash_params& i_o) -{ - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) - { - case cmd_add_item: - { - int l_iId = i_o[data_id].toInt(); - Q_ASSERT(! m_oItems.contains(l_iId)); - - canvas_item*l_oR = new canvas_item(this, l_iId); - - l_oR->setSelected(true); - - QRectF l_oRect = l_oR->boundingRect(); - l_oR->setPos(m_oLastPoint - QPointF(l_oRect.width()/2, l_oRect.height()/2)); +void canvas_view::sync_colors() { + semantik_win *l_o = (semantik_win*) m_oSemantikWindow; + l_o->m_oColorsToolBar->clear(); - data_item *l_oData = *m_oControl + l_iId; - l_oData->m_iXX = l_oR->pos().x(); - l_oData->m_iYY = l_oR->pos().y(); + while (l_o->m_oColorGroup->actions().size() > m_oMediator->m_oColorSchemes.size()+1) + { + QAction* l_oA = l_o->m_oColorGroup->actions().takeFirst(); + l_o->m_oColorsToolBar->removeAction(l_oA); + m_oColorMenu->removeAction(l_oA); + delete l_oA; + } - m_oItems[l_iId] = l_oR; - } - break; - case cmd_update_item: - { - if (i_o[data_orig].toInt() == view_canvas) return; - int j = i_o[data_id].toInt(); - m_oItems.value(j)->update_data(); - m_oItems.value(j)->update(); - } - break; - case cmd_select_item: - { - if (i_o[data_orig].toInt() == view_canvas) - { - check_selected(); - return; - } - int l_iId = i_o[data_id].toInt(); - if (l_iId == NO_ITEM) - { - deselect_all(false); - } - else if (m_oSelected.size() == 1) - { - if (m_oSelected[0]->Id() != l_iId) - { - rm_select(m_oSelected[0], false); - add_select(m_oItems.value(l_iId), false); - } - } - else - { - add_select(m_oItems.value(l_iId), false); - } - check_selected(); - } - break; - case cmd_link: - { - canvas_item *l_oR1 = m_oItems.value(i_o[data_id].toInt()); - canvas_item *l_oR2 = m_oItems.value(i_o[data_parent].toInt()); - canvas_link * l_oLink = new canvas_link(this, l_oR2, l_oR1); - l_oLink->update_pos(); - l_oR1->update(); - } - break; - case cmd_unlink: - { - canvas_item *l_oR1 = m_oItems.value(i_o[data_id1].toInt()); - canvas_item *l_oR2 = m_oItems.value(i_o[data_id2].toInt()); + while (l_o->m_oColorGroup->actions().size() < m_oMediator->m_oColorSchemes.size()+1) + { + new QAction(QIcon(), trUtf8("Color"), l_o->m_oColorGroup); + } - foreach (QGraphicsItem *l_oItem, items()) - { - if (l_oItem->type() == gratype(17)) - { - canvas_link *l_oLink = (canvas_link*) l_oItem; - if ( - (l_oLink->m_oFrom == l_oR1 && l_oLink->m_oTo == l_oR2) - || - (l_oLink->m_oFrom == l_oR2 && l_oLink->m_oTo == l_oR1) - ) - { - l_oLink->hide(); - l_oLink->rm_link(); - delete l_oLink; - break; - } - } - } - l_oR1->update(); - l_oR2->update(); - } - break; - case cmd_remove_item: - { - int l_iId = i_o[data_id].toInt(); - canvas_item *l_oR1 = m_oItems.value(l_iId); + l_o->m_oColorGroup->removeAction(l_o->m_oCustomColorAct); + l_o->m_oColorGroup->addAction(l_o->m_oCustomColorAct); + m_oColorMenu->removeAction(l_o->m_oCustomColorAct); + m_oColorMenu->addAction(l_o->m_oCustomColorAct); - Q_ASSERT(l_oR1!=NULL); + for (int i=0; im_oColorSchemes.size(); ++i) + { + color_scheme l_oScheme = m_oMediator->m_oColorSchemes[i]; + QAction *l_oAction = l_o->m_oColorGroup->actions()[i]; - m_oSelected.removeAll(l_oR1); - m_oItems.remove(l_iId); + QPixmap l_oPix(22, 22); + QPainter l_oP(&l_oPix); - //l_oR1->hide(); - scene()->removeItem(l_oR1); - delete l_oR1; - } - break; - case cmd_sort_item: - { - show_sort(m_oSelected[0]->Id(), m_iMode == sort_mode); - } - break; - case cmd_save_data: - { - QList l_oList = m_oItems.values(); - foreach (canvas_item *l_oItem, l_oList) - { - data_item *l_oData = *m_oControl + l_oItem->Id(); - l_oData->m_iXX = l_oItem->pos().x(); - l_oData->m_iYY = l_oItem->pos().y(); - l_oData->m_iWW = l_oItem->boundingRect().width(); - l_oData->m_iHH = l_oItem->boundingRect().height(); - } - } - break; - case cmd_update_flags: - { - semantik_win *l_o = (semantik_win*) m_oSemantikWindow; - l_o->m_oFlagsToolBar->clear(); + l_oAction->setText(l_oScheme.m_sName); - while (l_o->m_oFlagGroup->actions().size() > m_oControl->m_oFlagSchemes.size()) - { - QAction* l_oA = l_o->m_oFlagGroup->actions().takeFirst(); - delete l_oA; - } + l_oPix.fill(l_oScheme.m_oInnerColor); + //TODO pen ? + l_oP.drawRect(0, 0, 21, 21); + l_oAction->setIcon(QIcon(l_oPix)); + } - while (l_o->m_oFlagGroup->actions().size() < m_oControl->m_oFlagSchemes.size()) - { - new QAction(QIcon(), trUtf8("Flag"), l_o->m_oFlagGroup); - } + // la première action est pour la couleur de la racine + for (int i=1; im_oColorGroup->actions().size(); ++i) + { + QAction *l_oAct = l_o->m_oColorGroup->actions()[i]; + l_o->m_oColorsToolBar->addAction(l_oAct); + m_oColorMenu->addAction(l_oAct); + } +} - for (int i=0; im_oFlagSchemes.size(); ++i) - { - flag_scheme* l_oScheme = m_oControl->m_oFlagSchemes[i]; - QAction *l_oAction = l_o->m_oFlagGroup->actions()[i]; +void canvas_view::notify_pic(int id) +{ + qDebug()<<"canvas_view::notify_pic to be implemented"; +} - l_oAction->setText(l_oScheme->m_sName); - l_oAction->setIcon(l_oScheme->_icon()); - } +void canvas_view::sync_flags() { + semantik_win *l_o = (semantik_win*) m_oSemantikWindow; + l_o->m_oFlagsToolBar->clear(); - foreach(QAction* l_oAct, l_o->m_oFlagGroup->actions()) - { - l_o->m_oFlagsToolBar->addAction(l_oAct); - l_oAct->setCheckable(true); - } - } - break; - case cmd_update_colors: - { - semantik_win *l_o = (semantik_win*) m_oSemantikWindow; - l_o->m_oColorsToolBar->clear(); + while (l_o->m_oFlagGroup->actions().size() > m_oMediator->m_oFlagSchemes.size()) + { + QAction* l_oA = l_o->m_oFlagGroup->actions().takeFirst(); + delete l_oA; + } - while (l_o->m_oColorGroup->actions().size() > m_oControl->m_oColorSchemes.size()+1) - { - QAction* l_oA = l_o->m_oColorGroup->actions().takeFirst(); - l_o->m_oColorsToolBar->removeAction(l_oA); - m_oColorMenu->removeAction(l_oA); - delete l_oA; - } + while (l_o->m_oFlagGroup->actions().size() < m_oMediator->m_oFlagSchemes.size()) + { + new QAction(QIcon(), trUtf8("Flag"), l_o->m_oFlagGroup); + } - while (l_o->m_oColorGroup->actions().size() < m_oControl->m_oColorSchemes.size()+1) - { - new QAction(QIcon(), trUtf8("Color"), l_o->m_oColorGroup); - } + for (int i=0; im_oFlagSchemes.size(); ++i) + { + flag_scheme* l_oScheme = m_oMediator->m_oFlagSchemes[i]; + QAction *l_oAction = l_o->m_oFlagGroup->actions()[i]; - l_o->m_oColorGroup->removeAction(l_o->m_oCustomColorAct); - l_o->m_oColorGroup->addAction(l_o->m_oCustomColorAct); - m_oColorMenu->removeAction(l_o->m_oCustomColorAct); - m_oColorMenu->addAction(l_o->m_oCustomColorAct); - - for (int i=0; im_oColorSchemes.size(); ++i) - { - color_scheme l_oScheme = m_oControl->m_oColorSchemes[i]; - QAction *l_oAction = l_o->m_oColorGroup->actions()[i]; - - QPixmap l_oPix(22, 22); - QPainter l_oP(&l_oPix); - - l_oAction->setText(l_oScheme.m_sName); - - l_oPix.fill(l_oScheme.m_oInnerColor); - //TODO pen ? - l_oP.drawRect(0, 0, 21, 21); - l_oAction->setIcon(QIcon(l_oPix)); - } + l_oAction->setText(l_oScheme->m_sName); + l_oAction->setIcon(l_oScheme->_icon()); + } - // la première action est pour la couleur de la racine - for (int i=1; im_oColorGroup->actions().size(); ++i) - { - QAction *l_oAct = l_o->m_oColorGroup->actions()[i]; - l_o->m_oColorsToolBar->addAction(l_oAct); - m_oColorMenu->addAction(l_oAct); - } - } - break; - case cmd_open_map: - { - check_canvas_size(); - fit_zoom(); - } - break; - default: - break; + foreach(QAction* l_oAct, l_o->m_oFlagGroup->actions()) + { + l_o->m_oFlagsToolBar->addAction(l_oAct); + l_oAct->setCheckable(true); } } void canvas_view::change_colors(QAction* i_oAct) { + if (! hasFocus()) return; + static QColor l_oColor; int l_iIdx = -1; semantik_win *l_o = (semantik_win*) m_oSemantikWindow; for (int i=1; im_oColorGroup->actions().size(); ++i) { - // attention hat trick, il y a une assignation - if (l_o->m_oColorGroup->actions()[i]==i_oAct && (l_iIdx = i)) + if (l_o->m_oColorGroup->actions()[i]==i_oAct) { + l_iIdx = i; if (i==l_o->m_oColorGroup->actions().size()-1) { l_oColor = QColorDialog::getColor(l_oColor, this); @@ -660,18 +661,9 @@ } } - for (int i=0; iId(); - data_item *l_oData = *m_oControl + l_oId; - l_oData->m_oCustom.m_oInnerColor = l_oColor; - l_oData->m_oCustom.m_oBorderColor = l_oColor.dark(); - l_oData->m_iXX = l_oItem->pos().x(); - l_oData->m_iYY = l_oItem->pos().y(); - l_oData->m_iColor = l_iIdx; - m_oControl->update_item(l_oId); - } + mem_color* col = new mem_color(m_oMediator); + col->newColor = l_iIdx; + col->apply(); } void canvas_view::change_flags(QAction* i_oAction) @@ -683,23 +675,30 @@ QAction *l_oAct = l_o->m_oFlagGroup->actions()[i]; if (l_oAct == i_oAction) l_iIndex = i; } - QString l_sName = m_oControl->m_oFlagSchemes[l_iIndex]->m_sId; - canvas_item *l_oItem = m_oSelected[0]; - data_item *l_oData = *m_oControl + m_oSelected[0]->Id(); + QString l_sName = m_oMediator->m_oFlagSchemes[l_iIndex]->m_sId; + + /* + canvas_item *l_oItem = selection()[0]; + data_item *l_oData = *m_oMediator + l_oItem->Id(); if (i_oAction->isChecked()) l_oData->m_oFlags.push_back(l_sName); else l_oData->m_oFlags.removeAll(l_sName); - l_oItem->update_flags(); + l_oItem->update_flags(); */ + + mem_flag* tmp = new mem_flag(m_oMediator); + tmp->flag = l_sName; + tmp->add = i_oAction->isChecked(); + tmp->apply(); } void canvas_view::check_selected() { + QList sel = selection(); semantik_win *l_o = (semantik_win*) m_oSemantikWindow; - bool l_bItemsAreSelected = (m_oSelected.size()==1); data_item *l_oData = NULL; - if (l_bItemsAreSelected) + if (sel.size() == 1) { - l_oData = *m_oControl + m_oSelected[0]->Id(); + l_oData = *m_oMediator + sel[0]->Id(); } //foreach(QAction* l_oAct, l_o->m_oFlagGroup->actions()) @@ -707,90 +706,32 @@ { QAction *l_oAct = l_o->m_oFlagGroup->actions()[i]; - if (!l_bItemsAreSelected) l_oAct->setChecked(false); + if (sel.size() != 1) l_oAct->setChecked(false); else { - QString l_sName = m_oControl->m_oFlagSchemes[i]->m_sId; + QString l_sName = m_oMediator->m_oFlagSchemes[i]->m_sId; l_oAct->setChecked(l_oData->m_oFlags.contains(l_sName)); } - l_oAct->setEnabled(l_bItemsAreSelected); + l_oAct->setEnabled(sel.size()); } - l_bItemsAreSelected = (m_oSelected.size()>=1); foreach(QAction* l_oAct, l_o->m_oColorGroup->actions()) { - l_oAct->setEnabled(l_bItemsAreSelected); + l_oAct->setEnabled(sel.size() >= 1); } } void canvas_view::deselect_all(bool i_oSignal) { - if (m_oSelected.size() == 1) - { - QFocusEvent l_oEv = QFocusEvent(QEvent::FocusOut); - m_oSelected[0]->focus_out(&l_oEv); - } - - foreach (canvas_item *l_oItem, m_oSelected) - { - l_oItem->set_selected(false); - l_oItem->setZValue(99); - if (m_iMode == sort_mode || m_iLastMode == sort_mode) - { - show_sort(l_oItem->Id(), false); - emit sig_message("", -1); - } - l_oItem->update(); - } - m_oSelected.clear(); - - notify_select(i_oSignal); -} - -void canvas_view::add_select(canvas_item* i_oItem, bool i_oSignal) -{ - Q_ASSERT(i_oItem != NULL); - - if (m_oSelected.size() == 1) + edit_off(); + mem_sel *sel = new mem_sel(m_oMediator); + if (sel->unsel.empty()) { - QFocusEvent l_oEv = QFocusEvent(QEvent::FocusOut); - m_oSelected[0]->focus_out(&l_oEv); + delete sel; } - - m_iSortCursor = 0; - m_oSelected.push_back(i_oItem); - i_oItem->set_selected(true); - i_oItem->setZValue(100); - if (m_iMode == sort_mode) + else { - show_sort(i_oItem->Id(), true); - emit sig_message(trUtf8("Click to set Item %1").arg(QString::number(m_iSortCursor+1)), -1); + sel->apply(); } - i_oItem->update(); - - notify_select(i_oSignal); -} - -void canvas_view::rm_select(canvas_item* i_oItem, bool i_oSignal) -{ - Q_ASSERT(i_oItem != NULL); - i_oItem->set_selected(false); - i_oItem->setZValue(99); - if (m_iMode == sort_mode) show_sort(i_oItem->Id(), false); - i_oItem->update(); - m_oSelected.removeAll(i_oItem); - - notify_select(i_oSignal); -} - -void canvas_view::notify_select(bool i_oSignal) -{ - enable_actions(); - - if (!i_oSignal) return; - if (m_oSelected.size()==1) - m_oControl->select_item(m_oSelected[0]->Id(), view_canvas); - else - m_oControl->select_item(NO_ITEM, view_canvas); } void canvas_view::enable_actions() @@ -804,338 +745,246 @@ void canvas_view::enable_menu_actions() { - m_oAddItemAction->setEnabled(m_oSelected.size()<=1); - m_oDeleteAction->setEnabled(m_oSelected.size()>0); - m_oEditAction->setEnabled(m_oSelected.size()==1); - m_oColorMenu->setEnabled(m_oSelected.size()>=1); - m_oDataMenu->setEnabled(m_oSelected.size()==1); + QList sel = selection(); + m_oAddItemAction->setEnabled(sel.size()<=1); + m_oDeleteAction->setEnabled(sel.size()>0); + //m_oEditAction->setEnabled(sel.size()==1); + m_oColorMenu->setEnabled(sel.size()>=1); + m_oDataMenu->setEnabled(sel.size()==1); + m_oSelectSubtreeAction->setEnabled(sel.size()==1); - if (m_oSelected.size() == 1) + if (sel.size() == 1) { - data_item *l_oData = *m_oControl + m_oSelected[0]->Id(); + data_item *l_oData = *m_oMediator + sel[0]->Id(); #define fafa(v, t) v->setChecked(l_oData->m_iDataType == t); - fafa(m_oTextType, view_text); - fafa(m_oDiagramType, view_diag); - fafa(m_oTableType, view_table); - fafa(m_oImageType, view_img); + fafa(m_oTextType, VIEW_TEXT); + fafa(m_oDiagramType, VIEW_DIAG); + fafa(m_oTableType, VIEW_TABLE); + fafa(m_oImageType, VIEW_IMG); } foreach (QAction* l_o, m_oDataMenu->actions()) { - l_o->setEnabled(m_oSelected.size()==1); + l_o->setEnabled(sel.size()==1); } } void canvas_view::mousePressEvent(QMouseEvent *i_oEv) { + if (i_oEv->button() == Qt::MidButton) { + m_bScroll = true; + setDragMode(QGraphicsView::ScrollHandDrag); + return; + } + + m_oLastPressPoint = i_oEv->pos(); if (i_oEv->button() == Qt::RightButton) { + // first, we cannot edit an item when right-click is selected + edit_off(); + // select the item under the cursor if available and show the popup menu m_oLastPoint = mapToScene(i_oEv->pos()); QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); - if (l_oItem && l_oItem->type() == gratype(7)) + if (l_oItem && l_oItem->type() == CANVAS_ITEM_T) { - if (!m_oSelected.contains((canvas_item*) l_oItem)) + if (!l_oItem->isSelected()) { - deselect_all(); - add_select((canvas_item*) l_oItem); + QList lst; + lst.append(((canvas_item*) l_oItem)->Id()); + + mem_sel *sel = new mem_sel(m_oMediator); + sel->sel = lst; + sel->apply(); } } else { deselect_all(); } + enable_menu_actions(); m_oMenu->popup(i_oEv->globalPos()); + i_oEv->accept(); return; } - if (i_oEv->button() == Qt::MidButton) - { - m_iLastMode = m_iMode; - m_iMode = scroll_mode; + QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); + QList sel = selection(); + if (sel.size() == 1 && QApplication::keyboardModifiers() & Qt::ShiftModifier) + { + // link items on click sequences + if (l_oItem && l_oItem->type() == CANVAS_ITEM_T) { + + int id1 = sel.at(0)->Id(); + int id2 = ((canvas_item*) l_oItem)->Id(); + m_oMediator->link_items(id1, id2); + + QList unlst; + unlst.append(id1); + QList lst; + lst.append(id2); + + mem_sel *sel = new mem_sel(m_oMediator); + sel->sel = lst; + sel->unsel = unlst; + sel->apply(); + return; + } } - canvas_item *l_oRect = NULL; - switch (m_iMode) + canvas_chain *kk=NULL; + if (l_oItem && (kk = dynamic_cast(l_oItem))) { - case select_mode: - { - m_oLastPressPoint = i_oEv->pos(); - m_oLastMovePoint = mapToScene(m_oLastPressPoint); - - - m_bPressed = (i_oEv->button() == Qt::LeftButton); - - QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); - if (m_bPressed) - { - if (l_oItem && l_oItem->type() == gratype(7)) - { - l_oRect = (canvas_item*) l_oItem; - } - else - { - l_oItem = NULL; - } - - if (l_oItem) - { - switch (i_oEv->modifiers()) - { - case Qt::ShiftModifier: - if (m_oSelected.contains(l_oRect)) - rm_select(l_oRect); - else - add_select(l_oRect); - break; - default: - if (!m_oSelected.contains(l_oRect)) - { - if (m_oSelected.size() == 1 && !m_oControl->parent_of(l_oRect->Id())) - { - if (QApplication::keyboardModifiers() & Qt::ControlModifier) - m_oControl->link_items(m_oSelected[0]->Id(), l_oRect->Id()); - } - deselect_all(); - add_select(l_oRect); - } - } - } - else - { - deselect_all(); - } - } - - } - break; - case link_mode: + QList lst; + foreach (QGraphicsItem *l_o, scene()->selectedItems()) + { + l_o->setSelected(false); + canvas_item *it = dynamic_cast(l_o); + if (it) { - m_oLastPressPoint = i_oEv->pos(); - m_bPressed = (i_oEv->button() == Qt::LeftButton); - - deselect_all(); - QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); - if (l_oItem && l_oItem->type() == gratype(7)) - { - l_oRect = (canvas_item*) l_oItem; - add_select(l_oRect); - } + lst.append(it->Id()); } - break; - case sort_mode: - { - QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); - if (l_oItem && l_oItem->type() == gratype(7)) - { - l_oRect = (canvas_item*) l_oItem; - deselect_all(); - add_select(l_oRect); - } - else if (l_oItem && l_oItem->type() == gratype(19)) - { - qDebug()<<"sort called"<m_oFrom->Id(); - l_oRect = l_oSort->m_oFrom; - - qDebug()<<"sort_children("<Id()<<" "<sort_children(m_oSelected[0]->Id(), l_iId, m_iSortCursor); - show_sort(m_oSelected[0]->Id(), true); + } - m_iSortCursor++; - if (m_iSortCursor >= m_oControl->num_children(m_oSelected[0]->Id())) - m_iSortCursor=0; + if (lst.size()) + { + mem_sel *sel = new mem_sel(m_oMediator); + sel->unsel = lst; + sel->apply(); + } - emit sig_message(trUtf8("Click to set Item %1").arg(QString::number(m_iSortCursor+1)), -1); - //qDebug(); - } - else - { - deselect_all(); - } - } - break; - case scroll_mode: - viewport()->setCursor(Qt::ClosedHandCursor); - m_oLastPressPoint = i_oEv->pos(); - m_bPressed = (i_oEv->button() == Qt::LeftButton || i_oEv->button() == Qt::MidButton); + canvas_item *l_oParent = dynamic_cast(kk->parentItem()); + Q_ASSERT(l_oParent); - if (m_bPressed) - { - deselect_all(); - QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); - if (l_oItem && l_oItem->type() == gratype(7)) - { - l_oRect = (canvas_item*) l_oItem; - add_select(l_oRect); - } - } + QRectF r = l_oParent->boundingRect().translated(l_oParent->pos()); + m_oLastPressPoint.setX(r.x() + r.width() / 2.); + m_oLastPressPoint.setY(r.y() + r.height() / 2.); + m_oLastPressPoint = mapFromScene(m_oLastPressPoint); + + QRect l_oSel = QRect(m_oLastPressPoint, i_oEv->pos()); + m_oRubberLine->setGeometry(l_oSel); - break; - default: - break; + m_oRubberLine->setVisible(true); + return; } + + canvas_sort *l_oSort = dynamic_cast(scene()->itemAt(mapToScene(i_oEv->pos()))); + if (l_oSort) + return; + canvas_sort_toggle *l_oToggle = dynamic_cast(l_oItem); + if (l_oToggle) + return; + QGraphicsView::mousePressEvent(i_oEv); } -void canvas_view::mouseMoveEvent(QMouseEvent *i_oEv) + +void canvas_view::mouseReleaseEvent(QMouseEvent *i_oEv) { - switch (m_iMode) + if (m_oRubberLine->isVisible()) { - case select_mode: - if (m_bPressed && m_oSelected.size() == 0) - { - bool c1 = ((m_oLastPressPoint - i_oEv->pos()).manhattanLength() >= QApplication::startDragDistance()); - if (m_oRubbery->isVisible() || c1) - { - QRect l_oSel = QRect(m_oLastPressPoint, i_oEv->pos()).normalized(); - m_oRubbery->setGeometry(l_oSel); - } + m_oRubberLine->setVisible(false); + canvas_item *l_oR1 = NULL; + canvas_item *l_oR2 = NULL; - if (c1) m_oRubbery->show(); - } - else if (m_bPressed) + foreach (QGraphicsItem *l_oI1, scene()->items(mapToScene(m_oLastPressPoint))) + { + if (l_oI1->type() == CANVAS_ITEM_T) { - // ugly, but it works - - QRectF l_oRect; - l_oRect.setTopLeft(m_oLastMovePoint); - m_oLastMovePoint = mapToScene(i_oEv->pos()); - l_oRect.setBottomRight(m_oLastMovePoint); - m_oControl->set_dirty(); - foreach (canvas_item *l_oItem, m_oSelected) - { - l_oItem->moveBy(l_oRect.width(), l_oRect.height()); - } - // FIXME - foreach (canvas_item *l_oItem, m_oSelected) - { - l_oItem->update_links(); - } - check_canvas_size(); + l_oR1 = (canvas_item*) l_oI1; + break; } - break; - case link_mode: - if (m_bPressed) - { - bool c1 = ((m_oLastPressPoint - i_oEv->pos()).manhattanLength() >= QApplication::startDragDistance()); - if (m_oRubberLine->isVisible() || c1) - { - QRect l_oSel = QRect(m_oLastPressPoint, i_oEv->pos()); - m_oRubberLine->setGeometry(l_oSel); - } + } - if (c1) - { - m_oRubberLine->show(); - } - } - break; - case sort_mode: - break; - case scroll_mode: - if (m_bPressed) + foreach (QGraphicsItem *l_oI1, scene()->items(mapToScene(i_oEv->pos()))) + { + if (l_oI1->type() == CANVAS_ITEM_T) { - QScrollBar *hBar = horizontalScrollBar(); - QScrollBar *vBar = verticalScrollBar(); + l_oR2 = (canvas_item*) l_oI1; + break; + } + } - QPoint delta = i_oEv->pos() - m_oLastPressPoint; + if (l_oR1 && l_oR2 && l_oR1 != l_oR2) + { + m_oMediator->link_items(l_oR1->Id(), l_oR2->Id()); + deselect_all(); // TODO + } + m_oRubberLine->hide(); + return; + } - hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x())); - vBar->setValue(vBar->value() - delta.y()); + if (m_bScroll) + { + m_bScroll = false; + setDragMode(QGraphicsView::RubberBandDrag); + } - m_oLastPressPoint = i_oEv->pos(); + QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); + canvas_sort *l_oSort = dynamic_cast(l_oItem); + if (l_oSort) + { + int l_iId = l_oSort->m_oFrom->Id(); + int l_iParentId = m_oMediator->parent_of(l_iId); - //viewport()->setCursor(Qt::ClosedHandCursor); - } - else - { - //viewport()->setCursor(Qt::OpenHandCursor); - } - default: - break; - } -} + mem_sort *srt = new mem_sort(m_oMediator); + srt->init(l_iParentId, l_iId, m_iSortCursor); + srt->apply(); -void canvas_view::mouseReleaseEvent(QMouseEvent *i_oEv) -{ - if (i_oEv->button() == Qt::RightButton) return; + m_iSortCursor++; + if (m_iSortCursor >= m_oMediator->num_children(l_iParentId)) + { + m_iSortCursor = 0; + } - if (m_iLastMode != no_mode) - { - m_iMode = m_iLastMode; - m_iLastMode = no_mode; - viewport()->setCursor(m_iMode==link_mode?Qt::CrossCursor:Qt::ArrowCursor); + emit sig_message(trUtf8("Click to set Item %1").arg(QString::number(m_iSortCursor+1)), -1); + return; } - switch (m_iMode) + canvas_sort_toggle *l_oToggle = dynamic_cast(l_oItem); + if (l_oToggle) { - case select_mode: - { - m_bPressed = false; - if (m_oRubbery->isVisible()) - { - m_oRubbery->hide(); - QRect l_oRect = m_oRubbery->geometry(); - QList l_oSel = scene()->items(QRectF(mapToScene(l_oRect.topLeft()), mapToScene(l_oRect.bottomRight()))); - - //ITA - - foreach (QGraphicsItem *l_oItem, l_oSel) - { - if (l_oItem->type() == gratype(7)) - { - add_select((canvas_item*) l_oItem); - } - } - } - } - break; - case link_mode: - { - m_bPressed = false; + //check_selection(); // TODO ITA + if (scene()->selectedItems().size() == 1) + { + canvas_item *it = static_cast(l_oToggle->parentItem()); + m_iSortId = it->Id(); + m_iSortCursor = 0; + show_sort(it->Id(), true); + } + return; + } + QGraphicsView::mouseReleaseEvent(i_oEv); - canvas_item *l_oR1 = NULL; - canvas_item *l_oR2 = NULL; + edit_off(); - foreach (QGraphicsItem *l_oI1, scene()->items(mapToScene(m_oLastPressPoint))) - { - if (l_oI1->type() == gratype(7)) - { - l_oR1 = (canvas_item*) l_oI1; - break; - } - } + if (i_oEv->button() == Qt::RightButton) return; + m_bPressed = false; - foreach (QGraphicsItem *l_oI1, scene()->items(mapToScene(i_oEv->pos()))) - { - if (l_oI1->type() == gratype(7)) - { - l_oR2 = (canvas_item*) l_oI1; - break; - } - } + check_selection(); - if (l_oR1 && l_oR2 && l_oR1 != l_oR2) - { - m_oControl->link_items(l_oR1->Id(), l_oR2->Id()); - deselect_all(); - } - m_oRubberLine->hide(); + //qDebug()<<"mouse release event!"; + QList lst; + foreach (QGraphicsItem* k, scene()->selectedItems()) { + canvas_item* t = (canvas_item*) k; + lst.append(t->Id()); + } + if (lst.size()) { + data_item *p = m_oMediator->m_oItems[lst[0]]; + canvas_item *v = m_oItems[lst[0]]; + if (qAbs(p->m_iXX - v->pos().x()) + qAbs(p->m_iYY - v->pos().y()) > 0.1) { + mem_move *mv = new mem_move(m_oMediator); + mv->sel = lst; + for (int i = 0; i < lst.size(); ++i) { + data_item *it = m_oMediator->m_oItems[lst[i]]; + mv->oldPos.append(QPointF(it->m_iXX, it->m_iYY)); + mv->newPos.append(m_oItems[lst[i]]->pos()); } - break; - case sort_mode: - break; - case scroll_mode: - viewport()->setCursor(Qt::OpenHandCursor); - m_bPressed = false; - break; - default: - break; + mv->apply(); + } // else { qDebug()<<"move too small"; } } + + check_canvas_size(); } void canvas_view::mouseDoubleClickEvent(QMouseEvent* i_oEv) @@ -1143,70 +992,42 @@ if (i_oEv->button() != Qt::LeftButton) return; m_oLastPoint = mapToScene(i_oEv->pos()); QGraphicsItem *l_oItem = itemAt(i_oEv->pos()); - int l_iAdded = NO_ITEM; - if (m_iMode == select_mode || m_iMode == link_mode) - { - if (l_oItem) - { - if (l_oItem->type() == gratype(7)) - { - deselect_all(); - canvas_item *l_oR = (canvas_item*) l_oItem; - l_oR->setSelected(false); - l_iAdded = m_oControl->add_item(l_oR->Id(), NO_ITEM, true); - if (m_oSelected.size() == 1) m_oSelected[0]->focus_in(); - check_canvas_size(); - } - else if (l_oItem->type() == gratype(17)) - { - canvas_link *l_oLink = (canvas_link*) l_oItem; - m_oControl->unlink_items(l_oLink->m_oTo->Id(), l_oLink->m_oFrom->Id()); - } - } - else if (i_oEv->modifiers() != Qt::ControlModifier) - { - l_iAdded = m_oControl->add_item(); - if (m_oSelected.size() == 1) m_oSelected[0]->focus_in(); + if (l_oItem) { + if (l_oItem->type() == CANVAS_ITEM_T) { + deselect_all(); + + canvas_item *l_oR = (canvas_item*) l_oItem; + l_oR->setSelected(false); + + mem_add *add = new mem_add(m_oMediator); + add->init(); + add->item->m_iXX = m_oLastPoint.x(); + add->item->m_iYY = m_oLastPoint.y(); + add->parent = l_oR->Id(); + add->apply(); + } else if (l_oItem->type() == CANVAS_LINK_T) { + canvas_link *l_oLink = (canvas_link*) l_oItem; + mem_unlink *link = new mem_unlink(m_oMediator); + link->child = l_oLink->m_oTo->Id(); + link->parent = l_oLink->m_oFrom->Id(); + link->apply(); } + } else if (i_oEv->modifiers() != Qt::ControlModifier) { + mem_add *add = new mem_add(m_oMediator); + add->init(); + add->item->m_iXX = m_oLastPoint.x(); + add->item->m_iYY = m_oLastPoint.y(); + add->apply(); } } -qreal _min(qreal a, qreal b) { if (arect() was a bad idea - QRect l_oRect = viewport()->rect(); - if (m_oItems.size() < 1) // no rectangle - { - scene()->setSceneRect(QRectF(mapToScene(l_oRect.topLeft()), mapToScene(l_oRect.bottomRight()))); - return; - } - - QRectF l_oR2; - - qreal x, y, z, t; - canvas_item *l_o = m_oItems.values()[0]; - - x = z = l_o->x() + l_o->rect().width()/2; - y = t = l_o->y() + l_o->rect().height()/2; - - QList l_oList = m_oItems.values(); - foreach (canvas_item *l_oItem, l_oList) - { - if (l_oItem->x() < x) x = l_oItem->x(); - if (l_oItem->y() < y) y = l_oItem->y(); - if (l_oItem->x2() > z) z = l_oItem->x2(); - if (l_oItem->y2() > t) t = l_oItem->y2(); - } - x -=100; y -= 100; z += 100, t += 100; - - l_oR2 = QRectF(QPointF(x, y), QPointF(z, t)); - l_oR2 = l_oR2.united(QRectF(mapToScene(l_oRect.topLeft()), mapToScene(l_oRect.bottomRight()))); - if (l_oR2 == sceneRect()) return; - scene()->setSceneRect(l_oR2); + QRectF br = scene()->itemsBoundingRect(); + br.adjust(-GAP, -GAP, GAP, GAP); + br = br.united(scene()->sceneRect()); + scene()->setSceneRect(br); } void canvas_view::fit_zoom() @@ -1224,14 +1045,12 @@ fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); } -void canvas_view::focusInEvent(QFocusEvent *i_oEv) -{ - enable_actions(); -} - void canvas_view::slot_change_data() { - m_oControl->change_data(m_oSelected[0]->Id(), ((QAction*) QObject::sender())->data().toInt()); + mem_datatype* t = new mem_datatype(m_oMediator); + t->newDataType = ((QAction*) QObject::sender())->data().toInt(); + if (t->sel != NULL && t->newDataType != t->oldDataType) t->apply(); + else delete(t); } void canvas_view::toggle_fullscreen() @@ -1280,5 +1099,441 @@ QRubberBand::setGeometry(i_o.normalized()); } +#define HSPACER 32. +#define WSPACER 32. + +double canvas_view::compute_height(QMap &map, QMap >&children, int id) { + double size = 0; + + QMap >::const_iterator it = children.find(id); + if (it != children.end()) { + QList tmp = it.value(); + size += (tmp.size() - 1) * HSPACER; + foreach (int k, tmp) { + size += compute_height(map, children, k); + } + } + + double tmp = m_oItems[id]->boundingRect().height(); + if (size < tmp) size = tmp; + + map[id] = size; + //qDebug()<<"size for"< &map, QMap >&children, int id, int level) { + double w = m_oItems[id]->boundingRect().width(); + QMap::iterator jt = map.find(level); + if (jt != map.end()) { + double val = jt.value(); + map[level] = val > w ? val : w; + } else { + map[level] = w; + } + + QMap >::iterator it = children.find(id); + if (it != children.end()) { + QList tmp = it.value(); + foreach (int sub, tmp) { + compute_width(map, children, sub, level+1); + } + } +} + +void canvas_view::reorganize() { + QList roots = m_oMediator->all_roots(); + QMap height; + + QMap > children; + + for (int i=0; i < m_oMediator->m_oLinks.size(); ++i) { + QPoint l_oP = m_oMediator->m_oLinks.at(i); + + QMap >::iterator it = children.find(l_oP.x()); + if (it != children.end()) { + it.value() << l_oP.y(); + } else { + QList tmp; + tmp << l_oP.y(); + children[l_oP.x()] = tmp; + } + } + + foreach (int k, roots) { + double ref = compute_height(height, children, k); + QMap >::iterator it = children.find(k); + if (it != children.end()) { + QList tmp = it.value(); + + ref -= (tmp.size() - 1) * HSPACER; + int mid = 0; + int max = 0; + int tot = 0; + double left_height = 0; + foreach (int sub, tmp) { + tot += height[sub]; + if (tot * (ref - tot) >= max) { + max = tot * (ref - tot); + mid = sub; + + left_height += height[sub] + HSPACER; + } else { + break; + } + } + + QMap width; + compute_width(width, children, k, 0); + + left_height -= HSPACER; + + int left = 1; + double acc_height = m_oItems[k]->y() + m_oItems[k]->boundingRect().height() / 2 - left_height / 2; + foreach (int sub, tmp) { + + // put the element in place, then recurse + + double y = acc_height + height[sub] / 2 - m_oItems[sub]->boundingRect().height() / 2; + if (left) { + double x = m_oItems[k]->x() + m_oItems[k]->boundingRect().width() - width[0] - WSPACER; + m_oItems[sub]->setPos(x - m_oItems[sub]->boundingRect().width(), y); + } else { + double x = m_oItems[k]->x() + width[0] + WSPACER; + m_oItems[sub]->setPos(x, y); + } + + acc_height += height[sub] + HSPACER; + + m_oItems[k]->update_links(); + pack(width, height, children, sub, 1, left); + + // now to the right + if (sub == mid) { + left = 0; + acc_height = m_oItems[k]->y() + m_oItems[k]->boundingRect().height() / 2 - (height[k] - left_height - HSPACER) / 2; + } + } + } + } +} + +void canvas_view::pack(QMap &width, QMap &height, QMap >&children, int id, int level, int left) { + QMap >::iterator it = children.find(id); + if (it != children.end()) { + QList tmp = it.value(); + double acc_height = m_oItems[id]->y() + m_oItems[id]->boundingRect().height() / 2 - height[id] / 2; + foreach (int sub, tmp) { + double y = acc_height + height[sub] / 2 - m_oItems[sub]->boundingRect().height()/2; + if (left) { + double x = m_oItems[id]->x() + m_oItems[id]->boundingRect().width() - width[0] - WSPACER; + m_oItems[sub]->setPos(x - m_oItems[sub]->boundingRect().width(), y); + } else { + double x = m_oItems[id]->x() + width[0] + WSPACER; + m_oItems[sub]->setPos(x, y); + } + acc_height += height[sub] + HSPACER; + pack(width, height, children, sub, level+1, left); + } + m_oItems[id]->update_links(); + } +} + +void canvas_view::export_map_size() +{ + QRectF l_oRect = scene()->itemsBoundingRect(); + l_oRect = QRectF(l_oRect.topLeft() - QPointF(25, 25), l_oRect.bottomRight() + QPointF(25, 25)); + + export_map_dialog* exp = new export_map_dialog(this); + + exp->kurlrequester->setMode(KFile::File | KFile::LocalOnly); + exp->kurlrequester->setFilter(trUtf8("*.png|PNG Files (*.png)")); + + exp->kurlrequester->setUrl(KUrl(m_oMediator->m_sExportUrl)); + exp->m_oWidthC->setChecked(m_oMediator->m_bExportIsWidth); + exp->m_iBaseWidth = l_oRect.width(); + exp->m_iBaseHeight = l_oRect.height(); + + if (m_oMediator->m_bExportIsWidth) + { + if (m_oMediator->m_iExportWidth > 0) + exp->m_oWidth->setValue(m_oMediator->m_iExportWidth); + else + exp->m_oWidth->setValue(l_oRect.width()); + } + else + { + if (m_oMediator->m_iExportHeight > 0) + exp->m_oHeight->setValue(m_oMediator->m_iExportHeight); + else + exp->m_oHeight->setValue(l_oRect.height()); + } + + if (exp->exec() == KDialog::Accepted) + { + if (m_oMediator->m_iExportWidth != exp->m_oWidth->value()) + { + m_oMediator->m_iExportWidth = exp->m_oWidth->value(); + m_oMediator->set_dirty(); + } + + if (m_oMediator->m_iExportHeight != exp->m_oHeight->value()) + { + m_oMediator->m_iExportHeight = exp->m_oHeight->value(); + m_oMediator->set_dirty(); + } + + if (!exp->kurlrequester->url().isValid() || exp->kurlrequester->url().isEmpty()) + { + m_oMediator->notify_message(trUtf8("No destination file selected"), 5000); + return; + } + + if (m_oMediator->m_sExportUrl != exp->kurlrequester->url().url()) + { + m_oMediator->m_sExportUrl = exp->kurlrequester->url().url(); + m_oMediator->set_dirty(); + } + + QImage l_oImage((int) l_oRect.width(), (int) l_oRect.height(), QImage::Format_RGB32); + if (exp->m_oWidthC->isChecked()) + { + l_oImage = l_oImage.scaledToWidth(exp->m_oWidth->value()); + } + else + { + l_oImage = l_oImage.scaledToHeight(exp->m_oHeight->value()); + } + l_oImage.fill(qRgb(255,255,255)); + + QPainter l_oP; + l_oP.begin(&l_oImage); + l_oP.setRenderHints(QPainter::Antialiasing); + scene()->render(&l_oP, l_oImage.rect(), l_oRect); + l_oP.end(); + + // TODO upload remote files + QString path = exp->kurlrequester->url().toLocalFile(); + if (exp->kurlrequester->url().isRelative()) + { + path = QDir::homePath() + notr("/") + path; + } + bool isOk = l_oImage.save(path); + if (isOk) + m_oMediator->notify_message(trUtf8("Exported '%1'").arg(path), 2000); + else + KMessageBox::sorry(this, trUtf8("Could not save to %1").arg(path), trUtf8("Missing picture")); + } +} + +void canvas_view::notify_export_doc() +{ + QRectF l_oRect = scene()->itemsBoundingRect(); + l_oRect = QRectF(l_oRect.topLeft() - QPointF(25, 25), l_oRect.bottomRight() + QPointF(25, 25)); + QRectF l_oR(0, 0, l_oRect.width(), l_oRect.height()); + + // fill with white + QImage l_oImage((int) l_oR.width(), (int) l_oR.height(), QImage::Format_RGB32); + l_oImage.fill(qRgb(255,255,255)); + + QPainter l_oP; + l_oP.begin(&l_oImage); + l_oP.setRenderHints(QPainter::Antialiasing); + scene()->render(&l_oP, l_oR, l_oRect); + l_oP.end(); + + l_oImage.save(QString(m_oMediator->m_sTempDir + QString("/wholemap.png"))); +} + +QList canvas_view::selection() { + // FIXME use scene()->selectedItems() + QList ret; + + foreach (QGraphicsItem *tmp, items()) { + if (tmp->type() == CANVAS_ITEM_T && tmp->isSelected()) { + ret.append((canvas_item*) tmp); + } + } + return ret; +} + +void canvas_view::mouseMoveEvent(QMouseEvent *i_oEv) +{ + if (m_oRubberLine->isVisible()) + { + QRect l_oSel = QRect(m_oLastPressPoint, i_oEv->pos()); + m_oRubberLine->setGeometry(l_oSel); + } + + if (m_bScroll) + { + QScrollBar *h = horizontalScrollBar(); + QScrollBar *v = verticalScrollBar(); + QPoint d = i_oEv->pos() - m_oLastPressPoint; + h->setValue(h->value() - d.x()); + v->setValue(v->value() - d.y()); + m_oLastPressPoint = i_oEv->pos(); + //QGraphicsView::mouseMoveEvent(i_oEv); + return; + } + + + QGraphicsView::mouseMoveEvent(i_oEv); + + QList sel = scene()->selectedItems(); + if (sel.size() > 4) { // does not solve the repainting problem + QSet lst; + foreach (QGraphicsItem*tmp, sel) { + if (tmp->type() == CANVAS_ITEM_T && tmp->isSelected()) { + canvas_item* x = (canvas_item*) tmp; + foreach (canvas_link* l_oLink, x->m_oLinks) { + lst.insert(l_oLink); + } + } + } + foreach (canvas_link* tmp, lst) { + tmp->update_pos(); + } + } else { + foreach (QGraphicsItem*tmp, sel) { + if (tmp->type() == CANVAS_ITEM_T && tmp->isSelected()) { + ((canvas_item*) tmp)->update_links(); + } + } + } +} + +void canvas_view::notify_add_item(int id) { + Q_ASSERT(! m_oItems.contains(id)); + canvas_item* l_oR = new canvas_item(this, id); + m_oItems[id] = l_oR; + l_oR->update_data(); + // do not call methods that create events here + + check_canvas_size(); +} + +void canvas_view::notify_change_data(int id) +{ + //canvas_item* l_oR = m_oItems.value(id); + //qDebug()<<"FIXME data has changed!!!"; +} + +void canvas_view::notify_delete_item(int id) { + m_bDeleting = true; + canvas_item *l_oR1 = m_oItems.value(id); + Q_ASSERT(l_oR1!=NULL); + scene()->removeItem(l_oR1); + m_oItems.remove(id); + delete l_oR1; + m_bDeleting = false; + + check_canvas_size(); +} + +void canvas_view::notify_link_items(int id1, int id2) { + canvas_item *l_oR1 = m_oItems.value(id1); + canvas_item *l_oR2 = m_oItems.value(id2); + canvas_link * l_oLink = new canvas_link(this, l_oR1, l_oR2); + l_oLink->update_pos(); + l_oR2->update(); +} + +void canvas_view::notify_unlink_items(int id1, int id2) { + canvas_item *l_oR1 = m_oItems.value(id1); + canvas_item *l_oR2 = m_oItems.value(id2); + + foreach (QGraphicsItem *l_oItem, items()) + { + if (l_oItem->type() == CANVAS_LINK_T) + { + canvas_link *l_oLink = (canvas_link*) l_oItem; + if ( + (l_oLink->m_oFrom == l_oR1 && l_oLink->m_oTo == l_oR2) + || + (l_oLink->m_oFrom == l_oR2 && l_oLink->m_oTo == l_oR1) + ) + { + l_oLink->hide(); + l_oLink->rm_link(); + delete l_oLink; + break; + } + } + } + l_oR1->update(); + l_oR2->update(); +} + +void canvas_view::notify_move(const QList&sel, const QList&pos) { + for (int i = 0; i < sel.size(); ++i) { + m_oItems[sel[i]]->setPos(pos[i]); + m_oItems[sel[i]]->update_links(); + } +} + +void canvas_view::notify_repaint(int id) { + m_oItems[id]->update(); +} + +void canvas_view::notify_edit(int id) { + data_item *sel = *m_oMediator + id; + if (m_oItems[id]->toPlainText() != sel->m_sSummary) { + m_oItems[id]->setPlainText(sel->m_sSummary); + m_oItems[id]->adjustSize(); + m_oItems[id]->update_links(); + } + m_oItems[id]->update(); +} + +void canvas_view::notify_flag(int id) { + m_oItems[id]->update_flags(); +} + +void canvas_view::notify_sort(int id) { + show_sort(id, true); // TODO ITA +} + +void canvas_view::notify_focus(void* ptr) +{ + bool cond = ptr == this; + m_oAddItemAction->setEnabled(cond); + m_oDeleteAction->setEnabled(cond); + m_oEditAction->setEnabled(cond); +} + +void canvas_view::focusInEvent(QFocusEvent *i_oEv) +{ + QGraphicsView::focusInEvent(i_oEv); + m_oMediator->notify_focus(this); +} + +void canvas_view::focusOutEvent(QFocusEvent *i_oEv) +{ + QGraphicsView::focusOutEvent(i_oEv); + edit_off(); +} + %: include "canvas_view.moc" + +void recurse_add(int id, QList& sel, const QList& m_oLinks) +{ + sel.append(id); + for (int i=0; i < m_oLinks.size(); i++) + { + QPoint l_oP = m_oLinks.at(i); + if (l_oP.x() == id) recurse_add(l_oP.y(), sel, m_oLinks); + } +} + +void canvas_view::slot_select_subtree() +{ + QList seli = selection(); + Q_ASSERT(seli.size() == 1); + + mem_sel *sel = new mem_sel(m_oMediator); + recurse_add(seli.at(0)->m_iId, sel->sel, m_oMediator->m_oLinks); + sel->apply(); +} + diff -Nru semantik-0.7.3/src/canvas_view.h semantik-0.8.3/src/canvas_view.h --- semantik-0.7.3/src/canvas_view.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/canvas_view.h 2012-10-21 10:09:17.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef CANVAS_VIEW_H #define CANVAS_VIEW_H @@ -14,29 +14,18 @@ class QMenu; class canvas_link; -class data_control; +class sem_mediator; class canvas_item; class rubber_line; class canvas_view : public QGraphicsView { Q_OBJECT public: - canvas_view(QWidget *i_oWidget, data_control* i_oControl); + canvas_view(QWidget *i_oWidget, sem_mediator* i_oControl); void item_moved(); QMap m_oItems; - enum mode_type - { - no_mode = 0, - select_mode = 1, - link_mode = 2, - sort_mode = 3, - scroll_mode = 4, - }; - - void set_mode(mode_type i_o); - QMenu* m_oMenu; QMenu* m_oColorMenu; QMenu* m_oDataMenu; @@ -45,20 +34,21 @@ QAction* m_oTextType, *m_oDiagramType, *m_oTableType, *m_oImageType; - mode_type m_iMode; + bool m_bDeleting; + + void focusInEvent(QFocusEvent *); + void focusOutEvent(QFocusEvent *); - void keyPressEvent(QKeyEvent *i_oEvent); - void keyReleaseEvent(QKeyEvent *i_oEvent); - void focusOutEvent(QFocusEvent *i_oEv); void wheelEvent(QWheelEvent *i_oEvent); void mouseDoubleClickEvent(QMouseEvent *i_oEv); void mousePressEvent(QMouseEvent *i_oEv); void mouseMoveEvent(QMouseEvent *i_oEv); void mouseReleaseEvent(QMouseEvent *i_oEv); - void focusInEvent(QFocusEvent *i_oEv); bool m_bPressed; + bool m_bScroll; + QPoint m_oLastPressPoint; QPointF m_oLastMovePoint; @@ -66,61 +56,95 @@ QRubberBand* m_oRubbery; rubber_line * m_oRubberLine; - QList m_oSelected; + QList selection(); void deselect_all(bool i_oSignal=true); void show_sort(int i_iId, bool i_b); - void add_select(canvas_item*, bool i_oSignal=true); - void rm_select(canvas_item*, bool i_oSignal=true); - void notify_select(bool i_oSignal=true); void enable_menu_actions(); // like check_actions, but only for the popup menu + double compute_height(QMap &map, QMap >&children, int id); + void compute_width(QMap &map, QMap >&children, int id, int level); + void pack(QMap &width, QMap &height, QMap >&children, int id, int level, int left); - //protected: void check_selected(); + void edit_off(); // if the editing was on, turn it off //void scaleView(qreal i_oScaleFactor); - data_control *m_oControl; + sem_mediator *m_oMediator; QVector m_oRect; QPointF m_oLastPoint; int m_iSortCursor; + int m_iSortId; void move_sel(int i_iX, int i_iY); - mode_type m_iLastMode; - void check_canvas_size(); - bool event(QEvent *i_oEvent); - void enable_all(bool); QAction *m_oAddItemAction; QAction *m_oEditAction; + QAction *m_oCancelEditAction; QAction *m_oDeleteAction; + QAction *m_oMoveUpAction; + QAction *m_oMoveDownAction; + QAction *m_oMoveLeftAction; + QAction *m_oMoveRightAction; + QAction *m_oSelectUpAction; + QAction *m_oSelectDownAction; + QAction *m_oSelectLeftAction; + QAction *m_oSelectRightAction; + QAction *m_oSelectSubtreeAction; + + QAction *m_oInsertSiblingAction; + QAction *m_oNextRootAction; + public slots: - void synchro_doc(const hash_params&); + void export_map_size(); void change_colors(QAction*); void fit_zoom(); void change_flags(QAction*); - void slot_edit(); + void slot_toggle_edit(); + void slot_cancel_edit(); void slot_add_item(); void enable_actions(); // used on focus in void slot_add_sibling(); void slot_delete(); void slot_move(); void slot_sel(); - void slot_hop(); + void slot_next_root(); void zoom_in(); void zoom_out(); void toggle_fullscreen(); + void slot_select_subtree(); + + void notify_focus(void* ptr); + void notify_pic(int id); + void notify_add_item(int id); + void notify_delete_item(int id); + void notify_link_items(int id1, int id2); + void notify_unlink_items(int id1, int id2); + void notify_select(const QList& unsel, const QList& sel); + void notify_move(const QList&sel, const QList&pos); + void notify_repaint(int id); + void notify_edit(int id); + void notify_flag(int id); + void notify_sort(int id); + void notify_open_map(); + void notify_change_data(int id); + void notify_export_doc(); + void sync_flags(); + void sync_colors(); void slot_change_data(); + void reorganize(); + + void check_selection(); signals: void sig_message(const QString &, int); diff -Nru semantik-0.7.3/src/color_scheme.cpp semantik-0.8.3/src/color_scheme.cpp --- semantik-0.7.3/src/color_scheme.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/color_scheme.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include "color_scheme.h" diff -Nru semantik-0.7.3/src/color_scheme.h semantik-0.8.3/src/color_scheme.h --- semantik-0.7.3/src/color_scheme.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/color_scheme.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef COLOR_SCHEME_H #define COLOR_SCHEME_H diff -Nru semantik-0.7.3/src/con.h semantik-0.8.3/src/con.h --- semantik-0.7.3/src/con.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/con.h 2012-09-05 01:08:33.000000000 +0000 @@ -1,87 +1,23 @@ -// Thomas Nagy 2007-2009 GPLV3 - -#include +// Thomas Nagy 2007-2012 GPLV3 #ifndef CON #define CON -#define notr(x) QString(x) - -#define xp(a, b, d) a->setItem(b, 0, new QStandardItem(d)); -#define yp(a, b, d) a->setItem(b, 1, new QStandardItem(d)); - - -#define GRID_VALUE 10. -#define nof(x, y) ((int) ((y) * ((int) ((x) / (y))))) -#define int_val2(x) (nof(x, GRID_VALUE/2.)) -#define int_val(x) (nof(x, GRID_VALUE)) - -#define mu(x) #x - -#define fu(x, y) mu(x##y) - -#define min_offset 15 - - -#define NO_ITEM 0 -#define NO_VIEW 0 - -#define mix(x, y) {x^=y;y^=x;x^=y;} - - #define CONST const - -#ifdef Q_OS_DARWIN -#define _TAILLETABLE_ 300 -#define _NBRECT_ 500 -#define _RECTMAXSIZE_ 9999999 -#define _RATIO_GAP_ 10.0 -#define _R_ 120.0 -#define _D_ 4.0 -#define _ROWS_ 300 -#define _LONG_ "long" -#define _LARG_ "larg" -#define _POSX_ "posx" -#define _POSY_ "posy" -#define _ORI_ "ori" -#endif - -#define moc(x) fu(x, moc) - -#define gratype(x) (QGraphicsItem::UserType + x) - -#incl\ -ude \ -"aux.h" - +#include #include #include +#include -#define hash_params QHash - -qreal _min(qreal a, qreal b); -qreal _max(qreal a, qreal b); - -/* TODO: values hardcoded in some places */ - -#define cmd_add_item 0 -#define cmd_update_item 1 -#define data_root "/" -#define cmd_remove_item 2 -#define cmd_link 3 -#define cmd_unlink 4 -#define data_outdir "tmp" -#define cmd_select_item 5 -#define cmd_sort_item 6 -#define cmd_save_data 7 -#define cmd_update_colors 8 -#define cmd_update_flags 9 -#define cmd_open_map 10 -#define cmd_pre_view 11 -#define cmd_change_data 12 -#define cmd_export_item 13 - -#define NUM_RECENT cmd_open_map +#define gratype(x) (QGraphicsItem::UserType + x) +#define CANVAS_ITEM_T gratype(12301) +#define CANVAS_FLAG_T gratype(12302) +#define CANVAS_LINK_T gratype(12303) +#define CANVAS_SORT_T gratype(12304) +#define BOX_ITEM_T gratype(12305) +#define BOX_LINK_T gratype(12306) +#define CANVAS_CHAIN_T gratype(12307) +#define hash_params QHash #define data_parent 0 #define data_id 1 @@ -91,30 +27,46 @@ #define data_commande 5 #define data_type 6 // change the view stuff -#define view_canvas 1 -#define view_linear 2 -#define view_text 3 -#define view_img 4 -#define view_diag 5 -#define view_table 6 -#define EMPTY_TEXT "Empty" +#define VIEW_CANVAS 1 +#define VIEW_LINEAR 2 +#define VIEW_TEXT 3 +#define VIEW_IMG 4 +#define VIEW_DIAG 5 +#define VIEW_TABLE 6 + + +#define notr(x) QString(x) +#define xp(a, b, d) a->setItem(b, 0, new QStandardItem(d)); +#define yp(a, b, d) a->setItem(b, 1, new QStandardItem(d)); -#include -//#define trUtf8(x) QCoreApplication::translate(NULL, x) -#define fillloc(x) xp(x, 0, "exclude_pic"); yp(x, 0, trUtf8("exclude the picture")); xp(x, 1, "exclude_pic.html"); xp(x, 2, "exclude_pic.pdflatex"); xp(x, 3, "exclude_table"); yp(x, 3, trUtf8("exclude the table")); xp(x, 4, "exclude_table.html"); xp(x, 5, "exclude_table.pdflatex"); xp(x, 6, "make_slide.s5"); yp(x, 6, trUtf8("fit the item on one slide")); xp(x, 7, "piccaptionstyle.html"); yp(x, 7, trUtf8("picture caption")); xp(x, 8, "picdim.pdflatex"); yp(x, 8, trUtf8("picture dimension in pdf files")); xp(x, 9, "picdivstyle.html"); yp(x, 9, trUtf8("html div style: style=\"width: 99px;\"")); xp(x, 10, "picstyle.html"); yp(x, 10, trUtf8("html picture style: style=\"width: 99px;\"")); xp(x, 11, "skip_slide.s5"); yp(x, 11, trUtf8("do not use this item for generating slides")); +#define GRID 10 +#define nof(x, y) ((int) ((y) * ((int) ((x) / (y))))) +#define int_val2(x) (nof(x, GRID/2.)) +#define int_val(x) (nof(x, GRID)) + + +int grid_int(int x); + + + +#define mu(x) #x +#define fu(x, y) mu(x##y) +#define moc(x) fu(x, moc) -#define fillglo(x) xp(x, 0, "babel"); yp(x, 0, trUtf8("latex language: english (frenchb, )")); xp(x, 1, "babel.beamer"); xp(x, 2, "babel.pdflatex"); xp(x, 3, "command"); yp(x, 3, trUtf8("command to launch (%s is the resulting file)")); xp(x, 4, "command.beamer"); yp(x, 4, trUtf8("cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view")); xp(x, 5, "command.html"); yp(x, 5, trUtf8("firefox %s")); xp(x, 6, "command.odp"); yp(x, 6, trUtf8("ooimpress %s")); xp(x, 7, "command.odt"); yp(x, 7, trUtf8("oowriter %s")); xp(x, 8, "command.pdflatex"); yp(x, 8, trUtf8("cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view")); xp(x, 9, "command.s5"); yp(x, 9, trUtf8("firefox %s")); xp(x, 10, "doc_author"); yp(x, 10, trUtf8("document author")); xp(x, 11, "doc_author_off"); yp(x, 11, trUtf8("turn off the document author (latex)")); xp(x, 12, "doc_class"); yp(x, 12, trUtf8("document class (latex: a4, report, book)")); xp(x, 13, "doc_company"); yp(x, 13, trUtf8("company")); xp(x, 14, "doc_date"); yp(x, 14, trUtf8("document date")); xp(x, 15, "doc_date_off"); yp(x, 15, trUtf8("turn of the document date (latex)")); xp(x, 16, "doc_place"); yp(x, 16, trUtf8("location of the presentation")); xp(x, 17, "doc_title"); yp(x, 17, trUtf8("document title")); xp(x, 18, "doc_title_off"); yp(x, 18, trUtf8("turn off the document title (latex)")); xp(x, 19, "footer_c.pdflatex"); yp(x, 19, trUtf8("footer center (pdflatex)")); xp(x, 20, "footer_l.pdflatex"); yp(x, 20, trUtf8("footer left (pdflatex)")); xp(x, 21, "footer_off.pdflatex"); yp(x, 21, trUtf8("turn off the fancy output")); xp(x, 22, "footer_r.pdflatex"); yp(x, 22, trUtf8("footer right")); xp(x, 23, "header_c.pdflatex"); yp(x, 23, trUtf8("header center (pdflatex)")); xp(x, 24, "header_l.pdflatex"); yp(x, 24, trUtf8("header left")); xp(x, 25, "header_off.pdflatex"); xp(x, 26, "header_r.pdflatex"); yp(x, 26, trUtf8("header right")); xp(x, 27, "oolang"); yp(x, 27, trUtf8("openoffice.org language (fr_FR)")); xp(x, 28, "oolang.odp"); yp(x, 28, trUtf8("openoffice.org presentation language")); xp(x, 29, "oolang.odt"); yp(x, 29, trUtf8("openoffice.org text language")); xp(x, 30, "theme.beamer"); yp(x, 30, trUtf8("Warsaw (JuanLesPins, Montpellier, )")); +#define min_offset 15 +#define NO_ITEM 0 +#define NO_VIEW 0 -#define aegy do { while(1){} } while (0) +//#define EMPTY_TEXT "Empty" -//#define nono break -//while (1) { nono; } +//#define trUtf8(x) QCoreApplication::translate(NULL, x) +#incl\ +ude \ +"aux.h" -#define errmsg "im sorry dave, im afraid i cant do that" -/* end - con.h */ #endif diff -Nru semantik-0.7.3/src/config_dialog.cpp semantik-0.8.3/src/config_dialog.cpp --- semantik-0.7.3/src/config_dialog.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/config_dialog.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -1,12 +1,11 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include #include #include #include -#include -#include +#include #include #include #include @@ -24,59 +23,52 @@ #include "config_dialog.h" config_dialog::config_dialog(QWidget *i_oParent): - QDialog(i_oParent) + KDialog(i_oParent) { - QGridLayout *l_oGridLayout = new QGridLayout(this); + QWidget *widget = new QWidget(this); + setCaption(trUtf8("Document settings")); + setButtons(KDialog::Ok | KDialog::Cancel); + + QGridLayout *l_oGridLayout = new QGridLayout(widget); QLabel *l_sLabel; - l_sLabel = new QLabel(this); + l_sLabel = new QLabel(widget); l_sLabel->setText(trUtf8("Reorganization type")); l_oGridLayout->addWidget(l_sLabel, 0, 0, 1, 1); - l_sLabel = new QLabel(this); + l_sLabel = new QLabel(widget); l_sLabel->setText(trUtf8("Connection type")); l_oGridLayout->addWidget(l_sLabel, 1, 0, 1, 1); - l_sLabel = new QLabel(this); + l_sLabel = new QLabel(widget); l_sLabel->setText(trUtf8("Save document automatically")); l_oGridLayout->addWidget(l_sLabel, 2, 0, 1, 1); - l_sLabel = new QLabel(this); + l_sLabel = new QLabel(widget); l_sLabel->setText(trUtf8("Background color")); l_oGridLayout->addWidget(l_sLabel, 3, 0, 1, 1); - m_oReorgType = new QComboBox(this); + m_oReorgType = new QComboBox(widget); m_oReorgType->addItems(QStringList()<addWidget(m_oReorgType, 0, 1, 1, 1); - m_oConnType = new QComboBox(this); + m_oConnType = new QComboBox(widget); m_oConnType->addItems(QStringList()<addWidget(m_oConnType, 1, 1, 1, 1); - m_oAutoSave = new QSpinBox(this); + m_oAutoSave = new QSpinBox(widget); m_oAutoSave->setSuffix(trUtf8(" min")); m_oAutoSave->setRange(0, 69 /* 69 hmmm */); l_oGridLayout->addWidget(m_oAutoSave, 2, 1, 1, 1); m_oAutoSave->setToolTip(trUtf8("Interval in minutes for saving the document automatically, 0 for disabling this feature")); - m_oColorWidget = new QPushButton(); + m_oColorWidget = new QPushButton(widget); l_oGridLayout->addWidget(m_oColorWidget, 3, 1, 1, 1); connect(m_oColorWidget, SIGNAL(clicked()), this, SLOT(select_color())); - QSpacerItem *spacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - l_oGridLayout->addItem(spacerItem, 4, 1, 1, 1); - - - QDialogButtonBox *l_oButtonBox = new QDialogButtonBox(this); - l_oButtonBox->setOrientation(Qt::Horizontal); - l_oButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok); - - l_oGridLayout->addWidget(l_oButtonBox, 5, 0, 1, 2); - - connect(l_oButtonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(l_oButtonBox, SIGNAL(rejected()), this, SLOT(reject())); + setMainWidget(widget); QSize size(321, 120); size = size.expandedTo(minimumSizeHint()); @@ -95,3 +87,4 @@ } #include "config_dialog.moc" + diff -Nru semantik-0.7.3/src/config_dialog.h semantik-0.8.3/src/config_dialog.h --- semantik-0.7.3/src/config_dialog.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/config_dialog.h 2012-10-21 10:09:17.000000000 +0000 @@ -1,16 +1,16 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef CONFIG_DIALOG_H #define CONFIG_DIALOG_H -#include +#include #include class QComboBox; class QSpinBox; class QTreeWidgetItem; class QPushButton; -class config_dialog : public QDialog +class config_dialog : public KDialog { Q_OBJECT public: Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/src/data/hi128-app-semantik.png and /tmp/YNuC9JdPw2/semantik-0.8.3/src/data/hi128-app-semantik.png differ Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/src/data/hi22-app-semantik.png and /tmp/YNuC9JdPw2/semantik-0.8.3/src/data/hi22-app-semantik.png differ Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/src/data/hi32-app-semantik.png and /tmp/YNuC9JdPw2/semantik-0.8.3/src/data/hi32-app-semantik.png differ Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/src/data/hi48-app-semantik.png and /tmp/YNuC9JdPw2/semantik-0.8.3/src/data/hi48-app-semantik.png differ Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/src/data/hi64-app-semantik.png and /tmp/YNuC9JdPw2/semantik-0.8.3/src/data/hi64-app-semantik.png differ diff -Nru semantik-0.7.3/src/data/semantik.desktop semantik-0.8.3/src/data/semantik.desktop --- semantik-0.7.3/src/data/semantik.desktop 2009-08-30 11:35:32.000000000 +0000 +++ semantik-0.8.3/src/data/semantik.desktop 2012-08-26 23:18:49.000000000 +0000 @@ -1,6 +1,6 @@ [Desktop Entry] -Encoding=UTF-8 Name=Semantik +Exec=semantik GenericName=Mind mapping software GenericName[tr]=Zihin haritalama uygulaması Type=Application @@ -9,4 +9,4 @@ MimeType=application/x-semantik; X-KDE-StartupNotify=true X-DBUS-StartupType=Multi -Categories=Qt;KDE;Application;Office; +Categories=Qt;KDE;Office; diff -Nru semantik-0.7.3/src/data/semantik.svg semantik-0.8.3/src/data/semantik.svg --- semantik-0.7.3/src/data/semantik.svg 2009-08-30 11:35:32.000000000 +0000 +++ semantik-0.8.3/src/data/semantik.svg 2012-08-26 23:18:49.000000000 +0000 @@ -1,20 +1,21 @@ + + inkscape:version="0.48.2 r9819" + sodipodi:docname="semantik.svg" + version="1.1"> + inkscape:window-y="87" + showgrid="false" + inkscape:window-maximized="0" /> @@ -43,6 +46,7 @@ image/svg+xml + @@ -51,18 +55,18 @@ inkscape:groupmode="layer" id="layer1"> + width="214.41547" + height="310.43961" + x="425.33282" + y="751.46344" + inkscape:export-filename="/comp/semantik/src/data/hi48-app-semantik.png" + inkscape:export-xdpi="4.0617318" + inkscape:export-ydpi="4.0617318" /> + d="M 20.000004,55.219326 -526.30126,-382.08676 -92.794034,276.64939 -277.71897,-398.24649 -314.19966,389.49141 -67.113228,-265.20698 -559.64744,350.64356 25.071736,-33.784802 -735.38467,174.9444 -36.375603,207.62463 -774.28571,-70.49496 l 546.30126,437.30609 -433.50722,-658.73616 184.92493,674.89588 36.48069,-787.73789 -247.08643,654.69838 492.53421,-615.85053 L -779.35744,18.509168 -18.901031,-190.22003 -717.9101,-222.90027 z" + transform="matrix(1.3251449,-0.0618995,0.06505014,1.2609625,1031.8587,485.36816)" + inkscape:export-filename="/comp/semantik/src/data/hi48-app-semantik.png" + inkscape:export-xdpi="4.0617318" + inkscape:export-ydpi="4.0617318" /> diff -Nru semantik-0.7.3/src/data/semantikui.rc semantik-0.8.3/src/data/semantikui.rc --- semantik-0.7.3/src/data/semantikui.rc 2009-08-30 11:35:32.000000000 +0000 +++ semantik-0.8.3/src/data/semantikui.rc 2012-10-21 10:09:14.000000000 +0000 @@ -5,6 +5,8 @@ &File &Edit + + &View @@ -16,11 +18,6 @@ &Tools - - - - - &Settings @@ -40,18 +37,6 @@ - Main Toolbar - - - - - Modes Toolbar - - - - - - Colors Toolbar diff -Nru semantik-0.7.3/src/data/tips semantik-0.8.3/src/data/tips --- semantik-0.7.3/src/data/tips 2009-08-30 11:35:32.000000000 +0000 +++ semantik-0.8.3/src/data/tips 2012-08-26 23:18:49.000000000 +0000 @@ -2,12 +2,12 @@

1. Essential commands

    -
  • double click to add a concept
  • -
  • double click on a leaf or use the link mode to connect concepts
  • -
  • double click on a link to remove it
  • -
  • middle button + move to scroll on the map
  • -
  • scroll wheel for zooming
  • -
  • when a concept is selected, press enter to start editing it
  • +
  • Double click to add a concept
  • +
  • Double click on a leaf or use the link mode to connect concepts
  • +
  • Double click on a link to remove it
  • +
  • Middle button + move to scroll on the map
  • +
  • Scroll wheel for zooming
  • +
  • When a concept is selected, press enter to start editing it
  • Control+R to reorganize the map
  • Control+H to center the zoom
  • When a map is ready, use Ctrl+G to generate a document
  • @@ -46,9 +46,9 @@

    4. Data types

      -
    • right-click on a map item and set the data type
    • -
    • A graph may be created in the diagram panel
    • -
    • Pictures may be added in the image panel
    • +
    • Right-click on a map item and set the data type
    • +
    • Graphs can be created in the diagram panel
    • +
    • Pictures can be added in the image panel
    @@ -57,11 +57,27 @@

    5. Diagrams

      -
    • to connect diagram elements, maintain the control key pressed, select an item, and drag to the element to connect
    • -
    • right-click on a link to change the style
    • -
    • right-click on a box to change its color
    • +
    • To connect diagram elements, drag the pointer from one box to another while maintaining the shift key pressed
    • +
    • Right-click on a link or on a box to change the properties
    + + +

    6. LaTeX export

    +

    +Set all_latex=1 in the variables view to let the beamer and pdf templates use LaTeX commands. +

    + + + + +

    7. Diagram size

    +

    +The size of the diagrams exported can be tuned by specific values in the variables view:
    +diagram_width=200
    +diagram_height=500
    +

    +
    diff -Nru semantik-0.7.3/src/data_control.cpp semantik-0.8.3/src/data_control.cpp --- semantik-0.7.3/src/data_control.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/data_control.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1264 +0,0 @@ -// Thomas Nagy 2007-2009 GPLV3 - -#include - -%: include - #include -#include - #include - %: include - #include -#include -%:include\ - -#include - #include - #include -/* - */ #include - #include -#include -/* - */ %: include "con.h" - #include - #include "sembind.h" - #include "data_item.h" - %: include "data_control.h" - -class semantik_reader : public QXmlDefaultHandler -{ - public: - semantik_reader(data_control*); - - //private: - QString m_sBuf; - int m_iVersion; - data_control *m_oControl; - int m_iId; - - //public: - bool startElement(const QString&, const QString&, const QString&, const QXmlAttributes&); - bool endElement(const QString&, const QString&, const QString&); - bool characters(const QString &i_sStr); - -}; - -semantik_reader::semantik_reader(data_control *i_oControl) -{ - m_oControl = i_oControl; -} - -bool semantik_reader::startElement(const QString&, const QString&, const QString& i_sName, const QXmlAttributes& i_oAttrs) -{ - if (i_sName == notr("info")) - { - //m_oControl->m_sName = i_oAttrs.value("name"); - //m_oControl->m_sFirstName = i_oAttrs.value("fname"); - //m_oControl->m_sOrganization = i_oAttrs.value("organization"); - //m_oControl->m_sEmail = i_oAttrs.value("email"); - m_oControl->m_sHints = i_oAttrs.value(notr("hints")); - - if (i_oAttrs.value(notr("location")).size()) m_oControl->m_sOutDir = i_oAttrs.value(notr("location")); - if (i_oAttrs.value(notr("dir")).size()) m_oControl->m_sOutProject = i_oAttrs.value(notr("dir")); - if (i_oAttrs.value(notr("output")).size()) m_oControl->m_sOutTemplate = i_oAttrs.value(notr("output")); - } - else if (i_sName == notr("link")) - { - int a = i_oAttrs.value(notr("p")).toInt(); - int b = i_oAttrs.value(notr("v")).toInt(); - if (!m_oControl->m_oItems.contains(a)) return false; - if (!m_oControl->m_oItems.contains(b)) return false; - m_oControl->link_items(a, b); - } - else if (i_sName == notr("tblsettings")) - { - data_item *l_oItem = m_oControl->m_oItems.value(m_iId); - l_oItem->m_iNumRows = i_oAttrs.value(notr("rows")).toInt(); - l_oItem->m_iNumCols = i_oAttrs.value(notr("cols")).toInt(); - } - else if (i_sName == notr("tbl")) - { - data_item *l_oItem = m_oControl->m_oItems.value(m_iId); - data_table_item l_o; - l_o.m_iRow = i_oAttrs.value(notr("row")).toInt(); - l_o.m_iCol = i_oAttrs.value(notr("col")).toInt(); - l_o.m_sText = i_oAttrs.value(notr("text")); - l_oItem->m_oTableData.push_back(l_o); - } - else if (i_sName == notr("item")) - { - m_iId = i_oAttrs.value(notr("id")).toInt(); - if (m_iId <= NO_ITEM) return false; - - m_oControl->add_item(NO_ITEM, m_iId); - - data_item *l_oItem = m_oControl->m_oItems.value(m_iId); - l_oItem->m_sSummary = i_oAttrs.value(notr("summary")); - l_oItem->m_sText = i_oAttrs.value(notr("text")); - l_oItem->m_iTextLength = i_oAttrs.value(notr("len")).toInt(); - l_oItem->m_sComment = i_oAttrs.value(notr("comment")); - - l_oItem->m_sPicLocation = i_oAttrs.value(notr("pic_location")); - l_oItem->m_sPicCaption = i_oAttrs.value(notr("pic_caption")); - l_oItem->m_sPicComment = i_oAttrs.value(notr("pic_comment")); - - l_oItem->m_iDataType = i_oAttrs.value(notr("data")).toInt(); - if (l_oItem->m_iDataType == 0) l_oItem->m_iDataType = view_text; - - l_oItem->m_sHints = i_oAttrs.value(notr("hints")); - - l_oItem->m_iNumRows = i_oAttrs.value(notr("tbl_rows")).toInt(); - l_oItem->m_iNumCols = i_oAttrs.value(notr("tbl_cols")).toInt(); - - l_oItem->m_sDiag = i_oAttrs.value(notr("dg")); - - l_oItem->m_iXX = i_oAttrs.value(notr("c2")).toDouble(); - l_oItem->m_iYY = i_oAttrs.value(notr("c1")).toDouble(); - - l_oItem->m_iColor = i_oAttrs.value(notr("color")).toInt(); - l_oItem->m_oCustom.m_sName = i_oAttrs.value(notr("custom_name")); - l_oItem->m_oCustom.m_oInnerColor = QColor(i_oAttrs.value(notr("custom_inner"))); - l_oItem->m_oCustom.m_oBorderColor = QColor(i_oAttrs.value(notr("custom_border"))); - l_oItem->m_oCustom.m_oTextColor = QColor(i_oAttrs.value(notr("custom_text"))); - } - else if (i_sName == notr("color_schemes")) - { - m_oControl->m_oColorSchemes.clear(); - } - else if (i_sName == notr("color_scheme")) - { - color_scheme l_o; - l_o.m_sName = i_oAttrs.value(notr("name")); - l_o.m_oInnerColor = i_oAttrs.value(notr("inner")); - l_o.m_oBorderColor = i_oAttrs.value(notr("border")); - l_o.m_oTextColor = i_oAttrs.value(notr("text")); - m_oControl->m_oColorSchemes.push_back(l_o); - } - else if (i_sName == notr("flag")) - { - data_item *l_oItem = m_oControl->m_oItems.value(m_iId); - l_oItem->m_oFlags.push_back(i_oAttrs.value(notr("id"))); - } - return true; -} - -bool semantik_reader::endElement(const QString&, const QString&, const QString& i_sName) -{ - return true; -} - -bool semantik_reader::characters(const QString &i_s) -{ - m_sBuf += i_s; - return true; -} - -extern "C" { - void cleanup_pb(); void add_cstr(int, int); - void add_box(int, double, double, double, double); - void iterate_pb(int); double get_x(int); double get_y(int); - } - -data_control::~data_control() -{ - destroy_timer(); - clean_temp_dir(); - while (!m_oFlagSchemes.empty()) - { - delete m_oFlagSchemes.takeFirst(); - } -} - -void data_control::init_timer() -{ - destroy_timer(); - if (m_iTimerValue<1) return; - m_oTimer = new QTimer(this); - m_oTimer->setInterval(m_iTimerValue * 60000); - connect(m_oTimer, SIGNAL(timeout()), this, SLOT(slot_autosave())); - m_oTimer->start(); -} - -void data_control::destroy_timer() -{ - if (m_oTimer) m_oTimer->stop(); - delete m_oTimer; - m_oTimer = NULL; -} - -void data_control::slot_autosave() -{ - m_oLock.lock(); - // autosave for the last used save name - qDebug()<<"autosave"< 1) - { - QString o = trUtf8("Automatic save failed for file: %1").arg(m_sLastSaved); - if (save_file(m_sLastSaved)) - { - o = trUtf8("%1 saved automatically").arg(m_sLastSaved); - } - emit sig_message(o, 5000); - } - m_oLock.unlock(); -} - -void data_control::init_colors() -{ - m_oColorSchemes.clear(); - - QStringList l_oS; - //l_oS<<"#FFFCD5"<<"#ABFBC7"<<"#FDE1E1"<<"#D2F1FF"<<"#EDDFFF"<<"#FFFFFF"; - l_oS<<"#fffe8d"<<"#91ffab"<<"#9bfffe"<<"#b8bbff"<<"#e0aaff"<<"#ffa6a6"<<"#ffd8a6"<<"#FFFFFF"<<"#d3d7cf"; - - int i = 0; - foreach (QString l_s, l_oS) - { - color_scheme l_o; - l_o.m_oInnerColor = QColor(l_s); - l_o.m_sName = trUtf8("Color %1").arg(QString::number(i)); - m_oColorSchemes.push_back(l_o); - ++i; - } - - KConfigGroup l_oSettings(KGlobal::config(), notr("General Options")); - m_iConnType = l_oSettings.readEntry(notr("conn"), 0); - m_iReorgType = l_oSettings.readEntry(notr("reorg"), 0); - m_dTriSize = l_oSettings.readEntry(notr("trisize"), (double) 4.5); - m_iTimerValue = l_oSettings.readEntry(notr("auto"), 0); - - init_timer(); - - hash_params l_oCmd; - l_oCmd.insert(data_commande, QVariant(cmd_update_colors)); - emit synchro(l_oCmd); -} - -void data_control::init_flags() -{ - while (!m_oFlagSchemes.empty()) - { - delete m_oFlagSchemes.takeFirst(); - } - - QStringList l_oLst = QString(notr("flag_delay flag_idea flag_look flag_lunch flag_money flag_ok flag_people flag_phone flag_star flag_stop flag_talk flag_target flag_time flag_tune flag_unknown flag_write")).split(" "); - foreach (QString l_s, l_oLst) - { - m_oFlagSchemes.push_back(new flag_scheme(this, l_s, l_s)); - } - - hash_params l_oCmd; - l_oCmd.insert(data_commande, QVariant(cmd_update_flags)); - emit synchro(l_oCmd); -} - -void data_control::init_temp_dir() -{ - char sfn[16] = ""; - strcpy(sfn, "/tmp/sem.XXXXXX"); - char * l_oRet = mkdtemp(sfn); - m_sTempDir = l_oRet; - - Q_ASSERT(l_oRet!=NULL); - Q_ASSERT(QFile::exists(m_sTempDir)); -} - -void data_control::clean_temp_dir() -{ - //qDebug()<<"data_control::clean_temp_dir"; - QProcess l_oP; - QStringList l_oArgs; - l_oArgs<m_iXX + l_oData->m_iWW/2, - (double) l_oData->m_iYY + l_oData->m_iHH/2, - (double) l_oData->m_iWW/2, (double) l_oData->m_iHH/2); - } - for (int i=0; im_iXX = get_x(l_iVal) - l_oData->m_iWW/2; - l_oData->m_iYY = get_y(l_iVal) - l_oData->m_iHH/2; - update_item(l_iVal); - } - cleanup_pb(); - - hash_params l_oCmd2; - l_oCmd2.insert(data_commande, QVariant(cmd_open_map)); - emit synchro(l_oCmd2); -} - -QString data_control::doc_to_xml() -{ - QStringList l_oS; - - l_oS<\n"); - l_oS<\n"); - l_oS<\n"); - - l_oS<\n"); - foreach (color_scheme l_o, m_oColorSchemes) - { - l_oS<\n").arg( - l_o.m_sName, - l_o.m_oInnerColor.name(), - l_o.m_oBorderColor.name(), - l_o.m_oTextColor.name() - ); - } - l_oS<\n"); - - - QList l_oLst = m_oItems.values(); - for (int i=0; im_iId)); - l_oS<m_sSummary)); - l_oS<m_sText)); - l_oS<m_iTextLength)); - l_oS<m_sComment)); - - l_oS<m_sPicLocation)); - l_oS<m_sPicCaption)); - l_oS<m_sPicComment)); - - l_oS<m_iNumRows)); - l_oS<m_iNumCols)); - - l_oS<m_sDiag)); - - l_oS<m_sHints)); - l_oS<m_iDataType)); - - l_oS<m_iYY)); - l_oS<m_iXX)); - - l_oS<m_iColor)); - - color_scheme l_o = l_oItem->m_oCustom; - - l_oS<\n"); - - l_oS<\n").arg( - QString::number(l_oItem->m_iNumRows), QString::number(l_oItem->m_iNumCols)); - foreach (data_table_item l_o, l_oItem->m_oTableData) - { - l_oS<\n"); - } - - foreach (QString l_s, l_oItem->m_oFlags) - { - l_oS<\n").arg(bind_node::protectXML(l_s)); - } - - l_oS<\n"); - } - - for (int i=0; i\n").arg(l_oP.x()).arg(l_oP.y()); - } - - l_oS<\n"); - - return l_oS.join(""); -} - -bool data_control::save_file(QString i_sUrl) -{ - Q_ASSERT(i_sUrl.endsWith(".sem")); - - hash_params l_oCmd; - l_oCmd.insert(data_commande, QVariant(cmd_save_data)); - emit synchro(l_oCmd); - - QFile l_o2(QString(TEMPLATE_DIR)+notr("/semantik.sem.py")); - if (!l_o2.open(QIODevice::ReadOnly)) - { - emit sig_message(trUtf8("File saving: missing file %1").arg(l_o2.fileName()), 5000); - return false; - } - - QByteArray l_oBa = l_o2.readAll(); - l_o2.close(); - - bind_node::set_var(notr("temp_dir"), m_sTempDir); - bind_node::set_var(notr("outfile"), i_sUrl); - bind_node::set_var(notr("fulldoc"), doc_to_xml()); - bind_node::set_var(notr("hints"), m_sHints); - bind_node::set_var(notr("namet"), ""); - bind_node::set_var(notr("outdir"), ""); - - if (!init_py()) - { - emit sig_message(trUtf8("Missing bindings for opening files"), 5000); - return false; - } - PyRun_SimpleString(l_oBa.constData()); - - m_sLastSaved = i_sUrl; - - return true; -} - -void data_control::purge_document() -{ - QList k = m_oItems.keys(); - foreach(int i, k) - { - remove_item(i); - } - Q_ASSERT(m_oItems.keys().size()==0); - m_sCount = 1; -} - -bool data_control::open_file(const QString& i_sUrl) -{ - purge_document(); - - QFile l_o2(QString(FILTER_DIR)+"/main.py"); - if (!l_o2.open(QIODevice::ReadOnly)) - { - emit sig_message(trUtf8("Missing filter file %1 for opening files").arg(l_o2.fileName()), 5000); - return false; - } - QByteArray l_oBa = l_o2.readAll(); - l_o2.close(); - - bind_node::set_var(notr("temp_dir"), m_sTempDir); - bind_node::set_var(notr("pname"), i_sUrl); - bind_node::set_var(notr("hints"), m_sHints); - bind_node::set_var(notr("namet"), i_sUrl); - bind_node::set_var(notr("outdir"), ""); - - if (!init_py()) - { - emit sig_message(trUtf8("Missing bindings for opening files"), 5000); - return false; - } - PyRun_SimpleString(l_oBa.constData()); - - delete bind_node::_root; - bind_node::_root = NULL; - - //qDebug()<<"full text "<load_from_path(l_sNew); - } - - // now update all items created - for (int i=0; i NO_ITEM) l_iNext = i_iIdx; - else l_iNext = get_next(); - - data_item *l_oItem = new data_item(this, l_iNext); - m_oItems[l_iNext] = l_oItem; - - if (i_iCopy) - { - // copy parents colors and other settings - data_item *l_oParent = m_oItems[i_oAdd]; - l_oItem->m_iColor = l_oParent->m_iColor; - l_oItem->m_oCustom = l_oParent->m_oCustom; - } - - hash_params l_oCmd; - l_oCmd.insert(data_commande, QVariant(cmd_add_item)); - l_oCmd.insert(data_id, QVariant(l_iNext)); - emit synchro(l_oCmd); - - if (i_oAdd != NO_ITEM) - { - link_items(i_oAdd, l_iNext); - } - - select_item(l_iNext); - return l_iNext; -} - -void data_control::unlink_items(int i_iId1, int i_iId2) -{ - Q_ASSERT(m_oItems.contains(i_iId1) && m_oItems.contains(i_iId2)); - - m_oLinks.removeAll(QPoint(i_iId1, i_iId2)); - m_oLinks.removeAll(QPoint(i_iId2, i_iId1)); - - hash_params l_oCmd; - l_oCmd.insert(data_commande, QVariant(cmd_unlink)); - l_oCmd.insert(data_id1, QVariant(i_iId1)); - l_oCmd.insert(data_id2, QVariant(i_iId2)); - emit synchro(l_oCmd); -} - -bool data_control::link_items(int i_iParent, int i_iChild) -{ - Q_ASSERT(m_oItems.contains(i_iParent) && m_oItems.contains(i_iChild)); - - if (i_iParent == i_iChild) return false; - - // one parent - for (int i=0; i NO_ITEM) - { - int l_iNew = NO_ITEM; - for (int i=0; i data_control::all_roots() -{ - QList l_o = QList (); - foreach (int l_iVal, m_oItems.keys()) - { - for (int i=0; i l_o = all_roots(); - if (l_o.size() == 0) return; - - int l_i = root_of(m_iLastItemSelected); - if (l_i == NO_ITEM) select_item(l_o[0]); - - for (int i=0; i l_o = all_roots(); - if (l_o.size() == 0) return; - - int l_i = root_of(m_iLastItemSelected); - if (l_i == NO_ITEM) select_item(l_o[0]); - - for (int i=0; i l_o = all_roots(); - if (l_o.size() > 0) select_item(l_o[0]); - } - else - { - int l_iId = root_of(i_iId); - select_item(l_iId); - } -} - -void data_control::select_item_keyboard(int l_iId, int l_iDirection) -{ - if (l_iId == NO_ITEM) - { - select_root_item(NO_ITEM); return; - } - if (!m_oLinks.size()) return; - - switch (l_iDirection) - { - case 1: //left - { - int l_iParent = NO_ITEM; - int i = 0; - - while (i= m_oLinks.size()) i=0; - - QPoint l_oP = m_oLinks.at(i); - if (l_oP.x() == l_iParent) - { - select_item(l_oP.y()); - break; - } - } - } - break; - case 3: //top - { - for (int i=0; im_iDown = l_iId; - select_item(l_oP.x()); - return; - } - } - } - break; - case 4: //bottom - { - // first try the cache - data_item *l_oItem = m_oItems.value(l_iId); - Q_ASSERT(l_oItem != NULL); - int l_iDown = l_oItem->m_iDown; - - for (int i=0; i=0 && i_iVal2>=0) - { - if (i_iVal1 > i_iVal2) - { - m_oLinks.swap(i_iVal1, i_iVal2); - break; - } - else - { - int l_iPrev = i_iVal1; - for (int i=i_iVal1+1; im_iDataType != view_diag) - continue; - hash_params l_oCmd; - l_oCmd.insert(data_commande, QVariant(cmd_export_item)); - l_oCmd.insert(data_id, QVariant(l_oData->m_iId)); - emit synchro(l_oCmd); - } - - if (!init_py()) - { - emit sig_message(trUtf8("Missing bindings for opening files"), 5000); - return; - } - PyRun_SimpleString(l_oBa.constData()); - - delete bind_node::_root; - bind_node::_root = NULL; - - hash_params l_oCmd; - l_oCmd.insert(data_commande, QVariant(cmd_pre_view)); - emit synchro(l_oCmd); -} - -bind_node* data_control::create_tree(int i_i) -{ - Q_ASSERT(i_i!=0); - bind_node * l_oNode = new bind_node(); - l_oNode->m_oItem = m_oItems[i_i]; - //l_oNode->_id = i_i; - //fill_from_node(l_oNode); - - for (int i=0; i_children.push_back(l_oNew); - } - - return l_oNode; -} - -int data_control::choose_root() -{ - int l_oCand = NO_ITEM; - int l_oCandSize = 0; - for (int i=0; i NO_ITEM) continue; - if (l_oP.x() == l_oCand) continue; - - int l_oNewSize = size_of(l_oP.x()); - if (l_oNewSize > l_oCandSize) - { - l_oCand = l_oP.x(); - l_oCandSize = l_oNewSize; - } - } - - if (l_oCandSize == 0) return NO_ITEM; - return l_oCand; -} - -int data_control::size_of(int i_i) -{ - // warning, recursive - int l_i = 0; - for (int i=0; i"); - } - - m_sBuf.clear(); - return true; -} - -data_control::data_control(QObject* i_oParent) : QObject(i_oParent) -{ - m_sCount = 1; - m_iLastItemSelected = NO_ITEM; - m_sOutDir = ""; - m_iTimerValue = 21 / 4; - m_bDirty = false; - - m_oTimer = NULL; - m_sOutProject = ""; - m_sOutTemplate = ""; - init_temp_dir(); -} - -bool html_converter::endElement(const QString&, const QString&, const QString& i_sName) -{ - if (i_sName == notr("p")) - { - m_oTotale<")<"); - } - else if (i_sName == notr("li")) - { - m_oTotale<"); - } - return true; -} - -bool html_converter::characters(const QString &i_s) -{ - m_sBuf += i_s; - return true; -} - -data_item* data_control::operator+(const int y) -{ - return m_oItems.value(y); -} - -void data_control::change_data(int i_iId, int i_iType) -{ - if (i_iId <= NO_ITEM) return; - Q_ASSERT(m_oItems.value(i_iId) != NULL); - - m_oItems.value(i_iId)->m_iDataType = i_iType; - - hash_params l_oCmd; - l_oCmd.insert(data_commande, QVariant(cmd_change_data)); - l_oCmd.insert(data_id, QVariant(i_iId)); - emit synchro(l_oCmd); -} - -#include "data_control.moc" - diff -Nru semantik-0.7.3/src/data_control.h semantik-0.8.3/src/data_control.h --- semantik-0.7.3/src/data_control.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/data_control.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -// Thomas Nagy 2007-2009 GPLV3 - -#ifndef DATA_CONTROL_H -#define DATA_CONTROL_H - -#include -#include -#include -#include - - -#include "flag_scheme.h" -#include "color_scheme.h" -#include "con.h" - -class QTimer; -class html_converter : public QXmlDefaultHandler -{ - public: - html_converter(); - - bool startElement(const QString&, const QString&, const QString&, const QXmlAttributes&); - bool endElement(const QString&, const QString&, const QString&); - bool characters(const QString &i_sStr); - - QString m_sBuf; - QStringList m_oTotale; -}; - -class data_item; -class bind_node; -class data_control: public QObject -{ - Q_OBJECT - - signals: - //void rectangle_changed(int i); - - void synchro(const hash_params&); - - void sig_message(const QString&, int); - void dirty(bool); - void update_title(); - - public: - data_control(QObject *i_oParent); - ~data_control(); - - QString m_sTempDir; - QString m_sOutDir; - QString m_sOutProject; - QString m_sOutTemplate; - - void set_dirty(bool b = true); - bool m_bDirty; - - void init_temp_dir(); - void clean_temp_dir(); - - bool save_file(QString); - bool open_file(const QString&); - void purge_document(); - bool read_xml_file(const QString &l_oBa); - - void init_colors(); - void init_flags(); - - // first parameter is the parent, second parameter is the wanted id - // and the third parameter is for copying the parents data - int add_item(int i_oAdd=NO_ITEM, int i_iIdx=NO_ITEM, bool i_iCopy=false); - - void unlink_items(int id1, int id2); - bool link_items(int id1, int id2); - void remove_item(int i_oId); - void dis_connect(int i_oId); - void select_item(int i_oId, int i_iView=NO_VIEW); - void update_item(int i_oId, int i_iView=NO_VIEW); - - void sort_children(int i_iParent, int i_iChild, int i_iNum); - int num_children(int i_iParent); - int m_iConnType; - int m_iReorgType; - void select_root_item(int); - QList all_roots(); - int root_of(int i_iId); - void next_root(); - void prev_root(); - double m_dTriSize; - - QColor m_oColor; - QString m_sHints; - - int m_iLastItemSelected; - - private: - int m_sCount; - QTimer *m_oTimer; - public: - - KUrl m_oCurrentUrl; - - QHash m_oItems; - QList m_oLinks; - QList m_oImgs; - - QList m_oColorSchemes; - QList m_oFlagSchemes; - - int get_next(); - - void generate_docs(const QString &i_oFile, const QString &i_sName, const QString &i_sLocation); - - int m_iTimerValue; - int parent_of(int i_iId); - int size_of(int i_iId); - bind_node* create_tree(int); - int choose_root(); - - void init_timer(); - void destroy_timer(); - - QString doc_to_xml(); - QString m_sLastSaved; - - data_item* operator+(const int x); - - void select_item_keyboard(int, int); - - void change_data(int i_iId, int i_iType); - QMutex m_oLock; - - public slots: - void do_reorganize(); - void slot_autosave(); -}; - -QIcon fetch_icon(const QString& i_sName, int i_iSize=32); - -#endif - diff -Nru semantik-0.7.3/src/data_item.cpp semantik-0.8.3/src/data_item.cpp --- semantik-0.7.3/src/data_item.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/data_item.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -14,16 +14,16 @@ #include #include "con.h" -#include "data_control.h" +#include "sem_mediator.h" #include "data_item.h" -data_item::data_item(data_control *i_oControl, int i_iId) +data_item::data_item(sem_mediator *i_oControl, int i_iId) { - m_iDataType = view_text; + m_iDataType = VIEW_TEXT; m_iId = i_iId; m_iColor = 0; - m_oControl = i_oControl; + m_oMediator = i_oControl; m_sSummary = QObject::trUtf8("Empty"); m_sText = ""; m_sComment = ""; @@ -35,50 +35,51 @@ m_iDown = NO_ITEM; - m_iNumRows = 0; - m_iNumCols = 0; + m_iNumRows = 3; + m_iNumCols = 3; + m_iPicId = NO_ITEM; + + m_iObjectWidthHint = 0; + m_iObjectHeightHint = 0; + + m_iYY = m_iXX = -200000.0; } -/*! - * TODO check - */ -bool data_item::load_from_path(const QString & i_sPath) -{ - QPixmap l_oPix; - l_oPix.load(i_sPath); - if (l_oPix.isNull()) return false; - - //m_oPix = l_oPix.scaledToHeight(300); - m_oPix = l_oPix; - m_oThumbnail = l_oPix.scaledToHeight(32); +QPixmap data_item::getPix() +{ + return m_oMediator->getPix(m_iPicId); +} - return true; +QPixmap data_item::getThumb() +{ + return m_oMediator->getThumb(m_iPicId); } + color_scheme& data_item::get_color_scheme() { - if (m_oControl->parent_of(m_iId) <= 0) + if (m_oMediator->parent_of(m_iId) <= 0) { - return m_oControl->m_oColorSchemes[0]; + return m_oMediator->m_oColorSchemes[0]; } if (m_iColor < 0) { return m_oCustom; } - if (m_iColor == m_oControl->m_oColorSchemes.size()) + if (m_iColor == m_oMediator->m_oColorSchemes.size()) { return m_oCustom; } - if (m_iColor > m_oControl->m_oColorSchemes.size()) + if (m_iColor > m_oMediator->m_oColorSchemes.size()) { qDebug()<<"invalid index color scheme "<m_oColorSchemes[1]; + return m_oMediator->m_oColorSchemes[1]; } - return m_oControl->m_oColorSchemes[m_iColor]; + return m_oMediator->m_oColorSchemes[m_iColor]; } color_scheme& data_item::get_color_scheme_raw() @@ -87,16 +88,116 @@ { return m_oCustom; } - if (m_iColor == m_oControl->m_oColorSchemes.size()) + if (m_iColor == m_oMediator->m_oColorSchemes.size()) { return m_oCustom; } - if (m_iColor > m_oControl->m_oColorSchemes.size()) + if (m_iColor > m_oMediator->m_oColorSchemes.size()) { qDebug()<<"invalid index color scheme "<m_oColorSchemes[m_iColor]; + return m_oMediator->m_oColorSchemes[m_iColor]; +} + + +diagram_item::diagram_item() +{ + pen_style = Qt::SolidLine; + border_width = 1; +} + +data_box::data_box(int id) : diagram_item() +{ + m_iId = id; + m_bIsEnd = false; + m_bIsVertical = false; + m_iType = data_box::ACTIVITY; + m_iWW = 100; + m_iHH = 40; + color = QColor("#a7e89b"); +} + +void diagram_item::setBorderWidth(int bw) +{ + border_width = bw; +} + +void diagram_item::setPenStyle(Qt::PenStyle st) +{ + pen_style = st; +} + +void diagram_item::setColor(QColor co) +{ + color = co; +} + +data_link::data_link() : diagram_item() +{ + color = QColor(Qt::black); + m_iParentPos = NORTH; + m_iChildPos = NORTH; + m_iLeftArrow = 0; + m_iRightArrow = 1; + m_iLineType = 0; +} + +void data_link::copy_from(const data_link& i_oLink) +{ + m_sLink = i_oLink.m_sLink; + m_sCaption = i_oLink.m_sCaption; + m_iParent = i_oLink.m_iParent; + m_iChild = i_oLink.m_iChild; + m_iParentPos = i_oLink.m_iParentPos; + m_iChildPos = i_oLink.m_iChildPos; + m_iLineType = i_oLink.m_iLineType; + m_oStartPoint = i_oLink.m_oStartPoint; + m_oEndPoint = i_oLink.m_oEndPoint; + m_oOffsets = i_oLink.m_oOffsets; + + m_iLeftArrow = i_oLink.m_iLeftArrow; + m_iRightArrow = i_oLink.m_iRightArrow; + + border_width = i_oLink.border_width; + pen_style = i_oLink.pen_style; + color = i_oLink.color; +} + +bool data_link::equals(const data_link& i_oLink) +{ + if (m_iParent != NO_ITEM) + { + if (m_iParent != i_oLink.m_iParent || m_iParentPos != i_oLink.m_iParentPos) + return false; + } + else + { + if (m_oStartPoint != i_oLink.m_oStartPoint) + return false; + } + + if (m_iChild != NO_ITEM) + { + if (m_iChild != i_oLink.m_iChild || m_iChildPos != i_oLink.m_iChildPos) + return false; + } + else + { + if (m_oEndPoint != i_oLink.m_oEndPoint) + return false; + } + + if (m_oOffsets.size() != i_oLink.m_oOffsets.size()) + return false; + + for (int i = 0; i < m_oOffsets.size(); ++i) + { + if (m_oOffsets.at(i) != i_oLink.m_oOffsets.at(i)) + return false; + } + + return true; } /* diff -Nru semantik-0.7.3/src/data_item.h semantik-0.8.3/src/data_item.h --- semantik-0.7.3/src/data_item.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/data_item.h 2012-10-21 10:09:17.000000000 +0000 @@ -1,10 +1,12 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef DATA_ITEM_H #define DATA_ITEM_H +#include #include #include +#include #include #include #include @@ -12,28 +14,78 @@ #include "color_scheme.h" #include "con.h" -class data_control; +class sem_mediator; -class data_table_item //: +class diagram_item { public: - int m_iRow; - int m_iCol; - QString m_sText; + diagram_item(); + + void setBorderWidth(int); + void setPenStyle(Qt::PenStyle); + void setColor(QColor); + + int border_width; + Qt::PenStyle pen_style; + QColor color; }; -class data_link //: +class data_link : public diagram_item { public: + enum Direction { NORTH=1, WEST=2, SOUTH=4, EAST=8, COORD=15 }; + data_link(); QString m_sLink; QString m_sCaption; + + int m_iParent; + int m_iChild; + int m_iParentPos; + int m_iChildPos; + + bool m_iLeftArrow; + bool m_iRightArrow; + int m_iLineType; + + QPoint m_oStartPoint; + QPoint m_oEndPoint; + QList m_oOffsets; + + void copy_from(const data_link&); + bool equals(const data_link&); +}; + +class data_box : public diagram_item +{ + public: + data_box(int id); + int m_iId; + QString m_sText; + int m_iXX; + int m_iYY; + int m_iWW; + int m_iHH; + bool m_bIsEnd; + bool m_bIsVertical; + enum IType { ACTIVITY=1, ACTIVITY_START=2, ACTIVITY_PARALLEL=3, LABEL=4, COMPONENT=5, NODE=6, ACTOR=7, USECASE=8, DECISION=9 }; + data_box::IType m_iType; +}; + +class data_pic +{ + public: + QPixmap m_oPix; + QPixmap m_oThumb; + //QString m_sPicLocation; // keep them on the item? + //QString m_sPicCaption; + //QString m_sPicComment; }; -class data_item //: +class data_item { public: - data_item(data_control *i_oControl, int i_iId); - data_control* m_oControl; + data_item(sem_mediator *i_oControl, int i_iId); + sem_mediator* m_oMediator; QString m_sSummary; QString m_sText; @@ -44,11 +96,16 @@ QString m_sPicLocation; QString m_sPicCaption; QString m_sPicComment; + //QPixmap m_oPix; + //QPixmap m_oThumbnail; + + int m_iPicId; // references a data_pic - QPixmap m_oPix; - QPixmap m_oThumbnail; + QPixmap getPix(); + QPixmap getThumb(); int m_iId; + bool m_bSelected; double m_iXX; double m_iYY; double m_iWW; @@ -70,10 +127,17 @@ int m_iNumRows; int m_iNumCols; - QList m_oTableData; + QHash, QString> m_oTableData; QString m_sHints; - bool load_from_path(const QString &); + //bool load_from_path(const QString &); + + QHash m_oBoxes; + QList m_oLinks; + + // transient + int m_iObjectWidthHint; + int m_iObjectHeightHint; }; #endif diff -Nru semantik-0.7.3/src/data_view.cpp semantik-0.8.3/src/data_view.cpp --- semantik-0.7.3/src/data_view.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/data_view.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,57 +1,46 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include #include #include "data_item.h" -#include "data_control.h" +#include "sem_mediator.h" #include "data_view.h" #include "con.h" #include "sembind.h" -data_view::data_view(QWidget *i_oParent, data_control *i_oControl) : QStackedWidget(i_oParent) +data_view::data_view(QWidget *i_oParent, sem_mediator *i_oControl) : QStackedWidget(i_oParent) { - m_oControl = i_oControl; + m_oMediator = i_oControl; m_oLabel = new QLabel(this); m_oLabel->setText(trUtf8("

    No item selected

    ")); addWidget(m_oLabel); } -void data_view::synchro_doc(const hash_params&i_o) -{ - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) +void data_view::notify_select(const QList& unsel, const QList& sel) { + if (sel.size() != 1) { + setCurrentIndex(0); + } + else { - case cmd_select_item: - { - int l_iId = i_o[data_id].toInt(); - if (l_iId == NO_ITEM) - { - setCurrentIndex(0); - break; - } - } - // else fall through - case cmd_change_data: - { - data_item *l_oItem = *m_oControl + i_o[data_id].toInt(); - int j = 0; - switch (l_oItem->m_iDataType) - { - // just to make it really complicated - // text image table diagram - case view_diag: j++; - case view_table: j++; - case view_img: j++; - case view_text: j++; - default: - setCurrentIndex(j); - break; - } - break; - } + notify_datatype(sel.at(0)); + } +} + +void data_view::notify_datatype(int id) { + data_item *l_oItem = *m_oMediator + id; + int j = 0; + switch (l_oItem->m_iDataType) + { + // text image table diagram + case VIEW_DIAG: j++; + case VIEW_TABLE: j++; + case VIEW_IMG: j++; + case VIEW_TEXT: j++; default: + setCurrentIndex(j); + //qDebug()<<"index is"<& unsel, const QList& sel); + void notify_datatype(int id); }; #endif diff -Nru semantik-0.7.3/src/doc_dialog.cpp semantik-0.8.3/src/doc_dialog.cpp --- semantik-0.7.3/src/doc_dialog.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/doc_dialog.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include diff -Nru semantik-0.7.3/src/doc_dialog.h semantik-0.8.3/src/doc_dialog.h --- semantik-0.7.3/src/doc_dialog.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/doc_dialog.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef DOC_DIALOG_H #define DOC_DIALOG_H diff -Nru semantik-0.7.3/src/export_map_dialog.cpp semantik-0.8.3/src/export_map_dialog.cpp --- semantik-0.7.3/src/export_map_dialog.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/export_map_dialog.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -0,0 +1,112 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "export_map_dialog.h" + +export_map_dialog::export_map_dialog(QWidget *i_oParent): KDialog(i_oParent) +{ + setButtons(KDialog::Ok | KDialog::Cancel); + + QWidget *widget = new QWidget(this); + setCaption(trUtf8("Export the map")); + setButtons(KDialog::Ok | KDialog::Cancel); + + QGridLayout * gridLayout = new QGridLayout(widget); + + QLabel *label = new QLabel(widget); + label->setText(trUtf8("File to write")); + gridLayout->addWidget(label, 0, 0); + + kurlrequester = new KUrlRequester(widget); + gridLayout->addWidget(kurlrequester, 0, 1, 1, 1); + + m_oWidthC = new QRadioButton(trUtf8("Width"), widget); + gridLayout->addWidget(m_oWidthC, 1, 0, 1, 1); + + m_oWidth = new QSpinBox(widget); + m_oWidth->setMinimum(16); + m_oWidth->setMaximum(20000); + gridLayout->addWidget(m_oWidth, 1, 1, 1, 1); + + m_oHeightC = new QRadioButton(trUtf8("Height"), widget); + gridLayout->addWidget(m_oHeightC, 2, 0, 1, 1); + + m_oHeight = new QSpinBox(widget); + m_oHeight->setMinimum(16); + m_oHeight->setMaximum(20000); + m_oHeight->setEnabled(false); + gridLayout->addWidget(m_oHeight, 2, 1, 1, 1); + + connect(m_oHeightC, SIGNAL(clicked(bool)), this, SLOT(radio(bool))); + connect(m_oWidthC, SIGNAL(clicked(bool)), this, SLOT(radio(bool))); + connect(m_oWidth, SIGNAL(valueChanged(int)), this, SLOT(widthChanged(int))); + connect(m_oHeight, SIGNAL(valueChanged(int)), this, SLOT(heightChanged(int))); + + setMainWidget(widget); + QSize size(600, 100); + resize(size.expandedTo(minimumSizeHint())); + + kurlrequester->setFocus(); +} + +void export_map_dialog::slotButtonClicked(int button) { + if (button == KDialog::Ok) + { + accept(); + } + else + { + KDialog::slotButtonClicked(button); + } +} + +void export_map_dialog::radio(bool) +{ + if (m_oHeightC->isChecked()) + { + m_oHeight->setEnabled(true); + m_oWidth->setEnabled(false); + } + else + { + m_oWidth->setEnabled(true); + m_oHeight->setEnabled(false); + } +} + +void export_map_dialog::widthChanged(int v) +{ + if (m_oHeightC->isChecked()) + return; + m_oHeight->setValue((v * m_iBaseHeight) / m_iBaseWidth); +} + +void export_map_dialog::heightChanged(int v) +{ + if (m_oWidthC->isChecked()) + return; + m_oWidth->setValue((v * m_iBaseWidth) / m_iBaseHeight); +} + +#include "export_map_dialog.moc" + diff -Nru semantik-0.7.3/src/export_map_dialog.h semantik-0.8.3/src/export_map_dialog.h --- semantik-0.7.3/src/export_map_dialog.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/export_map_dialog.h 2012-10-21 10:09:17.000000000 +0000 @@ -0,0 +1,34 @@ +// Thomas Nagy 2012 GPLV3 + +#ifndef EXPORT_MAP_DIALOG_H +#define EXPORT_MAP_DIALOG_H + +#include + +class QSpinBox; +class QRadioButton; +class KUrlRequester; +class export_map_dialog : public KDialog +{ + Q_OBJECT + public: + export_map_dialog(QWidget *i_oParent); + + KUrlRequester *kurlrequester; + QRadioButton *m_oWidthC; + QSpinBox *m_oWidth; + QRadioButton *m_oHeightC; + QSpinBox *m_oHeight; + + int m_iBaseWidth; + int m_iBaseHeight; + + public slots: + void slotButtonClicked(int button); + void radio(bool); + void widthChanged(int); + void heightChanged(int); +}; + +#endif + diff -Nru semantik-0.7.3/src/fig/CON.h semantik-0.8.3/src/fig/CON.h --- semantik-0.7.3/src/fig/CON.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/CON.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,53 @@ +// Thomas Nagy 2007-2012 GPLV3 + + +#ifndef CON_h +#define CON_h + +#include +#include "data_item.h" +#include "box_chain.h" + +#define MUL 64 +#define GRADVAL 110 +#define JUST 1 +class connectable +{ + public: + connectable() { m_oBox = NULL; }; + virtual ~connectable() {}; + int m_iId; + virtual QRectF rect() const { return QRectF(); } + virtual void update_data() {}; + virtual void update_size() {}; + virtual int choose_position(const QPointF&p, int id=-1) { Q_ASSERT(false); return 0; }; + virtual QPoint get_point(int position) { return QPoint(0, 0); }; + data_box *m_oBox; + box_chain *m_oChain; + + + virtual data_link::Direction pos_heuristic(const QPoint & i_oP, int i_iDirection) + { + switch (i_iDirection & data_link::COORD) + { + case data_link::NORTH: + return (i_oP.y() > 0) ? data_link::NORTH : data_link::SOUTH; + break; + case data_link::WEST: + return (i_oP.x() < 0) ? data_link::EAST : data_link::WEST; + break; + case data_link::SOUTH: + return (i_oP.y() < rect().height()) ? data_link::SOUTH : data_link::NORTH; + break; + case data_link::EAST: + return (i_oP.x() > rect().width()) ? data_link::WEST : data_link::EAST; + break; + default: + break; + } + return data_link::SOUTH; + }; +}; + +#endif + diff -Nru semantik-0.7.3/src/fig/box_actor.cpp semantik-0.8.3/src/fig/box_actor.cpp --- semantik-0.7.3/src/fig/box_actor.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_actor.cpp 2012-09-17 21:01:39.000000000 +0000 @@ -0,0 +1,69 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_actor.h" +#include "data_item.h" + #include "res:zable.h" +#include "box_view.h" + #include "box_link.h" +#include "sem_mediator.h" +#include "mem_box.h" + +#include + +#define PAD 2 +#define MIN_FORK_SIZE 30 + +box_actor::box_actor(box_view* view, int id) : box_item(view, id) +{ + QFont font = doc.defaultFont(); + font.setPointSize(font.pointSize() - 2); + doc.setDefaultFont(font); +} + +void box_actor::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + painter->setPen(l_oPen); + + + qreal xtop = l_oRect.x(); + qreal ytop = l_oRect.y(); + qreal xcoord = xtop + l_oRect.width() / 2.0; + qreal ycoord = l_oRect.height() / 5.; + + painter->drawLine(xcoord, ytop + 2 * ycoord, xcoord, ytop + 4 * ycoord); + painter->drawLine(xtop, ytop + 3 * ycoord, xtop + l_oRect.width(), ytop + 3 * ycoord); + + painter->drawLine(xtop, ytop + l_oRect.height(), xcoord, ytop + 4 * ycoord); + painter->drawLine(xtop + l_oRect.width(), ytop + l_oRect.height(), xcoord, ytop + 4 * ycoord); + + painter->drawEllipse(l_oRect.x(), l_oRect.y(), l_oRect.width(), 2 * ycoord); + + if (isSelected()) + { + painter->setBrush(QColor("#FFFF00")); + QRectF l_oR2(m_iWW - 8, m_iHH - 8, 6, 6); + painter->drawRect(l_oR2); + } + + painter->restore(); +} + diff -Nru semantik-0.7.3/src/fig/box_actor.h semantik-0.8.3/src/fig/box_actor.h --- semantik-0.7.3/src/fig/box_actor.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_actor.h 2012-09-17 21:01:39.000000000 +0000 @@ -0,0 +1,24 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_ACTOR_H +#define BOX_ACTOR_H + +#include +#include +#include "res:zable.h" +#include "ed:table.h" +#include "box_item.h" +#include "CON.h" +#include "con.h" + +#define OFF 3 + +class box_actor : public box_item +{ + public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + box_actor(box_view*, int i_iId); +}; + +#endif // BOX_ACTOR_H + diff -Nru semantik-0.7.3/src/fig/box_chain.cpp semantik-0.8.3/src/fig/box_chain.cpp --- semantik-0.7.3/src/fig/box_chain.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_chain.cpp 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,30 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include "CON.h" +#include "box_chain.h" +#include "box_view.h" +#include "data_item.h" +#include + +#define PAD 1 + +box_chain::box_chain(box_view* i_oParent) : QGraphicsRectItem() +{ + setVisible(false); + setRect(0, 0, 10, 10); +} + +void box_chain::paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *option, QWidget * i_oW) +{ + QPen l_oPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setWidth(1); + i_oPainter->setPen(l_oPen); + + i_oPainter->drawLine(QPoint(PAD, 5), QPoint(10-PAD, 5)); + i_oPainter->drawLine(QPoint(5, PAD), QPoint(5, 10-PAD)); +} + diff -Nru semantik-0.7.3/src/fig/box_chain.h semantik-0.8.3/src/fig/box_chain.h --- semantik-0.7.3/src/fig/box_chain.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_chain.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,26 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_CHAIN_H +#define BOX_CHAIN_H + +#include +#include +#include +#include +#include +#include "con.h" + +class box_view; +class box_item; +class data_link; +class box_control_point; +class box_chain : public QGraphicsRectItem +{ + public: + box_chain(box_view*); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); +}; + +#endif // BOX_CHAIN_H + diff -Nru semantik-0.7.3/src/fig/box_component.cpp semantik-0.8.3/src/fig/box_component.cpp --- semantik-0.7.3/src/fig/box_component.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_component.cpp 2012-09-17 21:01:39.000000000 +0000 @@ -0,0 +1,91 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_component.h" +#include "data_item.h" + #include "res:zable.h" +#include "box_view.h" + #include "box_link.h" +#include "sem_mediator.h" +#include "mem_box.h" + +#define PAD 2 +#define MIN_FORK_SIZE 30 + +box_component::box_component(box_view* view, int id) : box_item(view, id) +{ + setZValue(95); +} + +void box_component::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QColor bc(m_oBox->color); + if (m_oView->m_bDisableGradient) + { + painter->setBrush(bc); + } + else + { + QLinearGradient linearGradient(0, 0, l_oRect.width(), 0); + linearGradient.setColorAt(0.0, bc); + linearGradient.setColorAt(1.0, bc.darker(GRADVAL)); + painter->setBrush(linearGradient); + } + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + + + if (isSelected()) + { + l_oPen.setStyle(Qt::DotLine); + } + + painter->setPen(l_oPen); + painter->drawRect(l_oRect); + + if (isSelected()) + { + l_oPen.setStyle(Qt::SolidLine); + painter->setPen(l_oPen); + painter->setBrush(QColor("#FFFF00")); + QRectF l_oR2(m_iWW - 8, m_iHH - 8, 6, 6); + painter->drawRect(l_oR2); + } + + l_oPen.setStyle(Qt::SolidLine); + painter->setPen(l_oPen); + painter->setBrush(bc); + QRectF l_o(m_iWW - 20, 6, 12, 14); + painter->drawRect(l_o); + QRectF l_o2(m_iWW - 24, 9, 8, 3); + painter->drawRect(l_o2); + QRectF l_o3(m_iWW - 24, 14, 8, 3); + painter->drawRect(l_o3); + + + painter->translate(OFF, OFF + 15); + QAbstractTextDocumentLayout::PaintContext ctx; + ctx.palette = QApplication::palette("QTextControl"); + doc.documentLayout()->draw(painter, ctx); + + painter->restore(); +} + diff -Nru semantik-0.7.3/src/fig/box_component.h semantik-0.8.3/src/fig/box_component.h --- semantik-0.7.3/src/fig/box_component.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_component.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,25 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_COMPONENT_H +#define BOX_COMPONENT_H + +#include +#include +#include "res:zable.h" +#include "ed:table.h" +#include "box_item.h" +#include "CON.h" +#include "con.h" + +#define OFF 3 + +class box_component : public box_item +{ + public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + box_component(box_view*, int i_iId); + +}; + +#endif // BOX_COMPONENT_H + diff -Nru semantik-0.7.3/src/fig/box_control_point.cpp semantik-0.8.3/src/fig/box_control_point.cpp --- semantik-0.7.3/src/fig/box_control_point.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_control_point.cpp 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,270 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_control_point.h" +#include "box_view.h" +#include "box_control_point.h" +#include "mem_box.h" + #include "box_link.h" +#include "data_item.h" +#include "sem_mediator.h" + +#define PAD 1 +#define CTRLSIZE 8 + +box_control_point::box_control_point(box_view* i_oParent) : QGraphicsRectItem(), m_oView(i_oParent) +{ + setRect(-CTRLSIZE/2., -CTRLSIZE/2., CTRLSIZE, CTRLSIZE); + m_bIsSegment = true; + m_oLink = NULL; + i_oParent->scene()->addItem(this); + setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + setZValue(110); + m_bChanged = false; + m_bForced = false; + setFlags(ItemIsMovable | ItemSendsGeometryChanges); +} + +void box_control_point::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + painter->setPen(l_oPen); + if (m_bIsSegment) + { + painter->setBrush(QColor("#FFFF00")); + } + else + { + if ( + (m_oLink->m_oStartPoint == this && m_oLink->m_oInnerLink.m_iParent != NO_ITEM) + || + (m_oLink->m_oEndPoint == this && m_oLink->m_oInnerLink.m_iChild != NO_ITEM)) + { + painter->setBrush(QColor(Qt::green)); + } + else + painter->setBrush(QColor(Qt::red)); + } + painter->drawRect(l_oRect); + painter->restore(); +} + +void box_control_point::mousePressEvent(QGraphicsSceneMouseEvent* e) { + //qDebug()<<"FIXME mouse press event"; + QGraphicsRectItem::mousePressEvent(e); +} + +void box_control_point::mouseReleaseEvent(QGraphicsSceneMouseEvent* e) { + if (! m_oView->m_oCurrent) + { + if (!m_oLink->m_oLink->equals(m_oLink->m_oInnerLink)) + { + mem_change_link_box* mem = new mem_change_link_box(m_oView->m_oMediator, m_oView->m_iId); + mem->link = m_oLink->m_oLink; + mem->prev.copy_from(*m_oLink->m_oLink); + mem->next.copy_from(m_oLink->m_oInnerLink); + mem->apply(); + } + } + QGraphicsRectItem::mouseReleaseEvent(e); +} + +QVariant box_control_point::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) +{ + if (scene()) + { + if (i_oChange == ItemPositionChange) + { + // TODO make sure items do not mess each other positions (crashes...) + QPointF l_o = i_oValue.toPointF(); + QPoint np = QPoint(l_o.x(), l_o.y()); + + if (m_oView->m_oCurrent && this == m_oLink->m_oEndPoint) + { + connectable *start = m_oView->m_oItems.value(m_oView->m_oCurrent->m_oInnerLink.m_iParent); + QRectF r = start->rect(); + QPointF l_o1 = r.topLeft() - l_o + QPointF(r.width()/2, r.height()/2); + double c_x = l_o1.x() * r.height(); + double c_y = l_o1.y() * r.width(); + + int cand = 0; + if (qAbs(c_x) > qAbs(c_y)) + { + cand = (c_x > 0) ? data_link::WEST : data_link::EAST; + } + else + { + cand = (c_y > 0) ? data_link::NORTH : data_link::SOUTH; + } + m_oView->m_oCurrent->m_oInnerLink.m_iParentPos = cand + MUL * 500; + } + + if (m_bIsSegment) + { + if (m_bMoveX) { + int dec = int_val2(np.x()); + np.setX(dec); + if (m_oLink->m_oLst.size() > m_iOffset + 1) + { + np.setY((m_oLink->m_oGood[m_iOffset + 1].y() + m_oLink->m_oGood[m_iOffset + 2].y()) / 2.); + if (m_oLink->m_oGood[m_iOffset + 1].x() != dec) + { + m_oLink->m_oInnerLink.m_oOffsets[m_iOffset].setX(dec - m_oLink->m_oLst[m_iOffset + 1].x()); + m_bChanged = true; + } + } + } else { + int dec = int_val2(np.y()); + np.setY(dec); + if (m_oLink->m_oLst.size() > m_iOffset + 1) + { + np.setX((m_oLink->m_oGood[m_iOffset + 1].x() + m_oLink->m_oGood[m_iOffset + 2].x()) / 2.); + if (m_oLink->m_oGood[m_iOffset + 1].y() != dec) + { + m_oLink->m_oInnerLink.m_oOffsets[m_iOffset].setY(dec - m_oLink->m_oLst[m_iOffset + 1].y()); + m_bChanged = true; + } + } + } + return np; + } + else if (!m_bForced) + { + connectable *l_oUnder = NULL; // TODO do something with the z-index + foreach (QGraphicsItem *l_oI1, scene()->items(np)) + { + if ((l_oUnder = dynamic_cast(l_oI1))) + { + break; + } + } + + if (l_oUnder) + { + int l_iPosition = (int) l_oUnder->choose_position(l_o); + if (l_oUnder) + { + if (m_oLink->m_oStartPoint == this) + { + if (l_iPosition == m_oLink->m_oInnerLink.m_iChildPos && m_oLink->m_oInnerLink.m_iChild == l_oUnder->m_iId) + goto not_connected; + } + else if (m_oLink->m_oEndPoint == this) + { + if (l_iPosition == m_oLink->m_oInnerLink.m_iParentPos && m_oLink->m_oInnerLink.m_iParent == l_oUnder->m_iId) + goto not_connected; + } + } + + np = l_oUnder->get_point(l_iPosition); + if (m_oLink->m_oStartPoint == this) + { + m_oLink->m_oInnerLink.m_iParent = l_oUnder->m_iId; + m_oLink->m_oInnerLink.m_iParentPos = l_iPosition; + m_oLink->m_oInnerLink.m_oStartPoint = m_oRealPosition = np; + } + else if (m_oLink->m_oEndPoint == this) + { + m_oLink->m_oInnerLink.m_iChild = l_oUnder->m_iId; + m_oLink->m_oInnerLink.m_iChildPos = l_iPosition; + m_oLink->m_oInnerLink.m_oEndPoint = m_oRealPosition = np; + } + update(); + return np; + } + + not_connected: + + if (m_oLink->m_oStartPoint == this) + { + if (connectable* con = m_oView->m_oItems.value(m_oLink->m_oInnerLink.m_iChild)) + { + QPointF bot = con->rect().bottomLeft(); + m_oLink->m_oInnerLink.m_iParentPos = con->pos_heuristic(np - QPoint(bot.x(), bot.y()), m_oLink->m_oInnerLink.m_iChildPos); + } + m_oLink->m_oInnerLink.m_iParent = NO_ITEM; + m_oLink->m_oInnerLink.m_oStartPoint = m_oRealPosition = np; + } + else if (m_oLink->m_oEndPoint == this) + { + if (connectable* con = m_oView->m_oItems.value(m_oLink->m_oInnerLink.m_iParent)) + { + QPointF bot = con->rect().bottomLeft(); + m_oLink->m_oInnerLink.m_iChildPos = con->pos_heuristic(np - QPoint(bot.x(), bot.y()), m_oLink->m_oInnerLink.m_iParentPos); + } + m_oLink->m_oInnerLink.m_iChild = NO_ITEM; + m_oLink->m_oInnerLink.m_oEndPoint = m_oRealPosition = np; + } + + update(); + return np; + } + } + else if (i_oChange == ItemPositionHasChanged) + { + if (m_bIsSegment && m_bChanged && m_oLink->m_oLst.size() > m_iOffset) + { + m_oLink->update_offset(pos(), m_iOffset); + m_bChanged = false; + } + else if (!m_bIsSegment && !m_bForced) + { + m_oLink->update_pos(); + } + } + else if (i_oChange == ItemSelectedHasChanged) + { + if (isSelected()) + setZValue(105); + else + setZValue(104); + } + } + + return QGraphicsItem::itemChange(i_oChange, i_oValue); +} + +void box_control_point::init_pos() +{ + Q_ASSERT(m_oLink); + int i = m_iOffset; + + QPointF p(m_oLink->m_oGood.at(i+1)); + if (m_oLink->m_oGood.at(i+2).x() == p.x()) { + p.setY((p.y() + m_oLink->m_oGood.at(i+2).y()) / 2); + m_bMoveX = true; + } else { + p.setX((p.x() + m_oLink->m_oGood.at(i+2).x()) / 2); + m_bMoveX = false; + } + setPos(p); +} + +void box_control_point::force_position(const QPoint& i_oP) +{ + m_bForced = true; + if (m_oRealPosition != i_oP) + { + m_oRealPosition = i_oP; + } + setPos(i_oP); + m_bForced = false; +} + diff -Nru semantik-0.7.3/src/fig/box_control_point.h semantik-0.8.3/src/fig/box_control_point.h --- semantik-0.7.3/src/fig/box_control_point.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_control_point.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,42 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_CTRL_H +#define BOX_CTRL_H + +#include +#include +#include "CON.h" +#include "con.h" + +class box_view; +class data_item; +class data_box; +class box_link; +class box_control_point : public QGraphicsRectItem +{ + public: + box_control_point(box_view*); + bool m_bIsSegment; + bool m_bMoveX; + + int m_iOffset; + box_link *m_oLink; + box_view *m_oView; + + void init_pos(); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + QPoint m_oRealPosition; + QVariant itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue); + + void mousePressEvent(QGraphicsSceneMouseEvent* e); + void mouseReleaseEvent(QGraphicsSceneMouseEvent* e); + + void force_position(const QPoint&); + + private: + bool m_bChanged; + bool m_bForced; +}; + +#endif // BOX_CTRL_H + diff -Nru semantik-0.7.3/src/fig/box_decision.cpp semantik-0.8.3/src/fig/box_decision.cpp --- semantik-0.7.3/src/fig/box_decision.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_decision.cpp 2012-10-21 10:09:14.000000000 +0000 @@ -0,0 +1,95 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_decision.h" +#include "data_item.h" + #include "res:zable.h" +#include "box_view.h" + #include "box_link.h" +#include "sem_mediator.h" +#include "mem_box.h" + +#include + +#define PAD 2 +#define MIN_FORK_SIZE 30 + +box_decision::box_decision(box_view* view, int id) : box_item(view, id) +{ + QFont font = doc.defaultFont(); + font.setBold(true); + doc.setDefaultFont(font); + + setZValue(90); +} + +void box_decision::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QColor bc(m_oBox->color); + if (m_oView->m_bDisableGradient) + { + painter->setBrush(bc); + } + else + { + QLinearGradient linearGradient(0, 0, l_oRect.width(), 0); + linearGradient.setColorAt(0.0, bc); + linearGradient.setColorAt(1.0, bc.darker(GRADVAL)); + painter->setBrush(linearGradient); + } + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + if (isSelected()) + { + l_oPen.setStyle(Qt::DotLine); + } + + QPointF pts[4]; // NESW + QPointF topLeft = l_oRect.topLeft(); + pts[0] = topLeft + QPointF(l_oRect.width()/2, 0); + pts[1] = topLeft + QPointF(l_oRect.width(), l_oRect.height()/2); + pts[2] = topLeft + QPointF(l_oRect.width()/2, l_oRect.height()); + pts[3] = topLeft + QPointF(0, l_oRect.height()/2); + + painter->drawPolygon(pts, 4); + + if (isSelected()) + { + l_oPen.setStyle(Qt::SolidLine); + painter->setPen(l_oPen); + painter->setBrush(QColor("#FFFF00")); + QRectF l_oR2(m_iWW - 8, m_iHH - 8, 6, 6); + painter->drawRect(l_oR2); + } + painter->restore(); +} + +void box_decision::update_size() { + m_iWW = m_oBox->m_iWW; + m_iHH = m_oBox->m_iHH; + + doc.setHtml(QString("
    %1
    ").arg(m_oBox->m_sText)); + doc.setTextWidth(m_iWW - 2 * OFF - 20); + + setRect(0, 0, m_iWW, m_iHH); +} + diff -Nru semantik-0.7.3/src/fig/box_decision.h semantik-0.8.3/src/fig/box_decision.h --- semantik-0.7.3/src/fig/box_decision.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_decision.h 2012-10-21 10:09:14.000000000 +0000 @@ -0,0 +1,25 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_DECISION_H +#define BOX_DECISION_H + +#include +#include +#include "res:zable.h" +#include "ed:table.h" +#include "box_item.h" +#include "CON.h" +#include "con.h" + +#define OFF 3 + +class box_decision : public box_item +{ + public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + box_decision(box_view*, int i_iId); + void update_size(); +}; + +#endif // BOX_DECISION_H + diff -Nru semantik-0.7.3/src/fig/box_dot.cpp semantik-0.8.3/src/fig/box_dot.cpp --- semantik-0.7.3/src/fig/box_dot.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_dot.cpp 2012-09-05 01:08:33.000000000 +0000 @@ -0,0 +1,169 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_dot.h" +#include "box_view.h" + #include "box_link.h" +#include "data_item.h" +#include "sem_mediator.h" + +#define PAD 2 + +box_dot::box_dot(box_view* i_oParent, int i_iId) : QGraphicsRectItem(), connectable(), m_oView(i_oParent) +{ + m_iId = i_iId; + m_oItem = m_oView->m_oMediator->m_oItems[m_oView->m_iId]; + m_oBox = m_oItem->m_oBoxes[m_iId]; + Q_ASSERT(m_oBox); + + i_oParent->scene()->addItem(this); + //setRect(QRectF(QPointF(0, 0), QSizeF(20, 20))); + + m_oChain = new box_chain(i_oParent); + m_oChain->setParentItem(this); + + setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + setZValue(100); + setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges); + + update_size(); +} + +box_dot::~box_dot() +{ + delete m_oChain; +} + +void box_dot::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + if (isSelected()) l_oPen.setStyle(Qt::DotLine); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + + painter->setPen(l_oPen); + if (m_oBox->m_bIsEnd) { + painter->drawEllipse(l_oRect); + painter->setBrush(m_oBox->color); + QRectF in = l_oRect.adjusted(PAD+1, PAD+1, -PAD-1, -PAD-1); + painter->drawEllipse(in); + } else { + painter->setBrush(m_oBox->color); + painter->drawEllipse(l_oRect); + } + painter->restore(); +} + +void box_dot::mousePressEvent(QGraphicsSceneMouseEvent* e) { + setZValue(100); + QGraphicsRectItem::mousePressEvent(e); +} + +void box_dot::mouseReleaseEvent(QGraphicsSceneMouseEvent* e) { + setZValue(99); + QGraphicsRectItem::mouseReleaseEvent(e); +} + +/*QRectF box_dot::boundingRect() const { + return rect().adjusted(-OFF, -OFF, OFF, OFF); +}*/ + +void box_dot::update_data() { + setPos(QPointF(m_oBox->m_iXX, m_oBox->m_iYY)); + update_size(); + update(); +} + +void box_dot::update_size() +{ + setRect(0, 0, m_oBox->m_iWW, m_oBox->m_iHH); + m_oChain->setPos(m_oBox->m_iWW + 3, 0); +} + +QVariant box_dot::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) +{ + if (scene()) + { + if (i_oChange == ItemPositionChange) + { + QPointF np = i_oValue.toPointF(); + np.setX(((int) np.x() / GRID) * GRID); + np.setY(((int) np.y() / GRID) * GRID); + return np; + } + else if (i_oChange == ItemPositionHasChanged) + { + update_links(); + } + else if (i_oChange == ItemSelectedHasChanged) + { + m_oChain->setVisible(isSelected()); + if (isSelected()) + setZValue(101); + else + setZValue(100); + } + } + + return QGraphicsItem::itemChange(i_oChange, i_oValue); +} + +void box_dot::update_links() +{ + // FIXME + foreach (box_link* l_oLink, m_oView->m_oLinks) + { + l_oLink->update_pos(); + } +} + +int box_dot::choose_position(const QPointF& i_oP, int id) +{ + QRectF r = rect(); + QPointF l_o = pos() - i_oP + QPointF(r.width()/2, r.height()/2); + double c_x = l_o.x() * r.height(); + double c_y = l_o.y() * r.width(); + if (qAbs(c_x) > qAbs(c_y)) + { + return (c_x > 0) ? data_link::WEST : data_link::EAST; + } + else + { + return (c_y > 0) ? data_link::NORTH : data_link::SOUTH; + } + return data_link::NORTH; +} + +QPoint box_dot::get_point(int i_oP) +{ + QRectF r = rect(); + switch (i_oP & data_link::COORD) { + case data_link::NORTH: + return QPoint(r.x() + r.width() / 2., r.y()); + case data_link::WEST: + return QPoint(r.x(), r.y() + r.height() / 2); + case data_link::SOUTH: + return QPoint(r.x() + r.width()/2., r.y() + r.height()); + case data_link::EAST: + return QPoint(r.x() + r.width(), r.y() + r.height()/2.); + } + Q_ASSERT(false); + return QPoint(0, 0); +} + diff -Nru semantik-0.7.3/src/fig/box_dot.h semantik-0.8.3/src/fig/box_dot.h --- semantik-0.7.3/src/fig/box_dot.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_dot.h 2012-09-05 01:08:33.000000000 +0000 @@ -0,0 +1,50 @@ +// Thomas Nagy 2007-2012 GPLV3 + + +#ifndef BOX_DOT_H +#define BOX_DOT_H + +#include +#include +#include "CON.h" +#include "con.h" + +#define OFF 3 + +class QTextDocument; +class box_view; +class data_item; +class data_box; +class box_dot : public QGraphicsRectItem, public connectable +{ + public: + box_dot(box_view*, int i_iId); + ~box_dot(); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + + //QRectF boundingRect() const; + + QRectF rect() const { return boundingRect().translated(pos()).adjusted(JUST, JUST, -JUST, -JUST); }; + //void setRect(int, int, int, int) { } + + box_view *m_oView; + data_item *m_oItem; + + void mousePressEvent(QGraphicsSceneMouseEvent* e); + void mouseReleaseEvent(QGraphicsSceneMouseEvent* e); + //void keyPressEvent(QKeyEvent*); + //void keyReleaseEvent(QKeyEvent*); + + void update_data(); + void update_links(); + void update_size(); + + QVariant itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue); + int choose_position(const QPointF&p, int id=-1); + QPoint get_point(int position); + +}; + +#endif // BOX_DOT_H + diff -Nru semantik-0.7.3/src/fig/box_fork.cpp semantik-0.8.3/src/fig/box_fork.cpp --- semantik-0.7.3/src/fig/box_fork.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_fork.cpp 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,390 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_fork.h" +#include "data_item.h" + #include "res:zable.h" +#include "box_view.h" + #include "box_link.h" +#include "sem_mediator.h" +#include "mem_box.h" + + +#define PAD 2 +#define MIN_FORK_SIZE 30 + +box_fork::box_fork(box_view* i_oParent, int i_iId) : QGraphicsRectItem(), connectable(), resizable(), m_oView(i_oParent) +{ + m_iId = i_iId; + m_oItem = m_oView->m_oMediator->m_oItems[m_oView->m_iId]; + m_oBox = m_oItem->m_oBoxes[m_iId]; + Q_ASSERT(m_oBox); + + m_oChain = new box_chain(i_oParent); + m_oChain->setParentItem(this); + + i_oParent->scene()->addItem(this); + + setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + setZValue(100); + setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges); + + if (m_oBox->m_bIsVertical) + { + m_oTop = new box_resize_point(m_oView, this); + m_oTop->setRect(-CTRLSIZE/2., 0, CTRLSIZE, CTRLSIZE); + m_oTop->setCursor(Qt::SizeVerCursor); // FIXME if someone has a solution for this + m_oTop->hide(); + m_oDown = new box_resize_point(m_oView, this); + m_oDown->setRect(-CTRLSIZE/2., -CTRLSIZE, CTRLSIZE, CTRLSIZE); + m_oDown->setCursor(Qt::SizeVerCursor); + m_oDown->hide(); + m_oLeft = m_oRight = NULL; + } + else + { + m_oLeft = new box_resize_point(m_oView, this); + m_oLeft->setRect(0, -CTRLSIZE/2., CTRLSIZE, CTRLSIZE); + m_oLeft->setCursor(Qt::SizeHorCursor); + m_oLeft->hide(); + m_oRight = new box_resize_point(m_oView, this); + m_oRight->setRect(-CTRLSIZE, -CTRLSIZE/2., CTRLSIZE, CTRLSIZE); + m_oRight->setCursor(Qt::SizeHorCursor); + m_oRight->hide(); + m_oTop = m_oDown = NULL; + } + setRect(QRectF(0, 0, m_oBox->m_iWW, m_oBox->m_iHH)); +} + +box_fork::~box_fork() +{ + delete m_oTop; + delete m_oDown; + delete m_oLeft; + delete m_oRight; + delete m_oChain; +} + +void box_fork::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + if (isSelected()) l_oPen.setStyle(Qt::DotLine); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + painter->setBrush(m_oBox->color); + painter->drawRect(l_oRect); + + painter->restore(); +} + +void box_fork::mousePressEvent(QGraphicsSceneMouseEvent* e) { + setZValue(100); + QGraphicsRectItem::mousePressEvent(e); +} + +void box_fork::update_sizers() +{ + QPointF p = pos(); + if (m_oBox->m_bIsVertical) + { + m_oTop ->setPos(p.x() + m_oBox->m_iWW/2., p.y()); + m_oDown->setPos(p.x() + m_oBox->m_iWW/2., p.y() + m_oBox->m_iHH); + } + else + { + m_oLeft ->setPos(p.x() , p.y() + m_oBox->m_iHH / 2.); + m_oRight->setPos(p.x() + m_oBox->m_iWW, p.y() + m_oBox->m_iHH / 2.); + } +} + +void box_fork::mouseReleaseEvent(QGraphicsSceneMouseEvent* e) { + setZValue(99); + QGraphicsRectItem::mouseReleaseEvent(e); + update_sizers(); +} + +void box_fork::update_data() +{ + int ww = m_oBox->m_iWW; + int hh = m_oBox->m_iHH; + + setPos(QPointF(m_oBox->m_iXX, m_oBox->m_iYY)); + Q_ASSERT(ww < 9999 && ww > 0); + Q_ASSERT(hh < 9999 && hh > 0); + QRectF r = QRectF(0, 0, ww, hh); + setRect(r); + m_oChain->setPos(m_oBox->m_iWW + 3, 0); + + update_sizers(); +} + +QVariant box_fork::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) +{ + if (scene()) + { + if (i_oChange == ItemPositionChange) + { + QPointF np = i_oValue.toPointF(); + + /*if (m_oLeft && m_oLeft->m_bHeld) + { + //np.setX(m_oBox->m_iXX + m_oBox->m_iWW / 2.); + np.setY(m_oBox->m_iYY + m_oBox->m_iHH / 2.); + return np; + } + else if (m_oRight && m_oRight->m_bHeld) + { + //np.setX(m_oBox->m_iXX + m_oBox->m_iWW / 2.); + np.setY(m_oBox->m_iYY + m_oBox->m_iHH / 2.); + return np; + + } + else*/ + { + np.setX(((int) np.x() / GRID) * GRID); + np.setY(((int) np.y() / GRID) * GRID); + return np; + } + } + else if (i_oChange == ItemPositionHasChanged) + { + update_links(); + update_sizers(); + } + else if (i_oChange == ItemSelectedHasChanged) + { + bool b = isSelected(); + if (b) + { + setZValue(101); + } + else + { + setZValue(100); + } + + m_oChain->setVisible(isSelected()); + if (m_oLeft) m_oLeft->setVisible(b); + if (m_oRight) m_oRight->setVisible(b); + if (m_oTop) m_oTop->setVisible(b); + if (m_oDown) m_oDown->setVisible(b); + } + } + + return QGraphicsItem::itemChange(i_oChange, i_oValue); +} + +void box_fork::update_links() +{ + // FIXME + foreach (box_link* l_oLink, m_oView->m_oLinks) + { + l_oLink->update_pos(); + } +} + +static int RATIO[] = {250, 333, 500, 667, 750, 0}; + +int box_fork::choose_position(const QPointF& i_oP, int id) +{ + QRectF r = rect(); + QPointF l_o = pos() - i_oP + QPointF(r.width()/2, r.height()/2); + + double c_x = l_o.x() * r.height(); + double c_y = l_o.y() * r.width(); + + int ret = 0; + int best = 1<<30; + int cand = 0; + if (m_oBox->m_bIsVertical) + { + ret = (c_x > 0) ? data_link::WEST : data_link::EAST; + for (int i=0; i < 10; ++i) { + int k = RATIO[i]; + if (k == 0) break; + int val = qAbs((k * r.height() / 1000.) - (i_oP.y() - pos().y())); + + if (val < best) + { + best = val; + cand = k; + } + } + ret += cand * MUL; + } + else + { + ret = (c_y > 0) ? data_link::NORTH : data_link::SOUTH; + for (int i=0; i < 10; ++i) { + int k = RATIO[i]; + if (k == 0) break; + + int val = qAbs((k * r.width() / 1000.) - (i_oP.x() - pos().x())); + + if (val < best) + { + best = val; + cand = k; + } + } + ret += cand * MUL; + } + return ret; +} + +int round_point(int x) { + // Ugly + float y = x; + y = qRound(y / GRID); + int k = GRID * y; + return k; +}; + +QPoint box_fork::get_point(int i_oP) +{ + QRectF r = rect(); + int ratio = i_oP / MUL; + + if (ratio >= 1000 || ratio <= 0) ratio = 500; + switch (i_oP & data_link::COORD) { + case data_link::NORTH: + return QPoint(round_point(r.x() + r.width() * ratio / 1000.), r.y()); + case data_link::WEST: + return QPoint(r.x(), round_point(r.y() + r.height() * ratio / 1000.)); + case data_link::SOUTH: + return QPoint(round_point(r.x() + r.width() * ratio / 1000.), r.y() + r.height()); + case data_link::EAST: + return QPoint(r.x() + r.width(), round_point( r.y() + r.height() * ratio / 1000. )); + } + Q_ASSERT(false); + return QPoint(0, 0); +} + + +QPointF box_fork::validate_point(box_resize_point *p, const QPointF & orig) +{ + QPointF pf = QPointF(orig); + QSizeF s; + if (p == m_oTop) + { + pf.setX(m_oBox->m_iXX + m_oBox->m_iWW / 2.); + + m_iLastStretch = - pf.y() + m_oBox->m_iYY + m_oBox->m_iHH; + m_iLastStretch = GRID * (m_iLastStretch / GRID); + if (m_iLastStretch < MIN_FORK_SIZE) m_iLastStretch = MIN_FORK_SIZE; + pf.setY(m_oBox->m_iYY + m_oBox->m_iHH - m_iLastStretch); + setPos(m_oBox->m_iXX, pf.y()); + + s = QSizeF(FORK_WIDTH, m_iLastStretch); + m_oChain->setPos(FORK_WIDTH + 3, 0); + } + else if (p == m_oDown) + { + pf.setX(m_oBox->m_iXX + m_oBox->m_iWW / 2.); + + m_iLastStretch = pf.y() - m_oBox->m_iYY; + m_iLastStretch = GRID * (m_iLastStretch / GRID); + if (m_iLastStretch < MIN_FORK_SIZE) m_iLastStretch = MIN_FORK_SIZE; + pf.setY(m_oBox->m_iYY + m_iLastStretch); + + s = QSizeF(FORK_WIDTH, m_iLastStretch); + m_oChain->setPos(FORK_WIDTH + 3, 0); + } + else if (p == m_oLeft) + { + pf.setY(m_oBox->m_iYY + m_oBox->m_iHH / 2.); + + m_iLastStretch = - pf.x() + m_oBox->m_iXX + m_oBox->m_iWW; + m_iLastStretch = GRID * (m_iLastStretch / GRID); + if (m_iLastStretch < MIN_FORK_SIZE) m_iLastStretch = MIN_FORK_SIZE; + pf.setX(m_oBox->m_iXX + m_oBox->m_iWW - m_iLastStretch); + setPos(pf.x(), m_oBox->m_iYY); + + s = QSizeF(m_iLastStretch, FORK_WIDTH); + m_oChain->setPos(m_iLastStretch + 3, 0); + } + else if (p == m_oRight) + { + pf.setY(m_oBox->m_iYY + m_oBox->m_iHH / 2.); + m_iLastStretch = pf.x() - m_oBox->m_iXX; + m_iLastStretch = GRID * (m_iLastStretch / GRID); + if (m_iLastStretch < MIN_FORK_SIZE) m_iLastStretch = MIN_FORK_SIZE; + pf.setX(m_oBox->m_iXX + m_iLastStretch); + + s = QSizeF(m_iLastStretch, FORK_WIDTH); + m_oChain->setPos(m_iLastStretch + 3, 0); + } + setRect(QRectF(QPointF(0, 0), s)); + m_oView->message(m_oView->trUtf8("%1 x %2").arg(QString::number(s.width()), QString::number(s.height())), 1000); + return pf; +} + +void box_fork::commit_size(box_resize_point *p) +{ + QRect r_orig(m_oBox->m_iXX, m_oBox->m_iYY, m_oBox->m_iWW, m_oBox->m_iHH); + QRect r_dest; + + if (p == m_oTop) + { + r_dest.setX(m_oBox->m_iXX); + r_dest.setY(m_oBox->m_iYY + m_oBox->m_iHH - m_iLastStretch); + r_dest.setWidth(m_oBox->m_iWW); + r_dest.setHeight(m_iLastStretch); + } + else if (p == m_oDown) + { + r_dest.setX(m_oBox->m_iXX); + r_dest.setY(m_oBox->m_iYY); + r_dest.setWidth(m_oBox->m_iWW); + r_dest.setHeight(m_iLastStretch); + } + else if (p == m_oLeft) + { + r_dest.setX(m_oBox->m_iXX + m_oBox->m_iWW - m_iLastStretch); + r_dest.setY(m_oBox->m_iYY); + r_dest.setHeight(m_oBox->m_iHH); + r_dest.setWidth(m_iLastStretch); + } + else if (p == m_oRight) + { + r_dest.setX(m_oBox->m_iXX); + r_dest.setY(m_oBox->m_iYY); + r_dest.setHeight(m_oBox->m_iHH); + r_dest.setWidth(m_iLastStretch); + } + + mem_size_box *mem = new mem_size_box(m_oView->m_oMediator, m_oView->m_iId); + mem->prev_values[m_oBox] = r_orig; + mem->next_values[m_oBox] = r_dest; + mem->apply(); +} + +void box_fork::freeze(bool b) +{ + if (b) + { + setFlags(ItemIsSelectable); + m_iLastStretch = 0; + } + else + { + setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges); + } +} + diff -Nru semantik-0.7.3/src/fig/box_fork.h semantik-0.8.3/src/fig/box_fork.h --- semantik-0.7.3/src/fig/box_fork.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_fork.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,57 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_FORK_H +#define BOX_FORK_H + +#include +#include +#include "CON.h" +#include "res:zable.h" +#include "con.h" + +#define OFF 3 +#define FORK_LENGTH 160 +#define FORK_WIDTH 8 + +class QTextDocument; +class box_view; +class data_item; +class data_box; +class box_fork : public QGraphicsRectItem, public connectable, public resizable +{ + public: + box_fork(box_view*, int i_iId); + ~box_fork(); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + + QRectF rect() const { return boundingRect().translated(pos()).adjusted(JUST, JUST, -JUST, -JUST); }; + + box_view *m_oView; + data_item *m_oItem; + + void mousePressEvent(QGraphicsSceneMouseEvent* e); + void mouseReleaseEvent(QGraphicsSceneMouseEvent* e); + + void update_data(); + void update_links(); + + box_resize_point *m_oTop; + box_resize_point *m_oDown; + box_resize_point *m_oLeft; + box_resize_point *m_oRight; + + QVariant itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue); + int choose_position(const QPointF&p, int id=-1); + QPoint get_point(int position); + + void update_sizers(); + + int m_iLastStretch; + QPointF validate_point(box_resize_point *p, const QPointF & orig); + void freeze(bool b); + void commit_size(box_resize_point *p); +}; + +#endif // BOX_FORK_H + diff -Nru semantik-0.7.3/src/fig/box_item.cpp semantik-0.8.3/src/fig/box_item.cpp --- semantik-0.7.3/src/fig/box_item.cpp 2009-08-30 11:35:31.000000000 +0000 +++ semantik-0.8.3/src/fig/box_item.cpp 2012-10-21 10:09:14.000000000 +0000 @@ -1,510 +1,306 @@ -// Thomas Nagy 2007-2009 GPLV3 - +// Thomas Nagy 2007-2012 GPLV3 #include #include +#include #include #include #include #include +#include +#include #include #include #include +#include #include #include "box_item.h" #include "box_view.h" + #include "box_link.h" +#include "data_item.h" +#include "sem_mediator.h" +#include "mem_box.h" + +#define PAD 2 -box_item::box_item(box_view* i_oParent) : QGraphicsRectItem() +box_item::box_item(box_view* i_oParent, int i_iId) : QGraphicsRectItem(), connectable(), editable(), m_oView(i_oParent) { - m_oControl = i_oParent; - m_oDoc = new QTextDocument(); - m_oCursor = new QTextCursor(m_oDoc); - m_bEdit = false; - - QTextOption l_oOpt; -#if QT_VERSION >= 0x040290 - l_oOpt.setWrapMode(QTextOption::WordWrap); -#endif - l_oOpt.setAlignment(Qt::AlignCenter); - m_oDoc->setDefaultTextOption(l_oOpt); + m_iId = i_iId; + m_bMoving = false; - m_iId = i_oParent->next_id(); + m_oItem = m_oView->m_oMediator->m_oItems[m_oView->m_iId]; + m_oBox = m_oItem->m_oBoxes[m_iId]; + Q_ASSERT(m_oBox); - setBrush(QColor(170, 170, 255)); i_oParent->scene()->addItem(this); + m_oChain = new box_chain(i_oParent); + m_oChain->setParentItem(this); + + setCacheMode(QGraphicsItem::DeviceCoordinateCache); - setZValue(64); + update_size(); + setZValue(100); + setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges); } box_item::~box_item() { - + delete m_oChain; } -bool box_item::moveKey(QKeyEvent* i_oEv) +void box_item::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - //const QTextCursor oldSelection = cursor; - //const int oldCursorPos = m_oCursor->position(); + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); - QTextCursor::MoveMode mode = QTextCursor::MoveAnchor; - QTextCursor::MoveOperation op = QTextCursor::NoMove; - if (i_oEv == QKeySequence::SelectAll) - { - m_oCursor->select(QTextCursor::Document); - return true; - } - if (i_oEv == QKeySequence::MoveToNextChar) - { - op = QTextCursor::Right; - } - else if (i_oEv == QKeySequence::MoveToPreviousChar) - { - op = QTextCursor::Left; - } - else if (i_oEv == QKeySequence::SelectNextChar) - { - op = QTextCursor::Right; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectPreviousChar) - { - op = QTextCursor::Left; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectNextWord) - { - op = QTextCursor::WordRight; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectPreviousWord) - { - op = QTextCursor::WordLeft; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectStartOfLine) - { - op = QTextCursor::StartOfLine; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectEndOfLine) - { - op = QTextCursor::EndOfLine; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectStartOfBlock) - { - op = QTextCursor::StartOfBlock; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectEndOfBlock) - { - op = QTextCursor::EndOfBlock; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectStartOfDocument) - { - op = QTextCursor::Start; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectEndOfDocument) - { - op = QTextCursor::End; - mode = QTextCursor::KeepAnchor; - } - else if (i_oEv == QKeySequence::SelectPreviousLine) - { - op = QTextCursor::Up; - mode = QTextCursor::KeepAnchor; - } -#if 0 - else if (e == QKeySequence::SelectNextLine) { - op = QTextCursor::Down; - mode = QTextCursor::KeepAnchor; - { - QTextBlock block = cursor.block(); - QTextLine line = currentTextLine(cursor); - if (!block.next().isValid() - && line.isValid() - && line.lineNumber() == block.layout()->lineCount() - 1) - op = QTextCursor::End; - } - } - else if (e == QKeySequence::SelectNextLine) { - op = QTextCursor::Down; - mode = QTextCursor::KeepAnchor; - { - QTextBlock block = cursor.block(); - QTextLine line = currentTextLine(cursor); - if (!block.next().isValid() - && line.isValid() - && line.lineNumber() == block.layout()->lineCount() - 1) - op = QTextCursor::End; - } - } -#endif - else if (i_oEv == QKeySequence::MoveToNextWord) - { - op = QTextCursor::WordRight; - } - else if (i_oEv == QKeySequence::MoveToPreviousWord) - { - op = QTextCursor::WordLeft; - } - else if (i_oEv == QKeySequence::MoveToEndOfBlock) - { - op = QTextCursor::EndOfBlock; - } - else if (i_oEv == QKeySequence::MoveToStartOfBlock) - { - op = QTextCursor::StartOfBlock; - } - else if (i_oEv == QKeySequence::MoveToNextLine) - { - op = QTextCursor::Down; - } - else if (i_oEv == QKeySequence::MoveToPreviousLine) - { - op = QTextCursor::Up; - } - else if (i_oEv == QKeySequence::MoveToPreviousLine) - { - op = QTextCursor::Up; - } - else if (i_oEv == QKeySequence::MoveToStartOfLine) - { - op = QTextCursor::StartOfLine; - } - else if (i_oEv == QKeySequence::MoveToEndOfLine) - { - op = QTextCursor::EndOfLine; - } - else if (i_oEv == QKeySequence::MoveToStartOfDocument) - { - op = QTextCursor::Start; - } - else if (i_oEv == QKeySequence::MoveToEndOfDocument) + QPen l_oPen = QPen(Qt::SolidLine); + + l_oPen.setColor(Qt::black); + if (isSelected()) l_oPen.setStyle(Qt::DotLine); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + + painter->setPen(l_oPen); + + QColor bc(m_oBox->color); + if (m_oView->m_bDisableGradient) { - op = QTextCursor::End; + painter->setBrush(bc); } else { - return false; + QLinearGradient linearGradient(0, 0, l_oRect.width(), 0); + linearGradient.setColorAt(0.0, bc); + linearGradient.setColorAt(1.0, bc.darker(GRADVAL)); + painter->setBrush(linearGradient); } - /*const bool moved =*/ m_oCursor->movePosition(op, mode); -#if 0 - //m_oCursor->ensureCursorVisible(); - if (moved) - { - if (m_oCursor->position() != oldCursorPos) - emit q->cursorPositionChanged(); - emit q->microFocusChanged(); - } -#endif + painter->drawRoundRect(l_oRect, 20, 20); + if (isSelected()) + { + l_oPen.setStyle(Qt::SolidLine); + painter->setPen(l_oPen); + painter->setBrush(QColor("#FFFF00")); + QRectF l_oR2(m_iWW - 8, m_iHH - 8, 6, 6); + painter->drawRect(l_oR2); + + /*painter->setBrush(Qt::green); + l_oR2.setY(PAD); + l_oR2.setHeight(6); + painter->drawRect(l_oR2);*/ + } - return true; -} + QAbstractTextDocumentLayout::PaintContext ctx; + ctx.palette = QApplication::palette("QTextControl"); + QAbstractTextDocumentLayout * lay = doc.documentLayout(); + qreal yoff = lay->documentSize().height(); + painter->translate(OFF, OFF + (m_iHH - 2 * OFF - yoff) / 2.); + lay->draw(painter, ctx); +} -void box_item::keyPressEvent(QKeyEvent* i_oEv) +void box_item::mousePressEvent(QGraphicsSceneMouseEvent* e) { - // imitates qt - - if (moveKey(i_oEv)) goto accept; - - if (i_oEv->key() == Qt::Key_Backspace && !i_oEv->modifiers()) + m_oLastPressPoint = e->pos(); + if (m_oLastPressPoint.x() > m_iWW - GRID && m_oLastPressPoint.y() > m_iHH - GRID ) { - QTextBlockFormat blockFmt = m_oCursor->blockFormat(); - QTextList *list = m_oCursor->currentList(); - if (list && m_oCursor->atBlockStart()) - { - list->remove(m_oCursor->block()); - } - else if (m_oCursor->atBlockStart() && blockFmt.indent() > 0) - { - blockFmt.setIndent(blockFmt.indent() - 1); - m_oCursor->setBlockFormat(blockFmt); - } - else - { - m_oCursor->deletePreviousChar(); - } - goto accept; + setFlags(ItemIsSelectable | ItemSendsGeometryChanges); + m_bMoving = true; } + QGraphicsRectItem::mousePressEvent(e); +} - if (i_oEv == QKeySequence::Undo) - { - m_oDoc->undo(); - } - else if (i_oEv == QKeySequence::Redo) - { - m_oDoc->redo(); - } - else if (i_oEv == QKeySequence::Copy) - { - //TODO - } - else if (i_oEv == QKeySequence::Cut) - { -#if 0 - const QTextDocumentFragment fragment(*m_oCursor); - QMimeData *data = new QTextEditMimeData(fragment); - QApplication::clipboard()->setMimeData(data); - m_oCursor->removeSelectedText(); -#endif - } - else if (i_oEv == QKeySequence::Paste) - { - const QMimeData *source = QApplication::clipboard()->mimeData(); - if (source) - { - QString text = source->text(); - if (!text.isNull()) - { - m_oCursor->insertFragment( QTextDocumentFragment::fromPlainText(text) ); - } - } - } - else if (i_oEv == QKeySequence::Delete) - { - m_oCursor->deleteChar(); - } - else if (i_oEv == QKeySequence::DeleteEndOfWord) - { - m_oCursor->movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); - m_oCursor->deleteChar(); - } - else if (i_oEv == QKeySequence::DeleteStartOfWord) - { - m_oCursor->movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor); - m_oCursor->deleteChar(); - } -#if 0 - else if (i_oEv == QKeySequence::DeleteEndOfLine) +void box_item::mouseMoveEvent(QGraphicsSceneMouseEvent *e) +{ + if (m_bMoving) { - QTextBlock block = cursor.block(); - if (cursor.position() == block.position() + block.length() - 2) - cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor); - else - cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); - cursor.deleteChar(); + QPointF np = e->pos(); + int x = np.x() - m_oLastPressPoint.x(); + int y = np.y() - m_oLastPressPoint.y(); + + m_iWW = m_oBox->m_iWW + x; + if (m_iWW < 2 * GRID) m_iWW = 2 * GRID; + m_iWW = grid_int(m_iWW); + + m_iHH = m_oBox->m_iHH + y; + if (m_iHH < 2 * GRID) m_iHH = 2 * GRID; + m_iHH = grid_int(m_iHH); + + doc.setTextWidth(m_iWW - 2 * OFF); + setRect(0, 0, m_iWW, m_iHH); + m_oChain->setPos(m_iWW + 3, 0); + + m_oView->message(m_oView->trUtf8("%1 x %2").arg(QString::number(m_iWW), QString::number(m_iHH)), 1000); + + update(); + update_links(); } -#endif else { - goto process; + QGraphicsRectItem::mouseMoveEvent(e); } - goto accept; +} - process: +void box_item::mouseReleaseEvent(QGraphicsSceneMouseEvent* e) { + if (m_bMoving) { - bool overwriteMode = false; - QString text = i_oEv->text(); - if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) - { - if (overwriteMode && !m_oCursor->hasSelection() && !m_oCursor->atBlockEnd()) - m_oCursor->deleteChar(); + m_bMoving = false; + setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges); - m_oCursor->insertText(text); - //selectionChanged(); - } - else + if (m_iWW != m_oBox->m_iWW || m_iHH != m_oBox->m_iHH) { - i_oEv->ignore(); - return; + mem_size_box *mem = new mem_size_box(m_oView->m_oMediator, m_oView->m_iId); + mem->prev_values[m_oBox] = QRect(m_oBox->m_iXX, m_oBox->m_iYY, m_oBox->m_iWW, m_oBox->m_iHH); + mem->next_values[m_oBox] = QRect(m_oBox->m_iXX, m_oBox->m_iYY, m_iWW, m_iHH); + mem->apply(); } } - -accept: - - i_oEv->accept(); - - //FIXME adjustSize(); - update(); - - //QGraphicsTextItem::keyPressEvent(i_oEv); - //FIXME update_links(); -} - -void box_item::keyReleaseEvent(QKeyEvent* i_oEv) -{ - //ensureCursorVisible(); - //m_oCursor->movePosition(QTextCursor::End); - - if (i_oEv->key() == Qt::Key_Enter || i_oEv->key() == Qt::Key_Return) + else { - return; + QGraphicsRectItem::mouseReleaseEvent(e); } - //QGraphicsTextItem::keyReleaseEvent(i_oEv); } -void box_item::focus_in() -{ - if (m_oDoc->toPlainText() == QObject::trUtf8("Empty")) m_oDoc->setPlainText(""); - m_bEdit = true; - //FIXME m_oColorBackup = m_oColor; - //FIXME m_oColor = s_oColorSelect; - //QKeyEvent l_oKeyEvent = QKeyEvent(QEvent::KeyPress, Qt::Key_End, Qt::NoModifier); - //keyPressEvent(&l_oKeyEvent); +void box_item::update_data() { + setPos(QPointF(m_oBox->m_iXX, m_oBox->m_iYY)); + if (m_oBox->m_iWW != m_iWW || m_oBox->m_iHH != m_iHH || doc.toPlainText() != m_oBox->m_sText) + { + update_size(); + } update(); } -void box_item::focus_out(QFocusEvent *i_oEv) -{ - if (!m_bEdit) return; +void box_item::update_size() { + m_iWW = m_oBox->m_iWW; + m_iHH = m_oBox->m_iHH; - // FIXME m_oColor = m_oColorBackup; - m_bEdit = false; + doc.setHtml(QString("
    %1
    ").arg(m_oBox->m_sText)); + doc.setTextWidth(m_iWW - 2 * OFF); - if (m_oDoc->toPlainText().isEmpty()) m_oDoc->setPlainText(QObject::trUtf8("Empty")); - //FIXME m_oGraph->m_oControl->m_oItems.value(Id())->m_sSummary = m_oDoc->toPlainText(); - //FIXME m_oGraph->m_oControl->update_item(Id(), view_canvas); - - //QGraphicsTextItem::focusOutEvent(i_oEv); - //FIXME adjustSize(); - //FIXME update_links(); - update(); + setRect(0, 0, m_iWW, m_iHH); + m_oChain->setPos(m_iWW + 3, 0); + + update_links(); } -void box_item::paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *option, QWidget * i_oW) +void box_item::properties() { - //QGraphicsRectItem::paint(i_oPainter, option, i_oW); - QPen l_oPen = QPen(Qt::SolidLine); - l_oPen.setColor(QColor(Qt::black)); - l_oPen.setWidth(1); - if (m_oControl->m_oSelected.contains(this)) l_oPen.setWidth(2); - i_oPainter->setPen(l_oPen); - - QRectF l_oB = boundingRect(); - - qreal w = l_oPen.width()/2.; - QRectF l_oRect = l_oB.adjusted(w, w, -w, -w); - - if (m_bEdit) i_oPainter->setBrush(QColor(255, 255, 255)); - else i_oPainter->setBrush(brush()); - - - i_oPainter->drawRoundRect(l_oRect, 20, 20); - if (m_oControl->m_oSelected.contains(this) and m_oControl->m_oSelected.size() == 1) + bool ok = false; + QString text = KInputDialog::getText(m_oView->trUtf8("Properties for diagram box"), + m_oView->trUtf8("Text:"), m_oBox->m_sText, &ok); + if (ok && text != m_oBox->m_sText) { - QPointF l_oOffset(3, 3); - i_oPainter->save(); + mem_edit_box *ed = new mem_edit_box(m_oView->m_oMediator, m_oView->m_iId, m_iId); + ed->newText = text; - QPen l_oPen = i_oPainter->pen(); - l_oPen.setWidth(1); - i_oPainter->setPen(l_oPen); + QTextDocument doc; + doc.setHtml(QString("
    %1
    ").arg(text)); + doc.setTextWidth(m_oBox->m_iWW - 2 * OFF); + ed->newHeight = GRID * (((int) (doc.size().height() + 2 * OFF + GRID - 1)) / GRID); + if (ed->newHeight < m_oBox->m_iHH) + ed->newHeight = m_oBox->m_iHH; - i_oPainter->setBrush(QColor(255, 255, 0)); - QPointF l_o = l_oRect.bottomRight(); - i_oPainter->drawEllipse(QRectF(l_o - 2*l_oOffset, l_o)); - i_oPainter->restore(); + ed->apply(); } +} - - i_oPainter->save(); - - - // previously l_oRect - m_oDoc->setTextWidth(l_oB.width() - 14.); - i_oPainter->translate( - (l_oB.width() - m_oDoc->documentLayout()->documentSize().width()) / 2, - (l_oB.height() - m_oDoc->documentLayout()->documentSize().height()) / 2); - - QAbstractTextDocumentLayout::PaintContext ctx; - ctx.palette = QApplication::palette("QTextControl"); - - if (m_bEdit) +QVariant box_item::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) +{ + if (scene()) { - ctx.cursorPosition = m_oCursor->position(); - if (m_oCursor->hasSelection()) + if (i_oChange == ItemPositionChange) { - QAbstractTextDocumentLayout::Selection selection; - selection.cursor = *m_oCursor; - QPalette::ColorGroup cg = QPalette::Active; - selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight)); - selection.format.setForeground(ctx.palette.brush(cg, QPalette::HighlightedText)); - ctx.selections.append(selection); + QPointF np = i_oValue.toPointF(); + np.setX(((int) np.x() / GRID) * GRID); + np.setY(((int) np.y() / GRID) * GRID); + return np; + } + else if (i_oChange == ItemPositionHasChanged) + { + update_links(); + } + else if (i_oChange == ItemSelectedHasChanged) + { + m_oChain->setVisible(isSelected()); } - } - else - { - ctx.cursorPosition = -1; } - m_oDoc->documentLayout()->draw(i_oPainter, ctx); - //m_oDoc->drawContents(i_oPainter); - i_oPainter->restore(); + return QGraphicsItem::itemChange(i_oChange, i_oValue); } -void box_item::set_pos(QPointF i_oP) +void box_item::update_links() { - set_pos(i_oP.x(), i_oP.y()); + // FIXME + foreach (box_link* l_oLink, m_oView->m_oLinks) + { + l_oLink->update_pos(); + } } -void box_item::set_pos(qreal i_iXX, qreal i_iYY) -{ - m_iXX = i_iXX; - m_iYY = i_iYY; - qreal l_iXX = GRID_VALUE * (int) (i_iXX / GRID_VALUE); - qreal l_iYY = GRID_VALUE * (int) (i_iYY / GRID_VALUE); - QGraphicsRectItem::setPos(l_iXX, l_iYY); -} +static int RATIO[] = {333, 500, 667, 0}; -void box_item::move_by(qreal i_iXX, qreal i_iYY) +int box_item::choose_position(const QPointF& i_oP, int id) { - set_pos(m_iXX + i_iXX, m_iYY + i_iYY); -} + QRectF r = rect(); + QPointF l_o = pos() - i_oP + QPointF(r.width()/2, r.height()/2); + double c_x = l_o.x() * r.height(); + double c_y = l_o.y() * r.width(); -void box_item::inputMethodEvent(QInputMethodEvent *e) -{ - // TODO this is copied from qt - if (!m_bEdit) + int ret = 0; + int best = 1<<30; + int cand = 0; + if (qAbs(c_x) > qAbs(c_y)) { - e->ignore(); - return; + ret = (c_x > 0) ? data_link::WEST : data_link::EAST; + for (int i=0; i < 10; ++i) { + int k = RATIO[i]; + if (k == 0) break; + int val = qAbs((k * r.height() / 1000.) - (i_oP.y() - pos().y())); + + if (val < best) + { + best = val; + cand = k; + } + } + ret += cand * MUL; } - m_oCursor->beginEditBlock(); - m_oCursor->removeSelectedText(); + else + { + ret = (c_y > 0) ? data_link::NORTH : data_link::SOUTH; + for (int i=0; i < 10; ++i) { + int k = RATIO[i]; + if (k == 0) break; + int val = qAbs((k * r.width() / 1000.) - (i_oP.x() - pos().x())); - if (!e->commitString().isEmpty() || e->replacementLength()) - { - QTextCursor c = *m_oCursor; - c.setPosition(c.position() + e->replacementStart()); - c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor); - c.insertText(e->commitString()); - } - - QTextBlock block = m_oCursor->block(); - QTextLayout *layout = block.layout(); - //layout->setPreeditArea(m_oCursor->position() - block.position(), e->preeditString()); - QList overrides; - //preeditCursor = e->preeditString().length(); - //hideCursor = false; - for (int i = 0; i < e->attributes().size(); ++i) - { - const QInputMethodEvent::Attribute &a = e->attributes().at(i); - ///*if (a.type == QInputMethodEvent::Cursor) { - // preeditCursor = a.start; - // //hideCursor = !a.length; - //} else*/ - if (a.type == QInputMethodEvent::TextFormat) - { - QTextCharFormat f = qvariant_cast(a.value).toCharFormat(); - if (f.isValid()) + if (val < best) { - QTextLayout::FormatRange o; - o.start = a.start + m_oCursor->position() - block.position(); - o.length = a.length; - o.format = f; - overrides.append(o); + best = val; + cand = k; } } + ret += cand * MUL; } - layout->setAdditionalFormats(overrides); - m_oCursor->endEditBlock(); + return ret; +} - //adjustSize(); - update(); +QPoint box_item::get_point(int i_oP) +{ + QRectF r = rect(); + int ratio = i_oP / MUL; + + if (ratio >= 1000 || ratio <= 0) ratio = 500; + switch (i_oP & data_link::COORD) { + case data_link::NORTH: + return QPoint(r.x() + r.width() * ratio / 1000., r.y()); + case data_link::WEST: + return QPoint(r.x(), r.y() + r.height() * ratio / 1000.); + case data_link::SOUTH: + return QPoint(r.x() + r.width() * ratio / 1000., r.y() + r.height()); + case data_link::EAST: + return QPoint(r.x() + r.width(), r.y() + r.height() * ratio / 1000.); + } + Q_ASSERT(false); + return QPoint(0, 0); } diff -Nru semantik-0.7.3/src/fig/box_item.h semantik-0.8.3/src/fig/box_item.h --- semantik-0.7.3/src/fig/box_item.h 2009-08-30 11:35:31.000000000 +0000 +++ semantik-0.8.3/src/fig/box_item.h 2012-10-21 10:09:14.000000000 +0000 @@ -1,45 +1,60 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef BOX_ITEM_H #define BOX_ITEM_H #include +#include +#include +#include "res:zable.h" +#include "ed:table.h" +#include "box_resize_point.h" +#include "box_chain.h" +#include "CON.h" #include "con.h" +#define OFF 3 + class QTextDocument; class box_view; -class box_item : public QGraphicsRectItem +class data_item; +class data_box; +class box_item : public QGraphicsRectItem, public connectable, public editable { public: - box_item(box_view*); + box_item(box_view*, int i_iId); ~box_item(); - int type() const { return gratype(37); } - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); - QTextDocument *m_oDoc; - QTextCursor *m_oCursor; - bool m_bEdit; - qreal m_iXX; - qreal m_iYY; + QRectF rect() const { return boundingRect().translated(pos()).adjusted(JUST, JUST, -JUST, -JUST); }; + //void setRect(int, int, int, int) { } + + QTextDocument doc; + + box_view *m_oView; + data_item *m_oItem; + + void mousePressEvent(QGraphicsSceneMouseEvent* e); + void mouseMoveEvent(QGraphicsSceneMouseEvent *e); + void mouseReleaseEvent(QGraphicsSceneMouseEvent* e); + void properties(); - void move_by(qreal, qreal); - void set_pos(QPointF i_oP); - void set_pos(qreal i_iXX, qreal i_iYY); + void update_data(); + void update_size(); + void update_links(); - int m_iId; + QVariant itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue); - box_view *m_oControl; + int choose_position(const QPointF&p, int id=-1); + QPoint get_point(int position); + QPointF m_oLastPressPoint; - void focus_out(QFocusEvent*); - void focus_in(); + int m_iWW; + int m_iHH; + bool m_bMoving; - void keyPressEvent(QKeyEvent* i_oEv); - bool moveKey(QKeyEvent* i_oEv); - void keyReleaseEvent(QKeyEvent *i_oEv); - void inputMethodEvent(QInputMethodEvent *); }; #endif // BOX_ITEM_H diff -Nru semantik-0.7.3/src/fig/box_label.cpp semantik-0.8.3/src/fig/box_label.cpp --- semantik-0.7.3/src/fig/box_label.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_label.cpp 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,81 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_label.h" +#include "data_item.h" + #include "res:zable.h" +#include "box_view.h" + #include "box_link.h" +#include "sem_mediator.h" +#include "mem_box.h" + +#include + +#define PAD 2 +#define MIN_FORK_SIZE 30 + +box_label::box_label(box_view* view, int id) : box_item(view, id) +{ + QFont font = doc.defaultFont(); + font.setPointSize(font.pointSize() - 2); + doc.setDefaultFont(font); +} + +void box_label::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + if (isSelected()) + { + QPen l_oPen = QPen(Qt::DotLine); + l_oPen.setColor(Qt::black); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + painter->setPen(l_oPen); + painter->drawRoundRect(l_oRect, 20, 20); + + l_oPen.setStyle(Qt::SolidLine); + painter->setPen(l_oPen); + painter->setBrush(QColor("#FFFF00")); + QRectF l_oR2(m_iWW - 8, m_iHH - 8, 6, 6); + painter->drawRect(l_oR2); + } + + painter->translate(OFF, OFF); + QAbstractTextDocumentLayout::PaintContext ctx; + ctx.palette = QApplication::palette("QTextControl"); + doc.documentLayout()->draw(painter, ctx); + + painter->restore(); +} + +QVariant box_label::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) +{ + if (scene()) + { + if (i_oChange == ItemPositionHasChanged) + { + update_links(); + } + else if (i_oChange == ItemSelectedHasChanged) + { + m_oChain->setVisible(isSelected()); + } + } + + return QGraphicsItem::itemChange(i_oChange, i_oValue); +} + + diff -Nru semantik-0.7.3/src/fig/box_label.h semantik-0.8.3/src/fig/box_label.h --- semantik-0.7.3/src/fig/box_label.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_label.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,25 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_LABEL_H +#define BOX_LABEL_H + +#include +#include +#include "res:zable.h" +#include "ed:table.h" +#include "box_item.h" +#include "CON.h" +#include "con.h" + +#define OFF 3 + +class box_label : public box_item +{ + public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + box_label(box_view*, int i_iId); + QVariant itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue); +}; + +#endif // BOX_LABEL_H + diff -Nru semantik-0.7.3/src/fig/box_link.cpp semantik-0.8.3/src/fig/box_link.cpp --- semantik-0.7.3/src/fig/box_link.cpp 2009-08-30 11:35:31.000000000 +0000 +++ semantik-0.8.3/src/fig/box_link.cpp 2012-10-21 10:09:14.000000000 +0000 @@ -1,292 +1,375 @@ -// Thomas Nagy 2007-2009 GPLV3 - +// Thomas Nagy 2007-2012 GPLV3 #include #include +#include +#include #include +#include +#include +#include "CON.h" #include "box_link.h" #include "box_view.h" -#include "box_item.h" +#include "data_item.h" +#include "mem_box.h" +#include +#include +#include "box_link_properties.h" #define pad 25 +#define MAX 2000000000 +#define DAMP 1000000 -box_link::box_link(box_view* i_oParent) : QGraphicsRectItem() +box_link::box_link(box_view* i_oParent) : QGraphicsRectItem(), editable() { - m_bSel = false; - /*setBrush(QColor(0, 255, 0, 160)); - setPen(QColor(Qt::black));*/ - - m_iId = i_oParent->next_id(); + m_oInnerLink.m_iParentPos = 0; + m_oInnerLink.m_iChildPos = 0; - QPen l_oPen; - l_oPen.setWidth(1); - l_oPen.setColor(QColor(Qt::black)); - setPen(l_oPen); + m_oView = i_oParent; - setBrush(QColor(Qt::black)); + m_oLink = NULL; i_oParent->scene()->addItem(this); - setZValue(60); + setZValue(98); - m_iParent = 0; - m_iChild = 0; + setFlags(ItemIsSelectable); + m_bReentrantLock = false; - m_oParent = NULL; - m_oChild = NULL; - m_oView = i_oParent; - - // control segment: used to resize the segments - m_iControlSegment = 0; + m_oStartPoint = new box_control_point(m_oView); + m_oStartPoint->hide(); + m_oStartPoint->m_bIsSegment = false; + m_oStartPoint->m_oLink = this; + + m_oEndPoint = new box_control_point(m_oView); + m_oEndPoint->hide(); + m_oEndPoint->m_bIsSegment = false; + m_oEndPoint->m_oLink = this; + m_oEndPoint->setZValue(117); + + for (int i=0; i < 7; ++i) + { + box_control_point* b = new box_control_point(m_oView); + b->hide(); + b->m_oLink = this; + b->m_iOffset = i; + m_oControlPoints.append(b); + } } box_link::~box_link() { - + foreach (box_control_point *b, m_oControlPoints) { + delete b; + } + delete m_oStartPoint; + delete m_oEndPoint; } +#define xw 3. +#define yw 8. + void box_link::paint(QPainter *i_oPainter, const QStyleOptionGraphicsItem *option, QWidget * i_oW) { - //i_oPainter->setPen(pen()); - //QGraphicsRectItem::paint(i_oPainter, option, i_oW); + i_oPainter->setBrush(m_oInnerLink.color); - i_oPainter->setPen(pen()); - i_oPainter->setBrush(brush()); + QPen l_oPen(m_oInnerLink.pen_style); + l_oPen.setWidth(m_oInnerLink.border_width); + l_oPen.setColor(m_oInnerLink.color); + i_oPainter->setPen(l_oPen); - for (int i=0; idrawLine(l_oLine); - //qDebug()<setPen(l_oPen); - //draw_triangle(i_oPainter, m_iParent, m_oGood[0]); - draw_triangle(i_oPainter, m_iChild, m_oGood[m_oGood.size()-1]); - - l_oPen.setWidth(1); - i_oPainter->setPen(l_oPen); + qreal dx = m_oGood[last].x() - m_oGood[0].x(); + qreal dy = m_oGood[last].y() - m_oGood[0].y(); + qreal tot = sqrt(dx * dx + dy * dy); + if (tot > 0.01) + { + l_oPen.setStyle(Qt::SolidLine); + i_oPainter->setPen(l_oPen); + + qreal sinphi = dy / tot; + qreal cosphi = dx / tot; + QPolygonF l_oPol(3); - QPointF l_oOffset(3, 3); - if (!m_oParent && m_oChild) - { - i_oPainter->setBrush(QColor(255, 255, 0)); - QPointF l_o = m_oGood[m_oGood.size()-1]; - i_oPainter->drawEllipse(QRectF(l_o + l_oOffset, l_o - l_oOffset)); - box_item *l_oUnder = NULL; - foreach (QGraphicsItem *l_oI1, scene()->items(m_oView->m_oLastMovePoint)) - { - if (l_oI1->type() == gratype(37)) + if (m_oInnerLink.m_iLeftArrow) { - l_oUnder = (box_item*) l_oI1; - break; + l_oPol[0] = m_oGood[0]; + l_oPol[1] = m_oGood[0] + QPointF(yw * cosphi - xw * sinphi, yw * sinphi + xw * cosphi); + l_oPol[2] = m_oGood[0] + QPointF(yw * cosphi + xw * sinphi, yw * sinphi - xw * cosphi); + i_oPainter->drawPolygon(l_oPol); } - } - if (l_oUnder) - { - l_o = m_oGood[0]; - i_oPainter->drawEllipse(QRectF(l_o + l_oOffset, l_o - l_oOffset)); - } - } - else if (!m_oChild && m_oParent) - { - i_oPainter->setBrush(QColor(255, 255, 0)); - QPointF l_o = m_oGood[0]; - i_oPainter->drawEllipse(QRectF(l_o + l_oOffset, l_o - l_oOffset)); - box_item *l_oUnder = NULL; - foreach (QGraphicsItem *l_oI1, scene()->items(m_oView->m_oLastMovePoint)) - { - if (l_oI1->type() == gratype(37)) + if (m_oInnerLink.m_iRightArrow) { - l_oUnder = (box_item*) l_oI1; - break; + l_oPol[0] = m_oGood[last]; + l_oPol[1] = m_oGood[last] + QPointF( - yw * cosphi + xw * sinphi, - yw * sinphi - xw * cosphi); + l_oPol[2] = m_oGood[last] + QPointF( - yw * cosphi - xw * sinphi, - yw * sinphi + xw * cosphi); + i_oPainter->drawPolygon(l_oPol); } } - if (l_oUnder) - { - l_o = m_oGood[m_oGood.size()-1]; - i_oPainter->drawEllipse(QRectF(l_o + l_oOffset, l_o - l_oOffset)); - } } - else if (m_oChild && m_oParent && m_oParent->m_oControl->m_oSelected.contains(this)) + else { - // if the link is selected - i_oPainter->setBrush(QColor(255, 255, 0)); - QPointF l_o = m_oGood[0]; - i_oPainter->drawEllipse(QRectF(l_o + l_oOffset, l_o - l_oOffset)); - l_o = m_oGood[m_oGood.size()-1]; - i_oPainter->drawEllipse(QRectF(l_o + l_oOffset, l_o - l_oOffset)); - - // show the control points on all the segments except the borders - for (int i=1; idrawEllipse(QRectF(l_o + l_oOffset, l_o - l_oOffset)); + QLineF l_oLine(m_oGood[i].x(), m_oGood[i].y(), m_oGood[i+1].x(), m_oGood[i+1].y()); + i_oPainter->drawLine(l_oLine); } + + l_oPen.setStyle(Qt::SolidLine); + i_oPainter->setPen(l_oPen); + if (m_oInnerLink.m_iRightArrow) + draw_triangle(i_oPainter, m_oInnerLink.m_iChildPos, m_oGood[m_oGood.size()-1]); + if (m_oInnerLink.m_iLeftArrow) + draw_triangle(i_oPainter, m_oInnerLink.m_iParentPos, m_oGood[0]); } } - -#define xw 3. -#define yw 8. - void box_link::draw_triangle(QPainter *i_oPainter, int i_iPos, QPointF i_oP) { QPolygonF l_oPol; l_oPol<drawPolygon(l_oPol); } -extern "C" +void box_link::set_rectangles(int ax1, int ax2, int ay1, int ay2, int ap, QPoint& apos, int bx1, int bx2, int by1, int by2, int bp, QPoint& bpos) { -int get_vertex_x(int pos); -int get_vertex_y(int pos); -int num_seg(); -void set_rectangles(int ax1, int ax2, int ay1, int ay2, int ap, int bx1, int bx2, int by1, int by2, int bp); -} + hor.clear(); + ver.clear(); + graph.clear(); + prev.clear(); + dist.clear(); + m_oLst.clear(); -int box_link::pos_heuristic(const QRectF & i_oR, int i_iPos, const QPointF & i_oP) -{ - switch (i_iPos) + hor.append(apos.x()); + ver.append(apos.y()); + QPair init_p(apos.x(), apos.y()); + + hor.append(bpos.x()); + ver.append(bpos.y()); + QPair end_p(bpos.x(), bpos.y()); + + if (ap == data_link::WEST && bp == data_link::EAST && bx2 >= ax1 - pad) { - case 0: - return (i_oP.y() > 0) ? 0 : 2; - break; - case 1: - return (i_oP.x() < 0) ? 3 : 1; - break; - case 2: - return (i_oP.y() < i_oR.height()) ? 2 : 0; - break; - case 3: - return (i_oP.x() > i_oR.width()) ? 1 : 3; - break; - default: - break; + hor.append(ax1 - pad); + hor.append(bx2 + pad); } - return 2; -} - -int box_link::pos_inrect(const QRectF & i_oR, const QPointF & i_oP) -{ - QPointF l_o = i_oP + QPointF(i_oR.width()/2, i_oR.height()/2); - double c_x = l_o.x() * i_oR.height(); - double c_y = l_o.y() * i_oR.width(); - if (qAbs(c_x) > qAbs(c_y)) + else if (ap == data_link::EAST && bp == data_link::WEST && ax2 >= bx1 - pad) { - return (c_x > 0) ? 1 : 3; + hor.append(bx1 - pad); + hor.append(ax2 + pad); } - else + else if (ap == data_link::NORTH && bp == data_link::SOUTH && by2 >= ay1 - pad) { - return (c_y > 0) ? 0 : 2; + ver.append(ay1 - pad); + ver.append(by2 + pad); + } + else if (ap == data_link::SOUTH && bp == data_link::NORTH && ay2 >= by1 - pad) + { + ver.append(by1 - pad); + ver.append(ay2 + pad); } - return 0; -} -void box_link::update_pos() -{ - //if (!m_oParent || !m_oChild) return; - // now we are about certain we can work + hor.append(qMin(ax1, bx1) - pad); + hor.append(qMax(ax2, bx2) + pad); + ver.append(qMin(ay1, by1) - pad); + ver.append(qMax(ay2, by2) + pad); - QRectF l_oR1, l_oR2; - QPointF l_oP = m_oView->m_oLastMovePoint; + if (ax1 > bx2) hor.append((ax1 + bx2) / 2); + if (bx1 > ax2) hor.append((bx1 + ax2) / 2); + if (ay1 > by2) ver.append((ay1 + by2) / 2); + if (by1 > ay2) ver.append((by1 + ay2) / 2); + + foreach (int x, hor) { + foreach (int y, ver) { + QPair p(x, y); + + graph << p; + dist[p] = MAX; + prev[p] = init_p; + } + } + dist[init_p] = 0; + while (graph.size()) + { - //int ax1, ax2, ay1, ay2, ap, bx1, bx2, by1, by2, bp; + int mi = MAX; + QPair cand; + QPair p; + bool ok = false; + foreach (p, graph) { + if (dist[p] < mi) { + mi = dist[p]; + cand = p; + ok = true; + } + } - // FIXME ITA find the box_item under the pointer - box_item *l_oUnder = NULL; - foreach (QGraphicsItem *l_oI1, scene()->items(m_oView->m_oLastMovePoint)) - { - if (l_oI1->type() == gratype(37)) - { - l_oUnder = (box_item*) l_oI1; + if (!ok) { + m_oLst.clear(); + m_oLst.append(QPoint(init_p.first, init_p.second)); + m_oLst.append(QPoint(end_p.first, end_p.second)); break; - } - } + } - if (m_oParent) - { - l_oR1 = m_oParent->rect().translated(m_oParent->pos()); - } - else if (l_oUnder) - { - l_oR1 = l_oUnder->rect().translated(l_oUnder->pos()); - m_iParent = pos_inrect(l_oUnder->rect(), l_oUnder->pos() - l_oP); + graph.remove(cand); + if (cand == end_p) { + QPair cand = end_p; + while (cand != init_p) { + m_oLst.prepend(QPoint(cand.first, cand.second)); + cand = prev[cand]; + } + m_oLst.prepend(QPoint(cand.first, cand.second)); + break; + } + + foreach (p, graph) { + if (p.first == cand.first || p.second == cand.second) + { + if (may_use(cand, p, ax1, ax2, ay1, ay2, bx1, bx2, by1, by2)) + { + int newdist = dist[cand] + qAbs(p.first - cand.first) + qAbs(p.second - cand.second) + DAMP; + if (newdist < dist[p]) + { + dist[p] = newdist; + prev[p] = cand; + } + } + } + } } +} + +int box_link::may_use(QPair cand, QPair p, int ax1, int ax2, int ay1, int ay2, int bx1, int bx2, int by1, int by2) +{ + int cx1 = qMin(cand.first, p.first); + int cx2 = qMax(cand.first, p.first); + int cy1 = qMin(cand.second, p.second); + int cy2 = qMax(cand.second, p.second); + + return 1 && ( + (cx1 >= ax2 && cx2 > ax2) || + (cx2 <= ax1 && cx1 < ax1) || + (cy1 >= ay2 && cy2 > ay2) || + (cy2 <= ay1 && cy1 < ay1) + ) && ( + (cx1 >= bx2 && cx2 > bx2) || + (cx2 <= bx1 && cx1 < bx1) || + (cy1 >= by2 && cy2 > by2) || + (cy2 <= by1 && cy1 < by1) + ); +} + - if (m_oChild) +void box_link::update_pos() +{ + QRectF l_oR1, l_oR2; + QPoint apos, bpos; + + if (connectable *start = m_oView->m_oItems.value(m_oInnerLink.m_iParent)) { - l_oR2 = m_oChild->rect().translated(m_oChild->pos()); + m_oInnerLink.m_oStartPoint = apos = start->get_point(m_oInnerLink.m_iParentPos); + l_oR1 = start->rect(); } - else if (l_oUnder) + else { - l_oR2 = l_oUnder->rect().translated(l_oUnder->pos()); - m_iChild = pos_inrect(l_oUnder->rect(), l_oUnder->pos() - l_oP); + QPoint l_oP = m_oInnerLink.m_oStartPoint; + l_oR1 = QRectF(l_oP - QPointF(1, 1), l_oP + QPointF(1, 1)); + switch (m_oInnerLink.m_iParentPos & data_link::COORD) { + case data_link::NORTH: + apos = QPoint(l_oP.x(), l_oP.y() - 1); + break; + case data_link::WEST: + apos = QPoint(l_oP.x() - 1, l_oP.y()); + break; + case data_link::SOUTH: + apos = QPoint(l_oP.x(), l_oP.y() + 1); + break; + case data_link::EAST: + apos = QPoint(l_oP.x() + 1, l_oP.y()); + break; + default: + Q_ASSERT(false); + } } - if (!l_oUnder && (!m_oParent || !m_oChild)) - { - QRectF l_o = QRectF(l_oP - QPointF(1, 1), l_oP + QPointF(1, 1)); + m_oStartPoint->force_position(m_oInnerLink.m_oStartPoint); - if (!m_oParent) - { - if (!l_oUnder) m_iParent = pos_heuristic(l_oR2, m_iChild, l_oP - m_oChild->pos()); - l_oR1 = l_o; - } - if (!m_oChild) - { - if (!l_oUnder) m_iChild = pos_heuristic(l_oR1, m_iParent, l_oP - m_oParent->pos()); - l_oR2 = l_o; + if (connectable *end = m_oView->m_oItems.value(m_oInnerLink.m_iChild)) + { + m_oInnerLink.m_oEndPoint = bpos = end->get_point(m_oInnerLink.m_iChildPos); + l_oR2 = end->rect(); + } + else + { + QPoint l_oP = m_oInnerLink.m_oEndPoint; + l_oR2 = QRectF(l_oP - QPointF(1, 1), l_oP + QPointF(1, 1)); + switch (m_oInnerLink.m_iChildPos & data_link::COORD) { + case data_link::NORTH: + bpos = QPoint(l_oP.x(), l_oP.y() - 1); + break; + case data_link::WEST: + bpos = QPoint(l_oP.x() - 1, l_oP.y()); + break; + case data_link::SOUTH: + bpos = QPoint(l_oP.x(), l_oP.y() + 1); + break; + case data_link::EAST: + bpos = QPoint(l_oP.x() + 1, l_oP.y()); + break; + default: + Q_ASSERT(false); } + } + m_oEndPoint->force_position(m_oInnerLink.m_oEndPoint); - //set_rectangles(ax1, ax2, ay1, ay2, ap, bx1, bx2, by1, by2, bp); + int ax1 = (int) l_oR1.x(); + int ax2 = (int) (l_oR1.x()+l_oR1.width()); + int ay1 = (int) l_oR1.y(); + int ay2 = (int) (l_oR1.y()+l_oR1.height()); - set_rectangles( - (int) l_oR1.x(), (int) (l_oR1.x()+l_oR1.width()), - (int) l_oR1.y(), (int) (l_oR1.y()+l_oR1.height()), - m_iParent, - (int) l_oR2.x(), (int) (l_oR2.x()+l_oR2.width()), - (int) l_oR2.y(), (int) (l_oR2.y()+l_oR2.height()), - m_iChild); - - int ret = num_seg(); - while (m_oLst.size() > ret) - m_oLst.takeFirst(); - while (m_oLst.size() < ret) - m_oLst< l_oLst = m_oView->scene()->items(m_oView->m_oLastMovePoint); - //foreach (QGraphicsItem *l_oItem, l_oLst) - //{ - // if (l_oItem->type() == gratype(37)) - // { - // box_item *l_oBox = (box_item*) l_oItem; - //m_oView->add_select(l_oBox); - // l_b = true; - // break; - // } - //} - //if (not l_b) - //{ - // m_oView->deselect_all(); - //} + update_ratio(); + for (int i = 0; i < m_oLst.size() - 3; ++i) + { + box_control_point * b = m_oControlPoints.at(i); + if (i != i_iIdx) { + b->init_pos(); + } + } + m_bReentrantLock = false; + update(); } void box_link::update_ratio() @@ -324,15 +407,6 @@ // here we reset the offsets if necessary int ret = m_oLst.size(); - if (m_oOffsets.size() != ret - 2) - { - m_oOffsets.clear(); - for (int i=1; i= 1) + for (int i = 0; i < m_oControlPoints.size(); ++i) { - for (int i=0; iinit_pos(); + if (isSelected() && !m_oInnerLink.m_iLineType) + { + b->show(); + } + else + { + b->hide(); + } + } + else + { + b->hide(); + } + } + + QPainterPath p; + if (m_oInnerLink.m_iLineType) + { + if (m_oGood.size() > 0) + { + QPolygonF l_oPol(2); + l_oPol[0] = m_oGood[0]; + l_oPol[1] = m_oGood[m_oGood.size() - 1]; + p.addPolygon(l_oPol); + } + } + else + { + for (int i = 0; i < m_oGood.size() - 1; ++i) { int x1 = qMin(m_oGood[i].x(), m_oGood[i+1].x()); int x2 = qMax(m_oGood[i].x(), m_oGood[i+1].x()); int y1 = qMin(m_oGood[i].y(), m_oGood[i+1].y()); int y2 = qMax(m_oGood[i].y(), m_oGood[i+1].y()); - // vertical - if (m_oGood[i].x() == m_oGood[i+1].x()) + if (x1 == x2) { - if (i_oP.x() >= x1 - 5 and i_oP.x() <= x2 + 5) - if (i_oP.y() >= y1 and i_oP.y() <= y2) - return true; + p.addRect(x1 - 5, y1, 10, y2 - y1); } - else //if (m_oGood[i].y() == m_oGood[i+1].y()) + else { - if (i_oP.y() >= y1 - 5 and i_oP.y() <= y2 + 5) - if (i_oP.x() >= x1 and i_oP.x() <= x2) - return true; + p.addRect(x1, y1 - 5, x2 - x1, 10); } } - return false; } - return QGraphicsRectItem::contains(i_oP); + + inner_shape = p; } +QPainterPath box_link::shape() const +{ + return inner_shape; +} + +QVariant box_link::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) +{ + QVariant l_oRet = QGraphicsItem::itemChange(i_oChange, i_oValue); + if (scene()) + { + if (i_oChange == ItemSelectedHasChanged) + { + if (isSelected()) + { + setZValue(102); + m_oStartPoint->show(); + m_oEndPoint->show(); + } + else + { + setZValue(98); + m_oStartPoint->hide(); + m_oEndPoint->hide(); + } + update_pos(); + } + } + + return QGraphicsItem::itemChange(i_oChange, i_oValue); +} + +void box_link::properties() +{ + box_link_properties props(m_oView); + props.m_oThickness->setValue(m_oInnerLink.border_width); + props.m_oType->setCurrentIndex(m_oInnerLink.m_iLineType); + props.m_oStyle->setCurrentIndex((int) m_oInnerLink.pen_style); + props.m_oLeftArrow->setCurrentIndex(m_oInnerLink.m_iLeftArrow); + props.m_oRightArrow->setCurrentIndex(m_oInnerLink.m_iRightArrow); + if (props.exec() == KDialog::Accepted) + { + mem_edit_link *mem = new mem_edit_link(m_oView->m_oMediator, m_oView->m_iId); + mem->link = m_oLink; + + mem->prev.copy_from(m_oInnerLink); + mem->next.copy_from(m_oInnerLink); + mem->next.border_width = props.m_oThickness->value(); + mem->next.m_iLineType = props.m_oType->currentIndex(); + mem->next.pen_style = (Qt::PenStyle) props.m_oStyle->currentIndex(); + mem->next.m_iLeftArrow = props.m_oLeftArrow->currentIndex(); + mem->next.m_iRightArrow = props.m_oRightArrow->currentIndex(); + + mem->apply(); + } +} + + diff -Nru semantik-0.7.3/src/fig/box_link.h semantik-0.8.3/src/fig/box_link.h --- semantik-0.7.3/src/fig/box_link.h 2009-08-30 11:35:31.000000000 +0000 +++ semantik-0.8.3/src/fig/box_link.h 2012-08-26 23:18:49.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef BOX_LINK_H @@ -6,52 +6,61 @@ #include #include +#include +#include +#include +#include "ed:table.h" #include "con.h" class box_view; class box_item; -class box_link : public QGraphicsRectItem +class data_link; +class box_control_point; +class box_link : public QGraphicsRectItem, public editable { public: box_link(box_view*); ~box_link(); - int type() const { return gratype(39); } + QPointF m_oMediatorPoint; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); - bool m_bSel; - - int m_iParent; - int m_iChild; - int m_iParentPos; - int m_iChildPos; - - - int m_iControlSegment; - QPointF m_oControlPoint; - - box_item *m_oParent; - box_item *m_oChild; + data_link *m_oLink; + data_link m_oInnerLink; box_view *m_oView; void update_pos(); - void draw_triangle(QPainter *i_oPainter, int i_iPosition, QPointF i_oP); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + + QVariant itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue); - bool contains(const QPointF& i_oP) CONST; + QPainterPath shape() const; + QPainterPath inner_shape; - int m_iId; + QList m_oControlPoints; + box_control_point* m_oStartPoint; + box_control_point* m_oEndPoint; QList m_oGood; QList m_oLst; - QList m_oOffsets; // this is the list we will keep + void update_offset(const QPointF& i_oP, int i_iIdx); void update_ratio(); - static int pos_inrect(const QRectF&, const QPointF&); - int pos_heuristic(const QRectF&, int, const QPointF&); -}; + void properties(); + + bool m_bReentrantLock; + + // This shows how to abuse the qt containers :-) + QList ver; + QList hor; + QSet > graph; + QHash, QPair > prev; + QHash, int> dist; + void set_rectangles(int ax1, int ax2, int ay1, int ay2, int ap, QPoint&, int bx1, int bx2, int by1, int by2, int bp, QPoint&); + int may_use(QPair cand, QPair p, int ax1, int ax2, int ay1, int ay2, int bx1, int bx2, int by1, int by2); +}; #endif // BOX_LINK_H diff -Nru semantik-0.7.3/src/fig/box_link_properties.cpp semantik-0.8.3/src/fig/box_link_properties.cpp --- semantik-0.7.3/src/fig/box_link_properties.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_link_properties.cpp 2012-10-21 10:09:14.000000000 +0000 @@ -0,0 +1,82 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "box_link_properties.h" + +box_link_properties::box_link_properties(QWidget *i_oParent): + KDialog(i_oParent) +{ + QWidget *widget = new QWidget(this); + setCaption(trUtf8("Link properties")); + setButtons(KDialog::Ok | KDialog::Cancel); + + QGridLayout *l_oGridLayout = new QGridLayout(widget); + + QLabel *l_sLabel; + + l_sLabel = new QLabel(widget); + l_sLabel->setText(trUtf8("Thickness")); + l_oGridLayout->addWidget(l_sLabel, 0, 0); + + l_sLabel = new QLabel(widget); + l_sLabel->setText(trUtf8("Line Type")); + l_oGridLayout->addWidget(l_sLabel, 1, 0); + + l_sLabel = new QLabel(widget); + l_sLabel->setText(trUtf8("Line Style")); + l_oGridLayout->addWidget(l_sLabel, 2, 0); + + l_sLabel = new QLabel(widget); + l_sLabel->setText(trUtf8("Left arrow")); + l_oGridLayout->addWidget(l_sLabel, 3, 0); + + l_sLabel = new QLabel(widget); + l_sLabel->setText(trUtf8("Right arrow")); + l_oGridLayout->addWidget(l_sLabel, 4, 0); + + + m_oThickness = new QSpinBox(widget); + m_oThickness->setMinimum(1); + m_oThickness->setMaximum(3); + l_oGridLayout->addWidget(m_oThickness, 0, 1); + + m_oType = new QComboBox(widget); + m_oType->addItem(trUtf8("Zigzag"), 0); + m_oType->addItem(trUtf8("Straight"), 0); + l_oGridLayout->addWidget(m_oType, 1, 1); + + m_oStyle = new QComboBox(widget); + m_oStyle->addItem(trUtf8("Invisible line"), (int) Qt::NoPen); + m_oStyle->addItem(trUtf8("Solid Line"), (int) Qt::SolidLine); + m_oStyle->addItem(trUtf8("Dot Line"), (int) Qt::DotLine); + m_oStyle->addItem(trUtf8("Dash Line"), (int) Qt::DashLine); + l_oGridLayout->addWidget(m_oStyle, 2, 1); + + m_oLeftArrow = new QComboBox(widget); + m_oLeftArrow->addItem(trUtf8("No arrow"), 0); + m_oLeftArrow->addItem(trUtf8("Triangle"), 0); + l_oGridLayout->addWidget(m_oLeftArrow, 3, 1); + + m_oRightArrow = new QComboBox(widget); + m_oRightArrow->addItem(trUtf8("No arrow"), 0); + m_oRightArrow->addItem(trUtf8("Triangle"), 0); + l_oGridLayout->addWidget(m_oRightArrow, 4, 1); + + setMainWidget(widget); + QSize size(350, 120); + resize(size.expandedTo(minimumSizeHint())); +} + +#include "box_link_properties.moc" + diff -Nru semantik-0.7.3/src/fig/box_link_properties.h semantik-0.8.3/src/fig/box_link_properties.h --- semantik-0.7.3/src/fig/box_link_properties.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_link_properties.h 2012-10-21 10:09:14.000000000 +0000 @@ -0,0 +1,23 @@ +// Thomas Nagy 2012 GPLV3 + +#ifndef BOX_LINK_PROPERTIES_H +#define BOX_LINK_PROPERTIES_H + +#include + +class QSpinBox; +class QComboBox; +class box_link_properties : public KDialog +{ + Q_OBJECT + public: + box_link_properties(QWidget *i_oParent); + QSpinBox *m_oThickness; + QComboBox *m_oType; + QComboBox *m_oStyle; + QComboBox *m_oLeftArrow; + QComboBox *m_oRightArrow; +}; + +#endif + diff -Nru semantik-0.7.3/src/fig/box_node.cpp semantik-0.8.3/src/fig/box_node.cpp --- semantik-0.7.3/src/fig/box_node.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_node.cpp 2012-09-17 21:01:39.000000000 +0000 @@ -0,0 +1,125 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_node.h" +#include "data_item.h" + #include "res:zable.h" +#include "box_view.h" + #include "box_link.h" +#include "sem_mediator.h" +#include "mem_box.h" + +#include + +#define PAD 2 +#define MIN_FORK_SIZE 30 + +box_node::box_node(box_view* view, int id) : box_item(view, id) +{ + QFont font = doc.defaultFont(); + font.setBold(true); + doc.setDefaultFont(font); + + setZValue(90); +} + +void box_node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QColor bc(m_oBox->color); + if (m_oView->m_bDisableGradient) + { + painter->setBrush(bc); + } + else + { + QLinearGradient linearGradient(0, 0, l_oRect.width(), 0); + linearGradient.setColorAt(0.0, bc); + linearGradient.setColorAt(1.0, bc.darker(GRADVAL)); + painter->setBrush(linearGradient); + } + + + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + if (isSelected()) + { + l_oPen.setStyle(Qt::DotLine); + } + + painter->setPen(l_oPen); + QRectF br = l_oRect.adjusted(0, 10, -10, 0); + painter->drawRect(br); + + QPointF pts[4]; + pts[0] = br.topLeft(); + pts[1] = br.topLeft() + QPointF(10, -10); + pts[2] = br.topRight() + QPointF(10, -10); + pts[3] = br.topRight(); + + painter->drawPolygon(pts, 4); + + pts[0] = br.topRight(); + pts[1] = br.topRight() + QPointF(10, -10); + pts[2] = br.bottomRight() + QPointF(10, -10); + pts[3] = br.bottomRight(); + + painter->drawPolygon(pts, 4); + + if (isSelected()) + { + l_oPen.setStyle(Qt::SolidLine); + painter->setPen(l_oPen); + painter->setBrush(QColor("#FFFF00")); + QRectF l_oR2(m_iWW - 10 - 8, m_iHH - 8, 6, 6); + painter->drawRect(l_oR2); + } + + painter->translate(OFF, OFF + 10); + QAbstractTextDocumentLayout::PaintContext ctx; + ctx.palette = QApplication::palette("QTextControl"); + doc.documentLayout()->draw(painter, ctx); + + painter->restore(); +} + +void box_node::update_size() { + m_iWW = m_oBox->m_iWW; + m_iHH = m_oBox->m_iHH; + + doc.setHtml(QString("
    %1
    ").arg(m_oBox->m_sText)); + doc.setTextWidth(m_iWW - 2 * OFF - 20); + + setRect(0, 0, m_iWW, m_iHH); +} + +void box_node::mousePressEvent(QGraphicsSceneMouseEvent* e) +{ + m_oLastPressPoint = e->pos(); + if (m_oLastPressPoint.x() > m_iWW - GRID - 10 && m_oLastPressPoint.x() < m_iWW - 10 && m_oLastPressPoint.y() > m_iHH - GRID) + { + setFlags(ItemIsSelectable | ItemSendsGeometryChanges); + m_bMoving = true; + } + QGraphicsRectItem::mousePressEvent(e); +} + + diff -Nru semantik-0.7.3/src/fig/box_node.h semantik-0.8.3/src/fig/box_node.h --- semantik-0.7.3/src/fig/box_node.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_node.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,26 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_NODE_H +#define BOX_NODE_H + +#include +#include +#include "res:zable.h" +#include "ed:table.h" +#include "box_item.h" +#include "CON.h" +#include "con.h" + +#define OFF 3 + +class box_node : public box_item +{ + public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + box_node(box_view*, int i_iId); + void update_size(); + void mousePressEvent(QGraphicsSceneMouseEvent* e); +}; + +#endif // BOX_NODE_H + diff -Nru semantik-0.7.3/src/fig/box_resize_point.cpp semantik-0.8.3/src/fig/box_resize_point.cpp --- semantik-0.7.3/src/fig/box_resize_point.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_resize_point.cpp 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,79 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_resize_point.h" +#include "box_view.h" +#include "box_resize_point.h" +#include "mem_box.h" + #include "box_link.h" +#include "data_item.h" +#include "sem_mediator.h" + +#include + +#define PAD 1 + +box_resize_point::box_resize_point(box_view* i_oView, resizable *i_oR) : QGraphicsRectItem(), m_oParent(i_oR) +{ + setCacheMode(QGraphicsItem::DeviceCoordinateCache); + m_oView = i_oView; + m_bHeld = false; + setZValue(110); + m_bForced = false; + m_iPosition = 0; + setFlags(ItemIsMovable | ItemSendsGeometryChanges); + i_oView->scene()->addItem(this); +} + +void box_resize_point::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + painter->setPen(l_oPen); + painter->setBrush(QColor("#FFFF00")); + painter->drawRect(l_oRect); + painter->restore(); +} + +void box_resize_point::mousePressEvent(QGraphicsSceneMouseEvent* e) { + e->accept(); + m_oParent->freeze(true); + QGraphicsRectItem::mousePressEvent(e); + m_bHeld = true; +} + +void box_resize_point::mouseReleaseEvent(QGraphicsSceneMouseEvent* e) { + e->accept(); + m_oParent->freeze(false); + m_oParent->commit_size(this); + QGraphicsRectItem::mouseReleaseEvent(e); + m_bHeld = false; +} + +QVariant box_resize_point::itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue) +{ + if (scene()) + { + if (i_oChange == ItemPositionChange && m_bHeld) + { + return m_oParent->validate_point(this, i_oValue.toPointF()); + } + } + return QGraphicsItem::itemChange(i_oChange, i_oValue); +} + diff -Nru semantik-0.7.3/src/fig/box_resize_point.h semantik-0.8.3/src/fig/box_resize_point.h --- semantik-0.7.3/src/fig/box_resize_point.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_resize_point.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,43 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_RESIZE_H +#define BOX_RESIZE_H + +#include +#include +#include "CON.h" +#include "res:zable.h" +#include "con.h" + +class box_view; +class data_item; +class data_box; +class box_link; +class resizable; +class box_resize_point : public QGraphicsRectItem +{ + public: + box_resize_point(box_view*, resizable*); + bool m_bMoveX; + + int m_iPosition; + box_view *m_oView; + resizable *m_oParent; + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + QPoint m_oRealPosition; + QVariant itemChange(GraphicsItemChange i_oChange, const QVariant &i_oValue); + + void mousePressEvent(QGraphicsSceneMouseEvent* e); + void mouseReleaseEvent(QGraphicsSceneMouseEvent* e); + + bool m_bHeld; + + private: + bool m_bChanged; + bool m_bForced; + +}; + +#endif // BOX_RESIZE_H + diff -Nru semantik-0.7.3/src/fig/box_usecase.cpp semantik-0.8.3/src/fig/box_usecase.cpp --- semantik-0.7.3/src/fig/box_usecase.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_usecase.cpp 2012-09-17 21:01:39.000000000 +0000 @@ -0,0 +1,80 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "box_usecase.h" +#include "data_item.h" + #include "res:zable.h" +#include "box_view.h" + #include "box_link.h" +#include "sem_mediator.h" +#include "mem_box.h" + +#include + +#define PAD 2 +#define MIN_FORK_SIZE 30 + +box_usecase::box_usecase(box_view* view, int id) : box_item(view, id) +{ + QFont font = doc.defaultFont(); + font.setPointSize(font.pointSize() - 2); + doc.setDefaultFont(font); +} + +void box_usecase::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + + QRectF l_oRect = boundingRect().adjusted(PAD, PAD, -PAD, -PAD); + + QPen l_oPen = QPen(Qt::SolidLine); + l_oPen.setColor(Qt::black); + l_oPen.setCosmetic(false); + l_oPen.setWidth(1); + painter->setPen(l_oPen); + + QColor bc(m_oBox->color); + if (m_oView->m_bDisableGradient) + { + painter->setBrush(bc); + } + else + { + QLinearGradient linearGradient(0, 0, l_oRect.width(), 0); + linearGradient.setColorAt(0.0, bc); + linearGradient.setColorAt(1.0, bc.darker(GRADVAL)); + painter->setBrush(linearGradient); + } + + + painter->drawEllipse(l_oRect); + painter->save(); + + QAbstractTextDocumentLayout::PaintContext ctx; + ctx.palette = QApplication::palette("QTextControl"); + QAbstractTextDocumentLayout * lay = doc.documentLayout(); + qreal yoff = lay->documentSize().height(); + + painter->translate(OFF, OFF + (m_iHH - 2 * OFF - yoff) / 2.); + lay->draw(painter, ctx); + + painter->restore(); + if (isSelected()) + { + painter->setBrush(QColor("#FFFF00")); + QRectF l_oR2(m_iWW - 8, m_iHH - 8, 6, 6); + painter->drawRect(l_oR2); + } + painter->restore(); +} + diff -Nru semantik-0.7.3/src/fig/box_usecase.h semantik-0.8.3/src/fig/box_usecase.h --- semantik-0.7.3/src/fig/box_usecase.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/box_usecase.h 2012-09-17 21:01:39.000000000 +0000 @@ -0,0 +1,24 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef BOX_USECASE_H +#define BOX_USECASE_H + +#include +#include +#include "res:zable.h" +#include "ed:table.h" +#include "box_item.h" +#include "CON.h" +#include "con.h" + +#define OFF 3 + +class box_usecase : public box_item +{ + public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *); + box_usecase(box_view*, int i_iId); +}; + +#endif // BOX_USECASE_H + diff -Nru semantik-0.7.3/src/fig/box_view.cpp semantik-0.8.3/src/fig/box_view.cpp --- semantik-0.7.3/src/fig/box_view.cpp 2009-08-30 11:35:31.000000000 +0000 +++ semantik-0.8.3/src/fig/box_view.cpp 2012-10-21 10:09:14.000000000 +0000 @@ -1,10 +1,12 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include #include #include #include +#include +#include #include #include #include @@ -19,98 +21,107 @@ #include #include #include +#include + +#include "aux.h" #include "con.h" #include -#include "data_control.h" +#include "sem_mediator.h" #include "box_item.h" +#include "box_dot.h" +#include "box_label.h" +#include "box_fork.h" +#include "box_chain.h" #include "box_link.h" +#include "box_component.h" +#include "box_node.h" +#include "box_decision.h" +#include "box_actor.h" #include "data_item.h" +#include "box_usecase.h" #include "box_view.h" #include "sembind.h" + #include "mem_box.h" + + +#define ALIGN_LEFT 22 +#define ALIGN_CENTER 33 +#define ALIGN_RIGHT 44 +#define ALIGN_TOP 55 +#define ALIGN_MIDDLE 66 +#define ALIGN_BOTTOM 77 + +#define SAME_WIDTH 101 +#define SAME_HEIGHT 102 +#define SAME_WIDTH_HEIGHT 103 + class box_reader : public QXmlDefaultHandler { - public: - box_reader(box_view*); - - //private: - QString m_sBuf; - int m_iVersion; - box_view *m_oControl; - box_link *m_oCurrent; - int m_iId; - - //public: - bool startElement(const QString&, const QString&, const QString&, const QXmlAttributes&); - bool endElement(const QString&, const QString&, const QString&); - bool characters(const QString &i_sStr); + public: + box_reader(box_view*); + QString m_sBuf; + int m_iVersion; + box_view *m_oMediator; + data_link *m_oCurrent; + int m_iId; + + bool startElement(const QString&, const QString&, const QString&, const QXmlAttributes&); + bool endElement(const QString&, const QString&, const QString&); + bool characters(const QString &i_sStr); }; box_reader::box_reader(box_view *i_oControl) { - m_oControl = i_oControl; + m_oMediator = i_oControl; + m_iId = m_oMediator->m_iId; + m_oCurrent = NULL; } bool box_reader::startElement(const QString&, const QString&, const QString& i_sName, const QXmlAttributes& i_oAttrs) { if (i_sName == QObject::trUtf8("box_item")) { - box_item *l_o = new box_item(m_oControl); - m_oControl->m_oItems.push_back(l_o); - l_o->m_iId = i_oAttrs.value(QObject::trUtf8("id")).toInt(); - m_oControl->m_iIdCounter = 1 + qMax(m_oControl->m_iIdCounter, l_o->m_iId); - l_o->m_oDoc->setPlainText(i_oAttrs.value(QObject::trUtf8("text"))); - l_o->setBrush(QColor(i_oAttrs.value(QObject::trUtf8("col")))); + int id = i_oAttrs.value(QObject::trUtf8("id")).toInt(); - l_o->set_pos(i_oAttrs.value(QObject::trUtf8("c1")).toFloat(), i_oAttrs.value(QObject::trUtf8("c2")).toFloat()); - l_o->setRect(QRectF(0., 0., i_oAttrs.value(QObject::trUtf8("c3")).toDouble(), i_oAttrs.value(QObject::trUtf8("c4")).toDouble())); + data_box *box = new data_box(id); + //data_item *item = m_oMediator->m_oMediator->m_oItems[m_iId]; + m_oMediator->m_oMediator->m_oItems[m_iId]->m_oBoxes[id] = box; + box->m_iXX = i_oAttrs.value(QObject::trUtf8("c1")).toFloat(); + box->m_iYY = i_oAttrs.value(QObject::trUtf8("c2")).toFloat(); + box->m_sText = i_oAttrs.value(QObject::trUtf8("text")); + box->color = i_oAttrs.value(QObject::trUtf8("col")); + //l_o->setRect(QRectF(0., 0., i_oAttrs.value(QObject::trUtf8("c3")).toDouble(), i_oAttrs.value(QObject::trUtf8("c4")).toDouble())); } else if (i_sName == QObject::trUtf8("box_link")) { - box_link *l_o = new box_link(m_oControl); - l_o->m_iParent = i_oAttrs.value(QObject::trUtf8("p1")).toInt(); - l_o->m_iChild = i_oAttrs.value(QObject::trUtf8("p2")).toInt(); - - int l_i = i_oAttrs.value(QObject::trUtf8("c1")).toInt(); - foreach (box_item* l_oItem, m_oControl->m_oItems) - { - if (l_oItem->m_iId == l_i) - { - l_o->m_oParent = l_oItem; break; - } - } - - l_i = i_oAttrs.value(QObject::trUtf8("c2")).toInt(); - foreach (box_item* l_oItem, m_oControl->m_oItems) - { - if (l_oItem->m_iId == l_i) - { - l_o->m_oChild = l_oItem; break; - } - } - - QPen l_oPen; - l_oPen.setWidth(i_oAttrs.value(QObject::trUtf8("wl")).toInt()); - l_oPen.setStyle((Qt::PenStyle) i_oAttrs.value(QObject::trUtf8("sl")).toInt()); - if (l_oPen.style() == Qt::NoPen) l_oPen.setStyle(Qt::SolidLine); - l_o->setPen(l_oPen); - - if (!l_o->m_oChild or !l_o->m_oParent) - { - delete l_o; - return false; - } - - m_oControl->m_oLinks.push_back(l_o); - m_oCurrent = l_o; + data_link *link = new data_link(); + link->m_iParentPos = i_oAttrs.value(QObject::trUtf8("p1")).toInt(); + link->m_iParent = i_oAttrs.value(QObject::trUtf8("c1")).toInt(); + link->m_iChildPos = i_oAttrs.value(QObject::trUtf8("p2")).toInt(); + link->m_iChild = i_oAttrs.value(QObject::trUtf8("c2")).toInt(); + + if (link->m_iChildPos == 0) link->m_iChildPos = data_link::NORTH; + if (link->m_iChildPos == 1) link->m_iChildPos = data_link::WEST; + if (link->m_iChildPos == 2) link->m_iChildPos = data_link::SOUTH; + if (link->m_iChildPos == 3) link->m_iChildPos = data_link::EAST; + + if (link->m_iParentPos == 0) link->m_iParentPos = data_link::NORTH; + if (link->m_iParentPos == 1) link->m_iParentPos = data_link::WEST; + if (link->m_iParentPos == 2) link->m_iParentPos = data_link::SOUTH; + if (link->m_iParentPos == 3) link->m_iParentPos = data_link::EAST; + + link->pen_style = (Qt::PenStyle) i_oAttrs.value(QObject::trUtf8("sl")).toInt(); + link->border_width = i_oAttrs.value(QObject::trUtf8("wl")).toInt(); + m_oCurrent = link; + m_oMediator->m_oMediator->m_oItems.value(m_iId)->m_oLinks.append(link); } else if (i_sName == QObject::trUtf8("box_link_offset")) { if (m_oCurrent) { - m_oCurrent->m_oOffsets.append( - QPoint(i_oAttrs.value(QObject::trUtf8("x")).toInt(), i_oAttrs.value(QObject::trUtf8("y")).toInt())); + m_oCurrent->m_oOffsets.append(QPoint(i_oAttrs.value(QObject::trUtf8("x")).toInt(), i_oAttrs.value(QObject::trUtf8("y")).toInt())); } } @@ -121,7 +132,6 @@ { if (i_sName == QObject::trUtf8("box_link")) { - if (m_oCurrent) m_oCurrent->update_pos(); m_oCurrent = NULL; } return true; @@ -129,69 +139,99 @@ bool box_reader::characters(const QString &i_s) { - m_sBuf += i_s; - return true; -} - -int box_view::next_id() -{ - return ++m_iIdCounter; + m_sBuf += i_s; + return true; } -box_view::box_view(QWidget *i_oWidget, data_control *i_oControl) : QGraphicsView(i_oWidget) +box_view::box_view(QWidget *i_oWidget, sem_mediator *i_oControl) : QGraphicsView(i_oWidget) { - m_oControl = i_oControl; - m_iIdCounter = 0; // hidden + m_oMediator = i_oControl; m_iId = NO_ITEM; + m_bDisableGradient = false; QGraphicsScene *l_oScene = new QGraphicsScene(this); l_oScene->setSceneRect(-400, -400, 400, 400); setScene(l_oScene); - //setCacheMode(CacheBackground); - setRenderHint(QPainter::Antialiasing); + setDragMode(QGraphicsView::RubberBandDrag); + + //setCacheMode(CacheBackground); + setRenderHint(QPainter::Antialiasing); - m_oEditAction = new QAction(QObject::trUtf8("Toggle edit"), this); - m_oEditAction->setShortcut(QObject::trUtf8("Return")); - connect(m_oEditAction, SIGNAL(triggered()), this, SLOT(slot_edit())); - addAction(m_oEditAction); + m_oPropertiesAction = new QAction(QObject::trUtf8("Properties..."), this); + //m_oPropertiesAction->setShortcut(QObject::trUtf8("Return")); + connect(m_oPropertiesAction, SIGNAL(triggered()), this, SLOT(slot_edit_properties())); + addAction(m_oPropertiesAction); - m_oAddItemAction = new QAction(QObject::trUtf8("Add Box"), this); + m_oAddItemAction = new QAction(QObject::trUtf8("Activity"), this); m_oAddItemAction->setShortcut(QObject::trUtf8("Ctrl+Return")); - connect(m_oAddItemAction, SIGNAL(triggered()), this, SLOT(slot_add_item())); + connect(m_oAddItemAction, SIGNAL(triggered()), this, SLOT(slot_add_item())); addAction(m_oAddItemAction); m_oDeleteAction = new QAction(QObject::trUtf8("Delete selection"), this); m_oDeleteAction->setShortcut(QObject::trUtf8("Delete")); - connect(m_oDeleteAction, SIGNAL(triggered()), this, SLOT(slot_delete())); + connect(m_oDeleteAction, SIGNAL(triggered()), this, SLOT(slot_delete())); addAction(m_oDeleteAction); m_oColorAction = new QAction(QObject::trUtf8("Color..."), this); - connect(m_oColorAction, SIGNAL(triggered()), this, SLOT(slot_color())); + connect(m_oColorAction, SIGNAL(triggered()), this, SLOT(slot_color())); addAction(m_oColorAction); - //m_oMoveUpAction = new QAction(QObject::trUtf8("Move up"), this); - //m_oMoveUpAction->setShortcut(QObject::trUtf8("PgUp")); - //connect(m_oMoveUpAction, SIGNAL(triggered()), this, SLOT(slot_move_up())); - //addAction(m_oMoveUpAction); - - //m_oMoveDownAction = new QAction(QObject::trUtf8("Move down"), this); - //m_oMoveDownAction->setShortcut(QObject::trUtf8("PgDown")); - //connect(m_oMoveDownAction, SIGNAL(triggered()), this, SLOT(slot_move_down())); - //addAction(m_oMoveDownAction); - + m_oMoveUpAction = new QAction(QObject::trUtf8("Move up"), this); + m_oMoveUpAction->setShortcut(QObject::trUtf8("PgUp")); + connect(m_oMoveUpAction, SIGNAL(triggered()), this, SLOT(slot_move_up())); + addAction(m_oMoveUpAction); + + m_oMoveDownAction = new QAction(QObject::trUtf8("Move down"), this); + m_oMoveDownAction->setShortcut(QObject::trUtf8("PgDown")); + connect(m_oMoveDownAction, SIGNAL(triggered()), this, SLOT(slot_move_down())); + addAction(m_oMoveDownAction); + + m_oAddLabel = new QAction(QObject::trUtf8("Floating text"), this); + connect(m_oAddLabel, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddComponent = new QAction(QObject::trUtf8("Component"), this); + connect(m_oAddComponent, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddNode = new QAction(QObject::trUtf8("Node"), this); + connect(m_oAddNode, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddDecision = new QAction(QObject::trUtf8("Decision"), this); + connect(m_oAddDecision, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddDotStart = new QAction(QObject::trUtf8("Activity start"), this); + connect(m_oAddDotStart, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddDotEnd = new QAction(QObject::trUtf8("Activity end"), this); + connect(m_oAddDotEnd, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddParallelHorizontal = new QAction(QObject::trUtf8("Horizontal fork/join"), this); + connect(m_oAddParallelHorizontal, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddParallelVertical = new QAction(QObject::trUtf8("Vertical fork/join"), this); + connect(m_oAddParallelVertical, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddActor = new QAction(QObject::trUtf8("Actor"), this); + connect(m_oAddActor, SIGNAL(triggered()), this, SLOT(slot_add_element())); + m_oAddUsecase = new QAction(QObject::trUtf8("Usecase"), this); + connect(m_oAddUsecase, SIGNAL(triggered()), this, SLOT(slot_add_element())); m_oMenu = new QMenu(this); + m_oMenu->addAction(m_oAddLabel); m_oMenu->addAction(m_oAddItemAction); - m_oMenu->addAction(m_oEditAction); + m_oMenu->addAction(m_oAddComponent); + m_oMenu->addAction(m_oAddNode); + + m_oAddBoxMenu = m_oMenu->addMenu(QObject::trUtf8("More elements")); + m_oAddBoxMenu->addAction(m_oAddDotStart); + m_oAddBoxMenu->addAction(m_oAddDotEnd); + m_oAddBoxMenu->addAction(m_oAddParallelHorizontal); + m_oAddBoxMenu->addAction(m_oAddParallelVertical); + m_oAddBoxMenu->addAction(m_oAddDecision); + m_oAddBoxMenu->addAction(m_oAddActor); + m_oAddBoxMenu->addAction(m_oAddUsecase); + + //m_oMenu->addAction(m_oEditAction); m_oMenu->addAction(m_oDeleteAction); - m_oMenu->addAction(m_oColorAction); //m_oMenu->addAction(m_oMoveUpAction); //m_oMenu->addAction(m_oMoveDownAction); QAction *l_o; + /* m_oWidthMenu = m_oMenu->addMenu(QObject::trUtf8("Connection width")); m_oWidthGroup = new QActionGroup(this); l_o = m_oWidthMenu->addAction(QObject::trUtf8("1px")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_penwidth())); addAction(l_o); l_o->setData(QVariant(1)); m_oWidthGroup->addAction(l_o); @@ -204,13 +244,37 @@ l_o = m_oStyleMenu->addAction(QObject::trUtf8("dot line")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_penstyle())); addAction(l_o); l_o->setData(QVariant(Qt::DotLine)); m_oStyleGroup->addAction(l_o); l_o = m_oStyleMenu->addAction(QObject::trUtf8("dash line")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_penstyle())); addAction(l_o); l_o->setData(QVariant(Qt::DashLine)); m_oStyleGroup->addAction(l_o); + */ + + m_oMenu->addSeparator(); + + m_oAlignMenu = m_oMenu->addMenu(QObject::trUtf8("Alignment")); + m_oAlignGroup = new QActionGroup(this); + l_o = m_oAlignMenu->addAction(QObject::trUtf8("Align left")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_align())); addAction(l_o); l_o->setData(QVariant(ALIGN_LEFT)); m_oAlignGroup->addAction(l_o); + l_o = m_oAlignMenu->addAction(QObject::trUtf8("Align center")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_align())); addAction(l_o); l_o->setData(QVariant(ALIGN_CENTER)); m_oAlignGroup->addAction(l_o); + l_o = m_oAlignMenu->addAction(QObject::trUtf8("Align right")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_align())); addAction(l_o); l_o->setData(QVariant(ALIGN_RIGHT)); m_oAlignGroup->addAction(l_o); + + l_o = m_oAlignMenu->addAction(QObject::trUtf8("Align top")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_align())); addAction(l_o); l_o->setData(QVariant(ALIGN_TOP)); m_oAlignGroup->addAction(l_o); + l_o = m_oAlignMenu->addAction(QObject::trUtf8("Align middle")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_align())); addAction(l_o); l_o->setData(QVariant(ALIGN_MIDDLE)); m_oAlignGroup->addAction(l_o); + l_o = m_oAlignMenu->addAction(QObject::trUtf8("Align bottom")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_align())); addAction(l_o); l_o->setData(QVariant(ALIGN_BOTTOM)); m_oAlignGroup->addAction(l_o); + + + m_oSizeMenu = m_oMenu->addMenu(QObject::trUtf8("Size")); + m_oSizeGroup = new QActionGroup(this); + l_o = m_oSizeMenu->addAction(QObject::trUtf8("Same width")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_size())); addAction(l_o); l_o->setData(QVariant(SAME_WIDTH)); m_oSizeGroup->addAction(l_o); + l_o = m_oSizeMenu->addAction(QObject::trUtf8("Same height")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_size())); addAction(l_o); l_o->setData(QVariant(SAME_HEIGHT)); m_oSizeGroup->addAction(l_o); + l_o = m_oSizeMenu->addAction(QObject::trUtf8("Same width and height")); connect(l_o, SIGNAL(triggered()), this, SLOT(slot_size())); addAction(l_o); l_o->setData(QVariant(SAME_WIDTH_HEIGHT)); m_oSizeGroup->addAction(l_o); + m_oAddItemAction->setEnabled(false); m_oDeleteAction->setEnabled(false); - m_oEditAction->setEnabled(false); + + //m_oEditAction->setEnabled(false); //m_oMoveUpAction->setEnabled(false); //m_oMoveDownAction->setEnabled(false); m_oMenu->addSeparator(); + m_oMenu->addAction(m_oColorAction); + m_oMenu->addAction(m_oPropertiesAction); m_oColorAction->setEnabled(false); m_oLastMovePoint = QPointF(-100, -100); @@ -218,6 +282,9 @@ m_oCurrent = NULL; m_bPressed = false; m_bScroll = false; + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); } box_view::~box_view() @@ -225,515 +292,279 @@ } -void box_view::wheelEvent(QWheelEvent *i_oEvent) +void box_view::notify_add_item(int id) { - QPointF l_o = mapToScene(i_oEvent->pos()); - qreal i_iScaleFactor = pow(2.0, i_oEvent->delta() / 440.0); - qreal i_rFactor = matrix().scale(i_iScaleFactor, i_iScaleFactor).mapRect(QRectF(0, 0, 1, 1)).width(); - if (i_rFactor < 0.01 || i_rFactor > 1000) return; - scale(i_iScaleFactor, i_iScaleFactor); - centerOn(l_o + mapToScene(viewport()->rect().center()) - mapToScene(i_oEvent->pos())); + m_iId = id; + setEnabled(true); } -void box_view::mouseDoubleClickEvent(QMouseEvent* i_oEv) +void box_view::notify_edit_box(int id, int bid) { - if (i_oEv->button() != Qt::LeftButton) return; - QPointF m_oLastPoint = mapToScene(i_oEv->pos()); - - QGraphicsItem *l_oItem = itemAt(i_oEv->pos()); - if (l_oItem and l_oItem->type() == gratype(39)) - { - box_link *l_oLink = (box_link*) l_oItem; - m_oLinks.removeAll(l_oLink); - m_oSelected.removeAll(l_oLink); - delete l_oLink; - return; - } - - box_item *l_o = new box_item(this); - m_oItems.push_back(l_o); - l_o->setRect(0, 0, 80, 40); - - QRectF l_oRect = l_o->boundingRect(); - add_select(l_o); - l_o->set_pos(m_oLastPoint - QPointF(l_oRect.width()/2, l_oRect.height()/2)); - - check_canvas_size(); + Q_ASSERT(id == m_iId); + box_item *item = (box_item*) m_oItems.value(bid); // TODO + Q_ASSERT(item != NULL); + item->update_data(); } -void box_view::synchro_doc(const hash_params& i_o) +void box_view::notify_select(const QList& unsel, const QList& sel) { - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) - { - case cmd_add_item: - { - m_iId = i_o[data_id].toInt(); - setEnabled(true); - } - break; - - case cmd_select_item: - { - int l_iOldId = m_iId; - if (l_iOldId) - { - data_item *l_oData = m_oControl->m_oItems.value(l_iOldId); - // important, if the parser dies - if (l_oData != NULL and l_oData->m_iDataType == view_diag) { - l_oData->m_sDiag = to_string(); - } - } - clear_diagram(); - - m_iId = i_o[data_id].toInt(); - // if (m_iId == l_iOldId) break; + clear_diagram(); - setEnabled(m_iId > NO_ITEM); - if (m_iId) - { - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - if (l_oData and l_oData->m_iDataType == view_diag) - from_string(l_oData->m_sDiag); - } - } - break; - case cmd_save_data: - { - if (not m_iId) break; - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - if (l_oData->m_iDataType != view_diag) - { - //qDebug()<m_sDiag = to_string(); - } - break; - case cmd_export_item: + if (sel.size() != 1) + { + m_iId = NO_ITEM; + setEnabled(false); + //m_oEditAction->setEnabled(false); + //m_oCancelEditAction->setEnabled(false); + } + else + { + m_iId = sel.at(0); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + Q_ASSERT(l_oData); + if (l_oData and l_oData->m_iDataType == VIEW_DIAG) + { + if (!l_oData->m_sDiag.isEmpty()) { - int l_iOldId = m_iId; - clear_diagram(); - - m_iId = i_o[data_id].toInt(); - data_item *l_oData = m_oControl->m_oItems.value(m_iId); from_string(l_oData->m_sDiag); - - QRectF l_oRect = scene()->itemsBoundingRect(); - l_oRect = QRectF(l_oRect.topLeft() - QPointF(25, 25), l_oRect.bottomRight() + QPointF(25, 25)); - - QRectF l_oR(0, 0, l_oRect.width(), l_oRect.height()); - - - // fill with white - QImage l_oImage((int) l_oR.width(), (int) l_oR.height(), QImage::Format_RGB32); - l_oImage.fill(qRgb(255,255,255)); - - QPainter l_oP; - l_oP.begin(&l_oImage); - l_oP.setRenderHints(QPainter::Antialiasing); - scene()->render(&l_oP, l_oR, l_oRect); - l_oP.end(); - - l_oImage.save(QString(m_oControl->m_sTempDir + QString("/") + - QString("pic-%1.png")).arg(QString::number(m_iId))); - clear_diagram(); - m_iId = l_iOldId; - if (m_iId != NO_ITEM) - { - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - from_string(l_oData->m_sDiag); - } + l_oData->m_sDiag = ""; } - break; - default: - break; + sync_view(); + check_canvas_size(); + } + setEnabled(true); } } -void box_view::mousePressEvent(QMouseEvent *i_oEv) +void box_view::sync_view() { - if (i_oEv->button() == Qt::RightButton) + if (!m_iId) return; + + data_item *item = m_oMediator->m_oItems.value(m_iId); + Q_ASSERT(item); + if (item->m_iDataType != VIEW_DIAG) { - // select the item under the cursor if available and show the popup menu - m_oLastPoint = mapToScene(i_oEv->pos()); - QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); - if (l_oItem && (l_oItem->type() == gratype(37) || l_oItem->type() == gratype(39))) - { - if (!m_oSelected.contains(l_oItem)) - { - deselect_all(); - add_select(l_oItem); - } - } - else - { - deselect_all(); - } - m_oMenu->popup(i_oEv->globalPos()); return; } - - m_bPressed = true; - m_oLastMovePoint = mapToScene(i_oEv->pos()); - m_oLastPoint = mapToScene(i_oEv->pos()); - - if (i_oEv->button() == Qt::MidButton) + if (!item->m_sDiag.isEmpty()) { - m_oScrollPoint = i_oEv->pos(); - viewport()->setCursor(Qt::OpenHandCursor); - m_bScroll = true; - return; + from_string(item->m_sDiag); + item->m_sDiag = ""; } - - QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); - if (l_oItem && l_oItem->type() == gratype(37)) + foreach (data_box *box, item->m_oBoxes.values()) { - box_item *l_oRect = (box_item*) l_oItem; - if (QApplication::keyboardModifiers() & Qt::ControlModifier) + connectable *l_o = NULL; + if (box->m_iType == data_box::ACTIVITY) { - if (m_oCurrent) return; - m_oCurrent = new box_link(this); - m_oCurrent->m_oParent = l_oRect; - m_oCurrent->m_oChild = NULL; - m_oCurrent->m_iParent = box_link::pos_inrect( - l_oRect->rect(), l_oRect->pos() - m_oLastMovePoint); - m_oCurrent->m_iChild = 0; - m_oCurrent->update_pos(); + l_o = new box_item(this, box->m_iId); } - else if (i_oEv->modifiers() == Qt::ShiftModifier) + else if (box->m_iType == data_box::LABEL) { - if (m_oSelected.contains(l_oRect)) - rm_select(l_oRect); - else - add_select(l_oRect); + l_o = new box_label(this, box->m_iId); } - else if (!m_oSelected.contains(l_oRect)) + else if (box->m_iType == data_box::ACTOR) { - deselect_all(); - add_select(l_oRect); + l_o = new box_actor(this, box->m_iId); } - - QPointF l_o = l_oItem->pos(); - // used by the handle for resizing the boxes - check that the click was on the handle - if (m_oLastPoint.x() + m_oLastPoint.y() - l_o.x() - l_o.y() > - l_oRect->rect().width() + l_oRect->rect().height() - 2*GRID_VALUE) + else if (box->m_iType == data_box::USECASE) { - m_oOffsetPoint = QPointF(l_oRect->rect().width(), l_oRect->rect().height()); + l_o = new box_usecase(this, box->m_iId); } - else + else if (box->m_iType == data_box::COMPONENT) { - m_oOffsetPoint = QPointF(-1, -1); + l_o = new box_component(this, box->m_iId); } - } - else if (l_oItem && l_oItem->type() == gratype(39)) - { - box_link *l_oLink = (box_link*) l_oItem; - if (i_oEv->modifiers() == Qt::ShiftModifier) + else if (box->m_iType == data_box::NODE) { - if (m_oSelected.contains(l_oLink)) - { - rm_select(l_oLink); - } - else - { - add_select(l_oLink); - l_oLink->m_iControlSegment = 0; - } + l_o = new box_node(this, box->m_iId); } - else if (m_oSelected.contains(l_oLink) and m_oSelected.size() == 1) + else if (box->m_iType == data_box::DECISION) { - // check if a control point is hit for changing the segment position - bool l_b = false; // found - for (int i=1; im_oGood.size() - 2; ++i) - { - QPointF l_o = QPointF((l_oLink->m_oGood[i].x()+l_oLink->m_oGood[i+1].x())/2, - (l_oLink->m_oGood[i].y()+l_oLink->m_oGood[i+1].y())/2); - QPointF l_oP = mapToScene(i_oEv->pos()); - l_oP.setX(l_o.x() - l_oP.x()); - l_oP.setY(l_o.y() - l_oP.y()); - qreal l_i = l_oP.x() * l_oP.x() + l_oP.y() * l_oP.y(); - if (l_i < 100) // if the click is close to the control point - { - l_b = true; - l_oLink->m_iControlSegment = i; - l_oLink->m_oControlPoint = l_o; - break; - } - } - - // no control point was hit, usual behaviour - if (!l_b) - { - deselect_all(); - add_select(l_oLink); - l_oLink->m_iControlSegment = 0; - } + l_o = new box_decision(this, box->m_iId); + } + else if (box->m_iType == data_box::ACTIVITY_START) + { + l_o = new box_dot(this, box->m_iId); + } + else if (box->m_iType == data_box::ACTIVITY_PARALLEL) + { + l_o = new box_fork(this, box->m_iId); } else { - deselect_all(); - add_select(l_oLink); - l_oLink->m_iControlSegment = 0; + Q_ASSERT(false); } + m_oItems[box->m_iId] = l_o; + (dynamic_cast (l_o))->setPos(QPointF(box->m_iXX, box->m_iYY)); + l_o->update_data(); } - else - { - deselect_all(); - } -} - -void box_view::deselect_all() -{ - if (m_oSelected.size() == 1) - { - QFocusEvent l_oEv = QFocusEvent(QEvent::FocusOut); - if (m_oSelected[0]->type() == gratype(37)) - ((box_item*) m_oSelected[0])->focus_out(&l_oEv); - } - - while (m_oSelected.size() > 0) - { - QGraphicsItem *l_oItem = m_oSelected.takeFirst(); - l_oItem->update(); - } - enable_menu_actions(); -} - -void box_view::add_select(QGraphicsItem* i_oItem) -{ - if (m_oSelected.contains(i_oItem)) - { - qDebug()<<"item already selected"; - return; - } - - m_oSelected.push_back(i_oItem); - i_oItem->update(); - enable_menu_actions(); - - if (m_oSelected.size() == 2) - { - // we do this if the item selected is a box item to show/hide the resize handle - m_oSelected[0]->update(); - } -} - -void box_view::rm_select(QGraphicsItem* i_oItem) -{ - m_oSelected.removeAll(i_oItem); - i_oItem->update(); - enable_menu_actions(); - if (m_oSelected.size() == 1) - { - // we do this if the item selected is a box item to show/hide the resize handle - m_oSelected[0]->update(); + foreach (data_link *link, item->m_oLinks) { + box_link *l_o = new box_link(this); + l_o->m_oInnerLink.copy_from(*link); + l_o->m_oLink = link; + l_o->update_pos(); + m_oLinks.append(l_o); } } -void box_view::mouseMoveEvent(QMouseEvent *i_oEv) +void box_view::notify_export_item(int id) { - if (m_bScroll) - { - QScrollBar *l_h_bar = horizontalScrollBar(); - QScrollBar *l_v_bar = verticalScrollBar(); - - QPoint l_o = i_oEv->pos() - m_oScrollPoint; - - l_h_bar->setValue(l_h_bar->value() + (isRightToLeft() ? l_o.x() : - l_o.x())); - l_v_bar->setValue(l_v_bar->value() - l_o.y()); - - m_oScrollPoint = i_oEv->pos(); + int l_iOldId = m_iId; + if (m_oMediator->m_oItems.value(id)->m_iDataType != VIEW_DIAG) return; - } + clear_diagram(); - if (!m_bPressed) - { - return; - } + m_iId = id; + sync_view(); QRectF l_oRect; - l_oRect.setTopLeft(m_oLastMovePoint); - m_oLastMovePoint = mapToScene(i_oEv->pos()); - l_oRect.setBottomRight(m_oLastMovePoint); - - if (m_oCurrent) - { - m_oCurrent->update_pos(); - } - else + foreach (QGraphicsItem*it, scene()->items()) { - if (m_oSelected.size() == 1 and m_oSelected[0]->type() == gratype(39) and - ((box_link*) m_oSelected[0])->m_iControlSegment) + if (it->isVisible()) { - /* boustophedon */ - box_link *l_oLink = (box_link*) m_oSelected[0]; - int i = l_oLink->m_iControlSegment; - - QPointF l_oP((l_oLink->m_oLst[i].x()+l_oLink->m_oLst[i+1].x())/2, - (l_oLink->m_oLst[i].y()+l_oLink->m_oLst[i+1].y())/2); - --i; - - QPointF l_oNew = m_oLastMovePoint - m_oLastPoint + l_oLink->m_oControlPoint - l_oP; - l_oLink->m_oOffsets[i].setX((int) l_oNew.x()); - l_oLink->m_oOffsets[i].setY((int) l_oNew.y()); - l_oLink->update_ratio(); // no need to update_pos - l_oLink->update(); - } - else if (m_oSelected.size() == 1 and m_oSelected[0]->type() == gratype(37) and - m_oOffsetPoint.x()>0 and m_oOffsetPoint.y()>0 ) - { - QPointF l_o = m_oLastMovePoint - m_oLastPoint + m_oOffsetPoint; - box_item *l_oItem = (box_item*) m_oSelected[0]; - l_o.setX(qMax(GRID_VALUE, l_o.x())); - l_o.setY(qMax(GRID_VALUE, l_o.y())); - l_oItem->setRect(0, 0, int_val(l_o.x()), int_val(l_o.y())); - - // then update the links - foreach (box_link *l_oLink, m_oLinks) + if (l_oRect.width() < 1) { - // either the parent or the child - if (l_oLink->m_oParent == l_oItem or l_oLink->m_oChild == l_oItem) - l_oLink->update_pos(); + l_oRect = it->boundingRect(); + l_oRect.translate(it->pos()); } - } - else - { - foreach (QGraphicsItem *l_oItem, m_oSelected) + else { - if (l_oItem->type() == gratype(37)) - { - ((box_item*) l_oItem)->move_by(l_oRect.width(), l_oRect.height()); - } - - foreach (box_link *l_oLink, m_oLinks) - { - // either the parent or the child - if (l_oLink->m_oParent == l_oItem or l_oLink->m_oChild == l_oItem) - l_oLink->update_pos(); - } + QRectF tmp = it->boundingRect(); + tmp.translate(it->pos()); + l_oRect = l_oRect.united(tmp); } } + it->setCacheMode(QGraphicsItem::NoCache); // the magic happens here } - check_canvas_size(); -} - -void box_view::mouseReleaseEvent(QMouseEvent *i_oEv) -{ - if (m_bScroll) - { - m_bPressed = false; - m_bScroll = false; - viewport()->setCursor(Qt::ArrowCursor); - return; - } + l_oRect = l_oRect.adjusted(-15, -15, 15, 15); - m_bPressed = false; - if (m_oCurrent) - { - box_item *l_oUnder = NULL; - foreach (QGraphicsItem *l_oI1, scene()->items(m_oLastMovePoint)) - { - if (l_oI1->type() == gratype(37)) - { - l_oUnder = (box_item*) l_oI1; - break; - } - } + QRectF l_oR(0, 0, l_oRect.width(), l_oRect.height()); - if (l_oUnder) - { - if (!m_oCurrent->m_oChild) m_oCurrent->m_oChild = l_oUnder; - else m_oCurrent->m_oParent = l_oUnder; + QPair p = m_oMediator->hint_size_diagram(id); - if (m_oCurrent->m_iParent != m_oCurrent->m_iChild or - m_oCurrent->m_oParent != m_oCurrent->m_oChild) - { - m_oLinks.push_back(m_oCurrent); - m_oCurrent->update(); - m_oCurrent = NULL; - } + if (p.first != 0) { + l_oR.setWidth(p.first); + if (p.second == 0) { + l_oR.setHeight((p.first * l_oRect.height()) / (double) l_oRect.width()); } - - // use the fall through - if (m_oCurrent) - { - delete m_oCurrent; - m_oCurrent = NULL; + } + if (p.second != 0) { + l_oR.setHeight(p.second); + if (p.first == 0) { + l_oR.setWidth((p.second * l_oRect.width()) / (double) l_oRect.height()); } } -} -void box_view::focusInEvent(QFocusEvent *) -{ - enable_actions(); -} + data_item *item = m_oMediator->m_oItems.value(m_iId); + item->m_iObjectWidthHint = l_oR.width(); + item->m_iObjectHeightHint = l_oR.height(); -void box_view::focusOutEvent(QFocusEvent *i_oEv) -{ - foreach (QAction* l_o, actions()) + // fill with white + QImage l_oImage((int) l_oR.width(), (int) l_oR.height(), QImage::Format_RGB32); + l_oImage.fill(qRgb(255,255,255)); + + QPainter l_oP; + l_oP.begin(&l_oImage); + l_oP.setRenderHints(QPainter::Antialiasing); + Qt::AspectRatioMode rat = (p.first == 0 || p.second == 0) ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio; + scene()->render(&l_oP, l_oR, l_oRect, rat); + l_oP.end(); + + l_oImage.save(QString(m_oMediator->m_sTempDir + QString("/") + QString("diag-%1.png")).arg(QString::number(m_iId))); + + QPrinter l_oPrinter; + //l_oPrinter.setResolution(QPrinter::HighResolution); + l_oPrinter.setOrientation(QPrinter::Portrait); + l_oPrinter.setOutputFormat(QPrinter::PdfFormat); + l_oPrinter.setPaperSize(l_oR.size(), QPrinter::DevicePixel); + l_oPrinter.setPageMargins(0, 0, 0, 0, QPrinter::DevicePixel); + l_oPrinter.setOutputFileName(QString(m_oMediator->m_sTempDir + QString("/") + QString("diag-%1.pdf")).arg(QString::number(m_iId))); + + QPainter l_oPdf; + if (l_oPdf.begin(&l_oPrinter)) { - l_o->setEnabled(false); + m_bDisableGradient = true; + scene()->render(&l_oPdf, l_oR, l_oRect, rat); + l_oPdf.end(); + m_bDisableGradient = false; } - if (m_oMenu->isVisible()) enable_menu_actions(); - delete m_oCurrent; - m_oCurrent = NULL; + clear_diagram(); + m_iId = l_iOldId; + if (m_iId != NO_ITEM) + { + sync_view(); + } } void box_view::slot_delete() { - while (m_oSelected.size() > 0) + QList boxes; + QSet links; + foreach (QGraphicsItem* el, scene()->selectedItems()) { - QGraphicsItem *l_o = m_oSelected.takeFirst(); - scene()->removeItem(l_o); - %:\ - ifdef\ - unix - if (l_o->type() == gratype(37)) + if (box_link *l = dynamic_cast(el)) + { + links << l->m_oLink; + Q_ASSERT(l->m_oLink); + } + else if (connectable* c = dynamic_cast(el)) { - // disconnect - foreach (box_link *l_oLink, m_oLinks) + data_box *b = c->m_oBox; + boxes.append(b); + foreach (box_link* l, m_oLinks) { - if (l_oLink->m_oParent == l_o || l_oLink->m_oChild == l_o) + if (l->m_oLink->m_iParent == b->m_iId || l->m_oLink->m_iChild == b->m_iId) { - scene()->removeItem(l_oLink); - delete l_oLink; - m_oLinks.removeAll(l_oLink); - m_oSelected.removeAll(l_oLink); + links << l->m_oLink; } } - m_oItems.removeAll((box_item*) l_o); - } - else if (l_o->type() == gratype(39)) - { - m_oLinks.removeAll((box_link*) l_o); } - #endif - delete l_o; + } + + if (boxes.size() > 0 || links.size() > 0) { + mem_del_box *del = new mem_del_box(m_oMediator, m_iId); + del->init(boxes, links.toList()); + del->apply(); } } void box_view::enable_menu_actions() { - m_oAddItemAction->setEnabled(m_oSelected.size() <= 1); - m_oDeleteAction->setEnabled(m_oSelected.size() >= 1); - m_oColorAction->setEnabled(m_oSelected.size() >= 1); - m_oEditAction->setEnabled(m_oSelected.size() == 1 and m_oSelected[0]->type() == gratype(37)); + QList selection = scene()->selectedItems(); + int selected = selection.size(); + + m_oAddItemAction->setEnabled(selected <= 1); + m_oDeleteAction->setEnabled(selected >= 1); + m_oColorAction->setEnabled(selected >= 1); + + m_oPropertiesAction->setEnabled(selected == 1 and dynamic_cast(selection.at(0))); + + m_oSizeMenu->setEnabled(selected > 1); + foreach(QAction* l_o, m_oSizeGroup->actions()) + { + l_o->setEnabled(selected >= 1); + } - m_oWidthMenu->setEnabled(m_oSelected.size() >= 1 and m_oSelected[0]->type() == gratype(39)); + /*m_oWidthMenu->setEnabled(selected >= 1 and dynamic_cast(selection.at(0))); foreach(QAction* l_o, m_oWidthGroup->actions()) { - l_o->setEnabled(m_oSelected.size() >= 1); + l_o->setEnabled(selected >= 1); } - m_oStyleMenu->setEnabled(m_oSelected.size() >= 1 and m_oSelected[0]->type() == gratype(39)); + m_oStyleMenu->setEnabled(selected >= 1 and dynamic_cast(selection.at(0))); foreach(QAction* l_o, m_oStyleGroup->actions()) { - l_o->setEnabled(m_oSelected.size() >= 1); + l_o->setEnabled(selected >= 1); + }*/ + + m_oAlignMenu->setEnabled(selected > 1); + foreach(QAction* l_o, m_oAlignGroup->actions()) + { + l_o->setEnabled(selected > 1); } } @@ -748,86 +579,328 @@ void box_view::slot_add_item() { - box_item *l_o = new box_item(this); - l_o->setRect(0, 0, 80, 40); - QRectF l_oRect = l_o->boundingRect(); - add_select(l_o); - l_o->set_pos(m_oLastPoint - QPointF(l_oRect.width()/2, l_oRect.height()/2)); + foreach(QGraphicsItem *l_o, scene()->items()) { + l_o->setSelected(false); + } + + mem_add_box *add = new mem_add_box(m_oMediator, m_iId, next_seq()); + add->box->m_iXX = m_oLastPoint.x(); + add->box->m_iYY = m_oLastPoint.y(); + add->box->m_iWW = 80; + add->apply(); + + box_item *l_o = (box_item*) m_oItems.value(add->box->m_iId); + l_o->setSelected(true); + // l_o->setPos(m_oLastPoint - QPointF(l_oRect.width()/2, l_oRect.height()/2)); // TODO } -void box_view::slot_color() +void box_view::change_colors(QAction* i_oAct) { - Q_ASSERT(m_oSelected.size() >= 1); - QColor l_oColor = QColorDialog::getColor(l_oColor, this); + if (!hasFocus()) return; + if (scene()->selectedItems().size() < 1) return; + + QColor l_oColor; + static QColor selected_color; + + for (int i=1; i < i_oAct->actionGroup()->actions().size(); ++i) + { + if (i_oAct->actionGroup()->actions()[i] == i_oAct) + { + if (i == i_oAct->actionGroup()->actions().size()-1) + { + selected_color = QColorDialog::getColor(selected_color, this); + if (!selected_color.isValid()) + { + return; + } + l_oColor = selected_color; + } + else + { + selected_color = l_oColor = m_oMediator->m_oColorSchemes[i].m_oInnerColor; + + } + break; + } + } + + mem_prop_box *mem = new mem_prop_box(m_oMediator, m_iId); + foreach (QGraphicsItem *l_o, scene()->selectedItems()) + { + if (box_link *k = dynamic_cast(l_o)) + { + mem->items.append(k->m_oLink); + } + else if (connectable* t = dynamic_cast(l_o)) + { + mem->items.append(t->m_oBox); + } + } + mem->change_type = CH_COLOR; + mem->new_props.color = l_oColor; + mem->apply(); +} + +void box_view::slot_color() +{ + if (scene()->selectedItems().size() < 1) return; + QColor l_oColor = QColorDialog::getColor(l_oColor, this); if (!l_oColor.isValid()) return; - foreach (QGraphicsItem *l_oItem, m_oSelected) + mem_prop_box *mem = new mem_prop_box(m_oMediator, m_iId); + foreach (QGraphicsItem *l_o, scene()->selectedItems()) { - QAbstractGraphicsShapeItem* l_o = (QAbstractGraphicsShapeItem*) l_oItem; - l_o->setBrush(l_oColor); - if (l_oItem->type() == gratype(39)) - { - box_link *l_oLink = (box_link*) l_oItem; - QPen l_oPen = l_oLink->pen(); - l_oPen.setColor(l_oColor); - l_oLink->setPen(l_oPen); + if (box_link *k = dynamic_cast(l_o)) + { + mem->items.append(k->m_oLink); + } + else if (connectable *k = dynamic_cast(l_o)) + { + mem->items.append(k->m_oBox); } - l_oItem->update(); } + mem->change_type = CH_COLOR; + mem->new_props.color = l_oColor; + mem->apply(); } void box_view::slot_penstyle() { int l_i = ((QAction*) QObject::sender())->data().toInt(); - foreach (QGraphicsItem* l_o, m_oSelected) + mem_prop_box *mem = new mem_prop_box(m_oMediator, m_iId); + foreach (QGraphicsItem* l_o, scene()->selectedItems()) { - if (l_o->type() == gratype(39)) + if (box_link *k = dynamic_cast(l_o)) { - box_link *l_oLink = (box_link*) l_o; - QPen l_oPen = l_oLink->pen(); - l_oPen.setStyle((Qt::PenStyle) l_i); - l_oLink->setPen(l_oPen); + mem->items.append(k->m_oLink); } } + mem->change_type = CH_PENST; + mem->new_props.pen_style = (Qt::PenStyle) l_i; + mem->apply(); +} + +void box_view::slot_add_element() +{ + QAction *sender = (QAction*) QObject::sender(); + mem_add_box *add = new mem_add_box(m_oMediator, m_iId, next_seq()); + add->box->m_iXX = GRID * (int) (m_oLastPoint.x() / GRID); + add->box->m_iYY = GRID * (int) (m_oLastPoint.y() / GRID); + + if (sender == m_oAddDotStart || sender == m_oAddDotEnd) + { + add->box->m_iHH = 20; + add->box->m_iWW = 20; + } + else if (sender == m_oAddParallelVertical) + { + add->box->m_iWW = FORK_WIDTH; + add->box->m_iHH = FORK_LENGTH; + add->box->m_bIsVertical = true; + } + else if (sender == m_oAddParallelHorizontal) + { + add->box->m_iHH = FORK_WIDTH; + add->box->m_iWW = FORK_LENGTH; + add->box->m_bIsVertical = false; + } + add->box->m_bIsEnd = sender == m_oAddDotEnd; + + if (sender == m_oAddDotEnd || sender == m_oAddDotStart) { + add->box->m_iType = data_box::ACTIVITY_START; + add->box->color = QColor(Qt::black); + } + if (sender == m_oAddParallelHorizontal || sender == m_oAddParallelVertical) { + add->box->m_iType = data_box::ACTIVITY_PARALLEL; + add->box->color = QColor(Qt::black); + } + if (sender == m_oAddLabel) + { + add->box->m_iType = data_box::LABEL; + add->box->m_iWW = 60; + add->box->m_iHH = 30; + add->box->m_sText = QString("..."); + } + else if (sender == m_oAddActor) + { + add->box->m_iType = data_box::ACTOR; + add->box->m_iWW = 30; + add->box->m_iHH = 70; + } + else if (sender == m_oAddUsecase) + { + add->box->m_iType = data_box::USECASE; + add->box->m_iWW = 100; + add->box->m_iHH = 50; + } + else if (sender == m_oAddComponent) + { + add->box->m_iType = data_box::COMPONENT; + add->box->m_iWW = 120; + add->box->m_iHH = 60; + add->box->color = QColor("#FFFFCC"); + } + else if (sender == m_oAddNode) + { + add->box->m_iType = data_box::NODE; + add->box->m_iWW = 180; + add->box->m_iHH = 180; + add->box->color = QColor("#FFFFCC"); + } + else if (sender == m_oAddDecision) + { + add->box->m_iType = data_box::DECISION; + add->box->m_iWW = 50; + add->box->m_iHH = 50; + } + + add->apply(); + + QGraphicsItem *l_o = dynamic_cast(m_oItems.value(add->box->m_iId)); + l_o->setSelected(true); } void box_view::slot_penwidth() { int l_i = ((QAction*) QObject::sender())->data().toInt(); - foreach (QGraphicsItem* l_o, m_oSelected) + mem_prop_box *mem = new mem_prop_box(m_oMediator, m_iId); + foreach (QGraphicsItem* l_o, scene()->selectedItems()) { - if (l_o->type() == gratype(39)) + if (box_link *k = dynamic_cast(l_o)) { - box_link *l_oLink = (box_link*) l_o; - QPen l_oPen = l_oLink->pen(); - l_oPen.setWidth(l_i); - l_oLink->setPen(l_oPen); + mem->items.append(k->m_oLink); } } + mem->change_type = CH_BORDER; + mem->new_props.border_width = l_i; + mem->apply(); } -void box_view::slot_edit() +void box_view::slot_edit_properties() { - if (m_oSelected.size() == 1 && m_oSelected[0]->type() == gratype(37)) + QList lst = scene()->selectedItems(); + if (lst.length() == 1) { - box_item *l_o = (box_item*) m_oSelected[0]; - if (l_o->m_bEdit) + if (editable*e = dynamic_cast(lst.at(0))) { - QFocusEvent l_oEv = QFocusEvent(QEvent::FocusOut); - l_o->focus_out(&l_oEv); - l_o->update(); + e->properties(); } - else + } +} + +#if 0 +void box_view::slot_toggle_edit() +{ + if (!hasFocus()) { + return; + } + + box_item* sel = NULL; + foreach (QGraphicsItem *tmp, items()) + { + box_item* k; + if (tmp->isSelected() && (k = dynamic_cast(tmp))) + { + if (sel) { + sel = NULL; + break; + } else { + sel = k; + } + } + } + + if (sel) { + if (sel->textInteractionFlags() & Qt::TextEditorInteraction) { + sel->setTextInteractionFlags(Qt::NoTextInteraction); + /*if (sel->toPlainText() == QObject::trUtf8("")) { + sel->setPlainText(QObject::trUtf8("Empty")); + sel->update(); // seems to update faster + //sel->update_links(); + + }*/ + if (sel->toPlainText() != m_oMediator->m_oItems[m_iId]->m_oBoxes[sel->m_iId]->m_sText) { + mem_edit_box *ed = new mem_edit_box(m_oMediator, m_iId, sel->m_iId); + ed->newText = sel->toPlainText(); + ed->apply(); + } + } else { + sel->setTextInteractionFlags(Qt::TextEditorInteraction); + sel->setFocus(); + + m_oAddItemAction->setEnabled(false); + m_oDeleteAction->setEnabled(false); + m_oCancelEditAction->setEnabled(true); + + /* + m_oInsertSiblingAction->setEnabled(false); + m_oNextRootAction->setEnabled(false); + + m_oMoveUpAction->setEnabled(false); + m_oMoveDownAction->setEnabled(false); + m_oMoveLeftAction->setEnabled(false); + m_oMoveRightAction->setEnabled(false); + m_oSelectUpAction->setEnabled(false); + m_oSelectDownAction->setEnabled(false); + m_oSelectLeftAction->setEnabled(false); + m_oSelectRightAction->setEnabled(false); + m_oMediator->check_undo(false); + */ + return; + } + } + + m_oAddItemAction->setEnabled(true); + m_oDeleteAction->setEnabled(true); + m_oCancelEditAction->setEnabled(false); + + /* + m_oInsertSiblingAction->setEnabled(true); + m_oNextRootAction->setEnabled(true); + + m_oMoveUpAction->setEnabled(true); + m_oMoveDownAction->setEnabled(true); + m_oMoveLeftAction->setEnabled(true); + m_oMoveRightAction->setEnabled(true); + m_oSelectUpAction->setEnabled(true); + m_oSelectDownAction->setEnabled(true); + m_oSelectLeftAction->setEnabled(true); + m_oSelectRightAction->setEnabled(true); + m_oMediator->check_undo(true); + */ +} + +void box_view::slot_cancel_edit() +{ + //qDebug()<<"slot cancel edit"; + box_item* sel = NULL; + foreach (QGraphicsItem *tmp, items()) { + box_item *k; + if (tmp->isSelected() && (k = dynamic_cast(tmp))) { - l_o->focus_in(); - l_o->update(); + if (sel) { + sel = NULL; + break; + } else { + sel = k; + } } } + + if (sel && sel->textInteractionFlags() & Qt::TextEditorInteraction) { + //qDebug()<<"cancel edit!"<setTextInteractionFlags(Qt::NoTextInteraction); + sel->update_data(); + } + + m_oAddItemAction->setEnabled(true); + m_oDeleteAction->setEnabled(true); } +#endif void box_view::slot_move_up() { - foreach (QGraphicsItem *l_oItem, m_oSelected) + foreach (QGraphicsItem *l_oItem, scene()->selectedItems()) { l_oItem->setZValue(l_oItem->zValue()+1); } @@ -835,7 +908,7 @@ void box_view::slot_move_down() { - foreach (QGraphicsItem *l_oItem, m_oSelected) + foreach (QGraphicsItem *l_oItem, scene()->selectedItems()) { l_oItem->setZValue(l_oItem->zValue()-1); } @@ -853,186 +926,534 @@ //qDebug()<<"parse error!!"; clear_diagram(); } - check_canvas_size(); } void box_view::clear_diagram() { - m_oSelected.clear(); - if (m_oCurrent) - { - delete m_oCurrent; - } - m_oCurrent = NULL; - m_iIdCounter = 1; - while (m_oLinks.size()>0) - { - box_link *l_o = m_oLinks.takeFirst(); + foreach (box_link *l_o, m_oLinks) { + scene()->removeItem(l_o); delete l_o; } - Q_ASSERT(m_oLinks.size() == 0); - - while (m_oItems.size()>0) - { - box_item *l_o = m_oItems.takeFirst(); + m_oLinks.clear(); + foreach (connectable *l_o, m_oItems.values()) { + scene()->removeItem(dynamic_cast(l_o)); delete l_o; } - Q_ASSERT(m_oItems.size() == 0); + m_oItems.clear(); +} + +void box_view::check_canvas_size() +{ + QRectF br = scene()->itemsBoundingRect(); + br.adjust(-GAP, -GAP, GAP, GAP); + br = br.united(scene()->sceneRect()); + scene()->setSceneRect(br); +} + +void box_view::focusInEvent(QFocusEvent *i_oEv) +{ + QGraphicsView::focusInEvent(i_oEv); + m_oMediator->notify_focus(this); +} + +void box_view::focusOutEvent(QFocusEvent *i_oEv) +{ + QGraphicsView::focusOutEvent(i_oEv); } -QString box_view::to_string() +void box_view::notify_add_box(int id, int box) { - QStringList l; - l<"); - foreach (box_item *l_oBox, m_oItems) + Q_ASSERT(m_iId == id); + data_item *item = m_oMediator->m_oItems.value(m_iId); + data_box *db = item->m_oBoxes[box]; + connectable *l_o = NULL; + if (db->m_iType == data_box::ACTIVITY) { - l<m_iId)); - l<m_oDoc->toPlainText())); - l<pos().x()), - QString::number(l_oBox->pos().y()), - QString::number(l_oBox->rect().width()), - QString::number(l_oBox->rect().height())); - l<brush().color().name()); - l<\n"); + l_o = new box_item(this, box); } - - foreach (box_link *l_oLink, m_oLinks) + else if (db->m_iType == data_box::LABEL) { - l<m_iId)); - l<m_iParent)); - l<m_iChild)); - l<pen().width())); - l<pen().style())); - - if (l_oLink->m_oParent && l_oLink->m_oChild) + l_o = new box_label(this, box); + } + else if (db->m_iType == data_box::ACTOR) + { + l_o = new box_actor(this, box); + } + else if (db->m_iType == data_box::USECASE) + { + l_o = new box_usecase(this, box); + } + else if (db->m_iType == data_box::COMPONENT) + { + l_o = new box_component(this, box); + } + else if (db->m_iType == data_box::NODE) + { + l_o = new box_node(this, box); + } + else if (db->m_iType == data_box::DECISION) + { + l_o = new box_decision(this, box); + } + else if (db->m_iType == data_box::ACTIVITY_START) + { + l_o = new box_dot(this, box); + } + else if (db->m_iType == data_box::ACTIVITY_PARALLEL) + { + if (db->m_bIsVertical) { - l<m_oParent->m_iId)); - l<m_oChild->m_iId)); + db->m_iHH = FORK_LENGTH; + db->m_iWW = FORK_WIDTH; } - l<\n"); - for (int i=0; im_oOffsets.size(); ++i) + else { - l<\n").arg( - QString::number(l_oLink->m_oOffsets[i].x()), - QString::number(l_oLink->m_oOffsets[i].y())); + db->m_iWW = FORK_LENGTH; + db->m_iHH = FORK_WIDTH; } - l<\n"); + l_o = new box_fork(this, box); } + Q_ASSERT(l_o != NULL); + m_oItems[box] = l_o; + l_o->update_data(); +} + +void box_view::notify_del_box(int id, int box) +{ + connectable *l_o = m_oItems.value(box); + Q_ASSERT(l_o!=NULL); + scene()->removeItem(dynamic_cast(l_o)); + m_oItems.remove(box); + delete l_o; +} - l<"); +void box_view::notify_link_box(int id, data_link* link) +{ + box_link *l_o = m_oCurrent; + if (!l_o) + { + l_o = new box_link(this); + } + m_oLinks.push_back(l_o); + l_o->m_oInnerLink.copy_from(*link); + l_o->m_oLink = link; + l_o->update_pos(); +} - return l.join(""); +void box_view::notify_unlink_box(int id, data_link* link) +{ + Q_ASSERT(!m_oCurrent); + foreach (box_link *cur, m_oLinks) { + if (cur->m_oLink == link) + { + delete cur; + m_oLinks.removeAll(cur); + break; + } + } } -void box_view::keyPressEvent(QKeyEvent *i_oEvent) +void box_view::notify_change_link_box(int id, data_link*link) { - if (m_oSelected.size() == 1 && m_oSelected[0]->type() == gratype(37)) + foreach (box_link *cur, m_oLinks) { - box_item * l_oItem = (box_item*) m_oSelected[0]; - if (l_oItem->m_bEdit && i_oEvent->type() == QEvent::KeyPress) + if (cur->m_oLink == link) { - setCursor(Qt::ArrowCursor); - l_oItem->keyPressEvent(i_oEvent); + cur->m_oInnerLink.copy_from(*cur->m_oLink); + cur->update_pos(); + break; } } - if (QApplication::keyboardModifiers() & Qt::ControlModifier) setCursor(Qt::CrossCursor); - i_oEvent->accept(); } -void box_view::keyReleaseEvent(QKeyEvent *i_oEvent) +void box_view::wheelEvent(QWheelEvent *i_oEvent) +{ + QPointF l_o = mapToScene(i_oEvent->pos()); + qreal i_iScaleFactor = pow(2.0, i_oEvent->delta() / 440.0); + qreal i_rFactor = matrix().scale(i_iScaleFactor, i_iScaleFactor).mapRect(QRectF(0, 0, 1, 1)).width(); + if (i_rFactor < 0.01 || i_rFactor > 1000) return; + scale(i_iScaleFactor, i_iScaleFactor); + centerOn(l_o + mapToScene(viewport()->rect().center()) - mapToScene(i_oEvent->pos())); + check_canvas_size(); +} + +void box_view::keyPressEvent(QKeyEvent *i_oEvent) { - if (! (QApplication::keyboardModifiers() & Qt::ControlModifier)) - setCursor(Qt::ArrowCursor); + if (i_oEvent->key() == Qt::Key_Enter || i_oEvent->key() == Qt::Key_Return) + { + slot_edit_properties(); + } + QGraphicsView::keyPressEvent(i_oEvent); +} - i_oEvent->accept(); +void box_view::keyReleaseEvent(QKeyEvent *i_oEvent) +{ + QGraphicsView::keyReleaseEvent(i_oEvent); + setCursor(Qt::ArrowCursor); } -bool box_view::event(QEvent *i_oEvent) +void box_view::slot_size() { - //qDebug()<<"event type "<type(); - /*if (i_oEvent->type() == QEvent::ToolTip) + if (scene()->selectedItems().size() < 2) return; + + int l_i = ((QAction*) QObject::sender())->data().toInt(); + int w = 0; + int h = 0; + foreach (QGraphicsItem* l_oItem, scene()->selectedItems()) { - QHelpEvent *l_oEv = static_cast(i_oEvent); - QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(l_oEv->pos())); - if (l_oItem && l_oItem->type() == gratype(7)) + if (connectable* c = dynamic_cast(l_oItem)) { - data_item *l_o = *m_oControl + ((canvas_item*) l_oItem)->Id(); - if (l_o && l_o->m_iTextLength > 1) + QRectF r = c->rect(); + if ((l_i == SAME_WIDTH || l_i == SAME_WIDTH_HEIGHT) && r.width() > w) { - QToolTip::showText(l_oEv->globalPos(), l_o->m_sText); + w = r.width(); + } + if ((l_i == SAME_HEIGHT || l_i == SAME_WIDTH_HEIGHT) && r.height() > h) + { + h = r.height(); } } } - else*/ if (i_oEvent->type() == QEvent::KeyPress - || i_oEvent->type() == QEvent::ShortcutOverride - || i_oEvent->type() == QEvent::Shortcut) + mem_size_box *mem = new mem_size_box(m_oMediator, m_iId); + foreach (QGraphicsItem* l_oItem, scene()->selectedItems()) { - if (m_oSelected.size() == 1 && m_oSelected[0]->type() == gratype(37)) - { - box_item *l_oItem = (box_item*) m_oSelected[0]; - if (l_oItem->m_bEdit) - { - QKeyEvent *l_o = (QKeyEvent*) i_oEvent; - if (m_oEditAction->shortcut().matches(l_o->key())) - { - //qDebug()<<"matches"<key(); - return QGraphicsView::event(i_oEvent); - } + if (connectable* c = dynamic_cast(l_oItem)) + { + data_box *box = c->m_oBox; + mem->prev_values[box] = QRect(box->m_iXX, box->m_iYY, box->m_iWW, box->m_iHH); + mem->next_values[box] = QRect(box->m_iXX, box->m_iYY, w, h); + } + } + mem->apply(); +} + +void box_view::slot_align() +{ + int l_i = ((QAction*) QObject::sender())->data().toInt(); + + int n = 0; + qreal best = 0; + if (l_i == ALIGN_LEFT || l_i == ALIGN_TOP) + best = 99999999; + else if (l_i == ALIGN_BOTTOM || l_i == ALIGN_RIGHT) + best = -99999999; + + foreach (QGraphicsItem* l_oItem, scene()->selectedItems()) + { + if (connectable* c = dynamic_cast(l_oItem)) + { + n++; + QRectF r = c->rect(); + if (l_i == ALIGN_LEFT) + best = qMin(r.x(), best); + if (l_i == ALIGN_RIGHT) + best = qMax(r.x() + r.width(), best); + if (l_i == ALIGN_BOTTOM) + best = qMax(r.y() , best); + if (l_i == ALIGN_TOP) + best = qMin(r.y() + r.height(), best); + if (l_i == ALIGN_CENTER) + best = r.x() + r.width() / 2.; // TODO do not pick one randomly + if (l_i == ALIGN_MIDDLE) + best = r.y() + r.height()/2.; + } + } - keyPressEvent(l_o); - return true; + if (l_i == ALIGN_CENTER || l_i == ALIGN_MIDDLE) + best = (int) best; + + mem_pos_box *mem = new mem_pos_box(m_oMediator, m_iId); + + foreach (QGraphicsItem* l_oItem, scene()->selectedItems()) + { + if (connectable* c = dynamic_cast(l_oItem)) + { + data_box *box = c->m_oBox; + mem->prev_values[box] = QPointF(box->m_iXX, box->m_iYY); + switch (l_i) + { + case ALIGN_LEFT: + mem->next_values[box] = QPoint(best, box->m_iYY); + break; + case ALIGN_RIGHT: + mem->next_values[box] = QPoint(best - box->m_iWW, box->m_iYY); + break; + case ALIGN_TOP: + mem->next_values[box] = QPoint(box->m_iXX, best); + break; + case ALIGN_BOTTOM: + mem->next_values[box] = QPoint(box->m_iXX, best - box->m_iHH); + break; + case ALIGN_CENTER: + mem->next_values[box] = QPoint(best - box->m_iWW / 2., box->m_iYY); + break; + case ALIGN_MIDDLE: + mem->next_values[box] = QPoint(box->m_iXX, best - box->m_iHH / 2.); + break; + default: + Q_ASSERT(false); } } } - else if (i_oEvent->type() == QEvent::InputMethod) + mem->apply(); +} + +void box_view::mouseDoubleClickEvent(QMouseEvent* i_oEv) +{ + if (i_oEv->button() != Qt::LeftButton) + { + //qDebug()<<"left button on click, leaving"; + return; + } + + QGraphicsItem *l_oItem = itemAt(i_oEv->pos()); + box_link *l_oLink; + if (l_oItem && (l_oLink = dynamic_cast(l_oItem))) + { + mem_unlink_box *rm = new mem_unlink_box(m_oMediator, m_iId); + rm->link = l_oLink->m_oLink; + rm->apply(); + + return; + } + + slot_add_item(); +} + +void box_view::mousePressEvent(QMouseEvent *i_oEv) +{ + if (i_oEv->button() == Qt::RightButton) + { + m_oLastPoint = mapToScene(i_oEv->pos()); + enable_menu_actions(); + m_oMenu->popup(i_oEv->globalPos()); + return; + } + + m_bPressed = true; + m_oLastMovePoint = m_oLastPoint = mapToScene(i_oEv->pos()); + + if (i_oEv->button() == Qt::MidButton) + { + m_oScrollPoint = i_oEv->pos(); + viewport()->setCursor(Qt::OpenHandCursor); + m_bScroll = true; + return; + } + + QGraphicsItem *l_oItem = scene()->itemAt(mapToScene(i_oEv->pos())); + + box_chain* kk; + if (l_oItem && (kk = dynamic_cast(l_oItem))) + { + Q_ASSERT(!m_oCurrent); + + foreach (QGraphicsItem *l_o, scene()->selectedItems()) + { + l_o->setSelected(false); + } + + connectable *l_oParent = dynamic_cast(kk->parentItem()); + Q_ASSERT(l_oParent); + + QPoint p = QPoint(m_oLastPoint.x(), m_oLastPoint.y()); + + m_oCurrent = new box_link(this); + m_oCurrent->m_oInnerLink.m_iParent = l_oParent->m_iId; + m_oCurrent->m_oInnerLink.m_iParentPos = data_link::EAST + MUL * 500; + m_oCurrent->m_oInnerLink.m_iChild = NO_ITEM; + m_oCurrent->m_oInnerLink.m_iChildPos = data_link::NORTH; + m_oCurrent->m_oInnerLink.m_oStartPoint = m_oCurrent->m_oInnerLink.m_oEndPoint = p; + if (dynamic_cast(l_oParent)) + { + m_oCurrent->m_oInnerLink.pen_style = Qt::DotLine; + m_oCurrent->m_oInnerLink.m_iLeftArrow = 0; + m_oCurrent->m_oInnerLink.m_iRightArrow = 0; + } + + if (dynamic_cast(l_oParent) || dynamic_cast(l_oParent)) + { + m_oCurrent->m_oInnerLink.m_iLeftArrow = 0; + m_oCurrent->m_oInnerLink.m_iRightArrow = 0; + } + + m_oCurrent->setSelected(true); + } + + box_item *k; + if (l_oItem && (k = dynamic_cast(l_oItem))) { - if (m_oSelected.size() == 1 && m_oSelected[0]->type() == gratype(37)) + QPointF l_o = l_oItem->pos(); + // TODO used by the handle for resizing the boxes - check that the click was on the handle + if (m_oLastPoint.x() + m_oLastPoint.y() - l_o.x() - l_o.y() > + k->rect().width() + k->rect().height() - 2*GRID) { - box_item * l_oItem = (box_item*) m_oSelected[0]; - if (l_oItem->m_bEdit) - { - l_oItem->inputMethodEvent((QInputMethodEvent*) i_oEvent); - } + m_oOffsetPoint = QPointF(k->rect().width(), k->rect().height()); + } + else + { + m_oOffsetPoint = QPointF(-1, -1); } } - return QGraphicsView::event(i_oEvent); + + QGraphicsView::mousePressEvent(i_oEv); } -void box_view::check_canvas_size() +void box_view::mouseMoveEvent(QMouseEvent *i_oEv) { - QWidget *l_oW = viewport(); - QRect l_oRect = l_oW->rect(); + if (m_bScroll) + { + QScrollBar *l_h_bar = horizontalScrollBar(); + QScrollBar *l_v_bar = verticalScrollBar(); + + QPoint l_o = i_oEv->pos() - m_oScrollPoint; + + l_h_bar->setValue(l_h_bar->value() + (isRightToLeft() ? l_o.x() : - l_o.x())); + l_v_bar->setValue(l_v_bar->value() - l_o.y()); + + m_oScrollPoint = i_oEv->pos(); + return; + } - if (m_oItems.size() < 1) + if (!m_bPressed) { - scene()->setSceneRect(QRectF(mapToScene(l_oRect.topLeft()), mapToScene(l_oRect.bottomRight()))); return; } - QRectF l_oR2; + m_oLastMovePoint = mapToScene(i_oEv->pos()); + QGraphicsView::mouseMoveEvent(i_oEv); +} + +void box_view::mouseReleaseEvent(QMouseEvent *i_oEv) +{ + if (m_oCurrent) + { + if (m_oItems.value(m_oCurrent->m_oInnerLink.m_iChild)) + { + mem_link_box *ln = new mem_link_box(m_oMediator, m_iId); + ln->link = new data_link(); + ln->link->copy_from(m_oCurrent->m_oInnerLink); + ln->apply(); - qreal x, y, z, t; - box_item *l_o = m_oItems[0]; + m_oCurrent = NULL; + } + else + { + // assume cancel + delete m_oCurrent; + m_oCurrent = NULL; + } + m_bPressed = false; + QGraphicsView::mouseReleaseEvent(i_oEv); + return; + } - x = z = l_o->x() + l_o->rect().width()/2; - y = t = l_o->y() + l_o->rect().height()/2; - foreach (box_item *l_oItem, m_oItems) + if (m_bScroll) { - if (l_oItem->x() < x) x = l_oItem->x(); - if (l_oItem->y() < y) y = l_oItem->y(); - if (l_oItem->x() > z) z = l_oItem->x() + l_oItem->rect().width(); - if (l_oItem->y() > t) t = l_oItem->y() + l_oItem->rect().height(); + QGraphicsView::mouseReleaseEvent(i_oEv); + m_bPressed = false; + m_bScroll = false; + viewport()->setCursor(Qt::ArrowCursor); + return; } - x -=100; y -= 100; z+=100, t += 100; - l_oR2 = QRectF(QPointF(x, y), QPointF(z, t)); - l_oR2 = l_oR2.united(QRectF(mapToScene(l_oRect.topLeft()), mapToScene(l_oRect.bottomRight()))); - if (l_oR2 == sceneRect()) return; - scene()->setSceneRect(l_oR2); + QGraphicsView::mouseReleaseEvent(i_oEv); + + m_bPressed = false; + { + //if (qAbs(p->m_iXX - v->pos().x()) + qAbs(p->m_iYY - v->pos().y()) > 0.1) { + + QPointF p = mapToScene(i_oEv->pos()) - m_oLastPoint; + if (qAbs(p.x()) > 3 || qAbs(p.y()) > 3) + { + mem_pos_box *mem = new mem_pos_box(m_oMediator, m_iId); + foreach (QGraphicsItem *l_oI1, scene()->selectedItems()) + { + if (connectable* item = dynamic_cast(l_oI1)) + { + data_box *box = item->m_oBox; + mem->prev_values[box] = QPointF(box->m_iXX, box->m_iYY); + mem->next_values[box] = l_oI1->pos(); + } + } + if (mem->prev_values.size() > 0) + { + mem->apply(); + } + else + { + delete mem; + } + } + } + check_canvas_size(); } +void box_view::notify_box_props(int id, const QList& items) +{ + Q_ASSERT(id == m_iId); + foreach (diagram_item* it, items) { + foreach (box_link *lnk, m_oLinks) + { + if (lnk->m_oLink == it) { + data_link* dat = static_cast(it); + lnk->m_oInnerLink.copy_from(*dat); + lnk->update(); + goto end; + } + } + + foreach (connectable *box, m_oItems.values()) + { + if (box->m_oBox == it) { + (dynamic_cast(box))->update(); + goto end; + } + } + end: + ; + } +} + +void box_view::notify_pos_box(int id, const QList& items) +{ + Q_ASSERT(id == m_iId); + foreach (data_box *box, items) + { + m_oItems[box->m_iId]->update_data(); + } +} + +void box_view::notify_size_box(int id, const QList& items) +{ + Q_ASSERT(id == m_iId); + foreach (data_box *box, items) + { + m_oItems[box->m_iId]->update_size(); + } +} + +int box_view::next_seq() +{ + do { + ++num_seq; + } while (m_oItems.contains(num_seq)); + return num_seq; +} + +void box_view::notify_focus(void* ptr) +{ + bool cond = ptr == this; + m_oAddItemAction->setEnabled(cond); + m_oDeleteAction->setEnabled(cond); + //m_oEditAction->setEnabled(cond); +} + +void box_view::message(const QString &s, int d) +{ + emit sig_message(s, d); +} #include "box_view.moc" diff -Nru semantik-0.7.3/src/fig/box_view.h semantik-0.8.3/src/fig/box_view.h --- semantik-0.7.3/src/fig/box_view.h 2009-08-30 11:35:31.000000000 +0000 +++ semantik-0.8.3/src/fig/box_view.h 2012-10-21 10:09:14.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef BOX_VIEW_H @@ -10,35 +10,26 @@ #include "con.h" class QActionGroup; +class connectable; class box_item; class box_link; -class data_control; +class data_link; +class data_box; +class diagram_item; +class sem_mediator; class box_view : public QGraphicsView { Q_OBJECT public: - box_view(QWidget*, data_control *); + box_view(QWidget*, sem_mediator *); ~box_view(); - void mousePressEvent(QMouseEvent *); - void mouseDoubleClickEvent(QMouseEvent*); - void wheelEvent(QWheelEvent*); void clear_diagram(); - void keyPressEvent(QKeyEvent*); - void keyReleaseEvent(QKeyEvent*); - bool event(QEvent *i_oEvent); - - QList m_oSelected; - QList m_oItems; QList m_oLinks; - void deselect_all(); - void add_select(QGraphicsItem*); - void rm_select(QGraphicsItem*); + QMap m_oItems; - void mouseMoveEvent(QMouseEvent*); - void mouseReleaseEvent(QMouseEvent*); QPointF m_oLastPoint; QPointF m_oLastMovePoint; @@ -50,11 +41,25 @@ void check_canvas_size(); QMenu* m_oMenu; - QMenu* m_oWidthMenu; - QMenu* m_oStyleMenu; + //QMenu* m_oWidthMenu; + //QMenu* m_oStyleMenu; + QMenu* m_oAddBoxMenu; + QMenu* m_oAlignMenu; + QMenu* m_oSizeMenu; QAction *m_oAddItemAction; - QAction *m_oEditAction; + QAction *m_oAddLabel; + QAction *m_oAddComponent; + QAction *m_oAddActor; + QAction *m_oAddUsecase; + QAction *m_oAddNode; + QAction *m_oAddDotStart; + QAction *m_oAddDotEnd; + QAction *m_oAddDecision; + QAction *m_oAddParallelHorizontal; + QAction *m_oAddParallelVertical; + + QAction *m_oPropertiesAction; QAction *m_oDeleteAction; QAction *m_oColorAction; QAction *m_oMoveUpAction; @@ -65,17 +70,12 @@ void enable_menu_actions(); // like check_actions, but only for the popup menu - int next_id(); - int m_iId; // the item this diagram belongs to - // private - int m_iIdCounter; - - QString to_string(); + void sync_view(); void from_string(const QString &); - data_control *m_oControl; + sem_mediator *m_oMediator; box_link *m_oCurrent; @@ -83,20 +83,61 @@ QActionGroup *m_oWidthGroup; QActionGroup *m_oStyleGroup; + QActionGroup *m_oAlignGroup; + QActionGroup *m_oSizeGroup; + + void keyPressEvent(QKeyEvent *i_oEvent); + void keyReleaseEvent(QKeyEvent *i_oEvent); + + void mousePressEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent*); + void mouseReleaseEvent(QMouseEvent*); + void mouseDoubleClickEvent(QMouseEvent*); + void wheelEvent(QWheelEvent*); + + //void edit_off(); + + int next_seq(); + int num_seq; + + void message(const QString &, int); + bool m_bDisableGradient; public slots: + void change_colors(QAction* i_oAct); void enable_actions(); // used on focus in void slot_delete(); void slot_add_item(); void slot_color(); - void slot_edit(); + void slot_edit_properties(); + void slot_align(); + void slot_size(); void slot_move_up(); void slot_move_down(); - void synchro_doc(const hash_params& i_o); void slot_penstyle(); void slot_penwidth(); + + void slot_add_element(); + + void notify_focus(void* ptr); + void notify_add_item(int); + void notify_add_box(int, int); + void notify_del_box(int, int); + void notify_edit_box(int, int); + void notify_link_box(int id, data_link *link); + void notify_unlink_box(int id, data_link* link); + void notify_box_props(int id, const QList&); + void notify_pos_box(int, const QList&); + void notify_size_box(int, const QList&); + void notify_change_link_box(int id, data_link*link); + + void notify_select(const QList& unsel, const QList& sel); + void notify_export_item(int); + + signals: + void sig_message(const QString &, int); }; #endif diff -Nru semantik-0.7.3/src/fig/ed:table.h semantik-0.8.3/src/fig/ed:table.h --- semantik-0.7.3/src/fig/ed:table.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/ed:table.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,16 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef editable_h +#define editable_h + +#define CTRLSIZE 8 + +class editable +{ + public: + editable() {} + virtual void properties() = 0; +}; + +#endif // editable_h + diff -Nru semantik-0.7.3/src/fig/mem_box.cpp semantik-0.8.3/src/fig/mem_box.cpp --- semantik-0.7.3/src/fig/mem_box.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/mem_box.cpp 2012-10-21 10:09:14.000000000 +0000 @@ -0,0 +1,299 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include +/* + */ %: include "con.h" + #include + #include "sembind.h" + #include "data_item.h" + %: include "sem_mediator.h" + +#include "mem_box.h" + +mem_del_box::mem_del_box(sem_mediator* mod, int id) : mem_command(mod) +{ + m_iId = id; +} + +void mem_del_box::init(QList _items, QList _links) +{ + items = _items; + links = _links; +} + + +void mem_del_box::undo() +{ + data_item *item = model->m_oItems[m_iId]; + foreach (data_box *k, items) { + item->m_oBoxes[k->m_iId] = k; + model->notify_add_box(m_iId, k->m_iId); + } + foreach (data_link *k, links) { + item->m_oLinks.append(k); + model->notify_link_box(m_iId, k); + } + undo_dirty(); +} + +void mem_del_box::redo() +{ + data_item *item = model->m_oItems[m_iId]; + foreach (data_link *k, links) { + model->notify_unlink_box(m_iId, k); + item->m_oLinks.removeAll(k); + } + foreach (data_box *k, items) { + model->notify_del_box(m_iId, k->m_iId); + item->m_oBoxes.remove(k->m_iId); + } + redo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_add_box::mem_add_box(sem_mediator* mod, int id, int boxid) : mem_command(mod) +{ + item = NULL; + m_iId = id; + item = model->m_oItems.value(id); + + box = new data_box(boxid); + box->color = QColor("#cafeba"); +} + +void mem_add_box::redo() +{ + item->m_oBoxes[box->m_iId] = box; + model->notify_add_box(item->m_iId, box->m_iId); + redo_dirty(); +} + +void mem_add_box::undo() +{ + model->notify_del_box(item->m_iId, box->m_iId); + item->m_oBoxes.remove(box->m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_edit_box::mem_edit_box(sem_mediator* mod, int id, int bid) : mem_command(mod) { + item = model->m_oItems[id]; + box = item->m_oBoxes[bid]; + oldText = box->m_sText; + oldHeight = box->m_iHH; +} + +void mem_edit_box::redo() +{ + box->m_sText = newText; + box->m_iHH = newHeight; + model->notify_edit_box(item->m_iId, box->m_iId); + redo_dirty(); +} + +void mem_edit_box::undo() +{ + box->m_sText = oldText; + box->m_iHH = oldHeight; + model->notify_edit_box(item->m_iId, box->m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_link_box::mem_link_box(sem_mediator* mod, int id) : mem_command(mod) { + m_iId = id; +} + +void mem_link_box::init(int parent, int parentPos, int child, int childPos) { + link = new data_link(); + link->m_iParent = parent; + link->m_iParentPos = parentPos; + link->m_iChild = child; + link->m_iChildPos = childPos; +} + +void mem_link_box::redo() { + //qDebug()<<"redo mem_link_box"<m_oItems[m_iId]->m_oLinks.append(link); + model->notify_link_box(m_iId, link); + redo_dirty(); +} + +void mem_link_box::undo() { + //qDebug()<<"undo mem_link_box"<notify_unlink_box(m_iId, link); + model->m_oItems[m_iId]->m_oLinks.removeAll(link); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_unlink_box::mem_unlink_box(sem_mediator* mod, int id) : mem_command(mod) { + m_iId = id; +} + +void mem_unlink_box::redo() { + //qDebug()<<"redo mem_link_box"<notify_unlink_box(m_iId, link); + model->m_oItems[m_iId]->m_oLinks.removeAll(link); + redo_dirty(); +} + +void mem_unlink_box::undo() { + //qDebug()<<"undo mem_link_box"<m_oItems[m_iId]->m_oLinks.append(link); + model->notify_link_box(m_iId, link); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +#define CH_COLOR 1 +#define CH_BORDER 2 +#define CH_PENST 4 + +mem_prop_box::mem_prop_box(sem_mediator* mod, int id) : mem_command(mod) { + m_iId = id; +} + +void mem_prop_box::redo() { + for (int i = prev_values.size(); i < items.size(); ++i) + { + diagram_item *cur = items.at(i); + diagram_item *it = new diagram_item(); + it->color = cur->color; + it->pen_style = cur->pen_style; + it->border_width = cur->border_width; + prev_values[cur] = it; + } + foreach (diagram_item *cur, items) { + if (change_type & CH_COLOR) { + cur->color = new_props.color; + } + if (change_type & CH_BORDER) { + cur->border_width = new_props.border_width; + } + if (change_type & CH_PENST) { + cur->pen_style = new_props.pen_style; + } + } + model->notify_box_props(m_iId, items); + redo_dirty(); +} + +void mem_prop_box::undo() { + foreach (diagram_item *cur, items) { + if (change_type & CH_COLOR) { + cur->color = prev_values[cur]->color; + } + if (change_type & CH_BORDER) { + cur->border_width = prev_values[cur]->border_width; + } + if (change_type & CH_PENST) { + cur->pen_style = prev_values[cur]->pen_style; + } + } + model->notify_box_props(m_iId, items); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_pos_box::mem_pos_box(sem_mediator* mod, int id) : mem_command(mod) +{ + m_iId = id; +} + +void mem_pos_box::redo() { + foreach (data_box* box, next_values.keys()) { + box->m_iXX = next_values[box].x(); + box->m_iYY = next_values[box].y(); + } + model->notify_pos_box(m_iId, next_values.keys()); + redo_dirty(); +} + +void mem_pos_box::undo() { + foreach (data_box* box, prev_values.keys()) { + box->m_iXX = prev_values[box].x(); + box->m_iYY = prev_values[box].y(); + } + model->notify_pos_box(m_iId, prev_values.keys()); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_change_link_box::mem_change_link_box(sem_mediator* mod, int id) : mem_command(mod) +{ + m_iId = id; +} + +void mem_change_link_box::redo() { + link->copy_from(next); + model->notify_change_link_box(m_iId, link); + redo_dirty(); +} + +void mem_change_link_box::undo() { + link->copy_from(prev); + model->notify_change_link_box(m_iId, link); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_size_box::mem_size_box(sem_mediator* mod, int id) : mem_command(mod) +{ + m_iId = id; +} + +void mem_size_box::redo() { + foreach (data_box* box, next_values.keys()) { + box->m_iXX = next_values[box].x(); + box->m_iYY = next_values[box].y(); + if (next_values[box].width() > 0) box->m_iWW = next_values[box].width(); + if (next_values[box].height() > 0) box->m_iHH = next_values[box].height(); + } + model->notify_size_box(m_iId, next_values.keys()); + redo_dirty(); +} + +void mem_size_box::undo() { + foreach (data_box* box, prev_values.keys()) { + box->m_iXX = prev_values[box].x(); + box->m_iYY = prev_values[box].y(); + if (prev_values[box].width() > 0) box->m_iWW = prev_values[box].width(); + if (prev_values[box].height() > 0) box->m_iHH = prev_values[box].height(); + } + model->notify_size_box(m_iId, prev_values.keys()); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_edit_link::mem_edit_link(sem_mediator* mod, int id) : mem_command(mod) +{ + m_iId = id; +} + +void mem_edit_link::redo() { + link->copy_from(next); + QList items; + items.append(link); + model->notify_box_props(m_iId, items); + redo_dirty(); +} + +void mem_edit_link::undo() { + link->copy_from(prev); + QList items; + items.append(link); + model->notify_box_props(m_iId, items); + undo_dirty(); +} + diff -Nru semantik-0.7.3/src/fig/mem_box.h semantik-0.8.3/src/fig/mem_box.h --- semantik-0.7.3/src/fig/mem_box.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/mem_box.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,163 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef MEM_BOX +#define MEM_BOX + +#include "QHash" +#include "QGraphicsItem" +#include "mem_command.h" + +class data_link; + +class mem_del_box : public mem_command { + public: + mem_del_box(sem_mediator*, int id); + void init(QList, QList); + void undo(); + void redo(); + + int m_iId; + QList items; + QList links; + + IType type() { return DEL_BOX; } +}; + + +class mem_add_box : public mem_command { + public: + mem_add_box(sem_mediator*, int id, int boxid); + void undo(); + void redo(); + + int m_iId; + data_item* item; + data_box* box; + + double m_iXX; + double m_iYY; + + IType type() { return ADD_BOX; } +}; + +class mem_edit_box: public mem_command { + public: + mem_edit_box(sem_mediator*, int id, int box); + void undo(); + void redo(); + + data_item *item; + data_box *box; + + int oldHeight; + int newHeight; + + QString oldText; + QString newText; + IType type() { return EDIT_BOX; } +}; + +class mem_link_box : public mem_command { + public: + mem_link_box(sem_mediator*, int id); + void init(int, int, int, int); + void undo(); + void redo(); + + int m_iId; + data_link *link; + + IType type() { return LINK_BOX; } +}; + +class mem_unlink_box : public mem_command { + public: + mem_unlink_box(sem_mediator*, int id); + void undo(); + void redo(); + + int m_iId; + data_link *link; + + IType type() { return UNLINK_BOX; } +}; + +#define CH_COLOR 1 +#define CH_BORDER 2 +#define CH_PENST 4 + +class mem_prop_box : public mem_command { + public: + mem_prop_box(sem_mediator*, int id); + void undo(); + void redo(); + + int m_iId; + int change_type; + diagram_item new_props; + + // item -> item with value before + QList items; + + IType type() { return PROP_BOX; } + + private: + QHash prev_values; + +}; + +class mem_pos_box : public mem_command { + public: + mem_pos_box(sem_mediator*, int id); + void undo(); + void redo(); + + int m_iId; + QHash prev_values; + QHash next_values; + + IType type() { return POS_BOX; } +}; + +class mem_change_link_box : public mem_command { + public: + mem_change_link_box(sem_mediator*, int); + + int m_iId; + data_link prev; + data_link next; + data_link *link; + + void undo(); + void redo(); + IType type() { return CHANGE_LINK_BOX; } +}; + +class mem_size_box : public mem_command { + public: + mem_size_box(sem_mediator*, int); + void undo(); + void redo(); + int m_iId; + QHash prev_values; + QHash next_values; + IType type() { return SIZE_BOX; } +}; + +class mem_edit_link: public mem_command { + public: + mem_edit_link(sem_mediator*, int id); + void undo(); + void redo(); + + int m_iId; + data_link prev; + data_link next; + data_link *link; + QList items; + + IType type() { return EDIT_LINK; } +}; + +#endif + diff -Nru semantik-0.7.3/src/fig/res:zable.h semantik-0.8.3/src/fig/res:zable.h --- semantik-0.7.3/src/fig/res:zable.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/fig/res:zable.h 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,24 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef resize_h +#define resize_h + +#include +#include "box_view.h" +#include + +#define CTRLSIZE 8 + +class box_resize_point; +class resizable +{ + public: + resizable() {} + int m_iOrientation; + virtual QPointF validate_point(box_resize_point *p, const QPointF & orig) = 0; + virtual void commit_size(box_resize_point *p) = 0; + virtual void freeze(bool b) = 0; +}; + +#endif // resize_h + diff -Nru semantik-0.7.3/src/filters/semantik.py semantik-0.8.3/src/filters/semantik.py --- semantik-0.7.3/src/filters/semantik.py 2009-08-30 11:35:31.000000000 +0000 +++ semantik-0.8.3/src/filters/semantik.py 2012-08-26 23:18:48.000000000 +0000 @@ -1,6 +1,6 @@ #! /usr/bin/env python # encoding: utf-8 -# Thomas Nagy, 2007 (ita) +# Thomas Nagy, 2007-2012 import os, sys, tarfile, string @@ -50,17 +50,13 @@ tar.close() try: - file = open('con.xml', 'rb') - txt = file.read() - file.close() + with open('con.xml', 'rb') as f: + txt = f.read() os.remove('con.xml') - except: + except Exception: # will remove this at version >= 0.7 - file = open('com.xml', 'rb') - txt = file.read() - txt = filter(txt) - file.close() + with open('com.xml', 'rb') as f: + txt = filter(file.read()) os.remove('com.xml') - return txt diff -Nru semantik-0.7.3/src/fixed.ml semantik-0.8.3/src/fixed.ml --- semantik-0.7.3/src/fixed.ml 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/fixed.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,277 +0,0 @@ -(* - Thomas Nagy 2007-2009 GPLV3 -*) - -open Printf -open Hashtbl -open Random -open Apis - -exception Finished - -let sign x = - if x > 0. then 1.0 else - 1.0 - -let ortho_comp p v = - if p > 0. then - if v > 0. then - 2. -. v - else - 0. -. v -. 2. - else - v - -let ortho key val_lst = - - (* pivot and father *) - let p_a = container.prob.(Hashtbl.find container.rel key) - let p_b = container.prob.(key) - let vrx = p_a.sx -. p_b.sx - let vry = p_a.sy -. p_b.sy - - let ab = sqrt (vrx *. vrx +. vry *. vry) - - for i = 0 to Array.length val_lst - 1 do - for j = i + 1 to Array.length val_lst - 1 do - - (* COM: recompute everytime *) - let p_c = container.prob.(val_lst.(i)) - let vcx = p_c.sx -. p_b.sx - let vcy = p_c.sy -. p_b.sy - let cb = sqrt (vcx *. vcx +. vcy *. vcy) - - - let p_d = container.prob.(val_lst.(j)) - let vdx = p_d.sx -. p_b.sx - let vdy = p_d.sy -. p_b.sy - - let db = sqrt (vdx *. vdx +. vdy *. vdy) - - let x1 = cb *. ab and x2 = db *. ab - - if true (*|| ((x1< -0.1 || x1>0.1) && (x2< -0.1 || x2>0.1)) *) then - let p1 = ortho_comp (vcx *. vrx +. vcy *. vry) ((vcx *. vry -. vcy *. vrx) /. x1) - let p2 = ortho_comp (vdx *. vrx +. vdy *. vry) ((vdx *. vry -. vdy *. vrx) /. x2) - - if p1 < p2 then - (* apply the sort *) - (*Printf.fprintf stderr "replacing %d and %d\n" val_lst.(i) val_lst.(j)*) - let tmpx = p_c.sx and tmpy = p_c.sy - p_c.sx <- p_d.sx - p_c.sy <- p_d.sy - p_d.sx <- tmpx - p_d.sy <- tmpy - -let ortho2 key val_lst = - try - ortho key val_lst - with - | Not_found -> - () - -let calc_gap ddx ddy w h = - let xdos = 1. /. (w *. w) and ydos = 1. /. (h *. h) - let absdx = abs_float(ddx) and absdy = abs_float(ddy) - - if absdx > absdy then - let k = absdy /. absdx - let kdos = k *. k - sqrt( (1. +. kdos) /. (kdos *. ydos +. xdos) ) - else - let k = absdx /. absdy - let kdos = k *. k - sqrt( (1. +. kdos) /. (kdos *. xdos +. ydos) ) - -let check_pos () = - let size_max = container.size-1 - for i=0 to size_max do - let a = container.prob.(i) - for j=i+1 to size_max do - let b = container.prob.(j) - - let dx = b.sx -. a.sx and dy = b.sy -. a.sy - let dist_dos = dx *. dx +. dy *. dy - let dist = sqrt(dist_dos) - - if dist < 1. then - let rr = Random.float 20.0 - if dx > dy then - a.sx <- a.sx +. rr - b.sx <- b.sx -. rr - else - a.sy <- a.sy +. rr - b.sy <- b.sy -. rr - -let spring key val_lst = - let size = Array.length val_lst - 1 - for i = 0 to size do - let c = val_lst.(i) - let a = container.prob.(key) and b = container.prob.(c) - - let dx = b.sx -. a.sx and dy = b.sy -. a.sy - let ddx = abs_float(dx) and ddy = abs_float(dy) - let gap1 = calc_gap ddx ddy a.sw a.sh - let gap2 = calc_gap ddx ddy b.sw b.sh - - let dist = sqrt(dx *. dx +. dy *. dy) - - let fac = - if dist > gap1 +. gap2 then - (cst_spring -. dist +. gap1 +. gap2) /. dist - else - (cst_spring -. dist) /. dist - - a.fx <- a.fx -. dx *. fac - a.fy <- a.fy -. dy *. fac - - b.fx <- b.fx +. dx *. fac - b.fy <- b.fy +. dy *. fac - -let iter_forces arr = - let size_max = Array.length arr - 1 - (*let ideal_ = (cst_electric) ** (2.)*) - for i=0 to size_max do - - let a = container.prob.(arr.(i)) - for j=i+1 to size_max do - let b = container.prob.(arr.(j)) - - let dx = b.sx -. a.sx and dy = b.sy -. a.sy - let dist = sqrt(dx *. dx +. dy *. dy) - - (* COM: pow 7 : non-overlapping rectangles *) - let fac = (200. ** 7.) /. (dist ** 7. +. 0.01) +. (150. ** 2.5) /. (dist ** 2.5 +. 0.01) - - a.fx <- a.fx -. dx *. fac - a.fy <- a.fy -. dy *. fac - - b.fx <- b.fx +. dx *. fac - b.fy <- b.fy +. dy *. fac - -let iterate_impl gee = - - container.count <- container.count + 1 - check_pos () - - (*if container.count mod 47 = 0 then - Hashtbl.iter ortho2 container.padres - check_pos ()*) - - for i=0 to container.size-1 do - let a = container.prob.(i) - a.fx <- 0.0 - a.fy <- 0.0 - - Hashtbl.iter spring container.padres - Hashtbl.iter (fun _ v -> iter_forces (Array.of_list v)) gee - - let size_max = Array.length container.prob - 1 - - (* COM: now add the forces *) - let energy = ref 0.0 - for i=0 to size_max do - let a = container.prob.(i) - - (* COM: not too far *) - if a.fx > 1000. then a.fx <- 1000. - if a.fy > 1000. then a.fy <- 1000. - if a.fx < -1000. then a.fx <- -1000. - if a.fy < -1000. then a.fy <- -1000. - - if a.fx *. a.fx < 0.0001 then a.fx <- 0.0 - if a.fy *. a.fy < 0.0001 then a.fy <- 0.0 - - (* COM: compute the speed for the energy *) - let vx = (a.fx *. cst_time) - let vy = (a.fy *. cst_time) - - energy := !energy +. (vx *. vx +. vy *. vy) (* *. (a.sw *. a.sh) *) - - a.sx <- a.sx +. (a.fx *. cst_time) - a.sy <- a.sy +. (a.fy *. cst_time) - - !energy - - (* debug_all() *) - -let reorg_force x = - - ensure_init () - - - let groups = Hashtbl.create 5 - - let rec father_luke ivv gru = - try - let nu = Hashtbl.find gru ivv - father_luke nu gru - with - | Not_found -> ivv - - let foufou b = - let x = Hashtbl.find container.id_to_idx b.a and y = Hashtbl.find container.id_to_idx b.b - - let vati = father_luke x container.rel - try - let vec = Hashtbl.find groups vati - Hashtbl.replace groups vati (vec@[y]) - with - | Not_found -> Hashtbl.replace groups vati [y] - - - List.iter foufou container.links - - - (* COM: now the groups should contain all fathers from the map, with the list of all descendants *) - - let size = float_of_int(container.size) - try - while true do - let en = iterate_impl groups - if en < 0.05 *. size then raise Finished - if container.count > maxiter then raise Finished - (* Printf.fprintf stderr "%f %d\n" en container.size *) - with - | Finished -> - () - | _ -> - Printf.fprintf Pervasives.stderr "error in iterate" - - - - flush_all() - - (* COM: now scale the view *) - (* - let scx = ref 5000000 - let scy = ref 5000000 - for i = 0 to Array.length val_lst - 1 do - for j = i + 1 to Array.length val_lst - 1 do - - (* COM: recompute everytime *) - let p_c = container.prob.(val_lst.(i)) - let vcx = p_c.sx -. p_b.sx - let vcy = p_c.sy -. p_b.sy - let cb = sqrt (vcx *. vcx +. vcy *. vcy) - - - let p_d = container.prob.(val_lst.(j)) - let vdx = p_d.sx -. p_b.sx - let vdy = p_d.sy -. p_b.sy - - let db = sqrt (vdx *. vdx +. vdy *. vdy) - - let x1 = cb *. ab and x2 = db *. ab - - let gap1 = calc_gap ddx ddy a.sw a.sh - let gap2 = calc_gap ddx ddy b.sw b.sh - - scx := min !scx gap1 - scy := min !scy gap2 - - Printf.fprintf stderr "could reduce by %d %d" - Printf.fprintf stderr "end in iterate %d\n" container.count - flush_all () - *) - - diff -Nru semantik-0.7.3/src/fixed.mli semantik-0.8.3/src/fixed.mli --- semantik-0.7.3/src/fixed.mli 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/fixed.mli 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -(* - Thomas Nagy 2007-2009 GPLV3 -*) - -val reorg_force : int -> unit diff -Nru semantik-0.7.3/src/flag_scheme.cpp semantik-0.8.3/src/flag_scheme.cpp --- semantik-0.7.3/src/flag_scheme.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/flag_scheme.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,7 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include #include # include diff -Nru semantik-0.7.3/src/flag_scheme.h semantik-0.8.3/src/flag_scheme.h --- semantik-0.7.3/src/flag_scheme.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/flag_scheme.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,10 +1,12 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef FLAG_SCHEME_H #define FLAG_SCHEME_H -#include -#include +//#include +class QIcon; +//#include +class QSvgRenderer; #include #include diff -Nru semantik-0.7.3/src/force.ml semantik-0.8.3/src/force.ml --- semantik-0.7.3/src/force.ml 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/force.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,154 +0,0 @@ -(* - Thomas Nagy 2007-2009 GPLV3 -*) - -open Printf -open Hashtbl -open Apis - -let xpad = 25. -let ypad = 25. - -type nono = { bx: sbox; mutable child: nono array;} -type packing = { mutable rt: nono; mutable pw: float; mutable ph: float; } -type all = {mutable packs: packing list; } - -let rec height p = - (* COM: height of the tree, sum of all height of boxes *) - let y = Array.fold_left (fun acc x -> acc +. height x) 0. p.child - max y (p.bx.sh *. 2.) - -let rec height_pad p = - (* COM: height of the tree taking the y padding into account *) - let y = Array.fold_left (fun acc x -> acc +. height_pad x) 0. p.child +. float_of_int(Array.length p.child - 1) *. ypad - max y (p.bx.sh *. 2.) - -let find_middle p = - let y = height p - - (* COM: create an array of the ratio height / total height *) - let prev = ref 0. - let fufu x = - prev := !prev +. height x - abs_float(0.5 -. !prev /. y) - let mp = Array.map fufu p.child - - (* COM: keep the optimum, that is closer to 0 *) - let ev (i, min, v) x = - if x < v then - (i+1, i, x) - else - (i+1, min, v) - - (* COM: iterate with tuples, hmm :-) *) - let (a, b, c) = Array.fold_left ev (0, 0, 1.) mp - b - -let rec depth x = - if Array.length x.child < 1 then - 1 - else - Array.fold_left (fun v x -> max v (1 + depth x)) 1 x.child - -let deb x = - let mid = find_middle x.rt - - let total = ref (height_pad x.rt) - if Array.length x.rt.child > 1 then - total := !total -. ypad - - (* COM: maximum width at each level of the tree *) - let arr = Array.make (depth x.rt) 0. - let rec maxi x d = - arr.(d) <- max arr.(d) x.bx.sw - Array.iter (fun x -> maxi x (d+1)) x.child - maxi x.rt 0 - - let rec pack_left y pp hh n = - let x = y.bx and p = pp.bx - x.sx <- p.sx -. 2. *. arr.(n-1) -. x.sw +. p.sw -. xpad - - let mh = height_pad y - x.sy <- hh +. mh /. 2. - - let tmp = ref (hh) - for i=0 to Array.length y.child -1 do - tmp := pack_left y.child.(i) y (!tmp) (n+1) - if i < Array.length y.child -1 then - tmp := !tmp +. ypad - hh +. mh - - let rec pack_right y pp hh n = - let x = y.bx and p = pp.bx - x.sx <- p.sx +. 2. *. arr.(n-1) +. x.sw -. p.sw +. xpad - - let mh = height_pad y - x.sy <- hh +. mh /. 2. - - let tmp = ref (hh) - for i=0 to Array.length y.child -1 do - tmp := pack_right y.child.(i) y (!tmp) (n+1) - if i < Array.length y.child -1 then - tmp := !tmp +. ypad - hh +. mh - - (* COM: for left and right, compute the y position of the item for vertical alignment *) - let size_left = ref 0. - if mid > 0 then - size_left := float_of_int(mid) *. ypad - - for i=0 to mid do - size_left := !size_left +. height_pad x.rt.child.(i) - let size_right = ref (!total -. !size_left) - - (* COM: now apply the padding *) - let buf_left = ref (x.rt.bx.sy -. !size_left /. 2.) - for i=0 to mid do - buf_left := ypad +. pack_left x.rt.child.(i) x.rt (!buf_left) 1 - - let buf_right = ref (x.rt.bx.sy -. !size_right /. 2.) - for i=mid+1 to Array.length x.rt.child - 1 do - buf_right := ypad +. pack_right x.rt.child.(i) x.rt (!buf_right) 1 - -let reorg_fixed () = - - ensure_init () - - for i=0 to container.size-1 do - let a = container.prob.(i) - a.fx <- 0.0 - a.fy <- 0.0 - - let mp = Array.map (fun x -> {bx = x; child = [||]}) container.prob - - let ch x = - try - let tmp = Hashtbl.find container.padres x - Array.map (fun y -> mp.(y)) tmp - with - | Not_found -> - [||] - - (* COM: mp is an array of nono struct *) - for i=0 to container.size-1 do - mp.(i).child <- ch i - - (* COM: find the objects which do not have an ancestor, ban is a hashtable of nono struct *) - let ban = Hashtbl.create container.size - Hashtbl.iter (fun _ vv -> Array.iter (fun x -> Hashtbl.add ban x 0) vv) container.padres - - (* COM: for all roots, apply the layout - we create a list of tree (packing struct) *) - let all_root = {packs = [];} - for i=0 to container.size - 1 do - try - let _ = Hashtbl.find ban i - () - with - | Not_found -> - all_root.packs <- all_root.packs @ [ {rt = mp.(i); pw=0.; ph=0.} ] - - (* COM: Printf.fprintf stderr "found %d roots\n" (List.length all_root.packs) *) - List.iter (fun x -> if Array.length x.rt.child > 0 then deb x) all_root.packs - - container.count <- 1 - diff -Nru semantik-0.7.3/src/force.mli semantik-0.8.3/src/force.mli --- semantik-0.7.3/src/force.mli 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/force.mli 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -(* - Thomas Nagy 2007-2009 GPLV3 -*) - -val reorg_fixed : unit -> unit - diff -Nru semantik-0.7.3/src/generator_dialog.cpp semantik-0.8.3/src/generator_dialog.cpp --- semantik-0.7.3/src/generator_dialog.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/generator_dialog.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -1,11 +1,10 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include #include #include -#include -#include +#include #include #include #include @@ -24,45 +23,47 @@ #include "generator_dialog.h" generator_dialog::generator_dialog(QWidget *i_oParent, QList i_oLst): - QDialog(i_oParent), + KDialog(i_oParent), m_oLst(i_oLst) { - setObjectName(trUtf8("Generator dialog")); + QWidget *widget = new QWidget(this); + setCaption(trUtf8("Generate documents")); + setButtons(KDialog::Ok | KDialog::Cancel); - QGridLayout *l_oGridLayout = new QGridLayout(this); + QGridLayout *l_oGridLayout = new QGridLayout(widget); - QLabel *label = new QLabel(this); + QLabel *label = new QLabel(widget); label->setText(trUtf8("Generators")); - QLabel *label2 = new QLabel(this); + QLabel *label2 = new QLabel(widget); label2->setText(trUtf8("Description")); l_oGridLayout->addWidget(label, 0, 0, 1, 2); l_oGridLayout->addWidget(label2, 0, 2, 1, 1); - m_oTree = new QTreeWidget(this); + m_oTree = new QTreeWidget(widget); m_oTree->header()->hide(); l_oGridLayout->addWidget(m_oTree, 1, 0, 1, 2); m_oTree->setFocusPolicy(Qt::NoFocus); - m_oTextEdit = new QTextEdit(this); + m_oTextEdit = new QTextEdit(widget); m_oTextEdit->setReadOnly(true); l_oGridLayout->addWidget(m_oTextEdit, 1, 2, 1, 1); m_oTextEdit->setFocusPolicy(Qt::NoFocus); - label = new QLabel(this); + label = new QLabel(widget); label->setText(trUtf8("Name")); l_oGridLayout->addWidget(label, 2, 0, 1, 1); - m_oName = new QLineEdit(this); + m_oName = new QLineEdit(widget); l_oGridLayout->addWidget(m_oName, 2, 1, 1, 2); - label = new QLabel(this); + label = new QLabel(widget); label->setText(trUtf8("Location")); l_oGridLayout->addWidget(label, 3, 0, 1, 1); - m_oLocation = new QLineEdit(this); + m_oLocation = new QLineEdit(widget); l_oGridLayout->addWidget(m_oLocation, 3, 1, 1, 2); QCompleter *l_oCompleter = new QCompleter(); QDirModel *l_oDirModel = new QDirModel(l_oCompleter); @@ -72,42 +73,6 @@ m_oLocation->setCompleter(l_oCompleter); - - QSpacerItem *spacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); - - l_oGridLayout->addItem(spacerItem, 4, 4, 1, 1); - - QDialogButtonBox *l_oButtonBox = new QDialogButtonBox(this); - l_oButtonBox->setOrientation(Qt::Horizontal); - - /* - The trolls may well support the gay computer (tm) and winblows, - yet they cannot even provide accelerators on QDialog buttons - - setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok); - */ - QPushButton *b = NULL; - b = new QPushButton(trUtf8("&Ok")); - b->setDefault(true); - connect(b, SIGNAL(pressed()), this, SLOT(slot_accept())); - l_oButtonBox->addButton(b, QDialogButtonBox::YesRole); - b = new QPushButton(trUtf8("&Cancel")); - connect(b, SIGNAL(clicked()), this, SLOT(reject())); - l_oButtonBox->addButton(b, QDialogButtonBox::NoRole); - - - l_oGridLayout->addWidget(l_oButtonBox, 5, 0, 1, 3); - - - QSize size(421, 250); - size = size.expandedTo(minimumSizeHint()); - resize(size); - - //connect(l_oButtonBox, SIGNAL(accepted()), this, SLOT(slot_accept())); - //connect(l_oButtonBox, SIGNAL(rejected()), this, SLOT(reject())); - - - foreach (template_entry l_o, m_oLst) { QTreeWidgetItem *l_oItem = new QTreeWidgetItem(m_oTree); @@ -117,6 +82,13 @@ } connect(m_oTree, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(selection_changed(QTreeWidgetItem *, int))); + + + setMainWidget(widget); + + QSize size(421, 250); + size = size.expandedTo(minimumSizeHint()); + resize(size); } void generator_dialog::selection_changed(QTreeWidgetItem * i_oItem, int i_oCol) @@ -134,20 +106,26 @@ } -void generator_dialog::slot_accept() -{ - if (m_sCurrent.length()<2) +void generator_dialog::slotButtonClicked(int button) { + if (button == KDialog::Ok) { - KMessageBox::sorry(this, trUtf8("No document generator chosen."), trUtf8("Missing data")); - return; + if (m_sCurrent.length()<2) + { + KMessageBox::sorry(this, trUtf8("No document generator chosen."), trUtf8("Missing data")); + return; + } + QFileInfo l_oFi(m_oLocation->text()); + if (!l_oFi.isDir() || !l_oFi.isWritable()) + { + KMessageBox::sorry(this, trUtf8("Invalid output directory %1").arg(m_oLocation->text()), trUtf8("Missing location")); + return; + } + accept(); } - QFileInfo l_oFi(m_oLocation->text()); - if (!l_oFi.isDir() || !l_oFi.isWritable()) + else { - KMessageBox::sorry(this, trUtf8("Invalid output directory %1").arg(m_oLocation->text()), trUtf8("Missing location")); - return; + KDialog::slotButtonClicked(button); } - accept(); } void generator_dialog::activate_from_name(const QString &i_s) diff -Nru semantik-0.7.3/src/generator_dialog.h semantik-0.8.3/src/generator_dialog.h --- semantik-0.7.3/src/generator_dialog.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/generator_dialog.h 2012-10-21 10:09:17.000000000 +0000 @@ -1,9 +1,9 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef GENERATOR_DIALOG_H #define GENERATOR_DIALOG_H -#include +#include #include "con.h" #include "template_entry.h" @@ -11,7 +11,7 @@ class QLineEdit; class QTextEdit; class QTreeWidgetItem; -class generator_dialog : public QDialog +class generator_dialog : public KDialog { Q_OBJECT public: @@ -26,7 +26,7 @@ public slots: void selection_changed(QTreeWidgetItem *i_o, int i_oCol); - void slot_accept(); + void slotButtonClicked(int button); void activate_from_name(const QString &i_s); }; diff -Nru semantik-0.7.3/src/image_view.cpp semantik-0.8.3/src/image_view.cpp --- semantik-0.7.3/src/image_view.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/image_view.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -15,27 +17,26 @@ #include #include #include +#include #include "con.h" #include "data_item.h" -#include "data_control.h" +#include "sem_mediator.h" #include "image_view.h" -image_view::image_view(QWidget *i_oParent, data_control *i_oControl) : QWidget(i_oParent) +image_view::image_view(QWidget *i_oParent, sem_mediator *i_oControl) : QWidget(i_oParent) { setCursor(Qt::PointingHandCursor); - m_oControl = i_oControl; + m_oMediator = i_oControl; m_iId = NO_ITEM; setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(context_menu(const QPoint&))); - ///* FIXME cette action n'a pas de raccourci */ m_oChangePictureAction = new QAction(trUtf8("Change picture"), this); connect(m_oChangePictureAction, SIGNAL(triggered()), this, SLOT(change_pic())); addAction(m_oChangePictureAction); - ///* FIXME cette action n'a pas de raccourci */ m_oClearPictureAction = new QAction(trUtf8("Clear picture"), this); connect(m_oClearPictureAction, SIGNAL(triggered()), this, SLOT(clear_pic())); addAction(m_oClearPictureAction); @@ -95,49 +96,28 @@ } } -void image_view::synchro_doc(const hash_params & i_o) -{ - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) - { - case cmd_select_item: - { - m_iId = i_o[data_id].toInt(); - if (m_iId <= NO_ITEM) - { - m_oPixmap = QPixmap(); - } - else - { - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - m_oPixmap = l_oData->m_oPix; - } - repaint(); - } - break; - default: - break; +void image_view::notify_select(const QList& unsel, const QList& sel) { + bool one = (sel.size() == 1); + if (one) { + m_iId = sel.at(0); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + m_oPixmap = l_oData->getPix(); + } else { + m_oPixmap = QPixmap(); + m_iId = NO_ITEM; } + repaint(); } void image_view::clear_pic() { - m_oControl->m_oImgs.removeAll(m_iId); - m_oPixmap = QPixmap(); - - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - - l_oData->m_oPix = QPixmap(); - l_oData->m_oThumbnail = QPixmap(); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); - QString l_s = QString(m_oControl->m_sTempDir+"/pic-%1.png").arg(QString::number(m_iId)); - if (QFile::exists(l_s)) - { - QFile l_oFile(l_s); - l_oFile.remove(); - } - m_oControl->update_item(m_iId, view_img); - repaint(); + mem_pic *mem = new mem_pic(m_oMediator); + mem->sel = l_oData; + mem->m_iOldId = l_oData->m_iPicId; + mem->m_iNewId = NO_ITEM; + mem->apply(); } #include "image_view.moc" @@ -149,7 +129,7 @@ if (m_iId) { QHelpEvent *l_oEv = static_cast(i_oEvent); - data_item *l_oData = m_oControl->m_oItems.value(m_iId); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); QToolTip::showText(l_oEv->globalPos(), l_oData->m_sPicLocation); } } @@ -162,8 +142,8 @@ if (!m_oMenu) { m_oMenu = new QMenu(this); - m_oMenu->addAction(m_oChangePictureAction); - m_oMenu->addAction(m_oClearPictureAction); + m_oMenu->addAction(m_oChangePictureAction); + m_oMenu->addAction(m_oClearPictureAction); } m_oMenu->popup(mapToGlobal(i_o)); } @@ -181,60 +161,29 @@ void image_view::change_pic() { - QString l_sText = QFileDialog::getOpenFileName(this, trUtf8("Choose a file"), QString(), - trUtf8("Image files (*.png *.jpg *.jpeg *.gif)")); - do_change_pic(l_sText); + KUrl l_o = KFileDialog::getOpenUrl(KUrl(notr("kfiledialog:///image")), + trUtf8("*.png *.jpg *.jpeg *.gif|Image Files (*.png *.jpg *.jpeg *.gif)"), + this, trUtf8("Choose a picture")); + do_change_pic(l_o); } -void image_view::do_change_pic(const QString& l_sText) +void image_view::do_change_pic(const KUrl& l_sText) { - if (!QFile::exists(l_sText)) - { - emit sig_message(trUtf8("File %1 does not exist").arg(l_sText), 20000); - return; - } - - QFile l_oInFile(l_sText); - if (!l_oInFile.open(QIODevice::ReadOnly)) - { - emit sig_message(trUtf8("File %1 could not be opened").arg(l_sText), 20000); - return; - } + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + int id = m_oMediator->next_pic_seq(); - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - bool l_bRet = l_oData->load_from_path(l_sText); + bool l_bRet = m_oMediator->save_and_load_picture(l_sText, id); if (!l_bRet) { - emit sig_message(trUtf8("something bad happened"), 20000); - return; - } - m_oControl->update_item(m_iId, view_img); - - m_oPixmap = l_oData->m_oPix; - repaint(); - //m_oPixmap->setScaledContents(true); - - QStringList l = l_sText.split("."); - QString l_sNameOut = QString(m_oControl->m_sTempDir+"/pic-%1.%2").arg(QString::number(m_iId)).arg(l[l.size()-1]); - QFile l_oOutFile(l_sNameOut); - if (!l_oOutFile.open(QIODevice::WriteOnly)) - { - emit sig_message(trUtf8("something worse happened"), 20000); + emit sig_message(trUtf8("Could not load the picture"), 20000); return; } - char l_oBuf[8192]; - while (1) - { - int l_oLen = l_oInFile.read(l_oBuf, 8192); - if (l_oLen == 0) break; - l_oOutFile.write(l_oBuf, l_oLen); - } - l_oInFile.close(); - l_oOutFile.close(); - - l_oData->m_sPicLocation = l_sText; - if (!m_oControl->m_oImgs.contains(m_iId)) m_oControl->m_oImgs.push_back(m_iId); + mem_pic *mem = new mem_pic(m_oMediator); + mem->sel = l_oData; + mem->m_iOldId = l_oData->m_iPicId; + mem->m_iNewId = id; + mem->apply(); } void image_view::dragEnterEvent(QDragEnterEvent *i_o) @@ -285,3 +234,35 @@ i_o->accept(); } +void image_view::notify_pic(int id) +{ + if (m_iId == id) + { + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + m_oPixmap = l_oData->getPix(); + repaint(); + } +} + +void image_view::notify_export_item(int id) +{ + data_item *l_oData = m_oMediator->m_oItems.value(id); + if (l_oData->m_iDataType != VIEW_IMG) + return; + if (l_oData->m_iPicId != NO_ITEM) + { + QDir l_oDir(m_oMediator->m_sTempDir); + QFileInfoList l_oLst = l_oDir.entryInfoList(); + foreach (QFileInfo l_oInfo, l_oLst) { + QString l_sName = l_oInfo.fileName(); + if (l_sName.startsWith(notr("img-%1").arg(QString::number(l_oData->m_iPicId)))) + { + QFile f(l_oInfo.absoluteFilePath()); + QString newName = l_oInfo.fileName().replace(QRegExp("img-\\d+"), QString("diag-%1").arg(QString::number(id))); + f.copy(newName); // TODO works for now + break; + } + } + } +} + diff -Nru semantik-0.7.3/src/image_view.h semantik-0.8.3/src/image_view.h --- semantik-0.7.3/src/image_view.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/image_view.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef IMAGE_VIEW_H #define IMAGE_VIEW_H @@ -7,17 +7,19 @@ #include #include "c\ on.h" +#include class QMenu; class image_view : public QWidget { Q_OBJECT public: - image_view(QWidget*, data_control*); - data_control *m_oControl; + image_view(QWidget*, sem_mediator*); + sem_mediator *m_oMediator; QPixmap m_oPixmap; int m_iId; + // yes, we could use a QLabel... void paintEvent(QPaintEvent*); QMenu *m_oMenu; @@ -27,7 +29,7 @@ bool event(QEvent*); void mouseReleaseEvent(QMouseEvent*); - void do_change_pic(const QString&); + void do_change_pic(const KUrl&); void dragEnterEvent(QDragEnterEvent*); void dragMoveEvent(QDragMoveEvent*); @@ -38,10 +40,12 @@ void sig_message(const QString&, int); public slots: - void synchro_doc(const hash_params&); void clear_pic(); void change_pic(); + void notify_pic(int id); void context_menu(const QPoint&); + void notify_select(const QList& unsel, const QList& sel); + void notify_export_item(int id); }; #endif Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/src/images/semantik-16.png and /tmp/YNuC9JdPw2/semantik-0.8.3/src/images/semantik-16.png differ Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/src/images/semantik-32.png and /tmp/YNuC9JdPw2/semantik-0.8.3/src/images/semantik-32.png differ diff -Nru semantik-0.7.3/src/linear_container.cpp semantik-0.8.3/src/linear_container.cpp --- semantik-0.7.3/src/linear_container.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/linear_container.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -8,14 +8,14 @@ #include #include -#include "data_control.h" +#include "sem_mediator.h" #include "linear_container.h" #include "linear_view.h" #include "con.h" -linear_container::linear_container(QWidget *i_oParent, data_control *i_oControl) : QWidget(i_oParent) +linear_container::linear_container(QWidget *i_oParent, sem_mediator *i_oControl) : QWidget(i_oParent) { - m_oControl = i_oControl; + m_oMediator = i_oControl; QGridLayout *l_oLayout = new QGridLayout(); m_oView = new linear_view(this, i_oControl); @@ -40,13 +40,3 @@ setLayout(l_oLayout); } -void linear_container::synchro_doc(const hash_params& i_oParams) -{ - m_oView->synchro_doc(i_oParams); -} - -#ifdef WAF -#include "linear_container.moc" -#endif - - diff -Nru semantik-0.7.3/src/linear_container.h semantik-0.8.3/src/linear_container.h --- semantik-0.7.3/src/linear_container.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/linear_container.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef LINEAR_CONTAINER_H #define LINEAR_CONTAINER_H @@ -8,19 +8,15 @@ #include "con.h" class QWidget; -class data_control; +class sem_mediator; class linear_view; class linear_container : public QWidget { - Q_OBJECT public: - linear_container(QWidget *i_oParent, data_control *i_oControl); + linear_container(QWidget *i_oParent, sem_mediator *i_oControl); - data_control *m_oControl; + sem_mediator *m_oMediator; linear_view *m_oView; - - public slots: - void synchro_doc(const hash_params&); }; #endif diff -Nru semantik-0.7.3/src/linear_view.cpp semantik-0.8.3/src/linear_view.cpp --- semantik-0.7.3/src/linear_view.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/linear_view.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -7,214 +7,104 @@ #include #include "data_item.h" -#include "data_control.h" +#include "sem_mediator.h" #include "linear_view.h" #include "con.h" -linear_view::linear_view(QWidget *i_oParent, data_control *i_oControl) : QTreeWidget(i_oParent) +linear_view::linear_view(QWidget *i_oParent, sem_mediator *i_oControl) : QTreeWidget(i_oParent) { setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(true); setDragDropMode(QAbstractItemView::InternalMove); header()->hide(); - m_oControl = i_oControl; - //connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), - // this, SLOT(doubleClickHandler(QTreeWidgetItem*, int))); - connect(this, SIGNAL(itemSelectionChanged()), - this, SLOT(selection_changed())); + m_oMediator = i_oControl; + connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(selection_changed())); m_bLockSelect = false; } -void linear_view::synchro_doc(const hash_params&i_o) +void linear_view::notify_add_item(int id) { - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) - { - case cmd_add_item: - { - QTreeWidgetItem *l_oItem = new QTreeWidgetItem(this); - int l_iId = i_o[data_id].toInt(); - l_oItem->setText(0, m_oControl->m_oItems.value(l_iId)->m_sSummary); - l_oItem->setData(0, Qt::UserRole, i_o[data_id]); - //l_oItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled); - addTopLevelItem(l_oItem); - m_oItems[l_iId] = l_oItem; - } - break; - case cmd_update_item: - { - if (i_o[data_orig].toInt() == view_linear) return; - - int l_iId = i_o[data_id].toInt(); - QTreeWidgetItem *l_oItem = m_oItems.value(l_iId); - l_oItem->setText(0, m_oControl->m_oItems.value(l_iId)->m_sSummary); - - data_item *l_o = m_oControl->m_oItems.value(l_iId); - l_oItem->setBackgroundColor(0, l_o->get_color_scheme().m_oInnerColor); - } - break; - case cmd_select_item: - { - m_bLockSelect = true; - - if (i_o[data_orig].toInt() == view_linear) - { - m_bLockSelect = false; - return; - } - - int l_iId = i_o[data_id].toInt(); - - QList l_oLst = selectedItems(); - if (l_oLst.size()>1) - { - foreach (QTreeWidgetItem* l_oItem, l_oLst) - { - l_oItem->setSelected(false); - } - } - else if (l_oLst.size()==1) - { - QTreeWidgetItem *l_oItem = l_oLst.at(0); - int l_iIdOld = l_oItem->data(0, Qt::UserRole).toInt(); - if (l_iIdOld != l_iId) - { - l_oItem->setSelected(false); - if (l_iId>0) - { - m_oItems.value(l_iId)->setSelected(true); - m_oItems.value(l_iId)->setExpanded(true); - } - } - } - else - { - //TODO dead code above - if (l_iId>NO_ITEM) - { - m_oItems.value(l_iId)->setSelected(true); - m_oItems.value(l_iId)->setExpanded(true); - } - } - m_bLockSelect = false; - } - break; - case cmd_link: - { - QTreeWidgetItem *l_oItem1 = m_oItems.value(i_o[data_id].toInt()); - QTreeWidgetItem *l_oItem2 = m_oItems.value(i_o[data_parent].toInt()); - QTreeWidgetItem *l_oRet = takeTopLevelItem(indexOfTopLevelItem(l_oItem1)); - Q_ASSERT(l_oRet != NULL); - l_oItem2->insertChild(l_oItem2->childCount(), l_oItem1); - l_oItem2->setExpanded(true); - - data_item *l_o = m_oControl->m_oItems.value(i_o[data_id].toInt()); - l_oItem1->setBackgroundColor(0, l_o->get_color_scheme().m_oInnerColor); - } - break; - case cmd_unlink: - { - QTreeWidgetItem *l_oItem1 = m_oItems.value(i_o[data_id1].toInt()); - QTreeWidgetItem *l_oItem2 = m_oItems.value(i_o[data_id2].toInt()); - if (l_oItem1->parent() == l_oItem2) - { - l_oItem2->takeChild(l_oItem2->indexOfChild(l_oItem1)); - l_oItem2->setExpanded(true); - addTopLevelItem(l_oItem1); - - data_item *l_o = m_oControl->m_oItems.value(i_o[data_id1].toInt()); - l_oItem1->setBackgroundColor(0, l_o->get_color_scheme().m_oInnerColor); - } - else if (l_oItem2->parent() == l_oItem1) - { - l_oItem1->takeChild(l_oItem1->indexOfChild(l_oItem2)); - l_oItem1->setExpanded(true); - addTopLevelItem(l_oItem2); + QTreeWidgetItem *l_oItem = new QTreeWidgetItem(this); + l_oItem->setText(0, m_oMediator->m_oItems.value(id)->m_sSummary); + l_oItem->setData(0, Qt::UserRole, id); + //l_oItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled); + addTopLevelItem(l_oItem); + m_oItems[id] = l_oItem; +} - data_item *l_o = m_oControl->m_oItems.value(i_o[data_id2].toInt()); - l_oItem2->setBackgroundColor(0, l_o->get_color_scheme().m_oInnerColor); - } - else - { - Q_ASSERT(1>1); - } - } - break; - case cmd_remove_item: - { - QTreeWidgetItem *l_oItem = m_oItems.value(i_o[data_id].toInt()); +void linear_view::notify_delete_item(int id) +{ + QTreeWidgetItem *l_oItem = m_oItems.value(id); - QTreeWidgetItem *l_oChild = NULL; - while ( (l_oChild = l_oItem->takeChild(0)) != NULL) - { - addTopLevelItem(l_oChild); - } - if (l_oItem->parent()) - l_oItem->parent()->takeChild(l_oItem->parent()->indexOfChild(l_oItem)); - else - takeTopLevelItem(indexOfTopLevelItem(l_oItem)); - delete l_oItem; - } - break; - case cmd_sort_item: - { - if (i_o[data_orig].toInt() == view_linear) return; + QTreeWidgetItem *l_oChild = NULL; + while ( (l_oChild = l_oItem->takeChild(0)) != NULL) + { + addTopLevelItem(l_oChild); + } + if (l_oItem->parent()) + l_oItem->parent()->takeChild(l_oItem->parent()->indexOfChild(l_oItem)); + else + takeTopLevelItem(indexOfTopLevelItem(l_oItem)); + delete l_oItem; +} - int l_iId = i_o[data_id].toInt(); +void linear_view::notify_link_items(int id1, int id2) +{ + QTreeWidgetItem *l_oItem1 = m_oItems.value(id2); + QTreeWidgetItem *l_oItem2 = m_oItems.value(id1); + QTreeWidgetItem *l_oRet = takeTopLevelItem(indexOfTopLevelItem(l_oItem1)); + Q_ASSERT(l_oRet != NULL); + l_oItem2->insertChild(l_oItem2->childCount(), l_oItem1); + l_oItem2->setExpanded(true); - QTreeWidgetItem *l_oItem = m_oItems.value(l_iId); - int l_iCnt = 0; - for (int i=0; im_oLinks.size(); i++) - { - QPoint l_oP = m_oControl->m_oLinks.at(i); - if (l_oP.x() == l_iId) - { - QTreeWidgetItem *l_oItem2 = m_oItems.value(l_oP.y()); - int l_iIndex = l_oItem->indexOfChild(l_oItem2); - if (l_iIndex != l_iCnt) - { - l_oItem->takeChild(l_iIndex); - l_oItem->insertChild(l_iCnt, l_oItem2); - } - l_iCnt++; - } - } - } - break; - default: - break; - } + data_item *l_o = m_oMediator->m_oItems.value(id2); + l_oItem1->setBackgroundColor(0, l_o->get_color_scheme().m_oInnerColor); } -#if 0 -void linear_view::doubleClickHandler(QTreeWidgetItem* i_oWidget, int) +void linear_view::notify_unlink_items(int id1, int id2) { - if (i_oWidget) + QTreeWidgetItem *l_oItem1 = m_oItems.value(id1); + QTreeWidgetItem *l_oItem2 = m_oItems.value(id2); + if (l_oItem1->parent() == l_oItem2) { - QTreeWidgetItem *l_oItem = new QTreeWidgetItem(i_oWidget); - l_oItem->setText(0, "hello"); + l_oItem2->takeChild(l_oItem2->indexOfChild(l_oItem1)); + l_oItem2->setExpanded(true); + addTopLevelItem(l_oItem1); + + data_item *l_o = m_oMediator->m_oItems.value(id1); + l_oItem1->setBackgroundColor(0, l_o->get_color_scheme().m_oInnerColor); + } + else if (l_oItem2->parent() == l_oItem1) + { + l_oItem1->takeChild(l_oItem1->indexOfChild(l_oItem2)); + l_oItem1->setExpanded(true); + addTopLevelItem(l_oItem2); + + data_item *l_o = m_oMediator->m_oItems.value(id2); + l_oItem2->setBackgroundColor(0, l_o->get_color_scheme().m_oInnerColor); } else { - QTreeWidgetItem *l_oItem = new QTreeWidgetItem(this); - l_oItem->setText(0, "hello"); - addTopLevelItem(l_oItem); + Q_ASSERT(1>1); } } -#endif void linear_view::selection_changed() { if (!m_bLockSelect) { QList l_oItems = selectedItems(); - if (l_oItems.size()) + QList lst; + + foreach (QTreeWidgetItem* it, l_oItems) { - QTreeWidgetItem *l_oItem = l_oItems.at(0); - int l_iIdOld = l_oItem->data(0, Qt::UserRole).toInt(); - m_oControl->select_item(l_iIdOld, view_linear); + lst.append(it->data(0, Qt::UserRole).toInt()); } + + mem_sel *sel = new mem_sel(m_oMediator); + sel->sel = lst; + sel->apply(); } } @@ -222,14 +112,8 @@ { foreach (QTreeWidgetItem *l_oItem, m_oItems.values()) { -#if 0 - if (i_oS.length() < 1) - { - l_oItem->setHidden(false); - } -#endif - - if (l_oItem->parent() != NULL) continue; + if (l_oItem->parent() != NULL) + continue; filter_item(l_oItem, i_oS); } } @@ -262,22 +146,35 @@ int l_iId = l_oChild->data(0, Qt::UserRole).toInt(); if (dropIndicatorPosition() == QAbstractItemView::OnItem) { - if (m_oControl->parent_of(l_iId)) m_oControl->unlink_items(l_iId, m_oControl->parent_of(l_iId)); + if (m_oMediator->parent_of(l_iId)) + { + mem_unlink *link = new mem_unlink(m_oMediator); + link->child = l_iId; + link->parent = m_oMediator->parent_of(l_iId); + link->apply(); + } + if (l_oItem != NULL) { - m_oControl->link_items(l_oItem->data(0, Qt::UserRole).toInt(), l_iId); + m_oMediator->link_items(l_oItem->data(0, Qt::UserRole).toInt(), l_iId); } } else if (l_oItem != NULL) { int j = l_oItem->data(0, Qt::UserRole).toInt(); - int k = m_oControl->parent_of(j); + int k = m_oMediator->parent_of(j); // make certain they have the same parent now - if (m_oControl->parent_of(l_iId) != k); + if (m_oMediator->parent_of(l_iId) != k); { - if (m_oControl->parent_of(l_iId)) m_oControl->unlink_items(l_iId, m_oControl->parent_of(l_iId)); - m_oControl->link_items(k, l_iId); + if (m_oMediator->parent_of(l_iId)) + { + mem_unlink *link = new mem_unlink(m_oMediator); + link->child = l_iId; + link->parent = m_oMediator->parent_of(l_iId); + link->apply(); + } + m_oMediator->link_items(k, l_iId); } int z = 1; // offset for re-inserting the item @@ -287,14 +184,17 @@ } int l = 0; // the index of the item drop - for (int i=0; im_oLinks.size(); i++) + for (int i=0; im_oLinks.size(); i++) { - QPoint l_oP = m_oControl->m_oLinks.at(i); + QPoint l_oP = m_oMediator->m_oLinks.at(i); if (l_oP.x() == k) // same parent { if (l_oP.y() == j) // item found { - m_oControl->sort_children(k, l_iId, l+z); + mem_sort *srt = new mem_sort(m_oMediator); + srt->init(k, l_iId, l+z); + srt->apply(); + break; } l++; @@ -303,14 +203,82 @@ } else { - if (m_oControl->parent_of(l_iId)) m_oControl->unlink_items(l_iId, m_oControl->parent_of(l_iId)); + if (m_oMediator->parent_of(l_iId)) + { + mem_unlink *link = new mem_unlink(m_oMediator); + link->child = l_iId; + link->parent = m_oMediator->parent_of(l_iId); + link->apply(); + } } - m_oControl->select_item(l_iId); + QList lst; + lst.append(l_iId); + mem_sel *sel = new mem_sel(m_oMediator); + sel->sel = lst; + sel->apply(); } } i_oEv->accept(); i_oEv->setDropAction(Qt::CopyAction); } +void linear_view::notify_select(const QList& unsel, const QList& sel) +{ + m_bLockSelect = true; + + QList l_oLst = selectedItems(); + foreach (QTreeWidgetItem* l_oItem, l_oLst) + { + int id = l_oItem->data(0, Qt::UserRole).toInt(); + if (!sel.contains(id)) + { + l_oItem->setSelected(false); + } + } + + foreach (int id, sel) + { + QTreeWidgetItem *item = m_oItems.value(id); + item->setSelected(true); + item->setExpanded(true); + } + + m_bLockSelect = false; +} + +void linear_view::notify_repaint(int id) +{ + QTreeWidgetItem *l_oItem = m_oItems.value(id); + data_item *l_o = m_oMediator->m_oItems.value(id); + l_oItem->setBackgroundColor(0, l_o->get_color_scheme().m_oInnerColor); +} + +void linear_view::notify_sort(int id) +{ + QTreeWidgetItem *l_oItem = m_oItems.value(id); + int l_iCnt = 0; + for (int i=0; im_oLinks.size(); i++) + { + QPoint l_oP = m_oMediator->m_oLinks.at(i); + if (l_oP.x() == id) + { + QTreeWidgetItem *l_oItem2 = m_oItems.value(l_oP.y()); + int l_iIndex = l_oItem->indexOfChild(l_oItem2); + if (l_iIndex != l_iCnt) + { + l_oItem->takeChild(l_iIndex); + l_oItem->insertChild(l_iCnt, l_oItem2); + } + l_iCnt++; + } + } +} + +void linear_view::notify_edit(int id) +{ + QTreeWidgetItem *l_oItem = m_oItems.value(id); + l_oItem->setText(0, m_oMediator->m_oItems.value(id)->m_sSummary); +} + #include "linear_view.moc" diff -Nru semantik-0.7.3/src/linear_view.h semantik-0.8.3/src/linear_view.h --- semantik-0.7.3/src/linear_view.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/linear_view.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef LINEAR_VIEW_H #define LINEAR_VIEW_H @@ -16,8 +16,8 @@ { Q_OBJECT public: - linear_view(QWidget *i_oParent, data_control *i_oControl); - data_control *m_oControl; + linear_view(QWidget *i_oParent, sem_mediator *i_oControl); + sem_mediator *m_oMediator; QMap m_oItems; @@ -28,10 +28,17 @@ bool m_bLockSelect; public slots: - void synchro_doc(const hash_params&); - //void doubleClickHandler(QTreeWidgetItem*, int); void filter_slot(const QString & i_oS); void selection_changed(); + + void notify_add_item(int id); + void notify_repaint(int id); + void notify_delete_item(int id); + void notify_link_items(int id1, int id2); + void notify_unlink_items(int id1, int id2); + void notify_select(const QList& unsel, const QList& sel); + void notify_sort(int id); + void notify_edit(int id); }; #endif diff -Nru semantik-0.7.3/src/main.cpp semantik-0.8.3/src/main.cpp --- semantik-0.7.3/src/main.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/main.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -1,8 +1,6 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include -#include -extern "C" { void caml_startup(char**); }; #include #include #include @@ -24,9 +22,13 @@ #include #include -static const char description[] = I18N_NOOP("Semantik - Creating better documents"); +static const char description[] = I18N_NOOP("A mind-mapping tool for KDE\nAvailable exclusively for open systems such as OpenSuse, Gentoo or Fedora."); static const char version[] = VERSION; +int grid_int(int x) { + return GRID * (x / GRID); +} + int main(int i_iArgc, char **i_iArgv) { int l_iSeed; @@ -34,34 +36,32 @@ l_oInfile.read(reinterpret_cast(&l_iSeed), sizeof(int)); l_oInfile.close(); srandom(l_iSeed); - caml_startup(i_iArgv); + + KCmdLineOptions options; + options.add("+[url]", ki18n("A file to open on startup")); KAboutData l_o("semantik", 0, ki18n("Semantik"), version, ki18n(description), - KAboutData::License_GPL_V3, ki18n("(C) 2007-2009 Thomas Nagy"), KLocalizedString(), - "tnagyemail-mail@yahoo.fr"); - l_o.addAuthor(ki18n("Thomas Nagy"), KLocalizedString(), "tnagyemail-mail@yahoo.fr"); + KAboutData::License_GPL_V3, ki18n("(C) 2007-2012 Thomas Nagy"), KLocalizedString(), + "tnagy@outlook.com"); + l_o.setBugAddress("http://code.google.com/p/semantik/issues/list"); + l_o.addAuthor(ki18n("Thomas Nagy"), KLocalizedString()); KCmdLineArgs::init(i_iArgc, i_iArgv, &l_o); + KCmdLineArgs::addCmdLineOptions(options); KApplication l_oApp; - //QApplication l_oApp(i_iArgc, i_iArgv); - //qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); - //QResource res(":/src/semantik_"+QLocale::system().name()+".qm"); - //qDebug()<<"res size "<insertCatalog("libkdeedu"); semantik_win *l_oMainWin = new semantik_win; l_oMainWin->show(); + + const KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + for (int i = 0; i < args->count(); ++i) + { + l_oMainWin->slot_recent(args->url(i)); + } + return l_oApp.exec(); } diff -Nru semantik-0.7.3/src/mem_command.cpp semantik-0.8.3/src/mem_command.cpp --- semantik-0.7.3/src/mem_command.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/mem_command.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -0,0 +1,587 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include +#include + +#include "data_item.h" +#include "mem_command.h" +#include "sem_mediator.h" + +inline uint qHash(const QPoint &p) { + return p.x() + p.y(); +} + +mem_command::mem_command(sem_mediator* mod) { + model = mod; +} + +void mem_command::apply() { + while (!model->m_oRedoStack.isEmpty()) + delete model->m_oRedoStack.pop(); + redo(); + model->m_oUndoStack.push(this); + model->check_undo(true); +} + +void mem_command::add() { + while (!model->m_oRedoStack.isEmpty()) + delete model->m_oRedoStack.pop(); + model->m_oUndoStack.push(this); + model->check_undo(true); +} + +void mem_command::redo_dirty() { + was_dirty = model->m_bDirty; + model->set_dirty(true); +} + +void mem_command::undo_dirty() { + model->set_dirty(was_dirty); +} + +/////////////////////////////////////////////////////////////////// + +mem_delete::mem_delete(sem_mediator* mod) : mem_command(mod) { + +} + +void mem_delete::init(QList lst) { + foreach (int id, lst) { + items.append(*model + id); + for (int i = 0; i < model->m_oLinks.size(); i++) { + QPoint p = model->m_oLinks.at(i); + if (p.x() == id || p.y() == id) { + links.insert(p); + } + } + } +} + +void mem_delete::redo() { + foreach (QPoint p, links) { + Q_ASSERT(model->m_oLinks.contains(p)); + model->m_oLinks.removeAll(p); + model->notify_unlink_items(p.x(), p.y()); + } + foreach (data_item* d, items) { + Q_ASSERT(model->m_oItems.contains(d->m_iId)); + model->notify_delete_item(d->m_iId); + model->m_oItems.remove(d->m_iId); + } + redo_dirty(); +} + +void mem_delete::undo() { + foreach (data_item* d, items) { + Q_ASSERT(!model->m_oItems.contains(d->m_iId)); + model->m_oItems[d->m_iId] = d; + model->notify_add_item(d->m_iId); + } + foreach (QPoint p, links) { + Q_ASSERT(!model->m_oLinks.contains(p)); + model->m_oLinks.append(p); + model->notify_link_items(p.x(), p.y()); + } + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_add::mem_add(sem_mediator* mod) : mem_command(mod) { + parent = NO_ITEM; +} + +void mem_add::init() { + item = new data_item(model, model->next_seq()); + sel = new mem_sel(model); +} + +void mem_add::redo() { + //qDebug()<<"redo mem_add"<m_iId; + Q_ASSERT(!model->m_oItems.contains(item->m_iId)); + model->m_oItems[item->m_iId] = item; + model->notify_add_item(item->m_iId); + if (parent) { + Q_ASSERT(!model->m_oLinks.contains(QPoint(parent, item->m_iId))); + model->m_oLinks.append(QPoint(parent, item->m_iId)); + model->notify_link_items(parent, item->m_iId); + } + + if (sel->sel.size() != 1) { + sel->sel.append(item->m_iId); + } + sel->redo(); + redo_dirty(); +} + +void mem_add::undo() { + //qDebug()<<"undo mem_add"<m_iId; + sel->undo(); + + if (parent) { + Q_ASSERT(model->m_oLinks.contains(QPoint(parent, item->m_iId))); + model->m_oLinks.removeAll(QPoint(parent, item->m_iId)); + model->notify_unlink_items(parent, item->m_iId); + } + Q_ASSERT(model->m_oItems.contains(item->m_iId)); + model->notify_delete_item(item->m_iId); + model->m_oItems.remove(item->m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_link::mem_link(sem_mediator* mod) : mem_command(mod) { + +} + +void mem_link::redo() { + //qDebug()<<"redo mem_link"<m_oLinks.contains(QPoint(parent, child))); + model->m_oLinks.append(QPoint(parent, child)); + model->notify_link_items(parent, child); + redo_dirty(); +} + +void mem_link::undo() { + //qDebug()<<"undo mem_link"<m_oLinks.contains(QPoint(parent, child))); + model->m_oLinks.removeAll(QPoint(parent, child)); + model->notify_unlink_items(parent, child); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_unlink::mem_unlink(sem_mediator* mod) : mem_command(mod) { + +} + +void mem_unlink::redo() { + //qDebug()<<"redo mem_link"<m_oLinks.contains(QPoint(parent, child))); + model->m_oLinks.removeAll(QPoint(parent, child)); + model->notify_unlink_items(parent, child); + redo_dirty(); +} + +void mem_unlink::undo() { + //qDebug()<<"undo mem_link"<m_oLinks.contains(QPoint(parent, child))); + model->m_oLinks.append(QPoint(parent, child)); + model->notify_link_items(parent, child); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_sel::mem_sel(sem_mediator* mod) : mem_command(mod) { + foreach (data_item* t, model->m_oItems.values()) { + if (t->m_bSelected) { + unsel.append(t->m_iId); + } + } +} + +void mem_sel::apply() { + //qDebug()<<"apply sel begin"<m_oUndoStack.size()<m_oRedoStack.size(); + + while (!model->m_oRedoStack.isEmpty()) + delete model->m_oRedoStack.pop(); + + // merge a previous selection if possible + while (!model->m_oUndoStack.empty()) { + mem_command *me = model->m_oUndoStack.pop(); + if (me->type() == SELECT) { + mem_sel *sal = (mem_sel*) me; + foreach (int i, sal->sel) { + if (!sel.contains(i) && !unsel.contains(i)) + sel.append(i); + } + foreach (int i, sal->unsel) { + if (!sel.contains(i) && !unsel.contains(i)) + unsel.append(i); + } + delete sal; + } else { + model->m_oUndoStack.push(me); + break; + } + } + + foreach (int k, sel) { + unsel.removeAll(k); + } + + // normal processing + redo(); + model->m_oUndoStack.push(this); + //qDebug()<<"apply sel end"<m_oUndoStack.size()<m_oRedoStack.size(); + model->check_undo(true); +} + +void mem_sel::redo() { + //qDebug()<<"redo mem_sel"<m_oItems[k]->m_bSelected = false; + } + foreach (int k, sel) { + model->m_oItems[k]->m_bSelected = true; + } + model->notify_select(unsel, sel); +} + +void mem_sel::undo() { + //qDebug()<<"undo mem_sel"<m_oItems[k]->m_bSelected = false; + } + foreach (int k, unsel) { + model->m_oItems[k]->m_bSelected = true; + } + model->notify_select(sel, unsel); +} + +/////////////////////////////////////////////////////////////////// + +mem_move::mem_move(sem_mediator* mod) : mem_command(mod) { + foreach (data_item* t, model->m_oItems.values()) { + if (t->m_bSelected) { + sel.append(t->m_iId); + } + } +} + +void mem_move::redo() { + //qDebug()<<"redo mem_move"<m_oItems[sel[i]]; + it->m_iXX = newPos[i].x(); + it->m_iYY = newPos[i].y(); + } + model->notify_move(sel, newPos); + redo_dirty(); +} + +void mem_move::undo() { + //qDebug()<<"undo mem_move"<m_oItems[sel[i]]; + it->m_iXX = oldPos[i].x(); + it->m_iYY = oldPos[i].y(); + } + model->notify_move(sel, oldPos); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_color::mem_color(sem_mediator* mod) : mem_command(mod) { + foreach (data_item* t, model->m_oItems.values()) { + if (t->m_bSelected) { + prevColors[t->m_iId] = t->m_iColor; + } + } +} + +void mem_color::redo() { + QMap::iterator i; + for (i = prevColors.begin(); i != prevColors.end(); ++i) + { + data_item *t = model->m_oItems[i.key()]; + t->m_iColor = newColor; + model->notify_repaint(i.key()); + } + redo_dirty(); +} + +void mem_color::undo() { + QMap::iterator i; + for (i = prevColors.begin(); i != prevColors.end(); ++i) + { + data_item *t = model->m_oItems[i.key()]; + t->m_iColor = i.value(); + model->notify_repaint(i.key()); + } + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_flag::mem_flag(sem_mediator* mod) : mem_command(mod) { + add = true; + foreach (data_item* t, model->m_oItems.values()) { + if (t->m_bSelected) { + prevFlags[t->m_iId] = t->m_oFlags; + } + } +} + +void mem_flag::redo() { + QMap >::iterator i; + for (i = prevFlags.begin(); i != prevFlags.end(); ++i) + { + data_item *t = model->m_oItems[i.key()]; + t->m_oFlags = QList(i.value()); + if (add) { + if (!t->m_oFlags.contains(flag)) { + t->m_oFlags.append(flag); + } + } else { + t->m_oFlags.removeAll(flag); + } + model->notify_flag(i.key()); + } + redo_dirty(); +} + +void mem_flag::undo() { + QMap >::iterator i; + for (i = prevFlags.begin(); i != prevFlags.end(); ++i) + { + data_item *t = model->m_oItems[i.key()]; + t->m_oFlags = i.value(); + model->notify_flag(i.key()); + } + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_edit::mem_edit(sem_mediator* mod) : mem_command(mod) { + foreach (data_item* t, model->m_oItems.values()) { + if (t->m_bSelected) { + sel = t; + } + } + oldSummary = sel->m_sSummary; +} + +void mem_edit::redo() { + sel->m_sSummary = newSummary; + model->notify_edit(sel->m_iId); + redo_dirty(); +} + +void mem_edit::undo() { + sel->m_sSummary = oldSummary; + model->notify_edit(sel->m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_datatype::mem_datatype(sem_mediator* mod) : mem_command(mod) { + sel = NULL; + foreach (data_item* t, model->m_oItems.values()) { + if (t->m_bSelected) { + sel = t; + oldDataType = sel->m_iDataType; + break; + } + } +} + +void mem_datatype::redo() { + sel->m_iDataType = newDataType; + model->notify_datatype(sel->m_iId); + redo_dirty(); +} + +void mem_datatype::undo() { + sel->m_iDataType = oldDataType; + model->notify_datatype(sel->m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_text::mem_text(sem_mediator* mod) : mem_command(mod) { +} + +void mem_text::redo() +{ + sel->m_sText = newText; + model->notify_text(sel->m_iId); + redo_dirty(); +} + +void mem_text::undo() +{ + sel->m_sText = oldText; + model->notify_text(sel->m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_vars::mem_vars(sem_mediator* mod) : mem_command(mod) { +} + +void mem_vars::redo() +{ + if (m_iId == NO_ITEM) + { + model->m_sHints = newVars; + } + else + { + data_item *item = model->m_oItems[m_iId]; + item->m_sHints = newVars; + } + model->notify_vars(m_iId); + redo_dirty(); +} + +void mem_vars::undo() +{ + if (m_iId == NO_ITEM) + { + model->m_sHints = oldVars; + } + else + { + data_item *item = model->m_oItems[m_iId]; + item->m_sHints = oldVars; + } + model->notify_vars(m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_pic::mem_pic(sem_mediator* mod) : mem_command(mod) { +} + +void mem_pic::redo() +{ + sel->m_iPicId = m_iNewId; + model->notify_pic(sel->m_iId); + redo_dirty(); +} + +void mem_pic::undo() +{ + sel->m_iPicId = m_iOldId; + model->notify_pic(sel->m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_table::mem_table(sem_mediator* mod) : mem_command(mod) { +} + +void mem_table::redo() +{ + data_item *item = model->m_oItems[m_iId]; + item->m_iNumRows = newNRows; + item->m_iNumCols = newNCols; + item->m_oTableData = newData; + + model->notify_table(m_iId); + redo_dirty(); +} + +void mem_table::undo() +{ + data_item *item = model->m_oItems[m_iId]; + item->m_iNumRows = oldNRows; + item->m_iNumCols = oldNCols; + item->m_oTableData = oldData; + + model->notify_table(m_iId); + undo_dirty(); +} + +/////////////////////////////////////////////////////////////////// + +mem_sort::mem_sort(sem_mediator* mod) : mem_command(mod) { +} + +void mem_sort::init(int i_iParent, int i_iChild, int i_iNum) +{ + m_iParent = i_iParent; + m_iChild = i_iChild; + + int i_iVal1 = -1; + int i_iVal2 = -1; + + for (int i=0; i < model->m_oLinks.size(); i++) + { + QPoint l_oP = model->m_oLinks.at(i); + if (l_oP.x() == i_iParent) + { + oldData.append(l_oP); + newData.append(l_oP); + } + } + + // very old code here + int l_iIdx = 0; + for (int i=0; i=0 && i_iVal2>=0) + { + if (i_iVal1 > i_iVal2) + { + newData.swap(i_iVal1, i_iVal2); + break; + } + else + { + int l_iPrev = i_iVal1; + for (int i=i_iVal1+1; im_oLinks.size(); i++) + { + QPoint l_oP = model->m_oLinks.at(i); + if (l_oP.x() == m_iParent) + { + model->m_oLinks.removeAt(i); + i--; + } + } + model->m_oLinks += newData; + model->notify_sort(m_iParent); + redo_dirty(); +} + +void mem_sort::undo() +{ + for (int i=0; i < model->m_oLinks.size(); i++) + { + QPoint l_oP = model->m_oLinks.at(i); + if (l_oP.x() == m_iParent) + { + model->m_oLinks.removeAt(i); + i--; + } + } + model->m_oLinks += oldData; + model->notify_sort(m_iParent); + undo_dirty(); +} + diff -Nru semantik-0.7.3/src/mem_command.h semantik-0.8.3/src/mem_command.h --- semantik-0.7.3/src/mem_command.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/mem_command.h 2012-08-26 23:18:50.000000000 +0000 @@ -0,0 +1,213 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef MEM_COMMAND +#define MEM_COMMAND + +#include +#include +#include +#include + +#include "data_item.h" + +class sem_mediator; +class mem_sel; +class mem_command { + public: + mem_command(sem_mediator*); + virtual ~mem_command() {}; + sem_mediator *model; + virtual void undo() = 0; + virtual void redo() = 0; + virtual void apply(); + virtual void redo_dirty(); + virtual void undo_dirty(); + void add(); + + bool was_dirty; + enum IType {DELETE, ADD, LINK, UNLINK, SELECT, MOVE, COLOR, FLAG, EDIT, DATATYPE, TEXT, VARS, PIC, TABLE, SORT, + ADD_BOX, DEL_BOX, EDIT_BOX, LINK_BOX, UNLINK_BOX, PROP_BOX, POS_BOX, CHANGE_LINK_BOX, SIZE_BOX, EDIT_LINK}; + virtual IType type() = 0; +}; + +class mem_delete : public mem_command { + public: + mem_delete(sem_mediator*); + void init(QList ids); + void undo(); + void redo(); + + QList items; + QSet links; + + IType type() { return DELETE; } +}; + +class mem_add : public mem_command { + public: + mem_add(sem_mediator*); + void init(); + void undo(); + void redo(); + + data_item* item; + int parent; + + mem_sel *sel; + + IType type() { return ADD; } +}; + +class mem_link : public mem_command { + public: + mem_link(sem_mediator*); + void undo(); + void redo(); + + int parent; + int child; + + IType type() { return LINK; } +}; + +class mem_unlink : public mem_command { + public: + mem_unlink(sem_mediator*); + void undo(); + void redo(); + + int parent; + int child; + IType type() { return UNLINK; } +}; + +class mem_sel : public mem_command { + public: + mem_sel(sem_mediator*); + void undo(); + void redo(); + void apply(); + QList unsel; + QList sel; + IType type() { return SELECT; } +}; + +class mem_move : public mem_command { + public: + mem_move(sem_mediator*); + void undo(); + void redo(); + QList sel; + QList oldPos; + QList newPos; + IType type() { return MOVE; } +}; + +class mem_color : public mem_command { + public: + mem_color(sem_mediator*); + void undo(); + void redo(); + QMap prevColors; + int newColor; + IType type() { return COLOR; } +}; + +class mem_flag : public mem_command { + public: + mem_flag(sem_mediator*); + void undo(); + void redo(); + bool add; + QString flag; + QMap > prevFlags; + IType type() { return FLAG; } +}; + +class mem_edit: public mem_command { + public: + mem_edit(sem_mediator*); + void undo(); + void redo(); + data_item *sel; + QString oldSummary; + QString newSummary; + IType type() { return EDIT; } +}; + +class mem_datatype: public mem_command { + public: + mem_datatype(sem_mediator*); + void undo(); + void redo(); + data_item *sel; + int oldDataType; + int newDataType; + IType type() { return DATATYPE; } +}; + +class mem_text: public mem_command { + public: + mem_text(sem_mediator*); + void undo(); + void redo(); + data_item *sel; + QString oldText; + QString newText; + IType type() { return TEXT; } +}; + +class mem_vars: public mem_command { + public: + mem_vars(sem_mediator*); + void undo(); + void redo(); + int m_iId; + QString oldVars; + QString newVars; + IType type() { return VARS; } +}; + +class mem_pic: public mem_command { + public: + mem_pic(sem_mediator*); + void undo(); + void redo(); + data_item *sel; + int m_iOldId; + int m_iNewId; + IType type() { return PIC; } +}; + +class mem_table: public mem_command { + public: + mem_table(sem_mediator*); + void undo(); + void redo(); + + int m_iId; + int oldNRows; + int oldNCols; + int newNRows; + int newNCols; + QHash, QString> oldData; + QHash, QString> newData; + IType type() { return TABLE; } +}; + +class mem_sort: public mem_command { + public: + mem_sort(sem_mediator*); + void init(int i_iParent, int i_iChild, int i_iNum); + void undo(); + void redo(); + int m_iChild; + int m_iParent; + QList oldData; + QList newData; + + IType type() { return SORT; } +}; + +#endif + diff -Nru semantik-0.7.3/src/po/cs.po semantik-0.8.3/src/po/cs.po --- semantik-0.7.3/src/po/cs.po 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/po/cs.po 2012-10-21 10:09:17.000000000 +0000 @@ -0,0 +1,1036 @@ +# This file is put in the public domain. +# +# Pavel Fric , 2009. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: http://code.google.com/p/semantik/issues\n" +"POT-Creation-Date: 2012-10-09 23:25+0200\n" +"PO-Revision-Date: 2009-10-24 10:14+0200\n" +"Last-Translator: Pavel Fric \n" +"Language-Team: Czech \n" +"Language: cs\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.0\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +#: browser.cpp:21 canvas_view.cpp:134 +msgid "Toggle fullscreen" +msgstr "" + +#: canvas_view.cpp:83 +#, fuzzy +msgid "Add an element" +msgstr "Přidat sloupec" + +#: canvas_view.cpp:88 fig/box_view.cpp:170 +msgid "Delete selection" +msgstr "Smazat výběr" + +#: canvas_view.cpp:93 +#, fuzzy +msgid "Insert a sibling" +msgstr "Vložit sourozence" + +#: canvas_view.cpp:98 fig/box_view.cpp:180 +msgid "Move up" +msgstr "Posunout nahoru" + +#: canvas_view.cpp:99 fig/box_view.cpp:185 +msgid "Move down" +msgstr "Posunout dolů" + +#: canvas_view.cpp:100 +msgid "Move left" +msgstr "Posunout doleva" + +#: canvas_view.cpp:101 +msgid "Move right" +msgstr "Posunout doprava" + +#: canvas_view.cpp:103 +msgid "Select up" +msgstr "Vybrat nahoru" + +#: canvas_view.cpp:104 +msgid "Select down" +msgstr "Vybrat dolů" + +#: canvas_view.cpp:105 +msgid "Select left" +msgstr "Vybrat doleva" + +#: canvas_view.cpp:106 +msgid "Select right" +msgstr "Vybrat doprava" + +#: canvas_view.cpp:109 +#, fuzzy +msgid "Select subtree" +msgstr "Vybrat nahoru" + +#: canvas_view.cpp:114 +msgid "Next root" +msgstr "Další kořen" + +#: canvas_view.cpp:117 +msgid "Toggle edit" +msgstr "Přepnout úpravy" + +#: canvas_view.cpp:122 +#, fuzzy +msgid "Cancel edit" +msgstr "&Zrušit" + +#: canvas_view.cpp:138 +msgid "Colors" +msgstr "Barvy" + +#: canvas_view.cpp:139 +msgid "Data type" +msgstr "Datový typ" + +#: canvas_view.cpp:148 +msgid "Text" +msgstr "Text" + +#: canvas_view.cpp:149 +msgid "Diagram" +msgstr "Nákres" + +#: canvas_view.cpp:150 +msgid "Table" +msgstr "Tabulka" + +#: canvas_view.cpp:151 +msgid "Image" +msgstr "Obrázek" + +#: canvas_view.cpp:224 canvas_view.cpp:276 canvas_view.cpp:288 +#: data_item.cpp:27 +msgid "Empty" +msgstr "Prázdné" + +#: canvas_view.cpp:573 +msgid "Color" +msgstr "Barva" + +#: canvas_view.cpp:623 +msgid "Flag" +msgstr "Příznak" + +#: canvas_view.cpp:940 +msgid "Click to set Item %1" +msgstr "Klepněte pro umístění položky %1" + +#: canvas_view.cpp:1250 +msgid "*.png|PNG Files (*.png)" +msgstr "" + +#: canvas_view.cpp:1288 +msgid "No destination file selected" +msgstr "" + +#: canvas_view.cpp:1323 +#, fuzzy +msgid "Exported '%1'" +msgstr "Uloženo '%1'" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Could not save to %1" +msgstr "Klepněte pro umístění položky %1" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Missing picture" +msgstr "Změnit obrázek" + +#: config_dialog.cpp:29 +#, fuzzy +msgid "Document settings" +msgstr "Název dokumentu" + +#: config_dialog.cpp:37 +msgid "Reorganization type" +msgstr "Druh nového uspořádání" + +#: config_dialog.cpp:41 +msgid "Connection type" +msgstr "Druh spojení" + +#: config_dialog.cpp:45 +msgid "Save document automatically" +msgstr "Dokument uložit automaticky" + +#: config_dialog.cpp:49 +msgid "Background color" +msgstr "Barva pozadí" + +#: config_dialog.cpp:54 +msgid "Fixed" +msgstr "Pevné" + +#: config_dialog.cpp:54 +msgid "Force-based" +msgstr "Usazené silou" + +#: config_dialog.cpp:54 +msgid "Incremental" +msgstr "Přírustkové" + +#: config_dialog.cpp:58 +msgid "Lines" +msgstr "Čáry" + +#: config_dialog.cpp:58 +msgid "Splines" +msgstr "Křivky" + +#: config_dialog.cpp:62 +msgid " min" +msgstr " min" + +#: config_dialog.cpp:65 +msgid "" +"Interval in minutes for saving the document automatically, 0 for disabling " +"this feature" +msgstr "" +"Doba v minutách pro automatické ukládání dokumentu, 0 pro zakázání této " +"funkce" + +#: data_view.cpp:17 +msgid "

    No item selected

    " +msgstr "

    Nebyla vybrána žádná položka

    " + +#: doc_dialog.cpp:30 +msgid "First Name" +msgstr "Křestní jméno" + +#: doc_dialog.cpp:34 generator_dialog.cpp:56 +msgid "Name" +msgstr "Příjmení" + +#: doc_dialog.cpp:38 +msgid "Organization" +msgstr "Organizace" + +#: doc_dialog.cpp:42 +msgid "Email" +msgstr "E-mail" + +#: export_map_dialog.cpp:31 +#, fuzzy +msgid "Export the map" +msgstr "Prázdné zobrazení" + +#: export_map_dialog.cpp:37 +msgid "File to write" +msgstr "" + +#: export_map_dialog.cpp:43 +msgid "Width" +msgstr "" + +#: export_map_dialog.cpp:51 +#, fuzzy +msgid "Height" +msgstr "Posunout doprava" + +#: fig/box_fork.cpp:334 fig/box_item.cpp:133 +msgid "%1 x %2" +msgstr "" + +#: fig/box_item.cpp:189 +msgid "Properties for diagram box" +msgstr "" + +#: fig/box_item.cpp:190 +#, fuzzy +msgid "Text:" +msgstr "Text" + +#: fig/box_link_properties.cpp:21 +msgid "Link properties" +msgstr "" + +#: fig/box_link_properties.cpp:29 +msgid "Thickness" +msgstr "" + +#: fig/box_link_properties.cpp:33 +msgid "Line Style" +msgstr "" + +#: fig/box_link_properties.cpp:37 +msgid "Left arrow" +msgstr "" + +#: fig/box_link_properties.cpp:41 +msgid "Right arrow" +msgstr "" + +#: fig/box_link_properties.cpp:51 +msgid "Invisible line" +msgstr "" + +#: fig/box_link_properties.cpp:52 +#, fuzzy +msgid "Solid Line" +msgstr "Plná čára" + +#: fig/box_link_properties.cpp:53 +#, fuzzy +msgid "Dot Line" +msgstr "Čáry" + +#: fig/box_link_properties.cpp:54 +#, fuzzy +msgid "Dash Line" +msgstr "Čárkovaná čára" + +#: fig/box_link_properties.cpp:58 fig/box_link_properties.cpp:63 +msgid "No arrow" +msgstr "" + +#: fig/box_link_properties.cpp:59 fig/box_link_properties.cpp:64 +msgid "Triangle" +msgstr "" + +#: fig/box_view.cpp:83 +msgid "box_item" +msgstr "" + +#: fig/box_view.cpp:85 +msgid "id" +msgstr "" + +#: fig/box_view.cpp:90 fig/box_view.cpp:100 +msgid "c1" +msgstr "" + +#: fig/box_view.cpp:91 fig/box_view.cpp:102 +msgid "c2" +msgstr "" + +#: fig/box_view.cpp:92 +msgid "text" +msgstr "" + +#: fig/box_view.cpp:93 +#, fuzzy +msgid "col" +msgstr "&Projíždět" + +#: fig/box_view.cpp:96 fig/box_view.cpp:132 +msgid "box_link" +msgstr "" + +#: fig/box_view.cpp:99 +msgid "p1" +msgstr "" + +#: fig/box_view.cpp:101 +msgid "p2" +msgstr "" + +#: fig/box_view.cpp:114 +msgid "sl" +msgstr "" + +#: fig/box_view.cpp:115 +msgid "wl" +msgstr "" + +#: fig/box_view.cpp:119 +msgid "box_link_offset" +msgstr "" + +#: fig/box_view.cpp:123 +msgid "x" +msgstr "" + +#: fig/box_view.cpp:123 +msgid "y" +msgstr "" + +#: fig/box_view.cpp:160 +msgid "Properties..." +msgstr "" + +#: fig/box_view.cpp:165 +msgid "Activity" +msgstr "" + +#: fig/box_view.cpp:166 +msgid "Ctrl+Return" +msgstr "" + +#: fig/box_view.cpp:171 +msgid "Delete" +msgstr "Smazat" + +#: fig/box_view.cpp:175 +msgid "Color..." +msgstr "Barva..." + +#: fig/box_view.cpp:181 +msgid "PgUp" +msgstr "" + +#: fig/box_view.cpp:186 +msgid "PgDown" +msgstr "" + +#: fig/box_view.cpp:190 +msgid "Floating text" +msgstr "" + +#: fig/box_view.cpp:192 +msgid "Component" +msgstr "" + +#: fig/box_view.cpp:194 +msgid "Node" +msgstr "" + +#: fig/box_view.cpp:196 +msgid "Activity start" +msgstr "" + +#: fig/box_view.cpp:198 +msgid "Activity end" +msgstr "" + +#: fig/box_view.cpp:200 +msgid "Horizontal fork/join" +msgstr "" + +#: fig/box_view.cpp:202 +msgid "Vertical fork/join" +msgstr "" + +#: fig/box_view.cpp:204 +msgid "Actor" +msgstr "" + +#: fig/box_view.cpp:206 +msgid "Usecase" +msgstr "" + +#: fig/box_view.cpp:215 +msgid "More elements" +msgstr "" + +#: fig/box_view.cpp:247 +msgid "Alignment" +msgstr "" + +#: fig/box_view.cpp:249 +msgid "Align left" +msgstr "" + +#: fig/box_view.cpp:250 +msgid "Align center" +msgstr "" + +#: fig/box_view.cpp:251 +#, fuzzy +msgid "Align right" +msgstr "Vybrat doprava" + +#: fig/box_view.cpp:253 +msgid "Align top" +msgstr "" + +#: fig/box_view.cpp:254 +msgid "Align middle" +msgstr "" + +#: fig/box_view.cpp:255 +msgid "Align bottom" +msgstr "" + +#: fig/box_view.cpp:258 +msgid "Size" +msgstr "" + +#: fig/box_view.cpp:260 +msgid "Same width" +msgstr "" + +#: fig/box_view.cpp:261 +#, fuzzy +msgid "Same height" +msgstr "Vybrat doprava" + +#: fig/box_view.cpp:262 +msgid "Same width and height" +msgstr "" + +#: flag_scheme.cpp:14 +msgid "Flag item(s) as..." +msgstr "Označit položku(y) jako..." + +#: generator_dialog.cpp:30 +#, fuzzy +msgid "Generate documents" +msgstr "Tvůrci" + +#: generator_dialog.cpp:36 +msgid "Generators" +msgstr "Tvůrci" + +#: generator_dialog.cpp:39 +msgid "Description" +msgstr "Popis" + +#: generator_dialog.cpp:63 +msgid "Location" +msgstr "Umístění" + +#: generator_dialog.cpp:114 +msgid "No document generator chosen." +msgstr "Nebyl vybrán žádný tvůrce dokumentu." + +#: generator_dialog.cpp:114 +msgid "Missing data" +msgstr "Chybí data" + +#: generator_dialog.cpp:120 +msgid "Invalid output directory %1" +msgstr "Neplatný výstupní adresář %1" + +#: generator_dialog.cpp:120 +msgid "Missing location" +msgstr "Chybí umístění" + +#: image_view.cpp:36 +msgid "Change picture" +msgstr "Změnit obrázek" + +#: image_view.cpp:40 +msgid "Clear picture" +msgstr "Smazat obrázek" + +#: image_view.cpp:65 +msgid "Click to set a picture" +msgstr "Klepněte pro položení obrázku" + +#: image_view.cpp:69 +msgid "Select an item on the map" +msgstr "Vybrat položku na zobrazení" + +#: image_view.cpp:165 +#, fuzzy +msgid "*.png *.jpg *.jpeg *.gif|Image Files (*.png *.jpg *.jpeg *.gif)" +msgstr "Soubory s obrázky (*.png *.jpg *.jpeg *.gif)" + +#: image_view.cpp:166 +#, fuzzy +msgid "Choose a picture" +msgstr "Vybrat soubor" + +#: image_view.cpp:178 +#, fuzzy +msgid "Could not load the picture" +msgstr "Klepněte pro položení obrázku" + +#: main.cpp:25 +msgid "" +"A mind-mapping tool for KDE\n" +"Available exclusively for open systems such as OpenSuse, Gentoo or Fedora." +msgstr "" + +#: main.cpp:41 +msgid "A file to open on startup" +msgstr "" + +#: main.cpp:43 +msgid "Semantik" +msgstr "Semantik" + +#: main.cpp:44 +msgid "(C) 2007-2012 Thomas Nagy" +msgstr "" + +#: main.cpp:47 +msgid "Thomas Nagy" +msgstr "" + +#. i18n: file: data/semantikui.rc:5 +#. i18n: ectx: Menu (file) +#: po/rc.cpp:3 rc.cpp:3 +msgid "&File" +msgstr "" + +#. i18n: file: data/semantikui.rc:7 +#. i18n: ectx: Menu (edit) +#: po/rc.cpp:6 rc.cpp:6 +msgid "&Edit" +msgstr "" + +#. i18n: file: data/semantikui.rc:12 +#. i18n: ectx: Menu (view) +#: po/rc.cpp:9 rc.cpp:9 +msgid "&View" +msgstr "" + +#. i18n: file: data/semantikui.rc:20 +#. i18n: ectx: Menu (tools) +#: po/rc.cpp:12 rc.cpp:12 +msgid "&Tools" +msgstr "" + +#. i18n: file: data/semantikui.rc:23 +#. i18n: ectx: Menu (settings) +#: po/rc.cpp:15 rc.cpp:15 +msgid "&Settings" +msgstr "" + +#. i18n: file: data/semantikui.rc:26 +#. i18n: ectx: Menu (help) +#: po/rc.cpp:18 rc.cpp:18 +msgid "&Help" +msgstr "" + +#. i18n: file: data/semantikui.rc:40 +#. i18n: ectx: ToolBar (colorsToolBar) +#: po/rc.cpp:21 rc.cpp:21 +#, fuzzy +msgid "Colors Toolbar" +msgstr "Barvy" + +#. i18n: file: data/semantikui.rc:44 +#. i18n: ectx: ToolBar (flagsToolBar) +#: po/rc.cpp:24 rc.cpp:24 +msgid "Flags Toolbar" +msgstr "" + +#: po/rc.cpp:25 rc.cpp:25 +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "" + +#: po/rc.cpp:26 rc.cpp:26 +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "" + +#: pre_view.cpp:23 +msgid "

    No preview available
    at this time

    " +msgstr "

    V této chvíli
    není dostupný žádný náhled

    " + +#: semantik.cpp:45 +msgid "" +"The map is empty, Semantik\n" +"cannot create documents from it" +msgstr "" +"Zobrazení je prázdné, Semantik\n" +"z něj nedokáže vytvářet dokumenty" + +#: semantik.cpp:45 +msgid "Empty map" +msgstr "Prázdné zobrazení" + +#: semantik.cpp:52 +msgid "Template folder %1 is not readable" +msgstr "Složka s předlohami %1 je nečitelná" + +#: semantik.cpp:166 +msgid "&Reorganize the map" +msgstr "&Přeuspořádat zobrazení" + +#: semantik.cpp:168 +msgid "Ctrl+R" +msgstr "" + +#: semantik.cpp:171 +msgid "&Export the map..." +msgstr "" + +#: semantik.cpp:173 +msgid "Ctrl+Shift+E" +msgstr "" + +#: semantik.cpp:178 +msgid "&Generate..." +msgstr "&Vytvořit..." + +#: semantik.cpp:181 +msgid "Ctrl+G" +msgstr "" + +#: semantik.cpp:187 +msgid "CustomColor" +msgstr "Vlastní barva" + +#: semantik.cpp:201 +msgid "Ctrl+H" +msgstr "" + +#: semantik.cpp:210 +msgid "Data" +msgstr "Data" + +#: semantik.cpp:233 +msgid "Variables" +msgstr "Proměnné" + +#: semantik.cpp:242 +msgid "Preview" +msgstr "Náhled" + +#: semantik.cpp:254 +msgid "Linear view" +msgstr "Přímočarý pohled" + +#: semantik.cpp:347 +msgid "Welcome to Semantik" +msgstr "Vítejte v Semantiku" + +#: semantik.cpp:393 +msgid "Ready" +msgstr "Připraven" + +#: semantik.cpp:400 +msgid "*.sem|Semantik file (*.sem)" +msgstr "*.sem|Soubor pro Semantik (*.sem)" + +#: semantik.cpp:401 semantik.cpp:463 +msgid "Choose a file name" +msgstr "Vybrat název souboru" + +#: semantik.cpp:414 +msgid "" +"The file \"%1\" already exists.\n" +"Overwrite it?" +msgstr "" + +#: semantik.cpp:415 +msgid "Overwrite existing file" +msgstr "" + +#: semantik.cpp:426 semantik.cpp:448 +msgid "Saved '%1'" +msgstr "Uloženo '%1'" + +#: semantik.cpp:462 +msgid "*.sem *.kdi *.mm *.vym|All Supported Files (*.sem *.kdi *.mm *.vym)" +msgstr "" +"*.sem *.kdi *.mm *.vym|Všechny podporované soubory (*.sem *.kdi *.mm *.vym)" + +#: semantik.cpp:474 +msgid " [Modified] " +msgstr "" + +#: semantik.cpp:479 +#, fuzzy +msgid "Semantik %1" +msgstr "Semantik" + +#: semantik.cpp:483 +#, fuzzy +msgid "%1 %2 - Semantik" +msgstr "%1 - Semantik" + +#: semantik.cpp:530 +msgid "Untitled" +msgstr "Nepojmenovaný" + +#: semantik.cpp:533 +msgid "" +"The document \"%1\" has been modified.\n" +"Do you want to save your changes or discard them?" +msgstr "" +"Dokument \"%1\" byl změněn.\n" +"Chcete svoje změny uložit nebo je vyhodit?" + +#: semantik.cpp:534 +msgid "Close Document" +msgstr "Zavřít dokument" + +#: sem_mediator.cpp:270 +msgid "Automatic save failed for file: %1" +msgstr "Automatické uložení se nepodařilo u souboru: %1" + +#: sem_mediator.cpp:273 +msgid "%1 saved automatically" +msgstr "%1 uložen automaticky" + +#: sem_mediator.cpp:292 +msgid "Color %1" +msgstr "Barva %1" + +#: sem_mediator.cpp:618 +msgid "File saving: missing file %1" +msgstr "Ukládání souboru: chybí soubor %1" + +#: sem_mediator.cpp:643 sem_mediator.cpp:1142 sem_mediator.cpp:1185 +msgid "Missing bindings for opening files" +msgstr "Chybí spojení pro otevření souborů" + +#: sem_mediator.cpp:694 +msgid "Missing filter file %1 for opening files" +msgstr "Chybí soubor s filtrem %1 pro otevření souborů" + +#: sem_mediator.cpp:694 sem_mediator.cpp:709 +msgid "Broken installation" +msgstr "" + +#: sem_mediator.cpp:709 +#, fuzzy +msgid "Missing python bindings for opening files" +msgstr "Chybí spojení pro otevření souborů" + +#: sem_mediator.cpp:725 +msgid "Could not load the document %1" +msgstr "" + +#: sem_mediator.cpp:725 +#, fuzzy +msgid "Broken document" +msgstr "Zavřít dokument" + +#: sem_mediator.cpp:1108 +msgid "Code generation failed: missing file %1" +msgstr "Vytvoření kódu se nepodařilo: chybí soubor %1" + +#: sem_mediator.cpp:1147 +msgid "Document generation completed successfully" +msgstr "" + +#: table_dialog.cpp:32 +msgid "Rows" +msgstr "Řádky" + +#: table_dialog.cpp:36 +msgid "Columns" +msgstr "Sloupce" + +#: table_view.cpp:25 table_view.cpp:79 +msgid "Add Row" +msgstr "Přidat řádek" + +#: table_view.cpp:26 +msgid "Add a row" +msgstr "Přidat řádek" + +#: table_view.cpp:30 table_view.cpp:80 +msgid "Add Column" +msgstr "Přidat sloupec" + +#: table_view.cpp:31 +msgid "Add a column" +msgstr "Přidat sloupec" + +#: table_view.cpp:36 table_view.cpp:81 +msgid "Remove Row" +msgstr "Odstranit řádek" + +#: table_view.cpp:37 +msgid "Remove a row" +msgstr "Odstranit řádek" + +#: table_view.cpp:41 table_view.cpp:82 +msgid "Remove Column" +msgstr "Odstranit sloupec" + +#: table_view.cpp:42 +msgid "Remove a column" +msgstr "Odstranit sloupec" + +#: table_view.cpp:46 +msgid "Redimension" +msgstr "Změnit rozměry" + +#: table_view.cpp:47 +msgid "Change table dimensions" +msgstr "Změnit rozměry tabulky" + +#: text_view.cpp:40 +msgid "&Bold" +msgstr "&Tučné" + +#: text_view.cpp:41 +msgid "Ctrl+B" +msgstr "" + +#: text_view.cpp:44 +msgid "&Italic" +msgstr "&Kurzíva" + +#: text_view.cpp:45 +msgid "Ctrl+I" +msgstr "" + +#: text_view.cpp:48 +msgid "&Underline" +msgstr "&Podtržení" + +#: text_view.cpp:49 +msgid "Ctrl+U" +msgstr "" + +#: vars_view.cpp:76 +msgid "Code complete" +msgstr "Kód dokončen" + +#: vars_view.cpp:77 +msgid "Ctrl+space" +msgstr "" + +#~ msgid "Insert child" +#~ msgstr "Vložit potomka" + +#~ msgid "dirty" +#~ msgstr "špinavý" + +#~ msgid "Add Box" +#~ msgstr "Přidat kolonku" + +#~ msgid "Connection width" +#~ msgstr "Šířka spojení" + +#~ msgid "1px" +#~ msgstr "1px" + +#~ msgid "2px" +#~ msgstr "2px" + +#~ msgid "3px" +#~ msgstr "3px" + +#~ msgid "Connection style" +#~ msgstr "Styl spojení" + +#~ msgid "dot line" +#~ msgstr "Tečkovaná čára" + +#~ msgid "exclude the table" +#~ msgstr "Vyjmout tabulku" + +#~ msgid "fit the item on one slide" +#~ msgstr "Umístit položku na snímek" + +#~ msgid "picture caption" +#~ msgstr "Popisek obrázku" + +#~ msgid "picture dimension in pdf files" +#~ msgstr "Rozměry obrázku v souborech PDF" + +#~ msgid "html div style: style=\"width: 99px;\"" +#~ msgstr "html div style: style=\"width: 99px;\"" + +#~ msgid "html picture style: style=\"width: 99px;\"" +#~ msgstr "Styl obrázku v html: style=\"width: 99px;\"" + +#~ msgid "do not use this item for generating slides" +#~ msgstr "Tuto položku nepoužívejte pro vytváření snímků" + +#~ msgid "command to launch (%s is the resulting file)" +#~ msgstr "Příkaz ke spuštění (%s je výsledným souborem)" + +#~ msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#~ msgstr "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" + +#~ msgid "firefox %s" +#~ msgstr "firefox %s" + +#~ msgid "ooimpress %s" +#~ msgstr "ooimpress %s" + +#~ msgid "oowriter %s" +#~ msgstr "oowriter %s" + +#~ msgid "document author" +#~ msgstr "Autor dokumentu" + +#~ msgid "turn off the document author (latex)" +#~ msgstr "Vypnout autora dokumentu (latex)" + +#~ msgid "document class (latex: a4, report, book)" +#~ msgstr "Třída dokumentu (latex: a4, zpráva, kniha)" + +#~ msgid "company" +#~ msgstr "Společnost" + +#~ msgid "document date" +#~ msgstr "Datum vytvoření dokumentu" + +#~ msgid "turn of the document date (latex)" +#~ msgstr "Vypnout datum vytvoření dokumentu (latex)" + +#~ msgid "location of the presentation" +#~ msgstr "Umístění představení" + +#~ msgid "turn off the document title (latex)" +#~ msgstr "Vypnout název dokumentu (latex)" + +#~ msgid "footer center (pdflatex)" +#~ msgstr "Zápatí na střed (pdflatex)" + +#~ msgid "footer left (pdflatex)" +#~ msgstr "Zápatí vlevo (pdflatex)" + +#~ msgid "turn off the fancy output" +#~ msgstr "Vypnout vypracovaný výstup" + +#~ msgid "footer right" +#~ msgstr "Zápatí vpravo" + +#~ msgid "header center (pdflatex)" +#~ msgstr "Záhlaví na střed (pdflatex)" + +#~ msgid "header left" +#~ msgstr "Záhlaví vlevo" + +#~ msgid "header right" +#~ msgstr "Záhlaví vpravo" + +#~ msgid "openoffice.org language (fr_FR)" +#~ msgstr "Jazyk v openoffice.org (fr_FR)" + +#~ msgid "openoffice.org presentation language" +#~ msgstr "Jazyk představení v openoffice.org" + +#~ msgid "openoffice.org text language" +#~ msgstr "Jazyk textu v openoffice.org" + +#~ msgid "Warsaw (JuanLesPins, Montpellier, )" +#~ msgstr "Varšava (JuanLesPins, Montpellier, )" + +#~ msgid "Generator dialog" +#~ msgstr "Dialog tvůrce" + +#~ msgid "&Ok" +#~ msgstr "&OK" + +#~ msgid "File %1 does not exist" +#~ msgstr "Soubor %1 neexistuje" + +#~ msgid "File %1 could not be opened" +#~ msgstr "Soubor %1 se nepodařilo otevřít" + +#~ msgid "something bad happened" +#~ msgstr "Stalo se něco nepříjemného" + +#~ msgid "something worse happened" +#~ msgstr "Stalo se něco ještě horšího" + +#~ msgid "&Select" +#~ msgstr "&Vybrat" + +#~ msgid "&Link" +#~ msgstr "&Spojit" + +#~ msgid "&Sort" +#~ msgstr "&Třídit" + +#~ msgid "exclude the picture" +#~ msgstr "Vyjmout obrázek" + +#~ msgid "latex language: english (frenchb, )" +#~ msgstr "Jazyk latexu: english (frenchb, )" diff -Nru semantik-0.7.3/src/po/el.po semantik-0.8.3/src/po/el.po --- semantik-0.7.3/src/po/el.po 2009-08-30 11:35:33.000000000 +0000 +++ semantik-0.8.3/src/po/el.po 2012-10-21 10:09:17.000000000 +0000 @@ -2,374 +2,627 @@ msgid "" msgstr "" "Project-Id-Version: \n" -"Report-Msgid-Bugs-To: http://www.google.com\n" -"POT-Creation-Date: 2009-04-26 15:20+0200\n" +"Report-Msgid-Bugs-To: http://code.google.com/p/semantik/issues\n" +"POT-Creation-Date: 2012-10-09 23:25+0200\n" "PO-Revision-Date: 2009-07-28 12:17+0300\n" "Last-Translator: \n" "Language-Team: Ελληνικά \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Lokalize 1.0\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -msgid "Empty" -msgstr "Κενό" - -msgid "Toggle edit" -msgstr "Επεξεργασία κόμβου" +#: browser.cpp:21 canvas_view.cpp:134 +msgid "Toggle fullscreen" +msgstr "" -msgid "Insert child" -msgstr "Εισαγωγή απογονικού κόμβου" +#: canvas_view.cpp:83 +#, fuzzy +msgid "Add an element" +msgstr "Προσθήκη μιας στήλης" +#: canvas_view.cpp:88 fig/box_view.cpp:170 msgid "Delete selection" msgstr "Διαγραφή κόμβου" -msgid "Insert sibling" +#: canvas_view.cpp:93 +#, fuzzy +msgid "Insert a sibling" msgstr "Εισαγωγή αδελφικού κόμβου" +#: canvas_view.cpp:98 fig/box_view.cpp:180 msgid "Move up" msgstr "Μετακίνηση πάνω" +#: canvas_view.cpp:99 fig/box_view.cpp:185 msgid "Move down" msgstr "Μετακίνηση κάτω" +#: canvas_view.cpp:100 msgid "Move left" msgstr "Μετακίνηση αριστερά" +#: canvas_view.cpp:101 msgid "Move right" msgstr "Μετακίνηση δεξιά" +#: canvas_view.cpp:103 msgid "Select up" msgstr "Επιλογή πάνω" +#: canvas_view.cpp:104 msgid "Select down" msgstr "Επιλογή κάτω" +#: canvas_view.cpp:105 msgid "Select left" msgstr "Επιλογή αριστερά" +#: canvas_view.cpp:106 msgid "Select right" msgstr "Επιλογή δεξιά" +#: canvas_view.cpp:109 +#, fuzzy +msgid "Select subtree" +msgstr "Επιλογή πάνω" + +#: canvas_view.cpp:114 msgid "Next root" msgstr "Επόμενος γονικός κόμβος" +#: canvas_view.cpp:117 +msgid "Toggle edit" +msgstr "Επεξεργασία κόμβου" + +#: canvas_view.cpp:122 +#, fuzzy +msgid "Cancel edit" +msgstr "&Ακύρωση" + +#: canvas_view.cpp:138 msgid "Colors" msgstr "Χρώματα" +#: canvas_view.cpp:139 msgid "Data type" msgstr "Είδος δεδομένων" +#: canvas_view.cpp:148 msgid "Text" msgstr "Κείμενο" +#: canvas_view.cpp:149 msgid "Diagram" msgstr "Διάγραμμα" +#: canvas_view.cpp:150 msgid "Table" msgstr "Πίνακας" +#: canvas_view.cpp:151 msgid "Image" msgstr "Εικόνα" -msgid "Flag" -msgstr "Σημαία" +#: canvas_view.cpp:224 canvas_view.cpp:276 canvas_view.cpp:288 +#: data_item.cpp:27 +msgid "Empty" +msgstr "Κενό" +#: canvas_view.cpp:573 msgid "Color" msgstr "Χρώμα" -#, kde-format +#: canvas_view.cpp:623 +msgid "Flag" +msgstr "Σημαία" + +#: canvas_view.cpp:940 msgid "Click to set Item %1" msgstr "Κλικ για τον ορισμό αντικειμένου %1" +#: canvas_view.cpp:1250 +msgid "*.png|PNG Files (*.png)" +msgstr "" + +#: canvas_view.cpp:1288 +msgid "No destination file selected" +msgstr "" + +#: canvas_view.cpp:1323 +#, fuzzy +msgid "Exported '%1'" +msgstr "Αποθηκεύτηκε '%1'" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Could not save to %1" +msgstr "Κλικ για τον ορισμό αντικειμένου %1" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Missing picture" +msgstr "Αλλαγή εικόνας" + +#: config_dialog.cpp:29 +#, fuzzy +msgid "Document settings" +msgstr "τίτλος εγγράφου" + +#: config_dialog.cpp:37 msgid "Reorganization type" msgstr "Είδος αναδιοργάνωσης" +#: config_dialog.cpp:41 msgid "Connection type" msgstr "Είδος συνδέσμου" +#: config_dialog.cpp:45 msgid "Save document automatically" msgstr "Αυτόματη αποθήκευση εγγράφου" +#: config_dialog.cpp:49 msgid "Background color" msgstr "Χρώμα παρασκηνίου" +#: config_dialog.cpp:54 msgid "Fixed" msgstr "Σταθερό" +#: config_dialog.cpp:54 msgid "Force-based" msgstr "Αναγκατικό" +#: config_dialog.cpp:54 msgid "Incremental" msgstr "Αυξητικό" +#: config_dialog.cpp:58 msgid "Lines" msgstr "Γραμμές" +#: config_dialog.cpp:58 msgid "Splines" msgstr "Καμπύλες" +#: config_dialog.cpp:62 msgid " min" msgstr "μίνιμουμ" +#: config_dialog.cpp:65 msgid "" "Interval in minutes for saving the document automatically, 0 for disabling " "this feature" msgstr "" -"Χρονικό διάτημα σε λεπτά για την αυτόματη αποθήκευση του εγγράφου, " -"0 για απενεργοποίηση αυτής της λειτουργίας." - -#, kde-format -msgid "Automatic save failed for file: %1" -msgstr "Απέτυχε η αυτόματη αποθήκευση για το αρχείο: %1" - -#, kde-format -msgid "%1 saved automatically" -msgstr "%1 αποθηκεύτηκε αυτόματα" - -#, kde-format -msgid "Color %1" -msgstr "Χρώμα %1" - -#, kde-format -msgid "File saving: missing file %1" -msgstr "Αποθήκευση αρχείου: το αρχείο %1 λείπει" - -msgid "Missing bindings for opening files" -msgstr "Ανυπαρξία δεσμών για το άνοιγμα των αρχείων" - -#, kde-format -msgid "Missing filter file %1 for opening files" -msgstr "Έλλειψη φίλτρου αρχείου %1 για το άνοιγμα των αρχείων" - -msgid "dirty" -msgstr "λερωμένος" - -#, kde-format -msgid "Code generation failed: missing file %1" -msgstr "Η δημιουργία κώδικα απέτυχε: αρχείο που λείπει %1" +"Χρονικό διάτημα σε λεπτά για την αυτόματη αποθήκευση του εγγράφου, 0 για " +"απενεργοποίηση αυτής της λειτουργίας." +#: data_view.cpp:17 msgid "

    No item selected

    " msgstr "

    Δεν επιλέχθηκε αντικείμενο

    " +#: doc_dialog.cpp:30 msgid "First Name" msgstr "Όνομα" +#: doc_dialog.cpp:34 generator_dialog.cpp:56 msgid "Name" msgstr "Επώνυμο" +#: doc_dialog.cpp:38 msgid "Organization" msgstr "Οργανισμός" +#: doc_dialog.cpp:42 msgid "Email" msgstr "Email" -msgid "Add Box" -msgstr "Προσθήκη πλαισίου" +#: export_map_dialog.cpp:31 +#, fuzzy +msgid "Export the map" +msgstr "Κενός χάρτης" -msgid "Delete" -msgstr "Διαγραφή" +#: export_map_dialog.cpp:37 +msgid "File to write" +msgstr "" -msgid "Color..." -msgstr "Χρώμα..." +#: export_map_dialog.cpp:43 +msgid "Width" +msgstr "" + +#: export_map_dialog.cpp:51 +#, fuzzy +msgid "Height" +msgstr "Μετακίνηση δεξιά" + +#: fig/box_fork.cpp:334 fig/box_item.cpp:133 +msgid "%1 x %2" +msgstr "" + +#: fig/box_item.cpp:189 +msgid "Properties for diagram box" +msgstr "" + +#: fig/box_item.cpp:190 +#, fuzzy +msgid "Text:" +msgstr "Κείμενο" + +#: fig/box_link_properties.cpp:21 +msgid "Link properties" +msgstr "" -msgid "Connection width" -msgstr "Πλάτος σύνδεσης" +#: fig/box_link_properties.cpp:29 +msgid "Thickness" +msgstr "" -msgid "1px" -msgstr "1px" +#: fig/box_link_properties.cpp:33 +msgid "Line Style" +msgstr "" -msgid "2px" -msgstr "2px" +#: fig/box_link_properties.cpp:37 +msgid "Left arrow" +msgstr "" -msgid "3px" -msgstr "3px" +#: fig/box_link_properties.cpp:41 +msgid "Right arrow" +msgstr "" -msgid "Connection style" -msgstr "Στυλ σύνδεσης" +#: fig/box_link_properties.cpp:51 +msgid "Invisible line" +msgstr "" -msgid "solid line" +#: fig/box_link_properties.cpp:52 +#, fuzzy +msgid "Solid Line" msgstr "συμπαγής γραμμής" -msgid "dot line" -msgstr "γραμμή με τελείες" +#: fig/box_link_properties.cpp:53 +#, fuzzy +msgid "Dot Line" +msgstr "Γραμμές" -msgid "dash line" +#: fig/box_link_properties.cpp:54 +#, fuzzy +msgid "Dash Line" msgstr "γραμμή με παύλες" -msgid "Flag item(s) as..." -msgstr "Σημείωση αντικειμένου(ων) ως..." +#: fig/box_link_properties.cpp:58 fig/box_link_properties.cpp:63 +msgid "No arrow" +msgstr "" -msgid "exclude the table" -msgstr "αποκλεισμός του πίνακα" +#: fig/box_link_properties.cpp:59 fig/box_link_properties.cpp:64 +msgid "Triangle" +msgstr "" -msgid "fit the item on one slide" -msgstr "Προσαρμογή του αντικειμένου στη μια πλευρά" +#: fig/box_view.cpp:83 +msgid "box_item" +msgstr "" -msgid "picture caption" -msgstr "λεζάντα εικόνας" +#: fig/box_view.cpp:85 +msgid "id" +msgstr "" -msgid "picture dimension in pdf files" -msgstr "διαστάσεις εικόνας στα αρχεία pdf" +#: fig/box_view.cpp:90 fig/box_view.cpp:100 +msgid "c1" +msgstr "" -msgid "html div style: style=\"width: 99px;\"" -msgstr "html div style: style=\"πλάτος: 99px;\"" +#: fig/box_view.cpp:91 fig/box_view.cpp:102 +msgid "c2" +msgstr "" -msgid "html picture style: style=\"width: 99px;\"" -msgstr "html picture style: style=\"πλάτος: 99px;\"" +#: fig/box_view.cpp:92 +msgid "text" +msgstr "" -msgid "do not use this item for generating slides" -msgstr "μη χρησιμοποιήσετε αυτό το αντικείμενο για δημιουργία διαφανειών" +#: fig/box_view.cpp:93 +#, fuzzy +msgid "col" +msgstr "&Κύλιση" -#, c-format -msgid "command to launch (%s is the resulting file)" -msgstr "εντολή για φόρτωση (%s είναι το αρχείο που προκύπτει)" +#: fig/box_view.cpp:96 fig/box_view.cpp:132 +msgid "box_link" +msgstr "" -#, c-format -msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" -msgstr "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#: fig/box_view.cpp:99 +msgid "p1" +msgstr "" -#, c-format -msgid "firefox %s" -msgstr "firefox %s" +#: fig/box_view.cpp:101 +msgid "p2" +msgstr "" -#, c-format -msgid "ooimpress %s" -msgstr "ooimpress %s" +#: fig/box_view.cpp:114 +msgid "sl" +msgstr "" -#, c-format -msgid "oowriter %s" -msgstr "oowriter %s" +#: fig/box_view.cpp:115 +msgid "wl" +msgstr "" -msgid "document author" -msgstr "συγγραφέας εγγράφου" +#: fig/box_view.cpp:119 +msgid "box_link_offset" +msgstr "" -msgid "turn off the document author (latex)" -msgstr "απενεργοποίηση του συγγραφέα του εγγράφου (latex)" +#: fig/box_view.cpp:123 +msgid "x" +msgstr "" -msgid "document class (latex: a4, report, book)" -msgstr "κλάση εγγράφου (latex: a4, report, book)" +#: fig/box_view.cpp:123 +msgid "y" +msgstr "" -msgid "company" -msgstr "εταιρεία" +#: fig/box_view.cpp:160 +msgid "Properties..." +msgstr "" -msgid "document date" -msgstr "ημερομηνία εγγράφου" +#: fig/box_view.cpp:165 +msgid "Activity" +msgstr "" -msgid "turn of the document date (latex)" -msgstr "απενεργοποίηση ημερομηνίας εγγράφου (latex)" +#: fig/box_view.cpp:166 +msgid "Ctrl+Return" +msgstr "" -msgid "location of the presentation" -msgstr "τοποθεσία της παρουσίασης" +#: fig/box_view.cpp:171 +msgid "Delete" +msgstr "Διαγραφή" -msgid "document title" -msgstr "τίτλος εγγράφου" +#: fig/box_view.cpp:175 +msgid "Color..." +msgstr "Χρώμα..." -msgid "turn off the document title (latex)" -msgstr "απενεργοποίηση του τίτλου του εγγράφου (latex)" +#: fig/box_view.cpp:181 +msgid "PgUp" +msgstr "" -msgid "footer center (pdflatex)" -msgstr "κεντραρισμένο υποσέλιδο (pdflatex)" +#: fig/box_view.cpp:186 +msgid "PgDown" +msgstr "" -msgid "footer left (pdflatex)" -msgstr "υποσελίδο αριστερά (pdflatex)" +#: fig/box_view.cpp:190 +msgid "Floating text" +msgstr "" -msgid "turn off the fancy output" -msgstr "απενεργοποίηση του φανταχτερού αποτελέσματος" +#: fig/box_view.cpp:192 +msgid "Component" +msgstr "" + +#: fig/box_view.cpp:194 +msgid "Node" +msgstr "" + +#: fig/box_view.cpp:196 +msgid "Activity start" +msgstr "" + +#: fig/box_view.cpp:198 +msgid "Activity end" +msgstr "" + +#: fig/box_view.cpp:200 +msgid "Horizontal fork/join" +msgstr "" -msgid "footer right" -msgstr "υποσέλιδο δεξιά" +#: fig/box_view.cpp:202 +msgid "Vertical fork/join" +msgstr "" -msgid "header center (pdflatex)" -msgstr "κεφαλίδα κεντραρισμένη (pdflatex)" +#: fig/box_view.cpp:204 +msgid "Actor" +msgstr "" -msgid "header left" -msgstr "κεφαλίδα αριστερά" +#: fig/box_view.cpp:206 +msgid "Usecase" +msgstr "" -msgid "header right" -msgstr "κεφαλίδα δεξιά" +#: fig/box_view.cpp:215 +msgid "More elements" +msgstr "" -msgid "openoffice.org language (fr_FR)" -msgstr "γλώσσα openoffice.org (fr_FR)" +#: fig/box_view.cpp:247 +msgid "Alignment" +msgstr "" -msgid "openoffice.org presentation language" -msgstr "γλώσσα παρουσίασης openoffice.org " +#: fig/box_view.cpp:249 +msgid "Align left" +msgstr "" -msgid "openoffice.org text language" -msgstr "γλώσσα κειμένου openoffice.org " +#: fig/box_view.cpp:250 +msgid "Align center" +msgstr "" -msgid "Warsaw (JuanLesPins, Montpellier, )" -msgstr "Βαρσοβία (JuanLesPins, Montpellier, )" +#: fig/box_view.cpp:251 +#, fuzzy +msgid "Align right" +msgstr "Επιλογή δεξιά" -msgid "Generator dialog" -msgstr "Διάλογος δημιουργού" +#: fig/box_view.cpp:253 +msgid "Align top" +msgstr "" + +#: fig/box_view.cpp:254 +msgid "Align middle" +msgstr "" + +#: fig/box_view.cpp:255 +msgid "Align bottom" +msgstr "" + +#: fig/box_view.cpp:258 +msgid "Size" +msgstr "" + +#: fig/box_view.cpp:260 +msgid "Same width" +msgstr "" + +#: fig/box_view.cpp:261 +#, fuzzy +msgid "Same height" +msgstr "Επιλογή δεξιά" + +#: fig/box_view.cpp:262 +msgid "Same width and height" +msgstr "" + +#: flag_scheme.cpp:14 +msgid "Flag item(s) as..." +msgstr "Σημείωση αντικειμένου(ων) ως..." + +#: generator_dialog.cpp:30 +#, fuzzy +msgid "Generate documents" +msgstr "Δημιουργοί" +#: generator_dialog.cpp:36 msgid "Generators" msgstr "Δημιουργοί" +#: generator_dialog.cpp:39 msgid "Description" msgstr "Περιγραφή" +#: generator_dialog.cpp:63 msgid "Location" msgstr "Τοποθεσία" -msgid "&Ok" -msgstr "&Εντάξει" - -msgid "&Cancel" -msgstr "&Ακύρωση" - +#: generator_dialog.cpp:114 msgid "No document generator chosen." msgstr "Δεν επιλέχθηκε δημιουργός εγγράφου." +#: generator_dialog.cpp:114 msgid "Missing data" msgstr "Λείπουν δεδομένα" -#, kde-format +#: generator_dialog.cpp:120 msgid "Invalid output directory %1" msgstr "Μη έγκυρος φάκελος εξαγωγής%1" +#: generator_dialog.cpp:120 msgid "Missing location" msgstr "Λείπει η τοποθεσία" +#: image_view.cpp:36 msgid "Change picture" msgstr "Αλλαγή εικόνας" +#: image_view.cpp:40 msgid "Clear picture" msgstr "Καθαρισμός εικόνας" +#: image_view.cpp:65 msgid "Click to set a picture" msgstr "Κάντε κλικ για να ορίσετε μια εικόνα" +#: image_view.cpp:69 msgid "Select an item on the map" msgstr "Επιλέξτε ένα αντικείμενο στον χάρτη" -msgid "Choose a file" +#: image_view.cpp:165 +#, fuzzy +msgid "*.png *.jpg *.jpeg *.gif|Image Files (*.png *.jpg *.jpeg *.gif)" +msgstr "Αρχεία εικόνων (*.png *.jpg *.jpeg *.gif)" + +#: image_view.cpp:166 +#, fuzzy +msgid "Choose a picture" msgstr "Επιλογή ενός αρχείου" -msgid "Image files (*.png *.jpg *.jpeg *.gif)" -msgstr "Αρχεία εικόνων (*.png *.jpg *.jpeg *.gif)" +#: image_view.cpp:178 +#, fuzzy +msgid "Could not load the picture" +msgstr "Κάντε κλικ για να ορίσετε μια εικόνα" + +#: main.cpp:25 +msgid "" +"A mind-mapping tool for KDE\n" +"Available exclusively for open systems such as OpenSuse, Gentoo or Fedora." +msgstr "" + +#: main.cpp:41 +msgid "A file to open on startup" +msgstr "" + +#: main.cpp:43 +msgid "Semantik" +msgstr "Semantik" + +#: main.cpp:44 +msgid "(C) 2007-2012 Thomas Nagy" +msgstr "" + +#: main.cpp:47 +msgid "Thomas Nagy" +msgstr "" + +#. i18n: file: data/semantikui.rc:5 +#. i18n: ectx: Menu (file) +#: po/rc.cpp:3 rc.cpp:3 +msgid "&File" +msgstr "" + +#. i18n: file: data/semantikui.rc:7 +#. i18n: ectx: Menu (edit) +#: po/rc.cpp:6 rc.cpp:6 +msgid "&Edit" +msgstr "" + +#. i18n: file: data/semantikui.rc:12 +#. i18n: ectx: Menu (view) +#: po/rc.cpp:9 rc.cpp:9 +msgid "&View" +msgstr "" + +#. i18n: file: data/semantikui.rc:20 +#. i18n: ectx: Menu (tools) +#: po/rc.cpp:12 rc.cpp:12 +msgid "&Tools" +msgstr "" -#, kde-format -msgid "File %1 does not exist" -msgstr "Το αρχείο %1 δεν υπάρχει" - -#, kde-format -msgid "File %1 could not be opened" -msgstr "Το αρχείο %1 δεν μπορεί να ανοίξει" +#. i18n: file: data/semantikui.rc:23 +#. i18n: ectx: Menu (settings) +#: po/rc.cpp:15 rc.cpp:15 +msgid "&Settings" +msgstr "" -msgid "something bad happened" -msgstr "συνέβη κάτι άσχημο" +#. i18n: file: data/semantikui.rc:26 +#. i18n: ectx: Menu (help) +#: po/rc.cpp:18 rc.cpp:18 +msgid "&Help" +msgstr "" -msgid "something worse happened" -msgstr "συνέβη κάτι χειρότερο" +#. i18n: file: data/semantikui.rc:40 +#. i18n: ectx: ToolBar (colorsToolBar) +#: po/rc.cpp:21 rc.cpp:21 +#, fuzzy +msgid "Colors Toolbar" +msgstr "Χρώματα" + +#. i18n: file: data/semantikui.rc:44 +#. i18n: ectx: ToolBar (flagsToolBar) +#: po/rc.cpp:24 rc.cpp:24 +msgid "Flags Toolbar" +msgstr "" + +#: po/rc.cpp:25 rc.cpp:25 +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "" + +#: po/rc.cpp:26 rc.cpp:26 +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "" +#: pre_view.cpp:23 msgid "

    No preview available
    at this time

    " msgstr "" -"

    Δεν υπάρχει διαθέσιμη προεπισκόπηση
    αυτή τη στιγμή<" -"/p>" +"

    Δεν υπάρχει διαθέσιμη προεπισκόπηση
    αυτή τη στιγμή

    " +#: semantik.cpp:45 msgid "" "The map is empty, Semantik\n" "cannot create documents from it" @@ -378,78 +631,116 @@ "δεν μπορεί να δημιουργήσει έγγραφα\n" "από αυτόν." +#: semantik.cpp:45 msgid "Empty map" msgstr "Κενός χάρτης" -#, kde-format +#: semantik.cpp:52 msgid "Template folder %1 is not readable" msgstr "Ο φάκελος των προτύπων %1 δεν είναι αναγνώσιμος" +#: semantik.cpp:166 msgid "&Reorganize the map" msgstr "&Αναδιοργάνωση του χάρτη" -msgid "&Generate..." -msgstr "&Δημιουργία" +#: semantik.cpp:168 +msgid "Ctrl+R" +msgstr "" -msgid "&Select" -msgstr "&Επιλογή" +#: semantik.cpp:171 +msgid "&Export the map..." +msgstr "" -msgid "&Link" -msgstr "&Σύνδεση" +#: semantik.cpp:173 +msgid "Ctrl+Shift+E" +msgstr "" -msgid "&Sort" -msgstr "&Ταξινόμηση" +#: semantik.cpp:178 +msgid "&Generate..." +msgstr "&Δημιουργία" -msgid "&Scroll" -msgstr "&Κύλιση" +#: semantik.cpp:181 +msgid "Ctrl+G" +msgstr "" +#: semantik.cpp:187 msgid "CustomColor" msgstr "Προσαρμοσμένο χρώμα" +#: semantik.cpp:201 +msgid "Ctrl+H" +msgstr "" + +#: semantik.cpp:210 msgid "Data" msgstr "Δεδομένα" +#: semantik.cpp:233 msgid "Variables" msgstr "Μεταβλητές" +#: semantik.cpp:242 msgid "Preview" msgstr "Προεπισκόπηση" +#: semantik.cpp:254 msgid "Linear view" msgstr "Γραμμική προβολή" +#: semantik.cpp:347 msgid "Welcome to Semantik" msgstr "Καλωσήρθατε στο Semantik" +#: semantik.cpp:393 msgid "Ready" msgstr "Έτοιμος" +#: semantik.cpp:400 msgid "*.sem|Semantik file (*.sem)" msgstr "*.sem|Semantik file (*.sem)" +#: semantik.cpp:401 semantik.cpp:463 msgid "Choose a file name" msgstr "Επιλέξτε ένα όνομα αρχείου" -#, kde-format +#: semantik.cpp:414 +msgid "" +"The file \"%1\" already exists.\n" +"Overwrite it?" +msgstr "" + +#: semantik.cpp:415 +msgid "Overwrite existing file" +msgstr "" + +#: semantik.cpp:426 semantik.cpp:448 msgid "Saved '%1'" msgstr "Αποθηκεύτηκε '%1'" +#: semantik.cpp:462 msgid "*.sem *.kdi *.mm *.vym|All Supported Files (*.sem *.kdi *.mm *.vym)" msgstr "" -"*.sem *.kdi *.mm *.vym|Όλα τα υποστηριζόμενα αρχεία (*.sem *.kdi *.mm *." -"vym)" +"*.sem *.kdi *.mm *.vym|Όλα τα υποστηριζόμενα αρχεία (*.sem *.kdi *.mm *.vym)" -msgid "Semantik" +#: semantik.cpp:474 +msgid " [Modified] " +msgstr "" + +#: semantik.cpp:479 +#, fuzzy +msgid "Semantik %1" msgstr "Semantik" -#, kde-format -msgid "%1 - Semantik" +#: semantik.cpp:483 +#, fuzzy +msgid "%1 %2 - Semantik" msgstr "%1 - Semantik" +#: semantik.cpp:530 msgid "Untitled" msgstr "Χωρίς τίτλο" -#, kde-format +#: semantik.cpp:533 msgid "" "The document \"%1\" has been modified.\n" "Do you want to save your changes or discard them?" @@ -458,61 +749,289 @@ "Θέλετε να αποθηκεύσετε τις αλλαγές\n" "ή να τις απορρίψετε;" +#: semantik.cpp:534 msgid "Close Document" msgstr "Κλείσιμο εγγράφου" +#: sem_mediator.cpp:270 +msgid "Automatic save failed for file: %1" +msgstr "Απέτυχε η αυτόματη αποθήκευση για το αρχείο: %1" + +#: sem_mediator.cpp:273 +msgid "%1 saved automatically" +msgstr "%1 αποθηκεύτηκε αυτόματα" + +#: sem_mediator.cpp:292 +msgid "Color %1" +msgstr "Χρώμα %1" + +#: sem_mediator.cpp:618 +msgid "File saving: missing file %1" +msgstr "Αποθήκευση αρχείου: το αρχείο %1 λείπει" + +#: sem_mediator.cpp:643 sem_mediator.cpp:1142 sem_mediator.cpp:1185 +msgid "Missing bindings for opening files" +msgstr "Ανυπαρξία δεσμών για το άνοιγμα των αρχείων" + +#: sem_mediator.cpp:694 +msgid "Missing filter file %1 for opening files" +msgstr "Έλλειψη φίλτρου αρχείου %1 για το άνοιγμα των αρχείων" + +#: sem_mediator.cpp:694 sem_mediator.cpp:709 +msgid "Broken installation" +msgstr "" + +#: sem_mediator.cpp:709 +#, fuzzy +msgid "Missing python bindings for opening files" +msgstr "Ανυπαρξία δεσμών για το άνοιγμα των αρχείων" + +#: sem_mediator.cpp:725 +msgid "Could not load the document %1" +msgstr "" + +#: sem_mediator.cpp:725 +#, fuzzy +msgid "Broken document" +msgstr "Κλείσιμο εγγράφου" + +#: sem_mediator.cpp:1108 +msgid "Code generation failed: missing file %1" +msgstr "Η δημιουργία κώδικα απέτυχε: αρχείο που λείπει %1" + +#: sem_mediator.cpp:1147 +msgid "Document generation completed successfully" +msgstr "" + +#: table_dialog.cpp:32 msgid "Rows" msgstr "Γραμμές" +#: table_dialog.cpp:36 msgid "Columns" msgstr "Στήλες" +#: table_view.cpp:25 table_view.cpp:79 msgid "Add Row" msgstr "Προσθήκη γραμμής" +#: table_view.cpp:26 msgid "Add a row" msgstr "Προσθήκη μιας γραμμής" +#: table_view.cpp:30 table_view.cpp:80 msgid "Add Column" msgstr "Προσθήκη στήλης" +#: table_view.cpp:31 msgid "Add a column" msgstr "Προσθήκη μιας στήλης" +#: table_view.cpp:36 table_view.cpp:81 msgid "Remove Row" msgstr "Διαγραφή γραμμής" +#: table_view.cpp:37 msgid "Remove a row" msgstr "Διαγραφή μιας γραμμής" +#: table_view.cpp:41 table_view.cpp:82 msgid "Remove Column" msgstr "Διαγραφή στήλης" +#: table_view.cpp:42 msgid "Remove a column" msgstr "Διαγραφή μιας στήλης" +#: table_view.cpp:46 msgid "Redimension" msgstr "Επαναπροσδιορισμός διαστάσεων" +#: table_view.cpp:47 msgid "Change table dimensions" msgstr "Αλλαγή διαστάσεων πίνακα" +#: text_view.cpp:40 msgid "&Bold" msgstr "&Έντονα" +#: text_view.cpp:41 +msgid "Ctrl+B" +msgstr "" + +#: text_view.cpp:44 msgid "&Italic" msgstr "&Πλάγια" +#: text_view.cpp:45 +msgid "Ctrl+I" +msgstr "" + +#: text_view.cpp:48 msgid "&Underline" msgstr "&Υπογράμμιση" +#: text_view.cpp:49 +msgid "Ctrl+U" +msgstr "" + +#: vars_view.cpp:76 msgid "Code complete" msgstr "Ο κώδικας συμπληρώθηκε" -msgid "exclude the picture" -msgstr "αποκλεισμός της εικόνας" +#: vars_view.cpp:77 +msgid "Ctrl+space" +msgstr "" + +#~ msgid "Insert child" +#~ msgstr "Εισαγωγή απογονικού κόμβου" + +#~ msgid "dirty" +#~ msgstr "λερωμένος" + +#~ msgid "Add Box" +#~ msgstr "Προσθήκη πλαισίου" + +#~ msgid "Connection width" +#~ msgstr "Πλάτος σύνδεσης" + +#~ msgid "1px" +#~ msgstr "1px" + +#~ msgid "2px" +#~ msgstr "2px" + +#~ msgid "3px" +#~ msgstr "3px" + +#~ msgid "Connection style" +#~ msgstr "Στυλ σύνδεσης" + +#~ msgid "dot line" +#~ msgstr "γραμμή με τελείες" + +#~ msgid "exclude the table" +#~ msgstr "αποκλεισμός του πίνακα" + +#~ msgid "fit the item on one slide" +#~ msgstr "Προσαρμογή του αντικειμένου στη μια πλευρά" + +#~ msgid "picture caption" +#~ msgstr "λεζάντα εικόνας" + +#~ msgid "picture dimension in pdf files" +#~ msgstr "διαστάσεις εικόνας στα αρχεία pdf" + +#~ msgid "html div style: style=\"width: 99px;\"" +#~ msgstr "html div style: style=\"πλάτος: 99px;\"" + +#~ msgid "html picture style: style=\"width: 99px;\"" +#~ msgstr "html picture style: style=\"πλάτος: 99px;\"" + +#~ msgid "do not use this item for generating slides" +#~ msgstr "μη χρησιμοποιήσετε αυτό το αντικείμενο για δημιουργία διαφανειών" + +#~ msgid "command to launch (%s is the resulting file)" +#~ msgstr "εντολή για φόρτωση (%s είναι το αρχείο που προκύπτει)" + +#~ msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#~ msgstr "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" + +#~ msgid "firefox %s" +#~ msgstr "firefox %s" + +#~ msgid "ooimpress %s" +#~ msgstr "ooimpress %s" + +#~ msgid "oowriter %s" +#~ msgstr "oowriter %s" + +#~ msgid "document author" +#~ msgstr "συγγραφέας εγγράφου" + +#~ msgid "turn off the document author (latex)" +#~ msgstr "απενεργοποίηση του συγγραφέα του εγγράφου (latex)" + +#~ msgid "document class (latex: a4, report, book)" +#~ msgstr "κλάση εγγράφου (latex: a4, report, book)" + +#~ msgid "company" +#~ msgstr "εταιρεία" + +#~ msgid "document date" +#~ msgstr "ημερομηνία εγγράφου" + +#~ msgid "turn of the document date (latex)" +#~ msgstr "απενεργοποίηση ημερομηνίας εγγράφου (latex)" + +#~ msgid "location of the presentation" +#~ msgstr "τοποθεσία της παρουσίασης" + +#~ msgid "turn off the document title (latex)" +#~ msgstr "απενεργοποίηση του τίτλου του εγγράφου (latex)" + +#~ msgid "footer center (pdflatex)" +#~ msgstr "κεντραρισμένο υποσέλιδο (pdflatex)" + +#~ msgid "footer left (pdflatex)" +#~ msgstr "υποσελίδο αριστερά (pdflatex)" + +#~ msgid "turn off the fancy output" +#~ msgstr "απενεργοποίηση του φανταχτερού αποτελέσματος" + +#~ msgid "footer right" +#~ msgstr "υποσέλιδο δεξιά" + +#~ msgid "header center (pdflatex)" +#~ msgstr "κεφαλίδα κεντραρισμένη (pdflatex)" + +#~ msgid "header left" +#~ msgstr "κεφαλίδα αριστερά" + +#~ msgid "header right" +#~ msgstr "κεφαλίδα δεξιά" + +#~ msgid "openoffice.org language (fr_FR)" +#~ msgstr "γλώσσα openoffice.org (fr_FR)" + +#~ msgid "openoffice.org presentation language" +#~ msgstr "γλώσσα παρουσίασης openoffice.org " + +#~ msgid "openoffice.org text language" +#~ msgstr "γλώσσα κειμένου openoffice.org " + +#~ msgid "Warsaw (JuanLesPins, Montpellier, )" +#~ msgstr "Βαρσοβία (JuanLesPins, Montpellier, )" + +#~ msgid "Generator dialog" +#~ msgstr "Διάλογος δημιουργού" + +#~ msgid "&Ok" +#~ msgstr "&Εντάξει" + +#~ msgid "File %1 does not exist" +#~ msgstr "Το αρχείο %1 δεν υπάρχει" + +#~ msgid "File %1 could not be opened" +#~ msgstr "Το αρχείο %1 δεν μπορεί να ανοίξει" + +#~ msgid "something bad happened" +#~ msgstr "συνέβη κάτι άσχημο" + +#~ msgid "something worse happened" +#~ msgstr "συνέβη κάτι χειρότερο" + +#~ msgid "&Select" +#~ msgstr "&Επιλογή" + +#~ msgid "&Link" +#~ msgstr "&Σύνδεση" -msgid "latex language: english (frenchb, )" -msgstr "γλώσσα latex: αγγλικά (frenchb, )" +#~ msgid "&Sort" +#~ msgstr "&Ταξινόμηση" +#~ msgid "exclude the picture" +#~ msgstr "αποκλεισμός της εικόνας" +#~ msgid "latex language: english (frenchb, )" +#~ msgstr "γλώσσα latex: αγγλικά (frenchb, )" diff -Nru semantik-0.7.3/src/po/es.po semantik-0.8.3/src/po/es.po --- semantik-0.7.3/src/po/es.po 2009-08-30 11:35:33.000000000 +0000 +++ semantik-0.8.3/src/po/es.po 2012-10-21 10:09:17.000000000 +0000 @@ -1,501 +1,845 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: http://www.google.com\n" -"POT-Creation-Date: 2009-04-26 15:20+0200\n" +"Report-Msgid-Bugs-To: http://code.google.com/p/semantik/issues\n" +"POT-Creation-Date: 2012-10-09 23:25+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -msgid "Empty" -msgstr "Vacio" - -msgid "Toggle edit" +#: browser.cpp:21 canvas_view.cpp:134 +msgid "Toggle fullscreen" msgstr "" -msgid "Insert child" +#: canvas_view.cpp:83 +msgid "Add an element" msgstr "" +#: canvas_view.cpp:88 fig/box_view.cpp:170 msgid "Delete selection" msgstr "" -msgid "Insert sibling" +#: canvas_view.cpp:93 +msgid "Insert a sibling" msgstr "" +#: canvas_view.cpp:98 fig/box_view.cpp:180 msgid "Move up" msgstr "" +#: canvas_view.cpp:99 fig/box_view.cpp:185 msgid "Move down" msgstr "" +#: canvas_view.cpp:100 msgid "Move left" msgstr "" +#: canvas_view.cpp:101 msgid "Move right" msgstr "" +#: canvas_view.cpp:103 msgid "Select up" msgstr "" +#: canvas_view.cpp:104 msgid "Select down" msgstr "" +#: canvas_view.cpp:105 msgid "Select left" msgstr "" +#: canvas_view.cpp:106 msgid "Select right" msgstr "" +#: canvas_view.cpp:109 +msgid "Select subtree" +msgstr "" + +#: canvas_view.cpp:114 msgid "Next root" msgstr "" +#: canvas_view.cpp:117 +msgid "Toggle edit" +msgstr "" + +#: canvas_view.cpp:122 +msgid "Cancel edit" +msgstr "" + +#: canvas_view.cpp:138 msgid "Colors" msgstr "" +#: canvas_view.cpp:139 msgid "Data type" msgstr "" +#: canvas_view.cpp:148 msgid "Text" msgstr "" +#: canvas_view.cpp:149 msgid "Diagram" msgstr "" +#: canvas_view.cpp:150 msgid "Table" msgstr "" +#: canvas_view.cpp:151 msgid "Image" msgstr "" -msgid "Flag" -msgstr "" +#: canvas_view.cpp:224 canvas_view.cpp:276 canvas_view.cpp:288 +#: data_item.cpp:27 +msgid "Empty" +msgstr "Vacio" +#: canvas_view.cpp:573 msgid "Color" msgstr "" -#, kde-format +#: canvas_view.cpp:623 +msgid "Flag" +msgstr "" + +#: canvas_view.cpp:940 msgid "Click to set Item %1" msgstr "" +#: canvas_view.cpp:1250 +msgid "*.png|PNG Files (*.png)" +msgstr "" + +#: canvas_view.cpp:1288 +msgid "No destination file selected" +msgstr "" + +#: canvas_view.cpp:1323 +msgid "Exported '%1'" +msgstr "" + +#: canvas_view.cpp:1325 +msgid "Could not save to %1" +msgstr "" + +#: canvas_view.cpp:1325 +msgid "Missing picture" +msgstr "" + +#: config_dialog.cpp:29 +msgid "Document settings" +msgstr "" + +#: config_dialog.cpp:37 msgid "Reorganization type" msgstr "" +#: config_dialog.cpp:41 msgid "Connection type" msgstr "" +#: config_dialog.cpp:45 msgid "Save document automatically" msgstr "" +#: config_dialog.cpp:49 msgid "Background color" msgstr "" +#: config_dialog.cpp:54 msgid "Fixed" msgstr "" +#: config_dialog.cpp:54 msgid "Force-based" msgstr "" +#: config_dialog.cpp:54 msgid "Incremental" msgstr "" +#: config_dialog.cpp:58 msgid "Lines" msgstr "" +#: config_dialog.cpp:58 msgid "Splines" msgstr "" +#: config_dialog.cpp:62 msgid " min" msgstr "" +#: config_dialog.cpp:65 msgid "" "Interval in minutes for saving the document automatically, 0 for disabling " "this feature" msgstr "" -#, kde-format -msgid "Automatic save failed for file: %1" +#: data_view.cpp:17 +msgid "

    No item selected

    " msgstr "" -#, kde-format -msgid "%1 saved automatically" +#: doc_dialog.cpp:30 +msgid "First Name" msgstr "" -#, kde-format -msgid "Color %1" +#: doc_dialog.cpp:34 generator_dialog.cpp:56 +msgid "Name" msgstr "" -#, kde-format -msgid "File saving: missing file %1" +#: doc_dialog.cpp:38 +msgid "Organization" msgstr "" -msgid "Missing bindings for opening files" +#: doc_dialog.cpp:42 +msgid "Email" msgstr "" -#, kde-format -msgid "Missing filter file %1 for opening files" +#: export_map_dialog.cpp:31 +msgid "Export the map" msgstr "" -msgid "dirty" +#: export_map_dialog.cpp:37 +msgid "File to write" msgstr "" -#, kde-format -msgid "Code generation failed: missing file %1" +#: export_map_dialog.cpp:43 +msgid "Width" msgstr "" -msgid "

    No item selected

    " +#: export_map_dialog.cpp:51 +msgid "Height" msgstr "" -msgid "First Name" +#: fig/box_fork.cpp:334 fig/box_item.cpp:133 +msgid "%1 x %2" msgstr "" -msgid "Name" +#: fig/box_item.cpp:189 +msgid "Properties for diagram box" msgstr "" -msgid "Organization" +#: fig/box_item.cpp:190 +msgid "Text:" msgstr "" -msgid "Email" +#: fig/box_link_properties.cpp:21 +msgid "Link properties" msgstr "" -msgid "Add Box" +#: fig/box_link_properties.cpp:29 +msgid "Thickness" msgstr "" -msgid "Delete" +#: fig/box_link_properties.cpp:33 +msgid "Line Style" msgstr "" -msgid "Color..." +#: fig/box_link_properties.cpp:37 +msgid "Left arrow" msgstr "" -msgid "Connection width" +#: fig/box_link_properties.cpp:41 +msgid "Right arrow" msgstr "" -msgid "1px" +#: fig/box_link_properties.cpp:51 +msgid "Invisible line" msgstr "" -msgid "2px" +#: fig/box_link_properties.cpp:52 +msgid "Solid Line" msgstr "" -msgid "3px" +#: fig/box_link_properties.cpp:53 +msgid "Dot Line" msgstr "" -msgid "Connection style" +#: fig/box_link_properties.cpp:54 +msgid "Dash Line" msgstr "" -msgid "solid line" +#: fig/box_link_properties.cpp:58 fig/box_link_properties.cpp:63 +msgid "No arrow" msgstr "" -msgid "dot line" +#: fig/box_link_properties.cpp:59 fig/box_link_properties.cpp:64 +msgid "Triangle" msgstr "" -msgid "dash line" +#: fig/box_view.cpp:83 +msgid "box_item" msgstr "" -msgid "Flag item(s) as..." +#: fig/box_view.cpp:85 +msgid "id" msgstr "" -msgid "exclude the table" +#: fig/box_view.cpp:90 fig/box_view.cpp:100 +msgid "c1" msgstr "" -msgid "fit the item on one slide" +#: fig/box_view.cpp:91 fig/box_view.cpp:102 +msgid "c2" msgstr "" -msgid "picture caption" +#: fig/box_view.cpp:92 +msgid "text" msgstr "" -msgid "picture dimension in pdf files" +#: fig/box_view.cpp:93 +msgid "col" msgstr "" -msgid "html div style: style=\"width: 99px;\"" +#: fig/box_view.cpp:96 fig/box_view.cpp:132 +msgid "box_link" msgstr "" -msgid "html picture style: style=\"width: 99px;\"" +#: fig/box_view.cpp:99 +msgid "p1" msgstr "" -msgid "do not use this item for generating slides" +#: fig/box_view.cpp:101 +msgid "p2" msgstr "" -#, c-format -msgid "command to launch (%s is the resulting file)" +#: fig/box_view.cpp:114 +msgid "sl" msgstr "" -#, c-format -msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#: fig/box_view.cpp:115 +msgid "wl" msgstr "" -#, c-format -msgid "firefox %s" +#: fig/box_view.cpp:119 +msgid "box_link_offset" msgstr "" -#, c-format -msgid "ooimpress %s" +#: fig/box_view.cpp:123 +msgid "x" msgstr "" -#, c-format -msgid "oowriter %s" +#: fig/box_view.cpp:123 +msgid "y" msgstr "" -msgid "document author" +#: fig/box_view.cpp:160 +msgid "Properties..." msgstr "" -msgid "turn off the document author (latex)" +#: fig/box_view.cpp:165 +msgid "Activity" msgstr "" -msgid "document class (latex: a4, report, book)" +#: fig/box_view.cpp:166 +msgid "Ctrl+Return" msgstr "" -msgid "company" +#: fig/box_view.cpp:171 +msgid "Delete" msgstr "" -msgid "document date" +#: fig/box_view.cpp:175 +msgid "Color..." msgstr "" -msgid "turn of the document date (latex)" +#: fig/box_view.cpp:181 +msgid "PgUp" msgstr "" -msgid "location of the presentation" +#: fig/box_view.cpp:186 +msgid "PgDown" msgstr "" -msgid "document title" +#: fig/box_view.cpp:190 +msgid "Floating text" msgstr "" -msgid "turn off the document title (latex)" +#: fig/box_view.cpp:192 +msgid "Component" msgstr "" -msgid "footer center (pdflatex)" +#: fig/box_view.cpp:194 +msgid "Node" msgstr "" -msgid "footer left (pdflatex)" +#: fig/box_view.cpp:196 +msgid "Activity start" msgstr "" -msgid "turn off the fancy output" +#: fig/box_view.cpp:198 +msgid "Activity end" msgstr "" -msgid "footer right" +#: fig/box_view.cpp:200 +msgid "Horizontal fork/join" msgstr "" -msgid "header center (pdflatex)" +#: fig/box_view.cpp:202 +msgid "Vertical fork/join" msgstr "" -msgid "header left" +#: fig/box_view.cpp:204 +msgid "Actor" msgstr "" -msgid "header right" +#: fig/box_view.cpp:206 +msgid "Usecase" msgstr "" -msgid "openoffice.org language (fr_FR)" +#: fig/box_view.cpp:215 +msgid "More elements" msgstr "" -msgid "openoffice.org presentation language" +#: fig/box_view.cpp:247 +msgid "Alignment" msgstr "" -msgid "openoffice.org text language" +#: fig/box_view.cpp:249 +msgid "Align left" msgstr "" -msgid "Warsaw (JuanLesPins, Montpellier, )" +#: fig/box_view.cpp:250 +msgid "Align center" msgstr "" -msgid "Generator dialog" +#: fig/box_view.cpp:251 +msgid "Align right" msgstr "" -msgid "Generators" +#: fig/box_view.cpp:253 +msgid "Align top" msgstr "" -msgid "Description" +#: fig/box_view.cpp:254 +msgid "Align middle" msgstr "" -msgid "Location" +#: fig/box_view.cpp:255 +msgid "Align bottom" msgstr "" -msgid "&Ok" +#: fig/box_view.cpp:258 +msgid "Size" msgstr "" -msgid "&Cancel" +#: fig/box_view.cpp:260 +msgid "Same width" msgstr "" +#: fig/box_view.cpp:261 +msgid "Same height" +msgstr "" + +#: fig/box_view.cpp:262 +msgid "Same width and height" +msgstr "" + +#: flag_scheme.cpp:14 +msgid "Flag item(s) as..." +msgstr "" + +#: generator_dialog.cpp:30 +msgid "Generate documents" +msgstr "" + +#: generator_dialog.cpp:36 +msgid "Generators" +msgstr "" + +#: generator_dialog.cpp:39 +msgid "Description" +msgstr "" + +#: generator_dialog.cpp:63 +msgid "Location" +msgstr "" + +#: generator_dialog.cpp:114 msgid "No document generator chosen." msgstr "" +#: generator_dialog.cpp:114 msgid "Missing data" msgstr "" -#, kde-format +#: generator_dialog.cpp:120 msgid "Invalid output directory %1" msgstr "" +#: generator_dialog.cpp:120 msgid "Missing location" msgstr "" +#: image_view.cpp:36 msgid "Change picture" msgstr "" +#: image_view.cpp:40 msgid "Clear picture" msgstr "" +#: image_view.cpp:65 msgid "Click to set a picture" msgstr "" +#: image_view.cpp:69 msgid "Select an item on the map" msgstr "" -msgid "Choose a file" +#: image_view.cpp:165 +msgid "*.png *.jpg *.jpeg *.gif|Image Files (*.png *.jpg *.jpeg *.gif)" +msgstr "" + +#: image_view.cpp:166 +msgid "Choose a picture" +msgstr "" + +#: image_view.cpp:178 +msgid "Could not load the picture" +msgstr "" + +#: main.cpp:25 +msgid "" +"A mind-mapping tool for KDE\n" +"Available exclusively for open systems such as OpenSuse, Gentoo or Fedora." +msgstr "" + +#: main.cpp:41 +msgid "A file to open on startup" +msgstr "" + +#: main.cpp:43 +msgid "Semantik" +msgstr "" + +#: main.cpp:44 +msgid "(C) 2007-2012 Thomas Nagy" +msgstr "" + +#: main.cpp:47 +msgid "Thomas Nagy" +msgstr "" + +#. i18n: file: data/semantikui.rc:5 +#. i18n: ectx: Menu (file) +#: po/rc.cpp:3 rc.cpp:3 +msgid "&File" +msgstr "" + +#. i18n: file: data/semantikui.rc:7 +#. i18n: ectx: Menu (edit) +#: po/rc.cpp:6 rc.cpp:6 +msgid "&Edit" msgstr "" -msgid "Image files (*.png *.jpg *.jpeg *.gif)" +#. i18n: file: data/semantikui.rc:12 +#. i18n: ectx: Menu (view) +#: po/rc.cpp:9 rc.cpp:9 +msgid "&View" msgstr "" -#, kde-format -msgid "File %1 does not exist" +#. i18n: file: data/semantikui.rc:20 +#. i18n: ectx: Menu (tools) +#: po/rc.cpp:12 rc.cpp:12 +msgid "&Tools" msgstr "" -#, kde-format -msgid "File %1 could not be opened" +#. i18n: file: data/semantikui.rc:23 +#. i18n: ectx: Menu (settings) +#: po/rc.cpp:15 rc.cpp:15 +msgid "&Settings" msgstr "" -msgid "something bad happened" +#. i18n: file: data/semantikui.rc:26 +#. i18n: ectx: Menu (help) +#: po/rc.cpp:18 rc.cpp:18 +msgid "&Help" msgstr "" -msgid "something worse happened" +#. i18n: file: data/semantikui.rc:40 +#. i18n: ectx: ToolBar (colorsToolBar) +#: po/rc.cpp:21 rc.cpp:21 +msgid "Colors Toolbar" msgstr "" +#. i18n: file: data/semantikui.rc:44 +#. i18n: ectx: ToolBar (flagsToolBar) +#: po/rc.cpp:24 rc.cpp:24 +msgid "Flags Toolbar" +msgstr "" + +#: po/rc.cpp:25 rc.cpp:25 +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "" + +#: po/rc.cpp:26 rc.cpp:26 +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "" + +#: pre_view.cpp:23 msgid "

    No preview available
    at this time

    " msgstr "" +#: semantik.cpp:45 msgid "" "The map is empty, Semantik\n" "cannot create documents from it" msgstr "" +#: semantik.cpp:45 msgid "Empty map" msgstr "" -#, kde-format +#: semantik.cpp:52 msgid "Template folder %1 is not readable" msgstr "" +#: semantik.cpp:166 msgid "&Reorganize the map" msgstr "" -msgid "&Generate..." +#: semantik.cpp:168 +msgid "Ctrl+R" msgstr "" -msgid "&Select" +#: semantik.cpp:171 +msgid "&Export the map..." msgstr "" -msgid "&Link" +#: semantik.cpp:173 +msgid "Ctrl+Shift+E" msgstr "" -msgid "&Sort" +#: semantik.cpp:178 +msgid "&Generate..." msgstr "" -msgid "&Scroll" +#: semantik.cpp:181 +msgid "Ctrl+G" msgstr "" +#: semantik.cpp:187 msgid "CustomColor" msgstr "" +#: semantik.cpp:201 +msgid "Ctrl+H" +msgstr "" + +#: semantik.cpp:210 msgid "Data" msgstr "" +#: semantik.cpp:233 msgid "Variables" msgstr "" +#: semantik.cpp:242 msgid "Preview" msgstr "" +#: semantik.cpp:254 msgid "Linear view" msgstr "" +#: semantik.cpp:347 msgid "Welcome to Semantik" msgstr "" +#: semantik.cpp:393 msgid "Ready" msgstr "" +#: semantik.cpp:400 msgid "*.sem|Semantik file (*.sem)" msgstr "" +#: semantik.cpp:401 semantik.cpp:463 msgid "Choose a file name" msgstr "" -#, kde-format +#: semantik.cpp:414 +msgid "" +"The file \"%1\" already exists.\n" +"Overwrite it?" +msgstr "" + +#: semantik.cpp:415 +msgid "Overwrite existing file" +msgstr "" + +#: semantik.cpp:426 semantik.cpp:448 msgid "Saved '%1'" msgstr "" +#: semantik.cpp:462 msgid "*.sem *.kdi *.mm *.vym|All Supported Files (*.sem *.kdi *.mm *.vym)" msgstr "" -msgid "Semantik" +#: semantik.cpp:474 +msgid " [Modified] " +msgstr "" + +#: semantik.cpp:479 +msgid "Semantik %1" msgstr "" -#, kde-format -msgid "%1 - Semantik" +#: semantik.cpp:483 +msgid "%1 %2 - Semantik" msgstr "" +#: semantik.cpp:530 msgid "Untitled" msgstr "" -#, kde-format +#: semantik.cpp:533 msgid "" "The document \"%1\" has been modified.\n" "Do you want to save your changes or discard them?" msgstr "" +#: semantik.cpp:534 msgid "Close Document" msgstr "" +#: sem_mediator.cpp:270 +msgid "Automatic save failed for file: %1" +msgstr "" + +#: sem_mediator.cpp:273 +msgid "%1 saved automatically" +msgstr "" + +#: sem_mediator.cpp:292 +msgid "Color %1" +msgstr "" + +#: sem_mediator.cpp:618 +msgid "File saving: missing file %1" +msgstr "" + +#: sem_mediator.cpp:643 sem_mediator.cpp:1142 sem_mediator.cpp:1185 +msgid "Missing bindings for opening files" +msgstr "" + +#: sem_mediator.cpp:694 +msgid "Missing filter file %1 for opening files" +msgstr "" + +#: sem_mediator.cpp:694 sem_mediator.cpp:709 +msgid "Broken installation" +msgstr "" + +#: sem_mediator.cpp:709 +msgid "Missing python bindings for opening files" +msgstr "" + +#: sem_mediator.cpp:725 +msgid "Could not load the document %1" +msgstr "" + +#: sem_mediator.cpp:725 +msgid "Broken document" +msgstr "" + +#: sem_mediator.cpp:1108 +msgid "Code generation failed: missing file %1" +msgstr "" + +#: sem_mediator.cpp:1147 +msgid "Document generation completed successfully" +msgstr "" + +#: table_dialog.cpp:32 msgid "Rows" msgstr "" +#: table_dialog.cpp:36 msgid "Columns" msgstr "" +#: table_view.cpp:25 table_view.cpp:79 msgid "Add Row" msgstr "" +#: table_view.cpp:26 msgid "Add a row" msgstr "" +#: table_view.cpp:30 table_view.cpp:80 msgid "Add Column" msgstr "" +#: table_view.cpp:31 msgid "Add a column" msgstr "" +#: table_view.cpp:36 table_view.cpp:81 msgid "Remove Row" msgstr "" +#: table_view.cpp:37 msgid "Remove a row" msgstr "" +#: table_view.cpp:41 table_view.cpp:82 msgid "Remove Column" msgstr "" +#: table_view.cpp:42 msgid "Remove a column" msgstr "" +#: table_view.cpp:46 msgid "Redimension" msgstr "" +#: table_view.cpp:47 msgid "Change table dimensions" msgstr "" +#: text_view.cpp:40 msgid "&Bold" msgstr "" +#: text_view.cpp:41 +msgid "Ctrl+B" +msgstr "" + +#: text_view.cpp:44 msgid "&Italic" msgstr "" +#: text_view.cpp:45 +msgid "Ctrl+I" +msgstr "" + +#: text_view.cpp:48 msgid "&Underline" msgstr "" -msgid "Code complete" +#: text_view.cpp:49 +msgid "Ctrl+U" msgstr "" -msgid "exclude the picture" +#: vars_view.cpp:76 +msgid "Code complete" msgstr "" -msgid "latex language: english (frenchb, )" +#: vars_view.cpp:77 +msgid "Ctrl+space" msgstr "" diff -Nru semantik-0.7.3/src/po/fr.po semantik-0.8.3/src/po/fr.po --- semantik-0.7.3/src/po/fr.po 2009-08-30 11:35:33.000000000 +0000 +++ semantik-0.8.3/src/po/fr.po 2012-10-21 10:09:17.000000000 +0000 @@ -1,115 +1,191 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: http://www.google.com\n" -"POT-Creation-Date: 2009-04-26 15:20+0200\n" +"Report-Msgid-Bugs-To: http://code.google.com/p/semantik/issues\n" +"POT-Creation-Date: 2012-10-09 23:25+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -msgid "Empty" -msgstr "Vide" - -msgid "Toggle edit" -msgstr "Bascule l'édition" - -msgid "Insert child" -msgstr "Insérer une branche" +#: browser.cpp:21 canvas_view.cpp:134 +msgid "Toggle fullscreen" +msgstr "Basculer en plein ecran" + +#: canvas_view.cpp:83 +msgid "Add an element" +msgstr "Ajouter un element" +#: canvas_view.cpp:88 fig/box_view.cpp:170 msgid "Delete selection" msgstr "Effacer la sélection" -msgid "Insert sibling" -msgstr "Insérer un frère" +#: canvas_view.cpp:93 +msgid "Insert a sibling" +msgstr "Inserer un frere" +#: canvas_view.cpp:98 fig/box_view.cpp:180 msgid "Move up" msgstr "Déplacer vers le haut" +#: canvas_view.cpp:99 fig/box_view.cpp:185 msgid "Move down" msgstr "Déplacer vers le bas" +#: canvas_view.cpp:100 msgid "Move left" msgstr "Déplacer vers la gauche" +#: canvas_view.cpp:101 msgid "Move right" msgstr "Déplacer vers la droite" +#: canvas_view.cpp:103 msgid "Select up" msgstr "Sélectionner au dessus" +#: canvas_view.cpp:104 msgid "Select down" -msgstr "Sélectionner en bas" +msgstr "Sélectionner en dessous" +#: canvas_view.cpp:105 msgid "Select left" msgstr "Sélectionner à gauche" +#: canvas_view.cpp:106 msgid "Select right" msgstr "Sélectionner à droite" +#: canvas_view.cpp:109 +#, fuzzy +msgid "Select subtree" +msgstr "Sélectionner au dessus" + +#: canvas_view.cpp:114 msgid "Next root" msgstr "Racine suivante" +#: canvas_view.cpp:117 +msgid "Toggle edit" +msgstr "Bascule l'édition" + +#: canvas_view.cpp:122 +msgid "Cancel edit" +msgstr "" + +#: canvas_view.cpp:138 msgid "Colors" msgstr "Couleurs" +#: canvas_view.cpp:139 msgid "Data type" msgstr "Type de donnée" +#: canvas_view.cpp:148 msgid "Text" msgstr "Texte" +#: canvas_view.cpp:149 msgid "Diagram" msgstr "Diagramme" +#: canvas_view.cpp:150 msgid "Table" msgstr "Table" +#: canvas_view.cpp:151 msgid "Image" msgstr "Image" -msgid "Flag" -msgstr "Drapeau" +#: canvas_view.cpp:224 canvas_view.cpp:276 canvas_view.cpp:288 +#: data_item.cpp:27 +msgid "Empty" +msgstr "Vide" +#: canvas_view.cpp:573 msgid "Color" msgstr "Couleur" -#, kde-format +#: canvas_view.cpp:623 +msgid "Flag" +msgstr "Drapeau" + +#: canvas_view.cpp:940 msgid "Click to set Item %1" msgstr "Cliquer pour mettre en place l'item %1" +#: canvas_view.cpp:1250 +msgid "*.png|PNG Files (*.png)" +msgstr "" + +#: canvas_view.cpp:1288 +msgid "No destination file selected" +msgstr "" + +#: canvas_view.cpp:1323 +#, fuzzy +msgid "Exported '%1'" +msgstr "'%1' Sauvegardé" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Could not save to %1" +msgstr "Cliquer pour mettre en place l'item %1" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Missing picture" +msgstr "Changer l'image" + +#: config_dialog.cpp:29 +#, fuzzy +msgid "Document settings" +msgstr "titre du document" + +#: config_dialog.cpp:37 msgid "Reorganization type" msgstr "Type de réorganisation" +#: config_dialog.cpp:41 msgid "Connection type" msgstr "Type de connexion" +#: config_dialog.cpp:45 msgid "Save document automatically" msgstr "Sauvegarder automatiquement" +#: config_dialog.cpp:49 msgid "Background color" msgstr "Couleur de fond" +#: config_dialog.cpp:54 msgid "Fixed" msgstr "Fixe" +#: config_dialog.cpp:54 msgid "Force-based" msgstr "Equilibre de forces" +#: config_dialog.cpp:54 msgid "Incremental" msgstr "Incrémental" +#: config_dialog.cpp:58 msgid "Lines" msgstr "Lignes" +#: config_dialog.cpp:58 msgid "Splines" msgstr "Courbes" +#: config_dialog.cpp:62 msgid " min" msgstr " min" +#: config_dialog.cpp:65 msgid "" "Interval in minutes for saving the document automatically, 0 for disabling " "this feature" @@ -117,257 +193,432 @@ "Intervalle en minutes pour la sauvegarde automatique de documents, 0 pour " "désactiver cette fonctionnalité" -#, kde-format -msgid "Automatic save failed for file: %1" -msgstr "La sauvegarde automatique a échoué pour le fichier: %1" - -#, kde-format -msgid "%1 saved automatically" -msgstr "%1 sauvegardé automatiquement" - -#, kde-format -msgid "Color %1" -msgstr "Couleur %1" - -#, kde-format -msgid "File saving: missing file %1" -msgstr "Sauvegarde de fichier: le fichier %1 est absent" - -msgid "Missing bindings for opening files" -msgstr "Support Python absent: ouverture de fichier impossible" - -#, kde-format -msgid "Missing filter file %1 for opening files" -msgstr "Le filtre %1 pour l'ouverture de fichiers est manquant" - -msgid "dirty" -msgstr "" - -#, kde-format -msgid "Code generation failed: missing file %1" -msgstr "La génération de code a échoué: le fichier %1 est absent" - +#: data_view.cpp:17 msgid "

    No item selected

    " msgstr "

    Aucune sélection

    " +#: doc_dialog.cpp:30 msgid "First Name" msgstr "Prénom" +#: doc_dialog.cpp:34 generator_dialog.cpp:56 msgid "Name" msgstr "Nom" +#: doc_dialog.cpp:38 msgid "Organization" msgstr "Entreprise" +#: doc_dialog.cpp:42 msgid "Email" msgstr "Email" -msgid "Add Box" -msgstr "Ajouter un élément" +#: export_map_dialog.cpp:31 +#, fuzzy +msgid "Export the map" +msgstr "Carte vide" + +#: export_map_dialog.cpp:37 +msgid "File to write" +msgstr "" +#: export_map_dialog.cpp:43 +msgid "Width" +msgstr "" + +#: export_map_dialog.cpp:51 #, fuzzy -msgid "Delete" -msgstr "&Sélectionner" +msgid "Height" +msgstr "Déplacer vers la droite" -msgid "Color..." -msgstr "Couleur..." +#: fig/box_fork.cpp:334 fig/box_item.cpp:133 +msgid "%1 x %2" +msgstr "" + +#: fig/box_item.cpp:189 +msgid "Properties for diagram box" +msgstr "" + +#: fig/box_item.cpp:190 +#, fuzzy +msgid "Text:" +msgstr "Texte" -msgid "Connection width" -msgstr "Largeur de connexion" +#: fig/box_link_properties.cpp:21 +msgid "Link properties" +msgstr "" -msgid "1px" -msgstr "1px" +#: fig/box_link_properties.cpp:29 +msgid "Thickness" +msgstr "" + +#: fig/box_link_properties.cpp:33 +msgid "Line Style" +msgstr "" -msgid "2px" -msgstr "2px" +#: fig/box_link_properties.cpp:37 +msgid "Left arrow" +msgstr "" -msgid "3px" -msgstr "3px" +#: fig/box_link_properties.cpp:41 +msgid "Right arrow" +msgstr "" -msgid "Connection style" -msgstr "Style de connexion" +#: fig/box_link_properties.cpp:51 +msgid "Invisible line" +msgstr "" -msgid "solid line" +#: fig/box_link_properties.cpp:52 +#, fuzzy +msgid "Solid Line" msgstr "ligne" -msgid "dot line" -msgstr "pointillés" +#: fig/box_link_properties.cpp:53 +#, fuzzy +msgid "Dot Line" +msgstr "Lignes" -msgid "dash line" +#: fig/box_link_properties.cpp:54 +#, fuzzy +msgid "Dash Line" msgstr "ligne brisée" -msgid "Flag item(s) as..." -msgstr "Marquer l'objet comme..." +#: fig/box_link_properties.cpp:58 fig/box_link_properties.cpp:63 +msgid "No arrow" +msgstr "" -msgid "exclude the table" -msgstr "exclure la table" +#: fig/box_link_properties.cpp:59 fig/box_link_properties.cpp:64 +msgid "Triangle" +msgstr "" -msgid "fit the item on one slide" +#: fig/box_view.cpp:83 +msgid "box_item" msgstr "" -msgid "picture caption" -msgstr "légende pour l'image" +#: fig/box_view.cpp:85 +msgid "id" +msgstr "" -msgid "picture dimension in pdf files" -msgstr "dimension de l'image dans les fichiers pdf" +#: fig/box_view.cpp:90 fig/box_view.cpp:100 +msgid "c1" +msgstr "" -msgid "html div style: style=\"width: 99px;\"" -msgstr "html div style: style=\"width: 99px;\"" +#: fig/box_view.cpp:91 fig/box_view.cpp:102 +msgid "c2" +msgstr "" -msgid "html picture style: style=\"width: 99px;\"" -msgstr "html picture style: style=\"width: 99px;\"" +#: fig/box_view.cpp:92 +msgid "text" +msgstr "" -msgid "do not use this item for generating slides" -msgstr "ne pas utiliser cet objet pour la génération de slides" +#: fig/box_view.cpp:93 +#, fuzzy +msgid "col" +msgstr "&Parcourir la carte" -#, c-format -msgid "command to launch (%s is the resulting file)" -msgstr "commande à lancer (%s représente le fichier généré)" +#: fig/box_view.cpp:96 fig/box_view.cpp:132 +msgid "box_link" +msgstr "" -#, c-format -msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" -msgstr "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#: fig/box_view.cpp:99 +msgid "p1" +msgstr "" -#, c-format -msgid "firefox %s" -msgstr "firefox %s" +#: fig/box_view.cpp:101 +msgid "p2" +msgstr "" -#, c-format -msgid "ooimpress %s" -msgstr "ooimpress %s" +#: fig/box_view.cpp:114 +msgid "sl" +msgstr "" -#, c-format -msgid "oowriter %s" -msgstr "oowriter %s" +#: fig/box_view.cpp:115 +msgid "wl" +msgstr "" -msgid "document author" -msgstr "auteur du document" +#: fig/box_view.cpp:119 +msgid "box_link_offset" +msgstr "" -msgid "turn off the document author (latex)" -msgstr "masquer l'auteur du document (latex)" +#: fig/box_view.cpp:123 +msgid "x" +msgstr "" -msgid "document class (latex: a4, report, book)" -msgstr "classe du document (latex: a4, report, book)" +#: fig/box_view.cpp:123 +msgid "y" +msgstr "" -msgid "company" -msgstr "entreprise" +#: fig/box_view.cpp:160 +msgid "Properties..." +msgstr "" -msgid "document date" -msgstr "date du docment" +#: fig/box_view.cpp:165 +msgid "Activity" +msgstr "" -msgid "turn of the document date (latex)" -msgstr "masquer la date du document (latex)" +#: fig/box_view.cpp:166 +msgid "Ctrl+Return" +msgstr "" -msgid "location of the presentation" -msgstr "répertoire de la présentation" +#: fig/box_view.cpp:171 +#, fuzzy +msgid "Delete" +msgstr "&Sélectionner" -msgid "document title" -msgstr "titre du document" +#: fig/box_view.cpp:175 +msgid "Color..." +msgstr "Couleur..." + +#: fig/box_view.cpp:181 +msgid "PgUp" +msgstr "" + +#: fig/box_view.cpp:186 +msgid "PgDown" +msgstr "" + +#: fig/box_view.cpp:190 +msgid "Floating text" +msgstr "" + +#: fig/box_view.cpp:192 +msgid "Component" +msgstr "" + +#: fig/box_view.cpp:194 +msgid "Node" +msgstr "" + +#: fig/box_view.cpp:196 +msgid "Activity start" +msgstr "" + +#: fig/box_view.cpp:198 +msgid "Activity end" +msgstr "" + +#: fig/box_view.cpp:200 +msgid "Horizontal fork/join" +msgstr "" + +#: fig/box_view.cpp:202 +msgid "Vertical fork/join" +msgstr "" -msgid "turn off the document title (latex)" -msgstr "masquer le titre du document" +#: fig/box_view.cpp:204 +msgid "Actor" +msgstr "" -msgid "footer center (pdflatex)" -msgstr "pied de page au centre (pdflatex)" +#: fig/box_view.cpp:206 +msgid "Usecase" +msgstr "" -msgid "footer left (pdflatex)" -msgstr "pied de page gauche (pdflatex)" +#: fig/box_view.cpp:215 +msgid "More elements" +msgstr "" -msgid "turn off the fancy output" -msgstr "ne pas utiliser la sortie 'fancy' (latex)" +#: fig/box_view.cpp:247 +msgid "Alignment" +msgstr "" -msgid "footer right" -msgstr "pied de page à droite" +#: fig/box_view.cpp:249 +msgid "Align left" +msgstr "" -msgid "header center (pdflatex)" -msgstr "En-tête central (pdflatex)" +#: fig/box_view.cpp:250 +msgid "Align center" +msgstr "" -msgid "header left" -msgstr "En-tête à gauche" +#: fig/box_view.cpp:251 +#, fuzzy +msgid "Align right" +msgstr "Sélectionner à droite" -msgid "header right" -msgstr "En-tête à droite" +#: fig/box_view.cpp:253 +msgid "Align top" +msgstr "" -msgid "openoffice.org language (fr_FR)" -msgstr "langage pour openoffice.org (fr_FR)" +#: fig/box_view.cpp:254 +msgid "Align middle" +msgstr "" -msgid "openoffice.org presentation language" -msgstr "langage pour la prsentation openoffice.org" +#: fig/box_view.cpp:255 +msgid "Align bottom" +msgstr "" -msgid "openoffice.org text language" -msgstr "langage pour le document text openoffice.org" +#: fig/box_view.cpp:258 +msgid "Size" +msgstr "" -msgid "Warsaw (JuanLesPins, Montpellier, )" +#: fig/box_view.cpp:260 +msgid "Same width" msgstr "" -msgid "Generator dialog" -msgstr "Dialogue de génération de documents" +#: fig/box_view.cpp:261 +#, fuzzy +msgid "Same height" +msgstr "Sélectionner à droite" + +#: fig/box_view.cpp:262 +msgid "Same width and height" +msgstr "" + +#: flag_scheme.cpp:14 +msgid "Flag item(s) as..." +msgstr "Marquer l'objet comme..." +#: generator_dialog.cpp:30 +#, fuzzy +msgid "Generate documents" +msgstr "Générateurs" + +#: generator_dialog.cpp:36 msgid "Generators" msgstr "Générateurs" +#: generator_dialog.cpp:39 msgid "Description" msgstr "Description" +#: generator_dialog.cpp:63 msgid "Location" msgstr "Lieu" -msgid "&Ok" -msgstr "" - -msgid "&Cancel" -msgstr "" - +#: generator_dialog.cpp:114 msgid "No document generator chosen." msgstr "Aucun générateur de document sélectionné" +#: generator_dialog.cpp:114 msgid "Missing data" msgstr "Données manquantes" -#, kde-format +#: generator_dialog.cpp:120 msgid "Invalid output directory %1" msgstr "Répertoire de sortie %1 invalide" +#: generator_dialog.cpp:120 msgid "Missing location" msgstr "Lieu manquant" +#: image_view.cpp:36 msgid "Change picture" msgstr "Changer l'image" +#: image_view.cpp:40 msgid "Clear picture" msgstr "Effacer l'image" +#: image_view.cpp:65 msgid "Click to set a picture" msgstr "Cliquer pour mettre une image" +#: image_view.cpp:69 msgid "Select an item on the map" msgstr "Sélectionner un objet sur la carte" -msgid "Choose a file" +#: image_view.cpp:165 +#, fuzzy +msgid "*.png *.jpg *.jpeg *.gif|Image Files (*.png *.jpg *.jpeg *.gif)" +msgstr "Images (*.png *.jpg *.jpeg *.gif)" + +#: image_view.cpp:166 +#, fuzzy +msgid "Choose a picture" msgstr "Choisir un fichier" -msgid "Image files (*.png *.jpg *.jpeg *.gif)" -msgstr "Images (*.png *.jpg *.jpeg *.gif)" +#: image_view.cpp:178 +#, fuzzy +msgid "Could not load the picture" +msgstr "Cliquer pour mettre une image" + +#: main.cpp:25 +msgid "" +"A mind-mapping tool for KDE\n" +"Available exclusively for open systems such as OpenSuse, Gentoo or Fedora." +msgstr "" + +#: main.cpp:41 +msgid "A file to open on startup" +msgstr "" + +#: main.cpp:43 +msgid "Semantik" +msgstr "Semantik" + +#: main.cpp:44 +msgid "(C) 2007-2012 Thomas Nagy" +msgstr "" + +#: main.cpp:47 +msgid "Thomas Nagy" +msgstr "" + +#. i18n: file: data/semantikui.rc:5 +#. i18n: ectx: Menu (file) +#: po/rc.cpp:3 rc.cpp:3 +msgid "&File" +msgstr "" + +#. i18n: file: data/semantikui.rc:7 +#. i18n: ectx: Menu (edit) +#: po/rc.cpp:6 rc.cpp:6 +msgid "&Edit" +msgstr "" + +#. i18n: file: data/semantikui.rc:12 +#. i18n: ectx: Menu (view) +#: po/rc.cpp:9 rc.cpp:9 +msgid "&View" +msgstr "" + +#. i18n: file: data/semantikui.rc:20 +#. i18n: ectx: Menu (tools) +#: po/rc.cpp:12 rc.cpp:12 +msgid "&Tools" +msgstr "" + +#. i18n: file: data/semantikui.rc:23 +#. i18n: ectx: Menu (settings) +#: po/rc.cpp:15 rc.cpp:15 +msgid "&Settings" +msgstr "" + +#. i18n: file: data/semantikui.rc:26 +#. i18n: ectx: Menu (help) +#: po/rc.cpp:18 rc.cpp:18 +msgid "&Help" +msgstr "" -#, kde-format -msgid "File %1 does not exist" -msgstr "Le fichier %1 n'existe pas" - -#, kde-format -msgid "File %1 could not be opened" -msgstr "Le fichier %1 ne peut être ouvert" +#. i18n: file: data/semantikui.rc:40 +#. i18n: ectx: ToolBar (colorsToolBar) +#: po/rc.cpp:21 rc.cpp:21 +#, fuzzy +msgid "Colors Toolbar" +msgstr "Couleurs" -msgid "something bad happened" -msgstr "quelquechose de mal s'est produit" +#. i18n: file: data/semantikui.rc:44 +#. i18n: ectx: ToolBar (flagsToolBar) +#: po/rc.cpp:24 rc.cpp:24 +msgid "Flags Toolbar" +msgstr "" + +#: po/rc.cpp:25 rc.cpp:25 +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "" -msgid "something worse happened" -msgstr "quelquechose de pire s'est produit" +#: po/rc.cpp:26 rc.cpp:26 +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "" +#: pre_view.cpp:23 #, fuzzy msgid "

    No preview available
    at this time

    " msgstr "" "

    Aucune prévisualisation
    disponible pour le moment

    " +#: semantik.cpp:45 msgid "" "The map is empty, Semantik\n" "cannot create documents from it" @@ -375,138 +626,394 @@ "La carte est vide, Semantik\n" "ne peut pas générer de documents" +#: semantik.cpp:45 msgid "Empty map" msgstr "Carte vide" -#, kde-format +#: semantik.cpp:52 msgid "Template folder %1 is not readable" msgstr "Le répertoire des modèles %1 n'est pas disponible" +#: semantik.cpp:166 msgid "&Reorganize the map" msgstr "&Réorganiser la carte" -msgid "&Generate..." -msgstr "&Générer..." +#: semantik.cpp:168 +msgid "Ctrl+R" +msgstr "" -msgid "&Select" -msgstr "&Sélectionner" +#: semantik.cpp:171 +msgid "&Export the map..." +msgstr "" -msgid "&Link" -msgstr "&Lier" +#: semantik.cpp:173 +msgid "Ctrl+Shift+E" +msgstr "" -msgid "&Sort" -msgstr "&Trier" +#: semantik.cpp:178 +msgid "&Generate..." +msgstr "&Générer..." -msgid "&Scroll" -msgstr "&Parcourir la carte" +#: semantik.cpp:181 +msgid "Ctrl+G" +msgstr "" +#: semantik.cpp:187 msgid "CustomColor" msgstr "" +#: semantik.cpp:201 +msgid "Ctrl+H" +msgstr "" + +#: semantik.cpp:210 msgid "Data" msgstr "Données" +#: semantik.cpp:233 msgid "Variables" msgstr "Variables" +#: semantik.cpp:242 msgid "Preview" msgstr "Prévisualisation" +#: semantik.cpp:254 msgid "Linear view" msgstr "Représentation linaire" +#: semantik.cpp:347 msgid "Welcome to Semantik" msgstr "Bienvenue Semantik" +#: semantik.cpp:393 msgid "Ready" msgstr "Prêt" +#: semantik.cpp:400 msgid "*.sem|Semantik file (*.sem)" msgstr "*.sem|Fichier Semantik (*.sem)" +#: semantik.cpp:401 semantik.cpp:463 msgid "Choose a file name" msgstr "Choisir un nom de fichier" -#, kde-format +#: semantik.cpp:414 +msgid "" +"The file \"%1\" already exists.\n" +"Overwrite it?" +msgstr "" + +#: semantik.cpp:415 +msgid "Overwrite existing file" +msgstr "" + +#: semantik.cpp:426 semantik.cpp:448 msgid "Saved '%1'" msgstr "'%1' Sauvegardé" +#: semantik.cpp:462 msgid "*.sem *.kdi *.mm *.vym|All Supported Files (*.sem *.kdi *.mm *.vym)" msgstr "" "*.sem *.kdi *.mm *.vym|Tous les fichiers supports (*.sem *.kdi *.mm *.vym)" -msgid "Semantik" +#: semantik.cpp:474 +msgid " [Modified] " +msgstr "" + +#: semantik.cpp:479 +#, fuzzy +msgid "Semantik %1" msgstr "Semantik" -#, kde-format -msgid "%1 - Semantik" +#: semantik.cpp:483 +#, fuzzy +msgid "%1 %2 - Semantik" msgstr "%1 - Semantik" +#: semantik.cpp:530 msgid "Untitled" msgstr "" -#, kde-format +#: semantik.cpp:533 msgid "" "The document \"%1\" has been modified.\n" "Do you want to save your changes or discard them?" msgstr "" +#: semantik.cpp:534 msgid "Close Document" msgstr "" +#: sem_mediator.cpp:270 +msgid "Automatic save failed for file: %1" +msgstr "La sauvegarde automatique a échoué pour le fichier: %1" + +#: sem_mediator.cpp:273 +msgid "%1 saved automatically" +msgstr "%1 sauvegardé automatiquement" + +#: sem_mediator.cpp:292 +msgid "Color %1" +msgstr "Couleur %1" + +#: sem_mediator.cpp:618 +msgid "File saving: missing file %1" +msgstr "Sauvegarde de fichier: le fichier %1 est absent" + +#: sem_mediator.cpp:643 sem_mediator.cpp:1142 sem_mediator.cpp:1185 +msgid "Missing bindings for opening files" +msgstr "Support Python absent: ouverture de fichier impossible" + +#: sem_mediator.cpp:694 +msgid "Missing filter file %1 for opening files" +msgstr "Le filtre %1 pour l'ouverture de fichiers est manquant" + +#: sem_mediator.cpp:694 sem_mediator.cpp:709 +msgid "Broken installation" +msgstr "" + +#: sem_mediator.cpp:709 +#, fuzzy +msgid "Missing python bindings for opening files" +msgstr "Support Python absent: ouverture de fichier impossible" + +#: sem_mediator.cpp:725 +msgid "Could not load the document %1" +msgstr "" + +#: sem_mediator.cpp:725 +msgid "Broken document" +msgstr "" + +#: sem_mediator.cpp:1108 +msgid "Code generation failed: missing file %1" +msgstr "La génération de code a échoué: le fichier %1 est absent" + +#: sem_mediator.cpp:1147 +msgid "Document generation completed successfully" +msgstr "" + +#: table_dialog.cpp:32 msgid "Rows" msgstr "Lignes" +#: table_dialog.cpp:36 msgid "Columns" msgstr "Colonnes" +#: table_view.cpp:25 table_view.cpp:79 msgid "Add Row" msgstr "Ajouter une ligne" +#: table_view.cpp:26 msgid "Add a row" msgstr "Ajoute une ligne" +#: table_view.cpp:30 table_view.cpp:80 msgid "Add Column" msgstr "Ajouter une colonne" +#: table_view.cpp:31 msgid "Add a column" msgstr "Ajoute une colonne" +#: table_view.cpp:36 table_view.cpp:81 msgid "Remove Row" msgstr "Enlever une ligne" +#: table_view.cpp:37 msgid "Remove a row" msgstr "Enlève une ligne" +#: table_view.cpp:41 table_view.cpp:82 msgid "Remove Column" msgstr "Enlever une colonne" +#: table_view.cpp:42 msgid "Remove a column" msgstr "Enlève une colonne" +#: table_view.cpp:46 msgid "Redimension" msgstr "Redimensionner" +#: table_view.cpp:47 msgid "Change table dimensions" msgstr "Changer les dimensions de la table" +#: text_view.cpp:40 msgid "&Bold" msgstr "" +#: text_view.cpp:41 +msgid "Ctrl+B" +msgstr "" + +#: text_view.cpp:44 msgid "&Italic" msgstr "" +#: text_view.cpp:45 +msgid "Ctrl+I" +msgstr "" + +#: text_view.cpp:48 msgid "&Underline" msgstr "" +#: text_view.cpp:49 +msgid "Ctrl+U" +msgstr "" + +#: vars_view.cpp:76 msgid "Code complete" msgstr "" -msgid "exclude the picture" -msgstr "exclure l'image" +#: vars_view.cpp:77 +msgid "Ctrl+space" +msgstr "" + +#~ msgid "Insert child" +#~ msgstr "Insérer une branche" + +#~ msgid "Add Box" +#~ msgstr "Ajouter un élément" + +#~ msgid "Connection width" +#~ msgstr "Largeur de connexion" + +#~ msgid "1px" +#~ msgstr "1px" + +#~ msgid "2px" +#~ msgstr "2px" + +#~ msgid "3px" +#~ msgstr "3px" + +#~ msgid "Connection style" +#~ msgstr "Style de connexion" + +#~ msgid "dot line" +#~ msgstr "pointillés" + +#~ msgid "exclude the table" +#~ msgstr "exclure la table" + +#~ msgid "picture caption" +#~ msgstr "légende pour l'image" + +#~ msgid "picture dimension in pdf files" +#~ msgstr "dimension de l'image dans les fichiers pdf" + +#~ msgid "html div style: style=\"width: 99px;\"" +#~ msgstr "html div style: style=\"width: 99px;\"" + +#~ msgid "html picture style: style=\"width: 99px;\"" +#~ msgstr "html picture style: style=\"width: 99px;\"" + +#~ msgid "do not use this item for generating slides" +#~ msgstr "ne pas utiliser cet objet pour la génération de slides" + +#~ msgid "command to launch (%s is the resulting file)" +#~ msgstr "commande à lancer (%s représente le fichier généré)" + +#~ msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#~ msgstr "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" + +#~ msgid "firefox %s" +#~ msgstr "firefox %s" + +#~ msgid "ooimpress %s" +#~ msgstr "ooimpress %s" + +#~ msgid "oowriter %s" +#~ msgstr "oowriter %s" + +#~ msgid "document author" +#~ msgstr "auteur du document" + +#~ msgid "turn off the document author (latex)" +#~ msgstr "masquer l'auteur du document (latex)" + +#~ msgid "document class (latex: a4, report, book)" +#~ msgstr "classe du document (latex: a4, report, book)" + +#~ msgid "company" +#~ msgstr "entreprise" + +#~ msgid "document date" +#~ msgstr "date du docment" + +#~ msgid "turn of the document date (latex)" +#~ msgstr "masquer la date du document (latex)" + +#~ msgid "location of the presentation" +#~ msgstr "répertoire de la présentation" + +#~ msgid "turn off the document title (latex)" +#~ msgstr "masquer le titre du document" + +#~ msgid "footer center (pdflatex)" +#~ msgstr "pied de page au centre (pdflatex)" + +#~ msgid "footer left (pdflatex)" +#~ msgstr "pied de page gauche (pdflatex)" + +#~ msgid "turn off the fancy output" +#~ msgstr "ne pas utiliser la sortie 'fancy' (latex)" + +#~ msgid "footer right" +#~ msgstr "pied de page à droite" + +#~ msgid "header center (pdflatex)" +#~ msgstr "En-tête central (pdflatex)" + +#~ msgid "header left" +#~ msgstr "En-tête à gauche" + +#~ msgid "header right" +#~ msgstr "En-tête à droite" + +#~ msgid "openoffice.org language (fr_FR)" +#~ msgstr "langage pour openoffice.org (fr_FR)" + +#~ msgid "openoffice.org presentation language" +#~ msgstr "langage pour la prsentation openoffice.org" + +#~ msgid "openoffice.org text language" +#~ msgstr "langage pour le document text openoffice.org" + +#~ msgid "Generator dialog" +#~ msgstr "Dialogue de génération de documents" + +#~ msgid "File %1 does not exist" +#~ msgstr "Le fichier %1 n'existe pas" + +#~ msgid "File %1 could not be opened" +#~ msgstr "Le fichier %1 ne peut être ouvert" + +#~ msgid "something bad happened" +#~ msgstr "une erreur s'est produite" + +#~ msgid "something worse happened" +#~ msgstr "une grave erreur s'est produite" + +#~ msgid "&Select" +#~ msgstr "&Sélectionner" + +#~ msgid "&Link" +#~ msgstr "&Lier" + +#~ msgid "&Sort" +#~ msgstr "&Trier" + +#~ msgid "exclude the picture" +#~ msgstr "exclure l'image" -msgid "latex language: english (frenchb, )" -msgstr "langage pour latex: english (frenchb, )" +#~ msgid "latex language: english (frenchb, )" +#~ msgstr "langage pour latex: english (frenchb, )" #~ msgid "Code generation failed: missing bindings" #~ msgstr "La génération a échoué: le support Python est manquant" diff -Nru semantik-0.7.3/src/po/messages.sh semantik-0.8.3/src/po/messages.sh --- semantik-0.7.3/src/po/messages.sh 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/po/messages.sh 2012-10-21 10:09:17.000000000 +0000 @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +BASEDIR="../" # root of translatable sources +PROJECT="semantik" # project name +BUGADDR="http://code.google.com/p/semantik/issues" # MSGID-Bugs +WDIR=`pwd` # working dir + +echo "Preparing rc files" +cd ${BASEDIR} + +# we use simple sorting to make sure the lines do not jump around too much from system to system +find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list +xargs --arg-file=${WDIR}/rcfiles.list extractrc > ${WDIR}/rc.cpp +# additional string for KAboutData +echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> ${WDIR}/rc.cpp +echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> ${WDIR}/rc.cpp +cd ${WDIR} +echo "Done preparing rc files" + +echo "Extracting messages" +cd ${BASEDIR} +# see above on sorting +find . -name '*.cpp' -o -name '*.h' -o -name '*.c' | sort > ${WDIR}/infiles.list +echo "rc.cpp" >> ${WDIR}/infiles.list +cd ${WDIR} +xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \ + -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -ktrUtf8 -kki18np:1,2 -kki18ncp:1c,2,3 \ + --msgid-bugs-address="${BUGADDR}" \ + --files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${PROJECT}.pot || { echo "error while calling xgettext. aborting."; exit 1; } +echo "Done extracting messages" + +echo "Merging translations" +catalogs=`find . -name '*.po'` +for cat in $catalogs; do + echo $cat + msgmerge -o $cat.new $cat ${PROJECT}.pot + mv $cat.new $cat +done +echo "Done merging translations" +echo "Cleaning up" +cd ${WDIR} +rm rcfiles.list +rm infiles.list +rm rc.cpp +echo "Done" + diff -Nru semantik-0.7.3/src/po/ru.po semantik-0.8.3/src/po/ru.po --- semantik-0.7.3/src/po/ru.po 2009-08-30 11:35:33.000000000 +0000 +++ semantik-0.8.3/src/po/ru.po 2012-10-21 10:09:17.000000000 +0000 @@ -1,119 +1,200 @@ # Алексей, 2009. +# Алексей Кузнецов Alexey.Kouznetsov gmail.com, 2011. +# Alexey D. Kouznetsov Alexey.Kouznetsov gmail.com, 2011. msgid "" msgstr "" "Project-Id-Version: \n" -"Report-Msgid-Bugs-To: http://bugzilla.kde.org\n" -"POT-Creation-Date: 2009-04-26 15:20+0200\n" -"PO-Revision-Date: 2009-08-11 17:50+0400\n" -"Last-Translator: Алексей Кузнецов\n" +"Report-Msgid-Bugs-To: http://code.google.com/p/semantik/issues\n" +"POT-Creation-Date: 2012-10-09 23:25+0200\n" +"PO-Revision-Date: 2011-05-10 00:58+0400\n" +"Last-Translator: Alexey D. Kouznetsov Alexey.Kouznetsov gmail.com\n" "Language-Team: Russian \n" +"Language: ru\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.0\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " -"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" -msgid "Empty" -msgstr "Пусто" - -msgid "Toggle edit" -msgstr "Правка" +#: browser.cpp:21 canvas_view.cpp:134 +msgid "Toggle fullscreen" +msgstr "" -msgid "Insert child" -msgstr "Вставить потомка" +#: canvas_view.cpp:83 +#, fuzzy +msgid "Add an element" +msgstr "Вставлен столбец" +#: canvas_view.cpp:88 fig/box_view.cpp:170 msgid "Delete selection" msgstr "Удалить выбранное" -msgid "Insert sibling" +#: canvas_view.cpp:93 +#, fuzzy +msgid "Insert a sibling" msgstr "Добавить равнозначный элемент" +#: canvas_view.cpp:98 fig/box_view.cpp:180 msgid "Move up" msgstr "Поднять" +#: canvas_view.cpp:99 fig/box_view.cpp:185 msgid "Move down" msgstr "Опустить" +#: canvas_view.cpp:100 msgid "Move left" msgstr "Сдвинуть влево" +#: canvas_view.cpp:101 msgid "Move right" msgstr "Сдвинуть вправо" +#: canvas_view.cpp:103 msgid "Select up" -msgstr "" +msgstr "Перейти выше" +#: canvas_view.cpp:104 msgid "Select down" -msgstr "" +msgstr "Перейти ниже" +#: canvas_view.cpp:105 msgid "Select left" -msgstr "" +msgstr "Перейти влево" +#: canvas_view.cpp:106 msgid "Select right" -msgstr "" +msgstr "Перейти вправо" + +#: canvas_view.cpp:109 +#, fuzzy +msgid "Select subtree" +msgstr "Перейти выше" +#: canvas_view.cpp:114 msgid "Next root" msgstr "Следующий корень" +#: canvas_view.cpp:117 +msgid "Toggle edit" +msgstr "Правка" + +#: canvas_view.cpp:122 +#, fuzzy +msgid "Cancel edit" +msgstr "&Отменить" + +#: canvas_view.cpp:138 msgid "Colors" msgstr "Цвета" +#: canvas_view.cpp:139 msgid "Data type" msgstr "Тип данных" +#: canvas_view.cpp:148 msgid "Text" msgstr "Текст" +#: canvas_view.cpp:149 msgid "Diagram" msgstr "Диаграмма" +#: canvas_view.cpp:150 msgid "Table" msgstr "Таблица" +#: canvas_view.cpp:151 msgid "Image" msgstr "Картинка" -msgid "Flag" -msgstr "Флаг" +#: canvas_view.cpp:224 canvas_view.cpp:276 canvas_view.cpp:288 +#: data_item.cpp:27 +msgid "Empty" +msgstr "Пусто" +#: canvas_view.cpp:573 msgid "Color" msgstr "Цвет" -#, kde-format +#: canvas_view.cpp:623 +msgid "Flag" +msgstr "Флаг" + +#: canvas_view.cpp:940 msgid "Click to set Item %1" msgstr "Нажмите, чтобы установить объект %1" +#: canvas_view.cpp:1250 +msgid "*.png|PNG Files (*.png)" +msgstr "" + +#: canvas_view.cpp:1288 +msgid "No destination file selected" +msgstr "" + +#: canvas_view.cpp:1323 +#, fuzzy +msgid "Exported '%1'" +msgstr "«%1» сохранён" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Could not save to %1" +msgstr "Нажмите, чтобы установить объект %1" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Missing picture" +msgstr "Изменить картинку" + +#: config_dialog.cpp:29 +#, fuzzy +msgid "Document settings" +msgstr "Заголовок документа" + +#: config_dialog.cpp:37 msgid "Reorganization type" msgstr "Вид группировки" +#: config_dialog.cpp:41 msgid "Connection type" msgstr "Вид соединений" +#: config_dialog.cpp:45 msgid "Save document automatically" msgstr "Сохранять автоматически" +#: config_dialog.cpp:49 msgid "Background color" msgstr "Цвет фона" +#: config_dialog.cpp:54 msgid "Fixed" msgstr "" +#: config_dialog.cpp:54 msgid "Force-based" msgstr "" +#: config_dialog.cpp:54 msgid "Incremental" msgstr "" +#: config_dialog.cpp:58 msgid "Lines" msgstr "Отрезки" +#: config_dialog.cpp:58 msgid "Splines" msgstr "Кривые" +#: config_dialog.cpp:62 msgid " min" msgstr " мин" +#: config_dialog.cpp:65 msgid "" "Interval in minutes for saving the document automatically, 0 for disabling " "this feature" @@ -121,255 +202,429 @@ "Период автоматического сохранения документа в минутах,\n" "«0» отключает автосохранение." -#, kde-format -msgid "Automatic save failed for file: %1" -msgstr "Не удалось сохранить автоматически файл «%1»" - -#, kde-format -msgid "%1 saved automatically" -msgstr "«%1» автоматически сохранён." - -#, kde-format -msgid "Color %1" -msgstr "Цвет %1" - -#, kde-format -msgid "File saving: missing file %1" -msgstr "Сохранение файла: файл «%1» не существует" - -msgid "Missing bindings for opening files" -msgstr "Не могу открыть файл: ошибка поддержки Python" - -#, kde-format -msgid "Missing filter file %1 for opening files" -msgstr "Не найден файл фильтра «%1» для открытия файлов" - -msgid "dirty" -msgstr "черновик" - -#, kde-format -msgid "Code generation failed: missing file %1" -msgstr "Не удалось генерировать код: нет файла «%1»" - +#: data_view.cpp:17 msgid "

    No item selected

    " msgstr "

    Ничего не выбрано

    " +#: doc_dialog.cpp:30 msgid "First Name" msgstr "Имя" +#: doc_dialog.cpp:34 generator_dialog.cpp:56 msgid "Name" msgstr "Фамилия" +#: doc_dialog.cpp:38 msgid "Organization" msgstr "Учреждение" +#: doc_dialog.cpp:42 msgid "Email" msgstr "Эл. почта" -msgid "Add Box" -msgstr "Добавить элемент" +#: export_map_dialog.cpp:31 +#, fuzzy +msgid "Export the map" +msgstr "Пустой план" -msgid "Delete" -msgstr "Удалить" +#: export_map_dialog.cpp:37 +msgid "File to write" +msgstr "" -msgid "Color..." -msgstr "Цвет..." +#: export_map_dialog.cpp:43 +msgid "Width" +msgstr "" + +#: export_map_dialog.cpp:51 +#, fuzzy +msgid "Height" +msgstr "Сдвинуть вправо" + +#: fig/box_fork.cpp:334 fig/box_item.cpp:133 +msgid "%1 x %2" +msgstr "" + +#: fig/box_item.cpp:189 +msgid "Properties for diagram box" +msgstr "" -msgid "Connection width" -msgstr "Толщина соед. линии" +#: fig/box_item.cpp:190 +#, fuzzy +msgid "Text:" +msgstr "Текст" -msgid "1px" +#: fig/box_link_properties.cpp:21 +msgid "Link properties" msgstr "" -msgid "2px" +#: fig/box_link_properties.cpp:29 +msgid "Thickness" msgstr "" -msgid "3px" +#: fig/box_link_properties.cpp:33 +msgid "Line Style" msgstr "" -msgid "Connection style" -msgstr "Тип соединений" +#: fig/box_link_properties.cpp:37 +msgid "Left arrow" +msgstr "" -msgid "solid line" +#: fig/box_link_properties.cpp:41 +msgid "Right arrow" +msgstr "" + +#: fig/box_link_properties.cpp:51 +msgid "Invisible line" +msgstr "" + +#: fig/box_link_properties.cpp:52 +#, fuzzy +msgid "Solid Line" msgstr "сплошная линия" -msgid "dot line" -msgstr "пунктир" +#: fig/box_link_properties.cpp:53 +#, fuzzy +msgid "Dot Line" +msgstr "Отрезки" -msgid "dash line" +#: fig/box_link_properties.cpp:54 +#, fuzzy +msgid "Dash Line" msgstr "штриховая линия" -msgid "Flag item(s) as..." -msgstr "Пометить элемент(ы) как..." +#: fig/box_link_properties.cpp:58 fig/box_link_properties.cpp:63 +msgid "No arrow" +msgstr "" -msgid "exclude the table" -msgstr "исключить таблицу" +#: fig/box_link_properties.cpp:59 fig/box_link_properties.cpp:64 +msgid "Triangle" +msgstr "" -msgid "fit the item on one slide" -msgstr "Закрепить элементы на одном слайде" +#: fig/box_view.cpp:83 +msgid "box_item" +msgstr "" -msgid "picture caption" -msgstr "Захват картинки" +#: fig/box_view.cpp:85 +msgid "id" +msgstr "" -msgid "picture dimension in pdf files" -msgstr "Размеры картинки в файлах PDF" +#: fig/box_view.cpp:90 fig/box_view.cpp:100 +msgid "c1" +msgstr "" -msgid "html div style: style=\"width: 99px;\"" -msgstr "html div style: style=\"width: 99px;\"" +#: fig/box_view.cpp:91 fig/box_view.cpp:102 +msgid "c2" +msgstr "" -msgid "html picture style: style=\"width: 99px;\"" -msgstr "html picture style: style=\"width: 99px;\"" +#: fig/box_view.cpp:92 +msgid "text" +msgstr "" -msgid "do not use this item for generating slides" -msgstr "Не использовать этот элемент при создании слайда" +#: fig/box_view.cpp:93 +#, fuzzy +msgid "col" +msgstr "&Прокрутка" -#, c-format -msgid "command to launch (%s is the resulting file)" -msgstr "Выполняемая команда («%s» - имя целевого файла)" +#: fig/box_view.cpp:96 fig/box_view.cpp:132 +msgid "box_link" +msgstr "" -#, c-format -msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" -msgstr "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#: fig/box_view.cpp:99 +msgid "p1" +msgstr "" -#, c-format -msgid "firefox %s" -msgstr "firefox %s" +#: fig/box_view.cpp:101 +msgid "p2" +msgstr "" -# In Russia we generally use OO.o build from the Infra-resource (http://i-rs.ru) which uses "openoffice.org3 -impress" syntax -#, c-format -msgid "ooimpress %s" -msgstr "openoffice.org3 -impress %s" +#: fig/box_view.cpp:114 +msgid "sl" +msgstr "" -#, c-format -msgid "oowriter %s" -msgstr "openoffice.org3 -writer %s" +#: fig/box_view.cpp:115 +msgid "wl" +msgstr "" -msgid "document author" -msgstr "Автор документа" +#: fig/box_view.cpp:119 +msgid "box_link_offset" +msgstr "" -msgid "turn off the document author (latex)" -msgstr "Скрыть автора документа (LaTeX)" +#: fig/box_view.cpp:123 +msgid "x" +msgstr "" -msgid "document class (latex: a4, report, book)" -msgstr "Класс документа (latex: a4, report, book)" +#: fig/box_view.cpp:123 +msgid "y" +msgstr "" -msgid "company" -msgstr "Учреждение" +#: fig/box_view.cpp:160 +msgid "Properties..." +msgstr "" -msgid "document date" -msgstr "Дата документа" +#: fig/box_view.cpp:165 +msgid "Activity" +msgstr "" -msgid "turn of the document date (latex)" -msgstr "Скрыть дату (LaTeX)" +#: fig/box_view.cpp:166 +msgid "Ctrl+Return" +msgstr "" -msgid "location of the presentation" -msgstr "Расположение презентации" +#: fig/box_view.cpp:171 +msgid "Delete" +msgstr "Удалить" -msgid "document title" -msgstr "Заголовок документа" +#: fig/box_view.cpp:175 +msgid "Color..." +msgstr "Цвет..." -msgid "turn off the document title (latex)" -msgstr "Скрыть заголовок (LaTeX)" +#: fig/box_view.cpp:181 +msgid "PgUp" +msgstr "" -msgid "footer center (pdflatex)" -msgstr "Нижний колонтитул, по центру" +#: fig/box_view.cpp:186 +msgid "PgDown" +msgstr "" -msgid "footer left (pdflatex)" -msgstr "Нижний колонтитул, слева" +#: fig/box_view.cpp:190 +msgid "Floating text" +msgstr "" -msgid "turn off the fancy output" -msgstr "не использовать \"украшенный\" вывод (latex)" +#: fig/box_view.cpp:192 +msgid "Component" +msgstr "" + +#: fig/box_view.cpp:194 +msgid "Node" +msgstr "" + +#: fig/box_view.cpp:196 +msgid "Activity start" +msgstr "" + +#: fig/box_view.cpp:198 +msgid "Activity end" +msgstr "" -msgid "footer right" -msgstr "Нижний колонтитул, справа" +#: fig/box_view.cpp:200 +msgid "Horizontal fork/join" +msgstr "" -msgid "header center (pdflatex)" -msgstr "Верхний колонтитул, по центру" +#: fig/box_view.cpp:202 +msgid "Vertical fork/join" +msgstr "" -msgid "header left" -msgstr "Верхний колонтитул, слева" +#: fig/box_view.cpp:204 +msgid "Actor" +msgstr "" -msgid "header right" -msgstr "Верхний колонтитул, справа" +#: fig/box_view.cpp:206 +msgid "Usecase" +msgstr "" -msgid "openoffice.org language (fr_FR)" -msgstr "язык для openoffice.org (ru_RU)" +#: fig/box_view.cpp:215 +msgid "More elements" +msgstr "" -msgid "openoffice.org presentation language" -msgstr "Язык для презентации openoffice.org" +#: fig/box_view.cpp:247 +msgid "Alignment" +msgstr "" -msgid "openoffice.org text language" -msgstr "Язык для текстового документа openoffice.org" +#: fig/box_view.cpp:249 +msgid "Align left" +msgstr "" -msgid "Warsaw (JuanLesPins, Montpellier, )" +#: fig/box_view.cpp:250 +msgid "Align center" msgstr "" -msgid "Generator dialog" -msgstr "Диалог создания документа" +#: fig/box_view.cpp:251 +#, fuzzy +msgid "Align right" +msgstr "Перейти вправо" + +#: fig/box_view.cpp:253 +msgid "Align top" +msgstr "" +#: fig/box_view.cpp:254 +msgid "Align middle" +msgstr "" + +#: fig/box_view.cpp:255 +msgid "Align bottom" +msgstr "" + +#: fig/box_view.cpp:258 +msgid "Size" +msgstr "" + +#: fig/box_view.cpp:260 +msgid "Same width" +msgstr "" + +#: fig/box_view.cpp:261 +#, fuzzy +msgid "Same height" +msgstr "Перейти вправо" + +#: fig/box_view.cpp:262 +msgid "Same width and height" +msgstr "" + +#: flag_scheme.cpp:14 +msgid "Flag item(s) as..." +msgstr "Пометить элемент(ы) как..." + +#: generator_dialog.cpp:30 +#, fuzzy +msgid "Generate documents" +msgstr "Генераторы" + +#: generator_dialog.cpp:36 msgid "Generators" msgstr "Генераторы" +#: generator_dialog.cpp:39 msgid "Description" msgstr "Описание" +#: generator_dialog.cpp:63 msgid "Location" msgstr "Расположение" -msgid "&Ok" -msgstr "&Угу" - -msgid "&Cancel" -msgstr "&Отменить" - +#: generator_dialog.cpp:114 msgid "No document generator chosen." msgstr "Не выбран генератор документа." +#: generator_dialog.cpp:114 msgid "Missing data" msgstr "Нет данных" -#, kde-format +#: generator_dialog.cpp:120 msgid "Invalid output directory %1" msgstr "Неверный целевой каталог «%1»" +#: generator_dialog.cpp:120 msgid "Missing location" msgstr "Не указано расположение" +#: image_view.cpp:36 msgid "Change picture" msgstr "Изменить картинку" +#: image_view.cpp:40 msgid "Clear picture" msgstr "Убрать картинку" +#: image_view.cpp:65 msgid "Click to set a picture" msgstr "Нажмите, чтобы задать картинку" +#: image_view.cpp:69 msgid "Select an item on the map" msgstr "Выбрать объект на плане" -msgid "Choose a file" +#: image_view.cpp:165 +#, fuzzy +msgid "*.png *.jpg *.jpeg *.gif|Image Files (*.png *.jpg *.jpeg *.gif)" +msgstr "Файлы изображений (*.png *.jpg *.jpeg *.gif)" + +#: image_view.cpp:166 +#, fuzzy +msgid "Choose a picture" msgstr "Выбор файла" -msgid "Image files (*.png *.jpg *.jpeg *.gif)" -msgstr "Файлы изображений (*.png *.jpg *.jpeg *.gif)" +#: image_view.cpp:178 +#, fuzzy +msgid "Could not load the picture" +msgstr "Нажмите, чтобы задать картинку" + +#: main.cpp:25 +msgid "" +"A mind-mapping tool for KDE\n" +"Available exclusively for open systems such as OpenSuse, Gentoo or Fedora." +msgstr "" + +#: main.cpp:41 +msgid "A file to open on startup" +msgstr "" + +#: main.cpp:43 +msgid "Semantik" +msgstr "Semantik" + +#: main.cpp:44 +msgid "(C) 2007-2012 Thomas Nagy" +msgstr "" + +#: main.cpp:47 +msgid "Thomas Nagy" +msgstr "" -#, kde-format -msgid "File %1 does not exist" -msgstr "Файл «%1» не существует" - -#, kde-format -msgid "File %1 could not be opened" -msgstr "Файл «%1» не может быть открыт" +#. i18n: file: data/semantikui.rc:5 +#. i18n: ectx: Menu (file) +#: po/rc.cpp:3 rc.cpp:3 +msgid "&File" +msgstr "" + +#. i18n: file: data/semantikui.rc:7 +#. i18n: ectx: Menu (edit) +#: po/rc.cpp:6 rc.cpp:6 +msgid "&Edit" +msgstr "" + +#. i18n: file: data/semantikui.rc:12 +#. i18n: ectx: Menu (view) +#: po/rc.cpp:9 rc.cpp:9 +msgid "&View" +msgstr "" + +#. i18n: file: data/semantikui.rc:20 +#. i18n: ectx: Menu (tools) +#: po/rc.cpp:12 rc.cpp:12 +msgid "&Tools" +msgstr "" + +#. i18n: file: data/semantikui.rc:23 +#. i18n: ectx: Menu (settings) +#: po/rc.cpp:15 rc.cpp:15 +msgid "&Settings" +msgstr "" -msgid "something bad happened" -msgstr "случилось нечто плохое" +#. i18n: file: data/semantikui.rc:26 +#. i18n: ectx: Menu (help) +#: po/rc.cpp:18 rc.cpp:18 +msgid "&Help" +msgstr "" -msgid "something worse happened" -msgstr "случилось нечто страшное" +#. i18n: file: data/semantikui.rc:40 +#. i18n: ectx: ToolBar (colorsToolBar) +#: po/rc.cpp:21 rc.cpp:21 +#, fuzzy +msgid "Colors Toolbar" +msgstr "Цвета" +#. i18n: file: data/semantikui.rc:44 +#. i18n: ectx: ToolBar (flagsToolBar) +#: po/rc.cpp:24 rc.cpp:24 +msgid "Flags Toolbar" +msgstr "" + +#: po/rc.cpp:25 rc.cpp:25 +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "" + +#: po/rc.cpp:26 rc.cpp:26 +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "" + +#: pre_view.cpp:23 msgid "

    No preview available
    at this time

    " msgstr "

    В настоящее время
    предпросмотр недоступен

    " +#: semantik.cpp:45 msgid "" "The map is empty, Semantik\n" "cannot create documents from it" @@ -377,78 +632,116 @@ "План пуст; Semantik\n" "не может создать документ." +#: semantik.cpp:45 msgid "Empty map" msgstr "Пустой план" -#, kde-format +#: semantik.cpp:52 msgid "Template folder %1 is not readable" msgstr "Каталог с шаблонами («%1») недоступен для чтения" +#: semantik.cpp:166 msgid "&Reorganize the map" msgstr "&Перегруппировать" -msgid "&Generate..." -msgstr "&Создать..." +#: semantik.cpp:168 +msgid "Ctrl+R" +msgstr "" -msgid "&Select" -msgstr "&Выбрать" +#: semantik.cpp:171 +msgid "&Export the map..." +msgstr "" -msgid "&Link" -msgstr "&Ссылка" +#: semantik.cpp:173 +msgid "Ctrl+Shift+E" +msgstr "" -msgid "&Sort" -msgstr "&Упорядочить" +#: semantik.cpp:178 +msgid "&Generate..." +msgstr "&Создать..." -msgid "&Scroll" -msgstr "&Прокрутка" +#: semantik.cpp:181 +msgid "Ctrl+G" +msgstr "" +#: semantik.cpp:187 msgid "CustomColor" msgstr "Другой цвет" +#: semantik.cpp:201 +msgid "Ctrl+H" +msgstr "" + +#: semantik.cpp:210 msgid "Data" msgstr "Данные" +#: semantik.cpp:233 msgid "Variables" msgstr "Переменные" +#: semantik.cpp:242 msgid "Preview" msgstr "Предв. просмотр" +#: semantik.cpp:254 msgid "Linear view" msgstr "Структура" +#: semantik.cpp:347 msgid "Welcome to Semantik" msgstr "Добро пожаловать в Semantik" +#: semantik.cpp:393 msgid "Ready" msgstr "Готово" +#: semantik.cpp:400 msgid "*.sem|Semantik file (*.sem)" msgstr "*.sem|Файлы Semantik (*.sem)" +#: semantik.cpp:401 semantik.cpp:463 msgid "Choose a file name" msgstr "Укажите имя файла" -#, kde-format +#: semantik.cpp:414 +msgid "" +"The file \"%1\" already exists.\n" +"Overwrite it?" +msgstr "" + +#: semantik.cpp:415 +msgid "Overwrite existing file" +msgstr "" + +#: semantik.cpp:426 semantik.cpp:448 msgid "Saved '%1'" msgstr "«%1» сохранён" +#: semantik.cpp:462 msgid "*.sem *.kdi *.mm *.vym|All Supported Files (*.sem *.kdi *.mm *.vym)" msgstr "" -"*.sem *.kdi *.mm *.vym|Файлы поддерживаемых форматов (*.sem *.kdi *.mm *." -"vym)" +"*.sem *.kdi *.mm *.vym|Файлы поддерживаемых форматов (*.sem *.kdi *.mm *.vym)" -msgid "Semantik" +#: semantik.cpp:474 +msgid " [Modified] " +msgstr "" + +#: semantik.cpp:479 +#, fuzzy +msgid "Semantik %1" msgstr "Semantik" -#, kde-format -msgid "%1 - Semantik" +#: semantik.cpp:483 +#, fuzzy +msgid "%1 %2 - Semantik" msgstr "%1 - Semantik" +#: semantik.cpp:530 msgid "Untitled" msgstr "Неназванный" -#, kde-format +#: semantik.cpp:533 msgid "" "The document \"%1\" has been modified.\n" "Do you want to save your changes or discard them?" @@ -456,62 +749,296 @@ "Документ «%1» изменён. \n" "Сохранить изменения или отклонить их?" +#: semantik.cpp:534 msgid "Close Document" msgstr "Закрыть документ" +#: sem_mediator.cpp:270 +msgid "Automatic save failed for file: %1" +msgstr "Не удалось сохранить автоматически файл «%1»" + +#: sem_mediator.cpp:273 +msgid "%1 saved automatically" +msgstr "«%1» автоматически сохранён." + +#: sem_mediator.cpp:292 +msgid "Color %1" +msgstr "Цвет %1" + +#: sem_mediator.cpp:618 +msgid "File saving: missing file %1" +msgstr "Сохранение файла: файл «%1» не существует" + +#: sem_mediator.cpp:643 sem_mediator.cpp:1142 sem_mediator.cpp:1185 +msgid "Missing bindings for opening files" +msgstr "Не могу открыть файл: ошибка поддержки Python" + +#: sem_mediator.cpp:694 +msgid "Missing filter file %1 for opening files" +msgstr "Не найден файл фильтра «%1» для открытия файлов" + +#: sem_mediator.cpp:694 sem_mediator.cpp:709 +msgid "Broken installation" +msgstr "" + +#: sem_mediator.cpp:709 +#, fuzzy +msgid "Missing python bindings for opening files" +msgstr "Не могу открыть файл: ошибка поддержки Python" + +#: sem_mediator.cpp:725 +msgid "Could not load the document %1" +msgstr "" + +#: sem_mediator.cpp:725 +#, fuzzy +msgid "Broken document" +msgstr "Закрыть документ" + +#: sem_mediator.cpp:1108 +msgid "Code generation failed: missing file %1" +msgstr "Не удалось генерировать код: нет файла «%1»" + +#: sem_mediator.cpp:1147 +msgid "Document generation completed successfully" +msgstr "" + +#: table_dialog.cpp:32 msgid "Rows" msgstr "Строки" +#: table_dialog.cpp:36 msgid "Columns" msgstr "Столбцы" +#: table_view.cpp:25 table_view.cpp:79 msgid "Add Row" msgstr "Добавить строку" +#: table_view.cpp:26 msgid "Add a row" msgstr "Вставлена строка" +#: table_view.cpp:30 table_view.cpp:80 msgid "Add Column" msgstr "Добавить столбец" +#: table_view.cpp:31 msgid "Add a column" msgstr "Вставлен столбец" +#: table_view.cpp:36 table_view.cpp:81 msgid "Remove Row" msgstr "Удалить строку" +#: table_view.cpp:37 msgid "Remove a row" msgstr "Строка удалена" +#: table_view.cpp:41 table_view.cpp:82 msgid "Remove Column" msgstr "Удалить столбец" +#: table_view.cpp:42 msgid "Remove a column" msgstr "Столбец удалён" +#: table_view.cpp:46 msgid "Redimension" msgstr "Указать размер таблицы" +#: table_view.cpp:47 msgid "Change table dimensions" msgstr "Изменение размеров таблицы" +#: text_view.cpp:40 msgid "&Bold" msgstr "Полу&жирный" +#: text_view.cpp:41 +msgid "Ctrl+B" +msgstr "" + +#: text_view.cpp:44 msgid "&Italic" msgstr "&Курсив" +#: text_view.cpp:45 +msgid "Ctrl+I" +msgstr "" + +#: text_view.cpp:48 msgid "&Underline" msgstr "&Подчёркнутый" +#: text_view.cpp:49 +msgid "Ctrl+U" +msgstr "" + +#: vars_view.cpp:76 msgid "Code complete" +msgstr "Код готов" + +#: vars_view.cpp:77 +msgid "Ctrl+space" msgstr "" -msgid "exclude the picture" -msgstr "исключить изображение" +#~ msgid "Insert child" +#~ msgstr "Вставить потомка" + +#~ msgid "dirty" +#~ msgstr "черновик" + +#~ msgid "Add Box" +#~ msgstr "Добавить элемент" + +#~ msgid "Connection width" +#~ msgstr "Толщина соед. линии" + +# Не нашёл стандартного сокращения для пикселя, пока что "п." +#, fuzzy +#~ msgid "1px" +#~ msgstr "1 п." + +# Не нашёл стандартного сокращения для пикселя, пока что "п." +#, fuzzy +#~ msgid "2px" +#~ msgstr "2 п." + +# Не нашёл стандартного сокращения для пикселя, пока что "п." +#, fuzzy +#~ msgid "3px" +#~ msgstr "3 п." + +#~ msgid "Connection style" +#~ msgstr "Тип соединений" + +#~ msgid "dot line" +#~ msgstr "пунктир" + +#~ msgid "exclude the table" +#~ msgstr "исключить таблицу" + +#~ msgid "fit the item on one slide" +#~ msgstr "Закрепить элементы на одном слайде" + +#~ msgid "picture caption" +#~ msgstr "Захват картинки" + +#~ msgid "picture dimension in pdf files" +#~ msgstr "Размеры картинки в файлах PDF" + +#~ msgid "html div style: style=\"width: 99px;\"" +#~ msgstr "html div style: style=\"width: 99px;\"" + +#~ msgid "html picture style: style=\"width: 99px;\"" +#~ msgstr "html picture style: style=\"width: 99px;\"" + +#~ msgid "do not use this item for generating slides" +#~ msgstr "Не использовать этот элемент при создании слайда" + +#~ msgid "command to launch (%s is the resulting file)" +#~ msgstr "Выполняемая команда («%s» - имя целевого файла)" + +#~ msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#~ msgstr "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" + +#~ msgid "firefox %s" +#~ msgstr "firefox %s" + +# In Russia we generally use OO.o build from the Infra-resource (http://i-rs.ru) which uses "openoffice.org3 -impress" syntax +#~ msgid "ooimpress %s" +#~ msgstr "openoffice.org3 -impress %s" + +#~ msgid "oowriter %s" +#~ msgstr "openoffice.org3 -writer %s" + +#~ msgid "document author" +#~ msgstr "Автор документа" + +#~ msgid "turn off the document author (latex)" +#~ msgstr "Скрыть автора документа (LaTeX)" + +#~ msgid "document class (latex: a4, report, book)" +#~ msgstr "Класс документа (latex: a4, report, book)" + +#~ msgid "company" +#~ msgstr "Учреждение" + +#~ msgid "document date" +#~ msgstr "Дата документа" + +#~ msgid "turn of the document date (latex)" +#~ msgstr "Скрыть дату (LaTeX)" + +#~ msgid "location of the presentation" +#~ msgstr "Расположение презентации" + +#~ msgid "turn off the document title (latex)" +#~ msgstr "Скрыть заголовок (LaTeX)" + +#~ msgid "footer center (pdflatex)" +#~ msgstr "Нижний колонтитул, по центру" + +#~ msgid "footer left (pdflatex)" +#~ msgstr "Нижний колонтитул, слева" + +#~ msgid "turn off the fancy output" +#~ msgstr "не использовать \"украшенный\" вывод (latex)" + +#~ msgid "footer right" +#~ msgstr "Нижний колонтитул, справа" + +#~ msgid "header center (pdflatex)" +#~ msgstr "Верхний колонтитул, по центру" + +#~ msgid "header left" +#~ msgstr "Верхний колонтитул, слева" + +#~ msgid "header right" +#~ msgstr "Верхний колонтитул, справа" + +#~ msgid "openoffice.org language (fr_FR)" +#~ msgstr "язык для openoffice.org (ru_RU)" + +#~ msgid "openoffice.org presentation language" +#~ msgstr "Язык для презентации openoffice.org" + +#~ msgid "openoffice.org text language" +#~ msgstr "Язык для текстового документа openoffice.org" + +#~ msgid "Generator dialog" +#~ msgstr "Диалог создания документа" + +#~ msgid "&Ok" +#~ msgstr "&Угу" + +#~ msgid "File %1 does not exist" +#~ msgstr "Файл «%1» не существует" + +#~ msgid "File %1 could not be opened" +#~ msgstr "Файл «%1» не может быть открыт" + +#~ msgid "something bad happened" +#~ msgstr "случилось нечто плохое" + +#~ msgid "something worse happened" +#~ msgstr "случилось нечто страшное" + +#~ msgid "&Select" +#~ msgstr "&Выбрать" + +#~ msgid "&Link" +#~ msgstr "&Ссылка" + +#~ msgid "&Sort" +#~ msgstr "&Упорядочить" + +#~ msgid "exclude the picture" +#~ msgstr "исключить изображение" -msgid "latex language: english (frenchb, )" -msgstr "langage pour latex: english (frenchb, )" +#~ msgid "latex language: english (frenchb, )" +#~ msgstr "langage pour latex: english (frenchb, )" #~ msgid "Code generation failed: missing bindings" #~ msgstr "La génération a échoué: le support Python est manquant" diff -Nru semantik-0.7.3/src/po/semantik.pot semantik-0.8.3/src/po/semantik.pot --- semantik-0.7.3/src/po/semantik.pot 2009-08-30 11:35:33.000000000 +0000 +++ semantik-0.8.3/src/po/semantik.pot 2012-10-21 10:09:17.000000000 +0000 @@ -1,506 +1,851 @@ # SOME DESCRIPTIVE TITLE. -# This file is put in the public domain. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: http://www.google.com\n" -"POT-Creation-Date: 2009-04-26 15:50+0200\n" +"Report-Msgid-Bugs-To: http://code.google.com/p/semantik/issues\n" +"POT-Creation-Date: 2012-10-09 23:25+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" +"Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -msgid "Empty" +#: browser.cpp:21 canvas_view.cpp:134 +msgid "Toggle fullscreen" msgstr "" -msgid "Toggle edit" -msgstr "" - -msgid "Insert child" +#: canvas_view.cpp:83 +msgid "Add an element" msgstr "" +#: canvas_view.cpp:88 fig/box_view.cpp:170 msgid "Delete selection" msgstr "" -msgid "Insert sibling" +#: canvas_view.cpp:93 +msgid "Insert a sibling" msgstr "" +#: canvas_view.cpp:98 fig/box_view.cpp:180 msgid "Move up" msgstr "" +#: canvas_view.cpp:99 fig/box_view.cpp:185 msgid "Move down" msgstr "" +#: canvas_view.cpp:100 msgid "Move left" msgstr "" +#: canvas_view.cpp:101 msgid "Move right" msgstr "" +#: canvas_view.cpp:103 msgid "Select up" msgstr "" +#: canvas_view.cpp:104 msgid "Select down" msgstr "" +#: canvas_view.cpp:105 msgid "Select left" msgstr "" +#: canvas_view.cpp:106 msgid "Select right" msgstr "" +#: canvas_view.cpp:109 +msgid "Select subtree" +msgstr "" + +#: canvas_view.cpp:114 msgid "Next root" msgstr "" +#: canvas_view.cpp:117 +msgid "Toggle edit" +msgstr "" + +#: canvas_view.cpp:122 +msgid "Cancel edit" +msgstr "" + +#: canvas_view.cpp:138 msgid "Colors" msgstr "" +#: canvas_view.cpp:139 msgid "Data type" msgstr "" +#: canvas_view.cpp:148 msgid "Text" msgstr "" +#: canvas_view.cpp:149 msgid "Diagram" msgstr "" +#: canvas_view.cpp:150 msgid "Table" msgstr "" +#: canvas_view.cpp:151 msgid "Image" msgstr "" -msgid "Flag" +#: canvas_view.cpp:224 canvas_view.cpp:276 canvas_view.cpp:288 +#: data_item.cpp:27 +msgid "Empty" msgstr "" +#: canvas_view.cpp:573 msgid "Color" msgstr "" -#, kde-format +#: canvas_view.cpp:623 +msgid "Flag" +msgstr "" + +#: canvas_view.cpp:940 msgid "Click to set Item %1" msgstr "" +#: canvas_view.cpp:1250 +msgid "*.png|PNG Files (*.png)" +msgstr "" + +#: canvas_view.cpp:1288 +msgid "No destination file selected" +msgstr "" + +#: canvas_view.cpp:1323 +msgid "Exported '%1'" +msgstr "" + +#: canvas_view.cpp:1325 +msgid "Could not save to %1" +msgstr "" + +#: canvas_view.cpp:1325 +msgid "Missing picture" +msgstr "" + +#: config_dialog.cpp:29 +msgid "Document settings" +msgstr "" + +#: config_dialog.cpp:37 msgid "Reorganization type" msgstr "" +#: config_dialog.cpp:41 msgid "Connection type" msgstr "" +#: config_dialog.cpp:45 msgid "Save document automatically" msgstr "" +#: config_dialog.cpp:49 msgid "Background color" msgstr "" +#: config_dialog.cpp:54 msgid "Fixed" msgstr "" +#: config_dialog.cpp:54 msgid "Force-based" msgstr "" +#: config_dialog.cpp:54 msgid "Incremental" msgstr "" +#: config_dialog.cpp:58 msgid "Lines" msgstr "" +#: config_dialog.cpp:58 msgid "Splines" msgstr "" +#: config_dialog.cpp:62 msgid " min" msgstr "" +#: config_dialog.cpp:65 msgid "" "Interval in minutes for saving the document automatically, 0 for disabling " "this feature" msgstr "" -#, kde-format -msgid "Automatic save failed for file: %1" +#: data_view.cpp:17 +msgid "

    No item selected

    " msgstr "" -#, kde-format -msgid "%1 saved automatically" +#: doc_dialog.cpp:30 +msgid "First Name" msgstr "" -#, kde-format -msgid "Color %1" +#: doc_dialog.cpp:34 generator_dialog.cpp:56 +msgid "Name" msgstr "" -#, kde-format -msgid "File saving: missing file %1" +#: doc_dialog.cpp:38 +msgid "Organization" msgstr "" -msgid "Missing bindings for opening files" +#: doc_dialog.cpp:42 +msgid "Email" msgstr "" -#, kde-format -msgid "Missing filter file %1 for opening files" +#: export_map_dialog.cpp:31 +msgid "Export the map" msgstr "" -msgid "dirty" +#: export_map_dialog.cpp:37 +msgid "File to write" msgstr "" -#, kde-format -msgid "Code generation failed: missing file %1" +#: export_map_dialog.cpp:43 +msgid "Width" msgstr "" -msgid "

    No item selected

    " +#: export_map_dialog.cpp:51 +msgid "Height" msgstr "" -msgid "First Name" +#: fig/box_fork.cpp:334 fig/box_item.cpp:133 +msgid "%1 x %2" msgstr "" -msgid "Name" +#: fig/box_item.cpp:189 +msgid "Properties for diagram box" msgstr "" -msgid "Organization" +#: fig/box_item.cpp:190 +msgid "Text:" msgstr "" -msgid "Email" +#: fig/box_link_properties.cpp:21 +msgid "Link properties" msgstr "" -msgid "Add Box" +#: fig/box_link_properties.cpp:29 +msgid "Thickness" msgstr "" -msgid "Delete" +#: fig/box_link_properties.cpp:33 +msgid "Line Style" msgstr "" -msgid "Color..." +#: fig/box_link_properties.cpp:37 +msgid "Left arrow" msgstr "" -msgid "Connection width" +#: fig/box_link_properties.cpp:41 +msgid "Right arrow" msgstr "" -msgid "1px" +#: fig/box_link_properties.cpp:51 +msgid "Invisible line" msgstr "" -msgid "2px" +#: fig/box_link_properties.cpp:52 +msgid "Solid Line" msgstr "" -msgid "3px" +#: fig/box_link_properties.cpp:53 +msgid "Dot Line" msgstr "" -msgid "Connection style" +#: fig/box_link_properties.cpp:54 +msgid "Dash Line" msgstr "" -msgid "solid line" +#: fig/box_link_properties.cpp:58 fig/box_link_properties.cpp:63 +msgid "No arrow" msgstr "" -msgid "dot line" +#: fig/box_link_properties.cpp:59 fig/box_link_properties.cpp:64 +msgid "Triangle" msgstr "" -msgid "dash line" +#: fig/box_view.cpp:83 +msgid "box_item" msgstr "" -msgid "Flag item(s) as..." +#: fig/box_view.cpp:85 +msgid "id" msgstr "" -msgid "exclude the table" +#: fig/box_view.cpp:90 fig/box_view.cpp:100 +msgid "c1" msgstr "" -msgid "fit the item on one slide" +#: fig/box_view.cpp:91 fig/box_view.cpp:102 +msgid "c2" msgstr "" -msgid "picture caption" +#: fig/box_view.cpp:92 +msgid "text" msgstr "" -msgid "picture dimension in pdf files" +#: fig/box_view.cpp:93 +msgid "col" msgstr "" -msgid "html div style: style=\"width: 99px;\"" +#: fig/box_view.cpp:96 fig/box_view.cpp:132 +msgid "box_link" msgstr "" -msgid "html picture style: style=\"width: 99px;\"" +#: fig/box_view.cpp:99 +msgid "p1" msgstr "" -msgid "do not use this item for generating slides" +#: fig/box_view.cpp:101 +msgid "p2" msgstr "" -#, c-format -msgid "command to launch (%s is the resulting file)" +#: fig/box_view.cpp:114 +msgid "sl" msgstr "" -#, c-format -msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#: fig/box_view.cpp:115 +msgid "wl" msgstr "" -#, c-format -msgid "firefox %s" +#: fig/box_view.cpp:119 +msgid "box_link_offset" msgstr "" -#, c-format -msgid "ooimpress %s" +#: fig/box_view.cpp:123 +msgid "x" msgstr "" -#, c-format -msgid "oowriter %s" +#: fig/box_view.cpp:123 +msgid "y" msgstr "" -msgid "document author" +#: fig/box_view.cpp:160 +msgid "Properties..." msgstr "" -msgid "turn off the document author (latex)" +#: fig/box_view.cpp:165 +msgid "Activity" msgstr "" -msgid "document class (latex: a4, report, book)" +#: fig/box_view.cpp:166 +msgid "Ctrl+Return" msgstr "" -msgid "company" +#: fig/box_view.cpp:171 +msgid "Delete" msgstr "" -msgid "document date" +#: fig/box_view.cpp:175 +msgid "Color..." msgstr "" -msgid "turn of the document date (latex)" +#: fig/box_view.cpp:181 +msgid "PgUp" msgstr "" -msgid "location of the presentation" +#: fig/box_view.cpp:186 +msgid "PgDown" msgstr "" -msgid "document title" +#: fig/box_view.cpp:190 +msgid "Floating text" msgstr "" -msgid "turn off the document title (latex)" +#: fig/box_view.cpp:192 +msgid "Component" msgstr "" -msgid "footer center (pdflatex)" +#: fig/box_view.cpp:194 +msgid "Node" msgstr "" -msgid "footer left (pdflatex)" +#: fig/box_view.cpp:196 +msgid "Activity start" msgstr "" -msgid "turn off the fancy output" +#: fig/box_view.cpp:198 +msgid "Activity end" msgstr "" -msgid "footer right" +#: fig/box_view.cpp:200 +msgid "Horizontal fork/join" msgstr "" -msgid "header center (pdflatex)" +#: fig/box_view.cpp:202 +msgid "Vertical fork/join" msgstr "" -msgid "header left" +#: fig/box_view.cpp:204 +msgid "Actor" msgstr "" -msgid "header right" +#: fig/box_view.cpp:206 +msgid "Usecase" msgstr "" -msgid "openoffice.org language (fr_FR)" +#: fig/box_view.cpp:215 +msgid "More elements" msgstr "" -msgid "openoffice.org presentation language" +#: fig/box_view.cpp:247 +msgid "Alignment" msgstr "" -msgid "openoffice.org text language" +#: fig/box_view.cpp:249 +msgid "Align left" msgstr "" -msgid "Warsaw (JuanLesPins, Montpellier, )" +#: fig/box_view.cpp:250 +msgid "Align center" msgstr "" -msgid "Generator dialog" +#: fig/box_view.cpp:251 +msgid "Align right" msgstr "" -msgid "Generators" +#: fig/box_view.cpp:253 +msgid "Align top" msgstr "" -msgid "Description" +#: fig/box_view.cpp:254 +msgid "Align middle" msgstr "" -msgid "Location" +#: fig/box_view.cpp:255 +msgid "Align bottom" +msgstr "" + +#: fig/box_view.cpp:258 +msgid "Size" msgstr "" -msgid "&Ok" +#: fig/box_view.cpp:260 +msgid "Same width" msgstr "" -msgid "&Cancel" +#: fig/box_view.cpp:261 +msgid "Same height" msgstr "" +#: fig/box_view.cpp:262 +msgid "Same width and height" +msgstr "" + +#: flag_scheme.cpp:14 +msgid "Flag item(s) as..." +msgstr "" + +#: generator_dialog.cpp:30 +msgid "Generate documents" +msgstr "" + +#: generator_dialog.cpp:36 +msgid "Generators" +msgstr "" + +#: generator_dialog.cpp:39 +msgid "Description" +msgstr "" + +#: generator_dialog.cpp:63 +msgid "Location" +msgstr "" + +#: generator_dialog.cpp:114 msgid "No document generator chosen." msgstr "" +#: generator_dialog.cpp:114 msgid "Missing data" msgstr "" -#, kde-format +#: generator_dialog.cpp:120 msgid "Invalid output directory %1" msgstr "" +#: generator_dialog.cpp:120 msgid "Missing location" msgstr "" +#: image_view.cpp:36 msgid "Change picture" msgstr "" +#: image_view.cpp:40 msgid "Clear picture" msgstr "" +#: image_view.cpp:65 msgid "Click to set a picture" msgstr "" +#: image_view.cpp:69 msgid "Select an item on the map" msgstr "" -msgid "Choose a file" +#: image_view.cpp:165 +msgid "*.png *.jpg *.jpeg *.gif|Image Files (*.png *.jpg *.jpeg *.gif)" +msgstr "" + +#: image_view.cpp:166 +msgid "Choose a picture" msgstr "" -msgid "Image files (*.png *.jpg *.jpeg *.gif)" +#: image_view.cpp:178 +msgid "Could not load the picture" msgstr "" -#, kde-format -msgid "File %1 does not exist" +#: main.cpp:25 +msgid "" +"A mind-mapping tool for KDE\n" +"Available exclusively for open systems such as OpenSuse, Gentoo or Fedora." +msgstr "" + +#: main.cpp:41 +msgid "A file to open on startup" +msgstr "" + +#: main.cpp:43 +msgid "Semantik" +msgstr "" + +#: main.cpp:44 +msgid "(C) 2007-2012 Thomas Nagy" +msgstr "" + +#: main.cpp:47 +msgid "Thomas Nagy" msgstr "" -#, kde-format -msgid "File %1 could not be opened" +#. i18n: file: data/semantikui.rc:5 +#. i18n: ectx: Menu (file) +#: po/rc.cpp:3 rc.cpp:3 +msgid "&File" msgstr "" -msgid "something bad happened" +#. i18n: file: data/semantikui.rc:7 +#. i18n: ectx: Menu (edit) +#: po/rc.cpp:6 rc.cpp:6 +msgid "&Edit" msgstr "" -msgid "something worse happened" +#. i18n: file: data/semantikui.rc:12 +#. i18n: ectx: Menu (view) +#: po/rc.cpp:9 rc.cpp:9 +msgid "&View" msgstr "" +#. i18n: file: data/semantikui.rc:20 +#. i18n: ectx: Menu (tools) +#: po/rc.cpp:12 rc.cpp:12 +msgid "&Tools" +msgstr "" + +#. i18n: file: data/semantikui.rc:23 +#. i18n: ectx: Menu (settings) +#: po/rc.cpp:15 rc.cpp:15 +msgid "&Settings" +msgstr "" + +#. i18n: file: data/semantikui.rc:26 +#. i18n: ectx: Menu (help) +#: po/rc.cpp:18 rc.cpp:18 +msgid "&Help" +msgstr "" + +#. i18n: file: data/semantikui.rc:40 +#. i18n: ectx: ToolBar (colorsToolBar) +#: po/rc.cpp:21 rc.cpp:21 +msgid "Colors Toolbar" +msgstr "" + +#. i18n: file: data/semantikui.rc:44 +#. i18n: ectx: ToolBar (flagsToolBar) +#: po/rc.cpp:24 rc.cpp:24 +msgid "Flags Toolbar" +msgstr "" + +#: po/rc.cpp:25 rc.cpp:25 +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "" + +#: po/rc.cpp:26 rc.cpp:26 +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "" + +#: pre_view.cpp:23 msgid "

    No preview available
    at this time

    " msgstr "" +#: semantik.cpp:45 msgid "" "The map is empty, Semantik\n" "cannot create documents from it" msgstr "" +#: semantik.cpp:45 msgid "Empty map" msgstr "" -#, kde-format +#: semantik.cpp:52 msgid "Template folder %1 is not readable" msgstr "" +#: semantik.cpp:166 msgid "&Reorganize the map" msgstr "" -msgid "&Generate..." +#: semantik.cpp:168 +msgid "Ctrl+R" msgstr "" -msgid "&Select" +#: semantik.cpp:171 +msgid "&Export the map..." msgstr "" -msgid "&Link" +#: semantik.cpp:173 +msgid "Ctrl+Shift+E" msgstr "" -msgid "&Sort" +#: semantik.cpp:178 +msgid "&Generate..." msgstr "" -msgid "&Scroll" +#: semantik.cpp:181 +msgid "Ctrl+G" msgstr "" +#: semantik.cpp:187 msgid "CustomColor" msgstr "" +#: semantik.cpp:201 +msgid "Ctrl+H" +msgstr "" + +#: semantik.cpp:210 msgid "Data" msgstr "" +#: semantik.cpp:233 msgid "Variables" msgstr "" +#: semantik.cpp:242 msgid "Preview" msgstr "" +#: semantik.cpp:254 msgid "Linear view" msgstr "" +#: semantik.cpp:347 msgid "Welcome to Semantik" msgstr "" +#: semantik.cpp:393 msgid "Ready" msgstr "" +#: semantik.cpp:400 msgid "*.sem|Semantik file (*.sem)" msgstr "" +#: semantik.cpp:401 semantik.cpp:463 msgid "Choose a file name" msgstr "" -#, kde-format +#: semantik.cpp:414 +msgid "" +"The file \"%1\" already exists.\n" +"Overwrite it?" +msgstr "" + +#: semantik.cpp:415 +msgid "Overwrite existing file" +msgstr "" + +#: semantik.cpp:426 semantik.cpp:448 msgid "Saved '%1'" msgstr "" +#: semantik.cpp:462 msgid "*.sem *.kdi *.mm *.vym|All Supported Files (*.sem *.kdi *.mm *.vym)" msgstr "" -msgid "Semantik" +#: semantik.cpp:474 +msgid " [Modified] " +msgstr "" + +#: semantik.cpp:479 +msgid "Semantik %1" msgstr "" -#, kde-format -msgid "%1 - Semantik" +#: semantik.cpp:483 +msgid "%1 %2 - Semantik" msgstr "" +#: semantik.cpp:530 msgid "Untitled" msgstr "" -#, kde-format +#: semantik.cpp:533 msgid "" "The document \"%1\" has been modified.\n" "Do you want to save your changes or discard them?" msgstr "" +#: semantik.cpp:534 msgid "Close Document" msgstr "" +#: sem_mediator.cpp:270 +msgid "Automatic save failed for file: %1" +msgstr "" + +#: sem_mediator.cpp:273 +msgid "%1 saved automatically" +msgstr "" + +#: sem_mediator.cpp:292 +msgid "Color %1" +msgstr "" + +#: sem_mediator.cpp:618 +msgid "File saving: missing file %1" +msgstr "" + +#: sem_mediator.cpp:643 sem_mediator.cpp:1142 sem_mediator.cpp:1185 +msgid "Missing bindings for opening files" +msgstr "" + +#: sem_mediator.cpp:694 +msgid "Missing filter file %1 for opening files" +msgstr "" + +#: sem_mediator.cpp:694 sem_mediator.cpp:709 +msgid "Broken installation" +msgstr "" + +#: sem_mediator.cpp:709 +msgid "Missing python bindings for opening files" +msgstr "" + +#: sem_mediator.cpp:725 +msgid "Could not load the document %1" +msgstr "" + +#: sem_mediator.cpp:725 +msgid "Broken document" +msgstr "" + +#: sem_mediator.cpp:1108 +msgid "Code generation failed: missing file %1" +msgstr "" + +#: sem_mediator.cpp:1147 +msgid "Document generation completed successfully" +msgstr "" + +#: table_dialog.cpp:32 msgid "Rows" msgstr "" +#: table_dialog.cpp:36 msgid "Columns" msgstr "" +#: table_view.cpp:25 table_view.cpp:79 msgid "Add Row" msgstr "" +#: table_view.cpp:26 msgid "Add a row" msgstr "" +#: table_view.cpp:30 table_view.cpp:80 msgid "Add Column" msgstr "" +#: table_view.cpp:31 msgid "Add a column" msgstr "" +#: table_view.cpp:36 table_view.cpp:81 msgid "Remove Row" msgstr "" +#: table_view.cpp:37 msgid "Remove a row" msgstr "" +#: table_view.cpp:41 table_view.cpp:82 msgid "Remove Column" msgstr "" +#: table_view.cpp:42 msgid "Remove a column" msgstr "" +#: table_view.cpp:46 msgid "Redimension" msgstr "" +#: table_view.cpp:47 msgid "Change table dimensions" msgstr "" +#: text_view.cpp:40 msgid "&Bold" msgstr "" +#: text_view.cpp:41 +msgid "Ctrl+B" +msgstr "" + +#: text_view.cpp:44 msgid "&Italic" msgstr "" +#: text_view.cpp:45 +msgid "Ctrl+I" +msgstr "" + +#: text_view.cpp:48 msgid "&Underline" msgstr "" -msgid "Code complete" +#: text_view.cpp:49 +msgid "Ctrl+U" msgstr "" -msgid "exclude the picture" +#: vars_view.cpp:76 +msgid "Code complete" msgstr "" -msgid "latex language: english (frenchb, )" +#: vars_view.cpp:77 +msgid "Ctrl+space" msgstr "" diff -Nru semantik-0.7.3/src/po/sk.po semantik-0.8.3/src/po/sk.po --- semantik-0.7.3/src/po/sk.po 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/po/sk.po 2012-10-21 10:09:17.000000000 +0000 @@ -0,0 +1,1026 @@ +# Slovak translations for semantik package +# Slovenské preklady pre balík semantik. +msgid "" +msgstr "" +"Project-Id-Version: semantik 0.7.3\n" +"Report-Msgid-Bugs-To: http://code.google.com/p/semantik/issues\n" +"POT-Creation-Date: 2012-10-09 23:25+0200\n" +"PO-Revision-Date: 2010-01-26 18:08+0100\n" +"Last-Translator: Slavko\n" +"Language-Team: Slovenský \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: UTF-8\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +#: browser.cpp:21 canvas_view.cpp:134 +msgid "Toggle fullscreen" +msgstr "" + +#: canvas_view.cpp:83 +#, fuzzy +msgid "Add an element" +msgstr "Pridať stĺpec" + +#: canvas_view.cpp:88 fig/box_view.cpp:170 +msgid "Delete selection" +msgstr "Zmazať výber" + +#: canvas_view.cpp:93 +#, fuzzy +msgid "Insert a sibling" +msgstr "Vložiť súrodenca" + +#: canvas_view.cpp:98 fig/box_view.cpp:180 +msgid "Move up" +msgstr "Posunúť hore" + +#: canvas_view.cpp:99 fig/box_view.cpp:185 +msgid "Move down" +msgstr "Posunúť dole" + +#: canvas_view.cpp:100 +msgid "Move left" +msgstr "Posunúť vľavo" + +#: canvas_view.cpp:101 +msgid "Move right" +msgstr "Posunúť vpravo" + +#: canvas_view.cpp:103 +msgid "Select up" +msgstr "Vybrať hore" + +#: canvas_view.cpp:104 +msgid "Select down" +msgstr "Vybrať dole" + +#: canvas_view.cpp:105 +msgid "Select left" +msgstr "Vybrať vľavo" + +#: canvas_view.cpp:106 +msgid "Select right" +msgstr "Vybrať vpravo" + +#: canvas_view.cpp:109 +#, fuzzy +msgid "Select subtree" +msgstr "Vybrať hore" + +#: canvas_view.cpp:114 +msgid "Next root" +msgstr "Ďalší koreň" + +#: canvas_view.cpp:117 +msgid "Toggle edit" +msgstr "Prepnúť editáciu" + +#: canvas_view.cpp:122 +#, fuzzy +msgid "Cancel edit" +msgstr "&Zrušiť" + +#: canvas_view.cpp:138 +msgid "Colors" +msgstr "Farby" + +#: canvas_view.cpp:139 +msgid "Data type" +msgstr "Typ dát" + +#: canvas_view.cpp:148 +msgid "Text" +msgstr "Text" + +#: canvas_view.cpp:149 +msgid "Diagram" +msgstr "Diagram" + +#: canvas_view.cpp:150 +msgid "Table" +msgstr "Tabuľka" + +#: canvas_view.cpp:151 +msgid "Image" +msgstr "Obrázok" + +#: canvas_view.cpp:224 canvas_view.cpp:276 canvas_view.cpp:288 +#: data_item.cpp:27 +msgid "Empty" +msgstr "Prázdne" + +#: canvas_view.cpp:573 +msgid "Color" +msgstr "Farba" + +#: canvas_view.cpp:623 +msgid "Flag" +msgstr "Značka" + +#: canvas_view.cpp:940 +msgid "Click to set Item %1" +msgstr "Kliknite pre výber položky %1" + +#: canvas_view.cpp:1250 +msgid "*.png|PNG Files (*.png)" +msgstr "" + +#: canvas_view.cpp:1288 +msgid "No destination file selected" +msgstr "" + +#: canvas_view.cpp:1323 +#, fuzzy +msgid "Exported '%1'" +msgstr "Uložené '%1'" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Could not save to %1" +msgstr "Kliknite pre výber položky %1" + +#: canvas_view.cpp:1325 +#, fuzzy +msgid "Missing picture" +msgstr "Zmeniť obrázok" + +#: config_dialog.cpp:29 +#, fuzzy +msgid "Document settings" +msgstr "názov dokumentu" + +#: config_dialog.cpp:37 +msgid "Reorganization type" +msgstr "Typ preusporiadania" + +#: config_dialog.cpp:41 +msgid "Connection type" +msgstr "Typ spojenia" + +#: config_dialog.cpp:45 +msgid "Save document automatically" +msgstr "Ukladať automaticky" + +#: config_dialog.cpp:49 +msgid "Background color" +msgstr "Farba pozadia" + +#: config_dialog.cpp:54 +msgid "Fixed" +msgstr "Pevné" + +#: config_dialog.cpp:54 +msgid "Force-based" +msgstr "" + +#: config_dialog.cpp:54 +msgid "Incremental" +msgstr "Vzostupné" + +#: config_dialog.cpp:58 +msgid "Lines" +msgstr "Čiary" + +#: config_dialog.cpp:58 +msgid "Splines" +msgstr "Krivky" + +#: config_dialog.cpp:62 +msgid " min" +msgstr " min" + +#: config_dialog.cpp:65 +msgid "" +"Interval in minutes for saving the document automatically, 0 for disabling " +"this feature" +msgstr "Interval automatického ukladania dokumentu v minútach, 0 pre vypnutie" + +#: data_view.cpp:17 +msgid "

    No item selected

    " +msgstr "

    Nie je vybratá položka

    " + +#: doc_dialog.cpp:30 +msgid "First Name" +msgstr "Prvé meno" + +#: doc_dialog.cpp:34 generator_dialog.cpp:56 +msgid "Name" +msgstr "Meno" + +#: doc_dialog.cpp:38 +msgid "Organization" +msgstr "Organizácia" + +#: doc_dialog.cpp:42 +msgid "Email" +msgstr "Email" + +#: export_map_dialog.cpp:31 +#, fuzzy +msgid "Export the map" +msgstr "Prázdna mapa" + +#: export_map_dialog.cpp:37 +msgid "File to write" +msgstr "" + +#: export_map_dialog.cpp:43 +msgid "Width" +msgstr "" + +#: export_map_dialog.cpp:51 +#, fuzzy +msgid "Height" +msgstr "Posunúť vpravo" + +#: fig/box_fork.cpp:334 fig/box_item.cpp:133 +msgid "%1 x %2" +msgstr "" + +#: fig/box_item.cpp:189 +msgid "Properties for diagram box" +msgstr "" + +#: fig/box_item.cpp:190 +#, fuzzy +msgid "Text:" +msgstr "Text" + +#: fig/box_link_properties.cpp:21 +msgid "Link properties" +msgstr "" + +#: fig/box_link_properties.cpp:29 +msgid "Thickness" +msgstr "" + +#: fig/box_link_properties.cpp:33 +msgid "Line Style" +msgstr "" + +#: fig/box_link_properties.cpp:37 +msgid "Left arrow" +msgstr "" + +#: fig/box_link_properties.cpp:41 +msgid "Right arrow" +msgstr "" + +#: fig/box_link_properties.cpp:51 +msgid "Invisible line" +msgstr "" + +#: fig/box_link_properties.cpp:52 +#, fuzzy +msgid "Solid Line" +msgstr "plná čiara" + +#: fig/box_link_properties.cpp:53 +#, fuzzy +msgid "Dot Line" +msgstr "Čiary" + +#: fig/box_link_properties.cpp:54 +#, fuzzy +msgid "Dash Line" +msgstr "čiarkovaná čiara" + +#: fig/box_link_properties.cpp:58 fig/box_link_properties.cpp:63 +msgid "No arrow" +msgstr "" + +#: fig/box_link_properties.cpp:59 fig/box_link_properties.cpp:64 +msgid "Triangle" +msgstr "" + +#: fig/box_view.cpp:83 +msgid "box_item" +msgstr "" + +#: fig/box_view.cpp:85 +msgid "id" +msgstr "" + +#: fig/box_view.cpp:90 fig/box_view.cpp:100 +msgid "c1" +msgstr "" + +#: fig/box_view.cpp:91 fig/box_view.cpp:102 +msgid "c2" +msgstr "" + +#: fig/box_view.cpp:92 +msgid "text" +msgstr "" + +#: fig/box_view.cpp:93 +#, fuzzy +msgid "col" +msgstr "&Posunúť" + +#: fig/box_view.cpp:96 fig/box_view.cpp:132 +msgid "box_link" +msgstr "" + +#: fig/box_view.cpp:99 +msgid "p1" +msgstr "" + +#: fig/box_view.cpp:101 +msgid "p2" +msgstr "" + +#: fig/box_view.cpp:114 +msgid "sl" +msgstr "" + +#: fig/box_view.cpp:115 +msgid "wl" +msgstr "" + +#: fig/box_view.cpp:119 +msgid "box_link_offset" +msgstr "" + +#: fig/box_view.cpp:123 +msgid "x" +msgstr "" + +#: fig/box_view.cpp:123 +msgid "y" +msgstr "" + +#: fig/box_view.cpp:160 +msgid "Properties..." +msgstr "" + +#: fig/box_view.cpp:165 +msgid "Activity" +msgstr "" + +#: fig/box_view.cpp:166 +msgid "Ctrl+Return" +msgstr "" + +#: fig/box_view.cpp:171 +msgid "Delete" +msgstr "Zmazať" + +#: fig/box_view.cpp:175 +msgid "Color..." +msgstr "Farba..." + +#: fig/box_view.cpp:181 +msgid "PgUp" +msgstr "" + +#: fig/box_view.cpp:186 +msgid "PgDown" +msgstr "" + +#: fig/box_view.cpp:190 +msgid "Floating text" +msgstr "" + +#: fig/box_view.cpp:192 +msgid "Component" +msgstr "" + +#: fig/box_view.cpp:194 +msgid "Node" +msgstr "" + +#: fig/box_view.cpp:196 +msgid "Activity start" +msgstr "" + +#: fig/box_view.cpp:198 +msgid "Activity end" +msgstr "" + +#: fig/box_view.cpp:200 +msgid "Horizontal fork/join" +msgstr "" + +#: fig/box_view.cpp:202 +msgid "Vertical fork/join" +msgstr "" + +#: fig/box_view.cpp:204 +msgid "Actor" +msgstr "" + +#: fig/box_view.cpp:206 +msgid "Usecase" +msgstr "" + +#: fig/box_view.cpp:215 +msgid "More elements" +msgstr "" + +#: fig/box_view.cpp:247 +msgid "Alignment" +msgstr "" + +#: fig/box_view.cpp:249 +msgid "Align left" +msgstr "" + +#: fig/box_view.cpp:250 +msgid "Align center" +msgstr "" + +#: fig/box_view.cpp:251 +#, fuzzy +msgid "Align right" +msgstr "Vybrať vpravo" + +#: fig/box_view.cpp:253 +msgid "Align top" +msgstr "" + +#: fig/box_view.cpp:254 +msgid "Align middle" +msgstr "" + +#: fig/box_view.cpp:255 +msgid "Align bottom" +msgstr "" + +#: fig/box_view.cpp:258 +msgid "Size" +msgstr "" + +#: fig/box_view.cpp:260 +msgid "Same width" +msgstr "" + +#: fig/box_view.cpp:261 +#, fuzzy +msgid "Same height" +msgstr "Vybrať vpravo" + +#: fig/box_view.cpp:262 +msgid "Same width and height" +msgstr "" + +#: flag_scheme.cpp:14 +msgid "Flag item(s) as..." +msgstr "Označiť položku(y) ako..." + +#: generator_dialog.cpp:30 +#, fuzzy +msgid "Generate documents" +msgstr "Generátoy" + +#: generator_dialog.cpp:36 +msgid "Generators" +msgstr "Generátoy" + +#: generator_dialog.cpp:39 +msgid "Description" +msgstr "Popis" + +#: generator_dialog.cpp:63 +msgid "Location" +msgstr "Umiestnenie" + +#: generator_dialog.cpp:114 +msgid "No document generator chosen." +msgstr "Nie je zvolený generátor dokumentu." + +#: generator_dialog.cpp:114 +msgid "Missing data" +msgstr "Chýbajúce dáta" + +#: generator_dialog.cpp:120 +msgid "Invalid output directory %1" +msgstr "Neplatný výstupný adresár %1" + +#: generator_dialog.cpp:120 +msgid "Missing location" +msgstr "Chýbajúce umiestnenie" + +#: image_view.cpp:36 +msgid "Change picture" +msgstr "Zmeniť obrázok" + +#: image_view.cpp:40 +msgid "Clear picture" +msgstr "Zmazať obrázok" + +#: image_view.cpp:65 +msgid "Click to set a picture" +msgstr "Kliknite pre nastavenie obrázka" + +#: image_view.cpp:69 +msgid "Select an item on the map" +msgstr "Vyberte položku mapy" + +#: image_view.cpp:165 +#, fuzzy +msgid "*.png *.jpg *.jpeg *.gif|Image Files (*.png *.jpg *.jpeg *.gif)" +msgstr "Súbory obrázkov (*.png *.jpg *.jpeg *.gif)" + +#: image_view.cpp:166 +#, fuzzy +msgid "Choose a picture" +msgstr "Vyberte súbor" + +#: image_view.cpp:178 +#, fuzzy +msgid "Could not load the picture" +msgstr "Kliknite pre nastavenie obrázka" + +#: main.cpp:25 +msgid "" +"A mind-mapping tool for KDE\n" +"Available exclusively for open systems such as OpenSuse, Gentoo or Fedora." +msgstr "" + +#: main.cpp:41 +msgid "A file to open on startup" +msgstr "" + +#: main.cpp:43 +msgid "Semantik" +msgstr "Semantik" + +#: main.cpp:44 +msgid "(C) 2007-2012 Thomas Nagy" +msgstr "" + +#: main.cpp:47 +msgid "Thomas Nagy" +msgstr "" + +#. i18n: file: data/semantikui.rc:5 +#. i18n: ectx: Menu (file) +#: po/rc.cpp:3 rc.cpp:3 +msgid "&File" +msgstr "" + +#. i18n: file: data/semantikui.rc:7 +#. i18n: ectx: Menu (edit) +#: po/rc.cpp:6 rc.cpp:6 +msgid "&Edit" +msgstr "" + +#. i18n: file: data/semantikui.rc:12 +#. i18n: ectx: Menu (view) +#: po/rc.cpp:9 rc.cpp:9 +msgid "&View" +msgstr "" + +#. i18n: file: data/semantikui.rc:20 +#. i18n: ectx: Menu (tools) +#: po/rc.cpp:12 rc.cpp:12 +msgid "&Tools" +msgstr "" + +#. i18n: file: data/semantikui.rc:23 +#. i18n: ectx: Menu (settings) +#: po/rc.cpp:15 rc.cpp:15 +msgid "&Settings" +msgstr "" + +#. i18n: file: data/semantikui.rc:26 +#. i18n: ectx: Menu (help) +#: po/rc.cpp:18 rc.cpp:18 +msgid "&Help" +msgstr "" + +#. i18n: file: data/semantikui.rc:40 +#. i18n: ectx: ToolBar (colorsToolBar) +#: po/rc.cpp:21 rc.cpp:21 +#, fuzzy +msgid "Colors Toolbar" +msgstr "Farby" + +#. i18n: file: data/semantikui.rc:44 +#. i18n: ectx: ToolBar (flagsToolBar) +#: po/rc.cpp:24 rc.cpp:24 +msgid "Flags Toolbar" +msgstr "" + +#: po/rc.cpp:25 rc.cpp:25 +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "" + +#: po/rc.cpp:26 rc.cpp:26 +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "" + +#: pre_view.cpp:23 +msgid "

    No preview available
    at this time

    " +msgstr "

    V tomto okamihu
    nie je dostupná ukážka.

    " + +#: semantik.cpp:45 +msgid "" +"The map is empty, Semantik\n" +"cannot create documents from it" +msgstr "" +"mapa je prázdna,\n" +"Semantik z nej nemôže vytvoriť dokument" + +#: semantik.cpp:45 +msgid "Empty map" +msgstr "Prázdna mapa" + +#: semantik.cpp:52 +msgid "Template folder %1 is not readable" +msgstr "Adresár šablón %1 nie je čitateľný" + +#: semantik.cpp:166 +msgid "&Reorganize the map" +msgstr "P&reusporiadať mapu" + +#: semantik.cpp:168 +msgid "Ctrl+R" +msgstr "" + +#: semantik.cpp:171 +msgid "&Export the map..." +msgstr "" + +#: semantik.cpp:173 +msgid "Ctrl+Shift+E" +msgstr "" + +#: semantik.cpp:178 +msgid "&Generate..." +msgstr "&Generovať..." + +#: semantik.cpp:181 +msgid "Ctrl+G" +msgstr "" + +#: semantik.cpp:187 +msgid "CustomColor" +msgstr "VlastnáFarba" + +#: semantik.cpp:201 +msgid "Ctrl+H" +msgstr "" + +#: semantik.cpp:210 +msgid "Data" +msgstr "Dáta" + +#: semantik.cpp:233 +msgid "Variables" +msgstr "Premenné" + +#: semantik.cpp:242 +msgid "Preview" +msgstr "Ukážka" + +#: semantik.cpp:254 +msgid "Linear view" +msgstr "Lineárne zobrazenie" + +#: semantik.cpp:347 +msgid "Welcome to Semantik" +msgstr "Vitajte v Semantiku" + +#: semantik.cpp:393 +msgid "Ready" +msgstr "Pripravený" + +#: semantik.cpp:400 +msgid "*.sem|Semantik file (*.sem)" +msgstr "*.sem|Súbor Semantik (*.sem)" + +#: semantik.cpp:401 semantik.cpp:463 +msgid "Choose a file name" +msgstr "Zvoľte meno súboru" + +#: semantik.cpp:414 +msgid "" +"The file \"%1\" already exists.\n" +"Overwrite it?" +msgstr "" + +#: semantik.cpp:415 +msgid "Overwrite existing file" +msgstr "" + +#: semantik.cpp:426 semantik.cpp:448 +msgid "Saved '%1'" +msgstr "Uložené '%1'" + +#: semantik.cpp:462 +msgid "*.sem *.kdi *.mm *.vym|All Supported Files (*.sem *.kdi *.mm *.vym)" +msgstr "" +"*.sem *.kdi *.mm *.vym|Všetky podporované súbory (*.sem *.kdi *.mm *.vym)" + +#: semantik.cpp:474 +msgid " [Modified] " +msgstr "" + +#: semantik.cpp:479 +#, fuzzy +msgid "Semantik %1" +msgstr "Semantik" + +#: semantik.cpp:483 +#, fuzzy +msgid "%1 %2 - Semantik" +msgstr "%1 - Semantik" + +#: semantik.cpp:530 +msgid "Untitled" +msgstr "Bez mena" + +#: semantik.cpp:533 +msgid "" +"The document \"%1\" has been modified.\n" +"Do you want to save your changes or discard them?" +msgstr "" +"Dokument \"%1\" bol zmenený.\n" +"Chcete svoje zmeny uložiť alebo ich zahodiť?" + +#: semantik.cpp:534 +msgid "Close Document" +msgstr "Zatvoriť dokument" + +#: sem_mediator.cpp:270 +msgid "Automatic save failed for file: %1" +msgstr "Zlyhalo automatické uloženie súboru: %1" + +#: sem_mediator.cpp:273 +msgid "%1 saved automatically" +msgstr "%1 automaticky uložený" + +#: sem_mediator.cpp:292 +msgid "Color %1" +msgstr "Farba %1" + +#: sem_mediator.cpp:618 +msgid "File saving: missing file %1" +msgstr "Ukladanie súboru: chýba súbor %1" + +#: sem_mediator.cpp:643 sem_mediator.cpp:1142 sem_mediator.cpp:1185 +msgid "Missing bindings for opening files" +msgstr "Chýba prepojenie otvorených súborov" + +#: sem_mediator.cpp:694 +msgid "Missing filter file %1 for opening files" +msgstr "Chýba súbor filtra %1 pre otváranie súborov" + +#: sem_mediator.cpp:694 sem_mediator.cpp:709 +msgid "Broken installation" +msgstr "" + +#: sem_mediator.cpp:709 +#, fuzzy +msgid "Missing python bindings for opening files" +msgstr "Chýba prepojenie otvorených súborov" + +#: sem_mediator.cpp:725 +msgid "Could not load the document %1" +msgstr "" + +#: sem_mediator.cpp:725 +#, fuzzy +msgid "Broken document" +msgstr "Zatvoriť dokument" + +#: sem_mediator.cpp:1108 +msgid "Code generation failed: missing file %1" +msgstr "Zlyhalo generovanie kódu: chýba súbor %1" + +#: sem_mediator.cpp:1147 +msgid "Document generation completed successfully" +msgstr "" + +#: table_dialog.cpp:32 +msgid "Rows" +msgstr "Riadky" + +#: table_dialog.cpp:36 +msgid "Columns" +msgstr "Stĺpce" + +#: table_view.cpp:25 table_view.cpp:79 +msgid "Add Row" +msgstr "Pridať riadok" + +#: table_view.cpp:26 +msgid "Add a row" +msgstr "Pridať riadok" + +#: table_view.cpp:30 table_view.cpp:80 +msgid "Add Column" +msgstr "Pridať stĺpec" + +#: table_view.cpp:31 +msgid "Add a column" +msgstr "Pridať stĺpec" + +#: table_view.cpp:36 table_view.cpp:81 +msgid "Remove Row" +msgstr "Odstrániť riadok" + +#: table_view.cpp:37 +msgid "Remove a row" +msgstr "Odstrániť riadok" + +#: table_view.cpp:41 table_view.cpp:82 +msgid "Remove Column" +msgstr "Odstrániť stĺpec" + +#: table_view.cpp:42 +msgid "Remove a column" +msgstr "Odstrániť stĺpec" + +#: table_view.cpp:46 +msgid "Redimension" +msgstr "Zmena rozmerov" + +#: table_view.cpp:47 +msgid "Change table dimensions" +msgstr "Zmeňte rozmery tabuľky" + +#: text_view.cpp:40 +msgid "&Bold" +msgstr "&Bold" + +#: text_view.cpp:41 +msgid "Ctrl+B" +msgstr "" + +#: text_view.cpp:44 +msgid "&Italic" +msgstr "&Italic" + +#: text_view.cpp:45 +msgid "Ctrl+I" +msgstr "" + +#: text_view.cpp:48 +msgid "&Underline" +msgstr "&Underline" + +#: text_view.cpp:49 +msgid "Ctrl+U" +msgstr "" + +#: vars_view.cpp:76 +msgid "Code complete" +msgstr "Kód dokončený" + +#: vars_view.cpp:77 +msgid "Ctrl+space" +msgstr "" + +#~ msgid "Insert child" +#~ msgstr "Vložiť potomka" + +#~ msgid "Add Box" +#~ msgstr "Pridať prvok" + +#~ msgid "Connection width" +#~ msgstr "Spojenie s" + +#~ msgid "1px" +#~ msgstr "1px" + +#~ msgid "2px" +#~ msgstr "2px" + +#~ msgid "3px" +#~ msgstr "3px" + +#~ msgid "Connection style" +#~ msgstr "Štýl spojenia" + +#~ msgid "dot line" +#~ msgstr "bodkovaná čiara" + +#~ msgid "exclude the table" +#~ msgstr "vylúčiť tabuľku" + +#~ msgid "fit the item on one slide" +#~ msgstr "rozšíriť položku na snímok" + +#~ msgid "picture caption" +#~ msgstr "titulok obrázka" + +#~ msgid "picture dimension in pdf files" +#~ msgstr "rozmery obrázku v súboroch PDF" + +#~ msgid "html div style: style=\"width: 99px;\"" +#~ msgstr "štýl html div: style=\"width: 99px;\"" + +#~ msgid "html picture style: style=\"width: 99px;\"" +#~ msgstr "štýl html picture: style=\"width: 99px;\"" + +#~ msgid "do not use this item for generating slides" +#~ msgstr "nepoužiť túto položku pre generovanie snímkov" + +#~ msgid "command to launch (%s is the resulting file)" +#~ msgstr "príkaz na vykonanie (%s je výsledný súbor)" + +#~ msgid "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" +#~ msgstr "cd `echo %s | sed s/main.tex//` && ./waf configure && waf --view" + +#~ msgid "firefox %s" +#~ msgstr "firefox %s" + +#~ msgid "ooimpress %s" +#~ msgstr "ooimpress %s" + +#~ msgid "oowriter %s" +#~ msgstr "oowriter %s" + +#~ msgid "document author" +#~ msgstr "autor dokumentu" + +#~ msgid "turn off the document author (latex)" +#~ msgstr "vypnúť autora dokumentu (latex)" + +#~ msgid "document class (latex: a4, report, book)" +#~ msgstr "trieda dokumentu (latex: a4, report, kniha)" + +#~ msgid "company" +#~ msgstr "spoločnosť" + +#~ msgid "document date" +#~ msgstr "dátum dokumentu" + +#~ msgid "turn of the document date (latex)" +#~ msgstr "vypnúť dátum dokumentu (latex)" + +#~ msgid "location of the presentation" +#~ msgstr "umiestnenie prezentácie" + +#~ msgid "turn off the document title (latex)" +#~ msgstr "vypnúť názov dokumentu (latex)" + +#~ msgid "footer center (pdflatex)" +#~ msgstr "pätka v strede (pdflatex)" + +#~ msgid "footer left (pdflatex)" +#~ msgstr "pätka vľavo (pdflatex)" + +#~ msgid "turn off the fancy output" +#~ msgstr "vypnúť vkusný výstup" + +#~ msgid "footer right" +#~ msgstr "pätka vpravo" + +#~ msgid "header center (pdflatex)" +#~ msgstr "hlavička v strede (pdflatex)" + +#~ msgid "header left" +#~ msgstr "hlavička vľavo" + +#~ msgid "header right" +#~ msgstr "hlavička vpravo" + +#~ msgid "openoffice.org language (fr_FR)" +#~ msgstr "jazyk openoffice.org language (sk_SK)" + +#~ msgid "openoffice.org presentation language" +#~ msgstr "jazyk prezentácie openoffice.org" + +#~ msgid "openoffice.org text language" +#~ msgstr "jazyk textu openoffice.org" + +#~ msgid "Generator dialog" +#~ msgstr "Generátor dialógu" + +#~ msgid "&Ok" +#~ msgstr "&Ok" + +#~ msgid "File %1 does not exist" +#~ msgstr "Súbor %1 neexistuje" + +#~ msgid "File %1 could not be opened" +#~ msgstr "Súbor %1 nemožno otvoriť" + +#~ msgid "something bad happened" +#~ msgstr "nastalo niečo zlé" + +#~ msgid "something worse happened" +#~ msgstr "nastalo niečo hrozné" + +#~ msgid "&Select" +#~ msgstr "&Vybrať" + +#~ msgid "&Link" +#~ msgstr "&Odkaz" + +#~ msgid "&Sort" +#~ msgstr "&Zoradiť" + +#~ msgid "exclude the picture" +#~ msgstr "vylúčiť obrázok" + +#~ msgid "latex language: english (frenchb, )" +#~ msgstr "jazyk latex: slovak (english, frenchb, )" diff -Nru semantik-0.7.3/src/pre_view.cpp semantik-0.8.3/src/pre_view.cpp --- semantik-0.7.3/src/pre_view.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/pre_view.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -9,65 +9,53 @@ #include #include #include "data_item.h" -#include "data_control.h" +#include "sem_mediator.h" #include "pre_view.h" #include "con.h" #include "sembind.h" #include "browser.h" -pre_view::pre_view(QWidget *i_oParent, data_control *i_oControl) : QStackedWidget(i_oParent) +pre_view::pre_view(QWidget *i_oParent, sem_mediator *i_oControl) : QStackedWidget(i_oParent) { - m_oControl = i_oControl; + m_oMediator = i_oControl; m_oLabel = new QLabel(this); m_oLabel->setText(trUtf8("

    No preview available
    at this time

    ")); addWidget(m_oLabel); /*m_oBrowserObject = new KHTMLPart(this, this); - m_oBrowser = m_oBrowserObject->widget(); //new QTextBrowser(this); - addWidget(m_oBrowser);*/ + m_oBrowser = m_oBrowserObject->widget(); //new QTextBrowser(this); + addWidget(m_oBrowser);*/ m_oBrowser = new browser(this); addWidget(m_oBrowser); } -void pre_view::synchro_doc(const hash_params&i_o) +void pre_view::notify_preview() { - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) + QString l_s = bind_node::get_var(notr("preview")); + if (l_s.endsWith(notr(".html"))) { - case cmd_pre_view: - { - QString l_s = bind_node::get_var(notr("preview")); - if (l_s.endsWith(notr(".html"))) - { - if (m_oBrowser->url() == QUrl(l_s)) - { - m_oBrowser->reload(); - } - else - { - m_oBrowser->load(QUrl(l_s)); - m_oBrowser->show(); - } - setCurrentWidget(m_oBrowser); - } - else if (l_s.endsWith(notr(".tex"))) - { - //m_oBrowser->openUrl(KUrl(l_s)); - //setCurrentWidget(m_oBrowser); - } - else - { - setCurrentWidget(m_oLabel); - } - } - break; - case cmd_open_map: - setCurrentWidget(m_oLabel); - break; - default: - break; + if (m_oBrowser->url() == QUrl(l_s)) + { + m_oBrowser->reload(); + } + else + { + m_oBrowser->load(QUrl(l_s)); + m_oBrowser->show(); + } + setCurrentWidget(m_oBrowser); } + else if (l_s.endsWith(notr(".tex"))) + { + //m_oBrowser->openUrl(KUrl(l_s)); + //setCurrentWidget(m_oBrowser); + } + else + { + setCurrentWidget(m_oLabel); + } + } #include "pre_view.moc" diff -Nru semantik-0.7.3/src/pre_view.h semantik-0.8.3/src/pre_view.h --- semantik-0.7.3/src/pre_view.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/pre_view.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef PRE_VIEW_H #define PRE_VIEW_H @@ -13,15 +13,14 @@ { Q_OBJECT public: - pre_view(QWidget *i_oParent, data_control *i_oControl); - data_control *m_oControl; + pre_view(QWidget *i_oParent, sem_mediator *i_oControl); + sem_mediator *m_oMediator; QLabel *m_oLabel; browser *m_oBrowser; - public slots: - void synchro_doc(const hash_params&); + void notify_preview(); }; #endif diff -Nru semantik-0.7.3/src/sem_mediator.cpp semantik-0.8.3/src/sem_mediator.cpp --- semantik-0.7.3/src/sem_mediator.cpp 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/sem_mediator.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -0,0 +1,1525 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#include + +#include + +#if defined(_POSIX_C_SOURCE) + #undef _POSIX_C_SOURCE +#endif + +#if defined(_XOPEN_SOURCE) + #undef _XOPEN_SOURCE +#endif + + +%: include + #include +#include + #include + %: include + #include +#include +%:include\ + +#include + #include + #include +/* + */ #include + #include +#include +/* + */ %: include "con.h" + #include + #include "sembind.h" + #include "data_item.h" + %: include "sem_mediator.h" +#include + +class semantik_reader : public QXmlDefaultHandler +{ + public: + semantik_reader(sem_mediator*); + + private: + QString m_sBuf; + int m_iVersion; + sem_mediator *m_oMediator; + int m_iId; + data_link * cur_link; + + public: + bool startElement(const QString&, const QString&, const QString&, const QXmlAttributes&); + bool endElement(const QString&, const QString&, const QString&); + bool characters(const QString &i_sStr); + +}; + +semantik_reader::semantik_reader(sem_mediator *i_oControl) +{ + m_oMediator = i_oControl; + cur_link = NULL; + m_iId = NO_ITEM; +} + +bool semantik_reader::startElement(const QString&, const QString&, const QString& i_sName, const QXmlAttributes& i_oAttrs) +{ + if (i_sName == notr("info")) + { + //m_oMediator->m_sName = i_oAttrs.value("name"); + //m_oMediator->m_sFirstName = i_oAttrs.value("fname"); + //m_oMediator->m_sOrganization = i_oAttrs.value("organization"); + //m_oMediator->m_sEmail = i_oAttrs.value("email"); + m_oMediator->m_sHints = i_oAttrs.value(notr("hints")); + m_iVersion = i_oAttrs.value(notr("version")).toInt(); + m_oMediator->m_bExportIsWidth = i_oAttrs.value(notr("export_is_width")) != notr("false"); + + if (i_oAttrs.index(notr("export_width")) > -1) + m_oMediator->m_iExportWidth = i_oAttrs.value(notr("export_width")).toInt(); + else + m_oMediator->m_iExportWidth = 0; + if (m_oMediator->m_iExportWidth < 0 || m_oMediator->m_iExportWidth > 30000) + m_oMediator->m_iExportWidth = 0; + + if (i_oAttrs.index(notr("export_height")) > -1) + m_oMediator->m_iExportHeight = i_oAttrs.value(notr("export_height")).toInt(); + else + m_oMediator->m_iExportHeight = 0; + if (m_oMediator->m_iExportHeight < 0 || m_oMediator->m_iExportHeight > 30000) + m_oMediator->m_iExportHeight = 0; + + m_oMediator->m_sExportUrl = i_oAttrs.value(notr("export_url")); + + if (i_oAttrs.value(notr("location")).size()) m_oMediator->m_sOutDir = i_oAttrs.value(notr("location")); + if (i_oAttrs.value(notr("dir")).size()) m_oMediator->m_sOutProject = i_oAttrs.value(notr("dir")); + if (i_oAttrs.value(notr("output")).size()) m_oMediator->m_sOutTemplate = i_oAttrs.value(notr("output")); + } + else if (i_sName == notr("link")) + { + int a = i_oAttrs.value(notr("p")).toInt(); + int b = i_oAttrs.value(notr("v")).toInt(); + if (!m_oMediator->m_oItems.contains(a)) return false; + if (!m_oMediator->m_oItems.contains(b)) return false; + m_oMediator->m_oLinks.append(QPoint(a, b)); + } + else if (i_sName == notr("tblsettings")) + { + data_item *l_oItem = m_oMediator->m_oItems.value(m_iId); + l_oItem->m_iNumRows = i_oAttrs.value(notr("rows")).toInt(); + l_oItem->m_iNumCols = i_oAttrs.value(notr("cols")).toInt(); + } + else if (i_sName == notr("itembox")) + { + data_item *l_oItem = m_oMediator->m_oItems.value(m_iId); + int bid = i_oAttrs.value(notr("id")).toInt(); + data_box *box = new data_box(bid); + l_oItem->m_oBoxes[bid] = box; + box->m_sText = i_oAttrs.value(notr("text")); + box->m_iXX = i_oAttrs.value(notr("x")).toFloat(); + box->m_iYY = i_oAttrs.value(notr("y")).toFloat(); + box->m_iWW = i_oAttrs.value(notr("w")).toFloat(); + box->m_iHH = i_oAttrs.value(notr("h")).toFloat(); + box->m_iType = (data_box::IType) i_oAttrs.value(notr("t")).toInt(); + box->m_bIsVertical = i_oAttrs.value(notr("v")).toInt(); + box->m_bIsEnd = i_oAttrs.value(notr("e")).toInt(); + box->color = QColor(i_oAttrs.value(notr("color"))); + + // TODO remove in the future... + if (box->m_iType == data_box::ACTIVITY_START) + { + if (box->m_iWW > 20 + box->m_iHH) box->m_iWW = box->m_iHH = 20; + } + } + else if (i_sName == notr("linkbox")) + { + data_item *l_oItem = m_oMediator->m_oItems.value(m_iId); + cur_link = new data_link(); + l_oItem->m_oLinks.append(cur_link); + cur_link->m_iParent = i_oAttrs.value(notr("parent")).toInt(); + cur_link->m_iParentPos = i_oAttrs.value(notr("parentpos")).toInt(); + cur_link->m_iChild = i_oAttrs.value(notr("child")).toInt(); + cur_link->m_iChildPos = i_oAttrs.value(notr("childpos")).toInt(); + cur_link->m_iRightArrow = i_oAttrs.value(notr("rightarrow")).toInt(); + cur_link->m_iLeftArrow = i_oAttrs.value(notr("leftarrow")).toInt(); + if (i_oAttrs.index("rightarrow") < 0) cur_link->m_iRightArrow = 1; // legacy + cur_link->color = QColor(i_oAttrs.value(notr("color"))); + cur_link->m_oStartPoint = QPoint(i_oAttrs.value(notr("startx")).toInt(), i_oAttrs.value(notr("starty")).toInt()); + cur_link->m_oEndPoint = QPoint(i_oAttrs.value(notr("endx")).toInt(), i_oAttrs.value(notr("endy")).toInt()); + cur_link->border_width = i_oAttrs.value(notr("border_width")).toInt(); + cur_link->pen_style = (Qt::PenStyle) i_oAttrs.value(notr("pen_style")).toInt(); + } + else if (i_sName == notr("linkbox_offset")) { + Q_ASSERT(cur_link); + cur_link->m_oOffsets.append(QPoint(i_oAttrs.value(notr("x")).toInt(), i_oAttrs.value(notr("y")).toInt())); + } + else if (i_sName == notr("tbl")) + { + data_item *l_oItem = m_oMediator->m_oItems.value(m_iId); + int row = i_oAttrs.value(notr("row")).toInt(); + int col = i_oAttrs.value(notr("col")).toInt(); + QPair p(row, col); + l_oItem->m_oTableData[p] = i_oAttrs.value(notr("text")); + } + else if (i_sName == notr("item")) + { + m_iId = i_oAttrs.value(notr("id")).toInt(); + if (!m_iId) return false; + + data_item *l_oItem = new data_item(m_oMediator, m_iId); + m_oMediator->m_oItems[m_iId] = l_oItem; + + l_oItem->m_sSummary = i_oAttrs.value(notr("summary")); + l_oItem->m_sText = i_oAttrs.value(notr("text")); + l_oItem->m_iTextLength = i_oAttrs.value(notr("len")).toInt(); + l_oItem->m_sComment = i_oAttrs.value(notr("comment")); + + if (i_oAttrs.index(notr("pic_id")) != -1) + l_oItem->m_iPicId = i_oAttrs.value(notr("pic_id")).toInt(); + else + l_oItem->m_iPicId = NO_ITEM; + + l_oItem->m_sPicLocation = i_oAttrs.value(notr("pic_location")); + l_oItem->m_sPicCaption = i_oAttrs.value(notr("pic_caption")); + l_oItem->m_sPicComment = i_oAttrs.value(notr("pic_comment")); + + l_oItem->m_iDataType = i_oAttrs.value(notr("data")).toInt(); + if (l_oItem->m_iDataType == 0) l_oItem->m_iDataType = VIEW_TEXT; + + l_oItem->m_sHints = i_oAttrs.value(notr("hints")); + + l_oItem->m_iNumRows = i_oAttrs.value(notr("tbl_rows")).toInt(); + l_oItem->m_iNumCols = i_oAttrs.value(notr("tbl_cols")).toInt(); + + l_oItem->m_sDiag = i_oAttrs.value(notr("dg")); + + l_oItem->m_iXX = i_oAttrs.value(notr("c2")).toDouble(); + l_oItem->m_iYY = i_oAttrs.value(notr("c1")).toDouble(); + + l_oItem->m_iColor = i_oAttrs.value(notr("color")).toInt(); + l_oItem->m_oCustom.m_sName = i_oAttrs.value(notr("custom_name")); + l_oItem->m_oCustom.m_oInnerColor = QColor(i_oAttrs.value(notr("custom_inner"))); + l_oItem->m_oCustom.m_oBorderColor = QColor(i_oAttrs.value(notr("custom_border"))); + l_oItem->m_oCustom.m_oTextColor = QColor(i_oAttrs.value(notr("custom_text"))); + } + else if (i_sName == notr("color_schemes")) + { + m_oMediator->m_oColorSchemes.clear(); + } + else if (i_sName == notr("color_scheme")) + { + color_scheme l_o; + l_o.m_sName = i_oAttrs.value(notr("name")); + l_o.m_oInnerColor = i_oAttrs.value(notr("inner")); + l_o.m_oBorderColor = i_oAttrs.value(notr("border")); + l_o.m_oTextColor = i_oAttrs.value(notr("text")); + m_oMediator->m_oColorSchemes.push_back(l_o); + } + else if (i_sName == notr("flag")) + { + data_item *l_oItem = m_oMediator->m_oItems.value(m_iId); + l_oItem->m_oFlags.push_back(i_oAttrs.value(notr("id"))); + } + return true; +} + +bool semantik_reader::endElement(const QString&, const QString&, const QString& i_sName) +{ + return true; +} + +bool semantik_reader::characters(const QString &i_s) +{ + m_sBuf += i_s; + return true; +} + +sem_mediator::~sem_mediator() +{ + destroy_timer(); + clean_temp_dir(); + while (!m_oFlagSchemes.empty()) + { + delete m_oFlagSchemes.takeFirst(); + } +} + +void sem_mediator::init_timer() +{ + destroy_timer(); + if (m_iTimerValue<1) return; + m_oTimer = new QTimer(this); + m_oTimer->setInterval(m_iTimerValue * 60000); + connect(m_oTimer, SIGNAL(timeout()), this, SLOT(slot_autosave())); + m_oTimer->start(); +} + +void sem_mediator::destroy_timer() +{ + if (m_oTimer) m_oTimer->stop(); + delete m_oTimer; + m_oTimer = NULL; +} + +void sem_mediator::slot_autosave() +{ + // autosave for the last used save name + qDebug()<<"autosave"< 1) + { + QString o = trUtf8("Automatic save failed for file: %1").arg(m_sLastSaved); + if (save_file(m_sLastSaved)) + { + o = trUtf8("%1 saved automatically").arg(m_sLastSaved); + } + emit sig_message(o, 5000); + } +} + +void sem_mediator::init_colors() +{ + m_oColorSchemes.clear(); + + QStringList l_oS; + //l_oS<<"#FFFCD5"<<"#ABFBC7"<<"#FDE1E1"<<"#D2F1FF"<<"#EDDFFF"<<"#FFFFFF"; + l_oS<<"#fffe8d"<<"#91ffab"<<"#9bfffe"<<"#b8bbff"<<"#e0aaff"<<"#ffa6a6"<<"#ffd8a6"<<"#FFFFFF"<<"#d3d7cf"; + + int i = 0; + foreach (QString l_s, l_oS) + { + color_scheme l_o; + l_o.m_oInnerColor = QColor(l_s); + l_o.m_sName = trUtf8("Color %1").arg(QString::number(i)); + m_oColorSchemes.push_back(l_o); + ++i; + } + + KConfigGroup l_oSettings(KGlobal::config(), notr("General Options")); + m_iConnType = l_oSettings.readEntry(notr("conn"), 0); + m_iReorgType = l_oSettings.readEntry(notr("reorg"), 0); + m_dTriSize = l_oSettings.readEntry(notr("trisize"), (double) 4.5); + m_iTimerValue = l_oSettings.readEntry(notr("auto"), 0); + + init_timer(); + + emit sync_colors(); +} + +void sem_mediator::init_flags() +{ + while (!m_oFlagSchemes.empty()) + { + delete m_oFlagSchemes.takeFirst(); + } + + QStringList l_oLst = QString(notr("flag_delay flag_idea flag_look flag_lunch flag_money flag_ok flag_people flag_phone flag_star flag_stop flag_talk flag_target flag_time flag_tune flag_unknown flag_write")).split(" "); + foreach (QString l_s, l_oLst) + { + m_oFlagSchemes.push_back(new flag_scheme(this, l_s, l_s)); + } + + emit sync_flags(); +} + +void sem_mediator::init_temp_dir() +{ + char sfn[16] = ""; + strcpy(sfn, "/tmp/sem.XXXXXX"); + char * l_oRet = mkdtemp(sfn); + m_sTempDir = l_oRet; + + Q_ASSERT(l_oRet!=NULL); + Q_ASSERT(QFile::exists(m_sTempDir)); +} + +void sem_mediator::clean_temp_dir() +{ + //qDebug()<<"sem_mediator::clean_temp_dir"; + QProcess l_oP; + QStringList l_oArgs; + l_oArgs<m_iXX + l_oData->m_iWW/2, + // (double) l_oData->m_iYY + l_oData->m_iHH/2, + // (double) l_oData->m_iWW/2, (double) l_oData->m_iHH/2); + } + for (int i=0; im_iXX = get_x(l_iVal) - l_oData->m_iWW/2; + l_oData->m_iYY = get_y(l_iVal) - l_oData->m_iHH/2; + update_item(l_iVal); + } + cleanup_pb(); + + hash_params l_oCmd2; + l_oCmd2.insert(data_commande, QVariant(cmd_open_map)); + emit synchro(l_oCmd2);*/ +} +#endif + +QString sem_mediator::doc_to_xml() +{ + QStringList l_oS; + + l_oS<\n"); + l_oS<\n"); + l_oS<\n"); + + l_oS<\n"); + foreach (color_scheme l_o, m_oColorSchemes) + { + l_oS<\n").arg( + l_o.m_sName, + l_o.m_oInnerColor.name(), + l_o.m_oBorderColor.name(), + l_o.m_oTextColor.name() + ); + } + l_oS<\n"); + + + QList l_oLst = m_oItems.values(); + for (int i=0; im_iId)); + l_oS<m_sSummary)); + l_oS<m_sText)); + l_oS<m_iTextLength)); + l_oS<m_sComment)); + + l_oS<m_iPicId)); + l_oS<m_sPicLocation)); + l_oS<m_sPicCaption)); + l_oS<m_sPicComment)); + + l_oS<m_iNumRows)); + l_oS<m_iNumCols)); + + l_oS<m_sDiag)); + + l_oS<m_sHints)); + l_oS<m_iDataType)); + + l_oS<m_iYY)); + l_oS<m_iXX)); + + l_oS<m_iColor)); + + color_scheme l_o = l_oItem->m_oCustom; + + l_oS<\n"); + + l_oS<\n").arg( + QString::number(l_oItem->m_iNumRows), QString::number(l_oItem->m_iNumCols)); + + + QPair p; + foreach (p, l_oItem->m_oTableData.keys()) + { + l_oS<m_oTableData[p])); + l_oS<\n"); + } + + foreach (QString l_s, l_oItem->m_oFlags) + { + l_oS<\n").arg(bind_node::protectXML(l_s)); + } + + + foreach (data_box *box, l_oItem->m_oBoxes) + { + l_oS<\n").arg( + QString::number(box->m_iId), + bind_node::protectXML(box->m_sText), + QString::number(box->m_iXX), + QString::number(box->m_iYY), + QString::number(box->m_iWW), + QString::number(box->m_iHH), + box->color.name(), + QString::number((int) box->m_iType), + QString(" v=\"%1\" e=\"%2\"").arg( + QString::number((int) box->m_bIsVertical), + QString::number((int) box->m_bIsEnd) + ) + ); + l_oS<\n"); + } + + foreach (data_link *link, l_oItem->m_oLinks) + { + l_oS<\n").arg( + QString::number(link->m_iParent), + QString::number(link->m_iParentPos), + QString::number(link->m_iChild), + QString::number(link->m_iChildPos), + link->color.name(), + QString::number(link->border_width), + QString::number(link->pen_style), + QString("\n startx=\"%1\" starty=\"%2\" endx=\"%3\" endy=\"%4\" leftarrow=\"%5\" rightarrow=\"%6\"").arg( + QString::number(link->m_oStartPoint.x()), + QString::number(link->m_oStartPoint.y()), + QString::number(link->m_oEndPoint.x()), + QString::number(link->m_oEndPoint.y()), + QString::number(link->m_iLeftArrow), + QString::number(link->m_iRightArrow) + ) + ); + foreach (QPoint p, link->m_oOffsets) { + l_oS<\n").arg(QString::number(p.x()), QString::number(p.y())); + } + l_oS<\n"); + + } + + l_oS<\n"); + } + + for (int i=0; i\n").arg(l_oP.x()).arg(l_oP.y()); + } + + l_oS<\n"); + + return l_oS.join(""); +} + +bool sem_mediator::save_file(QString i_sUrl) +{ + Q_ASSERT(i_sUrl.endsWith(".sem")); + + QFile l_o2(QString(TEMPLATE_DIR)+notr("/semantik.sem.py")); + if (!l_o2.open(QIODevice::ReadOnly)) + { + emit sig_message(trUtf8("File saving: missing file %1").arg(l_o2.fileName()), 5000); + return false; + } + + QByteArray l_oBa = l_o2.readAll(); + l_o2.close(); + + QStringList lst; + foreach (data_item *d, m_oItems.values()) { + if (d->m_iPicId != NO_ITEM) { + lst << QString::number(d->m_iPicId); + } + } + + bind_node::init(this); + bind_node::set_var(notr("temp_dir"), m_sTempDir); + bind_node::set_var(notr("outfile"), i_sUrl); + bind_node::set_var(notr("fulldoc"), doc_to_xml()); + bind_node::set_var(notr("hints"), m_sHints); + bind_node::set_var(notr("namet"), ""); + bind_node::set_var(notr("outdir"), ""); + bind_node::set_var(notr("pics"), lst.join(",")); + + if (!init_py()) + { + emit sig_message(trUtf8("Missing bindings for opening files"), 5000); + return false; + } + PyRun_SimpleString(l_oBa.constData()); + + m_sLastSaved = i_sUrl; + set_dirty(false); + return true; +} + +void sem_mediator::purge_document() +{ + while (!m_oUndoStack.isEmpty()) + delete m_oUndoStack.pop(); + while (!m_oRedoStack.isEmpty()) + delete m_oRedoStack.pop(); + + mem_sel *sel = new mem_sel(this); + sel->apply(); + + mem_delete* del = new mem_delete(this); + del->init(m_oItems.keys()); + del->apply(); +} + +void sem_mediator::undo_purge() { + m_oItems.clear(); + m_oLinks.clear(); + while (!m_oUndoStack.isEmpty()) { + mem_command* c = m_oUndoStack.pop(); + c->undo(); + } + while (!m_oRedoStack.isEmpty()) + delete m_oRedoStack.pop(); +} + +void sem_mediator::check_undo(bool enable) { + if (!enable) { + emit enable_undo(false, false); + } else { + emit enable_undo(!m_oUndoStack.isEmpty(), !m_oRedoStack.isEmpty()); + } +} + +bool sem_mediator::open_file(const QString& i_sUrl) +{ + purge_document(); + + QFile l_o2(QString(FILTER_DIR)+"/main.py"); + if (!l_o2.open(QIODevice::ReadOnly)) + { + KMessageBox::sorry(NULL, trUtf8("Missing filter file %1 for opening files").arg(l_o2.fileName()), trUtf8("Broken installation")); + undo_purge(); + return false; + } + QByteArray l_oBa = l_o2.readAll(); + l_o2.close(); + + bind_node::set_var(notr("temp_dir"), m_sTempDir); + bind_node::set_var(notr("pname"), i_sUrl); + bind_node::set_var(notr("hints"), m_sHints); + bind_node::set_var(notr("namet"), i_sUrl); + bind_node::set_var(notr("outdir"), ""); + + if (!init_py()) + { + KMessageBox::sorry(NULL, trUtf8("Missing python bindings for opening files"), trUtf8("Broken installation")); + undo_purge(); + return false; + } + PyRun_SimpleString(l_oBa.constData()); + + //qDebug()<<"full text "<m_iPicId = seq; + + QFile f(l_oInfo.absoluteFilePath()); + QString name = f.fileName().replace(QRegExp(notr("/pic-\\d+")), QString("/img-%1").arg(QString::number(seq))); + f.rename(name); + } + } + else if (l_sName.startsWith(notr("img-"))) + { + l_sName = l_sName.section(QRegExp(notr("[.-]")), 1, 1); + int l_iVal = l_sName.toInt(); + load_picture(l_oInfo.absoluteFilePath(), l_iVal); + } + } + + // now update all items created + foreach (int i, m_oItems.keys()) { + notify_add_item(i); + } + + foreach (QPoint p, m_oLinks) { + notify_link_items(p.x(), p.y()); + } + + QList lst; + mem_sel *sel = new mem_sel(this); + sel->sel = lst; + sel->apply(); + + + // now tell all the views that a new map was loaded + emit sig_open_map(); + emit sync_colors(); + + QRegExp r(notr(".kdi$")); + QString s(notr(".sem")); + + m_sLastSaved = i_sUrl; + m_sLastSaved.replace(r, s); + + sel = new mem_sel(this); + sel->sel = lst; + sel->apply(); + + set_dirty(false); + return true; +} + +bool sem_mediator::link_items(int i_iParent, int i_iChild) +{ + Q_ASSERT(m_oItems.contains(i_iParent) && m_oItems.contains(i_iChild)); + + if (i_iParent == i_iChild) return false; + + // one parent + for (int i=0; i NO_ITEM) + { + int l_iNew = NO_ITEM; + for (int i=0; iparent = i_iParent; + lnk->child = i_iChild; + lnk->apply(); + + return true; +} + +QList sem_mediator::all_roots() +{ + QList l_o = QList (); + foreach (int l_iVal, m_oItems.keys()) + { + for (int i=0; im_bSelected) + return l_iVal; + } + return NO_ITEM; +} + +void sem_mediator::next_root() +{ + QList l_o = all_roots(); + if (l_o.size() == 0) return; + + int l_i = itemSelected(); + if (l_i == NO_ITEM && !l_o.empty()) + { + private_select_item(l_o[0]); + } + + for (int i=0; i l_o = all_roots(); + + int l_i = itemSelected(); + if (l_i == NO_ITEM && !l_o.empty()) + { + private_select_item(l_o[0]); + } + + for (int i=0; i l_o = all_roots(); + if (l_o.size() > 0) private_select_item(l_o[0]); + } + else + { + int l_iId = root_of(i_iId); + private_select_item(l_iId); + } +} + +void sem_mediator::select_item_keyboard(int l_iId, int l_iDirection) +{ + if (l_iId == NO_ITEM) + { + select_root_item(NO_ITEM); return; + } + if (!m_oLinks.size()) return; + + switch (l_iDirection) + { + case 1: //left + { + int l_iParent = NO_ITEM; + int i = 0; + + while (i= m_oLinks.size()) i=0; + + QPoint l_oP = m_oLinks.at(i); + if (l_oP.x() == l_iParent) + { + private_select_item(l_oP.y()); + break; + } + } + } + break; + case 3: //top + { + for (int i=0; im_iDown = l_iId; + private_select_item(l_oP.x()); + return; + } + } + } + break; + case 4: //bottom + { + // first try the cache + data_item *l_oItem = m_oItems.value(l_iId); + Q_ASSERT(l_oItem != NULL); + int l_iDown = l_oItem->m_iDown; + + for (int i=0; iapply(); + + bind_node::init(this); + bind_node::_root = bind_node::create_tree(this, choose_root()); + + notify_export_doc(); + foreach (int l_iVal, m_oItems.keys()) + { + data_item *l_oData = m_oItems.value(l_iVal); + // the diagram view is the only one for now + if (l_oData->m_iDataType == VIEW_DIAG || l_oData->m_iDataType == VIEW_IMG) + notify_export_item(l_oData->m_iId); + } + + bind_node::set_var(notr("temp_dir"), m_sTempDir); + bind_node::set_var(notr("outdir"), i_sLocation); + bind_node::set_var(notr("pname"), i_sDirName); + bind_node::set_var(notr("fulldoc"), doc_to_xml()); + bind_node::set_var(notr("hints"), m_sHints); + bind_node::set_var(notr("namet"), i_oFile); + bind_node::set_var(notr("preview"), ""); // leave this right here! get the file generated + + if (!init_py()) + { + emit sig_message(trUtf8("Missing bindings for opening files"), 5000); + return; + } + PyRun_SimpleString(l_oBa.constData()); + + emit sig_message(trUtf8("Document generation completed successfully"), 5000); + emit sig_preview(); +} + +int sem_mediator::choose_root() +{ + int l_oCand = NO_ITEM; + int l_oCandSize = 0; + for (int i=0; i NO_ITEM) continue; + if (l_oP.x() == l_oCand) continue; + + int l_oNewSize = size_of(l_oP.x()); + if (l_oNewSize > l_oCandSize) + { + l_oCand = l_oP.x(); + l_oCandSize = l_oNewSize; + } + } + + if (l_oCandSize == 0) return NO_ITEM; + return l_oCand; +} + +QPair sem_mediator::hint_size_diagram(int id) +{ + int width = 0; + int height = 0; + + data_item *item = m_oItems.value(id); + Q_ASSERT(item); + if (item->m_sHints.size() > 4) + { + if (!init_py()) + { + emit sig_message(trUtf8("Missing bindings for opening files"), 5000); + } + else + { + bind_node::s_oResults.clear(); + QString s = QString("compute_hints(%1)").arg(id); + QByteArray ba = s.toAscii(); + PyRun_SimpleString(ba.constData()); + + width = bind_node::s_oResults.value("diagram_width").toInt(); + height = bind_node::s_oResults.value("diagram_height").toInt(); + } + } + return QPair(width, height); +} + +int sem_mediator::size_of(int i_i) +{ + // warning, recursive + int l_i = 0; + for (int i=0; i"); + } + + m_sBuf.clear(); + return true; +} + +sem_mediator::sem_mediator(QObject* i_oParent) : QObject(i_oParent) +{ + num_seq = 1; + pic_seq = 1; + + m_sOutDir = ""; + m_iTimerValue = 21 / 4; + m_bDirty = false; + + m_bExportIsWidth = true; + m_iExportWidth = 0; + m_iExportHeight = 0; + + m_oTimer = NULL; + m_sOutProject = ""; + m_sOutTemplate = ""; + init_temp_dir(); + + if (!QFile::exists(SEMANTIK_DIR "/templates/waf")) { + qDebug()<<"You cannot use Semantik if it is not installed"; + Q_ASSERT(false); + } +} + +bool html_converter::endElement(const QString&, const QString&, const QString& i_sName) +{ + if (i_sName == notr("p")) + { + m_oTotale<")<"); + } + else if (i_sName == notr("li")) + { + m_oTotale<"); + } + return true; +} + +bool html_converter::characters(const QString &i_s) +{ + m_sBuf += i_s; + return true; +} + +data_item* sem_mediator::operator+(const int y) +{ + return m_oItems.value(y); +} + +void sem_mediator::slot_undo() +{ + if (!m_oUndoStack.isEmpty()) { + mem_command *t = m_oUndoStack.pop(); + t->undo(); + m_oRedoStack.push(t); + } + check_undo(true); +} + +void sem_mediator::slot_redo() +{ + if (!m_oRedoStack.isEmpty()) { + mem_command *t = m_oRedoStack.pop(); + t->redo(); + m_oUndoStack.push(t); + } + check_undo(true); +} + +void sem_mediator::private_select_item(int id) +{ + mem_sel *sel = new mem_sel(this); + sel->sel.append(id); + sel->apply(); +} + + +QPixmap sem_mediator::getPix(int id) +{ + if (id == NO_ITEM) + return QPixmap(); + data_pic *pic = m_oPixCache.value(id); + if (pic) + return pic->m_oPix; + + return QPixmap(); +} + +QPixmap sem_mediator::getThumb(int id) +{ + if (id == NO_ITEM) + return QPixmap(); + data_pic *pic = m_oPixCache.value(id); + if (pic) + return pic->m_oThumb; + return QPixmap(); +} + +bool sem_mediator::save_and_load_picture(const KUrl& i_sPath, int id) +{ + QStringList sp = i_sPath.path().split("."); + if (sp.size() < 2) return false; + QString dest = QString(m_sTempDir+"/img-%1.%2").arg(QString::number(id)).arg(sp[sp.size()-1]); + + bool ok = KIO::NetAccess::file_copy(i_sPath, KUrl(dest), NULL); + if (!ok) + goto cleanup; + + ok = load_picture(dest, id); + if (!ok) + goto cleanup; + + return true; + + cleanup: + KIO::NetAccess::del(KUrl(dest), NULL); + return false; +} + +bool sem_mediator::load_picture(const QString & i_sPath, int id) +{ + QPixmap l_oPix; + l_oPix.load(i_sPath); + if (l_oPix.isNull()) return false; + + // l_oPix.scaledToHeight(300); + data_pic *pic = m_oPixCache[id]; + if (!pic) + pic = new data_pic(); + pic->m_oPix = l_oPix; + pic->m_oThumb = l_oPix.scaledToHeight(32); + m_oPixCache[id] = pic; + return true; +} + +void sem_mediator::notify_add_item(int id) +{ + emit sig_add_item(id); +} + +void sem_mediator::notify_delete_item(int id) +{ + emit sig_delete_item(id); +} + +void sem_mediator::notify_link_items(int id1, int id2) +{ + emit sig_link_items(id1, id2); +} + +void sem_mediator::notify_unlink_items(int id1, int id2) +{ + emit sig_unlink_items(id1, id2); +} + +void sem_mediator::notify_select(const QList& unsel, const QList& sel) +{ + emit sig_select(unsel, sel); +} + +void sem_mediator::notify_move(const QList&sel, const QList&pos) +{ + emit sig_move(sel, pos); +} + +void sem_mediator::notify_repaint(int id) +{ + emit sig_repaint(id); +} + +void sem_mediator::notify_edit(int id) +{ + emit sig_edit(id); +} + +void sem_mediator::notify_flag(int id) +{ + emit sig_flag(id); +} + +void sem_mediator::notify_datatype(int id) +{ + emit sig_datatype(id); +} + +void sem_mediator::notify_text(int id) +{ + emit sig_text(id); +} + +void sem_mediator::notify_vars(int id) +{ + emit sig_vars(id); +} + +void sem_mediator::notify_pic(int id) +{ + emit sig_pic(id); +} + +void sem_mediator::notify_table(int id) +{ + emit sig_table(id); +} + +void sem_mediator::notify_sort(int id) +{ + emit sig_sort(id); +} + +void sem_mediator::notify_change_data(int id) +{ + emit sig_change_data(id); +} + +void sem_mediator::notify_export_item(int id) +{ + emit sig_export_item(id); +} + +void sem_mediator::notify_export_doc() +{ + emit sig_export_doc(); +} + +void sem_mediator::notify_add_box(int id, int box) +{ + emit sig_add_box(id, box); +} + +void sem_mediator::notify_del_box(int id, int box) +{ + emit sig_del_box(id, box); +} + +void sem_mediator::notify_edit_box(int id, int box) +{ + emit sig_edit_box(id, box); +} + +void sem_mediator::notify_link_box(int id, data_link*link) +{ + emit sig_link_box(id, link); +} + +void sem_mediator::notify_unlink_box(int id, data_link*link) +{ + emit sig_unlink_box(id, link); +} + +void sem_mediator::notify_message(const QString& msg, int duration) +{ + emit sig_message(msg, duration); +} + +void sem_mediator::notify_box_props(int id, const QList& items) +{ + emit sig_box_props(id, items); +} + +void sem_mediator::notify_pos_box(int id, const QList& items) +{ + emit sig_pos_box(id, items); +} + +void sem_mediator::notify_focus(void *ptr) +{ + emit sig_focus(ptr); +} + +void sem_mediator::notify_change_link_box(int id, data_link*link) +{ + emit sig_change_link_box(id, link); +} + +void sem_mediator::notify_size_box(int id, const QList& items) +{ + emit sig_size_box(id, items); +} + +#include "sem_mediator.moc" + diff -Nru semantik-0.7.3/src/sem_mediator.h semantik-0.8.3/src/sem_mediator.h --- semantik-0.7.3/src/sem_mediator.h 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/sem_mediator.h 2012-10-21 10:09:17.000000000 +0000 @@ -0,0 +1,225 @@ +// Thomas Nagy 2007-2012 GPLV3 + +#ifndef DATA_CONTROL_H +#define DATA_CONTROL_H + +#include +#include +#include +#include +#include + +#include "aux.h" +#include "con.h" +#include "mem_command.h" +#include "flag_scheme.h" +#include "color_scheme.h" + +class QTimer; +class html_converter : public QXmlDefaultHandler +{ + public: + html_converter(); + + bool startElement(const QString&, const QString&, const QString&, const QXmlAttributes&); + bool endElement(const QString&, const QString&, const QString&); + bool characters(const QString &i_sStr); + + QString m_sBuf; + QStringList m_oTotale; +}; + + +class semantik_reader; +class data_item; +class bind_node; +class sem_mediator: public QObject +{ + Q_OBJECT + + signals: + //void rectangle_changed(int i); + + void sig_message(const QString&, int); + void dirty(bool); + void update_title(); + + void sig_add_item(int id); + void sig_delete_item(int id); + void sig_link_items(int id1, int id2); + void sig_unlink_items(int id1, int id2); + void sync_flags(); + void sync_colors(); + void sig_select(const QList& unsel, const QList& sel); + void sig_move(const QList&sel, const QList&pos); + void sig_repaint(int id); + void sig_flag(int id); + void sig_edit(int id); + void sig_text(int id); + void sig_datatype(int id); + void sig_preview(); + void sig_vars(int id); + void sig_pic(int id); + void sig_table(int id); + void sig_sort(int id); + void sig_open_map(); + void sig_change_data(int id); + void sig_export_item(int id); + void sig_export_doc(); + void sig_focus(void*); + + void sig_add_box(int, int); + void sig_del_box(int, int); + void sig_edit_box(int, int); + void sig_link_box(int, data_link*); + void sig_unlink_box(int, data_link*); + void sig_box_props(int id, const QList&); + void sig_pos_box(int id, const QList&); + void sig_change_link_box(int id, data_link*); + void sig_size_box(int id, const QList&); + + void enable_undo(bool, bool); + + public: + sem_mediator(QObject *i_oParent); + ~sem_mediator(); + + void undo_purge(); + + QString m_sTempDir; + QString m_sOutDir; + QString m_sOutProject; + QString m_sOutTemplate; + bool m_bExportIsWidth; + int m_iExportWidth; + int m_iExportHeight; + QString m_sExportUrl; + + void set_dirty(bool b = true); + bool m_bDirty; + + void init_temp_dir(); + void clean_temp_dir(); + + bool save_file(QString); + bool open_file(const QString&); + void purge_document(); + + void init_colors(); + void init_flags(); + + // first parameter is the parent, second parameter is the wanted id + // and the third parameter is for copying the parents data + bool link_items(int id1, int id2); + + int num_children(int i_iParent); + int m_iConnType; + int m_iReorgType; + void select_root_item(int); + QList all_roots(); + int root_of(int i_iId); + void next_root(); + void prev_root(); + double m_dTriSize; + + QColor m_oColor; + QString m_sHints; + + QStack m_oUndoStack; + QStack m_oRedoStack; + + void notify_add_item(int id); + void notify_delete_item(int id); + void notify_link_items(int id1, int id2); + void notify_unlink_items(int id1, int id2); + void notify_select(const QList& unsel, const QList& sel); + void notify_move(const QList&sel, const QList&pos); + void notify_repaint(int id); + void notify_edit(int id); + void notify_text(int id); + void notify_vars(int id); + void notify_flag(int id); + void notify_pic(int id); + void notify_datatype(int id); + void notify_table(int id); + void notify_sort(int id); + void notify_change_data(int id); + void notify_export_item(int id); + void notify_export_doc(); + void notify_focus(void *); + + void notify_add_box(int id, int box); + void notify_del_box(int id, int box); + void notify_edit_box(int id, int box); + void notify_link_box(int id, data_link *link); + void notify_unlink_box(int id, data_link *link); + void notify_box_props(int id, const QList&); + void notify_pos_box(int id, const QList&); + void notify_change_link_box(int id, data_link*); + void notify_size_box(int id, const QList&); + + void notify_message(const QString& msg, int duration); + + public: + + KUrl m_oCurrentUrl; + + QHash m_oItems; + QList m_oLinks; + QList m_oImgs; + + QList m_oColorSchemes; + QList m_oFlagSchemes; + + int next_seq(); + int next_pic_seq(); + + QPair hint_size_diagram(int); + QHash m_oPixCache; + + + QPixmap getPix(int id); + QPixmap getThumb(int id); + bool load_picture(const QString&, int); + bool save_and_load_picture(const KUrl& i_sPath, int id); + + + void generate_docs(const QString &i_oFile, const QString &i_sName, const QString &i_sLocation); + + int m_iTimerValue; + int parent_of(int i_iId); + int size_of(int i_iId); + int choose_root(); + + void init_timer(); + void destroy_timer(); + + QString doc_to_xml(); + QString m_sLastSaved; + + data_item* operator+(const int x); + + void select_item_keyboard(int, int); + void private_select_item(int i_oId); + + void check_undo(bool); // check if the undo/redo actions can be enabled + int itemSelected(); + + friend class semantik_reader; + + private: + int num_seq; + int pic_seq; + QTimer *m_oTimer; + + public slots: + //void do_reorganize(); + void slot_autosave(); + void slot_undo(); + void slot_redo(); +}; + +QIcon fetch_icon(const QString& i_sName, int i_iSize=32); + +#endif + diff -Nru semantik-0.7.3/src/semantik.cpp semantik-0.8.3/src/semantik.cpp --- semantik-0.7.3/src/semantik.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/semantik.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -1,6 +1,7 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include +#include #include #include #include @@ -22,7 +23,7 @@ #include "sembind.h" #include "semantik.h" #include "canvas_view.h" -#include "data_control.h" +#include "sem_mediator.h" #include "image_view.h" #include "config_dialog.h" #include "text_view.h" @@ -35,10 +36,11 @@ #include "data_view.h" #include "doc_dialog.h" #include "aux.h" +#include "linear_view.h" void semantik_win::slot_generate() { - if (m_oControl->choose_root() <= 0) + if (m_oMediator->choose_root() <= 0) { KMessageBox::sorry(this, trUtf8("The map is empty, Semantik\ncannot create documents from it"), trUtf8("Empty map")); return; @@ -112,17 +114,17 @@ } generator_dialog l_oGen(this, l_oLst); - l_oGen.m_oName->setText(m_oControl->m_sOutProject); - l_oGen.m_oLocation->setText(m_oControl->m_sOutDir); + l_oGen.m_oName->setText(m_oMediator->m_sOutProject); + l_oGen.m_oLocation->setText(m_oMediator->m_sOutDir); if (l_oGen.m_oLocation->text().length()<2) l_oGen.m_oLocation->setText(bind_node::get_var(notr("outdir"))); - l_oGen.activate_from_name(m_oControl->m_sOutTemplate); + l_oGen.activate_from_name(m_oMediator->m_sOutTemplate); if (l_oGen.exec() == QDialog::Accepted) { - m_oControl->m_sOutDir = l_oGen.m_oLocation->text(); - m_oControl->m_sOutProject = l_oGen.m_oName->text(); - m_oControl->m_sOutTemplate = l_oGen.m_sShortName; - m_oControl->generate_docs(l_oGen.m_sCurrent, l_oGen.m_oName->text(), l_oGen.m_oLocation->text()); + m_oMediator->m_sOutDir = l_oGen.m_oLocation->text(); + m_oMediator->m_sOutProject = l_oGen.m_oName->text(); + m_oMediator->m_sOutTemplate = l_oGen.m_sShortName; + m_oMediator->generate_docs(l_oGen.m_sCurrent, l_oGen.m_oName->text(), l_oGen.m_oLocation->text()); } } @@ -130,16 +132,16 @@ { setObjectName("semantik_win"); - //setWindowIcon(QIcon(notr(":images/semantik-32.png"))); + setWindowIcon(KIcon("semantik")); - m_oControl = new data_control(this); - connect(m_oControl, SIGNAL(sig_message(const QString&, int)), this, SLOT(slot_message(const QString&, int))); - connect(m_oControl, SIGNAL(update_title()), this, SLOT(update_title())); + m_oMediator = new sem_mediator(this); + connect(m_oMediator, SIGNAL(sig_message(const QString&, int)), this, SLOT(slot_message(const QString&, int))); + connect(m_oMediator, SIGNAL(update_title()), this, SLOT(update_title())); QFrame *fr = new QFrame(this); fr->setLineWidth(0); fr->setFrameStyle(QFrame::NoFrame); - m_oCanvas = new canvas_view(fr, m_oControl); + m_oCanvas = new canvas_view(fr, m_oMediator); setCentralWidget(fr); QGridLayout *ll = new QGridLayout(fr); ll->addWidget(m_oCanvas); @@ -154,13 +156,22 @@ KStandardAction::open(this, SLOT(slot_open()), actionCollection()); KStandardAction::print(this, SLOT(slot_print()), actionCollection()); KStandardAction::tipOfDay(this, SLOT(slot_tip_of_day()), actionCollection()); + m_oUndoAct = KStandardAction::undo(m_oMediator, SLOT(slot_undo()), actionCollection()); + m_oUndoAct->setEnabled(false); + m_oRedoAct = KStandardAction::redo(m_oMediator, SLOT(slot_redo()), actionCollection()); + m_oRedoAct->setEnabled(false); m_oRecentFilesAct = KStandardAction::openRecent(this, SLOT(slot_recent(const KUrl&)), actionCollection()); m_oReorgAct = new KAction(trUtf8("&Reorganize the map"), this); actionCollection()->addAction(notr("reorganize_map"), m_oReorgAct); m_oReorgAct->setShortcut(trUtf8("Ctrl+R")); - connect(m_oReorgAct, SIGNAL(triggered(bool)), m_oControl, SLOT(do_reorganize())); + connect(m_oReorgAct, SIGNAL(triggered(bool)), m_oCanvas, SLOT(reorganize())); + + m_oExportSizeAct = new KAction(trUtf8("&Export the map..."), this); + actionCollection()->addAction(notr("export_map_size"), m_oExportSizeAct); + m_oExportSizeAct->setShortcut(trUtf8("Ctrl+Shift+E")); + connect(m_oExportSizeAct, SIGNAL(triggered(bool)), m_oCanvas, SLOT(export_map_size())); KStandardAction::preferences(this, SLOT(slot_properties()), actionCollection()); @@ -170,39 +181,6 @@ m_oGenerateAct->setShortcut(trUtf8("Ctrl+G")); connect(m_oGenerateAct, SIGNAL(triggered(bool)), SLOT(slot_generate())); - m_oGroup = new QActionGroup(this); - - m_oSelectAct = new KAction(trUtf8("&Select"), this); - actionCollection()->addAction(notr("tool_select"), m_oSelectAct); - connect(m_oSelectAct, SIGNAL(triggered(bool)), SLOT(slot_tool_select())); - m_oSelectAct->setIcon(KIcon(notr("semantik_point"))); - m_oSelectAct->setCheckable(true); - - m_oLinkAct = new KAction(trUtf8("&Link"), this); - actionCollection()->addAction(notr("tool_link"), m_oLinkAct); - connect(m_oLinkAct, SIGNAL(triggered(bool)), SLOT(slot_tool_link())); - m_oLinkAct->setIcon(KIcon(notr("semantik_link"))); - m_oLinkAct->setCheckable(true); - - m_oSortAct = new KAction(trUtf8("&Sort"), this); - actionCollection()->addAction(notr("tool_sort"), m_oSortAct); - connect(m_oSortAct, SIGNAL(triggered(bool)), SLOT(slot_tool_sort())); - m_oSortAct->setIcon(KIcon(notr("semantik_sort"))); - m_oSortAct->setCheckable(true); - - m_oScrollAct = new KAction(trUtf8("&Scroll"), this); - actionCollection()->addAction(notr("tool_scroll"), m_oScrollAct); - connect(m_oScrollAct, SIGNAL(triggered(bool)), SLOT(slot_tool_scroll())); - m_oScrollAct->setIcon(KIcon(notr("semantik_move"))); - m_oScrollAct->setCheckable(true); - - m_oGroup->addAction(m_oSelectAct); - m_oGroup->addAction(m_oLinkAct); - m_oGroup->addAction(m_oSortAct); - m_oGroup->addAction(m_oScrollAct); - - m_oSelectAct->setChecked(true); - flag_scheme l_oScheme(this, notr("crsc-app-colors"), ""); m_oColorGroup = new QActionGroup(this); @@ -214,8 +192,6 @@ m_oFlagGroup->setExclusive(false); connect(m_oFlagGroup, SIGNAL(triggered(QAction*)), m_oCanvas, SLOT(change_flags(QAction*))); - slot_tool_select(); - //m_oCanvasFitZoom = new KAction(trUtf8("Fit zoom"), this); //actionCollection()->addAction(notr("zoom_map"), m_oCanvasFitZoom); //m_oCanvasFitZoom->setIcon(KIcon(notr("zoom-best-fit"))); @@ -228,33 +204,35 @@ KStandardAction::zoomOut(m_oCanvas, SLOT(zoom_out()), actionCollection()); //END setupActions() - setStandardToolBarMenuEnabled(true); + //setStandardToolBarMenuEnabled(true); QDockWidget *l_oDockData = new QDockWidget(trUtf8("Data"), this); l_oDockData->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_oDataView = new data_view(l_oDockData, m_oControl); + m_oDataView = new data_view(l_oDockData, m_oMediator); l_oDockData->setWidget(m_oDataView); addDockWidget(Qt::BottomDockWidgetArea, l_oDockData); actionCollection()->addAction(notr("show_dock_data"), l_oDockData->toggleViewAction()); l_oDockData->setObjectName(notr("DataDock")); - m_oTextView = new text_view(m_oDataView, m_oControl); + m_oTextView = new text_view(m_oDataView, m_oMediator); m_oDataView->addWidget(m_oTextView); - m_oImageView = new image_view(m_oDataView, m_oControl); + m_oImageView = new image_view(m_oDataView, m_oMediator); m_oDataView->addWidget(m_oImageView); - m_oTableView = new table_view(m_oDataView, m_oControl); + m_oTableView = new table_view(m_oDataView, m_oMediator); m_oDataView->addWidget(m_oTableView); - m_oDiagramView = new box_view(m_oDataView, m_oControl); + m_oDiagramView = new box_view(m_oDataView, m_oMediator); m_oDataView->addWidget(m_oDiagramView); + connect(m_oColorGroup, SIGNAL(triggered(QAction*)), m_oDiagramView, SLOT(change_colors(QAction*))); + connect(m_oDiagramView, SIGNAL(sig_message(const QString&, int)), this, SLOT(slot_message(const QString&, int))); QDockWidget *l_oDockVars = new QDockWidget(trUtf8("Variables"), this); l_oDockVars->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_oVarsView = new vars_view(l_oDockVars, m_oControl); + m_oVarsView = new vars_view(l_oDockVars, m_oMediator); l_oDockVars->setWidget(m_oVarsView); addDockWidget(Qt::BottomDockWidgetArea, l_oDockVars); l_oDockVars->setObjectName(notr("VarsDock")); @@ -263,7 +241,7 @@ QDockWidget *l_oDockPreview = new QDockWidget(trUtf8("Preview"), this); l_oDockPreview->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_oPreView = new pre_view(l_oDockPreview, m_oControl); + m_oPreView = new pre_view(l_oDockPreview, m_oMediator); l_oDockPreview->setWidget(m_oPreView); addDockWidget(Qt::RightDockWidgetArea, l_oDockPreview); actionCollection()->addAction(notr("show_dock_preview"), l_oDockPreview->toggleViewAction()); @@ -274,7 +252,7 @@ QDockWidget *l_oDock = new QDockWidget(trUtf8("Linear view"), this); - m_oTree = new linear_container(l_oDock, m_oControl); + m_oTree = new linear_container(l_oDock, m_oMediator); l_oDock->setWidget(m_oTree); addDockWidget(Qt::LeftDockWidgetArea, l_oDock); actionCollection()->addAction(notr("show_dock_linear"), l_oDock->toggleViewAction()); @@ -284,36 +262,92 @@ setXMLFile(notr("semantikui.rc")); setupGUI(); - m_oControl->m_oCurrentUrl = KUrl(); + m_oMediator->m_oCurrentUrl = KUrl(); update_title(); m_oColorsToolBar = toolBar(notr("colorsToolBar")); m_oFlagsToolBar = toolBar(notr("flagsToolBar")); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oCanvas, SLOT(synchro_doc(const hash_params&))); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oTableView, SLOT(synchro_doc(const hash_params&))); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oImageView, SLOT(synchro_doc(const hash_params&))); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oTextView, SLOT(synchro_doc(const hash_params&))); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oDataView, SLOT(synchro_doc(const hash_params&))); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oTree, SLOT(synchro_doc(const hash_params&))); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oVarsView, SLOT(synchro_doc(const hash_params&))); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oPreView, SLOT(synchro_doc(const hash_params&))); - connect(m_oControl, SIGNAL(synchro(const hash_params&)), m_oDiagramView, SLOT(synchro_doc(const hash_params&))); + linear_view* ln = m_oTree->m_oView; + connect(m_oMediator, SIGNAL(sig_preview()), m_oPreView, SLOT(notify_preview())); + connect(m_oMediator, SIGNAL(sig_add_item(int)), m_oCanvas, SLOT(notify_add_item(int))); + connect(m_oMediator, SIGNAL(sig_add_item(int)), ln, SLOT(notify_add_item(int))); + connect(m_oMediator, SIGNAL(sig_add_item(int)), m_oDiagramView, SLOT(notify_add_item(int))); + + connect(m_oMediator, SIGNAL(sig_delete_item(int)), m_oCanvas, SLOT(notify_delete_item(int))); + connect(m_oMediator, SIGNAL(sig_delete_item(int)), ln, SLOT(notify_delete_item(int))); + connect(m_oMediator, SIGNAL(sig_link_items(int, int)), m_oCanvas, SLOT(notify_link_items(int, int))); + connect(m_oMediator, SIGNAL(sig_link_items(int, int)), ln, SLOT(notify_link_items(int, int))); + connect(m_oMediator, SIGNAL(sig_unlink_items(int, int)), m_oCanvas, SLOT(notify_unlink_items(int, int))); + connect(m_oMediator, SIGNAL(sig_unlink_items(int, int)), ln, SLOT(notify_unlink_items(int, int))); + connect(m_oMediator, SIGNAL(sig_repaint(int)), m_oCanvas, SLOT(notify_repaint(int))); + connect(m_oMediator, SIGNAL(sig_repaint(int)), ln, SLOT(notify_repaint(int))); + + connect(m_oMediator, SIGNAL(sig_edit(int)), m_oCanvas, SLOT(notify_edit(int))); + connect(m_oMediator, SIGNAL(sig_edit(int)), ln, SLOT(notify_edit(int))); + connect(m_oMediator, SIGNAL(sig_text(int)), m_oTextView, SLOT(notify_text(int))); + connect(m_oMediator, SIGNAL(sig_vars(int)), m_oVarsView, SLOT(notify_vars(int))); + + connect(m_oMediator, SIGNAL(sig_table(int)), m_oTableView, SLOT(notify_table(int))); + + connect(m_oMediator, SIGNAL(sig_flag(int)), m_oCanvas, SLOT(notify_flag(int))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), m_oCanvas, SLOT(notify_select(const QList&, const QList&))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), ln, SLOT(notify_select(const QList&, const QList&))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), m_oDataView, SLOT(notify_select(const QList&, const QList&))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), m_oTextView, SLOT(notify_select(const QList&, const QList&))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), m_oVarsView, SLOT(notify_select(const QList&, const QList&))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), m_oImageView, SLOT(notify_select(const QList&, const QList&))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), m_oTableView, SLOT(notify_select(const QList&, const QList&))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), m_oDiagramView, SLOT(notify_select(const QList&, const QList&))); + connect(m_oMediator, SIGNAL(sig_select(const QList&, const QList&)), ln, SLOT(notify_select(const QList&, const QList&))); + + connect(m_oMediator, SIGNAL(sig_sort(int)), m_oCanvas, SLOT(notify_sort(int))); + connect(m_oMediator, SIGNAL(sig_sort(int)), ln, SLOT(notify_sort(int))); + + + connect(m_oMediator, SIGNAL(sig_datatype(int)), m_oDataView, SLOT(notify_datatype(int))); + + connect(m_oMediator, SIGNAL(sig_pic(int)), m_oCanvas, SLOT(notify_pic(int))); + connect(m_oMediator, SIGNAL(sig_pic(int)), m_oImageView, SLOT(notify_pic(int))); + + connect(m_oMediator, SIGNAL(sig_move(const QList&, const QList&)), m_oCanvas, SLOT(notify_move(const QList&, const QList&))); + + connect(m_oMediator, SIGNAL(sync_flags()), m_oCanvas, SLOT(sync_flags())); + connect(m_oMediator, SIGNAL(sync_colors()), m_oCanvas, SLOT(sync_colors())); connect(m_oImageView, SIGNAL(sig_message(const QString&, int)), this, SLOT(slot_message(const QString&, int))); - //qDebug()<<"instance is "<&)), m_oDiagramView, SLOT(notify_box_props(int, const QList&))); + connect(m_oMediator, SIGNAL(sig_pos_box(int, const QList&)), m_oDiagramView, SLOT(notify_pos_box(int, const QList&))); + connect(m_oMediator, SIGNAL(sig_size_box(int, const QList&)), m_oDiagramView, SLOT(notify_size_box(int, const QList&))); + connect(m_oMediator, SIGNAL(sig_focus(void *)), m_oDiagramView, SLOT(notify_focus(void *))); + connect(m_oMediator, SIGNAL(sig_focus(void *)), m_oCanvas, SLOT(notify_focus(void *))); - m_oControl->init_colors(); - m_oControl->init_flags(); + m_oTree->m_oView->addAction(m_oCanvas->m_oDeleteAction); // FIXME + + //qDebug()<<"instance is "<select_item(NO_ITEM); + m_oMediator->init_colors(); + m_oMediator->init_flags(); read_config(); statusBar()->showMessage(trUtf8("Welcome to Semantik"), 2000); setAutoSaveSettings(); - + connect(m_oMediator, SIGNAL(enable_undo(bool, bool)), this, SLOT(slot_enable_undo(bool, bool))); KTipDialog::showTip(this, notr("semantik/tips")); } @@ -323,8 +357,8 @@ m_oRecentFilesAct->loadEntries(KGlobal::config()->group(notr("Recent Files"))); move(l_oConfig.readEntry(notr("winpos"), QPoint(0, 0))); m_oCanvas->setBackgroundBrush(QColor(l_oConfig.readEntry(notr("bgcolor"), notr("#FFFDE8")))); - m_oControl->m_sOutDir = l_oConfig.readEntry(notr("outdir"), notr("/tmp/")); - bind_node::set_var(notr("outdir"), m_oControl->m_sOutDir); + m_oMediator->m_sOutDir = l_oConfig.readEntry(notr("outdir"), notr("/tmp/")); + bind_node::set_var(notr("outdir"), m_oMediator->m_sOutDir); //QString lang_code(config.readEntry("currentLanguageCode", QVariant(QString())).toString()); //if (lang_code.isEmpty()) lang_code = "en_US"; // null-string are saved as empty-strings @@ -349,6 +383,7 @@ void semantik_win::slot_print() { QPrinter *l_oP = new QPrinter; + //l_oP->setResolution(QPrinter::HighResolution); QPrintDialog l_oD(l_oP, m_oCanvas); if (l_oD.exec() == QDialog::Accepted) { @@ -360,6 +395,7 @@ bool semantik_win::slot_save_as() { + choose: KUrl l_o = KFileDialog::getSaveUrl(KUrl(notr("kfiledialog:///document")), trUtf8("*.sem|Semantik file (*.sem)"), this, trUtf8("Choose a file name")); @@ -370,16 +406,31 @@ l_o = KUrl(l_o.path()+notr(".sem")); } - if (m_oControl->save_file(l_o.path())) + if (m_oMediator->m_sLastSaved != l_o.path()) + { + if (l_o.isLocalFile() && QFile::exists(l_o.path())) + { + int mu = KMessageBox::questionYesNo(NULL, //this, + trUtf8("The file \"%1\" already exists.\nOverwrite it?").arg(l_o.path()), + trUtf8("Overwrite existing file"), + KStandardGuiItem::yes(), + KStandardGuiItem::no(), + notr("OverwriteExistingFile")); + if (!mu) + goto choose; + } + } + + if (m_oMediator->save_file(l_o.path())) { statusBar()->showMessage(trUtf8("Saved '%1'").arg(l_o.path()), 2000); - m_oControl->m_oCurrentUrl = l_o; + m_oMediator->m_oCurrentUrl = l_o; update_title(); return true; } else { - m_oControl->m_oCurrentUrl = KUrl(); + m_oMediator->m_oCurrentUrl = KUrl(); update_title(); } @@ -388,13 +439,13 @@ bool semantik_win::slot_save() { - if (m_oControl->m_sLastSaved.isEmpty()) + if (m_oMediator->m_sLastSaved.isEmpty()) { return slot_save_as(); } - if (m_oControl->save_file(m_oControl->m_sLastSaved)) + if (m_oMediator->save_file(m_oMediator->m_sLastSaved)) { - statusBar()->showMessage(trUtf8("Saved '%1'").arg(m_oControl->m_sLastSaved), 2000); + statusBar()->showMessage(trUtf8("Saved '%1'").arg(m_oMediator->m_sLastSaved), 2000); return true; } return false; @@ -402,32 +453,38 @@ void semantik_win::slot_open() { + if (m_oMediator->m_bDirty) + { + if (!proceed_save()) return; + } + KUrl l_o = KFileDialog::getOpenUrl(KUrl(notr("kfiledialog:///document")), trUtf8("*.sem *.kdi *.mm *.vym|All Supported Files (*.sem *.kdi *.mm *.vym)"), this, trUtf8("Choose a file name")); - if (l_o.isValid() && m_oControl->open_file(l_o.path())) - { - m_oControl->m_oCurrentUrl = l_o; - } - else + if (l_o.isValid() && m_oMediator->open_file(l_o.path())) { - m_oControl->m_oCurrentUrl = KUrl(); + m_oMediator->m_oCurrentUrl = l_o; } update_title(); } void semantik_win::update_title() { - if (m_oControl->m_oCurrentUrl.path().isEmpty()) + QString mod; + if (m_oMediator->m_bDirty) mod = trUtf8(" [Modified] "); + + QString txt; + if (m_oMediator->m_oCurrentUrl.path().isEmpty()) { - setWindowTitle(trUtf8("Semantik")); - return; + txt = trUtf8("Semantik %1").arg(mod); } + else + { + txt = trUtf8("%1 %2 - Semantik").arg(m_oMediator->m_oCurrentUrl.path(), mod); + m_oRecentFilesAct->addUrl(m_oMediator->m_oCurrentUrl); // TODO + } + setWindowTitle(txt); - QString mod; - if (m_oControl->m_bDirty) mod = trUtf8(" [Modified] "); - setWindowTitle(trUtf8("%1 %2 - Semantik").arg(m_oControl->m_oCurrentUrl.path(), mod)); - m_oRecentFilesAct->addUrl(m_oControl->m_oCurrentUrl); } void semantik_win::slot_properties() @@ -448,13 +505,13 @@ if (l_oGen.exec() == QDialog::Accepted) { - //m_oControl->m_iConnType = l_oGen.m_oConnType->currentIndex(); - //m_oControl->m_iReorgType = l_oGen.m_oReorgType->currentIndex(); - l_oSettings.writeEntry(notr("conn"), m_oControl->m_iConnType = l_oGen.m_oConnType->currentIndex()); - l_oSettings.writeEntry(notr("reorg"), m_oControl->m_iReorgType = l_oGen.m_oReorgType->currentIndex()); - l_oSettings.writeEntry(notr("auto"), m_oControl->m_iTimerValue = l_oGen.m_oAutoSave->value()); + //m_oMediator->m_iConnType = l_oGen.m_oConnType->currentIndex(); + //m_oMediator->m_iReorgType = l_oGen.m_oReorgType->currentIndex(); + l_oSettings.writeEntry(notr("conn"), m_oMediator->m_iConnType = l_oGen.m_oConnType->currentIndex()); + l_oSettings.writeEntry(notr("reorg"), m_oMediator->m_iReorgType = l_oGen.m_oReorgType->currentIndex()); + l_oSettings.writeEntry(notr("auto"), m_oMediator->m_iTimerValue = l_oGen.m_oAutoSave->value()); l_oSettings.writeEntry(notr("bgcolor"), l_oGen.m_oColor.name()); - m_oControl->init_timer(); + m_oMediator->init_timer(); m_oCanvas->setBackgroundBrush(l_oGen.m_oColor); } @@ -463,13 +520,13 @@ bool semantik_win::queryClose() { write_config(); - if (!m_oControl->m_bDirty) - { - //writeConfig(); - return true; - } + if (!m_oMediator->m_bDirty) return true; + return proceed_save(); +} - QString l_oTitle = m_oControl->m_sLastSaved; +bool semantik_win::proceed_save() +{ + QString l_oTitle = m_oMediator->m_sLastSaved; if (l_oTitle.isEmpty()) l_oTitle = trUtf8("Untitled"); int l_o = KMessageBox::warningYesNoCancel(NULL, //this, @@ -481,7 +538,7 @@ { case KMessageBox::Yes: return slot_save(); - case KMessageBox::No : + case KMessageBox::No: return true; default: return false; @@ -489,28 +546,19 @@ return false; } -void semantik_win::slot_tool_select() -{ - //qDebug()<<"slot tool select"<set_mode(canvas_view::select_mode); -} - -void semantik_win::slot_tool_link() -{ - //qDebug()<<"slot tool link"<set_mode(canvas_view::link_mode); -} - -void semantik_win::slot_tool_sort() +void semantik_win::slot_recent(const KUrl& i_oUrl) { - //qDebug()<<"slot tool sort"<set_mode(canvas_view::sort_mode); -} + if (i_oUrl.path().isEmpty()) return; + if (m_oMediator->m_bDirty) + { + if (!proceed_save()) return; + } -void semantik_win::slot_tool_scroll() -{ - //qDebug()<<"slot tool scroll"<set_mode(canvas_view::scroll_mode); + if (m_oMediator->open_file(i_oUrl.path())) + { + m_oMediator->m_oCurrentUrl = i_oUrl; + } + update_title(); } void semantik_win::slot_message(const QString & i_sMsg, int i_iDur) @@ -518,20 +566,15 @@ statusBar()->showMessage(i_sMsg, i_iDur); } -void semantik_win::slot_recent(const KUrl& i_oUrl) -{ - if (i_oUrl.path().isEmpty()) return; - if (m_oControl->open_file(i_oUrl.path())) - { - m_oControl->m_oCurrentUrl = i_oUrl; - } - update_title(); -} - void semantik_win::slot_tip_of_day() { KTipDialog::showTip(this, notr("semantik/tips"), true); } +void semantik_win::slot_enable_undo(bool undo, bool redo) { + m_oUndoAct->setEnabled(undo); + m_oRedoAct->setEnabled(redo); +} + #include "semantik.moc" diff -Nru semantik-0.7.3/src/semantik.h semantik-0.8.3/src/semantik.h --- semantik-0.7.3/src/semantik.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/semantik.h 2012-10-21 10:09:17.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 %: ifndef SEMANTIK_H #define SEMANTIK_H @@ -33,7 +33,7 @@ class data_view; class pre_view; class linear_container; -class data_control; +class sem_mediator; // THE DOC PROPERTIES HAVE BEEN MOVED INTO THE VARS VIEW (when no item is selected) @@ -55,7 +55,7 @@ box_view *m_oDiagramView; linear_container *m_oTree; - data_control *m_oControl; + sem_mediator *m_oMediator; vars_view *m_oVarsView; pre_view *m_oPreView; @@ -66,18 +66,20 @@ //void update_color_scheme(); KAction *m_oReorgAct; + KAction *m_oExportSizeAct; KAction *m_oDocPropsAct; KAction *m_oConfPropsAct; KAction *m_oGenerateAct; KAction *m_oCanvasFitZoom; + KAction *m_oUndoAct; + KAction *m_oRedoAct; KToolBar *m_oEditToolBar; KToolBar *m_oColorsToolBar; KToolBar *m_oFlagsToolBar; KMenu *m_oToolsMenu; QAction *m_oSelectAct; - QAction *m_oLinkAct; QAction *m_oSortAct; QAction *m_oScrollAct; @@ -95,6 +97,7 @@ QString m_sFileName; bool queryClose(); + bool proceed_save(); public slots: void update_title(); @@ -106,10 +109,7 @@ void slot_recent(const KUrl &); - void slot_tool_select(); - void slot_tool_link(); - void slot_tool_sort(); - void slot_tool_scroll(); + void slot_enable_undo(bool, bool); void slot_properties(); diff -Nru semantik-0.7.3/src/sembind.cpp semantik-0.8.3/src/sembind.cpp --- semantik-0.7.3/src/sembind.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/sembind.cpp 2012-09-17 21:01:39.000000000 +0000 @@ -1,28 +1,30 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 +#include #include #include #include "data_item.h" #inclu\ -de "data_control.h" +de "sem_mediator.h" #include "con.h" #include "sembind.h" +#include "sem_mediator.h" bind_node* bind_node::_root = NULL; +sem_mediator * bind_node::_model = NULL; +QHash bind_node::_cache = QHash(); +QMap bind_node::s_oResults = QMap(); QMap bind_node::s_oVars = QMap(); bind_node::bind_node() { + m_oItem = NULL; } bind_node::~bind_node() { - foreach (bind_node *l_o, _children) - { - delete l_o; - } } int bind_node::child_count() @@ -91,20 +93,48 @@ } else if (i_s == notr("tree_size")) { - return QString::number(m_oItem->m_oControl->size_of(m_oItem->m_iId)); + return QString::number(m_oItem->m_oMediator->size_of(m_oItem->m_iId)); } else if (i_s == notr("pic_w")) { - return QString::number(m_oItem->m_oPix.width()); + return QString::number(m_oItem->getPix().width()); } else if (i_s == notr("pic_h")) { - return QString::number(m_oItem->m_oPix.height()); + return QString::number(m_oItem->getPix().height()); } else if (i_s == notr("type")) { return QString::number(m_oItem->m_iDataType); } + else if (i_s == notr("pic_id")) + { + return QString::number(m_oItem->m_iPicId); + } + else if (i_s == notr("x")) + { + return QString::number(m_oItem->m_iXX); + } + else if (i_s == notr("y")) + { + return QString::number(m_oItem->m_iYY); + } + else if (i_s == notr("w")) + { + return QString::number(m_oItem->m_iWW); + } + else if (i_s == notr("h")) + { + return QString::number(m_oItem->m_iHH); + } + else if (i_s == notr("widthHint")) + { + return QString::number(m_oItem->m_iObjectWidthHint); + } + else if (i_s == notr("heightHint")) + { + return QString::number(m_oItem->m_iObjectHeightHint); + } return ""; } @@ -120,9 +150,9 @@ QString bind_node::tbl_cell(int row, int col) { - foreach(data_table_item l_o, m_oItem->m_oTableData) - { - if (l_o.m_iRow == row && l_o.m_iCol == col) return l_o.m_sText; + QPair l_o; + foreach(l_o, m_oItem->m_oTableData.keys()) { + if (l_o.first == row && l_o.second == col) return m_oItem->m_oTableData[l_o]; } return ""; } @@ -169,3 +199,64 @@ return l_oHandler.m_oTotale.join(""); } +QString bind_node::get_item_ids() +{ + Q_ASSERT(_model != NULL); + QStringList lst; + foreach (int id, _model->m_oItems.keys()) { + lst << QString::number(id); + } + return lst.join(","); +} + +bind_node* bind_node::get_item_by_id(int id) +{ + Q_ASSERT(_model != NULL); + bind_node *l_oNode = _cache.value(id); + if (l_oNode) return l_oNode; + l_oNode = _cache[id] = new bind_node(); + l_oNode->m_oItem = _model->m_oItems.value(id); + Q_ASSERT(l_oNode != NULL); + return l_oNode; +} + + +bind_node* bind_node::create_tree(sem_mediator *model, int i_i) +{ + Q_ASSERT(i_i!=0); + bind_node * l_oNode = new bind_node(); + l_oNode->m_oItem = model->m_oItems.value(i_i); + + for (int i=0; i < model->m_oLinks.size(); i++) + { + QPoint l_oP = model->m_oLinks.at(i); + if (l_oP.x() != i_i) continue; + + bind_node *l_oNew = create_tree(model, l_oP.y()); + l_oNode->_children.push_back(l_oNew); + } + _cache[i_i] = l_oNode; + Q_ASSERT(l_oNode != NULL); + return l_oNode; +} + +void bind_node::init(sem_mediator* med) +{ + // delete any node in the cache + foreach (int k, _cache.keys()) + { + bind_node * node = bind_node::_cache.take(k); + delete node; + } + + Q_ASSERT(_cache.size() == 0); + + bind_node::_model = med; + bind_node::s_oVars.clear(); +} + +void bind_node::set_result(const QString& k, const QString& v) +{ + s_oResults[k] = v; +} + diff -Nru semantik-0.7.3/src/sembind.h semantik-0.8.3/src/sembind.h --- semantik-0.7.3/src/sembind.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/sembind.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,12 +1,14 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef BIND_NODE_H #define BIND_NODE_H #include #include +#include class data_item; +class sem_mediator; class bind_node { public: @@ -14,6 +16,10 @@ static QString get_var(const QString &); static void set_var(const QString &, const QString &); + static void set_result(const QString &, const QString &); + + static QString get_item_ids(); + static bind_node* get_item_by_id(int i); // tree manipulation int child_count(); @@ -39,10 +45,15 @@ //protected: + static void init(sem_mediator*); + static bind_node* create_tree(sem_mediator *model, int i_i); bind_node(); ~bind_node(); static QMap s_oVars; + static QMap s_oResults; static bind_node* _root; + static QHash _cache; + static sem_mediator* _model; QList _children; data_item *m_oItem; }; diff -Nru semantik-0.7.3/src/sembind.py semantik-0.8.3/src/sembind.py --- semantik-0.7.3/src/sembind.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/sembind.py 2012-09-05 01:08:33.000000000 +0000 @@ -1,7 +1,9 @@ #! /usr/bin/env python # encoding: utf-8 -# Thomas Nagy, 2007-2008 (ita) +# Thomas Nagy, 2007-2012 +from sgmllib import SGMLParser +import htmlentitydefs import sys, sembind, re protectXML = sembind.protectXML @@ -36,6 +38,96 @@ tmp[lst[0]] = "=".join(lst[1:]) return tmp +class TrucProcessor(SGMLParser): + def reset(self): + self.pieces = [] + self.state = "" + self.buf = "" + self.inli = 0 + SGMLParser.reset(self) + + def unknown_starttag(self, tag, attrs): + if tag == 'ul': + if self.inli and self.buf: + self.pieces.append('\\item ') + self.pieces.append(tex_convert(self.buf)) + self.pieces.append('\n') + self.pieces.append('\\begin{itemize}\n') + + if tag == 'li': + self.inli += 1 + + self.buf = "" + + def unknown_endtag(self, tag): + if tag == 'p': + self.pieces.append(tex_convert(self.buf)) + self.pieces.append('\n') + elif tag == 'li': + if self.buf: + self.pieces.append('\\item ') + self.pieces.append(tex_convert(self.buf)) + self.pieces.append('\n') + self.inli -= 1 + elif tag == 'ul': + self.pieces.append('\\end{itemize}\n') + + def handle_charref(self, ref): + self.pieces.append("&#%(ref)s;" % locals()) + + def handle_data(self, text): + self.buf = text + + def output(self): + return "".join(self.pieces) + +def parse_string(s): + parser = TrucProcessor() + parser.feed(s) + parser.close() + return parser.output() + +class RichProcessor(SGMLParser): + def reset(self): + self.pieces = [] + self.state = "" + self.buf = "" + self.inli = 0 + SGMLParser.reset(self) + + def unknown_starttag(self, tag, attrs): + if tag == 'ul': + self.inli += 1 + self.buf = "" + + def unknown_endtag(self, tag): + if tag == 'p': + self.pieces.append(self.buf) + self.pieces.append('\n') + elif tag == 'li': + if self.buf: + self.pieces.append(' ' * self.inli) + self.pieces.append(self.buf) + self.pieces.append('\n') + elif tag == 'ul': + self.inli -= 1 + + def handle_charref(self, ref): + self.pieces.append("&#%(ref)s;" % locals()) + + def handle_data(self, text): + self.buf = text + + def output(self): + return "".join(self.pieces) + +def clear_html(s): + parser = RichProcessor() + parser.feed(s) + parser.close() + return parser.output() + + def template_dir(): return sembind.get_var('template_dir') #TEMPLATE_DIR = sembind.get_var('template_dir') @@ -129,10 +221,9 @@ def debug(x): try: #sys.stderr.write(x.__repr__()) - sys.stderr.write(x) - sys.stderr.write("\n") + sys.stderr.write("%s\n" % x) except: - debug("erreur d'encodage de utf8 ? :-/") + debug("erreur d'encodage utf8 ? :-/") def protect_tex(s): lst = [] @@ -152,7 +243,16 @@ else: lst.append(x) return "".join(lst) -class Node: +def compute_hints(x): + k = int(x) + item = sembind.get_item_by_id(int(x)) + if item: + m = read_properties(sembind.get_val(item, "hints")) + sembind.set_result("diagram_width", m.get('diagram_width', '0')) + sembind.set_result("diagram_height", m.get('diagram_height', '0')) + + +class Node(object): def __init__(self, bind): if not bind: debug("error!! node takes a parameter") diff -Nru semantik-0.7.3/src/sembind_py.cpp semantik-0.8.3/src/sembind_py.cpp --- semantik-0.7.3/src/sembind_py.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/sembind_py.cpp 2012-10-21 10:09:17.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include @@ -12,6 +12,7 @@ { QByteArray l_b = i_s.toUtf8(); PyObject *l_o = PyString_FromStringAndSize(l_b.data(), l_b.size()); + Py_XINCREF(l_o); return l_o; } @@ -29,11 +30,10 @@ int l_iSize = PyString_Size(i_o); char * l_iChars = PyString_AsString(i_o); - //qDebug()< #include diff -Nru semantik-0.7.3/src/table_dialog.h semantik-0.8.3/src/table_dialog.h --- semantik-0.7.3/src/table_dialog.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/table_dialog.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef TABLE_DIALOG_H #define TABLE_DIALOG_H diff -Nru semantik-0.7.3/src/table_view.cpp semantik-0.8.3/src/table_view.cpp --- semantik-0.7.3/src/table_view.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/table_view.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -7,33 +7,38 @@ #include #include +#include "con.h" #include "table_dialog.h" #include "data_item.h" -#include "data_control.h" +#include "sem_mediator.h" #include "table_view.h" -table_view::table_view(QWidget *i_oParent, data_control *i_oControl) : QTableWidget(0, 0, i_oParent) +numbered_action::numbered_action(QString x, QWidget *y) : QAction(x, y) { + +} + +table_view::table_view(QWidget *i_oParent, sem_mediator *i_oControl) : QTableWidget(0, 0, i_oParent) { - m_oControl = i_oControl; - m_bFreeze = 0; + m_oMediator = i_oControl; + m_bFreeze = false; - m_oAddRowAct = new QAction(trUtf8("Add Row"), this); + m_oAddRowAct = new numbered_action(trUtf8("Add Row"), this); m_oAddRowAct->setStatusTip(trUtf8("Add a row")); connect(m_oAddRowAct, SIGNAL(triggered()), this, SLOT(add_row())); insertAction(0, m_oAddRowAct); - m_oAddColAct = new QAction(trUtf8("Add Column"), this); + m_oAddColAct = new numbered_action(trUtf8("Add Column"), this); m_oAddColAct->setStatusTip(trUtf8("Add a column")); connect(m_oAddColAct, SIGNAL(triggered()), this, SLOT(add_column())); insertAction(0, m_oAddColAct); - m_oRmRowAct = new QAction(trUtf8("Remove Row"), this); + m_oRmRowAct = new numbered_action(trUtf8("Remove Row"), this); m_oRmRowAct->setStatusTip(trUtf8("Remove a row")); connect(m_oRmRowAct, SIGNAL(triggered()), this, SLOT(rm_row())); insertAction(0, m_oRmRowAct); - m_oRmColAct = new QAction(trUtf8("Remove Column"), this); + m_oRmColAct = new numbered_action(trUtf8("Remove Column"), this); m_oRmColAct->setStatusTip(trUtf8("Remove a column")); connect(m_oRmColAct, SIGNAL(triggered()), this, SLOT(rm_column())); insertAction(0, m_oRmColAct); @@ -52,46 +57,6 @@ connect(this, SIGNAL(cellChanged(int, int)), this, SLOT(cell_changed(int, int))); } -void table_view::synchro_doc(const hash_params& i_o) -{ - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) - { - case cmd_select_item: - { - m_iId = i_o[data_id].toInt(); - setEnabled(m_iId > NO_ITEM); - - if (m_iId > NO_ITEM) - { - m_bFreeze = 1; - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - - Q_ASSERT(l_oData!=NULL); - - setRowCount(l_oData->m_iNumRows); - setColumnCount(l_oData->m_iNumCols); - - foreach(data_table_item l_o, l_oData->m_oTableData) - { - QTableWidgetItem *l_oItem = new QTableWidgetItem(); - l_oItem->setText(l_o.m_sText); - setItem(l_o.m_iRow, l_o.m_iCol, l_oItem); - } - m_bFreeze = 0; - } - else - { - setRowCount(0); - setColumnCount(0); - } - } - break; - default: - break; - } -} - void table_view::mousePressEvent(QMouseEvent *i_oEv) { if (i_oEv->button() == Qt::RightButton) @@ -100,6 +65,22 @@ m_oRmColAct->setEnabled(l_b); m_oRmRowAct->setEnabled(l_b); + QTableWidgetItem *t = itemAt(i_oEv->pos()); + int i = 0; + int j = 0; + if (t != NULL) + { + i = t->row(); + j = t->column(); + } + m_oRmColAct->row = m_oRmRowAct->row = m_oAddRowAct->row = m_oAddColAct->row = i; + m_oRmColAct->col = m_oRmRowAct->col = m_oAddRowAct->col = m_oAddColAct->col = j; + + m_oAddRowAct->setText(QString("%1 (%2)").arg(trUtf8("Add Row"), QString::number(i))); + m_oAddColAct->setText(QString("%1 (%2)").arg(trUtf8("Add Column"), QString::number(j))); + m_oRmRowAct->setText(QString("%1 (%2)").arg(trUtf8("Remove Row"), QString::number(i))); + m_oRmColAct->setText(QString("%1 (%2)").arg(trUtf8("Remove Column"), QString::number(j))); + QMenu::exec(actions(), i_oEv->globalPos()); } else @@ -110,57 +91,139 @@ void table_view::cell_changed(int i_iRow, int i_iCol) { - Q_ASSERT(m_iId>NO_ITEM); if (m_bFreeze) return; + Q_ASSERT(m_iId != NO_ITEM); QString l_sText; QTableWidgetItem *l_oItem = item(i_iRow, i_iCol); if (l_oItem) l_sText = l_oItem->text(); else l_sText = ""; - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - for (QList::iterator l_oIt = l_oData->m_oTableData.begin(); l_oIt != l_oData->m_oTableData.end(); ++l_oIt) + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + QHash, QString> changed; + + for (int i=0; i < rowCount(); ++i) { - data_table_item& l_o = *l_oIt; - if (l_o.m_iRow == i_iRow && l_o.m_iCol == i_iCol) + for (int j=0; j < columnCount(); ++j) { - l_o.m_sText = l_sText; - return; + changed[QPair(i, j)] = l_oData->m_oTableData[QPair(i, j)]; } } - data_table_item l_o; - l_o.m_iRow = i_iRow; - l_o.m_iCol = i_iCol; - l_o.m_sText = l_sText; - l_oData->m_oTableData.push_back(l_o); + changed[QPair(i_iRow, i_iCol)] = l_sText; + + mem_table *tmp = new mem_table(m_oMediator); + tmp->m_iId = m_iId; + tmp->oldNRows = tmp->newNRows = l_oData->m_iNumRows; + tmp->oldNCols = tmp->newNCols = l_oData->m_iNumCols; + tmp->oldData = l_oData->m_oTableData; + tmp->newData = changed; + tmp->apply(); } void table_view::add_row() { - insertRow(0); - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - l_oData->m_iNumRows = rowCount(); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + QHash, QString> changed; + for (int i=0; i < rowCount() + 1; ++i) + { + int ii = i; + if (ii >= m_oAddRowAct->row) ii++; + for (int j=0; j < columnCount(); ++j) + { + changed[QPair(m_oAddRowAct->row, j)] = ""; + changed[QPair(ii, j)] = l_oData->m_oTableData[QPair(i, j)]; + } + } + + mem_table *tmp = new mem_table(m_oMediator); + tmp->m_iId = m_iId; + tmp->oldNRows = l_oData->m_iNumRows; + tmp->oldNCols = l_oData->m_iNumCols; + tmp->newNRows = rowCount() + 1; + tmp->newNCols = columnCount(); + tmp->oldData = l_oData->m_oTableData; + tmp->newData = changed; + tmp->apply(); } void table_view::add_column() { - insertColumn(0); - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - l_oData->m_iNumCols = columnCount(); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + QHash, QString> changed; + for (int i=0; i < rowCount(); ++i) + { + for (int j=0; j < columnCount() + 1; ++j) + { + int jj = j; + if (jj >= m_oAddRowAct->col) jj++; + + changed[QPair(i, m_oAddRowAct->col)] = ""; + changed[QPair(i, jj)] = l_oData->m_oTableData[QPair(i, j)]; + } + } + + mem_table *tmp = new mem_table(m_oMediator); + tmp->m_iId = m_iId; + tmp->oldNRows = l_oData->m_iNumRows; + tmp->oldNCols = l_oData->m_iNumCols; + tmp->newNRows = rowCount(); + tmp->newNCols = columnCount() + 1; + tmp->oldData = l_oData->m_oTableData; + tmp->newData = changed; + tmp->apply(); } void table_view::rm_row() { - removeRow(0); - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - l_oData->m_iNumRows = rowCount(); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + QHash, QString> changed; + for (int i=0; i < rowCount(); ++i) + { + int ii = i; + if (ii == m_oRmRowAct->row) continue; + if (ii > m_oRmRowAct->row) ii--; + for (int j=0; j < columnCount(); ++j) + { + changed[QPair(ii, j)] = l_oData->m_oTableData[QPair(i, j)]; + } + } + + mem_table *tmp = new mem_table(m_oMediator); + tmp->m_iId = m_iId; + tmp->oldNRows = l_oData->m_iNumRows; + tmp->oldNCols = l_oData->m_iNumCols; + tmp->newNRows = rowCount() - 1; + tmp->newNCols = columnCount(); + tmp->oldData = l_oData->m_oTableData; + tmp->newData = changed; + tmp->apply(); } void table_view::rm_column() { - removeColumn(0); - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - l_oData->m_iNumCols = columnCount(); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + QHash, QString> changed; + for (int i=0; i < rowCount(); ++i) + { + for (int j=0; j < columnCount(); ++j) + { + int jj = j; + if (jj == m_oRmRowAct->col) continue; + if (jj > m_oAddRowAct->col) jj--; + + changed[QPair(i, jj)] = l_oData->m_oTableData[QPair(i, j)]; + } + } + + mem_table *tmp = new mem_table(m_oMediator); + tmp->m_iId = m_iId; + tmp->oldNRows = l_oData->m_iNumRows; + tmp->oldNCols = l_oData->m_iNumCols; + tmp->newNRows = rowCount(); + tmp->newNCols = columnCount() - 1; + tmp->oldData = l_oData->m_oTableData; + tmp->newData = changed; + tmp->apply(); } void table_view::resize_table() @@ -170,26 +233,79 @@ l_oGen.m_oCols->setValue(columnCount()); if (l_oGen.exec() == QDialog::Accepted) { - setRowCount(l_oGen.m_oRows->value()); - setColumnCount(l_oGen.m_oCols->value()); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + mem_table *tmp = new mem_table(m_oMediator); + tmp->m_iId = m_iId; + tmp->oldNRows = l_oData->m_iNumRows; + tmp->oldNCols = l_oData->m_iNumCols; + tmp->newNRows = l_oGen.m_oRows->value(); + tmp->newNCols = l_oGen.m_oCols->value(); + tmp->oldData = tmp->newData = l_oData->m_oTableData; + tmp->apply(); + } +} + +void table_view::notify_table(int id) +{ + if (m_bFreeze) + { + return; + } + m_bFreeze = true; - if (m_iId>NO_ITEM) + data_item *l_oData = m_oMediator->m_oItems.value(id); + + if (l_oData->m_iNumRows != rowCount() || l_oData->m_iNumCols != columnCount()) + { + setRowCount(l_oData->m_iNumRows); + setColumnCount(l_oData->m_iNumCols); + } + + QPair t; + foreach (t, l_oData->m_oTableData.keys()) + { + QTableWidgetItem *it = item(t.first, t.second); + if (!it) { - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - l_oData->m_iNumRows = rowCount(); - l_oData->m_iNumCols = columnCount(); + it = new QTableWidgetItem(); + setItem(t.first, t.second, it); + } + it->setText(l_oData->m_oTableData[t]); + } + repaint(); + m_bFreeze = false; +} + +void table_view::notify_select(const QList& unsel, const QList& sel) +{ + m_bFreeze = true; + + bool one = (sel.size() == 1); + if (one) { + m_iId = sel.at(0); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); - for (int i=0; im_oTableData.size(); ++i) + Q_ASSERT(l_oData!=NULL); + + setRowCount(l_oData->m_iNumRows); + setColumnCount(l_oData->m_iNumCols); + + for (int i=0; i < rowCount(); ++i) + { + for (int j=0; j < columnCount(); ++j) { - data_table_item l_o = l_oData->m_oTableData.at(i); - if (l_o.m_iRow >= rowCount() && l_o.m_iCol >= columnCount()) - { - l_oData->m_oTableData.removeAt(i); - i--; - } + QTableWidgetItem *l_oItem = new QTableWidgetItem(); + l_oItem->setText(l_oData->m_oTableData[QPair(i, j)]); + setItem(i, j, l_oItem); } } + } else { + m_iId = NO_ITEM; + setRowCount(0); + setColumnCount(0); } + repaint(); + m_bFreeze = false; } #include "table_view.moc" diff -Nru semantik-0.7.3/src/table_view.h semantik-0.8.3/src/table_view.h --- semantik-0.7.3/src/table_view.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/table_view.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef TABLE_VIEW_H #define TABLE_VIEW_H @@ -8,32 +8,44 @@ #in\ clude "con.h" +#include +#include + +class numbered_action : public QAction +{ + public: + numbered_action(QString, QWidget*); + int row; + int col; +}; + class table_view : public QTableWidget { Q_OBJECT public: - table_view(QWidget *i_oParent, data_control *i_oControl); - data_control *m_oControl; + table_view(QWidget *i_oParent, sem_mediator *i_oControl); + sem_mediator *m_oMediator; void mousePressEvent(QMouseEvent *i_oEv); int m_iId; - QAction *m_oRmRowAct; - QAction *m_oRmColAct; - QAction *m_oAddRowAct; - QAction *m_oAddColAct; + numbered_action *m_oRmRowAct; + numbered_action *m_oRmColAct; + numbered_action *m_oAddRowAct; + numbered_action *m_oAddColAct; bool m_bFreeze; public slots: - void synchro_doc(const hash_params&); void rm_row(); void rm_column(); void add_row(); void add_column(); void resize_table(); void cell_changed(int i_iRow, int i_iCol); + void notify_select(const QList& unsel, const QList& sel); + void notify_table(int id); }; #endif diff -Nru semantik-0.7.3/src/template_entry.cpp semantik-0.8.3/src/template_entry.cpp --- semantik-0.7.3/src/template_entry.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/template_entry.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include "template_entry.h" diff -Nru semantik-0.7.3/src/template_entry.h semantik-0.8.3/src/template_entry.h --- semantik-0.7.3/src/template_entry.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/template_entry.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef TEMPLATE_ENTRY_H #define TEMPLATE_ENTRY_H diff -Nru semantik-0.7.3/src/templates/beamer/main.tex semantik-0.8.3/src/templates/beamer/main.tex --- semantik-0.7.3/src/templates/beamer/main.tex 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/beamer/main.tex 2012-09-17 21:01:39.000000000 +0000 @@ -35,10 +35,9 @@ % math extension - one probably wants to use symbols like '[' (written as '$[$') - +#ifdef @each_subsection_off@ % Delete this, if you do not want the table of contents to pop up at % the beginning of each subsection: -#ifdef @each_subsection_off@ \AtBeginSubsection[] { \begin{frame} @@ -48,10 +47,11 @@ } #endif +#ifdef @uncover_stepwise@ % If you wish to uncover everything in a step-wise fashion, uncomment % the following command: - \beamerdefaultoverlayspecification{<+->} +#endif #ifndef @doc_title_off@ \title{@doc_title@} @@ -65,6 +65,8 @@ \author{@doc_author@} #endif +\institute{@doc_company@} + \begin{document} #ifndef @doc_title_off@ diff -Nru semantik-0.7.3/src/templates/beamer/wscript semantik-0.8.3/src/templates/beamer/wscript --- semantik-0.7.3/src/templates/beamer/wscript 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/beamer/wscript 2012-09-05 01:08:33.000000000 +0000 @@ -11,45 +11,35 @@ $ waf --view ''' -import os, Options - VERSION = '0.0.1' -APPNAME = 'test' +APPNAME = 'the_docs' -srcdir = '.' -blddir = 'build' +top = '.' -def build(bld) : - bld.new_task_gen(features='tex', type='pdflatex', source='main.tex') +import os + +def options(opt): + opt.add_option('--view', action='store_true', default=False, help='View the document') -def configure(configuration): - configuration.check_tool('tex') - lat = configuration.env['LATEX'] +def configure(conf): + conf.load('tex') cwd = os.getcwd() cc = cwd + '/beamermindist/' + conf.find_program(['okular', 'kpdf', 'xpdf', 'gnome-open'], var='VIEW', mandatory=False) + lst = [] for x in "themes/color themes/font themes/inner themes/outer themes/theme art".split(): lst.append(cc+x) u = ":".join(lst) + conf.env.LATEX = "; export TEXINPUTS=%s:$TEXINPUTS; export GS_OPTIONS=\"-sPAPERSIZE=a4\"; %s" % (u, conf.env.LATEX) - configuration.env['LATEX'] = "; export TEXINPUTS=%s:$TEXINPUTS; export GS_OPTIONS=\"-sPAPERSIZE=a4\"; %s" % (u, lat) - +def build(bld) : + bld(features='tex', type='pdflatex', source='main.tex') -def set_options(options): - options.add_option('--view', action='store_true', default=False, help='View the document') + def view(ctx): + ctx.exec_command('%s build/main.pdf' % ctx.env.VIEW) -def shutdown(): - def exists(cmd): - try: - txt = os.popen("which %s 2>/dev/null "%cmd).read().strip() - return len(txt)>=len(cmd) - except: - return None - - if Options.options.view: - for i in ["kpdf", "gnome-open", "xpdf"]: - if exists(i): - os.popen("%s build/default/main.pdf" % i) - break + if bld.env.VIEW and bld.options.view: + bld.add_post_fun(view) diff -Nru semantik-0.7.3/src/templates/beamer.sem.py semantik-0.8.3/src/templates/beamer.sem.py --- semantik-0.7.3/src/templates/beamer.sem.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/beamer.sem.py 2012-09-17 21:01:39.000000000 +0000 @@ -1,20 +1,21 @@ #sem:name: Beamer presentation #sem:tip: Generates a LaTeX presentation using Beamer -# Thomas Nagy, 2007 (ita) -import os, shutil, time, StringIO -from sgmllib import SGMLParser -import htmlentitydefs +# Thomas Nagy, 2007-2012 + +import os, shutil, time, StringIO, sys +import getpass outdir = sembind.get_var('outdir')+'/'+sembind.get_var('pname') settings = { +'all_latex': False, 'doc_date':'', 'doc_content':'', -'doc_title':'How i did it', -'doc_author':'Krusty', +'doc_title':'', +'doc_author':getpass.getuser(), 'doc_place':'Los angeles', -'doc_company':'World company', +'doc_company':'World Company', 'theme':'Warsaw', 'babel':'english', # frenchb @@ -29,6 +30,7 @@ 'doc_author':'', 'doc_author_off':'None', +'uncover_stepwise': '', 'each_subsection_off':'None', 'doc_tableofcontents_off':'None', @@ -54,62 +56,25 @@ os.chdir(sembind.get_var('temp_dir')) pics = {} # map the id to the picture lst = os.listdir('.') -for i in lst: - if -1 == i.rfind('pic-'): continue - pics[ i.replace('pic-', '').split('.')[0] ] = i - shutil.copy2(i, outdir) +for x in lst: + if x.startswith('diag-'): + key = x.split('.')[0].replace('diag-', '') + if x.endswith('.pdf') or not key in pics: + pics[key] = x + shutil.copy2(x, outdir) os.chdir(cwd) buf = [] out = buf.append -class TrucProcessor(SGMLParser): - def reset(self): - self.pieces = [] - self.state = "" - self.buf = "" - self.inli = 0 - SGMLParser.reset(self) - - def unknown_starttag(self, tag, attrs): - if tag == 'ul': - if self.inli and self.buf: - self.pieces.append('\\item ') - self.pieces.append(self.buf) - self.pieces.append('\n') - self.pieces.append('\\begin{itemize}\n') - - if tag == 'li': - self.inli += 1 - - self.buf = "" - - def unknown_endtag(self, tag): - if tag == 'p': - self.pieces.append(self.buf) - self.pieces.append('\n') - elif tag == 'li': - if self.buf: - self.pieces.append('\\item ') - self.pieces.append(self.buf) - self.pieces.append('\n') - self.inli -= 1 - elif tag == 'ul': - self.pieces.append('\\end{itemize}\n') - - def handle_charref(self, ref): - self.pieces.append("&#%(ref)s;" % locals()) - - def handle_data(self, text): - self.buf = text - - def output(self): - return "".join(self.pieces) - def print_slide(node, niv): txt = tex_convert(node.get_val('summary')) + if niv == 0: + + num = node.child_count() + out('%-------------------------------------------------------------------\n') out('\\begin{frame}\n') out('\\frametitle{%s}\n\n' % txt) @@ -121,6 +86,7 @@ out("\\end{itemize}\n") out('\\end{frame}\n') out('%-------------------------------------------------------------------\n') + elif niv < 3: if txt: out('\\item %s\n' % txt) num = node.child_count() @@ -141,6 +107,83 @@ for i in range(num): print_slide(node.child_num(i), niv+1) +diagrams_added = set([]) # prevent accidents +def print_figure_slides(node, recurse=False): + typo = node.get_val('type') + if typo in ['table', 'diag', 'img'] and node.get_val("id") not in diagrams_added: + diagrams_added.add(node.get_val("id")) + # TODO what to do with the text? + #if typo == 'text': + # y = node.get_val('text') + # out(parse_string(y)) + + txt = tex_convert(node.get_val('summary')) + out('%-------------------------------------------------------------------\n') + out('\\begin{frame}\n') + out('\\frametitle{%s}\n\n' % txt) + + if typo == 'table': + rows = node.num_rows() + cols = node.num_cols() + if rows>0 and cols>0: + + caption = node.get_var('caption') + if not caption: caption = caption = node.get_val('summary') + + out('\\begin{table}\n') + + out('\\begin{center}\n') + out('\\begin{tabular}{|%s}' % ('c|'*cols)) + out(' \\hline\n') + for i in range(rows): + for j in range(cols): + if i == 0 or j == 0: + out('\\textbf{%s}' % tex_convert(node.get_cell(i, j))) + else: + out('%s' % tex_convert(node.get_cell(i, j))) + if j < cols - 1: out(" & ") + out(' \\\\ \\hline\n') + out('\\end{tabular}\n') + out('\\end{center}\n') + + out('\\caption{%s}\n' % tex_convert(caption)) + out('\\end{table}\n') + + out('\n') + + elif typo == 'img' or typo == 'diag': + id = node.get_val('id') + if id in pics: + + caption = node.get_var('caption') + if not caption: caption = caption = node.get_val('summary') + + restrict = node.get_var("picdim") + if not restrict: + w = int(node.get_val('pic_w')) + restrict = "" + if (w > 5*72): restrict = "[width=5in]" + if not restrict: + restrict = "[width=0.8\\textwidth,height=0.7\\textheight,keepaspectratio]" + + out('\\begin{figure}[htbp]\n') + out(' \\begin{center}\n') + out(' \\includegraphics%s{%s}\n' % (restrict, pics[id])) + out(' \\caption{\\footnotesize{%s}}\n' % tex_convert(caption)) + out('%% %s\n' % protect_tex(node.get_val('pic_location'))) + out('%% %s\n' % node.get_val('pic_w')) + out('%% %s\n' % node.get_val('pic_h')) + out(' \\end{center}\n') + out('\\end{figure}\n') + + out('\\end{frame}\n') + out('%-------------------------------------------------------------------\n') + + num = node.child_count() + for i in range(num): + print_figure_slides(node.child_num(i)) + #print_figure_slides(root, recurse=False) + def print_nodes(node, niv): num = node.child_count() @@ -155,36 +198,25 @@ elif niv == 1 and num >= 1: out('\\subsection{%s}\n' % sm) - if int(subtree.get_val('tree_size')) < 10: - print_slide(subtree, 0); - elif niv == 0: - print_nodes(subtree, 1) - elif niv == 1: - print_nodes(subtree, 2) - else: - sys.stderr.write("transforming this map into slides makes kitten cry") - -# rows = node.num_rows() -# cols = node.num_cols() -# if rows>0 and cols>0: -# out('\n') -# out('\n') -# out('\n') -# for i in range(rows): -# out('\t\n') -# for j in range(cols): -# if i>0 and j>0: -# out('\t\t\n' % x(node.get_cell(i, j))) -# else: -# out('\t\t\n' % x(node.get_cell(i, j))) -# out('\t\n') -# -# out('\n') -# out('
    %s%s
    \n') -# out('\n') + if subtree.child_count() > 0: + if int(subtree.get_val('tree_size')) < 16: + print_slide(subtree, 0); + print_figure_slides(subtree, True) + elif niv == 0: + print_nodes(subtree, 1) + print_figure_slides(subtree) + elif niv == 1: + print_nodes(subtree, 2) + print_figure_slides(subtree) + else: + print_figure_slides(subtree, True) + sys.stderr.write("transforming this map into slides makes kitten cry") # the main document -print_nodes(Root(), 0); +root = Root() +if not settings['doc_title']: + settings['doc_title'] = root.get_val('summary') +print_nodes(root, 0); settings['doc_content'] = "".join(buf) # now write main.tex @@ -199,6 +231,13 @@ shutil.copy2(template_dir()+'/waf', outdir+'/waf') os.chmod(outdir+'/waf', 0755) +f = open(outdir + '/run.sh', 'w') +try: + f.write('#! /bin/sh\npython waf configure build --view\n') +finally: + f.close() +os.chmod(outdir + '/run.sh', 0755) + # load the preview on main.tex visualize('beamer', outdir+'/main.tex') diff -Nru semantik-0.7.3/src/templates/html.sem.py semantik-0.8.3/src/templates/html.sem.py --- semantik-0.7.3/src/templates/html.sem.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/html.sem.py 2012-08-26 23:18:50.000000000 +0000 @@ -1,7 +1,7 @@ #sem:name: Web document #sem:tip: Generates a simple html document with a stylesheet -# Thomas Nagy, 2007 (ita) +# Thomas Nagy, 2007-2012 # exclude # caption @@ -32,10 +32,10 @@ os.chdir(sembind.get_var('temp_dir')) pics = {} # map the id to the picture lst = os.listdir('.') -for i in lst: - if i.rfind('pic-') > -1: - pics[ i.replace('pic-', '').split('.')[0] ] = i - shutil.copy2(i, outdir) +for x in lst: + if x.startswith('diag-'): + pics[ x.replace('diag-', '').split('.')[0] ] = x + shutil.copy2(x, outdir) os.chdir(cwd) buf = [] diff -Nru semantik-0.7.3/src/templates/java/Makefile semantik-0.8.3/src/templates/java/Makefile --- semantik-0.7.3/src/templates/java/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/templates/java/Makefile 2012-08-26 23:18:49.000000000 +0000 @@ -0,0 +1,20 @@ + +SOURCES=Kadapplet.java Mapview.java TextCoord.java + +.java.class: + javac $< + +all: Kadapplet.jar + +Kadapplet.jar: $(SOURCES) $(SOURCES:.java=.class) + jar cvf $@ $(SOURCES:.java=.class) pics/ + +clean: + \rm -f *.jar *.class + +view: Kadapplet.jar + appletviewer main.html + +.SUFFIXES: +.SUFFIXES: .java .class + diff -Nru semantik-0.7.3/src/templates/java/Mapview.java semantik-0.8.3/src/templates/java/Mapview.java --- semantik-0.7.3/src/templates/java/Mapview.java 2009-08-30 11:35:33.000000000 +0000 +++ semantik-0.8.3/src/templates/java/Mapview.java 2012-09-05 01:08:33.000000000 +0000 @@ -31,8 +31,7 @@ // Panel to hold the map picture JPanel panel = new JPanel(new BorderLayout()); - String filename = "map.png"; - String path = "/pics/" + filename; + String path = "/pics/wholemap.png"; ImageIcon pic = new ImageIcon(getClass().getResource(path)); m_picwidth = pic.getIconWidth(); diff -Nru semantik-0.7.3/src/templates/java.sem.py semantik-0.8.3/src/templates/java.sem.py --- semantik-0.7.3/src/templates/java.sem.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/java.sem.py 2012-09-05 01:08:33.000000000 +0000 @@ -2,8 +2,9 @@ #sem:tip: Generates a web applet in java (requires java) #sem:picture -# Thomas Nagy, 2007 (ita) -import os, shutil, time +# Thomas Nagy, 2007-2012 + +import os, shutil, time, sys # TODO for the moment it does not work @@ -20,31 +21,74 @@ except OSError: sys.stderr.write("Cannot create folder " + outdir) +try: + os.makedirs(outdir + '/pics') +except OSError: + sys.stderr.write("Cannot create the pics folder in %s" % outdir) + for x in "Makefile main.html Kadapplet.java Mapview.java".split(): - shutil.copy2(TEMPLATE_DIR+'/java/'+x, outdir) + shutil.copy2(template_dir() + '/java/'+x, outdir) + +cwd = os.getcwd() +os.chdir(sembind.get_var('temp_dir')) +pics = {} # map the id to the picture +lst = os.listdir('.') +for x in lst: + if x.startswith('diag-') or x.startswith('wholemap'): + pics[ x.replace('diag-', '').split('.')[0] ] = x + shutil.copy2(x, outdir + '/pics') +os.chdir(cwd) code = [] def out(s): global code code.append(s) -def comp(a, b, c, d, e): - s = "\nif (x > %d && y > %d && x < %d && y < %d) { return %s; }\n" % (a, b, c, d, e) - out(s) +def low_coords(node): + x = float(node.get_val('x')) + y = float(node.get_val('y')) + + num = node.child_count() + for i in range(num): + x2, y2 = low_coords(node.child_num(i)) + if x2 < x: + x = x2 + if y2 < y: + y = y2 + return (x, y) + +def print_rec(node, X, Y): + x = float(node.get_val('x')) - X + y = float(node.get_val('y')) - Y + w = float(node.get_val('w')) + h = float(node.get_val('h')) + + if node.get_val('type') == 'text': + txt = node.get_val('text') + txt = clear_html(txt) + txt = repr(txt)[1:-1].replace('"', '\\"') + + s = '\nif (x > %f && y > %f && x < %f && y < %f) { return "%s"; }\n' % (x, y, x+w, y+w, txt) + out(s) + + num = node.child_count() + for i in range(num): + print_rec(node.child_num(i), X, Y) + +root = Root() +x, y = low_coords(root) out("/** Generated by Semantik */\n\n") out("public class TextCoord\n{\n") -out("public static String coordToText(double x, double y)\n") - -# for ... -# comp() - +out("public static String coordToText(double x, double y) {\n") +print_rec(root, x - 25, y - 25) out("return \"\";\n") out("}\n}\n") file = open(outdir+'/TextCoord.java', 'w') -file.write(''.join(code)) -file.close() - +try: + file.write(''.join(code)) +finally: + file.close() diff -Nru semantik-0.7.3/src/templates/odp.sem.py semantik-0.8.3/src/templates/odp.sem.py --- semantik-0.7.3/src/templates/odp.sem.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/odp.sem.py 2012-09-05 01:08:33.000000000 +0000 @@ -1,7 +1,8 @@ #sem:name: OpenDocument Presentation #sem:tip: Generates presentations for Kpresenter or OpenOffice.org Impress -# Thomas Nagy, 2007 (ita) +# Thomas Nagy, 2007-2012 + mimetype = "application/vnd.oasis.opendocument.presentation" import os, shutil, time, zipfile, sys, StringIO @@ -39,61 +40,6 @@ def x(s): return sembind.protectXML(s) -from sgmllib import SGMLParser -import htmlentitydefs - -class TrucProcessor(SGMLParser): - def reset(self): - self.pieces = [] - self.state = "" - self.buf = "" - self.inli = 0 - SGMLParser.reset(self) - - def unknown_starttag(self, tag, attrs): - if tag == 'ul': - if self.inli and self.buf: - self.pieces.append('') - self.pieces.append(self.buf) - self.pieces.append('') - self.pieces.append('\n') - - if tag == 'li': - self.pieces.append('') - self.inli += 1 - - self.buf = "" - - def unknown_endtag(self, tag): - if tag == 'p': - self.pieces.append('') - self.pieces.append(self.buf) - self.pieces.append('\n') - elif tag == 'li': - if self.buf: - self.pieces.append('') - self.pieces.append(self.buf) - self.pieces.append('\n') - self.pieces.append('\n') - self.inli -= 1 - elif tag == 'ul': - self.pieces.append('\n') - - def handle_charref(self, ref): - self.pieces.append("&#%(ref)s;" % locals()) - - def handle_data(self, text): - self.buf = text - - def output(self): - return "".join(self.pieces) - -def parse_string(s): - parser = TrucProcessor() - parser.feed(s) - parser.close() - return parser.output() - def print_slide(node, niv): txt = x(node.get_val('summary')) if niv == 0: diff -Nru semantik-0.7.3/src/templates/odt.sem.py semantik-0.8.3/src/templates/odt.sem.py --- semantik-0.7.3/src/templates/odt.sem.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/odt.sem.py 2012-09-05 01:08:33.000000000 +0000 @@ -1,7 +1,8 @@ #sem:name: OpenDocument Text #sem:tip: Generates text documents for Kword or OpenOffice.org Writer -# Thomas Nagy, 2007 (ita) +# Thomas Nagy, 2007-2012 + mimetype = "application/vnd.oasis.opendocument.text" import os, shutil, time, zipfile, sys, StringIO @@ -34,7 +35,7 @@ def p(s): return sembind.protectHTML(s) -def x(s): +def xml(s): return sembind.protectXML(s) # substitute @var@, look if there is not a global variable named like that in the globals already @@ -44,7 +45,7 @@ if len(val)>3: if val[0]=='@' and val[-1]=='@' and not ' ' in val: nvar = val[1:-1] - if nvar in settings: settings[a] = x(settings[nvar]) + if nvar in settings: settings[a] = xml(settings[nvar]) else: settings[a] = globals.get(nvar, '') try: @@ -64,10 +65,10 @@ os.chdir(sembind.get_var('temp_dir')) pics = {} # map the id to the picture lst = os.listdir('.') -for i in lst: - if -1 == i.rfind('pic-'): continue - pics[ i.replace('pic-', '').split('.')[0] ] = i - shutil.copy2(i, outdir+'/Pictures') +for x in lst: + if x.startswith('diag-') and not x.endswith('.pdf'): + pics[ x.replace('diag-', '').split('.')[0] ] = x + shutil.copy2(x, outdir + '/Pictures') os.chdir(cwd) try: os.mkdir(outdir+'/META-INF') @@ -77,68 +78,13 @@ buf = [] out = buf.append -from sgmllib import SGMLParser -import htmlentitydefs - -class TrucProcessor(SGMLParser): - def reset(self): - self.pieces = [] - self.state = "" - self.buf = "" - self.inli = 0 - SGMLParser.reset(self) - - def unknown_starttag(self, tag, attrs): - if tag == 'ul': - if self.inli and self.buf: - self.pieces.append('') - self.pieces.append(self.buf) - self.pieces.append('') - self.pieces.append('\n') - - if tag == 'li': - self.pieces.append('') - self.inli += 1 - - self.buf = "" - - def unknown_endtag(self, tag): - if tag == 'p': - self.pieces.append('') - self.pieces.append(self.buf) - self.pieces.append('\n') - elif tag == 'li': - if self.buf: - self.pieces.append('') - self.pieces.append(self.buf) - self.pieces.append('\n') - self.pieces.append('\n') - self.inli -= 1 - elif tag == 'ul': - self.pieces.append('\n') - - def handle_charref(self, ref): - self.pieces.append("&#%(ref)s;" % locals()) - - def handle_data(self, text): - self.buf = text - - def output(self): - return "".join(self.pieces) - -def parse_string(s): - parser = TrucProcessor() - parser.feed(s) - parser.close() - return parser.output() - def print_nodes(node, niv, lbl_lst): lbl = ".".join(lbl_lst) typo = node.get_val('type') - txt = x(node.get_val('summary')) + txt = xml(node.get_val('summary')) #out('%s\n' % (nv, nv, txt)) if niv == 0: @@ -163,7 +109,7 @@ if typo == 'text': y = node.get_val('text') - if y: out(parse_string(y)) + if y: out(clear_html(y)) elif typo == 'table': rows = node.num_rows() @@ -175,18 +121,18 @@ out('\n') out('\n') - #out('%s\n' % x(caption)) + #out('%s\n' % xml(caption)) out('\n' % cols) for i in range(rows): out('\t\n') for j in range(cols): if i>0 and j>0: out('\t\t\n') - out('\t\t\t%s\n' % x(node.get_cell(i, j))) + out('\t\t\t%s\n' % xml(node.get_cell(i, j))) out('\t\t\n') else: out('\t\t\n') - out('\t\t\t%s\n' % x(node.get_cell(i, j))) + out('\t\t\t%s\n' % xml(node.get_cell(i, j))) out('\t\t\n') out('\t\n') out('\n') @@ -220,9 +166,16 @@ #out('\n') #out('\n') + w = float(node.get_val('widthHint')) / 36; # yuck + h = float(node.get_val('heightHint')) / 36; + + if w > 15: + h = (15 * h) / w + w = 15 + out('\n') out('\n') + out(' svg:width="%fcm" svg:height="%fcm" ' % (w, h)) out(' draw:z-index="0">\n') out('\n' % p) out('\n') diff -Nru semantik-0.7.3/src/templates/pdflatex/wscript semantik-0.8.3/src/templates/pdflatex/wscript --- semantik-0.7.3/src/templates/pdflatex/wscript 2009-08-30 11:35:34.000000000 +0000 +++ semantik-0.8.3/src/templates/pdflatex/wscript 2012-09-17 21:01:39.000000000 +0000 @@ -12,35 +12,31 @@ ''' import os -import Options +from waflib import Options VERSION = '0.0.1' APPNAME = 'pdf' -srcdir = '.' -blddir = 'build' +top = '.' +out = 'build' -def set_options(opts): +def options(opts): opts.add_option('--view', action='store_true', default=False, help='View the document') def configure(conf): - conf.check_tool('tex') + conf.load('tex') if not conf.env['PDFLATEX']: conf.fatal('install pdflatex!') + conf.find_program(['okular', 'kpdf', 'xpdf', 'gnome-open'], var='VIEW', mandatory=False) + + def build(bld) : - bld.new_task_gen(features='tex pdflatex', source='main.tex') + bld(features='tex', type='pdflatex', source='main.tex') + + def view(ctx): + ctx.exec_command('%s build/main.pdf' % ctx.env.VIEW) + + if bld.env.VIEW and bld.options.view: + bld.add_post_fun(view) -def shutdown(): - def exists(cmd): - try: - txt = os.popen("which %s 2>/dev/null "%cmd).read().strip() - return len(txt)>=len(cmd) - except: - return None - - if Options.options.view: - for i in ["kpdf", "gnome-open", "xpdf"]: - if exists(i): - os.popen("%s build/default/main.pdf" % i) - break diff -Nru semantik-0.7.3/src/templates/pdflatex.sem.py semantik-0.8.3/src/templates/pdflatex.sem.py --- semantik-0.7.3/src/templates/pdflatex.sem.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/pdflatex.sem.py 2012-09-17 21:01:39.000000000 +0000 @@ -1,10 +1,9 @@ #sem:name: PDF LaTeX #sem:tip: Generates a LaTeX project for obtaining PDF files -# Thomas Nagy, 2007 (ita) -import os, time, shutil, re, StringIO -from sgmllib import SGMLParser -import htmlentitydefs +# Thomas Nagy, 2007-2012 + +import os, time, shutil, re, StringIO, getpass # Additional variables: # exclude 1 @@ -14,8 +13,9 @@ 'doc_content':'', 'doc_class':'article', -'header_off':'None', -'footer_off':'None', +'all_latex':False, +'header_off':'', +'footer_off':'', 'header_l':'', 'header_c':'', 'header_r':'', @@ -29,7 +29,7 @@ 'doc_date':'', 'doc_date_off':'None', -'doc_author':'', +'doc_author':getpass.getuser(), 'doc_author_off':'None', 'babel':'english', # frenchb @@ -61,64 +61,17 @@ os.chdir(sembind.get_var('temp_dir')) pics = {} # map the id to the picture lst = os.listdir('.') -for i in lst: - if -1 == i.rfind('pic-'): continue - pics[ i.replace('pic-', '').split('.')[0] ] = i - shutil.copy2(i, outdir) +for x in lst: + if x.startswith('diag-'): + key = x.split('.')[0].replace('diag-', '') + if x.endswith('.pdf') or not key in pics: + pics[key] = x + shutil.copy2(x, outdir) os.chdir(cwd) buf = [] out = buf.append -class TrucProcessor(SGMLParser): - def reset(self): - self.pieces = [] - self.state = "" - self.buf = "" - self.inli = 0 - SGMLParser.reset(self) - - def unknown_starttag(self, tag, attrs): - if tag == 'ul': - if self.inli and self.buf: - self.pieces.append('\\item ') - self.pieces.append(tex_convert(self.buf)) - self.pieces.append('\n') - self.pieces.append('\\begin{itemize}\n') - - if tag == 'li': - self.inli += 1 - - self.buf = "" - - def unknown_endtag(self, tag): - if tag == 'p': - self.pieces.append(tex_convert(self.buf)) - self.pieces.append('\n') - elif tag == 'li': - if self.buf: - self.pieces.append('\\item ') - self.pieces.append(tex_convert(self.buf)) - self.pieces.append('\n') - self.inli -= 1 - elif tag == 'ul': - self.pieces.append('\\end{itemize}\n') - - def handle_charref(self, ref): - self.pieces.append("&#%(ref)s;" % locals()) - - def handle_data(self, text): - self.buf = text - - def output(self): - return "".join(self.pieces) - -def parse_string(s): - parser = TrucProcessor() - parser.feed(s) - parser.close() - return parser.output() - def print_nodes(node, niv): sm = tex_convert(node.get_val('summary')) if settings['doc_class'] in ['book', 'report']: @@ -188,6 +141,8 @@ w = int(node.get_val('pic_w')) restrict = "" if (w > 5*72): restrict = "[width=5in]" + if not restrict: + restrict = "[width=\\textwidth,height=\\textheight,keepaspectratio]" out('\\begin{figure}[htbp]\n') out(' \\begin{center}\n') @@ -232,6 +187,13 @@ shutil.copy2(template_dir()+'/waf', outdir+'/waf') os.chmod(outdir+'/waf', 0755) +f = open(outdir + '/run.sh', 'w') +try: + f.write('#! /bin/sh\npython2 waf configure build --view\n') +finally: + f.close() +os.chmod(outdir + '/run.sh', 0755) + # load the preview on main.tex visualize('pdflatex', outdir+'/main.tex') diff -Nru semantik-0.7.3/src/templates/s5/index.html semantik-0.8.3/src/templates/s5/index.html --- semantik-0.7.3/src/templates/s5/index.html 2009-08-30 11:35:34.000000000 +0000 +++ semantik-0.8.3/src/templates/s5/index.html 2012-09-05 01:08:33.000000000 +0000 @@ -20,6 +20,7 @@ + diff -Nru semantik-0.7.3/src/templates/s5/ui/default/semantik.css semantik-0.8.3/src/templates/s5/ui/default/semantik.css --- semantik-0.7.3/src/templates/s5/ui/default/semantik.css 1970-01-01 00:00:00.000000000 +0000 +++ semantik-0.8.3/src/templates/s5/ui/default/semantik.css 2012-09-05 01:08:33.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * html template + * this file is part of the Semantik templates + * http://code.google.com/p/semantik/ + * created by Thomas Nagy in 2012 for Semantik + * + * Permission is granted to redistribute copies and + * derivated works of this file (semantik.css) without + * any restrictions. + */ + +table.sem_table { + font-family: "Lucida Grande", "Lucida Sans Unicode", sans-serif; + border-collapse: collapse; + color: #212424; + margin: 3px; +} +table.sem_table td, table.sem_table th +{ + border: 1px solid black; /*#c5e894;*/ + padding: 3px; + padding-left: 5px; + padding-right: 5px; + cursor: default; +} + +table.sem_table th +{ + font-weight: bold; + background-color: #c5e894; +} + +table.sem_table thead +{ + background: #524123; +} + +table.sem_table tfoot +{ + color: #ffffff; + background: #524123; +} + +table.sem_table tbody tr td +{ + background: #DDF0BD; +} + +table.sem_table tbody tr td:hover, table.sem_table tbody tr td:hover +{ + background: #c5e894; +} + diff -Nru semantik-0.7.3/src/templates/s5.sem.py semantik-0.8.3/src/templates/s5.sem.py --- semantik-0.7.3/src/templates/s5.sem.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/s5.sem.py 2012-09-05 01:08:33.000000000 +0000 @@ -1,18 +1,19 @@ #sem:name: S5 presentation #sem:tip: Generates a xhtml presentation using s5 -# Thomas Nagy, 2007 (ita) -import os, shutil, time +# Thomas Nagy, 2007-2012 + +import os, shutil, time, getpass outdir = sembind.get_var('outdir')+'/'+sembind.get_var('pname') settings = { 'doc_date':'', 'doc_content':'', -'doc_title':'How i did it', -'doc_author':'Krusty', -'doc_place':'Los angeles', -'doc_company':'World company' +'doc_title':'Report', +'doc_author':getpass.getuser(), +'doc_place':'Stockholm', +'doc_company':'Organization' } add_globals(settings) @@ -30,10 +31,10 @@ os.chdir(sembind.get_var('temp_dir')) pics = {} # map the id to the picture lst = os.listdir('.') -for i in lst: - if -1 == i.rfind('pic-'): continue - pics[ i.replace('pic-', '').split('.')[0] ] = i - shutil.copy2(i, outdir) +for x in lst: + if x.startswith('diag-') and not x.endswith('pdf'): + pics[ x.replace('diag-', '').split('.')[0] ] = x + shutil.copy2(x, outdir) os.chdir(cwd) @@ -74,6 +75,72 @@ out('\n') +def print_figure_slides(node, niv): + typo = node.get_val('type') + if typo in ['table', 'diag', 'img']: + + out('\n\n
    \n') + out('

    %s

    \n' % node.get_val('summary')) + + if typo == 'table': + rows = node.num_rows() + cols = node.num_cols() + if rows>0 and cols>0: + out('\n') + out('
    \n') + out('\n') + out('\n') + for i in range(rows): + out('\t\n') + for j in range(cols): + if i>0 and j>0: + out('\t\t\n' % x(node.get_cell(i, j))) + else: + out('\t\t\n' % x(node.get_cell(i, j))) + out('\t\n') + + out('\n') + out('
    %s%s
    \n') + out('
    \n') + out('\n') + + elif typo == 'img' or typo == 'diag': + id = node.get_val('id') + if id in pics: + + caption = node.get_var('caption') + if not caption: caption = caption = node.get_val('summary') + out('
    \n') + out("\n" % pics[id]) + out('
    \n') + + """ + restrict = node.get_var("picdim") + if not restrict: + w = int(node.get_val('pic_w')) + restrict = "" + if (w > 5*72): restrict = "[width=5in]" + if not restrict: + restrict = "[width=\\textwidth,height=\\textheight,keepaspectratio]" + + out('\\begin{figure}[htbp]\n') + out(' \\begin{center}\n') + out(' \\includegraphics%s{%s}\n' % (restrict, pics[id])) + out(' \\caption{\\footnotesize{%s}}\n' % tex_convert(caption)) + out('%% %s\n' % protect_tex(node.get_val('pic_location'))) + out('%% %s\n' % node.get_val('pic_w')) + out('%% %s\n' % node.get_val('pic_h')) + out(' \\end{center}\n') + out('\\end{figure}\n') + """ + + out("
    \n") + + num = node.child_count() + for i in range(num): + print_figure_slides(node.child_num(i), niv+1) + + def print_nodes(node, niv): has_child_skip = 0 @@ -110,27 +177,7 @@ print_nodes(node.child_num(i), niv+1) else: print_slide(node, niv) - - ''' - rows = node.num_rows() - cols = node.num_cols() - if rows>0 and cols>0: - out('\n') - out('\n') - out('\n') - for i in range(rows): - out('\t\n') - for j in range(cols): - if i>0 and j>0: - out('\t\t\n' % x(node.get_cell(i, j))) - else: - out('\t\t\n' % x(node.get_cell(i, j))) - out('\t\n') - - out('\n') - out('
    %s%s
    \n') - out('\n') - ''' + print_figure_slides(node, niv) # the main document print_nodes(Root(), 0); @@ -149,6 +196,7 @@ s5-core.css slides.css slides.js +semantik.css """.split() shutil.copy2(template_dir()+'/s5/ui/default/blank.gif', outdir+'/ui/default/') diff -Nru semantik-0.7.3/src/templates/semantik.sem.py semantik-0.8.3/src/templates/semantik.sem.py --- semantik-0.7.3/src/templates/semantik.sem.py 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/templates/semantik.sem.py 2012-08-26 23:18:50.000000000 +0000 @@ -1,7 +1,8 @@ #sem:name: semantik document generator #sem:tip: used for saving semantik documents -# Thomas Nagy, 2007 (ita) +# Thomas Nagy, 2007-2012 + import os, tarfile from cStringIO import StringIO @@ -9,7 +10,6 @@ doc = sembind.get_var('fulldoc') stuff = StringIO(doc) -#stuff = StringIO(doc) tarinfo = tarfile.TarInfo('con.xml') tarinfo.size = len(doc) tar.addfile(tarinfo, stuff) @@ -18,9 +18,21 @@ os.chdir(sembind.get_var('temp_dir')) lst = os.listdir('.') -for i in lst: - if -1 == i.rfind('pic-'): continue - tar.add(i, i) +tmp = str(sembind.get_item_ids()).split(",") +for x in tmp: + item = sembind.get_item_by_id(int(x)) + if item: + pid = sembind.get_val(item, "pic_id") + s = 'img-%s' % pid + if pid != '0': + for pic in lst: + if pic.startswith(s): + tar.add(pic, pic) + break + else: + debug("Could not find the picture for item %r->%r in %r" % (x, pid, sembind.get_var('temp_dir'))) + else: + debug("Could not get an object for %r" % x) tar.close() diff -Nru semantik-0.7.3/src/text_view.cpp semantik-0.8.3/src/text_view.cpp --- semantik-0.7.3/src/text_view.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/text_view.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -12,39 +12,30 @@ #include -#include "con.h" +//#include "aux.h" +//#include "con.h" #include "data_item.h" -#include "data_control.h" +#include "sem_mediator.h" #include "text_view.h" #include "semantik.h" -text_view::text_view(QWidget *i_oParent, data_control *i_oControl) : QWidget(i_oParent) +text_view::text_view(QWidget *i_oParent, sem_mediator *i_oControl) : QWidget(i_oParent) { QGridLayout *l_oLayout = new QGridLayout(); setLayout(l_oLayout); - m_oLineEdit = new QLineEdit(this); - m_oControl = i_oControl; + m_oMediator = i_oControl; m_oEdit = new KTextEdit(this); m_oEdit->setCheckSpellingEnabled(true); - l_oLayout->addWidget(m_oLineEdit, 0, 0); l_oLayout->addWidget(m_oEdit, 1, 0, 1, 4); l_oLayout->setMargin(0); setMinimumHeight(30); m_iId = NO_ITEM; - /*QPalette l_oPalette = m_oLineEdit->palette(); - l_oPalette.setBrush(QPalette::Inactive, QPalette::Base, QColor(230, 230, 230)); - l_oPalette.setBrush(QPalette::Disabled, QPalette::Base, QColor(230, 230, 230)); - m_oLineEdit->setPalette(l_oPalette); - m_oEdit->setPalette(l_oPalette);*/ - - connect(m_oLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(update_summary(const QString &))); connect(m_oEdit, SIGNAL(textChanged()), this, SLOT(update_edit())); - connect(m_oEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), - this, SLOT(char_format_changed(const QTextCharFormat &))); + connect(m_oEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(char_format_changed(const QTextCharFormat &))); m_oBoldAct = new QAction(fetch_icon(notr("text_bold")), trUtf8("&Bold"), this); m_oBoldAct->setShortcut(trUtf8("Ctrl+B")); @@ -76,79 +67,33 @@ connect(m_oUnderLineAct, SIGNAL(triggered()), this, SLOT(text_underLine())); } -void text_view::synchro_doc(const hash_params& i_o) -{ - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) - { - case cmd_add_item: - m_iId = i_o[data_id].toInt(); - break; - - case cmd_select_item: - { - m_iId = i_o[data_id].toInt(); - bool l_bCond = !m_iId; - if (l_bCond) - { - m_oEdit->clear(); - m_oLineEdit->clear(); - } - else - { - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - m_oLineEdit->setText(l_oData->m_sSummary); - m_oEdit->setHtml(l_oData->m_sText); - } - - m_oEdit->setReadOnly(l_bCond); - m_oLineEdit->setReadOnly(l_bCond); - - m_oLineEdit->setEnabled(!l_bCond); - m_oEdit->setEnabled(!l_bCond); - m_oEdit->setCheckSpellingEnabled(!l_bCond); - - m_oBoldAct->setEnabled(!l_bCond); - m_oItalicAct->setEnabled(!l_bCond); - m_oUnderLineAct->setEnabled(!l_bCond); - } - break; - case cmd_update_item: - { - int l_oId = i_o[data_id].toInt(); - if (m_iId) - { - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - if (l_oId == m_iId) - { - m_oLineEdit->setText(l_oData->m_sSummary); - } - } - m_iId = l_oId; - } - break; - default: - break; - } -} - -void text_view::update_summary(const QString & i_s) +void text_view::update_edit() { if (!m_iId) return; - data_item *l_oData = m_oControl->m_oItems.value(m_iId); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); - bool l_b = (l_oData->m_sSummary != i_s); - l_oData->m_sSummary = i_s; - if (l_b) m_oControl->update_item(m_iId, view_text); -} + mem_text* tmp = NULL; -void text_view::update_edit() -{ - if (!m_iId) return; - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - l_oData->m_sText = m_oEdit->toHtml(); - l_oData->m_iTextLength = m_oEdit->toPlainText().length(); - // no need to update here + mem_command *c = NULL; + if (!m_oMediator->m_oUndoStack.empty()) + { + c = m_oMediator->m_oUndoStack.pop(); + m_oMediator->m_oUndoStack.push(c); + if (c->type() != mem_command::TEXT) + { + c = NULL; + } + } + + tmp = (mem_text*) c; + if (!c) { + tmp = new mem_text(m_oMediator); + tmp->sel = l_oData; + tmp->oldText = l_oData->m_sText; + tmp->add(); + } + tmp->newText = tmp->sel->m_sText = m_oEdit->toHtml(); + tmp->sel->m_iTextLength = m_oEdit->toPlainText().length(); } void text_view::text_bold() @@ -193,7 +138,35 @@ m_oUnderLineAct->setChecked(l_oF.underline()); } +void text_view::notify_text(int id) { + if (id == m_iId) { + m_iId = NO_ITEM; // do not trigger the signal changed + data_item *sel = *m_oMediator + id; + m_oEdit->setHtml(sel->m_sText); + m_iId = id; + } +} + +void text_view::notify_select(const QList& unsel, const QList& sel) { + bool one = (sel.size() == 1); + m_iId = NO_ITEM; + m_oEdit->setReadOnly(!one); + m_oEdit->setEnabled(one); + m_oEdit->setCheckSpellingEnabled(one); + + m_oBoldAct->setEnabled(one); + m_oItalicAct->setEnabled(one); + m_oUnderLineAct->setEnabled(one); + + if (one) { + data_item *l_oData = m_oMediator->m_oItems.value(sel.at(0)); + m_oEdit->setHtml(l_oData->m_sText); + m_iId = sel.at(0); + } else { + m_oEdit->clear(); + } +} #include "text_view.moc" diff -Nru semantik-0.7.3/src/text_view.h semantik-0.8.3/src/text_view.h --- semantik-0.7.3/src/text_view.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/text_view.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef TEXT_VIEW_H #define TEXT_VIEW_H @@ -9,16 +9,17 @@ n.h" #include +#include + class KTextEdit; class semantik_win; class text_view : public QWidget { Q_OBJECT public: - text_view(QWidget *i_oParent, data_control *i_oControl); - data_control *m_oControl; + text_view(QWidget *i_oParent, sem_mediator *i_oControl); + sem_mediator *m_oMediator; KTextEdit *m_oEdit; - QLineEdit *m_oLineEdit; int m_iId; @@ -33,8 +34,6 @@ QAction *m_oUnderLineAct; public slots: - void synchro_doc(const hash_params&); - void update_summary(const QString &); void update_edit(); void text_bold(); @@ -42,6 +41,8 @@ void text_underLine(); void char_format_changed(const QTextCharFormat&); + void notify_select(const QList& unsel, const QList& sel); + void notify_text(int id); }; #endif diff -Nru semantik-0.7.3/src/util.ml semantik-0.8.3/src/util.ml --- semantik-0.7.3/src/util.ml 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/util.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,230 +0,0 @@ -(* - Thomas Nagy 2007-2009 GPLV3 -*) - -open Fixed -open Force -open Printf -open Hashtbl - -let iterate x = - if x = 0 then - reorg_fixed () - else if x = 1 then - reorg_fixed () - reorg_force x - else - reorg_force x - flush_all() - -Callback.register "iterate_fun" iterate - - -type node = {x: float; y: float} -(* COM: the list of arcs in a hash table *) - -let pad = 20 - -exception Finished -exception Disconnected - -type line = {x1: int; x2: int; y1: int; y2: int;} -type point = {mutable x: int; y: int;} - -(* COM: the result is placed statically into vertices *) -let vertices = ref [||] - -let set_rects ax1 ax2 ay1 ay2 bp1 bx1 bx2 by1 by2 bp2 = - (* - Yet too difficult for many - thinking in closures is easy - can you understand the following ? - *) - (* COM: Printf.fprintf stderr "%d %d %d %d %d %d %d %d %d %d\n" ax1 ax2 ay1 ay2 bp1 bx1 bx2 by1 by2 bp2*) - - let cx1 = - pad + min ax1 bx1 - let cx2 = pad + max ax2 bx2 - let cy1 = - pad + min ay1 by1 - let cy2 = pad + max ay2 by2 - - let hrz = ref [cx1; cx2] - let ver = ref [cy1; cy2] - - if bx1 > ax2 then - hrz := (bx1 + ax2) / 2 :: !hrz - if ax1 > bx2 then - hrz := (ax1 + bx2) / 2 :: !hrz - - if by1 > ay2 then - ver := (by1 + ay2) / 2 :: !ver - if ay1 > by2 then - ver := (ay1 + by2) / 2 :: !ver - - let sx = ref 0 and sy = ref 0 and ex = ref 0 and ey = ref 0 - let store a b = - ver := b::!ver - hrz := a::!hrz - let s_store a b = - store a b - sx := a - sy := b - let e_store a b = - store a b - ex := a - ey := b - - (*ver := ((ax1 + ax2)/2)::!ver - ver := ((bx1 + bx2)/2)::!ver - hrz := ((ay1 + ay2)/2)::!hrz - hrz := ((by1 + by2)/2)::!hrz*) - - if bp1 == 0 then - s_store ((ax1 + ax2)/2) ay1 - if bp2 == 0 then - e_store ((bx1 + bx2)/2) by1 - - if bp1 == 1 then - s_store ax1 ((ay1 + ay2)/2) - if bp2 == 1 then - e_store bx1 ((by1 + by2)/2) - - if bp1 == 2 then - s_store ((ax1 + ax2)/2) ay2 - if bp2 == 2 then - e_store ((bx1 + bx2)/2) by2 - - if bp1 == 3 then - s_store ax2 ((ay1 + ay2)/2) - if bp2 == 3 then - e_store bx2 ((by1 + by2)/2) - - - if bp1 == 1 && bp2 == 3 && bx2 >= ax1 - pad then - hrz := ax1 - pad :: bx2 + pad :: !hrz - else if bp1 == 3 && bp2 == 1 && ax2 >= bx1 - pad then - hrz := bx1 - pad :: ax2 + pad :: !hrz - else if bp1 == 0 && bp2 == 2 && by2 >= ay1 - pad then - ver := ay1 - pad :: by2 + pad :: !ver - else if bp1 == 2 && bp2 == 0 && ay2 >= by1 - pad then - ver := by1 - pad :: ay2 + pad :: !ver - - let init = {x= !sx; y= !sy;} - let endp = {x= !ex; y= !ey;} - - let is_linked2 a b = - let is_vertical = a.x == b.x - try - if is_vertical then - if a.y < ay2 && b.y > ay1 then - if ax1 <= a.x && a.x <= ax2 then - raise Disconnected - if a.y < by2 && b.y > by1 then - if bx1 <= a.x && a.x <= bx2 then - raise Disconnected - else - if a.x < ax2 && b.x > ax1 then - if ay1 <= a.y && a.y <= ay2 then - raise Disconnected - if a.x < bx2 && b.x > bx1 then - if by1 <= a.y && a.y <= by2 then - raise Disconnected - true - with - | Disconnected -> - false - - let is_linked a b = - if a.x != b.x && a.y != b.y then - false - else if a.x == cx1 && b.x == cx1 then - true - else if a.x == cx2 && b.x == cx2 then - true - else if a.y == cy1 && b.y == cy1 then - true - else if a.y == cy2 && b.y == cy2 then - true - else - if a.x >= b.x && a.y >= b.y then - is_linked2 b a - else - is_linked2 a b - - let graph = ref [] - let x_arr = Array.of_list !hrz - let y_arr = Array.of_list !ver - - (* COM: distance to a point *) - let dist = Hashtbl.create 30 - (* COM: previous element *) - let prev = Hashtbl.create 30 - - - (* COM: initialize all *) - for i=0 to Array.length x_arr - 1 do - for j=0 to Array.length y_arr -1 do - let pt = {x= x_arr.(i); y= y_arr.(j);} - graph := pt::!graph - Hashtbl.replace prev pt init - Hashtbl.replace dist pt 999999999 - - Hashtbl.replace dist init 0 - let q = ref (!graph) - - try - while true do - let func x y = - let dx = Hashtbl.find dist x - let dy = Hashtbl.find dist y - - if dx < dy then - x - else - y - - let elem = List.fold_left func endp (!q) - if elem == endp then - raise Finished - - q := List.fold_left (fun lst x -> if compare x elem == 0 then lst else x::lst) [] (!q) - let arr = Array.of_list !q - for i=0 to Array.length arr - 1 do - let cand = arr.(i) - if is_linked cand elem then - let alt = 1 + abs(elem.x - cand.x) + abs(elem.y - cand.y) + Hashtbl.find dist elem - if alt < Hashtbl.find dist cand then - Hashtbl.replace dist cand alt - Hashtbl.replace prev cand elem - with - | Finished -> - () - - (* COM: now extract the shortest path *) - let rec out_lst (el:point) = - try - let x = Hashtbl.find prev el - if x == init then - raise Finished - (*Printf.printf "%d %d\n" x.x x.y *) - out_lst(x) @ [el] - with - | Finished -> - [el] - - vertices := Array.of_list (out_lst endp) - -let get_vx p = - (!vertices).(p).x - -let get_vy p = - (!vertices).(p).y - -let num_seg () = - Array.length !vertices - -Callback.register "set_rects_fun" set_rects -Callback.register "get_vx_fun" get_vx -Callback.register "get_vy_fun" get_vy -Callback.register "num_seg_fun" num_seg - - diff -Nru semantik-0.7.3/src/vars_view.cpp semantik-0.8.3/src/vars_view.cpp --- semantik-0.7.3/src/vars_view.cpp 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/vars_view.cpp 2012-08-26 23:18:50.000000000 +0000 @@ -1,4 +1,4 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #include #include @@ -9,19 +9,21 @@ #include #include #include +#include "con.h" #include "data_item.h" -#include "data_control.h" +#include "sem_mediator.h" #include "vars_view.h" -#include "con.h" -vars_view::vars_view(QWidget *i_oParent, data_control *i_oControl) : QTextEdit(i_oParent) +vars_view::vars_view(QWidget *i_oParent, sem_mediator *i_oControl) : QTextEdit(i_oParent) { - m_oControl = i_oControl; + m_oMediator = i_oControl; /*vars_highlighter *l_o =*/ new vars_highlighter(document()); connect(this, SIGNAL(textChanged()), this, SLOT(update_edit())); m_iId = NO_ITEM; m_oCompleter = NULL; + m_bLockEdit = false; + startup = true; } void vars_view::init_completer() @@ -84,42 +86,86 @@ #endif } -void vars_view::synchro_doc(const hash_params&i_o) -{ - int l_iCmd = i_o[data_commande].toInt(); - switch (l_iCmd) - { - case cmd_select_item: - { - m_iId = i_o[data_id].toInt(); - if (m_iId > NO_ITEM) - { - m_oCompleter = m_oCompleterItem; - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - setText(l_oData->m_sHints); - } - else - { - m_oCompleter = m_oCompleterAll; - setText(m_oControl->m_sHints); - } - } - break; - default: - break; +void vars_view::notify_vars(int id) { + if (id == m_iId) { + m_bLockEdit = true; + if (id != NO_ITEM) { + data_item *sel = *m_oMediator + id; + setText(sel->m_sHints); + } + else + { + setText(m_oMediator->m_sHints); + } + m_bLockEdit = false; } } +void vars_view::notify_select(const QList& unsel, const QList& sel) { + bool one = (sel.size() == 1); + m_bLockEdit = true; + if (one) { + m_iId = sel.at(0); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + m_oCompleter = m_oCompleterItem; + setText(l_oData->m_sHints); + } else { + m_iId = NO_ITEM; + m_oCompleter = m_oCompleterAll; + setText(m_oMediator->m_sHints); + } + m_bLockEdit = false; +} + void vars_view::update_edit() { + if (m_bLockEdit) return; + + if (startup) + { + startup = false; + return; + } + + mem_vars* tmp = NULL; + + mem_command *c = NULL; + if (!m_oMediator->m_oUndoStack.empty()) + { + c = m_oMediator->m_oUndoStack.pop(); + m_oMediator->m_oUndoStack.push(c); + if (c->type() != mem_command::VARS) + { + c = NULL; + } + } + + tmp = (mem_vars*) c; + if (!c) + { + tmp = new mem_vars(m_oMediator); + tmp->m_iId = m_iId; + if (m_iId) + { + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + tmp->oldVars = l_oData->m_sHints; + } + else + { + tmp->oldVars = m_oMediator->m_sHints; + } + tmp->add(); + } + tmp->newVars = toPlainText(); + if (m_iId) { - data_item *l_oData = m_oControl->m_oItems.value(m_iId); - l_oData->m_sHints = toPlainText(); + data_item *l_oData = m_oMediator->m_oItems.value(m_iId); + l_oData->m_sHints = tmp->newVars; } else { - m_oControl->m_sHints = toPlainText(); + m_oMediator->m_sHints = tmp->newVars; } } @@ -241,7 +287,6 @@ bool l_b = l_oCursor.position() == l_iWord; l_oCursor.setPosition(l_iSave); - // TODO message for saying "can not complete" if (!l_b) return; if (l_sPrefix != m_oCompleter->completionPrefix()) diff -Nru semantik-0.7.3/src/vars_view.h semantik-0.8.3/src/vars_view.h --- semantik-0.7.3/src/vars_view.h 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/src/vars_view.h 2012-08-26 23:18:50.000000000 +0000 @@ -1,8 +1,9 @@ -// Thomas Nagy 2007-2009 GPLV3 +// Thomas Nagy 2007-2012 GPLV3 #ifndef VARS_VIEW_H #define VARS_VIEW_H +#include #include #include @@ -26,21 +27,24 @@ { Q_OBJECT public: - vars_view(QWidget *i_oParent, data_control *i_oControl); - data_control *m_oControl; + vars_view(QWidget *i_oParent, sem_mediator *i_oControl); + sem_mediator *m_oMediator; int m_iId; + bool m_bLockEdit; QCompleter *m_oCompleter; QCompleter *m_oCompleterItem; QCompleter *m_oCompleterAll; QAction *m_oCompleteAction; void keyPressEvent(QKeyEvent*); void init_completer(); + bool startup; public slots: - void synchro_doc(const hash_params&); void update_edit(); void do_complete(const QString &); void try_complete(); + void notify_select(const QList& unsel, const QList& sel); + void notify_vars(int); }; #endif diff -Nru semantik-0.7.3/util/ocamltwt.ml semantik-0.8.3/util/ocamltwt.ml --- semantik-0.7.3/util/ocamltwt.ml 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/util/ocamltwt.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,776 +0,0 @@ -(* - ocaml+twt.ml - by Mike Lin (mikelin@mit.edu) - - "The Whitespace Thing" for OCaml - - This is a preprocessor for a new OCaml syntax that uses indentation rather than - parenthesization to group expressions. -*) - -type whitespace_mode = - Either - | Tab_only - | Space_only - -type configuration = { - mutable whitespace_mode : whitespace_mode -} - -let config = { - whitespace_mode = Either -} - -let endl = "\n" - -(****************************************************************************** - stupid amateurish lexing stuff -******************************************************************************) - -let whitespace_chars = [ ' '; '\t' ] -let comment_line_re = Str.regexp "[ \t]*(\\*.*" - -let indent_count line = - let i = ref 0 in - let l = String.length line in - while !i < l && List.mem line.[!i] whitespace_chars do - i := !i + 1 - done; - !i - -let is_blank line = - (indent_count line) = (String.length line) || (Str.string_match comment_line_re line 0) - -type lexical_state = - { - quote : bool; - comment : int; - paren : int; - square : int; - curly : int - } - -let update_lexical_state oldstate s = - let quote = ref oldstate.quote in - let comment = ref oldstate.comment in - let paren = ref oldstate.paren in - let square = ref oldstate.square in - let curly = ref oldstate.curly in - let inc x = x := 1 + !x in - let dec x = x := !x - 1 in - let len = String.length s in - for i = 0 to len - 1 do - let more = i < (len - 1) in - let less = i > 0 in - match s.[i] with - '"' when !comment = 0 && not !quote -> quote := true - | '"' when !quote && ((not less) || (s.[i-1] <> '\\')) -> quote := false - | '(' when more && s.[i+1] = '*' && not !quote -> inc comment - | ')' when less && s.[i-1] = '*' && not !quote -> dec comment - | '(' when !comment = 0 && not !quote -> inc paren - | ')' when !comment = 0 && not !quote -> dec paren - | '[' when !comment = 0 && not !quote -> inc square - | ']' when !comment = 0 && not !quote -> dec square - | '{' when !comment = 0 && not !quote -> inc curly - | '}' when !comment = 0 && not !quote -> dec curly - | _ -> () - done; - { quote = !quote; comment = !comment; paren = !paren; square = !square; curly = !curly } - -class line_reader chan = -object(self) - val mutable buf = None - val mutable line_num = 0 - val mutable pre_lexical_state = - { - quote = false; - comment = 0; - paren = 0; - square = 0; - curly = 0 - } - val mutable post_lexical_state = - { - quote = false; - comment = 0; - paren = 0; - square = 0; - curly = 0 - } - - method lexical_state () = pre_lexical_state - method line_number () = line_num - method peek () = - match buf with - Some line -> line - | None -> - let line = input_line chan in - let post_state = update_lexical_state post_lexical_state line in - pre_lexical_state <- post_lexical_state; - post_lexical_state <- post_state; - line_num <- 1 + line_num; - buf <- Some line; - line - method read () = - let line = self#peek () in - buf <- None; - line - method drop () = - ignore (self#read ()) -end - -(****************************************************************************** - parsing -******************************************************************************) - -type line_type = - | Identifier - | Paren - | Curly - | Square - | Quote - - | NamedOperand - | OptionalOperand - - | Let - | In - | And - - | If - | Else - - | Fun - - | Match - | Function - | Pipe - - | For - | While - - | Try - | With - - | Open - - | Exception - - | Type - | Val - - | Module - | ModuleType - | Struct - | Sig - - | Class - | Object - | Method - | Initializer - | Inherit - | Constraint - -let line_res = - let keyword_res = - List.map - (fun (keyword,ty) -> (Str.regexp (keyword ^ "\\([ \t]+\\|$\\)"),ty)) - [ - ("let",Let); - ("in",In); - ("and",And); - ("if",If); - ("else",Else); - ("for",For); - ("while",While); - ("match",Match); - ("function",Function); - ("try",Try); - ("with",With); - ("open",Open); - ("exception",Exception); - ("fun",Fun); - ("type",Type); - ("val",Val); - ("module[ \t]+type",ModuleType); - ("module",Module); - ("struct",Struct); - ("sig",Sig); - ("class",Class); - ("object",Object); - ("method",Method); - ("initializer",Initializer); - ("inherit",Inherit); - ("constraint",Constraint) - ] - in - keyword_res @ - [ - (Str.regexp "|.*",Pipe); - (Str.regexp "(.*",Paren); - (Str.regexp "{.*",Curly); - (Str.regexp "\\[.*",Square); - (Str.regexp "\".*",Quote); - (Str.regexp "'.*",Quote); - (Str.regexp "object(.*",Object); - (Str.regexp "~[a-zA-Z0-9'_]+:.*",NamedOperand); - (Str.regexp "\\?[a-zA-Z0-9'_]+:.*",OptionalOperand); - (Str.regexp "[a-zA-Z0-9!`#].*",Identifier) - ] - -let determine_line_type line = - let ic = indent_count line in - let rec iter = function - (re,ty) :: rest -> - if Str.string_match re line ic then - ty - else - iter rest - | [] -> invalid_arg "determine_line_type" - in - iter line_res - -(* a helpful warning *) -let check_indentation line_num line = - let ic = indent_count line in - if ic > 0 then - let saw_space = ref false in - let saw_tab = ref false in - for i = 0 to ic - 1 do - if line.[i] = ' ' then saw_space := true; - if line.[i] = '\t' then saw_tab := true - done; - match config.whitespace_mode with - Tab_only when !saw_space -> - (Printf.eprintf "Error: line %d uses spaces for indentation; you asked for -tabonly\n" line_num; - exit 2) - | Space_only when !saw_tab -> - (Printf.eprintf "Error: line %d uses tabs for indentation; you asked for -spaceonly\n" line_num; - exit 2) - | Either when !saw_space && !saw_tab -> - Printf.eprintf "Warning: line %d uses mixed space and tab indentation.\n" line_num - | _ -> () - -(* - parse pass 1: read in the source code and transform it into a sequence of meaningful lines by: - - merge blank lines into the next meaningful line - - merge comment lines into the next meaningful line - - merge dangling curly-braced, square-bracketed, or parenthesized lines into - the previous meaningful line - - determine the type and indent-level of each meaningful line -*) - -type syntax_pass1 = meaningful_line list -and meaningful_line = line_type * int * int * string (* line_type, indent_count, line_number, line_text *) - -let parse_pass1 reader = - let rec dangling_lines () = - match try Some (reader#peek ()) with End_of_file -> None with - Some line -> - let lexstate = reader#lexical_state () in - if lexstate.quote || lexstate.comment > 0 || lexstate.square > 0 || lexstate.curly > 0 || lexstate.paren > 0 then - begin - reader#drop (); - endl ^ line ^ (dangling_lines ()) - end - else - "" - | None -> "" - in - let next_meaningful_line () = - let rec iter meaningless_lines = - let line = reader#read () in - let lexstate = reader#lexical_state () in - if lexstate.comment = 0 && not (is_blank line) then - let ty = try determine_line_type line with Invalid_argument _ -> Printf.eprintf "syntax error at line %d\n" (reader#line_number ()); exit 2 in - let ln = reader#line_number () in - let dangle = dangling_lines () in - check_indentation ln line; - (ty,indent_count line,ln,meaningless_lines ^ line ^ dangle) - else - iter (meaningless_lines ^ line ^ endl) - in - iter "" - in - let lines = ref [] in - begin - try - while true do - lines := (next_meaningful_line ()) :: !lines - done - with - End_of_file -> () - end; - List.rev !lines - - -(* here's our extremely simple abstract syntax tree *) -type syntax = syntactic_unit list -and syntactic_unit = - Line of line_type*int*string (* line_type,line_number,line_text *) - | Block of syntax - | PipeBlock of syntax - -(* parse pass 2: collect lines at the same indent-level into blocks and sub-blocks *) - -let parse_pass2 lines = - let stream = Stream.of_list lines in - let rec level n = - match Stream.peek stream with - Some (ty,n',line_num,txt) when n = n' -> Stream.junk stream; (Line (ty,line_num,txt)) :: (level n) - | Some (ty,n',line_num,txt) when n < n' -> - let sublevel = level n' in - (Block sublevel) :: (level n) - | _ -> [] - in - level 0 - -(* parse pass 3: (postprocessing) change Blocks with only pipe lines or sub-blocks (i.e. patterns) into PipeBlocks *) - -let rec collect_pipe_blocks = function - (Block syntax) :: rest -> - let any_pipes = List.exists (function (Line (Pipe,_,_)) -> true | _ -> false) syntax in - let all_pipes = not (List.exists (function (Line (Pipe,_,_)) | (Block _) | (PipeBlock _) -> false | _ -> true) syntax) in - if any_pipes && all_pipes then - (PipeBlock (collect_pipe_blocks syntax)) :: (collect_pipe_blocks rest) - else - (Block (collect_pipe_blocks syntax)) :: (collect_pipe_blocks rest) - | fst :: rest -> fst :: (collect_pipe_blocks rest) - | [] -> [] - -(* aight *) -let parse reader = - let ml = parse_pass1 reader in - let syntax = parse_pass2 ml in - let postprocessed = collect_pipe_blocks syntax in - postprocessed - -(****************************************************************************** - syntax tree pretty-printing (mosty for debugging) -******************************************************************************) - -let string_of_ty = function - Identifier -> "ID " - | Curly -> "Crl" - | Square -> "Sqr" - | Quote -> "Qut" - | Let -> "Let" - | In -> "In " - | And -> "And" - | If -> "If " - | Else -> "Els" - | For -> "For" - | While -> "Whl" - | Paren -> "Par" - | Pipe -> "Pip" - | Function -> "Fnc" - | Match -> "Mch" - | Try -> "Try" - | With -> "Wth" - | Open -> "Opn" - | Fun -> "Fun" - | Type -> "Typ" - | Module -> "Mod" - | ModuleType -> "MTy" - | Struct -> "Str" - | Sig -> "Sig" - | Val -> "Val" - | Class -> "Cls" - | Method -> "Mth" - | Object -> "Obj" - | Initializer -> "Ini" - | Inherit -> "Inh" - | NamedOperand -> "Nmd" - | OptionalOperand -> "Opt" - | Constraint -> "Cns" - | Exception -> "Exn" -;; -let rec print_block_syntax pfx level syntax = - List.iter - (function - Line (ty,_,line) -> Printf.eprintf "%c%d%s %s\n" pfx level (string_of_ty ty) line - | Block block -> print_block_syntax 'B' (level + 1) block - | PipeBlock block -> print_block_syntax 'P' (level + 1) block) - syntax;; - -(****************************************************************************** - OCaml syntax formation -******************************************************************************) - -let rec nearest_line_number = function - (Line (_,num,_)) :: rest -> num - | (Block block) :: rest -> nearest_line_number block - | (PipeBlock block) :: rest -> nearest_line_number block - | [] -> 9999999 - -let rec form_expression form_rest = function - - (Line (Let,_,letline)) :: (((Line (_,_,_)) :: _) as rest) -> - endl ^ letline ^ (form_ands (form_in form_rest) rest) - | (Line (Let,_,letline)) :: (Block block) :: rest -> - endl ^ letline ^ " (" ^ (form_sequence block) ^ " )" ^ (form_ands (form_in form_rest) rest) - | (Line (Let,_,letline)) :: (PipeBlock block) :: rest -> - endl ^ letline ^ (form_patterns block) ^ (form_ands (form_in form_rest) rest) - -(* - (* it would be preferable to use begin and end instead of parentheses in the first and fourth let clauses, but this breaks object constructors (class c = let name = value in object ... end) due to ocamlc bug^H^H^Hirregularities *) - (Line (Let,_,letline)) :: (Block block) :: rest -> - endl ^ letline ^ " (" ^ (form_sequence block) ^ " )" ^ (form_ands (form_ins form_rest) rest) - | (Line (Let,_,letline)) :: (PipeBlock block) :: rest -> - endl ^ letline ^ (form_patterns block) ^ (form_ands (form_ins form_rest) rest) - | (Line (Let,_,letline)) :: ((Line (In,_,_) :: _) as rest) -> - endl ^ letline ^ (form_ands (form_ins form_rest) rest) - | (Line (Let,_,letline)) :: ((Line (Let,_,_) :: _) as rest) -> - endl ^ letline ^ " (" ^ (form_sequence rest) ^ " )" ^ (form_rest []) -*) - | (Line (If,_,ifline)) :: (Block block) :: rest -> - endl ^ ifline ^ " begin" ^ (form_sequence block) ^ " end" ^ (form_elses form_rest rest) - - | (Line (loopty,_,loopline)) :: (Block block) :: rest when loopty = For || loopty = While -> - endl ^ loopline ^ (form_sequence block) ^ " done" ^ (form_rest rest) - | (Line (loopty,_,loopline)) :: rest when loopty = For || loopty = While -> - endl ^ loopline ^ " done" ^ (form_rest rest) - - | (Line (Fun,_,line)) :: (Block block) :: rest -> " (" ^ endl ^ line ^ (form_sequence block) ^ " )" ^ (form_rest rest) - - | (Line (Function,_,line)) :: (PipeBlock block) :: rest | (Line (Match,_,line)) :: (PipeBlock block) :: rest -> - endl ^ line ^ (form_patterns block) ^ (form_rest rest) - | (Line (Match,_,matchline)) :: (Block block) :: (Line (With,_,withline)) :: rest -> - endl ^ matchline ^ " begin" ^ (form_sequence block) ^ " end" ^ endl ^ withline ^ - (match rest with - PipeBlock patterns :: rest -> - (form_patterns patterns) ^ (form_rest rest) - | _ -> form_rest rest) - - | (Line (Try,_,tryline)) :: (Block block) :: (Line (With,_,withline)) :: rest -> - endl ^ tryline ^ " begin" ^ (form_sequence block) ^ " end" ^ endl ^ withline ^ - (match rest with - PipeBlock patterns :: rest -> - (form_patterns patterns) ^ (form_rest rest) - | _ -> form_rest rest) - - (* immediate objects *) - | (Line (Object,_,line)) :: (Block block) :: rest -> - endl ^ line ^ (form_object_contents block) ^ " end" ^ (form_rest rest) - | (Line (Object,_,line)) :: rest -> - endl ^ line ^ " end" ^ (form_rest rest) - - (* local modules *) - | (Line (Struct,_,structline)) :: (Block block) :: rest -> - endl ^ structline ^ (form_module_sequence block) ^ " end" ^ (form_rest rest) - | (Line (Struct,_,structline)) :: rest -> - endl ^ structline ^ " end" ^ (form_rest rest) - | (Line (Sig,_,sigline)) :: (Block block) :: rest -> - endl ^ sigline ^ (form_module_type_contents block) ^ " end" ^ (form_rest rest) - | (Line (Sig,_,sigline)) :: rest -> - endl ^ sigline ^ " end" ^ (form_rest rest) - - | (Line (_,_,line)) :: (PipeBlock block) :: rest -> endl ^ line ^ (form_patterns block) ^ (form_rest rest) - | (Line (Identifier,_,line)) :: (Block block) :: rest -> endl ^ line ^ (form_application_operands block) ^ (form_rest rest) - | (Line (Paren,_,line)) :: (Block block) :: rest -> endl ^ line ^ (form_application_operands block) ^ (form_rest rest) - | (Line (_,_,line)) :: (Block block) :: rest -> " (" ^ endl ^ line ^ " )" ^ (form_application_operands block) ^ (form_rest rest) - | (Line (_,_,line)) :: rest -> endl ^ line ^ (form_rest rest) - | (Block block) :: rest -> failwith (Printf.sprintf "unexpected block at line %d" (nearest_line_number block)) - | (PipeBlock block) :: rest -> failwith (Printf.sprintf "unexpected pipeblock at line %d" (nearest_line_number block)) - | [] -> "" - -and form_ands form_rest = function - (Line (And,_,andline)) :: (Block block) :: rest -> - endl ^ andline ^ " begin" ^ (form_sequence block) ^ " end" ^ (form_ands form_rest rest) - | (Line (And,_,andline)) :: (PipeBlock block) :: rest -> - endl ^ andline ^ (form_patterns block) ^ (form_ands form_rest rest) - | (Line (And,_,andline)) :: rest -> - endl ^ andline ^ (form_ands form_rest rest) - | rest -> (form_rest rest) -and form_in form_rest rest = - " in (" ^ (form_sequence rest) ^ ")" ^ (form_rest []) - -(* (Line (In,_,inline)) :: (Block block) :: rest -> - endl ^ inline ^ " begin" ^ (form_sequence block) ^ " end" ^ (form_ins form_rest rest) - | (Line (In,_,inline)) :: ((Line (Let,_,_) :: _) as rest) -> - endl ^ inline ^ " begin" ^ (form_sequence rest) ^ " end" ^ (form_rest []) - | (Line (In,_,inline)) :: rest -> - endl ^ inline ^ (form_ins form_rest rest) - | rest -> form_rest rest *) - -and form_elses form_rest = function - (Line (Else,_,elseline)) :: (Block block) :: rest -> - endl ^ elseline ^ " begin" ^ (form_sequence block) ^ " end" ^ (form_elses form_rest rest) - | (Line (Else,_,elseline)) :: rest -> - endl ^ elseline ^ (form_elses form_rest rest) - | rest -> form_rest rest - -and form_naked_expressions syntax = - form_expression form_naked_expressions syntax - -and form_sequence = function - [] -> "" - | syntax -> " (" ^ (form_expression (fun rest -> " )" ^ form_rest_sequence rest) syntax) -and form_rest_sequence = function - [] -> "" - | syntax -> "; (" ^ (form_expression (fun rest -> " )" ^ form_rest_sequence rest) syntax) - -and form_application_operands = function - [] -> "" - | (Line (NamedOperand,_,line)) :: rest -> endl ^ line ^ (form_application_operands rest) - | (Line (OptionalOperand,_,line)) :: rest -> endl ^ line ^ (form_application_operands rest) - | syntax -> " (" ^ (form_expression (fun rest -> " )" ^ form_application_operands rest) syntax) - -and form_patterns = function - (Line (Pipe,_,pipeline)) :: (Block block) :: rest -> - endl ^ pipeline ^ " begin" ^ (form_sequence block) ^ " end" ^ (form_patterns rest) - | (Line (Pipe,_,pipeline)) :: rest -> - endl ^ pipeline ^ (form_patterns rest) - | [] -> "" - | (Line (_,num,_)) :: rest -> failwith (Printf.sprintf "unexpected in pattern block at line %d; this shouldn't happen" num) - | ((Block block) :: rest) as x -> failwith (Printf.sprintf "unexpected block at line %d" (nearest_line_number x)) - | ((PipeBlock block) :: rest) as x -> failwith (Printf.sprintf "unexpected pipeblock at line %d" (nearest_line_number x)) - -and form_object_contents = function - [] -> "" - | (Line (Val,_,line)) :: (Block block) :: rest -> - endl ^ line ^ " begin" ^ (form_sequence block) ^ " end" ^ (form_object_contents rest) - | (Line (Val,_,line)) :: (PipeBlock block) :: rest -> - endl ^ line ^ (form_patterns block) ^ (form_object_contents rest) - | (Line (Val,_,line)) :: rest -> - endl ^ line ^ (form_object_contents rest) - - | (Line (Method,_,line)) :: (Block block) :: rest -> - endl ^ line ^ " begin" ^ (form_sequence block) ^ " end" ^ (form_object_contents rest) - | (Line (Method,_,line)) :: (PipeBlock block) :: rest -> - endl ^ line ^ (form_patterns block) ^ (form_object_contents rest) - | (Line (Method,_,line)) :: rest -> - endl ^ line ^ (form_object_contents rest) - - | (Line (Initializer,_,line)) :: (Block block) :: rest -> - endl ^ line ^ " begin" ^ (form_sequence block) ^ " end" ^ (form_object_contents rest) - | (Line (Initializer,_,line)) :: (PipeBlock block) :: rest -> - endl ^ line ^ (form_patterns block) ^ (form_object_contents rest) - | (Line (Initializer,_,line)) :: rest -> - endl ^ line ^ (form_object_contents rest) - - | (Line (Inherit,_,line)) :: rest -> - endl ^ line ^ (form_object_contents rest) - - | (Line (Constraint,_,line)) :: rest -> - endl ^ line ^ (form_object_contents rest) - - | _ as lst -> failwith (Printf.sprintf "unexpected in object body at line %d" (nearest_line_number lst)) - -(* for recursive object types *) -and form_object_ands form_rest = function - - | (Line (And,_,andline)) :: (Block ((Line (Let,_,_) :: _) as block)) :: rest - | (Line (And,_,andline)) :: (Block ((Line (Object,_,_) :: _) as block)) :: rest -> - endl ^ andline ^ (form_sequence block) ^ (form_object_ands form_rest rest) - | (Line (And,_,andline)) :: (Block block) :: rest -> - endl ^ andline ^ (form_object_contents block) ^ " end" ^ (form_object_ands form_rest rest) - | (Line (And,_,andline)) :: (Line (Object,_,structline)) :: (Block block) :: rest -> - endl ^ andline ^ endl ^ structline ^ (form_object_contents block) ^ " end" ^ (form_object_ands form_rest rest) - | (Line (And,_,line)) :: (Line (Object,_,structline)) :: rest -> - endl ^ line ^ endl ^ structline ^ " end" ^ (form_object_ands form_rest rest) - | (Line (And,_,andline)) :: rest -> - endl ^ andline ^ " end" ^ (form_object_ands form_rest rest) - | rest -> (form_rest rest) - - -and form_module_type_contents = function - [] -> "" - | (Line (Type,_,typeline)) :: (PipeBlock block) :: rest -> - endl ^ typeline ^ (form_patterns block) ^ (form_ands form_module_type_contents rest) - | (Line (Type,_,typeline)) :: rest -> - endl ^ typeline ^ (form_ands form_module_type_contents rest) - | (Line (Open,_,line)) :: rest -> - endl ^ line ^ (form_module_type_contents rest) - | (Line (Exception,_,line)) :: rest -> - endl ^ line ^ (form_module_type_contents rest) - | (Line (Val,_,line)) :: rest -> - endl ^ line ^ (form_module_type_contents rest) - - | (Line (Module,_,line)) :: (Block ((Line (Sig,_,_) :: _) as block)) :: rest - | (Line (ModuleType,_,line)) :: (Block ((Line (Sig,_,_) :: _) as block)) :: rest -> - endl ^ line ^ (form_sequence block) ^ (form_module_type_contents rest) - - | (Line (Module,_,line)) :: (Block block) :: rest - | (Line (ModuleType,_,line)) :: (Block block) :: rest -> - endl ^ line ^ (form_module_type_contents block) ^ " end" ^ (form_module_type_contents rest) - | (Line (Module,_,line)) :: (Line (Sig,_,sigline)) :: (Block block) :: rest - | (Line (ModuleType,_,line)) :: (Line (Sig,_,sigline)) :: (Block block) :: rest -> - endl ^ line ^ endl ^ sigline ^ (form_module_type_contents block) ^ " end" ^ (form_module_type_contents rest) - - | (Line (Module,_,line)) :: rest - | (Line (ModuleType,_,line)) :: rest -> - endl ^ line (* ^ " end" *) ^ (form_module_type_contents rest) (* had to disable the end to allow: module Make (Q : IntervalType) : S with type t = Q.t *) - - | (Line (Class,_,line)) :: (Block ((Line (Object,_,_) :: _) as block)) :: rest -> - endl ^ line ^ (form_naked_expressions block) ^ " " ^ (form_object_ands form_module_type_contents rest) (* the form_naked_expressions is a hack because (object ... end) with parentheses is inexplicably a syntax error *) - | (Line (Class,_,line)) :: (Block block) :: rest -> - endl ^ line ^ (form_object_contents block) ^ " end" ^ (form_object_ands form_module_type_contents rest) - | (Line (Class,_,line)) :: (Line (Object,_,structline)) :: (Block block) :: rest -> - endl ^ line ^ endl ^ structline ^ (form_object_contents block) ^ " end" ^ (form_object_ands form_module_type_contents rest) - | (Line (Class,_,line)) :: (Line (Object,_,structline)) :: rest -> - endl ^ line ^ endl ^ structline ^ " end" ^ (form_object_ands form_module_type_contents rest) - | (Line (Class,_,line)) :: rest -> - endl ^ line ^ " end" ^ (form_object_ands form_module_type_contents rest) - - - | _ as lst -> failwith (Printf.sprintf "unexpected in module type at line %d" (nearest_line_number lst)) - -and form_module_contents form_rest = function - [] -> "" - - | (Line (Type,_,typeline)) :: (PipeBlock block) :: rest -> - endl ^ typeline ^ (form_patterns block) ^ (form_ands form_rest rest) - | (Line (Type,_,typeline)) :: rest -> - endl ^ typeline ^ (form_ands form_rest rest) - - | (Line (Open,_,line)) :: rest -> - endl ^ line ^ (form_rest rest) - - | (Line (Exception,_,line)) :: rest -> - endl ^ line ^ (form_rest rest) - - | (Line (ModuleType,_,line)) :: (Block ((Line (Sig,_,_) :: _) as block)) :: rest -> - endl ^ line ^ (form_sequence block) ^ (form_rest rest) - | (Line (ModuleType,_,line)) :: (Block block) :: rest -> - endl ^ line ^ (form_module_type_contents block) ^ " end" ^ (form_rest rest) - | (Line (ModuleType,_,line)) :: (Line (Sig,_,sigline)) :: (Block block) :: rest -> - endl ^ line ^ endl ^ sigline ^ (form_module_type_contents block) ^ " end" ^ (form_rest rest) - | (Line (ModuleType,_,line)) :: rest -> - endl ^ line ^ " end" ^ (form_rest rest) - - | (Line (Module,_,line)) :: (Block ((Line (Struct,_,_) :: _) as block)) :: rest -> - endl ^ line ^ (form_sequence block) ^ (form_rest rest) - | (Line (Module,_,line)) :: (Block block) :: rest -> - endl ^ line ^ (form_module_sequence block) ^ " end" ^ (form_rest rest) - | (Line (Module,_,line)) :: (Line (Struct,_,structline)) :: (Block block) :: rest -> - endl ^ line ^ endl ^ structline ^ (form_module_sequence block) ^ " end" ^ (form_rest rest) - - (* to allow module N = MyFunctor(M) *) - | (Line (Module,_,line)) :: rest -> - endl ^ line ^ (form_rest rest) - - (* - class c = - let name = value in - object - ... - *) - | (Line (Class,_,line)) :: (Block ((Line (Let,_,_) :: _) as block)) :: rest - (* - class c = - object - ... - *) - | (Line (Class,_,line)) :: (Block ((Line (Object,_,_) :: _) as block)) :: rest -> - endl ^ line ^ (form_naked_expressions block) ^ " " ^ (form_object_ands form_rest rest) - (* - class c = object - ... - *) - | (Line (Class,_,line)) :: (Block block) :: rest -> - endl ^ line ^ (form_object_contents block) ^ " end" ^ (form_object_ands form_rest rest) - (* - class c = - object - ... - *) - | (Line (Class,_,line)) :: (Line (Object,_,structline)) :: (Block block) :: rest -> - endl ^ line ^ endl ^ structline ^ (form_object_contents block) ^ " end" ^ (form_object_ands form_rest rest) - (* probably an unnecessary clause: - class c = - object ... - *) - | (Line (Class,_,line)) :: (Line (Object,_,structline)) :: rest -> - endl ^ line ^ endl ^ structline ^ " end" ^ (form_object_ands form_rest rest) - (* class c = object ... *) - | (Line (Class,_,line)) :: rest -> - endl ^ line ^ " end" ^ (form_object_ands form_rest rest) - -(* special case of toplevel lets, they don't need in. *) - | (Line (Let,_,letline)) :: (((Line (_,_,_)) :: _) as rest) -> - endl ^ letline ^ (form_ands form_rest rest) - | (Line (Let,_,letline)) :: (Block block) :: rest -> - endl ^ letline ^ " (" ^ (form_sequence block) ^ " )" ^ (form_ands form_rest rest) - | (Line (Let,_,letline)) :: (PipeBlock block) :: rest -> - endl ^ letline ^ (form_patterns block) ^ (form_ands form_rest rest) - - - | syntax -> (form_expression form_rest syntax) - -and form_module_sequence = function - [] -> "" - | syntax -> (form_module_contents form_rest_module_sequence syntax) -and form_rest_module_sequence = function - [] -> "" - | syntax -> " ;;" ^ (form_module_contents form_rest_module_sequence syntax) - - -(****************************************************************************** - main -******************************************************************************) - -;; -type srctype = - ML - | MLI - -let ty = ref None -let showblocks = ref false - -let arg_spec = - Arg.align - [ - ("-spaceonly",Arg.Unit (fun () -> config.whitespace_mode <- Space_only)," only allow spaces for indentation (default either spaces or tabs allowed and counted equally)"); - ("-tabonly",Arg.Unit (fun () -> config.whitespace_mode <- Tab_only)," only allow tabs for indentation"); - ("-ml",Arg.Unit (fun () -> ty := Some ML)," consider the input an implementation (.ml) file, regardless of its extension"); - ("-mli",Arg.Unit (fun () -> ty := Some MLI)," consider the input an interface (.mli) file, regardless of its extension"); - ("-showblocks",Arg.Set(showblocks)," (for debugging) print the source code's block structure to standard error") - ];; - -let usage_msg = - "Usage: ocaml+twt [options] source.ml\n" ^ - " normally the preprocessor should be invoked through ocamlc, e.g.\n" ^ - " ocamlc -pp ocaml+twt source.ml\n" ^ - " to invoke the preprocessor with options through ocamlc, quote the command, e.g.\n" ^ - " ocamlc -pp \"ocaml+twt -spaceonly\" source.ml\n" ^ - " options:" - -let input_fname = ref "";; -Arg.parse arg_spec (fun s -> input_fname := s) usage_msg;; -let input_fname = !input_fname;; -let showblocks = !showblocks;; - -if input_fname = "" then - (Arg.usage arg_spec usage_msg; - exit 2);; - -let ty = - match !ty with - Some x -> x - | None -> - if Filename.check_suffix input_fname ".ml" || Filename.check_suffix input_fname ".ml+twt" then - ML - else if Filename.check_suffix input_fname ".mli" || Filename.check_suffix input_fname ".mli+twt" then - MLI - else - (Printf.eprintf "don't know what to do with %s\n" Sys.argv.(1); - exit 2);; - -let chan = open_in input_fname -let reader = new line_reader chan;; -let syntax = parse reader;; - -if showblocks then - (print_block_syntax 'T' 0 syntax; - flush_all ()) - -let printer = - match ty with - ML -> form_module_sequence - | MLI -> form_module_type_contents -;; - -Printf.printf "#1 \"%s\"\n" input_fname;; -print_string ( Str.replace_first (Str.regexp "\n") "" (printer syntax) );; - Binary files /tmp/_gWh3A_UWN/semantik-0.7.3/waf and /tmp/YNuC9JdPw2/semantik-0.8.3/waf differ diff -Nru semantik-0.7.3/wscript semantik-0.8.3/wscript --- semantik-0.7.3/wscript 2009-08-30 11:35:35.000000000 +0000 +++ semantik-0.8.3/wscript 2012-10-21 10:09:17.000000000 +0000 @@ -1,41 +1,18 @@ #! /usr/bin/env python # encoding: utf-8 -# Thomas Nagy, 2007-2009 (pvm) +# Thomas Nagy, 2007-2012 (ita) -APPNAME='semantik' -VERSION='0.7.3' +APPNAME = 'semantik' +VERSION = '0.8.3' -srcdir = '.' -blddir = 'build' +top = '.' -import os, sys, re -import Task, Utils, Configure, Options, Logs - -try: import hashlib as md5 -except: import md5 - -#import Configure -#Configure.autoconfig = 1 - -#Params.g_autoconfig=1 - -def dist(): - from Scripting import dist - filename = dist(APPNAME, VERSION) - f = file(filename,'rb') - m = md5.md5() - readBytes = 100000 - while (readBytes): - readString = f.read(readBytes) - m.update(readString) - readBytes = len(readString) - f.close() - print filename, m.hexdigest() - sys.exit(0) +import os, sys, re, time +from waflib import Options, Logs, Configure def compile_py(task): - outfile = task.m_outputs[0].abspath(task.m_env) - f = open(outfile, 'w') + outfile = task.m_outputs[0].abspath() + f = open(outfile, 'w') # cpython close the file handles for you w = f.write w('\n\n') for k in task.m_inputs: @@ -46,104 +23,65 @@ f.close() def build(bld): - env = bld.env_of_name('default') - - Options.options.compile_targets = 'camlprog,util/ocamltwt,nablah,src/semantik' - - os.environ['LD_LIBRARY_PATH'] = env['LIBPATH_KDECORE']+':'+os.environ.get('LD_LIBRARY_PATH', '') - import ocaml - ocaml.open_re = re.compile('open ([a-zA-Z]+)', re.M) + os.environ['LD_LIBRARY_PATH'] = ':'.join(bld.env['LIBPATH_KDECORE'] + [os.environ.get('LD_LIBRARY_PATH', '')]) + bld.targets = '*' # build all targets by default - ibj = bld.new_task_gen('ocaml') - ibj.type = 'native' - ibj.includes = 'util' - ibj.find_sources_in_dirs('util') - ibj.target = 'util/ocamltwt' - ibj.are_deps_set=1 - ibj.uselib='PP' - - bld.add_group() - - abj = bld.new_task_gen('ocaml') - abj.type = 'c_object' - abj.find_sources_in_dirs('src', exts=['.c', '.ml', '.mli']) - abj.includes='. src' - abj.target='camlprog' - abj.are_deps_set = 1 - abj.uselib = 'TWT' - - ''' - ibj = bld.new_task_gen(features=['cxx', 'qt4', 'cshlib'], target = 'nablah', uselib='QTCORE QTGUI QTWEBKIT', includes='. src src/wp') - ibj.find_sources_in_dirs('src/wp', exts=['.cpp']) - ibj.install_path = '${KDE4_LIB_INSTALL_DIR}/' - ibj.post() - ''' - - ibj = bld.new_task_gen(features = 'cxx qt4 cshlib') - ibj.find_sources_in_dirs('src/wp', exts=['.cpp']) - ibj.target = 'nablah' - ibj.uselib = 'QTCORE QTGUI QTWEBKIT' - ibj.includes='. src src/wp' - ibj.install_path = '${KDE4_LIB_INSTALL_DIR}/' - - import time - obj = bld.new_task_gen(features='cxx qt4 cprogram pyembed') - obj.find_sources_in_dirs('src src/fig', excludes=['src/aux.c'], exts=['.cpp']) - obj.uselib = 'QTCORE QTGUI QTXML QTSVG CAML NABLAH KDECORE KIO KDEUI KHTML' - obj.uselib_local = 'nablah' - obj.target = 'src/semantik' - obj.install_path = '${KDE4_BIN_INSTALL_DIR}/' - #obj.defines = ['''TT1=\'"%s"\'''' % time.ctime(), '''TT2='"%s"' ''' % time.ctime(), 'foo=2'] - - obj.includes = '. src src/fig' - obj.add_objects = 'camlprog' - - import Task - Task.TaskBase.classes['ocalinkx'].before = 'cxx_link' + bld( + features = 'cxx qt4 cxxshlib', + source = bld.path.ant_glob('src/wp/*.cpp'), + target = 'nablah', + use = 'QTCORE QTGUI QTWEBKIT', + includes='. src src/wp', + install_path = '${KDE4_LIB_INSTALL_DIR}/') + + bld(features='cxx qt4 cxxprogram pyembed', + source = bld.path.ant_glob('src/*.cpp src/fig/*.cpp'), + use = 'QTCORE QTGUI QTXML QTSVG NABLAH KDECORE KIO KDEUI KHTML nablah', + target = 'src/semantik', + install_path = '${KDE4_BIN_INSTALL_DIR}/', + includes = '. src src/fig') bld.install_files('${SEMANTIK_DIR}', 'src/sembind.py') rt = 'src/templates/' - bld.install_files('${SEMANTIK_DIR}/flags', 'src/flags/*.svg') - bld.install_files('${TEMPLATE_DIR}', rt+'*.py') + glob = bld.path.ant_glob + + bld.install_files('${SEMANTIK_DIR}/flags', glob('src/flags/*.svg')) + bld.install_files('${TEMPLATE_DIR}', glob(rt+'*.py')) - if Options.is_install: - tgt = bld.env_of_name('default')['TEMPLATE_DIR']+'waf' - if env.get_destdir(): tgt = os.path.join(env.get_destdir(), tgt.lstrip(os.sep)) - bld.do_install(os.path.abspath('waf'), tgt) + bld.install_as('${TEMPLATE_DIR}/waf', 'waf') - bld.install_files('${TEMPLATE_DIR}/pdflatex', rt+'pdflatex/*') + bld.install_files('${TEMPLATE_DIR}/pdflatex', glob(rt+'pdflatex/*')) for x in 'html odt odp java'.split(): - bld.install_files('${TEMPLATE_DIR}/' + x, rt+'%s/*' % x) + bld.install_files('${TEMPLATE_DIR}/' + x, glob(rt+'%s/*' % x)) for x in "color font inner outer theme".split(): k = 'beamer/beamermindist/themes/' - bld.install_files('${TEMPLATE_DIR}/' + k+x, rt+k+x+'/*') + bld.install_files('${TEMPLATE_DIR}/' + k+x, bld.path.ant_glob(rt+k+x+'/*')) - obj = bld.new_task_gen('msgfmt') - obj.appname = 'semantik' - obj.langs=['src/po/'+x for x in 'fr es'.split()] + obj = bld(features='msgfmt', appname = 'semantik', langs=[x.path_from(bld.path).replace('.po', '') for x in bld.path.ant_glob('src/po/*.po')]) - bld.install_files('${TEMPLATE_DIR}/beamer/beamermindist/art/', rt+'beamer/beamermindist/art/*') - bld.install_files('${TEMPLATE_DIR}/beamer/beamermindist/', rt+'beamer/beamermindist/*.???') + bld.install_files('${TEMPLATE_DIR}/beamer/beamermindist/art/', glob(rt+'beamer/beamermindist/art/*')) + bld.install_files('${TEMPLATE_DIR}/beamer/beamermindist/', glob(rt+'beamer/beamermindist/*')) bld.install_files('${TEMPLATE_DIR}/beamer/', rt+'beamer/main.tex') bld.install_files('${TEMPLATE_DIR}/beamer/', rt+'beamer/wscript') bld.install_files('${TEMPLATE_DIR}/s5', rt+'s5/index.html') - bld.install_files('${TEMPLATE_DIR}/s5/ui/default/', rt+'s5/ui/default/*') - bld.install_files('${SEMANTIK_DIR}/images', 'src/images/*.svg') - bld.install_files('${FILTER_DIR}/', 'src/filters/*') + bld.install_files('${TEMPLATE_DIR}/s5/ui/default/', glob(rt+'s5/ui/default/*')) + bld.install_files('${SEMANTIK_DIR}/images', glob('src/images/*.svg')) + bld.install_files('${FILTER_DIR}/', glob('src/filters/*')) bld.install_files('${KDE4_XDG_APPS_INSTALL_DIR}/', 'src/data/semantik.desktop') bld.install_as('${KDE4_ICON_INSTALL_DIR}/hicolor/128x128/apps/semantik.png', 'src/data/hi128-app-semantik.png') bld.install_as('${KDE4_ICON_INSTALL_DIR}/hicolor/64x64/apps/semantik.png', 'src/data/hi64-app-semantik.png') bld.install_as('${KDE4_ICON_INSTALL_DIR}/hicolor/48x48/apps/semantik.png', 'src/data/hi48-app-semantik.png') + bld.install_as('${KDE4_ICON_INSTALL_DIR}/hicolor/32x32/apps/semantik.png', 'src/data/hi32-app-semantik.png') bld.install_as('${KDE4_ICON_INSTALL_DIR}/hicolor/22x22/apps/semantik.png', 'src/data/hi22-app-semantik.png') bld.install_files('${KDE4_DATA_INSTALL_DIR}/semantik', 'src/data/semantikui.rc src/data/tips') - if Options.commands['install'] or Options.commands['uninstall']: + if bld.cmd in ['install', 'uninstall']: lst = os.listdir('src/images') lst = [x for x in lst if (x.rfind('hi')>-1)] for x in lst: @@ -162,9 +100,9 @@ err = "Semantik cannot work on %s, please install a Linux system from http://www.opensuse.org" if (test('linux')): - Utils.pprint('GREEN', "You are using Linux, that's good (tm)") + Logs.pprint('GREEN', "You are using Linux, that's good (tm)") elif (test('bsd')): - Utils.pprint('GREEN', "You are using a BSD system, that's good (tm)") + Logs.pprint('GREEN', "You are using a BSD system, that's good (tm)") elif (test('win32') or test('cygwin')): conf.fatal(err % "win32") elif (test('darwin')): @@ -172,84 +110,115 @@ elif (test('solaris') or test('sunos')): conf.fatal(err % "Sun systems") - kde_config = os.popen("which kde-config").read().strip() if kde_config: icons = os.popen('%s --path icon' % kde_config).read().strip() else: icons = '/usr/share/icons:/usr:/etc/opt/kde3/share/icons/:/opt/kde3/share/icons/:/var/lib/mandriva/kde-profiles/powerpackplus/share/icons/:/usr/share/icons/' if not Options.options.icons: - Logs.warn("For now Semantik uses a few kde icons - if you have problems seeing the icons install kde") + Logs.warn("For now Semantik uses a few kde icons - if you have problems seeing the icons install kdebase") if Options.options.icons: icons = Options.options.icons - conf.check_tool('gcc g++ qt4') + conf.load('gcc g++ qt4') if not conf.env.CXX: conf.fatal('Semantik requires g++ (compilation only)') if not conf.env.QT_LRELEASE: conf.fatal('Semantik requires the program lrelease (from the Qt linguist package? - compilation only)') - conf.check_tool('python') - if conf.env.HAVE_QTWEBKIT != 1: conf.fatal('QtWebKit not found - Semantik requires Qt >= 4.4') + conf.load('python') + if not conf.env.LIB_QTWEBKIT: conf.fatal('QtWebKit not found - Semantik requires Qt >= 4.4') if not conf.env.PYTHON: conf.fatal('Semantik requires Python >= 2.5 (development package for the compilation)') conf.check_python_version((2,4,2)) conf.check_python_headers() if not conf.env.PYTHON_VERSION in "2.4 2.5 2.6 2.7".split(): Logs.warn('Bad Python version %s ' % str(conf.env.PYTHON_VERSION)) - conf.check_tool('ocaml') - if not conf.env.OCAMLOPT: conf.fatal('Semantik requires ocamlopt (compilation only)') - - #ret = Utils.cmd_output('python-config --cflags').strip().split() - #conf.env.append_value('CXXFLAGS_CAML', ret) + #ret = ctx.cmd_output('python-config --cflags').strip().split() try: - conf.check_tool('kde4') - Utils.pprint('GREEN', "And you even have kde4! we will use it") + conf.load('kde4') + Logs.pprint('GREEN', "And you even have kde4! we will use it") except Configure.ConfigurationError: raise - #Utils.pprint('YELLOW', "kde4 is disabled (missing)") + #Logs.pprint('YELLOW', "kde4 is disabled (missing)") conf.fatal('Compiling Semantik requires kde4 -devel') - conf.env.OCALINKFLAGS_OPT_PP = 'str.cmxa' - conf.env.LINKFLAGS_CAML = '-lasmrun -lstr -lnums'.split() - conf.env.LIBPATH_CAML = conf.env.OCAMLLIB - conf.env.LIB_CAML = "m".split() - conf.env.OCAMLFLAGS_TWT = '-pp default/util/ocamltwt'.split() #-unsafe -noassert -inline 10' - conf.env.CXXDEFINES ='WAF' + conf.env.DEFINES = 'WAF' conf.define('ICONS', icons) conf.define('VERSION', VERSION) - conf.define('SEMANTIK_DIR', conf.env.KDE4_DATA_INSTALL_DIR + '/semantik') - conf.define('TEMPLATE_DIR', conf.env.KDE4_DATA_INSTALL_DIR + '/semantik/templates/') - conf.define('FILTER_DIR', conf.env.KDE4_DATA_INSTALL_DIR +'/semantik/filters/') + conf.env.SEMANTIK_DIR = conf.env.KDE4_DATA_INSTALL_DIR + '/semantik' + conf.define('SEMANTIK_DIR', conf.env.SEMANTIK_DIR) + + conf.env.TEMPLATE_DIR = conf.env.KDE4_DATA_INSTALL_DIR + '/semantik/templates/' + conf.define('TEMPLATE_DIR', conf.env.TEMPLATE_DIR) + conf.env.FILTER_DIR = conf.env.KDE4_DATA_INSTALL_DIR +'/semantik/filters/' + conf.define('FILTER_DIR', conf.env.FILTER_DIR) conf.env.PICDIR = conf.env.KDE4_ICON_INSTALL_DIR #j('share/pixmaps/') + conf.define('cmd_add_item', 0) + conf.define('cmd_update_item', 1) + conf.define('data_root', os.sep) + conf.define('cmd_remove_item', 2) + conf.define('cmd_link', 3) + conf.define('cmd_unlink', 4) + conf.define('data_outdir', 'tmp') + conf.define('cmd_select_item', 5) + conf.define('cmd_sort_item', 6) + conf.define('cmd_save_data', 7) + conf.define('cmd_update_colors', 8) + conf.define('cmd_update_flags', 9) + conf.define('cmd_open_map', 10) + conf.define('cmd_pre_view', 11) + conf.define('cmd_change_data', 12) + conf.define('cmd_export_item', 13) + + lst = [x for x in conf.path.find_node('src/styles.txt').read().splitlines()] + buf = [] + for x in lst: + if not x: continue + t = x.split('\t') + buf.append("""xp(x,%d,"%s");yp(x,%d,trUtf8("%s"));""" % (len(buf), t[0], len(buf), t[1].replace('"', '\\"'))) + conf.define('fillglo(x)', ''.join(buf), quote=False) + + lst = [x for x in conf.path.find_node('src/styles_local.txt').read().splitlines()] + buf = [] + for x in lst: + if not x: continue + t = x.split('\t') + buf.append("""xp(x,%d,"%s");yp(x,%d,trUtf8("%s"));""" % (len(buf), t[0], len(buf), t[1].replace('"', '\\"'))) + conf.define('fillloc(x)', ''.join(buf), quote=False) + if Options.options.use64: conf.env.shlib_INST_DIR = 'lib64' conf.env.CXXFLAGS_PYEMBED = [x for x in conf.env.CXXFLAGS_PYEMBED if x != '-g'] - conf.env.CXXFLAGS = '-O2 -pipe -Wall'.split()# -DDEBUG=1 -g' + if not 'CXXFLAGS' in os.environ: + conf.env.CXXFLAGS = '-O2 -pipe -Wall'.split()# -DDEBUG=1 -g' + #conf.env.CXXFLAGS = ['-g'] conf.write_config_header('aux.h') # the Debian packagers compile with --prefix=/usr and set /etc/ld.so.conf accordingly # the rpath is for end users installing into /usr/local/lib only sur = '/usr/local' if Options.options.prefix[:len(sur)] == sur: - conf.env.RPATH_NABLAH = '-Wl,--rpath=/usr/local/lib' + conf.env.RPATH_NABLAH = '/usr/local/lib' + + conf.define('GAP', 50, quote=False) -def set_options(opt): - opt.tool_options('kde4') - opt.tool_options('qt4') - opt.tool_options('python') +def options(opt): + opt.load('kde4') + opt.load('qt4') + opt.load('python') opt.add_option('--exe', action='store_true', default=False, help='execute after the compilation (developers)') opt.add_option('--icons', action='store', default='', help='icon dirs where to look for kde icons (configuration)') opt.add_option('--use64', action='store_true', default=False, help='set the installation into lib+64 (configuration)') def post_build(bld): - if Options.commands['install']: - try: os.popen('/sbin/ldconfig 2> /dev/null') + if bld.cmd == 'install': + try: bld.exec_command('/sbin/ldconfig 2> /dev/null') except: pass if Options.options.exe: - #os.popen('export LD_LIBRARY_PATH=build/default/:$LD_LIBRARY_PATH; PATH=plugins:$PATH build/default/src/semantik') - os.popen('LD_LIBRARY_PATH=build/default/:$LD_LIBRARY_PATH build/default/src/semantik --style plastique') + #os.popen('export LD_LIBRARY_PATH=out/default/:$LD_LIBRARY_PATH; PATH=plugins:$PATH out/default/src/semantik') + bld.exec_command('LD_LIBRARY_PATH=build/:$LD_LIBRARY_PATH build/src/semantik --style plastique', stdout=None, stderr=None) return # display the graph of header dependencies @@ -274,8 +243,8 @@ try: os.popen('dot -Tpng me.dot -ofoo.png').read() except: - print "the dot program was not found - install graphviz?" + Logs.pprint("the dot program was not found - install graphviz?") else: - print "generated foo.png" + Logs.pprint("generated foo.png")