Stop event text from being stacked when too close

This commit is contained in:
Mark Watkins 2014-08-06 12:08:19 +10:00
parent 639588a261
commit d361a6398f
3 changed files with 27 additions and 10 deletions

View File

@ -873,8 +873,13 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
painter.setClipping(false);
if (m_day && (p_profile->appearance->lineCursorMode() || (m_codes[0]==CPAP_FlowRate))) {
QHash<ChannelID, gLineOverlayBar *>::iterator fit;
bool blockhover = false;
for (fit = flags.begin(); fit != flags.end(); ++fit) {
fit.value()->paint(painter, w, region);
gLineOverlayBar * lob = fit.value();
lob->setBlockHover(blockhover);
lob->paint(painter, w, region);
if (lob->hover()) blockhover = true; // did it render a hover over?
}
}
painter.setRenderHint(QPainter::Antialiasing, false);

View File

@ -16,7 +16,8 @@
gLineOverlayBar::gLineOverlayBar(ChannelID code, QColor color, QString label, FlagType flt)
: Layer(code), m_flag_color(color), m_label(label), m_flt(flt), m_odt(ODT_TopAndBottom)
{
m_hover = false;
m_blockhover = false;
}
gLineOverlayBar::~gLineOverlayBar()
{
@ -26,9 +27,11 @@ QColor brighten(QColor color);
void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion &region)
{
m_hover = false;
if (!schema::channel[m_code].enabled())
return;
int left = region.boundingRect().left();
int topp = region.boundingRect().top(); // FIXME: Misspelling intentional.
int width = region.boundingRect().width();
@ -258,15 +261,19 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion &region)
} else {
QRect rect(x1-d1-2, topp, d1+6, height);
if (!m_blockhover && QRect(x1-d1-2, topp, d1+6, height).contains(mouse)) {
if (!m_hover) {
m_hover = true;
if (rect.contains(mouse)) {
painter.setPen(QPen(m_flag_color,4));
QString lab = QString("%1 (%2)").arg(schema::channel[m_code].label()).arg(raw);
GetTextExtent(lab, x, y);
w.renderText(lab, x1 - (x / 2)+2, start_py + 14 + y + (3 * w.printScaleY()),0);
x1-=1;
QString lab = QString("%1 (%2)").arg(schema::channel[m_code].label()).arg(raw);
GetTextExtent(lab, x, y);
painter.fillRect(x1 - (x / 2) - x, start_py + 14 + (3 * w.printScaleY()), x+4,y+4, QBrush(QColor(255,255,255,245)));
painter.setPen(QPen(Qt::gray,1));
painter.drawRect(x1 - (x / 2) - x, start_py + 14 + (3 * w.printScaleY()), x+4,y+4);
w.renderText(lab, x1 - (x / 2)+2 - x, start_py + 14 + y + (3 * w.printScaleY()),0);
x1-=1;
painter.setPen(QPen(m_flag_color,4));
}
} else {
painter.setPen(QPen(m_flag_color,1));
}

View File

@ -40,6 +40,9 @@ class gLineOverlayBar: public Layer
int count() { return m_count; }
double sum() { return m_sum; }
FlagType flagtype() { return m_flt; }
bool hover() { return m_hover; }
void setBlockHover(bool b) { m_blockhover = b; }
inline void setOverlayDisplayType(OverlayDisplayType odt) { m_odt = odt; }
inline OverlayDisplayType overlayDisplayType() { return m_odt; }
@ -53,6 +56,8 @@ class gLineOverlayBar: public Layer
OverlayDisplayType m_odt;
int m_count;
double m_sum;
bool m_hover;
bool m_blockhover;
};
/*! \class gLineOverlaySummary