Bug 290952 - migrate remaining qt3 classes to qt4
Summary: migrate remaining qt3 classes to qt4
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: Unlisted Binaries All
: NOR wishlist (vote)
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-08 10:20 UTC by Ralf Habacker
Modified: 2013-11-02 17:32 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.10.0


Attachments
initial - uncomplete - version of UMLSceneRectangle wrapper class (2.35 KB, text/plain)
2012-01-09 14:26 UTC, Ralf Habacker
Details
initial - uncomplete - version of UMLSceneRectangle wrapper class (2.07 KB, text/plain)
2012-01-09 14:28 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2012-01-08 10:20:48 UTC
Version:           unspecified
OS:                All

In umbrello trunk there are still qt3 classes like 

Q3Canvas
Q3CanvasView
Q3TextEdit
Q3Frame

These classes should be migrated to the related Qt4 classes which are

QGraphicsScene
QGraphicsView
QTextEdit
QFrame




Reproducible: Always


Actual Results:  
An attempt to migrate the first two classes has been done in the umbrello-soc branch, but changes from the umbrello-soc branch hasn't been merged into trunk. 

Expected Results:  
The umbrello-soc branch should be merged into trunk.
Comment 1 Andi Fischer 2012-01-08 17:28:33 UTC
The following two classes were replaced in commit 1272536:

Q3TextEdit
Q3Frame
Comment 2 Ralf Habacker 2012-01-09 14:26:52 UTC
Created attachment 67615 [details]
initial - uncomplete - version of UMLSceneRectangle wrapper class
Comment 3 Ralf Habacker 2012-01-09 14:28:25 UTC
Created attachment 67616 [details]
initial - uncomplete - version of UMLSceneRectangle wrapper class
Comment 4 Ralf Habacker 2012-01-09 14:28:48 UTC
nice work. 

the remaining stuff in umbrello-soc is unfortunally a mixture of 

1. the basic QGraphics... port 
2. unrelated class doc changes (from header into source)
3. unrelated widget api changes 
4. uncomplete widget changes (for example AssociationManager) 
5. experimental widget style change
6 something else ?? 

which we canot merge at once. We need to find the important parts and how to merge in which order without breaking trunk functionality. 

Currently our efforts are concentrated to reduce the difference between trunk and umbrello-soc to be able to see more the important changes.
At the current level of unstanding I see the following issues/todo for merging the basic QGraphics... port: 

1. type differences (QPoint/QRect -> QPointF/QRectF) 
2. scene classes api differences 
3. Which methods and class member belongs to UMLView and which one to UMLScene
   The umbrello-soc branch moved already some methods and class members to UMLScene - the question is if these move are reasonable 
4. migrate UMLScene from Q3Canvas to QGraphicsScene api
5. migrate UMLView from Q3CanvasView to QGraphicsView api

There are already solutions for some of the issues listed above:

1. type differences (QPoint/QRect -> QPointF/QRectF) 

rename related ocurrence of QPoint/QRect in class UMLView and widgets class to UMLScenePoint and UMLSceneRect 
They are currently defined in umlscene.h as 

typedef QPoint UMLScenePoint;
typedef QRect UMLSceneRect;

and after the merge as

typedef QPointF UMLScenePoint;
typedef QRectF UMLSceneRect;

2. scene classes api differences 
An easy way to solve class api differences is by adding wrapper classes providing the missing or different api. After the merge is complety the related widgets methods may be refactored to get rid of the wrapper classes. 

As initial step typedef wrappers for the related classes has been added: 

// event types
typedef QKeyEvent UMLSceneKeyEvent;
typedef QHoverEvent UMLSceneHoverEvent;
typedef QContextMenuEvent UMLSceneContextMenuEvent;
//typedef QDragDropEvent UMLSceneDragDropEvent;

typedef Q3CanvasLine UMLSceneLine;
typedef Q3CanvasRectangle UMLSceneRectangle;
typedef Q3CanvasItem UMLSceneItem;
typedef Q3CanvasPolygon UMLScenePolygon;
typedef Q3CanvasEllipse UMLSceneEllipse;
typedef Q3CanvasItemList UMLSceneItemList;

An example for such a wrapper is shown below: 

class  UMLSceneMouseEvent : public QMouseEvent 
{
public:
    UMLSceneMouseEvent(Type type, const QPoint & position, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) 
     : QMouseEvent(type, position, button, buttons, modifiers) {}
    UMLScenePoint scenePos() { return pos(); }
};

As an experiment I found out that the following wrapper class is usable to replace Q3CanvasRectangle (still using the Q3 int type) 

class UMLSceneRectangle : public QGraphicsRectItem
{
public:
    UMLSceneRectangle(UMLScene *scene);
    UMLSceneRectangle(int x, int y, int w, int h,  UMLScene *scene);
    ~UMLSceneRectangle();

    int height() const;
    int width() const;

    int z() const;
    void setZ(int value);
    QRect rect() const;
    void setSize(int width, int height);
};


3. Which methods and class member belongs to UMLView and which one to UMLScene
   In trunk there has been created a UMLScene class, which is derived from UMLView to provide all methods from UMLView. 
   The next step in this area is to move the related UMLView methods into. 

4. migrate UMLScene from Q3Canvas to QGraphicsScene api
   ... 

5. migrate UMLView from Q3CanvasView to QGraphicsView api
   ... 

Are there any additional hints or ideas ?
Comment 5 Andi Fischer 2012-01-10 07:10:07 UTC
Very nice and good plan.
Comment 6 Ralf Habacker 2012-01-18 14:39:40 UTC
SVN commit 1274510 by habacker:

Merged widget size limiting methods and idea from soc-umbrello branch.

The merge has been done according to the merge plan on bug 290952
It solves also bug 291837.

Related: bug 291837

 M  +3 -0      umlscene.h  
 M  +1 -1      widgets/activitywidget.h  
 M  +1 -1      widgets/actorwidget.cpp  
 M  +1 -1      widgets/actorwidget.h  
 M  +2 -2      widgets/artifactwidget.cpp  
 M  +1 -1      widgets/artifactwidget.h  
 M  +1 -0      widgets/boxwidget.h  
 M  +1 -1      widgets/categorywidget.cpp  
 M  +1 -1      widgets/categorywidget.h  
 M  +2 -2      widgets/classifierwidget.cpp  
 M  +1 -1      widgets/classifierwidget.h  
 M  +1 -1      widgets/combinedfragmentwidget.cpp  
 M  +1 -1      widgets/combinedfragmentwidget.h  
 M  +1 -1      widgets/componentwidget.cpp  
 M  +1 -1      widgets/componentwidget.h  
 M  +2 -2      widgets/datatypewidget.cpp  
 M  +1 -1      widgets/datatypewidget.h  
 M  +2 -2      widgets/entitywidget.cpp  
 M  +1 -1      widgets/entitywidget.h  
 M  +2 -2      widgets/enumwidget.cpp  
 M  +1 -1      widgets/enumwidget.h  
 M  +3 -3      widgets/floatingtextwidget.cpp  
 M  +1 -1      widgets/floatingtextwidget.h  
 M  +1 -1      widgets/forkjoinwidget.cpp  
 M  +1 -1      widgets/forkjoinwidget.h  
 M  +2 -2      widgets/nodewidget.cpp  
 M  +1 -1      widgets/nodewidget.h  
 M  +1 -1      widgets/notewidget.cpp  
 M  +1 -1      widgets/notewidget.h  
 M  +1 -1      widgets/objectnodewidget.cpp  
 M  +1 -1      widgets/objectnodewidget.h  
 M  +1 -1      widgets/objectwidget.cpp  
 M  +1 -1      widgets/objectwidget.h  
 M  +2 -2      widgets/packagewidget.cpp  
 M  +1 -1      widgets/packagewidget.h  
 M  +3 -6      widgets/pinwidget.cpp  
 M  +0 -6      widgets/pinwidget.h  
 M  +2 -2      widgets/preconditionwidget.cpp  
 M  +1 -1      widgets/preconditionwidget.h  
 M  +1 -1      widgets/regionwidget.cpp  
 M  +1 -1      widgets/regionwidget.h  
 M  +1 -1      widgets/signalwidget.cpp  
 M  +1 -1      widgets/signalwidget.h  
 M  +1 -1      widgets/statewidget.cpp  
 M  +1 -1      widgets/statewidget.h  
 M  +75 -16    widgets/umlwidget.cpp  
 M  +12 -1     widgets/umlwidget.h  
 M  +1 -1      widgets/usecasewidget.cpp  
 M  +1 -1      widgets/usecasewidget.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1274510
Comment 7 Ralf Habacker 2012-01-31 08:14:40 UTC
The AssociationLine class is a good example how to get partially rid of Q3Canvas based code. 

The recent trunk implementation uses a Q3CanvasLine instances for each line segment, head lines and other graphical elements. The soc-umbrello implementation of AssociationLine holds and paints all lines by itself. 

All symbols required by an association line are handled by the class Symbol, which use a QPainter path based drawing. 

Merging the related parts of the soc-umbrello AssociationLine implementation into trunk will remove many Q3Canvas related references.
Comment 8 Ralf Habacker 2012-03-18 18:35:28 UTC
SVN commit 1286219 by habacker:

Derived UMLScene... classes from the related Q3Canvas... classes.

Removed also Q3Canvas* parameter from constructor in preparation
for QGraphicsScene requirements.


 M  +2 -1      toolbarstatearrow.cpp  
 M  +2 -1      toolbarstateassociation.cpp  
 M  +4 -2      toolbarstatemessages.cpp  
 M  +46 -4     umlscene.h  
 M  +23 -13    widgets/associationline.cpp  
 M  +2 -2      widgets/associationline.h  
 M  +4 -2      widgets/associationwidget.cpp  
 M  +6 -3      widgets/seqlinewidget.cpp  
 M  +4 -2      widgets/umlwidget.cpp  
 M  +2 -1      widgets/widget_utils.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286219
Comment 9 Ralf Habacker 2012-03-18 20:01:33 UTC
SVN commit 1286233 by habacker:

Refactored calls belonging to UMLScene related methods.


 M  +13 -13    clipboard/umlclipboard.cpp  
 M  +13 -13    dialogs/diagramprintpage.cpp  
 M  +4 -4      uml.cpp  
 M  +2 -2      umllistview.cpp  
 M  +1 -1      widgets/widget_utils.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286233
Comment 10 Ralf Habacker 2012-03-21 19:12:45 UTC
SVN commit 1286609 by habacker:

Moved UMLView implementation into UMLScene and derived UMLView from UMLScene.


 M  +2 -2      clipboard/umldragdata.cpp  
 M  +4547 -1   umlscene.cpp  
 M  +751 -4    umlscene.h  
 M  +2 -4529   umlview.cpp  
 M  +2 -731    umlview.h  
 M  +5 -5      umlviewcanvas.cpp  
 M  +3 -3      umlviewcanvas.h  
 M  +2 -2      widgets/associationline.cpp  
 M  +4 -4      widgets/linkwidget.cpp  
 M  +1 -1      widgets/linkwidget.h  
 M  +2 -2      widgets/notewidget.cpp  
 M  +1 -1      widgets/objectnodewidget.cpp  
 M  +4 -4      widgets/seqlinewidget.cpp  
 M  +2 -2      widgets/seqlinewidget.h  
 M  +1 -1      widgets/statewidget.cpp  
 M  +1 -1      widgets/umlwidget.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286609
Comment 11 Ralf Habacker 2012-03-24 07:22:06 UTC
SVN commit 1286839 by habacker:

Derived UMLScene from Q3Canvas and UMLView from Q3CanvasView.

Event handling do not work yet.


 M  +7 -7      clipboard/umlclipboard.cpp  
 M  +2 -2      clipboard/umldragdata.cpp  
 M  +1 -1      cmds/cmd_create_diagram.cpp  
 M  +3 -3      cmds/widget/cmd_changeFontSelection.cpp  
 M  +5 -5      controller/umlwidgetcontroller.cpp  
 M  +2 -2      dialogs/assocpage.cpp  
 M  +1 -1      dialogs/classgenpage.cpp  
 M  +3 -3      dialogs/diagramprintpage.cpp  
 M  +20 -20    dialogs/umlviewdialog.cpp  
 M  +3 -3      listpopupmenu.cpp  
 M  +13 -13    toolbarstate.cpp  
 M  +1 -1      toolbarstatearrow.cpp  
 M  +2 -2      toolbarstateassociation.cpp  
 M  +2 -2      toolbarstatemessages.cpp  
 M  +2 -2      umldoc.cpp  
 M  +4 -4      umllistview.cpp  
 M  +3 -3      umllistviewitem.cpp  
 M  +39 -90    umlscene.cpp  
 M  +8 -26     umlscene.h  
 M  +54 -1     umlview.cpp  
 M  +26 -1     umlview.h  
 M  +1 -1      widgets/activitywidget.cpp  
 M  +1 -1      widgets/artifactwidget.cpp  
 M  +2 -3      widgets/associationline.cpp  
 M  +7 -7      widgets/associationwidget.cpp  
 M  +1 -1      widgets/classifierwidget.cpp  
 M  +1 -1      widgets/componentwidget.cpp  
 M  +1 -1      widgets/datatypewidget.cpp  
 M  +1 -1      widgets/entitywidget.cpp  
 M  +2 -2      widgets/enumwidget.cpp  
 M  +5 -5      widgets/floatingtextwidget.cpp  
 M  +1 -1      widgets/nodewidget.cpp  
 M  +1 -1      widgets/notewidget.cpp  
 M  +2 -2      widgets/objectwidget.cpp  
 M  +1 -1      widgets/packagewidget.cpp  
 M  +2 -2      widgets/umlwidget.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286839
Comment 12 Ralf Habacker 2012-03-24 07:22:12 UTC
SVN commit 1286840 by habacker:

Merged UMLCanvasView into into UMLscene; it was based on Q3Canvas too.


 M  +0 -1      CMakeLists.txt  
 M  +12 -11    dialogs/umlviewdialog.cpp  
 M  +4 -10     dialogs/umlwidgetstylepage.cpp  
 M  +43 -24    umlscene.cpp  
 M  +6 -3      umlscene.h  
 D             umlviewcanvas.cpp  
 D             umlviewcanvas.h  
 M  +1 -2      widgets/associationline.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286840
Comment 13 Ralf Habacker 2012-03-24 07:22:15 UTC
SVN commit 1286841 by habacker:

Fixed Event handling.

Event handling is provided by UMLView, so moved related methods
from UMLScene to UMLView.


 M  +1 -1      controller/umlwidgetcontroller.cpp  
 M  +1 -1      dialogs/umlviewdialog.cpp  
 M  +1 -113    umlscene.cpp  
 M  +0 -31     umlscene.h  
 M  +133 -0    umlview.cpp  
 M  +39 -2     umlview.h  
 M  +4 -4      widgets/associationwidget.cpp  
 M  +2 -2      widgets/notewidget.cpp  
 M  +3 -3      widgets/umlwidget.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1286841
Comment 14 Ralf Habacker 2012-03-28 20:34:24 UTC
Based on the previous work in trunk this branch contains an initial working version of umbrello based on QGraphicsScene. This work has been done in a minimal invasive way. 

It contains 
1. some UMLScene... type related fixes (independent patch)
2. some minor code changes related to the virtual painting class method (associationwidget), 
3. changes to to switch UMLView to QGraphicsView 
4. changes to to switch UMLScene to QGraphicsView 
5. UMLScene...Item adapter classes located in umlscene.h. 

There are no additional changes in umbrello code required. 

Known problems: 
- Selecting of association 
- Widgets property dialog is shown in the top left corner of the application. 

After the remaining problems are fixed, the adapter classes could be merged into the related widget code. 

Additional features implemented in the soc-umbrello branch like QPainter based AssociationLine implementation could be merge afterwards. 

To get this branch into an already present git svn trunk checkout run 
git remote add umbrello-test git://gitorious.org/umbrello/test.git
git fetch umbrello-test
git checkout -b 290952 umbrello-test/290952
Comment 15 Ralf Habacker 2012-03-28 20:35:52 UTC
typo fix:  
4. changes to to switch UMLScene to QGraphicsScene
Comment 16 Ralf Habacker 2012-06-02 08:33:36 UTC
An additional merging topic are changes in the way popup menu are constructed. 

Trunk uses virtual methods based on UMLWidget::setupPopupMenu(ListPopupMenu *) to create popup menus. popup creation is triggered by UMLWidgetController::mouseReleaseEvent(), which calls UMLWidgetController::setupPopupMenu(QMouseEvent *), which  calls UMLWidget::setupPopupMenu(ListPopupMenu *) 

The soc-branch uses the QGraphicsScene supported way: 
QGraphicsScene provides a virtual method contextMenuEvent() which is routed to the top most graphics item http://qt-project.org/doc/qt-4.8/qgraphicsscene.html#contextMenuEvent

Graphics items constructs a menu instance
/**
 * Reimplemented to show appropriate context menu.
 */
void WidgetBase::contextMenuEvent(UMLSceneContextMenuEvent *event)
{
    event->accept();
    ...
    setSelected(true);
    QPointer<ListPopupMenu> menu = new ListPopupMenu(0, this, false, false);
    setupContextMenuActions(*(menu.data()));
    QAction *triggered = menu->exec(event->screenPos());
    ListPopupMenu *parentMenu = ListPopupMenu::menuFromAction(triggered);
    ....
}

The menu instance is not stored in the m_pMenu class member and requires the mentioned ugly hack in listpopmenu::setupActionData() 
/**
 * Sets up actions added to the ListPopupMenu to have their data field set to
 * pointer to this ListPopupMenu object, so that this menu pointer can be
 * retrieved in UMLWidget::slotMenuSelection
 *
 * @note This might seem like an ugly hack, but this is the only solution which
 *       helped in avoiding storage of ListPopupMenu pointer in each UMLWidget.
 */

What is bad with storing a menu pointer in UMLWidget ?
Comment 17 Oliver Kellogg 2012-06-03 07:03:44 UTC
(In reply to comment #16)
> [...]
> What is bad with storing a menu pointer in UMLWidget ?

"Bad" is perhaps a strong word because technically it gets the job done the way it's coded right now.
However,
1) There can never be two popups open at the same time
2) In case of multiple selection it is not clear which widget owns the popup (multiple owners?)
IMHO the menu could be a singleton existing outside the participating widget(s).
Comment 18 Ralf Habacker 2012-09-02 13:51:04 UTC
SVN commit 1314540 by habacker:

Ported class UMLScene and UMLView to QGraphicsScene and QGraphivsView.

This was possible because of the reduced soc2008 and trunk difference approach
performed in the last months by Andy Fischer an me.

The gsoc 2008 branch still contains several fixes and enhancements which may be merged
from now on.

Qt4 related fixes (the most important):
- Usage of QGraphicsItem based event handling
- Usage of QGraphicsScene based rubberband
- Usage of QGraphicsScene/View based item selection

Qt4 unrelated (most important):
- The QPainter based AssocationLine refactoring, which is required for spline based
  line style and auto layouts.
- AssociationSpaceManager class for optimized association line drawings.
- The TextItem/TextItemGroup classes, which refactores widgets content setup
- Widget Color gradients, which are useful enhancements of the widget style engine


 M  +3 -2      controller/objectwidgetcontroller.cpp  
 U             controller/objectwidgetcontroller.h  
 M  +40 -26    controller/umlwidgetcontroller.cpp  
 M  +2 -2      controller/umlwidgetcontroller.h  
 M  +1 -1      dialogs/umlviewdialog.cpp  
 M  +2 -2      dialogs/umlwidgetstylepage.cpp  
 M  +1 -1      dotgenerator.cpp  
 M  +51 -26    toolbarstate.cpp  
 M  +10 -10    toolbarstatearrow.cpp  
 M  +2 -2      toolbarstateassociation.cpp  
 M  +10 -10    toolbarstatemessages.cpp  
 M  +6 -6      uml.cpp  
 M  +159 -109  umlscene.cpp  
 M  +161 -39   umlscene.h  
 M  +128 -70   umlview.cpp  
 M  +17 -30    umlview.h  
 M  +1 -1      umlviewimageexportermodel.cpp  
 M  +1 -1      widgets/activitywidget.cpp  
 M  +1 -1      widgets/activitywidget.h  
 M  +1 -1      widgets/actorwidget.cpp  
 M  +1 -1      widgets/actorwidget.h  
 M  +1 -1      widgets/artifactwidget.cpp  
 M  +1 -1      widgets/artifactwidget.h  
 M  +4 -4      widgets/associationline.cpp  
 M  +1 -1      widgets/associationline.h  
 M  +12 -12    widgets/associationwidget.cpp  
 M  +1 -1      widgets/associationwidget.h  
 M  +1 -1      widgets/boxwidget.cpp  
 M  +1 -1      widgets/boxwidget.h  
 M  +1 -1      widgets/categorywidget.cpp  
 M  +1 -1      widgets/categorywidget.h  
 M  +1 -1      widgets/classifierwidget.cpp  
 M  +1 -1      widgets/classifierwidget.h  
 M  +3 -3      widgets/combinedfragmentwidget.cpp  
 M  +1 -1      widgets/combinedfragmentwidget.h  
 M  +1 -1      widgets/componentwidget.cpp  
 M  +1 -1      widgets/componentwidget.h  
 M  +1 -1      widgets/datatypewidget.cpp  
 M  +1 -1      widgets/datatypewidget.h  
 M  +1 -1      widgets/entitywidget.cpp  
 M  +1 -1      widgets/entitywidget.h  
 M  +1 -1      widgets/enumwidget.cpp  
 M  +1 -1      widgets/enumwidget.h  
 M  +1 -1      widgets/floatingdashlinewidget.cpp  
 M  +1 -1      widgets/floatingdashlinewidget.h  
 M  +1 -1      widgets/floatingtextwidget.cpp  
 M  +1 -1      widgets/floatingtextwidget.h  
 M  +1 -1      widgets/forkjoinwidget.cpp  
 M  +1 -1      widgets/forkjoinwidget.h  
 M  +2 -2      widgets/messagewidget.cpp  
 M  +2 -2      widgets/messagewidget.h  
 M  +1 -1      widgets/nodewidget.cpp  
 M  +1 -1      widgets/nodewidget.h  
 M  +1 -1      widgets/notewidget.cpp  
 M  +1 -1      widgets/notewidget.h  
 M  +1 -1      widgets/objectnodewidget.cpp  
 M  +1 -1      widgets/objectnodewidget.h  
 M  +2 -2      widgets/objectwidget.cpp  
 M  +3 -2      widgets/objectwidget.h  
 M  +1 -1      widgets/packagewidget.cpp  
 M  +1 -1      widgets/packagewidget.h  
 M  +1 -1      widgets/pinwidget.cpp  
 M  +1 -1      widgets/pinwidget.h  
 M  +1 -1      widgets/preconditionwidget.cpp  
 M  +1 -1      widgets/preconditionwidget.h  
 M  +1 -1      widgets/regionwidget.cpp  
 M  +1 -1      widgets/regionwidget.h  
 M  +1 -1      widgets/signalwidget.cpp  
 M  +1 -1      widgets/signalwidget.h  
 M  +1 -1      widgets/statewidget.cpp  
 M  +1 -1      widgets/statewidget.h  
 M  +2 -2      widgets/toolbarstateonewidget.cpp  
 M  +18 -14    widgets/umlwidget.cpp  
 M  +16 -6     widgets/umlwidget.h  
 M  +1 -1      widgets/usecasewidget.cpp  
 M  +1 -1      widgets/usecasewidget.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1314540