Document::~Document() { m_bDeleted = true; ViewList viewsToDelete = m_viewList; const ViewList::iterator end = viewsToDelete.end(); for ( ViewList::iterator it = viewsToDelete.begin(); it != end; ++it ) (*it)->deleteLater(); }
void Canvas::drawForeground(QPainter &p, const QRect & clip) { QCanvas::drawForeground(p, clip); if (!m_pMessageTimeout->isActive()) return; // Following code stolen and adapted from amarok/src/playlist.cpp :) // Find out width of smallest view QSize minSize; const ViewList viewList = p_itemDocument->viewList(); ViewList::const_iterator end = viewList.end(); View *firstView = 0; for (ViewList::const_iterator it = viewList.begin(); it != end; ++it) { if (!*it) continue; if (!firstView) { firstView = *it; minSize = (*it)->size(); } else minSize = minSize.boundedTo((*it)->size()); } if (!firstView) return; QSimpleRichText *t = new QSimpleRichText(m_message, QApplication::font()); const int w = t->width(); const int h = t->height(); const int x = rect().left() + 15; const int y = rect().top() + 15; const int b = 10; // text padding if (w + 2 * b >= minSize.width() || h + 2 * b >= minSize.height()) { delete t; return; } p.setBrush(firstView->colorGroup().background()); p.drawRoundRect(x, y, w + 2 * b, h + 2 * b, (8 * 200) / (w + 2 * b), (8 * 200) / (h + 2 * b)); t->draw(&p, x + b, y + b, QRect(), firstView->colorGroup()); delete t; }