From 59b267386c13622edec475fbbeeef8cd279e6883 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 26 May 2006 14:32:35 +0000 Subject: [PATCH] avoid using QString*, just use QString svn path=/branches/work/kde4/playground/graphics/okular/; revision=544974 --- core/page.cpp | 4 ++-- core/page.h | 2 +- core/textpage.cpp | 12 ++++++------ core/textpage.h | 2 +- ui/pageview.cpp | 11 +++++------ 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/page.cpp b/core/page.cpp index 878e9b07b..948c2ead9 100644 --- a/core/page.cpp +++ b/core/page.cpp @@ -131,9 +131,9 @@ RegularAreaRect * KPDFPage::findText( const QString & text, SearchDir dir, const */ } -QString * KPDFPage::getText( const RegularAreaRect * area ) const +QString KPDFPage::getText( const RegularAreaRect * area ) const { - QString *ret= 0; + QString ret; if ( !m_text ) return ret; diff --git a/core/page.h b/core/page.h index 4ce4689b3..f03437811 100644 --- a/core/page.h +++ b/core/page.h @@ -70,7 +70,7 @@ class OKULAR_EXPORT KPDFPage bool hasTransition() const; RegularAreaRect * findText( const QString & text, SearchDir dir, bool strictCase, const RegularAreaRect * lastRect=0) const; - QString * getText( const RegularAreaRect * rect ) const; + QString getText( const RegularAreaRect * rect ) const; RegularAreaRect * getTextArea ( TextSelection * ) const; // const ObjectRect * getObjectRect( double x, double y ) const; const ObjectRect * getObjectRect( ObjectRect::ObjectType type, double x, double y ) const; diff --git a/core/textpage.cpp b/core/textpage.cpp index c6415da9c..119735e4d 100644 --- a/core/textpage.cpp +++ b/core/textpage.cpp @@ -297,13 +297,13 @@ RegularAreaRect* KPDFTextPage::findTextInternal(const QString &query, bool forwa return 0; } -QString * KPDFTextPage::getText(const RegularAreaRect *area) +QString KPDFTextPage::getText(const RegularAreaRect *area) const { - if (area->isNull()) - return 0; + if (!area || area->isNull()) + return QString(); - QString* ret = new QString; - QList::Iterator it,end = m_words.end(); + QString ret = ""; + QList::ConstIterator it,end = m_words.end(); KPDFTextEntity * last=0; for( it=m_words.begin() ; it != end; ++it ) { @@ -311,7 +311,7 @@ QString * KPDFTextPage::getText(const RegularAreaRect *area) if (area->intersects((*it)->area)) { // kDebug()<< "[" << (*it)->area->left << "," << (*it)->area->top << "]x["<< (*it)->area->right << "," << (*it)->area->bottom << "]\n"; - *ret += ((*it)->txt); + ret += (*it)->txt; last=*it; } } diff --git a/core/textpage.h b/core/textpage.h index 7dfee2c43..816dc2981 100644 --- a/core/textpage.h +++ b/core/textpage.h @@ -62,7 +62,7 @@ class KPDFTextPage { public: RegularAreaRect* findText(const QString &query, SearchDir & direct, const bool &strictCase, const RegularAreaRect *area); - QString * getText(const RegularAreaRect *rect); + QString getText(const RegularAreaRect *rect) const; RegularAreaRect * getTextArea ( TextSelection* ) const; KPDFTextPage(QList words) : m_words(words) {}; KPDFTextPage() : m_words() {}; diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 643529fcb..03f497e9a 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -1304,7 +1304,7 @@ if (d->document->handleEvent( e ) ) } // if we support text generation - QString* selectedText=0; + QString selectedText; if (d->document->supportsSearching()) { // grab text in selection by extracting it from all intersected pages @@ -1334,9 +1334,9 @@ if (d->document->handleEvent( e ) ) // popup that ask to copy:text and copy/save:image KMenu menu( this ); QAction *textToClipboard = 0, *speakText = 0, *imageToClipboard = 0, *imageToFile = 0; - if ( d->document->supportsSearching() && !selectedText->isEmpty() ) + if ( d->document->supportsSearching() && !selectedText.isEmpty() ) { - menu.addTitle( i18np( "Text (1 character)", "Text (%n characters)", selectedText->length() ) ); + menu.addTitle( i18np( "Text (1 character)", "Text (%n characters)", selectedText.length() ) ); textToClipboard = menu.addAction( SmallIconSet("editcopy"), i18n( "Copy to Clipboard" ) ); if ( !d->document->isAllowed( KPDFDocument::AllowCopy ) ) { @@ -1394,9 +1394,9 @@ if (d->document->handleEvent( e ) ) { // [1] copy text to clipboard QClipboard *cb = QApplication::clipboard(); - cb->setText( *selectedText, QClipboard::Clipboard ); + cb->setText( selectedText, QClipboard::Clipboard ); if ( cb->supportsSelection() ) - cb->setText( *selectedText, QClipboard::Selection ); + cb->setText( selectedText, QClipboard::Selection ); } else if ( choice == speakText ) { @@ -1439,7 +1439,6 @@ if (d->document->handleEvent( e ) ) } } } - delete selectedText; // clear widget selection and invalidate rect selectionClear();