summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* QGraphicsAnchorLayout: add both vertex information in anchor dataCaio Marcelo de Oliveira Filho2009-08-143-41/+48
| | | | | | | | | | | | | Make AnchorData aware of both vertices instead only one (the origin). This information is useful for many functions when working in simplified mode. Changed the name "origin" to "from", and add an "to" field. Also change setAnchorSizeHintsFromItems() and its helpers to make use of this information. In a later commit we will rollback to using recursion for initializing the size hint information. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: size hint updated in a simplified graphCaio Marcelo de Oliveira Filho2009-08-142-123/+196
| | | | | | | | | | | | | | | | | This commit makes setAnchorSizeHintsFromItems() support a simplified graph. Instead of going recursively, since AnchorData doesn't have all needed information, we make a list with all anchors/vertexpairs with dependencies first. That way we are sure to fill all information, and the group anchors can peek at its children anchors (dependencies) and they'll have updated information. This solutions doesn't require refreshSizeHints(). Alternative solutions that we might consider are: complementing the AnchorData information or making refreshSizeHints() take two AnchorVertex as parameters and use the recursive approach. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: prepare ground for doing less simplificationsCaio Marcelo de Oliveira Filho2009-08-133-15/+57
| | | | | | | | | | | | | | | | | | Add variables to track whether the graph is simplified or not, as well as make the functions that need it simplified/restored call the corresponding functions. The functions look at the state variables, so it's safe to just call them. Also added Q_ASSERT() through the code paths that SHOULD have the full graph (not simplified), for making easy to track bugs in future refactorings. Ironically this commit cause more calls to simplify/restore right now, but the state will be better when we fix some functions to be simplification compatible ;-) Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: implement "deep" simplificationCaio Marcelo de Oliveira Filho2009-08-132-6/+35
| | | | | | | | | | | | Re-start the simplification procedure every time there's a change it the adjacent count of a vertex -- which happens when a new parallel anchor is created. The original algorithm stopped some simplifications too early, demanding the simplex unnecessarily. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: enable simplificationCaio Marcelo de Oliveira Filho2009-08-131-1/+6
| | | | | | | | Enable simplification by default. Allow disable during runtime by using the environment variable QT_ANCHORLAYOUT_NO_SIMPLIFICATION=1 when running the code. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGraphicsAnchorLayout: adding small debug messagesCaio Marcelo de Oliveira Filho2009-08-132-1/+8
| | | | | | Useful for verifying whether Simplex is being triggered or not. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGraphicsAnchorLayout: remove unused functionCaio Marcelo de Oliveira Filho2009-08-132-31/+0
| | | | | | | | The function setAnchorSizeHintsFromDefaults() is not necessary, since a more updated version (ready or almost-ready for simplification) was added: setAnchorSizeHintsFromItems(). Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGraphicsAnchorLayout: simplify updating of anchor sizesCaio Marcelo de Oliveira Filho2009-08-131-45/+13
| | | | | | | | | Instead of going through all anchors after the calculation of the graphs, do it as early as possible for each part (trunk and nonTrunks) and recursively updates the children in case of a simplified graph. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: use pickEdge()Caio Marcelo de Oliveira Filho2009-08-131-7/+1
| | | | Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGraphicsAnchorLayout: fix merging of preferredSizeHintCaio Marcelo de Oliveira Filho2009-08-131-2/+20
| | | | | | | | | | | | | | In simplification, the preferred size of a parallel group should get the maximum preferred size (and bound it to the maximum size). This follows the principle that for an layout item: 'growing is better than shrinking', and is consistent with what our linear program also do. This patch also make sure that the sizeAt* are properly initialized to the preferred size, the idea is if there's no restriction upon an anchor, it'll keep it's preferred size no matter what. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* QGraphicsAnchorLayout: fix restore simplification logicCaio Marcelo de Oliveira Filho2009-08-121-31/+13
| | | | Patch from Jan-Arve.
* QGraphicsAnchorLayout: add a dumper function for AnchorDataCaio Marcelo de Oliveira Filho2009-08-122-0/+20
| | | | Patch from Jan-Arve.
* Revert "QGraphicsAnchorLayoutPrivate: Avoiding extra loops in getGraphParts"Caio Marcelo de Oliveira Filho2009-08-121-6/+17
| | | | | | | | | This reverts commit 9e701f76f7478ea078e58076c91fee0d2ec505b4 and also add a comment explaining why is needed to delay the creation of the nonTrunkVariables to a later moment. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
* Update Anchor Layout APIArtur Duque de Souza2009-08-122-27/+59
| | | | | | | | More user friendly API for anchor layouts. Changed method names and also provided more methods to receive spacing. Signed-off-by: Artur Duque de Souza <artur.souza@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* restoring simplified anchors did not work properly recursively.Jan-Arve Sæther2009-08-121-27/+51
|
* Disable simplification and restoration since it still has problems.Jan-Arve Sæther2009-08-121-2/+2
|
* Fix implementation of setAnchorSizeHintsFromItems to be simplificationJan-Arve Sæther2009-08-122-48/+70
| | | | ready.
* Fix a bug in removeAnchors and reorder how anchors are removed.Jan-Arve Sæther2009-08-122-35/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem was that if an item had a center anchor and we removed the left-center anchor before we called removeCenterAnchors(). Suppose the center vertex had 3 edges, (refcount was 3) removeAnchor would then *first* remove the left-center edge, causing the internalVertex refcount to go to 2. That would cause removeInternalVertex() to try to "merge" the two center anchors by calling removeCenterAnchors(). Of course, calling removeCenterAnchors at that point did not work since removeCenterAnchors() assumed that the only two edges connected to the center vertex was its internal left-center and center-right anchors. This was not the case, and the assertion Q_ASSERT(first && center && last); was triggered, since first (or last) was removed at that point. Of course it was not enough to simply call removeCenterAnchors first, because that function assumed that the only two anchors connected to the center vertex was "internal center anchors". removeAnchors is a bit special since we are not really interested in first converting the "internal center anchors" to a single internal anchor because the ultimate goal of that function is to remove *all* anchors. The solution was the additional argument "substitute" to indicate that we really just want to substitute with a simpler anchor (normal behaviour). If not, we really just want to delete the center anchors (don't even try to merge them into a simple internal anchor).
* Added Graph::connections().Jan-Arve Sæther2009-08-121-0/+40
| | | | | | | This gives a list of all "edges" in the graph, but each edge is specified as a pair of vertices, since you cannot easily know the two AnchorVertex'es of an EdgeData. Added some debug stuff.
* QGraphicsAnchorLayout: Enable graph simplificationEduardo M. Fleury2009-08-101-18/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit enables graph simplification in its simplest way, which is to simplify the graph, run simplex and then restore it back. It also adds code to handle cases where the simplification handles the whole graph, and that therefore no simplex needs to be run. Additionally, the updateChildrenSizes() method is called on every root anchor in order to propagate the new sizes down the tree. A know issue appeared after this commit, as the quote below explains: ===== Q_ASSERT error in "Parallel" test That's something that started happening in the Parallel test (tests/auto/qgraphicsanchorlayout) after my commit of today, that enables simplification. I haven't been able to investigate it deeply but that's what I know about it: - It's triggered when the layout is destroyed, more precisely, from within "deleteLayoutEdges". What happens is that the layout structural anchors are missing at that point. - I suspect there's something to do with the simplifyGraph() and/or restoreSimplifyGraph() code. I say that because I tried moving the "restoreSimplifiedGraph" call from the end of the calculateGraph(s) method to the line exactly below the "simplifyGraph()" and the error still happens. That means that simplifying and then immediately restoring the graph might not leave it to the point where it was before the simplification. ==== Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Adding calculateGraphs() method documentationEduardo M. Fleury2009-08-101-7/+23
| | | | | | | That's too important a method to remain without at least some doc ;) Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
* QGraphicsAnchorLayout: Adding updateChildrenSizes method to anchorsEduardo M. Fleury2009-08-102-0/+31
| | | | | | | | | | | This method is meant to be called by the AnchorLayout after it has set the sizes of all root anchors of a simplified graph. The idea here it that these anchors will then propagate its new sizes down the simplification tree. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
* QGraphicsAnchorLayout: Fix center anchor deletion logicEduardo M. Fleury2009-08-062-9/+12
| | | | | | | | | | | | | | | We were missing a call to "removeCenterAnchors" in the "removeAnchors" method. To solve that, and also reduce the number of useless calls to that method, this commit: 1) Calls it only from "removeInternalVertex" 2) Does some preliminary testing before calling it 3) Replace the former test inside "removeCenterAnchors" by a Q_ASSERT It also adds other Q_ASSERTs to protect us from regression bugs. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGraphicsAnchorLayout: Do not create center anchors in the layoutEduardo M. Fleury2009-08-061-43/+63
| | | | | | | | Using same logic as for the items. We now create the center anchors on demand and delete them when not needed anymore. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
* QGraphicsAnchorLayoutPrivate: Avoiding extra loops in getGraphPartsJesus Sanchez-Palencia2009-07-311-9/+6
| | | | Signed-off-by: Jesus Sanchez-Palencia <jesus.palencia@openbossa.org>
* QGraphicsAnchorLayout: Remove center anchors when not neededEduardo M. Fleury2009-07-223-3/+71
| | | | | | | | | Continuing the effort to enforcing center anchors to exist only when needed, this commit removes the central anchors when they are no longer used. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Create center edges on demandEduardo M. Fleury2009-07-222-0/+63
| | | | | | | | | | Since the previous commit, center anchors are no longer created when an item is added to the layout. This commit creates only the required anchors, when needed. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Do not create center anchors by defaultEduardo M. Fleury2009-07-221-28/+8
| | | | | | | | | | | | | | | | | Previously we would create two half anchors internally to each item added to the layout. These anchors are meant to enforce the central anchorage point remains on its position. It is not effecient however, to create these anchors for all items if not all of them will have anchors linked to their center. This commit removes the creation of center anchors, the idea is to postpone this to the moment their are really needed, therefore reducing the number of variables and constraints sent to the simplex solver on the average case. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Testing for existing anchors before adding new onesEduardo M. Fleury2009-07-221-0/+5
| | | | | | | | | | The layout was not aware of the fact an anchor could already exist when it was added. This commit ensures that only one anchor exists between two vertices to avoid unwanted behavior and memory leaks (AnchorData's and Vertices would leak otherwise). Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Initialize spacing variablesEduardo M. Fleury2009-07-221-0/+2
| | | | | | | To avoid non-deterministic behavior. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Use Q_ASSERT instead of "if" testsEduardo M. Fleury2009-07-222-10/+10
| | | | | | | | Replacing two IF tests for Q_ASSERT statements instead. These tests are sanity checks that should never be false. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* Anchors to center edges should also have a default spacing of 0.Jan-Arve Sæther2009-07-221-6/+16
| | | | | Since the spacing will be 0 in most cases, we therefore "invert" the if (..) to only check for the cases where the spacing will *not* be zero.
* Make sure that internal center anchors are not simplified.Jan-Arve Sæther2009-07-221-2/+19
|
* Fix typo: feaseable => feasibleJan-Arve Sæther2009-07-221-1/+1
|
* The simplification makes the parallel autotest fail. Disable it for now.Jan-Arve Sæther2009-07-221-4/+4
|
* Avoid some warnings (unused variables)Jan-Arve Sæther2009-07-221-2/+0
|
* Add QGraphicsLayout::anchor() overloads and query the default spacing.Jan-Arve Sæther2009-07-224-50/+246
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes several related issues: 1. QGAL::anchor() had a spacing argument that defaulted to 0. That made it impossible to know if the user meant that the spacing should be 0 or if the spacing should be picked from the style. Instead we have to overload anchor, so now we have one function that does not take spacing as an argument. That one will create an anchor where the spacing is queried from the style. The other overload allows the user to explicitly set the spacing, thus the default spacing is ignored. 2. Make sure we pick up the spacing correctly from the style if needed. setAnchorSizeHintsFromDefaults() will set the correct spacing on anchors that was created without specifying a spacing value. 3. Add QGAL::anchor(Qt::Corner, ...) convenience function with an overload (for the same reason as explained in 1.) 4. Added QGraphicsAnchorLayoutPrivate::anchor() as a helper function that is called from all the 4 public API anchor() functions so that we don't need to have duplicate code for argument checking etc. 5. Fix autotests. They assumed that anchor() without a spacing argument created a spacing of 0.
* QSimplex: Skip x = x + y*0.0Anselmo Lacerda S. de Melo2009-07-221-1/+7
| | | | | | | | A small optimization. Added a verification in combineRows to skip calculating x = x + y*0.0 as it obviously won't change the value of x. Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QSimplex: new method solver, avoinding code replicationAnselmo Lacerda S. de Melo2009-07-222-18/+18
| | | | | | | | | | | The methods solveMin() and solveMax() had similar implementation, except by a "-1" multiplier. This commit includes a new private method called solver that is called by both solveMin() and solveMax(). A new enum 'solverFactor' was added admiting 2 values - Maximum (+1) and Minimum (-1). Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* Implemented parallel simplification, some bugfixes of the previous code.Jan-Arve Sæther2009-07-223-44/+104
| | | | | | | | | | Currently, the code is not in effect for the simplex solver kicks in (it crashes), but it is in effect for each layout to check that simplification and restoring the simplification back again works. This is currently done in calculateGraphs() Parts of the code does not read well, especially the detection of the sequential chunks.
* QGraphicsAnchorLayout: Add convencience "fill" methodsEduardo M. Fleury2009-07-221-0/+36
| | | | | | | | | | | | | | | Adding "fillWidth()", "fillHeight()" and "fill()". These convenience methods simplify the creation of anchor setups where some items are meant to use the full width and/or height of the layout. For instance, instead of creating four anchors (bottom, top, left, right) between an item and the layout, to make it use the full layout area, the user can call layout->fill(item). It is also possible to make an item assume the same width or height of another item, calling layout->fill(firstItem, secondItem). Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Fix QGraphicsItem reparent codeEduardo M. Fleury2009-07-224-38/+3
| | | | | | | Using QGraphicsLayoutPrivate methods for proper reparenting of items. This makes it work in cases where nested layouts are used. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* Simplify the code that finds the sequential chunks for simplification.Jan-Arve Sæther2009-07-221-14/+4
| | | | | | If two vertices are adjacent in the candidate list they should also be adjacent in the graph. This means there should always be an edge between candidates.at(n) and candidates.at(n + 1).
* Improved sequential simplification. Added restoreSimplifiedGraph().Jan-Arve Sæther2009-07-222-56/+197
| | | | | | | See comment in simplifyGraph on how the overall approach is. There are still outstanding issues: 1. Simplify parallel anchors 2. Use linear layout to distribute sequential anchors.
* Improve how graphviz (dotty) renders the serialized graph.Jan-Arve Sæther2009-07-221-1/+10
| | | | | The black arrow shows the principal direction based on the "origin" member of AnchorData.
* Simplify the graph by replacing a sequence of anchors with one anchor.Jan-Arve Sæther2009-07-222-2/+172
| | | | | | | We insert a special SequentialAnchorData. This anchor's min/pref/maxSize will be the sum of the sizes of all the anchors it is replacing. This should make the equation solver faster, and will enable us to do distribution properly just like a linear layout would do.
* Some cleanup - improve dot dumper.Jan-Arve Sæther2009-07-223-70/+52
| | | | | | | | | | | | | | | | | The previous dumper relied on traversal of the graph, which meant that it would not output the nodes that were not connected to the "main" graph. Due to this, we cannot rely on traversal, so instead we must iterate through all the vertices of the graph. As an added bonus the code gets simpler :-) There was also a problem with the previous dumper, since it dumped two "digraph" elements into one file. Graphwiz (win32) did not handle that. Instead just dump all the nodes and all the connections, both horizontal and vertical ones. The horizontal and vertical connections are never connected anyway, so the result will be two separate graphs when it is rendered by graphwiz. Also renamed firstVertex to rootVertex and simplified it.
* QGraphicsAnchorLayout: Fix memory management issue in QSimplex solverEduardo M. Fleury2009-07-223-50/+54
| | | | | | | | | | | | | | | Both QGraphicsAnchorLayoutPrivate::solveMinMax() and solvePreferred() were deleting the linear programming contraints while QSimplex still had them. For solveMinMax(), move the creation of constraints out of that method. For solvePreferred(), create the simplex solver in the heap so it can be deleted before the constraints are. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>
* QGraphicsAnchorLayout: Delete center constraints on item removalEduardo M. Fleury2009-07-223-11/+41
| | | | | | | | | | Each time an item is added to the layout, center constraits are created to ensure its internal anchors keep their size equal. To avoid memory leaks, we must delete them when the item is removed. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
* QGraphicsAnchorLayout: Removing delete d_ptrAnselmo Lacerda S. de Melo2009-07-221-3/+0
| | | | | | Removed an obsolete delete d_ptr, since it is not needed anymore. Signed-off-by: Anselmo Lacerda S. de Melo <anselmo.melo@openbossa.org>