Delete COPYING as LICENSE is to be used
[apps/poi-yelp.git] / InfoPanelLabel.cpp
1 #include "InfoPanelLabel.h"
2
3 InfoPanelLabel::InfoPanelLabel(QWidget *parent, QRect &r):QLabel(parent),rect(r)
4 {
5 }
6
7 void InfoPanelLabel::Init(int pos, int height, const QString &text, QFont *font)
8 {
9     if (text.length() > 0)
10     {
11         setText(text);
12         if (font)
13             setFont(*font);
14     }
15     setStyleSheet("QLabel { background-color : white; color : #FFFFFF; }");
16     setGeometry(QRect(0, pos, rect.width(), height));
17
18     /* if text is too big, align left so that we can at least read the beginning : */
19     if (this->text().length() > 0 && this->fontMetrics().width(this->text()) >= rect.width())
20         setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
21     else
22         setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
23
24     setVisible(true);
25 }