[scribus-dev] Tables GSoC - Weekly Report #8 and #9 - Double Report

Elvis Stansvik elvstone at gmail.com
Mon Aug 1 21:52:39 UTC 2011

Hi all,

Although I'm still on the meds, my health is now pretty much back to
normal and I'm hacking full time again. So it's high time for another
report [1].

This report covers the past ~2 weeks and is of course quite meagre
given the time period it covers. This is due to my illness. Here's a
very short screencast of some of the recent progress (on-canvas



[1] http://wiki.scribus.net/canvas/GSoC_2011_Tables_Weekly_Reports

= Tables GSoC - Weekly Report #8 and #9 - Double Report =

== Work Report ==
* Fixed the old code for painting the overflow marker and moved it up
to PageItem.
* Added isOverflowing() API to PageItem_Table and added painting of
the overflow marker to the table painting code.
* Added cellAt(QPointF, QPointF) API to PageItem_Table.
* Added the skeletons of a canvas mode for editing tables.
* Added hitTest(QPointF point, qreal threshold) to PageItem_Table.
Given a point in canvas coordinates, this function will return a
PageItem_Table::Handle object that describes what was hit.
* Added support for resizing rows and columns interactively.
* Added support for resizing the entire table interactively.
* Lots of minor cleanups, API improvements and a few bugfixes along the way.

== Project Status ==
On my schedule for the past week was work on the styles

* Table/row/column/cell styles.
* UI: Direct formatting.
* UI: Integration of styles in Style Manager.

but instead I decided to work the on-canvas manipulation of the
tables. One of the reasons I did this was that I feel that I've
already been touching the PP and SM code and feel that it is mostly
mundane work, while I hadn't looked at the canvas modes/gesture code
at all. So I felt that I needed to get my hands dirty there as well,
to get a good feel for how much work is involved.

Getting the canvas modes up and running turned out to be quite easy --
the majority of the work on them was done in the past two days. I feel
confident now that I'll manage to finish the remaining ones (cell
selections and I guess context menus for adding/removing rows/columns,
merging cells et.c.).

The unfortunate thing that happened since my last report was that I
fell very ill with what I first thought was just a flu. But after a
doctors visit when the fever went up, it was discovered to be a more
serious infection, one which I'm now on antibiotics for. But
eventhough I'm still on the meds, I feel a lot better now and can work
full time again. My work on the project did suffer a bit though.

== Problems / Questions ==
1) As mentioned in another thread on the ML, I can't seem to get the
guides and grid shown. For some reason they are always invisible for
me, even though I have "Show Grid" and "Show Guides" on. Any ideas?
I've tried changing their colors, putting the in foreground/background
as well as wiping ~/.scribus. If anyone is testing my repo, it would
be great if you could check. I really hope I didn't break anything and
that it's just some weird graphics issue or something (I'm on nvidia).
But I don't think I've touched any of those code paths.

2) When I wanted to have the selection of the table painted similar to
that of a text frame when it is edited (e.g. just a red rect, no
handles), I found that I could do this by calling
CanvasMode::commonDrawControls(). However, I discovered something that
I think is kind of nasty; if you take a look at
CanvasMode::drawSelection(), which is called by commonDrawControls(),
you'll see that it performs transformations on the painter without
save()ing and restore()ing it properly. I discovered this since I was
doing my own transformation of the painter. Okay I thought, I'll just
fix that, so I added save() and restore(). I then discovered that a
lot of the current items rely on this behavior. I really doubt this
was intended? So it is a bit of a work to make a proper fix. At the
moment I worked around it by guarding my call to
CanvasMode::commonDrawControls() with save()/restore() myself, e.g.:


but this is a hack. Just thought I'd give a heads up on this.

3) Minor question; I guess c++0x is still off limits for Scribus code?

4) InDesign draws a simply blue grid while a table is resized, without
any respect for cell spans/column spans. In my implementation, the
blue grid will respect row span / column span. Which one do we want? I
guess ID did it like this because its simpler (and possibly slightly

5) Now that I've worked a bit with the canvas mode code, I've gotten
this idea in my head for the editing of cell text content; what if I
create a canvas gesture that simply acts as a proxy to an instance of
the real text editing canvas mode (CanvasMode_Edit), which would be
set up to edit the text frame of the cell being edited? Do you think
such an approach could work? This proxy gesture would forward all
events (possibly intercepting some of them for cell navigation). It
might even be activated when a cell is hovered with the mouse, which
would save us from multiple layers of modes having to be activated by
the user to be able to edit cell content (But for a start, I would
activate it on double click on a cell). The approach has a slightly
hacky vibe to it, but if it could work I think it would be great as
all the functionality of the existing text editing canvas mode could
be leveraged. And what is really the alternative? Someone (was it
avox?) mentioned in another thread that one should simply forward
mouse presses and use insertText() in the keyboard event or something
to that effect? Perhaps this is what was meant...

Anyway, too many questions already for one report :)

== Next Week ==
It feels like this time, this is the most important section of the
report. In my mind, there are four main areas I need to focus hard on
in these last weeks of the project. In order of priority, they are

1) Finish off the canvas modes / gestures I'm working on now. This includes

a) Finding a good way for the table to represent cell selections. I'm
thinking a new CellSelection class that simply keeps a QSet of the
selected cells, with convenience functions such as (de)selectCell(int,
int), toggleCell(int, int), (de)selectRow(int), (de)selectColumn(int),
selectTable(), clear() et.c.

b) Adding some form of context menu with actions such as "Insert
Rows...", "Insert Columns...", "Merge Cells" et.c. I plan to look at
this tomorrow.

c) Add the possibility to move the boundary between two rows or
columns independently of the other boundaries.

d) Add some form of tooltip popup that shows the numeric information
when resizing a row/column.

2) Integrate text frames. Each cell should store a text frame and an
associated story text, and the table layout code will have to be
extended to adjust these as part of its layout procedure.

3) Finish off PP and SM UI for direct editing and editing of styles.
This includes among other things a way to set column widths / row
heights numerically.

4) Loading and saving (Low priority since I believe it will mostly be
mundane work)

If I have many days like today, getting lots of stuff done, I believe
this to be possible before the firm pencils down date on Aug 22. And
as I said in my proposal, I'll keep working full time on the project
for another week after that, until school starts (and of course after
that as well, to the best of my abilities).

More information about the scribus-dev mailing list