Author: jghali
Date: Wed Jan 18 19:32:49 2017
New Revision: 21733

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21733
Log:
#14565: selecting word by double clicking doesn't work in some cases

Modified:
    trunk/Scribus/scribus/text/storytext.cpp
    trunk/Scribus/scribus/text/storytext.h

Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=21733&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp    (original)
+++ trunk/Scribus/scribus/text/storytext.cpp    Wed Jan 18 19:32:49 2017
@@ -82,7 +82,6 @@
 {
        d = other.d;
        d->refs++;
-       m_text = other.m_text;
        
        if (m_doc) {
                m_doc->paragraphStyles().connect(this, SLOT(invalidateAll()));
@@ -157,7 +156,6 @@
        
        m_doc = other.m_doc; 
        d = other.d;
-       m_text = other.m_text;
        
        if (m_doc) {
                m_doc->paragraphStyles().connect(this, SLOT(invalidateAll()));
@@ -310,7 +308,6 @@
 
        d->clear();
        d->len = 0;
-       m_text.clear();
        invalidateAll();
 }
 
@@ -527,7 +524,7 @@
        if (pos + static_cast<int>(len) > length())
                len = length() - pos;
 
-       for ( int i = pos + static_cast<int>(len) - 1; i >= pos; --i )
+       for (int i = pos + static_cast<int>(len) - 1; i >= pos; --i)
        {
                ScText *it = d->at(i);
                if ((it->ch == SpecialChars::PARSEP))
@@ -553,7 +550,6 @@
                m_selLast  = -1;
        }
        invalidate(pos, length());
-       m_text.remove(pos, len);
 }
 
 void StoryText::trim()
@@ -610,20 +606,17 @@
 
        for (int i = 0; i < txt.length(); ++i) {
                ScText * item = new ScText(clone);
-               QChar tmpch = txt.at(i);
-               item->ch = tmpch;
+               item->ch= txt.at(i);
                item->setContext(cStyleContext);
                d->insert(pos + i, item);
                d->len++;
                if (item->ch == SpecialChars::PARSEP) {
 //                     qDebug() << QString("new PARSEP %2 at 
%1").arg(pos).arg(paragraphStyle(pos).name());
                        insertParSep(pos + i);
-                       tmpch = QLatin1Char('\n');
                }
                if (d->cursorPosition >= static_cast<uint>(pos + i)) {
                        d->cursorPosition += 1;
                }
-               m_text += tmpch;
        }
 
        d->len = d->count();
@@ -676,14 +669,10 @@
                        d->insert(index, item);
                        d->len++;
                        if (item->ch == SpecialChars::PARSEP)
-                       {
                                insertParSep(index);
-                               ch = QLatin1Char('\n');
-                       }
                        if (d->cursorPosition >= static_cast<uint>(index))
                                d->cursorPosition += 1;
                        ++inserted;
-                       m_text += ch;
                }
        }
 
@@ -712,9 +701,6 @@
        }
        
        invalidate(pos, pos + 1);
-       if (ch == SpecialChars::PARSEP)
-               ch = QLatin1Char('\n');
-       m_text[pos] = ch;
 }
 
 int StoryText::replaceWord(int pos, QString newWord)
@@ -820,7 +806,24 @@
 
 QString StoryText::plainText() const
 {
-       return m_text;
+       if (length() <= 0)
+               return QString();
+
+       QChar   ch;
+       QString result;
+
+       int len = length();
+       result.reserve(len);
+
+       StoryText* that(const_cast<StoryText*>(this));
+       for (int i = 0; i < len; ++i) {
+               ch = that->d->at(i)->ch;
+               if (ch == SpecialChars::PARSEP)
+                       ch = QLatin1Char('\n');
+               result += ch;
+       }
+
+       return result;
 }
 #if 0
 QChar StoryText::text() const

Modified: trunk/Scribus/scribus/text/storytext.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=21733&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h      (original)
+++ trunk/Scribus/scribus/text/storytext.h      Wed Jan 18 19:32:49 2017
@@ -281,8 +281,6 @@
        ScText * item(uint index);
        const ScText * item(uint index) const;
        void fixSurrogateSelection();
-       // storage for plain text
-       QString m_text;
 
 //public:
 //     ScText * item_p(uint index) { return item(index); }


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to