// 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); } }
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 ); }
const QPixmap *HeaderItem::pixmap(int col) const { KMHeaders *headers = static_cast<KMHeaders*>(listView()); KMMsgBase *msgBase = headers->folder()->getMsgBase( mMsgId ); if ( col == headers->paintInfo()->subCol ) { PixmapList pixmaps; if ( !headers->mPaintInfo.showSpamHam ) { // Have the spam/ham and watched/ignored icons first, I guess. if ( msgBase->isSpam() ) pixmaps << *KMHeaders::pixSpam; if ( msgBase->isHam() ) pixmaps << *KMHeaders::pixHam; } if ( !headers->mPaintInfo.showWatchedIgnored ) { if ( msgBase->isIgnored() ) pixmaps << *KMHeaders::pixIgnored; if ( msgBase->isWatched() ) pixmaps << *KMHeaders::pixWatched; } if ( !headers->mPaintInfo.showStatus ) { const QPixmap *pix = statusIcon(msgBase); if ( pix ) pixmaps << *pix; } // Only merge the attachment icon in if that is configured. if ( headers->paintInfo()->showAttachmentIcon && !headers->paintInfo()->showAttachment && msgBase->attachmentState() == KMMsgHasAttachment ) pixmaps << *KMHeaders::pixAttachment; // Only merge the crypto icons in if that is configured. if ( headers->paintInfo()->showCryptoIcons ) { const QPixmap *pix; if ( !headers->paintInfo()->showCrypto ) if ( (pix = cryptoIcon(msgBase)) ) pixmaps << *pix; if ( !headers->paintInfo()->showSigned ) if ( (pix = signatureIcon(msgBase)) ) pixmaps << *pix; } if ( !headers->mPaintInfo.showImportant ) if ( msgBase->isImportant() ) pixmaps << *KMHeaders::pixFlag; if ( !headers->mPaintInfo.showTodo ) if ( msgBase->isTodo() ) pixmaps << *KMHeaders::pixTodo; static QPixmap mergedpix; mergedpix = pixmapMerge( pixmaps ); return &mergedpix; } else if ( col == headers->paintInfo()->statusCol ) { return statusIcon(msgBase); } else if ( col == headers->paintInfo()->attachmentCol ) { if ( msgBase->attachmentState() == KMMsgHasAttachment ) return KMHeaders::pixAttachment; } else if ( col == headers->paintInfo()->importantCol ) { if ( msgBase->isImportant() ) return KMHeaders::pixFlag; } else if ( col == headers->paintInfo()->todoCol ) { if ( msgBase->isTodo() ) return KMHeaders::pixTodo; } else if ( col == headers->paintInfo()->spamHamCol ) { if ( msgBase->isSpam() ) return KMHeaders::pixSpam; if ( msgBase->isHam() ) return KMHeaders::pixHam; } else if ( col == headers->paintInfo()->watchedIgnoredCol ) { if ( msgBase->isWatched() ) return KMHeaders::pixWatched; if ( msgBase->isIgnored() ) return KMHeaders::pixIgnored; } else if ( col == headers->paintInfo()->signedCol ) { return signatureIcon(msgBase); } else if ( col == headers->paintInfo()->cryptoCol ) { return cryptoIcon(msgBase); } return 0; }