Rename copyFromList to setWordList

Also change the behaviour in that it adopts the pointers, saves a few news and deletes
remotes/origin/textfind-and-transparency
Albert Astals Cid 15 years ago
parent 33f9c203b1
commit 2ff2cd9434
  1. 31
      core/textpage.cpp
  2. 8
      core/textpage_p.h

@ -999,22 +999,16 @@ static bool compareTinyTextEntityY(TinyTextEntity* first, TinyTextEntity* second
/** /**
* Copies a TextList to m_words with the same pointer * Copies a TextList to m_words with the same pointer
*/ */
void TextPagePrivate::copyFromList(const TextList &list) void TextPagePrivate::setWordList(const TextList &list)
{ {
qDeleteAll(m_words); qDeleteAll(m_words);
m_words.clear(); m_words = list;
for(int i = 0 ; i < list.length() ; i++)
{
TinyTextEntity *ent = list.at(i);
m_words.append( new TinyTextEntity(ent->text(),ent->area) );
}
} }
/** /**
* Copies from m_words to list with distinct pointers * Copies from m_words to list with distinct pointers
*/ */
TextList TextPagePrivate::duplicateWordsList() const TextList TextPagePrivate::duplicateWordList() const
{ {
TextList list; TextList list;
for(int i = 0 ; i < m_words.length() ; i++) for(int i = 0 ; i < m_words.length() ; i++)
@ -1130,7 +1124,7 @@ void TextPagePrivate::makeWordFromCharacters()
* Finally we copy the newList to m_words. * Finally we copy the newList to m_words.
*/ */
const TextList tmpList = duplicateWordsList(); const TextList tmpList = duplicateWordList();
TextList newList; TextList newList;
TextList::ConstIterator it = tmpList.begin(), itEnd = tmpList.end(), tmpIt; TextList::ConstIterator it = tmpList.begin(), itEnd = tmpList.end(), tmpIt;
@ -1232,9 +1226,8 @@ void TextPagePrivate::makeWordFromCharacters()
if(it == itEnd) break; if(it == itEnd) break;
} }
copyFromList(newList);
qDeleteAll(tmpList); qDeleteAll(tmpList);
qDeleteAll(newList); setWordList(newList);
} }
/** /**
@ -1513,7 +1506,7 @@ void TextPagePrivate::XYCutForBoundingBoxes(int tcx, int tcy)
const int pageHeight = m_page->m_page->height(); const int pageHeight = m_page->m_page->height();
RegionTextList tree; RegionTextList tree;
QRect contentRect(m_page->m_page->boundingBox().geometry(pageWidth,pageHeight)); QRect contentRect(m_page->m_page->boundingBox().geometry(pageWidth,pageHeight));
const TextList words = duplicateWordsList(); const TextList words = duplicateWordList();
const RegionText root(words,contentRect); const RegionText root(words,contentRect);
// start the tree with the root, it is our only region at the start // start the tree with the root, it is our only region at the start
@ -1783,9 +1776,8 @@ void TextPagePrivate::XYCutForBoundingBoxes(int tcx, int tcy)
tmp.append( new TinyTextEntity(ent->text(),ent->area) ); tmp.append( new TinyTextEntity(ent->text(),ent->area) );
} }
} }
//copying elements of tmp to m_words // set tmp as new m_words
copyFromList(tmp); setWordList(tmp);
qDeleteAll(tmp);
// we are not removing tmp because, the elements of tmp are in m_XY_cut_tree, we will finally free from m_XY_cut_tree // we are not removing tmp because, the elements of tmp are in m_XY_cut_tree, we will finally free from m_XY_cut_tree
m_XY_cut_tree = tree; m_XY_cut_tree = tree;
@ -1878,9 +1870,7 @@ void TextPagePrivate::addNecessarySpace()
tmp.append(new TinyTextEntity(ent->text(),ent->area)); tmp.append(new TinyTextEntity(ent->text(),ent->area));
} }
} }
copyFromList(tmp); setWordList(tmp);
// deletes all TinyTextEntity from the m_XY_cut_tree
qDeleteAll(tmp);
} }
/** /**
@ -1929,8 +1919,7 @@ void TextPagePrivate::breakWordIntoCharacters()
tmp.append(list); tmp.append(list);
} }
} }
copyFromList(tmp); setWordList(tmp);
qDeleteAll(tmp);
} }

@ -57,14 +57,14 @@ class TextPagePrivate
const TextList::ConstIterator &end ); const TextList::ConstIterator &end );
/** /**
* Copy a TextList to m_words * Copy a TextList to m_words, the pointers of list are adopted
*/ */
void copyFromList(const TextList &list); void setWordList(const TextList &list);
/** /**
* Copy m_words to a TextList * Copy m_words to a new TextList, it is the caller responsability to free the pointers
*/ */
TextList duplicateWordsList() const; TextList duplicateWordList() const;
/** /**
* Remove odd spaces which are much bigger than normal spaces from m_words * Remove odd spaces which are much bigger than normal spaces from m_words

Loading…
Cancel
Save