Another Code Refactoring done

remotes/origin/textfind-and-transparency
Mohammad Mahfuzur Rahman Mamun 15 years ago
parent 88ec0951fe
commit dca4ee559c
  1. 18
      core/area.h
  2. 2
      core/page.cpp
  3. 691
      core/textpage.cpp
  4. 22
      core/textpage_p.h
  5. 22
      ui/pagepainter.cpp
  6. 1
      ui/pageview.cpp

@ -210,42 +210,48 @@ class OKULAR_EXPORT NormalizedRect
/** /**
* Returns true if the point pt is located to the bottom of the rectangle * Returns true if the point pt is located to the bottom of the rectangle
*/ */
bool isBottom(NormalizedPoint pt) const{ bool isBottom(NormalizedPoint pt) const
{
return bottom < pt.y; return bottom < pt.y;
} }
/** /**
* Returns true if the point pt is located on the top of the rectangle * Returns true if the point pt is located on the top of the rectangle
*/ */
bool isTop(NormalizedPoint pt) const{ bool isTop(NormalizedPoint pt) const
{
return top > pt.y; return top > pt.y;
} }
/** /**
* Returns true if the point pt is located under the top of the rectangle * Returns true if the point pt is located under the top of the rectangle
*/ */
bool isBottomOrLevel(NormalizedPoint pt) const{ bool isBottomOrLevel(NormalizedPoint pt) const
{
return top < pt.y; return top < pt.y;
} }
/** /**
* Returns true if the point pt is located above the bottom of the rectangle * Returns true if the point pt is located above the bottom of the rectangle
*/ */
bool isTopOrLevel(NormalizedPoint pt) const{ bool isTopOrLevel(NormalizedPoint pt) const
{
return bottom > pt.y; return bottom > pt.y;
} }
/** /**
* Returns true if the point pt is located to the right of the left arm of rectangle * Returns true if the point pt is located to the right of the left arm of rectangle
*/ */
bool isLeft(NormalizedPoint pt) const{ bool isLeft(NormalizedPoint pt) const
{
return left < pt.x; return left < pt.x;
} }
/** /**
* Returns true if the point pt is located to the left of the right arm of rectangle * Returns true if the point pt is located to the left of the right arm of rectangle
*/ */
bool isRight(NormalizedPoint pt) const{ bool isRight(NormalizedPoint pt) const
{
return right > pt.x; return right > pt.x;
} }

@ -453,7 +453,7 @@ void Page::setTextPage( TextPage * textPage )
{ {
d->m_text->d->m_page = d; d->m_text->d->m_page = d;
/** /**
* Correct text order for text selection * Correct text order for before text selection
*/ */
d->m_text->correctTextOrder(); d->m_text->correctTextOrder();
} }

File diff suppressed because it is too large Load Diff

@ -28,15 +28,15 @@ typedef QList< TinyTextEntity* > TextList;
typedef bool ( *TextComparisonFunction )( const QStringRef & from, const QStringRef & to, typedef bool ( *TextComparisonFunction )( const QStringRef & from, const QStringRef & to,
int *fromLength, int *toLength ); int *fromLength, int *toLength );
//mamun.nightcrawler@gmail.com
/** /**
We will make a line of TextList and also store the bounding rectangle of line * Make a line of TextList and store the bounding rectangle of line
**/ */
typedef QList<TextList> SortedTextList; typedef QList<TextList> SortedTextList;
typedef QList<QRect> LineRect; typedef QList<QRect> LineRect;
/** list of RegionText -- keeps a bunch of TextList with their bounding rectangles **/ /**
* A list of RegionText. It keeps a bunch of TextList with their bounding rectangles
*/
typedef QList<RegionText> RegionTextList; typedef QList<RegionText> RegionTextList;
class TextPagePrivate class TextPagePrivate
@ -55,10 +55,6 @@ class TextPagePrivate
TextComparisonFunction comparer, TextComparisonFunction comparer,
const TextList::ConstIterator &start, const TextList::ConstIterator &start,
const TextList::ConstIterator &end ); const TextList::ConstIterator &end );
/**
* Prints a line from m_lines
*/
void printTextList(int i, TextList list);
/** /**
* Copy a TextList to m_words * Copy a TextList to m_words
@ -70,11 +66,6 @@ class TextPagePrivate
*/ */
void copyFrom(TextList &list); void copyFrom(TextList &list);
/**
* Print the textpage contents with area (text and bounding rect)
*/
void printTextPageContent();
/** /**
* 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
*/ */
@ -103,7 +94,6 @@ class TextPagePrivate
*/ */
void XYCutForBoundingBoxes(int tcx,int tcy); void XYCutForBoundingBoxes(int tcx,int tcy);
/** /**
* Add additional spaces between words, if necessary, which can make the words valuable * Add additional spaces between words, if necessary, which can make the words valuable
* while copying after selection * while copying after selection
@ -115,8 +105,6 @@ class TextPagePrivate
*/ */
void breakWordIntoCharacters(); void breakWordIntoCharacters();
// variables those can be accessed directly from TextPage // variables those can be accessed directly from TextPage
QMap<int, RegionText> m_word_chars_map; QMap<int, RegionText> m_word_chars_map;
RegionTextList m_XY_cut_tree; RegionTextList m_XY_cut_tree;

@ -309,32 +309,26 @@ void PagePainter::paintCroppedPageOnPainter( QPainter * destPainter, const Okula
for( int x = highlightRect.left(); x <= highlightRect.right(); ++x ) for( int x = highlightRect.left(); x <= highlightRect.right(); ++x )
{ {
val = data[ x + offset ]; val = data[ x + offset ];
//for odt or epub //for odt or epub
if(has_alpha){ if(has_alpha)
{
newR = qRed(val); newR = qRed(val);
newG = qGreen(val); newG = qGreen(val);
newB = qBlue(val); newB = qBlue(val);
if(newR == newG && newG == newB && newR == 0){ if(newR == newG && newG == newB && newR == 0)
newR = newG = newB = 255; newR = newG = newB = 255;
}
newR = (newR * rh)/255; newR = (newR * rh) / 255;
newG = (newG * gh)/255; newG = (newG * gh) / 255;
newB = (newB * bh)/255; newB = (newB * bh) / 255;
// cout << newR << "," << newG << "," << newB << endl;
} }
else
//pdf, djvu and other formats {
else{
newR = (qRed(val) * rh) / 255; newR = (qRed(val) * rh) / 255;
newG = (qGreen(val) * gh) / 255; newG = (qGreen(val) * gh) / 255;
newB = (qBlue(val) * bh) / 255; newB = (qBlue(val) * bh) / 255;
} }
data[ x + offset ] = qRgba( newR, newG, newB, 255 ); data[ x + offset ] = qRgba( newR, newG, newB, 255 );
} }
offset += backImage.width(); offset += backImage.width();

@ -2143,7 +2143,6 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
//if there is text selected in the page //if there is text selected in the page
if(page->textSelection()) if(page->textSelection())
{ {
QAction *textToClipboard = menu.addAction( KIcon( "edit-copy" ), i18n( "Copy Text" ) ); QAction *textToClipboard = menu.addAction( KIcon( "edit-copy" ), i18n( "Copy Text" ) );
QAction *speakText = 0; QAction *speakText = 0;
if ( Okular::Settings::useKTTSD() ) if ( Okular::Settings::useKTTSD() )

Loading…
Cancel
Save