void K3bListViewItem::paintCell( QPainter* p, const QColorGroup& cg, int col, int width, int align ) { ColumnInfo* info = getColumnInfo( col ); p->save(); QFont oldFont( p->font() ); QFont newFont = info->fontSet ? info->font : oldFont; p->setFont( newFont ); QColorGroup cgh(cg); if( info->foregroundColorSet ) cgh.setColor( QColorGroup::Text, info->foregroundColor ); if( info->backgroundColorSet ) cgh.setColor( QColorGroup::Base, info->backgroundColor ); // in case this is the selected row has a margin we need to repaint the selection bar if( isSelected() && (col == 0 || listView()->allColumnsShowFocus()) && info->margin > 0 ) { p->fillRect( 0, 0, info->margin, height(), cgh.brush( QColorGroup::Highlight ) ); p->fillRect( width-info->margin, 0, info->margin, height(), cgh.brush( QColorGroup::Highlight ) ); } else { // in case we use the KListView alternate color stuff p->fillRect( 0, 0, info->margin, height(), cgh.brush( QColorGroup::Base ) ); p->fillRect( width-info->margin, 0, info->margin, height(), cgh.brush( QColorGroup::Base ) ); } // FIXME: the margin (we can only translate horizontally since height() is used for painting) p->translate( info->margin, 0 ); if( info->showProgress ) { paintProgressBar( p, cgh, col, width-2*info->margin ); } else { paintK3bCell( p, cgh, col, width-2*info->margin, align ); } p->restore(); }
void CharSelectEnhanced::newFont(int font) { // tDebug("newFont start"); QString oldFont(m_fontInUse); m_fontInUse = fontSelector->itemText(font); if (!m_fontInUse.isEmpty()) { m_charTableModel->setFontInUse(m_fontInUse); (*m_doc->AllFonts)[m_fontInUse].increaseUsage(); if (!oldFont.isEmpty()) (*m_doc->AllFonts)[oldFont].decreaseUsage(); delEdit(); scanFont(); generatePreview(0); m_characterClass = 0; setupRangeCombo(); } // tDebug("newFont end"); }
void CharSelectEnhanced::setDoc(ScribusDoc* doc) { // tDebug("CharSelectEnhanced setDoc start"); if (m_doc != doc) { m_doc = doc; m_charTableModel->setDoc(m_doc); delEdit(); setupRangeCombo(); newCharClass(1); } QString oldFont(m_fontInUse); m_fontInUse = m_doc->currentStyle.charStyle().font().scName(); if (oldFont != m_fontInUse && !m_fontInUse.isEmpty()) { setCurrentComboItem(fontSelector, m_fontInUse); newFont(fontSelector->currentIndex()); } // tDebug("CharSelectEnhanced setDoc end"); }
void DiffView::paintCell(QPainter *p, int row, int col) { QFontMetrics fm(font()); DiffViewItem *item = items.at(row); int width = cellWidth(col); int height = cellHeight(); QColor backgroundColor; bool inverted; Qt::Alignment align; int innerborder; QString str; QFont oldFont(p->font()); if (item->type==Separator) { backgroundColor = KColorScheme(QPalette::Active, KColorScheme::Selection).background().color(); p->setPen(KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color()); inverted = false; align = Qt::AlignLeft; innerborder = 0; if (col == (linenos?1:0) + (marker?1:0)) str = item->line; QFont f(oldFont); f.setBold(true); p->setFont(f); } else if (col == 0 && linenos) { backgroundColor = KColorScheme(QPalette::Active, KColorScheme::Selection).background().color(); p->setPen(KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color()); inverted = false; align = Qt::AlignLeft; innerborder = 0; if (item->no == -1) str = "+++++"; else str.setNum(item->no); } else if (marker && (col == 0 || col == 1)) { backgroundColor = KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::AlternateBackground).color(); p->setPen(KColorScheme(QPalette::Active, KColorScheme::View).foreground().color()); inverted = false; align = Qt::AlignRight; innerborder = BORDER; str = (item->type==Change)? i18n("Change") : (item->type==Insert)? i18n("Insert") : (item->type==Delete)? i18n("Delete") : QString(); } else { backgroundColor = (item->type==Change)? diffChangeColor : (item->type==Insert)? diffInsertColor : (item->type==Delete)? diffDeleteColor : (item->type==Neutral)? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::AlternateBackground).color() : KColorScheme(QPalette::Active, KColorScheme::View).background().color(); p->setPen(KColorScheme(QPalette::Active, KColorScheme::View).foreground().color()); inverted = item->inverted; align = Qt::AlignLeft; innerborder = 0; str = item->line; } if (inverted) { p->setPen(backgroundColor); backgroundColor = KColorScheme(QPalette::Active, KColorScheme::View).foreground().color(); QFont f(oldFont); f.setBold(true); p->setFont(f); } p->fillRect(0, 0, width, height, backgroundColor); QTextOption textOption(align); textOption.setTabStop(m_tabWidth * fm.width(' ')); p->drawText(QRectF(innerborder, 0, width-2*innerborder, height), str, textOption); p->setFont(oldFont); }