예제 #1
0
void ModelRewriter::setAnchor(const InternalNodeState::Pointer &state, const QString &propertyName, const QVariant &value)
{
    if (state.isNull() || !state->isValid())
        throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);

    if (state->propertyLocation(propertyName).isValid())
        m_modelToTextMerger.changePropertyValue(state, propertyName, value);
    else
        m_modelToTextMerger.addProperty(state, propertyName, value);

    if (!modificationGroupActive())
        m_modelToTextMerger.applyChanges(*m_textModifier);
}
예제 #2
0
void ModelRewriter::endModificationGroup(const ModificationGroupToken& token)
{
    if (m_activeModificationGroups.isEmpty()) {
        throw ModificationGroupException(__LINE__, Q_FUNC_INFO, __FILE__);
    }

    if (m_activeModificationGroups.last() != token) {
        throw ModificationGroupException(__LINE__, Q_FUNC_INFO, __FILE__);
    }

    if (!m_activeModificationGroups.removeAll(token)) {
        throw ModificationGroupException(__LINE__, Q_FUNC_INFO, __FILE__);
    }

    if (!modificationGroupActive()) {
        m_modelToTextMerger.applyChanges(*m_textModifier);
    }
}
예제 #3
0
/*!
  Inserts the copied data into the given node.

  \note The mime-type for the data must be <tt>"application/x-qt-bauhaus"</tt>, otherwise the paste will fail.

  \param transferData The clip-board contents to paste.
  \param intoNode The node into which the clip-board contents are to be pasted.
  \return true if successful, false otherwise.
 */
bool ModelRewriter::paste(QMimeData *transferData, const InternalNode::Pointer &intoNode)
{
    if (!transferData)
        return false;

    if (intoNode.isNull() || !intoNode->isValid())
        throw InvalidModelNodeException(__LINE__, Q_FUNC_INFO, __FILE__);

    Paster paster(transferData, intoNode);
    if (paster.doPaste(m_modelToTextMerger)) {
        if (!modificationGroupActive()) {
            m_modelToTextMerger.applyChanges(*m_textModifier);
        }
        return true;
    } else {
        m_modelToTextMerger.clear();
        return false;
    }
}