~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to libs/flake/KoCanvasController_p.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "KoCanvasController_p.h"
24
24
#include "KoShape.h"
25
 
#include "KoShapeFactory.h" // for the SHAPE mimetypes
 
25
#include "KoShape_p.h"
 
26
#include "KoShapeFactoryBase.h" // for the SHAPE mimetypes
26
27
#include "KoShapeRegistry.h"
27
28
#include "KoShapeController.h"
28
29
#include "KoShapeManager.h"
131
132
 
132
133
        // The rest of this method is mostly a copy paste from the KoCreateShapeStrategy
133
134
        // So, lets remove this again when Zagge adds his new class that does this kind of thing. (KoLoadSave)
134
 
        KoShapeFactory *factory = KoShapeRegistry::instance()->value(id);
 
135
        KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value(id);
135
136
        if (! factory) {
136
137
            kWarning(30006) << "Application requested a shape that is not registered '" <<
137
138
            id << "', Ignoring";
144
145
        if (isTemplate) {
145
146
            KoProperties props;
146
147
            props.load(properties);
147
 
            m_draggedShape = factory->createShapeAndInit(&props, m_parent->canvas()->shapeController()->dataCenterMap());
 
148
            m_draggedShape = factory->createShape(&props, m_parent->canvas()->shapeController()->resourceManager());
148
149
        } else
149
 
            m_draggedShape = factory->createDefaultShapeAndInit(m_parent->canvas()->shapeController()->dataCenterMap());
 
150
            m_draggedShape = factory->createDefaultShape(m_parent->canvas()->shapeController()->resourceManager());
150
151
 
151
152
        Q_ASSERT(m_draggedShape);
152
153
        if (!m_draggedShape) return;
153
154
 
154
155
        if (m_draggedShape->shapeId().isEmpty())
155
156
            m_draggedShape->setShapeId(factory->id());
156
 
        m_draggedShape->setZIndex(KoFlake::maxZIndex());
 
157
        m_draggedShape->setZIndex(KoShapePrivate::MaxZIndex);
157
158
 
158
159
        m_parent->canvas()->shapeManager()->add(m_draggedShape);
159
160
    }
167
168
                Q_ASSERT(0); // hmm hmm, when does this happen?
168
169
            }
169
170
            m_draggedShape = shapes.first();
170
 
            m_draggedShape->setZIndex(KoFlake::maxZIndex());
 
171
            m_draggedShape->setZIndex(KoShapePrivate::MaxZIndex);
171
172
            event->setDropAction(Qt::CopyAction);
172
173
            event->accept();
173
174
        }
229
230
    QRect rect = m_parent->canvas()->viewConverter()->documentToView(shape->boundingRect()).toRect();
230
231
    QWidget *canvasWidget = m_parent->canvas()->canvasWidget();
231
232
    Q_ASSERT(canvasWidget); // since we should not allow drag if there is not.
232
 
    rect.moveLeft(rect.left() + canvasWidget->x());
233
 
    rect.moveTop(rect.top() + canvasWidget->y());
 
233
    rect.moveLeft(rect.left() + canvasWidget->x() - m_documentOffset.x());
 
234
    rect.moveTop(rect.top() + canvasWidget->y() - m_documentOffset.y());
234
235
    rect.adjust(-2, -2, 2, 2); // adjust for antialias
235
236
    update(rect);
236
237
}
264
265
        painter.save();
265
266
        QWidget *canvasWidget = m_parent->canvas()->canvasWidget();
266
267
        Q_ASSERT(canvasWidget); // since we should not allow drag if there is not.
267
 
        painter.translate(canvasWidget->x(), canvasWidget->y());
 
268
        painter.translate(canvasWidget->x() - m_documentOffset.x(),
 
269
                canvasWidget->y() - m_documentOffset.y());
268
270
        QPointF offset = vc->documentToView(m_draggedShape->position());
269
271
        painter.setOpacity(0.6);
270
272
        painter.translate(offset.x(), offset.y());
272
274
        m_draggedShape->paint(painter, *vc);
273
275
        painter.restore();
274
276
    }
275
 
 
276
277
}
277
278
 
278
279
void Viewport::resetLayout()
367
368
#endif
368
369
}
369
370
 
370
 
#include "KoCanvasController_p.moc"
 
371
#include <KoCanvasController_p.moc>