Passing an integer to a string to a method having QString as a parameter signature

Gopalakrishna Bhat gopalakbhat at gmail.com
Tue Feb 8 13:39:13 GMT 2011


Thanks! :)

On Tue, Feb 8, 2011 at 7:04 PM, C. Boemann <cbo at boemann.dk> wrote:

> 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;
> _______________________________________________
> calligra-devel mailing list
> calligra-devel at kde.org
> https://mail.kde.org/mailman/listinfo/calligra-devel
>



-- 
My blog http://gkbhat.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20110208/8216e288/attachment.htm>


More information about the calligra-devel mailing list