File indexing completed on 2024-05-12 16:34:58

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007 Thomas Zander <zander@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 #ifndef TEXTCHANGE_H
0020 #define TEXTCHANGE_H
0021 
0022 #include <QString>
0023 
0024 class TextChange
0025 {
0026 public:
0027     TextChange();
0028     int formerLength() const;
0029     int length() const;
0030     int formerPosition() const;
0031     int position() const;
0032 
0033     TextChange *next() {
0034         return m_next;
0035     }
0036     const TextChange *next() const {
0037         return m_next;
0038     }
0039     TextChange *previous() {
0040         return m_previous;
0041     }
0042     const TextChange *previous() const {
0043         return m_previous;
0044     }
0045 
0046     QString before() const {
0047         return m_before;
0048     }
0049     QString after() const {
0050         return m_after;
0051     }
0052 
0053     void setPosition(int pos);
0054     void setOldText(const QString &old);
0055     void setNewText(const QString &current);
0056     void setPrevious(TextChange *item);
0057     void setNext(TextChange *item);
0058     void move(int length);
0059 
0060     void insertBefore(TextChange *node);
0061     void insertAfter(TextChange *node);
0062 
0063     void merge(TextChange *other);
0064 
0065 private:
0066     QString m_before, m_after;
0067     int m_formerPosition, m_position;
0068     TextChange *m_previous, *m_next;
0069 };
0070 
0071 #endif