Пример #1
0
void PlaylistProxyStyle::drawControl(ControlElement element,
                                     const QStyleOption* option,
                                     QPainter* painter,
                                     const QWidget* widget) const {
  if (element == CE_Header) {
    const QStyleOptionHeader* header_option =
        qstyleoption_cast<const QStyleOptionHeader*>(option);
    const QRect& rect = header_option->rect;
    const QString& text = header_option->text;
    const QFontMetrics& font_metrics = header_option->fontMetrics;

    // spaces added to make transition less abrupt
    if (rect.width() < font_metrics.width(text + "  ")) {
      const Playlist::Column column =
          static_cast<Playlist::Column>(header_option->section);
      QStyleOptionHeader new_option(*header_option);
      new_option.text = Playlist::abbreviated_column_name(column);
      QProxyStyle::drawControl(element, &new_option, painter, widget);
      return;
    }
  }

  if (element == CE_ItemViewItem)
    cleanlooks_->drawControl(element, option, painter, widget);
  else
    QProxyStyle::drawControl(element, option, painter, widget);
}
Пример #2
0
void Layer_list_delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
	QStyleOptionViewItem new_option(option);
	if (index.isValid()) {
		QVariant value = index.data(Qt::UserRole);
		QVariant checked = index.data(33);
		if (checked.toInt() == 0) new_option.palette.setColor(QPalette::Text, Qt::darkGray);
		if (value.isValid()) {
			QBrush brush(qvariant_cast<QBrush>(value));
			if (brush!=QBrush()) new_option.palette.setBrush(QPalette::LinkVisited, brush); //misused LinkVisited brush for checkbox background
		}
	}
	QItemDelegate::paint(painter, new_option, index);
}