Passing an integer to a string to a method having QString as a parameter signature
C. Boemann
cbo at boemann.dk
Tue Feb 8 13:34:55 GMT 2011
On Tuesday 08 February 2011 13:59:47 Gopalakrishna Bhat wrote:
> I was looking as this piece of code in KoTextEditor.cpp
>
>
> void KoTextEditor::newLine()
> {
> d->updateState(KoTextEditor::Private::Custom, i18n("Line Break"));
> if (d->caret.hasSelection())
> d->deleteInlineObjects();
> KoTextDocument koDocument(d->document);
> KoStyleManager *styleManager = koDocument.styleManager();
> KoParagraphStyle *nextStyle = 0;
> KoParagraphStyle *currentStyle = 0;
> if (styleManager) {
> int id =
> d->caret.blockFormat().intProperty(KoParagraphStyle::StyleId);
> currentStyle = styleManager->paragraphStyle(id);
> if (currentStyle == 0) // not a style based parag. Lets make the
> next one correct.
> nextStyle = styleManager->defaultParagraphStyle();
> else
> nextStyle =
> styleManager->paragraphStyle(currentStyle->nextStyle());
> Q_ASSERT(nextStyle);
> if (currentStyle == nextStyle)
> nextStyle = 0;
> }
> .
> .
> .
>
> }
>
>
> Here the parameter passed to styleManager->paragraphStyle(id) is a integer
> whereas its signature shows that it is a const QString....Is this the right
> way to call or am I missing something?
>
> //snippet from KoStyleManager.cpp
> KoParagraphStyle *KoStyleManager::paragraphStyle(const QString &name) const
> {
> foreach(KoParagraphStyle *style, d->paragStyles) {
> qDebug()<<Q_FUNC_INFO<<" name "<<name<<"style->name
> "<<style->name();
> if (style->name() == name)
> return style;
> }
> return 0;
from KoStyleManager.h:
/**
* Return a paragraphStyle by its id.
* From documents you can retrieve the id out of each QTextBlockFormat
* by requesting the KoParagraphStyle::StyleId property.
* @param id the unique Id to search for.
* @see KoParagraphStyle::styleId()
*/
KoParagraphStyle *paragraphStyle(int id) const;
More information about the calligra-devel
mailing list