69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#include <QPainter>
|
|
#include "WellLogLabel.h"
|
|
#include <QCoreApplication>
|
|
#include <QDir>
|
|
#include "geometryutils.h"
|
|
|
|
CWellLogLabel::CWellLogLabel(void)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
CWellLogLabel::~CWellLogLabel(void)
|
|
{
|
|
|
|
}
|
|
|
|
void CWellLogLabel::ShowPromtMessage(PromptType type)
|
|
{
|
|
m_PromptType = type;
|
|
update();
|
|
}
|
|
|
|
void CWellLogLabel::paintEvent(QPaintEvent *pEvent)
|
|
{
|
|
QPainter painter(this);
|
|
QFontMetrics fontMetrics(font());
|
|
switch (m_PromptType)
|
|
{
|
|
case PT_Error:
|
|
{
|
|
QPixmap errPixmap(GetImagePath()+ "error.png");
|
|
painter.drawPixmap(0, (this->height()-errPixmap.height())/2, errPixmap);
|
|
|
|
painter.setPen(Qt::red);
|
|
QString showText = fontMetrics.elidedText(text(),Qt::ElideRight,width()-errPixmap.width());
|
|
painter.drawText(rect().adjusted(errPixmap.width() + 3, 0, 0, 0),
|
|
Qt::AlignVCenter | Qt::AlignLeft, showText);
|
|
break;
|
|
}
|
|
case PT_Warning:
|
|
{
|
|
QPixmap warnPixmap(GetImagePath() + "warning.png");
|
|
painter.drawPixmap(0,(this->height()-warnPixmap.height())/2,warnPixmap);
|
|
painter.setPen(Qt::red);
|
|
QString showText = fontMetrics.elidedText(text(),Qt::ElideRight,width()-warnPixmap.width());
|
|
painter.drawText(rect().adjusted(warnPixmap.width() + 3, 0, 0, 0),
|
|
Qt::AlignVCenter | Qt::AlignLeft, showText);
|
|
break;
|
|
|
|
}
|
|
case PT_Right:
|
|
{
|
|
QPixmap rightPixmap(GetImagePath() + "right.png");
|
|
painter.drawPixmap(0,(this->height()- rightPixmap.height())/2,rightPixmap);
|
|
painter.setPen(Qt::black);
|
|
QString showText = fontMetrics.elidedText(text(),Qt::ElideRight,width()-rightPixmap.width());
|
|
painter.drawText(rect().adjusted(rightPixmap.width() + 3, 0, 0, 0),
|
|
Qt::AlignVCenter | Qt::AlignLeft, showText);
|
|
break;
|
|
}
|
|
default:
|
|
QLabel::paintEvent(pEvent);
|
|
break;
|
|
}
|
|
|
|
|
|
}
|