[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Explanation on the current inner working of the changeTracker
From:       Pierre Stirnweiss <pierre.stirnweiss () t-online ! de>
Date:       2009-04-19 18:32:05
Message-ID: 200904192032.05929.pierre.stirnweiss () t-online ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello there,

I have now finished a very basic implementation of the text changeTracker (the 
only thing missing is a way to disable it).
However, the code is very rough around the edges and already some issues creep 
up at other places. So in order to allow other people to understand what's 
going on and perhaps give me some advices, here is a quick explanation of the 
functioning of it:

- first a changeTracker is created. this uses the same mechanism as the 
styleManager. it is added to the dataCenterMap and set on every textShape's 
document.

- the editing actions (currently text typing, bold and italic) request the 
changeTracker for a changeId. The changeTracker creates a changeTrackerElement 
(which holds the info about the change: date, creator,...). On edit, a 
property is added to the QTextCharFormat. This property has the 
KoCharacterStyle::changeTrackerId as key and the given changeId as value.
This way allows the QTextDocument to handle the undo/redo.

- the saving is inspired by the style saving mechanism: the changeTracker is 
first asked to save the changes info in a KoGenChanges. Every change is a 
KoGenChange. This mimics the KoGenStyles/KoGenStyle mechanism. The only 
difference is that the KoGenChanges is added as a KoSharedSavingData to the 
context (whereas KoGenChanges is a member of the context itself).
Then, when the textWriter saves the paragraphs, it chaecks for the charFormat 
property (indicating a change), if a change is found, KoGenChanges is queried 
for the id and the tag <change-region> is created.
The changes info are stored within  <text:changed-region> element. These 
elements should be between the <office:text> tag and the first <text:_>. In order 
to achieve this, a specific xmlWriter is used.

- the loading is similar to the loading of the styles: the changed-regions 
info are loaded to the changeTracker. Then on loading the paragraphs, when a 
<change-start> is encountered, the KoCharacterStyle::changeTrackerId is set 
with the corresponding changeId.

- the display is just a proof of concept stuff: the layout paint a green 
background on insert change and a blue one on format change. In the 
textTool::mouseMoveEvent, I have set a timer to display a KPassivePopup with 
the change info, when a change is hovered more than 2 seconds. But this is 
really just a temporary stuff to display the change info.

Thanks for your advices/remarks,...

Pierre

[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" \
content="1" /><style type="text/css">p, li { white-space: pre-wrap; \
}</style></head><body style=" font-family:'DejaVu Sans'; font-size:10pt; \
font-weight:400; font-style:normal;">Hello there,<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>I \
have now finished a very basic implementation of the text changeTracker (the only \
thing missing is a way to disable it).<br> However, the code is very rough around the \
edges and already some issues creep up at other places. So in order to allow other \
people to understand what's going on and perhaps give me some advices, here is a \
quick explanation of the functioning of it:<br> <p style="-qt-paragraph-type:empty; \
margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; \
-qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>- first a \
changeTracker is created. this uses the same mechanism as the styleManager. it is \
added to the dataCenterMap and set on every textShape's document.<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>- \
the editing actions (currently text typing, bold and italic) request the \
changeTracker for a changeId. The changeTracker creates a changeTrackerElement (which \
holds the info about the change: date, creator,...). On edit, a property is added to \
the QTextCharFormat. This property has the KoCharacterStyle::changeTrackerId as key \
and the given changeId as value.<br> This way allows the QTextDocument to handle the \
undo/redo.<br> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br></p>- the saving is inspired by the style saving mechanism: \
the changeTracker is first asked to save the changes info in a KoGenChanges. Every \
change is a KoGenChange. This mimics the KoGenStyles/KoGenStyle mechanism. The only \
difference is that the KoGenChanges is added as a KoSharedSavingData to the context \
(whereas KoGenChanges is a member of the context itself).<br> Then, when the \
textWriter saves the paragraphs, it chaecks for the charFormat property (indicating a \
change), if a change is found, KoGenChanges is queried for the id and the tag \
&lt;change-region&gt; is created.<br> The changes info are stored within  \
&lt;text:changed-region&gt; element. These elements should be between the \
&lt;office:text&gt; tag and the first &lt;text:_&gt;. In order to achieve this, a \
specific xmlWriter is used.<br> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><br></p>- the loading is similar to the loading \
of the styles: the changed-regions info are loaded to the changeTracker. Then on \
loading the paragraphs, when a &lt;change-start&gt; is encountered, the \
KoCharacterStyle::changeTrackerId is set with the corresponding changeId.<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>- \
the display is just a proof of concept stuff: the layout paint a green background on \
insert change and a blue one on format change. In the textTool::mouseMoveEvent, I \
have set a timer to display a KPassivePopup with the change info, when a change is \
hovered more than 2 seconds. But this is really just a temporary stuff to display the \
change info.<br> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"><br></p>Thanks for your advices/remarks,...<br> \
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"><br></p>Pierre</p></body></html>



_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic