void ObjectDiagramView::mousePressEvent(QMouseEvent * e)
{
    if (!window()->frozen()) {
        QPoint diagramPoint(e->x(), e->y());
        QPointF scenePoint = mapToScene(diagramPoint);
        if (e->button() == ::Qt::RightButton)
            DiagramView::mousePressEvent(e);
        else {
            UmlCode c = window()->buttonOn();

            switch (c) {
            case UmlClass: {
                history_protected = FALSE;
                unselect_all();
                window()->selectOn();
                history_save();

                BrowserNode * parent =
                    ((BrowserNode *) window()->browser_diagram()->parent());
                BrowserClass * b =
                    BrowserClass::get_class(parent);

                if (b != 0) {
                    BrowserClassInstance * i =
                        new BrowserClassInstance("", b, parent);
                    OdClassInstCanvas * cl =
                        new OdClassInstCanvas(i, the_canvas(), scenePoint.x(), scenePoint.y(), 0);

                    cl->show();
                    cl->upper();
                    window()->package_modified();
                }
            }

            canvas()->update();
            break;

            case UmlClassInstance: {
                history_protected = TRUE;
                unselect_all();
                window()->selectOn();
                history_save();

                BrowserNode * parent =
                    ((BrowserNode *) window()->browser_diagram()->parent());
                BrowserClassInstance * b =
                    BrowserClassInstance::get_classinstance(parent);

                if (b != 0) {
                    OdClassInstCanvas * cl =
                        new OdClassInstCanvas(b, the_canvas(), scenePoint.x(), scenePoint.y(), 0);

                    cl->show();
                    cl->upper();
                    window()->package_modified();
                }
            }

            canvas()->update();
            history_protected = FALSE;
            break;

            default:
                DiagramView::mousePressEvent(e);
                break;
            }
        }
    }
    else
        DiagramView::mousePressEvent(e);
}
void ObjectDiagramView::dropEvent(QDropEvent * e)
{
    BrowserNode * bn;
   QPointF p = mapToScene(e->pos());

    if ((bn = UmlDrag::decode(e, UmlClassInstance)) != 0) {
        history_save();

        OdClassInstCanvas * i =
            new OdClassInstCanvas((BrowserClassInstance *) bn,
                                  the_canvas(), p.x(), p.y(), 0);

        history_protected = TRUE;
        i->show();
        i->upper();
        canvas()->update();
        history_protected = FALSE;
        window()->package_modified();
    }
    else if ((bn = UmlDrag::decode(e, UmlClass)) != 0) {
        history_save();

        BrowserNode * parent =
            ((BrowserNode *) window()->browser_diagram()->parent());
        BrowserClassInstance * cli =
            new BrowserClassInstance("", (BrowserClass *) bn, parent);
        OdClassInstCanvas * i =
            new OdClassInstCanvas(cli, the_canvas(), p.x(), p.y(), 0);

        history_protected = TRUE;
        i->show();
        i->upper();
        canvas()->update();
        history_protected = FALSE;
        window()->package_modified();
    }
    else if ((bn = UmlDrag::decode(e, UmlPackage)) != 0) {
        history_save();

        PackageCanvas * pk =
            new PackageCanvas(bn, the_canvas(), p.x(), p.y(), 0);

        history_protected = TRUE;
        pk->show();
        pk->upper();
        canvas()->update();
        window()->package_modified();
    }
    else if (((bn = UmlDrag::decode(e, UmlClassDiagram)) != 0) ||
             ((bn = UmlDrag::decode(e, UmlUseCaseDiagram)) != 0) ||
             ((bn = UmlDrag::decode(e, UmlSeqDiagram)) != 0) ||
             ((bn = UmlDrag::decode(e, UmlObjectDiagram)) != 0) ||
             ((bn = UmlDrag::decode(e, UmlComponentDiagram)) != 0) ||
             ((bn = UmlDrag::decode(e, UmlDeploymentDiagram)) != 0) ||
             ((bn = UmlDrag::decode(e, UmlStateDiagram, TRUE)) != 0) ||
             ((bn = UmlDrag::decode(e, UmlActivityDiagram, TRUE)) != 0)) {
        history_save();

        IconCanvas * ic = new IconCanvas(bn, the_canvas(), p.x(), p.y(), 0);

        history_protected = TRUE;
        ic->show();
        ic->upper();
        canvas()->update();
        history_protected = FALSE;
        window()->package_modified();
    }
}