void LogConfig::setCheck(QListViewItem *item) { int state = item->text(COL_CHECKED).isEmpty() ? CHECK_OFF : CHECK_ON; QColorGroup cg = palette().active(); #if QT_VERSION < 300 QSize s = style().indicatorSize(); QPixmap pixInd(s.width(), s.height()); QPainter pInd(&pixInd); style().drawIndicator(&pInd, 0, 0, s.width(), s.height(), cg, state); pInd.end(); QBitmap mInd(s.width(), s.height()); pInd.begin(&mInd); style().drawIndicatorMask(&pInd, 0, 0, s.width(), s.height(), state); pInd.end(); pixInd.setMask(mInd); #else int w = style().pixelMetric(QStyle::PM_IndicatorWidth); int h = style().pixelMetric(QStyle::PM_IndicatorHeight); QPixmap pixInd(w, h); QPainter pInd(&pixInd); QRect rc(0, 0, w, h); style().drawPrimitive(QStyle::PE_Indicator, &pInd, rc, cg, state); pInd.end(); QBitmap mInd(w, h); pInd.begin(&mInd); style().drawPrimitive(QStyle::PE_IndicatorMask, &pInd, rc, cg, state); pInd.end(); pixInd.setMask(mInd); #endif item->setPixmap(COL_CHECK, pixInd); }
int UserList::drawIndicator(QPainter *p, int x, QListViewItem *item, bool bState, const QColorGroup &cg) { int state = bState ? CHECK_ON : CHECK_OFF; #if QT_VERSION < 300 QSize s = style().indicatorSize(); QPixmap pixInd(s.width(), s.height()); QPainter pInd(&pixInd); style().drawIndicator(&pInd, 0, 0, s.width(), s.height(), cg, state); pInd.end(); QBitmap mInd(s.width(), s.height()); pInd.begin(&mInd); style().drawIndicatorMask(&pInd, 0, 0, s.width(), s.height(), state); pInd.end(); pixInd.setMask(mInd); p->drawPixmap(x, (item->height() - s.height()) / 2, pixInd); x += s.width() + 2; #else int w = style().pixelMetric(QStyle::PM_IndicatorWidth); int h = style().pixelMetric(QStyle::PM_IndicatorHeight); QRect rc(x, (item->height() - h) / 2, w, h); style().drawPrimitive(QStyle::PE_Indicator, p, rc, cg, state); x += w + 2; #endif return x; }