--- a/src/hbwidgets/widgets/hblabel.cpp Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbwidgets/widgets/hblabel.cpp Wed Aug 18 10:05:37 2010 +0300
@@ -37,6 +37,7 @@
#include "hbstyleoptionlabel_p.h"
#include "hbwidgetbase.h"
#include "hblabel.h"
+#include "hbstyle_p.h"
/*!
@alpha
@@ -94,7 +95,7 @@
void clearAll();
- void setText(const QString &text, HbStyle::Primitive primitiveId);
+ void setText(const QString &text, HbStylePrivate::Primitive primitiveId);
void setIcon(const HbIcon &icon);
void updatePrimitives ();
@@ -108,6 +109,7 @@
Qt::TextElideMode mElideMode;
Hb::TextWrapping mTextWrapping;
QColor mColor;
+ int mMaxLines;
// icon section
HbIcon mIcon;
@@ -115,7 +117,7 @@
// primitive handling
QGraphicsItem *mPrimitiveItem;
- HbStyle::Primitive mActivePrimitive;
+ HbStylePrivate::Primitive mActivePrimitive;
};
HbLabelPrivate::HbLabelPrivate() :
@@ -124,9 +126,10 @@
mText(QString()),
mElideMode(Qt::ElideRight),
mTextWrapping(Hb::TextNoWrap),
+ mMaxLines(0),
mAspectRatioMode(Qt::KeepAspectRatio),
mPrimitiveItem(0),
- mActivePrimitive(HbStyle::P_None)
+ mActivePrimitive(HbStylePrivate::P_None)
{
}
@@ -135,14 +138,14 @@
if (mPrimitiveItem) {
delete mPrimitiveItem;
mPrimitiveItem = 0;
- mActivePrimitive = HbStyle::P_None;
+ mActivePrimitive = HbStylePrivate::P_None;
}
mText.clear();
mIcon.clear();
}
-void HbLabelPrivate::setText(const QString &text, HbStyle::Primitive primitiveId)
+void HbLabelPrivate::setText(const QString &text, HbStylePrivate::Primitive primitiveId)
{
Q_Q(HbLabel);
@@ -175,15 +178,15 @@
return;
}
- if (mActivePrimitive != HbStyle::P_Label_icon) {
+ if (mActivePrimitive != HbStylePrivate::P_Label_icon) {
clearAll();
}
if (mIcon != icon) {
mIcon = icon;
- if (mActivePrimitive != HbStyle::P_Label_icon) {
- mActivePrimitive = HbStyle::P_Label_icon;
+ if (mActivePrimitive != HbStylePrivate::P_Label_icon) {
+ mActivePrimitive = HbStylePrivate::P_Label_icon;
createPrimitives();
q->repolish(); // reconecting new primitive to HbAnchorLayout so it is really needed!
}
@@ -201,8 +204,8 @@
Q_ASSERT(mPrimitiveItem==0);
- if (mActivePrimitive != HbStyle::P_None) {
- mPrimitiveItem = q->style()->createPrimitive(mActivePrimitive, q);
+ if (mActivePrimitive != HbStylePrivate::P_None) {
+ mPrimitiveItem = HbStylePrivate::createPrimitive(mActivePrimitive, q);
}
}
@@ -210,14 +213,14 @@
{
Q_Q(HbLabel);
- if (mActivePrimitive != HbStyle::P_None) {
- Q_ASSERT(mActivePrimitive == HbStyle::P_Label_icon
- || mActivePrimitive == HbStyle::P_Label_richtext
- || mActivePrimitive == HbStyle::P_Label_text);
+ if (mActivePrimitive != HbStylePrivate::P_None) {
+ Q_ASSERT(mActivePrimitive == HbStylePrivate::P_Label_icon
+ || mActivePrimitive == HbStylePrivate::P_Label_richtext
+ || mActivePrimitive == HbStylePrivate::P_Label_text);
HbStyleOptionLabel option;
q->initStyleOption(&option);
- q->style()->updatePrimitive(mPrimitiveItem, mActivePrimitive, &option);
+ HbStylePrivate::updatePrimitive(mPrimitiveItem, mActivePrimitive, &option);
}
}
@@ -432,7 +435,7 @@
void HbLabel::setPlainText(const QString &text)
{
Q_D(HbLabel);
- d->setText(text, HbStyle::P_Label_text);
+ d->setText(text, HbStylePrivate::P_Label_text);
}
/*!
@@ -446,7 +449,7 @@
void HbLabel::setHtml(const QString &text)
{
Q_D(HbLabel);
- d->setText(text, HbStyle::P_Label_richtext);
+ d->setText(text, HbStylePrivate::P_Label_richtext);
}
/*!
@@ -460,7 +463,7 @@
Q_D(HbLabel);
if (d->mAlignment != alignment) {
d->mAlignment = alignment;
- if (d->mActivePrimitive!=HbStyle::P_None) {
+ if (d->mActivePrimitive!=HbStylePrivate::P_None) {
updatePrimitives();
}
}
@@ -490,7 +493,7 @@
bool HbLabel::isEmpty() const
{
Q_D(const HbLabel);
- return d->mActivePrimitive == HbStyle::P_None;
+ return d->mActivePrimitive == HbStylePrivate::P_None;
}
/*!
@@ -500,7 +503,7 @@
Returns a pointer to the QGraphicsItem primitive used by this label.
\param primitive - the type of graphics primitive required.
- HbLabel supports HbStyle::P_Label_text and HbStyle::P_Label_icon.
+ HbLabel supports HbStylePrivate::P_Label_text and HbStylePrivate::P_Label_icon.
\return the QGraphicsItem used by the label. It is 0 if type \a primitive not currently in use.
It is also 0 if the text or icon object is empty.
@@ -511,7 +514,7 @@
QGraphicsItem * HbLabel::primitive(HbStyle::Primitive primitive) const
{
Q_D(const HbLabel);
- if (primitive == d->mActivePrimitive) {
+ if ((HbStylePrivate::Primitive)primitive == d->mActivePrimitive) {
return d->mPrimitiveItem;
}
return HbWidget::primitive(primitive);
@@ -536,6 +539,7 @@
option->elideMode = d->mElideMode;
option->textWrapMode = d->mTextWrapping;
option->color = d->mColor;
+ option->maximumLines = d->mMaxLines;
}
if (!d->mIcon.isNull()) {
@@ -576,7 +580,7 @@
QString HbLabel::plainText() const
{
Q_D(const HbLabel);
- if (d->mActivePrimitive == HbStyle::P_Label_text) {
+ if (d->mActivePrimitive == HbStylePrivate::P_Label_text) {
return d->mText;
}
return QString();
@@ -588,7 +592,7 @@
QString HbLabel::html() const
{
Q_D(const HbLabel);
- if (d->mActivePrimitive == HbStyle::P_Label_richtext) {
+ if (d->mActivePrimitive == HbStylePrivate::P_Label_richtext) {
return d->mText;
}
return QString();
@@ -617,4 +621,36 @@
return d->mColor;
}
+/*!
+ If plain text is used (\sa setPlainText) this will set maximum number of lines
+ to be visible in label.
+ Zero or negative value disables the feature.
+
+ \sa maximumLines()
+ */
+void HbLabel::setMaximumLines(int maxLines)
+{
+ Q_D(HbLabel);
+
+ maxLines = qMax(maxLines, 0);
+ if (d->mMaxLines != maxLines) {
+ d->mMaxLines = maxLines;
+ if (d->mActivePrimitive == HbStylePrivate::P_Label_text) {
+ updatePrimitives();
+ }
+ }
+}
+
+/*!
+ Returns maximum number of lines which can be visible in label when
+ plain text is used (\sa setPlainText).
+ Zero value means that there is no limitation.
+
+ \sa setMaximumLines(int)
+ */
+int HbLabel::maximumLines() const
+{
+ return d_func()->mMaxLines;
+}
+
#include "moc_hblabel.cpp"