Exemple #1
0
//----------------------------------------------------------------------
//
// paintCell
//
// overridden from base class in order to change color and style attributes
//
void SpawnListItem::paintCell( QPainter *p, const QColorGroup &cg,
                               int column, int width, int alignment )
{
    QColorGroup newCg( cg );

    newCg.setColor( QColorGroup::Text, m_textColor);

    QFont font = this->listView()->font();

    uint32_t filterFlags = 0;

    if (m_item != NULL)
        filterFlags = m_item->filterFlags();

    if (!(filterFlags & (FILTER_FLAG_FILTERED |
                         FILTER_FLAG_ALERT |
                         FILTER_FLAG_LOCATE |
                         FILTER_FLAG_CAUTION |
                         FILTER_FLAG_DANGER)))
    {
        font.setBold(false);
        font.setItalic(false);
        font.setUnderline(false);
    }
    else
    {
        // color filtered spawns grey
        if (filterFlags & FILTER_FLAG_FILTERED)
            newCg.setColor( QColorGroup::Text, Qt::gray);

        if (filterFlags & FILTER_FLAG_ALERT)
            font.setBold(true);
        else
            font.setBold(false);

        if (filterFlags & FILTER_FLAG_LOCATE)
            font.setItalic(true);
        else
            font.setItalic(false);

        if ((filterFlags & FILTER_FLAG_CAUTION) ||
                (filterFlags & FILTER_FLAG_DANGER))
            font.setUnderline(true);
        else
            font.setUnderline(false);
    }

    p->setFont(font);

    QListViewItem::paintCell( p, newCg, column, width, alignment );
}
// overridden from base class in order to change color and style attributes
void SpawnPointListItem::paintCell(QPainter* p, const QColorGroup& cg, 
				   int column, int width, int alignment )
{
#ifdef DEBUG
//      debug( "SpawnItem::paintCell()" );
#endif

  QColorGroup newCg( cg );
  QFont font = this->listView()->font();
  
  if (m_spawnPoint->age() > 220)
  {
    newCg.setColor(QColorGroup::Text, red);
    font.setBold(true);
  }
  else
    font.setBold(false);
  
  p->setFont(font);
  
  QListViewItem::paintCell(p, newCg, column, width, alignment);
}