[app] Added BooksPos::toString() method

This commit is contained in:
Slava Monich 2016-11-24 17:49:54 +02:00
parent 1a8aad3139
commit 32013a8ac5

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 Jolla Ltd. * Copyright (C) 2015-2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Contact: Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of the BSD license as follows: * You may use this file under the terms of the BSD license as follows:
@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors * * Neither the name of Jolla Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this * may be used to endorse or promote products derived from this
* software without specific prior written permission. * software without specific prior written permission.
* *
@ -38,7 +38,6 @@
#include <QDebug> #include <QDebug>
#include <QList> #include <QList>
#include "ZLTextParagraphCursor.h" #include "ZLTextParagraphCursor.h"
struct BooksPos { struct BooksPos {
@ -157,11 +156,21 @@ struct BooksPos {
iElementIndex != aPos.iElementIndex || iElementIndex != aPos.iElementIndex ||
iCharIndex != aPos.iCharIndex; iCharIndex != aPos.iCharIndex;
} }
QString toString() const
{
return QString("BooksPos(%1,%2,%3)").arg(iParagraphIndex).
arg(iElementIndex).arg(iCharIndex);
}
static BooksPos posAt(BooksPos::List aList, int aPage)
{
return (aPage >=0 && aPage < aList.count()) ?
aList.at(aPage) : BooksPos();
}
}; };
inline QDebug& operator<<(QDebug& aDebug, const BooksPos& aPosition) inline QDebug& operator<<(QDebug& aDebug, const BooksPos& aPos)
{ aDebug << qPrintable(QString("BooksPos(%1,%2,%3)"). { aDebug << qPrintable(aPos.toString()); return aDebug; }
arg(aPosition.iParagraphIndex).arg(aPosition.iElementIndex).
arg(aPosition.iCharIndex)); return aDebug.maybeSpace(); }
#endif /* BOOKS_POSITION_H */ #endif /* BOOKS_POSITION_H */