X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fui%2Fextendedlistitem.cpp;fp=src%2Fui%2Fextendedlistitem.cpp;h=ed2f912226c53fa1dfa1318079cbbb382f17afdb;hb=3ce90337cba06664859bafe3e21f679c2a2e4df6;hp=868857f6c83ad9a974b54644721f2675486b0bd1;hpb=c074268ac200455b2d1c7d9e2b8ca97518493904;p=situare diff --git a/src/ui/extendedlistitem.cpp b/src/ui/extendedlistitem.cpp index 868857f..ed2f912 100644 --- a/src/ui/extendedlistitem.cpp +++ b/src/ui/extendedlistitem.cpp @@ -76,40 +76,37 @@ void ExtendedListItem::addSubItem(const QString &text, const QPixmap &icon) QRect ExtendedListItem::boundingRect(const QString &text) { - qWarning() << __PRETTY_FUNCTION__ << text; + qDebug() << __PRETTY_FUNCTION__; QPixmap p = QPixmap(ICON_WIDTH, ICON_HEIGHT); QPainter painter(&p); painter.setFont(NOKIA_FONT_SMALL); - QFontMetrics textMetrics = painter.fontMetrics(); + QRect textRect; textRect.setSize(QSize(m_subItemTextWidth, textMetrics.height())); - QStringList rows = text.split('\n'); - - for (int i = 1; i < rows.count(); ++i) { - qWarning() << "jep"; - QRect textRowRect = textMetrics.boundingRect(rows.at(i)); - textRect.setHeight(textRect.height() + textRowRect.height()); + QStringList lines = text.split("\n"); + for (int i = 1; i < lines.count(); ++i) { + textRect.setHeight(textRect.height() + textMetrics.height()); } QStringList words = text.split(" "); - QString rowText; + QString textLine; for (int i = 0; i < words.count(); ++i) { - if (i == words.count() -1) - rowText.append(words.at(i)); + + if (i == 0) + textLine.append(words.at(i)); else - rowText.append(words.at(i) + " "); - if (textMetrics.width(rowText) > m_subItemTextWidth) { + textLine.append(" " + words.at(i)); + + if ((textMetrics.width(textLine) > m_subItemTextWidth) && !textLine.contains("\n")) { textRect.setHeight(textRect.height() + textMetrics.height()); - rowText = words.at(i); - qWarning() << "hep"; + textLine.clear(); + textLine.append(words.at(i)); } } - //textRect.setHeight(textRect.height() + 5); -// qWarning() << textRect.width() << textRect.height(); return textRect; } @@ -121,11 +118,6 @@ QRect ExtendedListItem::calculateExpandedTextRect(const QString &text) QRect textRect = boundingRect(text); QRect expandedTextRect = textRect; -// int textRectFactor = textRect.width() / m_subItemTextWidth; -// textRectFactor += textRect.height() / SUBITEM_TEXT_ROW_HEIGHT; - -// QRect expandedTextRect = QRect(0, 0, m_subItemTextWidth, SUBITEM_TEXT_ROW_HEIGHT -// * qMax(textRectFactor, 1)); m_normalHeight += SUBITEM_TEXT_ROW_HEIGHT + TEXT_BOTTOM_MARGIN; m_expandedHeight += expandedTextRect.height() + TEXT_BOTTOM_MARGIN;