Example #1
0
// Profiling note: About 30% of the time taken to initialize the
// listview is spent in this function. About 60% is spent in operator
// new and QListViewItem::QListViewItem.
void HeaderItem::irefresh()
{
  KMHeaders *headers = static_cast<KMHeaders*>(listView());
  NestingPolicy threadingPolicy = headers->getNestingPolicy();
  if ((threadingPolicy == AlwaysOpen) ||
      (threadingPolicy == DefaultOpen)) {
    //Avoid opening items as QListView is currently slow to do so.
    setOpen(true);
    return;

  }
  if (threadingPolicy == DefaultClosed)
    return; //default to closed

  // otherwise threadingPolicy == OpenUnread
  if (parent() && parent()->isOpen()) {
    setOpen(true);
    return;
  }

  KMMsgBase *mMsgBase = headers->folder()->getMsgBase( mMsgId );
  mSerNum = mMsgBase->getMsgSerNum();
  if (mMsgBase->isNew() || mMsgBase->isUnread()
      || mMsgBase->isImportant() || mMsgBase->isTodo() || mMsgBase->isWatched() ) {
    setOpen(true);
    HeaderItem * topOfThread = this;
    while(topOfThread->parent())
      topOfThread = (HeaderItem*)topOfThread->parent();
    topOfThread->setOpenRecursive(true);
  }
}
Example #2
0
void HeaderItem::paintCell( QPainter * p, const QColorGroup & cg,
    int column, int width, int align )
{
  KMHeaders *headers = static_cast<KMHeaders*>(listView());
  if (headers->noRepaint) return;
  if (!headers->folder()) return;
  KMMsgBase *mMsgBase = headers->folder()->getMsgBase( mMsgId );
  if (!mMsgBase) return;

  QColorGroup _cg( cg );
  QColor c = _cg.text();
  QColor *color = const_cast<QColor *>( &headers->paintInfo()->colFore );
  QFont font = p->font();
  int weight = font.weight();

  // for color and font family "important" overrides "new" overrides "unread"
  // overrides "todo" for the weight we use the maximal weight
  if ( mMsgBase->isTodo() ) {
    color = const_cast<QColor*>( &headers->paintInfo()->colTodo );
    font = headers->todoFont();
    weight = QMAX( weight, font.weight() );
  }
  if ( mMsgBase->isUnread() ) {
    color = const_cast<QColor*>( &headers->paintInfo()->colUnread );
    font = headers->unreadFont();
    weight = QMAX( weight, font.weight() );
  }
  if ( mMsgBase->isNew() ) {
    color = const_cast<QColor*>( &headers->paintInfo()->colNew );
    font = headers->newFont();
    weight = QMAX( weight, font.weight() );
  }

  if ( mMsgBase->isImportant() ) {
    color = const_cast<QColor*>( &headers->paintInfo()->colFlag );
    font = headers->importantFont();
    weight = QMAX( weight, font.weight() );
  }
  if ( column == headers->paintInfo()->dateCol ) {
    font = headers->dateFont();
  }

  QColor cdisabled = KGlobalSettings::inactiveTextColor();
  if ( headers->isMessageCut( msgSerNum() ) ) {
    font.setItalic( true );
    color = &cdisabled;
  }

  // set color and font
  _cg.setColor( QColorGroup::Text, *color );
  font.setWeight( weight );
  p->setFont( font );

  KListViewItem::paintCell( p, _cg, column, width, align );

  if (aboutToBeDeleted()) {
    // strike through
    p->drawLine( 0, height()/2, width, height()/2);
  }

  // reset color
  _cg.setColor( QColorGroup::Text, c );
}