void SpellConfig::setCheck(QListViewItem *item) { int state = item->text(COL_CHECKED).isEmpty() ? CHECK_OFF : CHECK_ON; QColorGroup cg = palette().active(); #if COMPAT_QT_VERSION < 0x030000 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); pInd.setBrush(cg.background()); QRect rc(0, 0, w, h); pInd.eraseRect(rc); style().drawPrimitive(QStyle::PE_Indicator, &pInd, rc, cg, state); pInd.end(); #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; }
void xmlBranchLoad::DecodeStrips( ticpp::Element* pStrips , int i ) { //считать индексы int iNum = 0; //считать сколько полосок pStrips->GetAttribute( m_BranchNames.m_sNum , &iNum ); m_pData->m_vBranch[ i ].m_vvIndex.resize( iNum ); ticpp::Iterator< ticpp::Element > pStrip( m_BranchNames.m_sStrip ); int iNom = 0; //перебрать все полоски треугольников for ( pStrip = pStrip.begin( pStrips ); pStrip != pStrip.end(); pStrip++ ) { ticpp::Iterator< ticpp::Element > pInd( m_BranchNames.m_sInd ); for ( pInd = pInd.begin( &( *pStrip ) ); pInd != pInd.end(); pInd++ ) { int iVal = 0; pInd->GetAttribute( m_BranchNames.m_sVal , &iVal ); m_pData->m_vBranch[ i ].m_vvIndex[ iNom ].push_back( iVal ); } ++iNom; } }