summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2010-05-05 08:08:43 +0200
committerKai Koehne <kai.koehne@nokia.com>2010-05-05 08:09:50 +0200
commitda621f82db110e5f169016a2200f09395b0b257d (patch)
tree1aa7d00f9dab5adf70bfe19553b9a5972219fa34 /src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp
parent75803b08d29b3e38897d1667f697d9664fd59208 (diff)
downloadqt-creator-da621f82db110e5f169016a2200f09395b0b257d.tar.gz
QuickDesigner: Rename "core" directory to "designercore"
Avoids problems when e.g. running 'make clean' - this one tries to delete all files named core.
Diffstat (limited to 'src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp')
-rw-r--r--src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp188
1 files changed, 0 insertions, 188 deletions
diff --git a/src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp b/src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp
deleted file mode 100644
index 69277d269f..0000000000
--- a/src/plugins/qmldesigner/core/model/plaintexteditmodifier.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "plaintexteditmodifier.h"
-
-#include <utils/changeset.h>
-
-#include <QtGui/QPlainTextEdit>
-#include <QtGui/QUndoStack>
-
-#include <QtCore/QDebug>
-
-using namespace Utils;
-using namespace QmlDesigner;
-
-PlainTextEditModifier::PlainTextEditModifier(QPlainTextEdit *textEdit):
- m_changeSet(0),
- m_textEdit(textEdit),
- m_changeSignalsEnabled(true),
- m_pendingChangeSignal(false),
- m_ongoingTextChange(false)
-{
- Q_ASSERT(textEdit);
-
- connect(m_textEdit, SIGNAL(textChanged()),
- this, SLOT(textEditChanged()));
-}
-
-PlainTextEditModifier::~PlainTextEditModifier()
-{
-}
-
-void PlainTextEditModifier::save(QIODevice *device)
-{
- device->write(m_textEdit->toPlainText().toLatin1());
-}
-
-void PlainTextEditModifier::replace(int offset, int length, const QString &replacement)
-{
-#if 0
- qDebug() << "Original:" << m_textEdit->toPlainText();
- qDebug() << "Replacement:" << replacement;
- qDebug() << " offset:" << offset;
- qDebug() << " length:" << length;
-#endif
-
- Q_ASSERT(offset >= 0);
- Q_ASSERT(length >= 0);
-
- const int replacementLength = replacement.length();
-
- if (m_changeSet) {
- m_changeSet->replace(offset, length, replacement);
- emit replaced(offset, length, replacementLength);
- } else {
- ChangeSet changeSet;
- changeSet.replace(offset, length, replacement);
- emit replaced(offset, length, replacementLength);
- runRewriting(&changeSet);
- }
-}
-
-void PlainTextEditModifier::move(const MoveInfo &moveInfo)
-{
- Q_ASSERT(moveInfo.objectStart >= 0);
- Q_ASSERT(moveInfo.objectEnd > moveInfo.objectStart);
- Q_ASSERT(moveInfo.destination >= 0);
- Q_ASSERT(moveInfo.leadingCharsToRemove >= 0);
- Q_ASSERT(moveInfo.trailingCharsToRemove >= 0);
- Q_ASSERT(moveInfo.objectStart - moveInfo.leadingCharsToRemove >= 0);
-
- if (m_changeSet) {
- m_changeSet->insert(moveInfo.destination, moveInfo.prefixToInsert);
- m_changeSet->move(moveInfo.objectStart, moveInfo.objectEnd - moveInfo.objectStart, moveInfo.destination);
- m_changeSet->insert(moveInfo.destination, moveInfo.suffixToInsert);
- m_changeSet->remove(moveInfo.objectStart - moveInfo.leadingCharsToRemove, moveInfo.leadingCharsToRemove);
- m_changeSet->remove(moveInfo.objectEnd, moveInfo.trailingCharsToRemove);
- emit moved(moveInfo);
- } else {
- ChangeSet changeSet;
- changeSet.insert(moveInfo.destination, moveInfo.prefixToInsert);
- changeSet.move(moveInfo.objectStart, moveInfo.objectEnd - moveInfo.objectStart, moveInfo.destination);
- changeSet.insert(moveInfo.destination, moveInfo.suffixToInsert);
- changeSet.remove(moveInfo.objectStart - moveInfo.leadingCharsToRemove, moveInfo.leadingCharsToRemove);
- changeSet.remove(moveInfo.objectEnd, moveInfo.trailingCharsToRemove);
- emit moved(moveInfo);
- runRewriting(&changeSet);
- }
-}
-
-void PlainTextEditModifier::startGroup()
-{
- if (!m_changeSet)
- m_changeSet = new ChangeSet;
-
- m_textEdit->textCursor().beginEditBlock();
-}
-
-void PlainTextEditModifier::flushGroup()
-{
- if (m_changeSet)
- runRewriting(m_changeSet);
-}
-
-void PlainTextEditModifier::commitGroup()
-{
- if (m_changeSet) {
- runRewriting(m_changeSet);
- delete m_changeSet;
- m_changeSet = 0;
- }
-
- m_textEdit->textCursor().endEditBlock();
-}
-
-void PlainTextEditModifier::textEditChanged()
-{
- if (!m_ongoingTextChange && m_changeSignalsEnabled) {
- emit textChanged();
- } else {
- m_pendingChangeSignal = true;
- }
-}
-
-void PlainTextEditModifier::runRewriting(ChangeSet *changeSet)
-{
- m_ongoingTextChange = true;
- QTextCursor cursor = m_textEdit->textCursor();
- changeSet->apply(&cursor);
- m_ongoingTextChange = false;
- textEditChanged();
-}
-
-QTextDocument *PlainTextEditModifier::textDocument() const
-{
- return m_textEdit->document();
-}
-
-QString PlainTextEditModifier::text() const
-{
- return m_textEdit->toPlainText();
-}
-
-QTextCursor PlainTextEditModifier::textCursor() const
-{
- return m_textEdit->textCursor();
-}
-
-void PlainTextEditModifier::deactivateChangeSignals()
-{
- m_changeSignalsEnabled = false;
-}
-
-void PlainTextEditModifier::reactivateChangeSignals()
-{
- m_changeSignalsEnabled = true;
-
- if (m_pendingChangeSignal) {
- m_pendingChangeSignal = false;
- emit textChanged();
- }
-}