void KWFrameGeometry::cancel() { KWFrame *frame = m_frame; if (frame == 0) { frame = m_state->frame(); m_state->markFrameUsed(); } Q_ASSERT(frame); frame->shape()->setPosition(m_originalPosition); frame->shape()->setSize(m_originalSize); }
void KWFrameSet::cleanupFrames() { kDebug(32001) << "type=" << m_type << "frameCount=" << frames().count(); while (!frames().isEmpty()) { // deleting a shape can result in multiple KWFrame's and shapes being deleted (e.g. copy-shapes) KWFrame *f = frames().last(); if (f->shape()) { delete f->shape(); // deletes also the KWFrame and calls KWFrameSet::removeFrame Q_ASSERT(!frames().contains(f)); } else { removeFrame(f); } } }
KWFrameDialog::KWFrameDialog(const QList<KWFrame*> &frames, KWDocument *document, KWCanvas *canvas) : KPageDialog(canvas) , m_frameConnectSelector(0) , m_canvas(canvas) { m_state = new FrameConfigSharedState(document); setFaceType(Tabbed); m_generalFrameProperties = new KWGeneralFrameProperties(m_state); addPage(m_generalFrameProperties, i18n("General")); m_generalFrameProperties->open(frames); m_anchoringProperties = new KWAnchoringProperties(m_state); if (m_anchoringProperties->open(frames)) addPage(m_anchoringProperties, i18n("Smart Positioning")); m_runAroundProperties = new KWRunAroundProperties(m_state); if (m_runAroundProperties->open(frames)) addPage(m_runAroundProperties, i18n("Text Run Around")); if (frames.count() == 1) { m_frameConnectSelector = new KWFrameConnectSelector(m_state); KWFrame *frame = frames.first(); m_state->setKeepAspectRatio(frame->shape()->keepAspectRatio()); if (m_frameConnectSelector->open(frame)) addPage(m_frameConnectSelector, i18n("Connect Text Frames")); else { delete m_frameConnectSelector; m_frameConnectSelector = 0; } } connect(this, SIGNAL(okClicked()), this, SLOT(okClicked())); connect(this, SIGNAL(cancelClicked()), this, SLOT(cancelClicked())); }
void KWFrameSet::removeFrame(KWFrame *frame, KoShape *shape) { Q_ASSERT(frame); if (frame->isCopy()) { KWCopyShape* copyShape = dynamic_cast<KWCopyShape*>(frame->shape()); if (copyShape && copyShape->original()) { KWFrame *originalFrame = dynamic_cast<KWFrame*>(copyShape->original()->applicationData()); if (originalFrame) { originalFrame->removeCopy(frame); } } } else { //TODO use the copyFrame-list the KWFrame's remembers now // Loop over all frames to see if there is a copy frame that references the removed // frame; if it does, then delete the copy too. for(int i = frames().count() - 1; i >= 0; --i) { KWFrame *frame = frames()[i]; if (KWCopyShape *cs = dynamic_cast<KWCopyShape*>(frame->shape())) { if (cs->original() == shape) { Q_ASSERT(frame->frameSet() == this); frame->cleanupShape(cs); removeFrame(frame, cs); delete cs; } } } } if (m_frames.removeAll(frame)) { frame->setFrameSet(0); emit frameRemoved(frame); } }
void KWFrameGeometry::updateShape() { if (m_blockSignals) return; KWFrame *frame = m_frame; if (frame == 0) { frame = m_state->frame(); m_state->markFrameUsed(); } Q_ASSERT(frame); frame->shape()->update(); KShape *shape = frame->shape(); QPointF currentPos(shape->absolutePosition(widget.positionSelector->position())); QPointF pos(widget.xPos->value(), widget.yPos->value() + m_topOfPage); QPointF moved = pos - currentPos; QPointF prev(moved); m_state->document()->clipToDocument(frame->shape(), moved); pos = currentPos + moved; frame->shape()->setAbsolutePosition(pos, widget.positionSelector->position()); QSizeF size(widget.width->value(), widget.height->value()); frame->shape()->setSize(size); KWTextFrame *tfs = dynamic_cast <KWTextFrame*>(frame); if (tfs) { KInsets insets(widget.topMargin->value(), widget.leftMargin->value(), widget.bottomMargin->value(), widget.rightMargin->value()); tfs->setInsets(insets); } frame->shape()->update(); }
void KWFrameGeometry::setGeometryAlignment(KFlake::Position position) { KWFrame *frame = m_frame; if (frame == 0) { frame = m_state->frame(); m_state->markFrameUsed(); } QPointF pos = frame->shape()->absolutePosition(position); m_blockSignals = true; widget.xPos->changeValue(pos.x()); widget.yPos->changeValue(pos.y() - m_topOfPage); m_blockSignals = false; }
void KWFrameGeometry::protectSizeChanged(int protectSizeState) { KWFrame *frame = m_frame; if (frame == 0) { frame = m_state->frame(); m_state->markFrameUsed(); } Q_ASSERT(frame); bool lock = (protectSizeState == Qt::Checked); frame->shape()->setGeometryProtected(lock); widget.xPos->setDisabled(lock); widget.yPos->setDisabled(lock); widget.width->setDisabled(lock); widget.height->setDisabled(lock); widget.keepAspect->setDisabled(lock); }