rpms/kdepim/F-10 kmail-fonts-4.3.patch, NONE, 1.1 kdepim.spec, 1.215, 1.216
Rex Dieter
rdieter at fedoraproject.org
Thu Aug 20 14:33:25 UTC 2009
Author: rdieter
Update of /cvs/pkgs/rpms/kdepim/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv25537
Modified Files:
kdepim.spec
Added Files:
kmail-fonts-4.3.patch
Log Message:
* Tue Aug 18 2009 Rex Dieter <rdieter at fedoraproject.org> - 4.3.0-4
- kmail: upstream fix for custom font settings (#kdebug#178402)
kmail-fonts-4.3.patch:
core/delegate.cpp | 2
core/messageitem.h | 14 ++
core/model.cpp | 24 -----
core/theme.cpp | 49 ----------
core/theme.h | 107 ----------------------
core/themedelegate.cpp | 211 ++++++++++++++++++++------------------------
core/themedelegate.h | 10 +-
core/themeeditor.cpp | 6 -
core/themeeditor.h | 2
storagemodel.cpp | 232 +++++++++++++++++++++----------------------------
storagemodel.h | 15 ++-
11 files changed, 241 insertions(+), 431 deletions(-)
--- NEW FILE kmail-fonts-4.3.patch ---
Index: kmail/messagelistview/storagemodel.cpp
===================================================================
--- kmail/messagelistview/storagemodel.cpp (revision 1011070)
+++ kmail/messagelistview/storagemodel.cpp (revision 1011071)
@@ -154,6 +154,21 @@
mColorToDoMessage = config.readEntry( "TodoMessage", mColorToDoMessage );
}
+ if ( GlobalSettings::self()->useDefaultFonts() )
+ {
+ mFont = mFontImportantMessage = mFontNewMessage = mFontUnreadMessage =
+ mFontToDoMessage = KGlobalSettings::generalFont();
+ }
+ else
+ {
+ KConfigGroup fonts( KMKernel::config(), "Fonts" );
+ mFont = fonts.readEntry( "list-font", KGlobalSettings::generalFont() );
+
+ mFontImportantMessage = fonts.readEntry( "list-important-font", mFont );
+ mFontNewMessage = fonts.readEntry( "list-new-font", mFont );
+ mFontUnreadMessage = fonts.readEntry( "list-unread-font", mFont );
+ mFontToDoMessage = fonts.readEntry( "list-toact-font", mFont );
+ }
}
StorageModel::~StorageModel()
@@ -290,46 +305,15 @@
return mFolder->whoField().toLower() == "to";
}
-bool StorageModel::initializeMessageItem( Core::MessageItem * mi, int row, bool bUseReceiver ) const
+/**
+ * Uses the KMMsgBase to fill a list of tags. It also picks out
+ * the colors the message should use.
+ */
+QList< Core::MessageItem::Tag * > * fillTagList( KMMsgBase * msg,
+ QColor & textColor, QColor & backgroundColor )
{
- KMMsgBase * msg = mFolder->getMsgBase( row );
- if ( !msg )
- return false;
-
- QString sender = msg->fromStrip();
- QString receiver = msg->toStrip();
-
- // Static for speed reasons
- static const QString noSubject = i18nc( "displayed as subject when the subject of a mail is empty", "No Subject" );
- static const QString unknown( i18nc( "displayed when a mail has unknown sender, receiver or date", "Unknown" ) );
-
- if ( sender.isEmpty() )
- sender = unknown;
- if ( receiver.isEmpty() )
- receiver = unknown;
-
- mi->initialSetup(
- msg->date(),
- mFolder->folderType() == KMFolderTypeImap ? msg->msgSizeServer() : msg->msgSize(),
- sender, receiver,
- bUseReceiver ? receiver : sender
- );
-
- mi->setUniqueId( msg->getMsgSerNum() );
-
- KPIM::MessageStatus stat = msg->messageStatus();
-
- QString subject = msg->subject();
- if ( subject.isEmpty() )
- subject = '(' + noSubject + ')';
- mi->setSubjectAndStatus(
- subject,
- stat
- );
-
- QColor clr;
-
// FIXME: Tags should be sorted by priority!
+ QList< Core::MessageItem::Tag * > * tagList = 0;
if ( msg->tagList() )
{
@@ -337,15 +321,16 @@
{
int bestPriority = -0xfffff;
- QList< Core::MessageItem::Tag * > * tagList = new QList< Core::MessageItem::Tag * >();
+ tagList = new QList< Core::MessageItem::Tag * >();
for ( KMMessageTagList::Iterator it = msg->tagList()->begin(); it != msg->tagList()->end(); ++it )
{
const KMMessageTagDescription * description = kmkernel->msgTagMgr()->find( *it );
if ( description )
{
- if ( ( bestPriority < description->priority() ) || ( !clr.isValid() ) )
+ if ( ( bestPriority < description->priority() ) || ( !textColor.isValid() ) )
{
- clr = description->textColor();
+ textColor = description->textColor();
+ backgroundColor = description->backgroundColor();
bestPriority = description->priority();
}
@@ -358,14 +343,18 @@
}
}
if ( tagList->isEmpty() )
+ {
delete tagList;
- else
- mi->setTagList( tagList );
+ tagList = 0;
+ }
}
}
+ return tagList;
+}
-
+static void setMessageItemEncryptionState( Core::MessageItem * mi, KMMsgBase * msg )
+{
switch ( msg->encryptionState() )
{
case KMMsgFullyEncrypted:
@@ -375,13 +364,17 @@
mi->setEncryptionState( Core::MessageItem::PartiallyEncrypted );
break;
case KMMsgEncryptionStateUnknown:
+ case KMMsgEncryptionProblematic:
mi->setEncryptionState( Core::MessageItem::EncryptionStateUnknown );
break;
default:
mi->setEncryptionState( Core::MessageItem::NotEncrypted );
break;
}
+}
+static void setMessageItemSignatureState( Core::MessageItem * mi, KMMsgBase * msg )
+{
switch ( msg->signatureState() )
{
case KMMsgFullySigned:
@@ -391,28 +384,51 @@
mi->setSignatureState( Core::MessageItem::PartiallySigned );
break;
case KMMsgSignatureStateUnknown:
+ case KMMsgSignatureProblematic:
mi->setSignatureState( Core::MessageItem::SignatureStateUnknown );
break;
default:
mi->setSignatureState( Core::MessageItem::NotSigned );
break;
}
+}
- if ( !clr.isValid() )
- {
- if ( stat.isNew() )
- clr = mColorNewMessage;
- else if ( stat.isUnread() )
- clr = mColorUnreadMessage;
- else if ( stat.isImportant() )
- clr = mColorImportantMessage;
- else if ( stat.isToAct() )
- clr = mColorToDoMessage;
- }
+bool StorageModel::initializeMessageItem( Core::MessageItem * mi, int row, bool bUseReceiver ) const
+{
+ KMMsgBase * msg = mFolder->getMsgBase( row );
+ if ( !msg )
+ return false;
- if ( clr.isValid() )
- mi->setTextColor( clr );
+ QString sender = msg->fromStrip();
+ QString receiver = msg->toStrip();
+ // Static for speed reasons
+ static const QString noSubject = i18nc( "displayed as subject when the subject of a mail is empty", "No Subject" );
+ static const QString unknown( i18nc( "displayed when a mail has unknown sender, receiver or date", "Unknown" ) );
+
+ if ( sender.isEmpty() )
+ sender = unknown;
+ if ( receiver.isEmpty() )
+ receiver = unknown;
+
+ mi->initialSetup(
+ msg->date(),
+ mFolder->folderType() == KMFolderTypeImap ? msg->msgSizeServer() : msg->msgSize(),
+ sender, receiver,
+ bUseReceiver ? receiver : sender
+ );
+
+ mi->setUniqueId( msg->getMsgSerNum() );
+
+ KPIM::MessageStatus stat = msg->messageStatus();
+
+ QString subject = msg->subject();
+ if ( subject.isEmpty() )
+ subject = '(' + noSubject + ')';
+ mi->setSubjectAndStatus( subject, stat );
+
+ setMessageItemData( mi, msg );
+
return true;
}
@@ -429,99 +445,53 @@
mi->recomputeMaxDate();
}
- QColor clr;
-
KPIM::MessageStatus stat = msg->messageStatus();
mi->setStatus( stat );
- switch ( msg->encryptionState() )
- {
- case KMMsgFullyEncrypted:
- mi->setEncryptionState( Core::MessageItem::FullyEncrypted );
- break;
- case KMMsgPartiallyEncrypted:
- mi->setEncryptionState( Core::MessageItem::PartiallyEncrypted );
- break;
- case KMMsgEncryptionStateUnknown:
- case KMMsgEncryptionProblematic:
- mi->setEncryptionState( Core::MessageItem::EncryptionStateUnknown );
- break;
- default:
- mi->setEncryptionState( Core::MessageItem::NotEncrypted );
- break;
- }
+ setMessageItemData( mi, msg );
+}
- switch ( msg->signatureState() )
- {
- case KMMsgFullySigned:
- mi->setSignatureState( Core::MessageItem::FullySigned );
- break;
- case KMMsgPartiallySigned:
- mi->setSignatureState( Core::MessageItem::PartiallySigned );
- break;
- case KMMsgSignatureStateUnknown:
- case KMMsgSignatureProblematic:
- mi->setSignatureState( Core::MessageItem::SignatureStateUnknown );
- break;
- default:
- mi->setSignatureState( Core::MessageItem::NotSigned );
- break;
- }
+void StorageModel::setMessageItemData( Core::MessageItem * mi, KMMsgBase * msg ) const
+{
+ setMessageItemEncryptionState( mi, msg );
+ setMessageItemSignatureState( mi, msg );
- QList< Core::MessageItem::Tag * > * tagList = 0;
-
- if ( msg->tagList() )
- {
- if ( !msg->tagList()->isEmpty() )
- {
- int bestPriority = -0xfffff;
-
- tagList = new QList< Core::MessageItem::Tag * >();
- for ( KMMessageTagList::Iterator it = msg->tagList()->begin(); it != msg->tagList()->end(); ++it )
- {
- const KMMessageTagDescription * description = kmkernel->msgTagMgr()->find( *it );
- if ( description )
- {
- if ( ( bestPriority < description->priority() ) || ( !clr.isValid() ) )
- {
- clr = description->textColor();
- bestPriority = description->priority();
- }
-
- Core::MessageItem::Tag * tag;
- if ( description->toolbarIconName().isEmpty() )
- tag = new Core::MessageItem::Tag( SmallIcon( "feed-subscribe" ), description->name(), *it );
- else
- tag = new Core::MessageItem::Tag( SmallIcon( description->toolbarIconName() ), description->name(), *it );
- tagList->append( tag );
- }
- }
- if ( tagList->isEmpty() )
- {
- delete tagList;
- tagList = 0;
- }
- }
- }
-
+ QColor clr;
+ QColor backClr;
+ QList< Core::MessageItem::Tag * > * tagList;
+ tagList = fillTagList( msg, clr, backClr );
mi->setTagList( tagList );
+ KPIM::MessageStatus stat = msg->messageStatus();
+
if ( !clr.isValid() )
{
- if ( stat.isNew() )
+ // from KDE3: "important" overrides "new" overrides "unread" overrides "todo"
+ if ( stat.isImportant() )
+ clr = mColorImportantMessage;
+ else if ( stat.isNew() )
clr = mColorNewMessage;
else if ( stat.isUnread() )
clr = mColorUnreadMessage;
- else if ( stat.isImportant() )
- clr = mColorImportantMessage;
else if ( stat.isToAct() )
clr = mColorToDoMessage;
}
mi->setTextColor( clr ); // set even if invalid (->default color)
+ mi->setBackgroundColor( backClr );
- // FIXME: Handle MDN State ?
+ // from KDE3: "important" overrides "new" overrides "unread" overrides "todo"
+ if ( stat.isImportant() )
+ mi->setFont( mFontImportantMessage );
+ else if ( stat.isNew() )
+ mi->setFont( mFontNewMessage );
+ else if ( stat.isUnread() )
+ mi->setFont( mFontUnreadMessage );
+ else if ( stat.isToAct() )
+ mi->setFont( mFontToDoMessage );
+ else
+ mi->setFont( mFont );
}
void StorageModel::fillMessageItemThreadingData( Core::MessageItem * mi, int row, ThreadingDataSubset subset ) const
Index: kmail/messagelistview/core/model.cpp
===================================================================
--- kmail/messagelistview/core/model.cpp (revision 1011070)
+++ kmail/messagelistview/core/model.cpp (revision 1011071)
@@ -3237,8 +3237,6 @@
// The end index of our work.
int endIndex = job->endIndex();
- bool viewportNeedsUpdate = false;
-
while( curIndex <= endIndex )
{
// Get the underlying storage message data...
@@ -3269,6 +3267,8 @@
// Do update
mStorageModel->updateMessageItemData( message, row );
+ QModelIndex idx = index( message, 0 );
+ emit dataChanged( idx, idx );
// Reinsert the item to the cache, if needed
if( mAggregation->threading() == Aggregation::PerfectReferencesAndSubject )
@@ -3289,22 +3289,6 @@
if ( propertyChangeMask )
{
// Some message data has changed
- // We could emit dataChanged() so the viewport would be updated...
- // but this is AGAIN a huge performance cost. Since we don't actually
- // use the standard painting code nothing will screw up if we don't
- // emit this signal (I hope.. :D). We just set a flag that will cause
- // us to update the viewport on exit instead.
- //
- // ... hm.. now that I think of it.. what the heck is the meaning of
- // topLeft and bottomRight parameters of dataChanged() in a tree ?
- // I guess that it should be always topLeft == bottomRight == itemIndex...
- // But anyway, the view jumps like crazy when this signal is emitted.
-
- // QModelIndex idx = index( message, 0 );
- // emit dataChanged( idx, idx );
-
- viewportNeedsUpdate = true;
-
// now we need to handle the changes that might cause re-grouping/re-sorting
// and propagate them to the parents.
@@ -3374,16 +3358,12 @@
if ( curIndex <= endIndex )
{
job->setCurrentIndex( curIndex );
- if ( viewportNeedsUpdate )
- mView->viewport()->update();
return ViewItemJobInterrupted;
}
}
}
}
- if ( viewportNeedsUpdate )
- mView->viewport()->update();
return ViewItemJobCompleted;
}
Index: kmail/messagelistview/core/theme.h
===================================================================
--- kmail/messagelistview/core/theme.h (revision 1011070)
+++ kmail/messagelistview/core/theme.h (revision 1011071)
@@ -237,10 +237,6 @@
QFont mFont; ///< The font to use with this content item, meaningful only if displaysText() returns true.
QColor mCustomColor; ///< The color to use with this content item, meaningful only if canUseCustomColor() return true.
- // Cache stuff
- QPaintDevice * mLastPaintDevice; ///< The last paint device that used this content item (this is usually set only once)
- QFontMetrics mFontMetrics; ///< Our font metrics cache (kept updated to the last QPaintDevice that uses this ContentItem)
- int mLineSpacing; ///< The line spacing in mFontMetrics, this is a value we use a lot (so by caching it we can avoid a function call)
public:
/**
@@ -437,46 +433,6 @@
// so for portability we're using a public interface also here.
/**
- * The last QPaintDevice that made use of this item.
- * This function is used by ThemeDelegate for QFontMetrics caching purposes.
- */
- const QPaintDevice * lastPaintDevice() const
- { return mLastPaintDevice; };
-
- /**
- * Updates the font metrics cache for this item by recreating them
- * for the currently set font and the specified QPaintDevice.
- * This function will also reset the font to the KGlobalSettings::generalFont()
- * if you haven't called setUseCustomFont().
- * This function is used by ThemeDelegate, you usually don't need to care.
- */
- void updateFontMetrics( QPaintDevice * device );
-
- /**
- * Returns the cached font metrics attacched to this content item.
- * The font metrics must be kept up-to-date by the means of the updateFontMetrics()
- * function whenever the QPaintDevice that this ContentItem is painted
- * on is different than lastPaintDevice(). This is done by ThemeDelegate
- * and in fact you shouldn't care.
- */
- const QFontMetrics & fontMetrics() const
- { return mFontMetrics; };
-
- /**
- * Returns the cached font metrics line spacing for this content item.
- * The line spacing is used really often in ThemeDelegate so this
- * inlineable getter will help the compiler in optimizing stuff.
- */
- int lineSpacing() const
- { return mLineSpacing; };
-
- /**
- * Resets the cache of this content item.
- * This is called by the Theme::Row resetCache() method.
- */
- void resetCache();
-
- /**
* Handles content item saving (used by Theme::Row::save())
*/
void save( QDataStream &stream ) const;
@@ -502,7 +458,6 @@
private:
QList< ContentItem * > mLeftItems; ///< The list of left aligned items
QList< ContentItem * > mRightItems; ///< The list of right aligned items
- QSize mSizeHint; ///< The size hint for this row: the height is the sufficient minimum, the width is a guess, invalid size when not computed
public:
/**
@@ -569,19 +524,6 @@
{ mRightItems.removeAll( item ); };
/**
- * Returns the cached size hint for this row. The returned size is invalid
- * if no cached size hint has been set yet.
- */
- QSize sizeHint() const
- { return mSizeHint; };
-
- /**
- * Sets the cached size hint for this row.
- */
- void setSizeHint( const QSize &s )
- { mSizeHint = s; };
-
- /**
* Returns true if this row contains text items.
* This is useful if you want to know if the column should just get
* its minimum allowable space or it should get more.
@@ -589,11 +531,6 @@
bool containsTextItems() const;
/**
- * Called from the Column's resetCache() method. You shouldn't need to care.
- */
- void resetCache();
-
- /**
* Handles row saving (used by Theme::Column::save())
*/
void save( QDataStream &stream ) const;
@@ -712,9 +649,7 @@
SortOrder::MessageSorting mMessageSorting; ///< The message sort order we switch to when clicking on this column
QList< Row * > mGroupHeaderRows; ///< The list of rows we display in this column for a GroupHeaderItem
QList< Row * > mMessageRows; ///< The list of rows we display in this column for a MessageItem
- // cache
- QSize mGroupHeaderSizeHint; ///< The cached size hint for group header rows: invalid if not computed yet
- QSize mMessageSizeHint; ///< The cached size hint for message rows: invalid if not computed yet
+
SharedRuntimeData * mSharedRuntimeData; ///< A pointer to the shared runtime data: shared between all instances of a theme with the same id
public:
/**
@@ -872,38 +807,6 @@
bool containsTextItems() const;
/**
- * This is called by the Theme when it's resetCache() method is called.
- * You shouldn't need to care about this.
- */
- void resetCache();
-
- /**
- * Returns the cached size hint for group header rows in this column
- * or an invalid QSize if the cached size hint hasn't been set yet.
- */
- QSize groupHeaderSizeHint() const
- { return mGroupHeaderSizeHint; };
-
- /**
- * Sets the cached size hint for group header rows in this column.
- */
- void setGroupHeaderSizeHint( const QSize &sh )
- { mGroupHeaderSizeHint = sh; };
-
- /**
- * Returns the cached size hint for message rows in this column
- * or an invalid QSize if the cached size hint hasn't been set yet.
- */
- QSize messageSizeHint() const
- { return mMessageSizeHint; };
-
- /**
- * Sets the cached size hint for message rows in this column.
- */
- void setMessageSizeHint( const QSize &sh )
- { mMessageSizeHint = sh; };
-
- /**
* Handles column saving (used by Theme::save())
*/
void save( QDataStream &stream ) const;
@@ -1113,14 +1016,6 @@
*/
static QList< QPair< QString, int > > enumerateViewHeaderPolicyOptions();
- /**
- * Resets the cache for this theme. This is called by the ThemeDelegate
- * when the theme is applied and must be called before any changes to this
- * theme are going to be painted (that is, apply a chunk of changes, call
- * resetCache() then repaint.
- */
- void resetCache();
-
protected:
/**
* Pure virtual reimplemented from OptionSet.
Index: kmail/messagelistview/core/messageitem.h
===================================================================
--- kmail/messagelistview/core/messageitem.h (revision 1011070)
+++ kmail/messagelistview/core/messageitem.h (revision 1011071)
@@ -101,6 +101,8 @@
SignatureState mSignatureState;
QList< Tag * > * mTagList; ///< Usually 0....
QColor mTextColor; ///< If invalid, use default text color
+ QColor mBackgroundColor; ///< If invalid, use default background color
+ QFont mFont;
unsigned long mUniqueId; ///< The unique id of this message (serial number of KMMsgBase at the moment of writing)
bool mAboutToBeRemoved; ///< Set to true when this item is going to be deleted and shouldn't be selectable
@@ -130,9 +132,21 @@
const QColor & textColor() const
{ return mTextColor; };
+ const QColor & backgroundColor() const
+ { return mBackgroundColor; };
+
+ const QFont &font() const
+ { return mFont; }
+
void setTextColor( const QColor &clr )
{ mTextColor = clr; };
+ void setBackgroundColor( const QColor &clr )
+ { mBackgroundColor = clr; };
+
+ void setFont( const QFont &f )
+ { mFont = f; }
+
SignatureState signatureState() const
{ return mSignatureState; };
Index: kmail/messagelistview/core/themeeditor.cpp
===================================================================
--- kmail/messagelistview/core/themeeditor.cpp (revision 1011070)
+++ kmail/messagelistview/core/themeeditor.cpp (revision 1011071)
@@ -189,8 +189,8 @@
drag->exec( Qt::CopyAction, Qt::CopyAction );
}
-ThemePreviewDelegate::ThemePreviewDelegate( QAbstractItemView * parent, QPaintDevice * paintDevice )
- : ThemeDelegate( parent, paintDevice )
+ThemePreviewDelegate::ThemePreviewDelegate( QAbstractItemView * parent )
+ : ThemeDelegate( parent )
{
mRowMapper = new ModelInvariantRowMapper();
@@ -263,7 +263,7 @@
mSelectedThemeColumn = 0;
mFirstShow = true;
- mDelegate = new ThemePreviewDelegate( this, viewport() );
+ mDelegate = new ThemePreviewDelegate( this );
setItemDelegate( mDelegate );
setRootIsDecorated( false );
viewport()->setAcceptDrops( true );
Index: kmail/messagelistview/core/delegate.cpp
===================================================================
--- kmail/messagelistview/core/delegate.cpp (revision 1011070)
+++ kmail/messagelistview/core/delegate.cpp (revision 1011071)
@@ -34,7 +34,7 @@
{
Delegate::Delegate( View *pParent )
- : ThemeDelegate( pParent, pParent->viewport() )
+ : ThemeDelegate( pParent )
{
}
Index: kmail/messagelistview/core/themedelegate.h
===================================================================
--- kmail/messagelistview/core/themedelegate.h (revision 1011070)
+++ kmail/messagelistview/core/themedelegate.h (revision 1011071)
@@ -29,7 +29,6 @@
#include "messagelistview/core/item.h"
class QAbstractItemView;
-class QPaintDevice;
namespace KMail
{
@@ -49,13 +48,12 @@
class ThemeDelegate : public QStyledItemDelegate
{
public:
- ThemeDelegate( QAbstractItemView * parent, QPaintDevice * paintDevice );
+ ThemeDelegate( QAbstractItemView * parent );
~ThemeDelegate();
private:
const Theme * mTheme; ///< Shallow pointer to the current theme
QAbstractItemView * mItemView;
- QPaintDevice * mPaintDevice;
QColor mGroupHeaderBackgroundColor; // cache
@@ -71,6 +69,7 @@
bool mHitContentItemRight;
const Theme::ContentItem * mHitContentItem;
QRect mHitContentItemRect;
+
public:
const Theme * theme() const
{ return mTheme; };
@@ -80,7 +79,7 @@
* Returns a heuristic sizeHint() for the specified item type and column.
* The hint is based on the contents of the theme (and not of any message or group header).
*/
- QSize sizeHintForItemTypeAndColumn( Item::Type type, int column ) const;
+ QSize sizeHintForItemTypeAndColumn( Item::Type type, int column, const Item *item = 0) const;
/**
* Performs a hit test on the specified viewport point.
@@ -195,6 +194,9 @@
QRect hitContentItemRect() const
{ return mHitContentItemRect; };
+ /// return the font to paint given item with, checking global kmail settings and theme settings
+ static QFont itemFont( const Theme::ContentItem *ci, const Item *item );
+
protected:
/**
* Returns the Item for the specified model index. Pure virtual: must be reimplemented
Index: kmail/messagelistview/core/theme.cpp
===================================================================
--- kmail/messagelistview/core/theme.cpp (revision 1011070)
+++ kmail/messagelistview/core/theme.cpp (revision 1011071)
@@ -62,7 +62,7 @@
Theme::ContentItem::ContentItem( Type type )
- : mType( type ), mFlags( 0 ), mLastPaintDevice( 0 ), mFontMetrics( QFont() )
+ : mType( type ), mFlags( 0 )
{
}
@@ -70,10 +70,7 @@
: mType( src.mType ),
mFlags( src.mFlags ),
mFont( src.mFont ),
- mCustomColor( src.mCustomColor ),
- mLastPaintDevice( src.mLastPaintDevice ),
- mFontMetrics( src.mFontMetrics ),
- mLineSpacing( src.mLineSpacing )
+ mCustomColor( src.mCustomColor )
{
}
@@ -164,27 +161,11 @@
return ( static_cast< int >( type ) & ApplicableToGroupHeaderItems );
}
-
-void Theme::ContentItem::updateFontMetrics( QPaintDevice * device )
-{
- if ( !( mFlags & UseCustomFont ) )
- mFont = KGlobalSettings::generalFont();
- mLastPaintDevice = device;
- mFontMetrics = QFontMetrics( mFont, device );
- mLineSpacing = mFontMetrics.lineSpacing();
-}
-
void Theme::ContentItem::setFont( const QFont &font )
{
mFont = font;
- mLastPaintDevice = 0; // will force regeneration of font metrics
}
-void Theme::ContentItem::resetCache()
-{
- mLastPaintDevice = 0; // will force regeneration of font metrics
-}
-
void Theme::ContentItem::save( QDataStream &stream ) const
{
stream << (int)mType;
@@ -296,15 +277,6 @@
mRightItems.insert( idx, item );
}
-void Theme::Row::resetCache()
-{
- mSizeHint = QSize();
- for ( QList< ContentItem * >::ConstIterator it = mLeftItems.constBegin(); it != mLeftItems.constEnd() ; ++it )
- ( *it )->resetCache();
- for ( QList< ContentItem * >::ConstIterator it = mRightItems.constBegin(); it != mRightItems.constEnd() ; ++it )
- ( *it )->resetCache();
-}
-
bool Theme::Row::containsTextItems() const
{
for ( QList< ContentItem * >::ConstIterator it = mLeftItems.constBegin(); it != mLeftItems.constEnd() ; ++it )
@@ -508,17 +480,6 @@
mGroupHeaderRows.insert( idx, row );
}
-void Theme::Column::resetCache()
-{
- mGroupHeaderSizeHint = QSize();
- mMessageSizeHint = QSize();
-
- for ( QList< Row * >::ConstIterator it = mMessageRows.constBegin(); it != mMessageRows.constEnd() ; ++it )
- ( *it )->resetCache();
- for ( QList< Row * >::ConstIterator it = mGroupHeaderRows.constBegin(); it != mGroupHeaderRows.constEnd() ; ++it )
- ( *it )->resetCache();
-}
-
bool Theme::Column::containsTextItems() const
{
for ( QList< Row * >::ConstIterator it = mMessageRows.constBegin(); it != mMessageRows.constEnd() ; ++it )
@@ -769,12 +730,6 @@
mIconSize = gThemeDefaultIconSize;
}
-void Theme::resetCache()
-{
- for ( QList< Column * >::ConstIterator it = mColumns.constBegin(); it != mColumns.constEnd() ; ++it )
- ( *it )->resetCache();
-}
-
bool Theme::load( QDataStream &stream )
{
removeAllColumns();
Index: kmail/messagelistview/core/themeeditor.h
===================================================================
--- kmail/messagelistview/core/themeeditor.h (revision 1011070)
+++ kmail/messagelistview/core/themeeditor.h (revision 1011071)
@@ -73,7 +73,7 @@
{
Q_OBJECT
public:
- ThemePreviewDelegate( QAbstractItemView * parent, QPaintDevice * paintDevice );
+ ThemePreviewDelegate( QAbstractItemView * parent );
~ThemePreviewDelegate();
private:
Index: kmail/messagelistview/core/themedelegate.cpp
===================================================================
--- kmail/messagelistview/core/themedelegate.cpp (revision 1011070)
+++ kmail/messagelistview/core/themedelegate.cpp (revision 1011071)
@@ -31,6 +31,7 @@
#include <QPixmap>
#include <QLinearGradient>
#include <KColorScheme>
+#include <KGlobalSettings>
namespace KMail
{
@@ -50,11 +51,10 @@
static const int gHorizontalItemSpacing = 2;
-ThemeDelegate::ThemeDelegate( QAbstractItemView * parent, QPaintDevice * paintDevice )
+ThemeDelegate::ThemeDelegate( QAbstractItemView * parent )
: QStyledItemDelegate( parent )
{
mItemView = parent;
- mPaintDevice = paintDevice;
mTheme = 0;
}
@@ -69,12 +69,6 @@
if ( !mTheme )
return; // hum
- // yep..we're violating const here
- // But most of the QStyledItemDelegate virtual methods are const and expect
- // const behaviour. So we need the const pointer to avoid compiler complains
- // but on the other side we're NOT really const... well...
- const_cast< Theme * >( mTheme )->resetCache();
-
// Rebuild the group header background color cache
switch( mTheme->groupHeaderBackgroundMode() )
{
@@ -104,14 +98,13 @@
// about function growth limit reached. Consider using macros
// or just convert to member functions.
-static inline void paint_right_aligned_elided_text( const QString &text, QPaintDevice * pd, Theme::ContentItem * ci, QPainter * painter, int &left, int top, int &right, Qt::LayoutDirection layoutDir )
+static inline void paint_right_aligned_elided_text( const QString &text, Theme::ContentItem * ci, QPainter * painter, int &left, int top, int &right, Qt::LayoutDirection layoutDir, const QFont &font )
{
- if ( ci->lastPaintDevice() != pd )
- ci->updateFontMetrics( pd );
- painter->setFont( ci->font() );
+ painter->setFont( font );
+ QFontMetrics fontMetrics( font );
int w = right - left;
- QString elidedText = ci->fontMetrics().elidedText( text, layoutDir == Qt::LeftToRight ? Qt::ElideLeft : Qt::ElideRight, w );
- QRect rct( left, top, w, ci->lineSpacing() );
+ QString elidedText = fontMetrics.elidedText( text, layoutDir == Qt::LeftToRight ? Qt::ElideLeft : Qt::ElideRight, w );
+ QRect rct( left, top, w, fontMetrics.height() );
QRect outRct;
if ( ci->softenByBlending() )
@@ -129,15 +122,14 @@
left += outRct.width() + gHorizontalItemSpacing;
}
-static inline void compute_bounding_rect_for_right_aligned_elided_text( const QString &text, QPaintDevice * pd, Theme::ContentItem * ci, int &left, int top, int &right, QRect &outRect, Qt::LayoutDirection layoutDir )
+static inline void compute_bounding_rect_for_right_aligned_elided_text( const QString &text, int &left, int top, int &right, QRect &outRect, Qt::LayoutDirection layoutDir, const QFont &font )
{
- if ( ci->lastPaintDevice() != pd )
- ci->updateFontMetrics( pd );
+ QFontMetrics fontMetrics( font );
int w = right - left;
- QString elidedText = ci->fontMetrics().elidedText( text, layoutDir == Qt::LeftToRight ? Qt::ElideLeft : Qt::ElideRight, w );
- QRect rct( left, top, w, ci->lineSpacing() );
+ QString elidedText = fontMetrics.elidedText( text, layoutDir == Qt::LeftToRight ? Qt::ElideLeft : Qt::ElideRight, w );
+ QRect rct( left, top, w, fontMetrics.height() );
Qt::AlignmentFlag af = layoutDir == Qt::LeftToRight ? Qt::AlignRight : Qt::AlignLeft;
- outRect = ci->fontMetrics().boundingRect( rct, Qt::AlignTop | af | Qt::TextSingleLine, elidedText );
+ outRect = fontMetrics.boundingRect( rct, Qt::AlignTop | af | Qt::TextSingleLine, elidedText );
if ( layoutDir == Qt::LeftToRight )
right -= outRect.width() + gHorizontalItemSpacing;
else
@@ -145,14 +137,13 @@
}
-static inline void paint_left_aligned_elided_text( const QString &text, QPaintDevice * pd, Theme::ContentItem * ci, QPainter * painter, int &left, int top, int &right, Qt::LayoutDirection layoutDir )
+static inline void paint_left_aligned_elided_text( const QString &text, Theme::ContentItem * ci, QPainter * painter, int &left, int top, int &right, Qt::LayoutDirection layoutDir, const QFont &font )
{
- if ( ci->lastPaintDevice() != pd )
- ci->updateFontMetrics( pd );
- painter->setFont( ci->font() );
+ painter->setFont( font );
+ QFontMetrics fontMetrics( font );
int w = right - left;
- QString elidedText = ci->fontMetrics().elidedText( text, layoutDir == Qt::LeftToRight ? Qt::ElideRight : Qt::ElideLeft, w );
- QRect rct( left, top, w, ci->lineSpacing() );
+ QString elidedText = fontMetrics.elidedText( text, layoutDir == Qt::LeftToRight ? Qt::ElideRight : Qt::ElideLeft, w );
+ QRect rct( left, top, w, fontMetrics.height() );
QRect outRct;
if ( ci->softenByBlending() )
{
@@ -169,15 +160,14 @@
right -= outRct.width() + gHorizontalItemSpacing;
}
-static inline void compute_bounding_rect_for_left_aligned_elided_text( const QString &text, QPaintDevice * pd, Theme::ContentItem * ci, int &left, int top, int &right, QRect &outRect, Qt::LayoutDirection layoutDir )
+static inline void compute_bounding_rect_for_left_aligned_elided_text( const QString &text, int &left, int top, int &right, QRect &outRect, Qt::LayoutDirection layoutDir, const QFont &font )
{
- if ( ci->lastPaintDevice() != pd )
- ci->updateFontMetrics( pd );
+ QFontMetrics fontMetrics( font );
int w = right - left;
- QString elidedText = ci->fontMetrics().elidedText( text, layoutDir == Qt::LeftToRight ? Qt::ElideRight : Qt::ElideLeft, w );
- QRect rct( left, top, w, ci->lineSpacing() );
+ QString elidedText = fontMetrics.elidedText( text, layoutDir == Qt::LeftToRight ? Qt::ElideRight : Qt::ElideLeft, w );
+ QRect rct( left, top, w, fontMetrics.height() );
Qt::AlignmentFlag af = layoutDir == Qt::LeftToRight ? Qt::AlignLeft : Qt::AlignRight;
- outRect = ci->fontMetrics().boundingRect( rct, Qt::AlignTop | af | Qt::TextSingleLine, elidedText );
+ outRect = fontMetrics.boundingRect( rct, Qt::AlignTop | af | Qt::TextSingleLine, elidedText );
if ( layoutDir == Qt::LeftToRight )
left += outRect.width() + gHorizontalItemSpacing;
else
@@ -485,15 +475,15 @@
}
}
-static inline void compute_size_hint_for_item( Theme::ContentItem * ci, QPaintDevice * pd,
- int &maxh, int &totalw, int iconSize )
+static inline void compute_size_hint_for_item( Theme::ContentItem * ci,
+ int &maxh, int &totalw, int iconSize, const Item *item )
{
if ( ci->displaysText() )
{
- if ( ci->lastPaintDevice() != pd )
- ci->updateFontMetrics( pd );
- if ( ci->lineSpacing() > maxh )
- maxh = ci->lineSpacing();
+ QFont font = ThemeDelegate::itemFont( ci, item );
+ QFontMetrics fontMetrics( font );
+ if ( fontMetrics.height() > maxh )
+ maxh = fontMetrics.height();
totalw += ci->displaysLongText() ? 128 : 64;
return;
}
@@ -520,7 +510,7 @@
totalw += gHorizontalItemSpacing;
}
-static inline void compute_size_hint_for_row( const Theme::Row * r, QPaintDevice * pd, int iconSize )
+static inline QSize compute_size_hint_for_row( const Theme::Row * r, int iconSize, const Item *item )
{
int maxh = 8; // at least 8 pixels for a pixmap
int totalw = 0;
@@ -530,15 +520,15 @@
QList< Theme::ContentItem * >::ConstIterator itemit;
for ( itemit = items->begin(); itemit != items->end() ; ++itemit )
- compute_size_hint_for_item( const_cast< Theme::ContentItem * >( *itemit ), pd, maxh, totalw, iconSize );
+ compute_size_hint_for_item( const_cast< Theme::ContentItem * >( *itemit ), maxh, totalw, iconSize, item );
// then left aligned stuff
items = &( r->leftItems() );
for ( itemit = items->begin(); itemit != items->end() ; ++itemit )
- compute_size_hint_for_item( const_cast< Theme::ContentItem * >( *itemit ), pd, maxh, totalw, iconSize );
+ compute_size_hint_for_item( const_cast< Theme::ContentItem * >( *itemit ), maxh, totalw, iconSize, item );
- const_cast< Theme::Row * >( r )->setSizeHint( QSize( totalw, maxh ) );
+ return QSize( totalw, maxh );
}
void ThemeDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
@@ -555,6 +545,13 @@
opt.text.clear(); // draw no text for me, please.. I'll do it in a while
+ // Set background color of control if necessary
+ if ( item->type() == Item::Message ) {
+ MessageItem * msgItem = static_cast< MessageItem * >( item );
+ if ( msgItem->backgroundColor().isValid() )
+ opt.backgroundBrush = QBrush( msgItem->backgroundColor() );
+ }
+
QStyle * style = mItemView->style();
style->drawControl( QStyle::CE_ItemViewItem, &opt, painter, mItemView );
@@ -806,12 +803,7 @@
for ( QList< Theme::Row * >::ConstIterator rowit = rows->begin(); rowit != rows->end(); ++rowit )
{
- QSize rowSizeHint = ( *rowit )->sizeHint();
- if ( !rowSizeHint.isValid() )
- {
- compute_size_hint_for_row( ( *rowit ), mPaintDevice, mTheme->iconSize() );
- rowSizeHint = ( *rowit )->sizeHint();
- }
+ QSize rowSizeHint = compute_size_hint_for_row( ( *rowit ), mTheme->iconSize(), item );
int bottom = top + rowSizeHint.height();
@@ -848,32 +840,34 @@
painter->setPen( defaultPen );
} // otherwise setting a pen is useless at this time
+ QFont font = itemFont( ci, item );
+
switch ( ci->type() )
{
case Theme::ContentItem::Subject:
- paint_right_aligned_elided_text( item->subject(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_right_aligned_elided_text( item->subject(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::SenderOrReceiver:
- paint_right_aligned_elided_text( item->senderOrReceiver(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_right_aligned_elided_text( item->senderOrReceiver(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::Receiver:
- paint_right_aligned_elided_text( item->receiver(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_right_aligned_elided_text( item->receiver(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::Sender:
- paint_right_aligned_elided_text( item->sender(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_right_aligned_elided_text( item->sender(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::Date:
- paint_right_aligned_elided_text( item->formattedDate(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_right_aligned_elided_text( item->formattedDate(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::MostRecentDate:
- paint_right_aligned_elided_text( item->formattedMaxDate(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_right_aligned_elided_text( item->formattedMaxDate(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::Size:
- paint_right_aligned_elided_text( item->formattedSize(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_right_aligned_elided_text( item->formattedSize(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::GroupHeaderLabel:
if ( groupHeaderItem )
- paint_right_aligned_elided_text( groupHeaderItem->label(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_right_aligned_elided_text( groupHeaderItem->label(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::ReadStateIcon:
paint_permanent_icon( get_read_state_icon( item ), ci, painter, l, top, r,
@@ -1001,32 +995,34 @@
}
} // otherwise setting a pen is useless at this time
+ QFont font = itemFont( ci, item );
+
switch ( ci->type() )
{
case Theme::ContentItem::Subject:
- paint_left_aligned_elided_text( item->subject(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_left_aligned_elided_text( item->subject(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::SenderOrReceiver:
- paint_left_aligned_elided_text( item->senderOrReceiver(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_left_aligned_elided_text( item->senderOrReceiver(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::Receiver:
- paint_left_aligned_elided_text( item->receiver(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_left_aligned_elided_text( item->receiver(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::Sender:
- paint_left_aligned_elided_text( item->sender(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_left_aligned_elided_text( item->sender(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::Date:
- paint_left_aligned_elided_text( item->formattedDate(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_left_aligned_elided_text( item->formattedDate(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::MostRecentDate:
- paint_left_aligned_elided_text( item->formattedMaxDate(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_left_aligned_elided_text( item->formattedMaxDate(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::Size:
- paint_left_aligned_elided_text( item->formattedSize(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_left_aligned_elided_text( item->formattedSize(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::GroupHeaderLabel:
if ( groupHeaderItem )
- paint_left_aligned_elided_text( groupHeaderItem->label(), mPaintDevice, ci, painter, l, top, r, layoutDir );
+ paint_left_aligned_elided_text( groupHeaderItem->label(), ci, painter, l, top, r, layoutDir, font );
break;
case Theme::ContentItem::ReadStateIcon:
paint_permanent_icon( get_read_state_icon( item ), ci, painter, l, top, r,
@@ -1203,12 +1199,7 @@
for ( QList< Theme::Row * >::ConstIterator rowit = rows->begin(); rowit != rows->end(); ++rowit )
{
- QSize rowSizeHint = ( *rowit )->sizeHint();
- if ( !rowSizeHint.isValid() )
- {
- compute_size_hint_for_row( ( *rowit ), mPaintDevice, mTheme->iconSize() );
- rowSizeHint = ( *rowit )->sizeHint();
- }
+ QSize rowSizeHint = compute_size_hint_for_row( ( *rowit ), mTheme->iconSize(), mHitItem );
if ( ( viewportPoint.y() < top ) && ( rowIdx > 0 ) )
break; // not this row (tough we should have already found it... probably clicked upper margin)
@@ -1246,32 +1237,34 @@
mHitContentItemRect = QRect();
+ QFont font = itemFont( ci, mHitItem );
+
switch ( ci->type() )
{
case Theme::ContentItem::Subject:
- compute_bounding_rect_for_right_aligned_elided_text( mHitItem->subject(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_right_aligned_elided_text( mHitItem->subject(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::SenderOrReceiver:
- compute_bounding_rect_for_right_aligned_elided_text( mHitItem->senderOrReceiver(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_right_aligned_elided_text( mHitItem->senderOrReceiver(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::Receiver:
- compute_bounding_rect_for_right_aligned_elided_text( mHitItem->receiver(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_right_aligned_elided_text( mHitItem->receiver(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::Sender:
- compute_bounding_rect_for_right_aligned_elided_text( mHitItem->sender(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_right_aligned_elided_text( mHitItem->sender(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::Date:
- compute_bounding_rect_for_right_aligned_elided_text( mHitItem->formattedDate(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_right_aligned_elided_text( mHitItem->formattedDate(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::MostRecentDate:
- compute_bounding_rect_for_right_aligned_elided_text( mHitItem->formattedMaxDate(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_right_aligned_elided_text( mHitItem->formattedMaxDate(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::Size:
- compute_bounding_rect_for_right_aligned_elided_text( mHitItem->formattedSize(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_right_aligned_elided_text( mHitItem->formattedSize(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::GroupHeaderLabel:
if ( groupHeaderItem )
- compute_bounding_rect_for_right_aligned_elided_text( groupHeaderItem->label(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_right_aligned_elided_text( groupHeaderItem->label(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::ReadStateIcon:
compute_bounding_rect_for_permanent_icon( ci, l, top, r, mHitContentItemRect, layoutDir == Qt::LeftToRight, mTheme->iconSize() );
@@ -1387,32 +1380,34 @@
mHitContentItemRect = QRect();
+ QFont font = itemFont( ci, mHitItem );
+
switch ( ci->type() )
{
case Theme::ContentItem::Subject:
- compute_bounding_rect_for_left_aligned_elided_text( mHitItem->subject(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_left_aligned_elided_text( mHitItem->subject(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::SenderOrReceiver:
- compute_bounding_rect_for_left_aligned_elided_text( mHitItem->senderOrReceiver(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_left_aligned_elided_text( mHitItem->senderOrReceiver(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::Receiver:
- compute_bounding_rect_for_left_aligned_elided_text( mHitItem->receiver(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_left_aligned_elided_text( mHitItem->receiver(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::Sender:
- compute_bounding_rect_for_left_aligned_elided_text( mHitItem->sender(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_left_aligned_elided_text( mHitItem->sender(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::Date:
- compute_bounding_rect_for_left_aligned_elided_text( mHitItem->formattedDate(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_left_aligned_elided_text( mHitItem->formattedDate(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::MostRecentDate:
- compute_bounding_rect_for_left_aligned_elided_text( mHitItem->formattedMaxDate(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_left_aligned_elided_text( mHitItem->formattedMaxDate(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::Size:
- compute_bounding_rect_for_left_aligned_elided_text( mHitItem->formattedSize(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_left_aligned_elided_text( mHitItem->formattedSize(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::GroupHeaderLabel:
if ( groupHeaderItem )
- compute_bounding_rect_for_left_aligned_elided_text( groupHeaderItem->label(), mPaintDevice, ci, l, top, r, mHitContentItemRect, layoutDir );
+ compute_bounding_rect_for_left_aligned_elided_text( groupHeaderItem->label(), l, top, r, mHitContentItemRect, layoutDir, font );
break;
case Theme::ContentItem::ReadStateIcon:
compute_bounding_rect_for_permanent_icon( ci, l, top, r, mHitContentItemRect, layoutDir != Qt::LeftToRight, mTheme->iconSize() );
@@ -1527,7 +1522,7 @@
return true;
}
-QSize ThemeDelegate::sizeHintForItemTypeAndColumn( Item::Type type, int column ) const
+QSize ThemeDelegate::sizeHintForItemTypeAndColumn( Item::Type type, int column, const Item *item ) const
{
if ( !mTheme )
return QSize( 16, 16 ); // bleah
@@ -1547,9 +1542,6 @@
{
case Item::Message:
{
- QSize cached = skcolumn->messageSizeHint();
- if ( cached.isValid() )
- return cached;
rows = &( skcolumn->messageRows() );
marginh = gMessageVerticalMargin << 1;
@@ -1558,9 +1550,6 @@
break;
case Item::GroupHeader:
{
- QSize cached = skcolumn->groupHeaderSizeHint();
- if ( cached.isValid() )
- return cached;
rows = &( skcolumn->groupHeaderRows() );
marginh = ( gGroupHeaderOuterVerticalMargin + gGroupHeaderInnerVerticalMargin ) << 1;
@@ -1577,34 +1566,15 @@
for ( QList< Theme::Row * >::ConstIterator rowit = rows->begin(); rowit != rows->end(); ++rowit )
{
- compute_size_hint_for_row( *rowit, mPaintDevice, mTheme->iconSize() );
-
- QSize sh = ( *rowit )->sizeHint();
+ QSize sh = compute_size_hint_for_row( ( *rowit ), mTheme->iconSize(), item );
totalh += sh.height();
if ( sh.width() > maxw )
maxw = sh.width();
}
- QSize ret( maxw + marginw , totalh + marginh );
-
- // cache it
- switch ( type )
- {
- case Item::Message:
- const_cast< Theme::Column * >( skcolumn )->setMessageSizeHint( ret );
- break;
- case Item::GroupHeader:
- const_cast< Theme::Column * >( skcolumn )->setGroupHeaderSizeHint( ret );
- break;
- default:
- // make gcc happy
- break;
- }
-
- return ret;
+ return QSize( maxw + marginw , totalh + marginh );
}
-
QSize ThemeDelegate::sizeHint( const QStyleOptionViewItem &, const QModelIndex & index ) const
{
if ( !mTheme )
@@ -1619,9 +1589,20 @@
//Item::Type type = item->type();
- return sizeHintForItemTypeAndColumn( item->type(), index.column() );
+ return sizeHintForItemTypeAndColumn( item->type(), index.column(), item );
}
+QFont ThemeDelegate::itemFont( const Theme::ContentItem *ci, const Item *item )
+{
+ if ( ci && ci->useCustomFont() )
+ return ci->font();
+
+ if ( item && ( item->type() == Item::Message ) )
+ return static_cast< const MessageItem * >( item )->font();
+
+ return KGlobalSettings::generalFont();
+}
+
} // namespace Core
} // namespace MessageListView
Index: kmail/messagelistview/storagemodel.h
===================================================================
--- kmail/messagelistview/storagemodel.h (revision 1011070)
+++ kmail/messagelistview/storagemodel.h (revision 1011071)
@@ -28,10 +28,11 @@
class KMMsgBase;
#include <QColor>
+#include <QFont>
namespace KPIM
{
- class MessageStatus;
+ class MessageStatus;
}
namespace KMail
@@ -65,6 +66,13 @@
QColor mColorUnreadMessage;
QColor mColorImportantMessage;
QColor mColorToDoMessage;
+
+ QFont mFont;
+ QFont mFontNewMessage;
+ QFont mFontUnreadMessage;
+ QFont mFontImportantMessage;
+ QFont mFontToDoMessage;
+
public:
// When porting to Akonadi the stuff below will be simply killed as it serves
@@ -239,6 +247,11 @@
*/
void slotMessageHeaderChanged( KMFolder *folder, int idx );
+private:
+ /**
+ * set MessageItem's color and font, etc. to reflect given mail message's state
+ */
+ void setMessageItemData( Core::MessageItem * mi, KMMsgBase * msg ) const;
};
} // namespace MessageListView
Index: kdepim.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kdepim/F-10/kdepim.spec,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -p -r1.215 -r1.216
--- kdepim.spec 11 Aug 2009 14:30:58 -0000 1.215
+++ kdepim.spec 20 Aug 2009 14:33:25 -0000 1.216
@@ -6,7 +6,7 @@ Name: kdepim
Summary: PIM (Personal Information Manager) applications
Epoch: 6
Version: 4.3.0
-Release: 3%{?dist}
+Release: 4%{?dist}
License: GPLv2
Group: Applications/Productivity
@@ -15,12 +15,15 @@ Source0: ftp://ftp.kde.org/pub/kde/stabl
Patch0: kdepim-4.1.80-libqgpgme-link-fix.patch
# http://bugzilla.redhat.com/show_bug.cgi?id=496988
Patch1: kdepim-4.3.1-kmail-saveAttachments.patch
+## upstream
+# https://bugs.kde.org/show_bug.cgi?id=178402
+Patch100: kmail-fonts-4.3.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Provides: kdepim4 = %{version}-%{release}
-Requires: %{name}-libs = %{?epoch:%{epoch}:}%{version}-%{release}
+Requires: %{name}-libs%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
# Upgrade path
%if 0%{?fedora} < 12
@@ -85,7 +88,6 @@ Install %{name}-devel if you want to wri
Summary: %{name} runtime libraries
Group: System Environment/Libraries
Requires: kdelibs4%{?_isa} >= %{version}
-# include to be paranoid, installing libs-only is still mostly untested -- Rex
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
%description libs
%{summary}.
@@ -95,10 +97,7 @@ Requires: %{name} = %{?epoch:%{epoch}:}%
%setup -q
%patch0 -p1 -b .libqgpgme-link-fix
%patch1 -p0 -b .kmail-saveAttachments
-
-# omit conflict with oxygen-icons, working on a better long-term fix with
-# oxygen folk to get all the icons/temporary stuff out of kdepim
-rm -fv icons/temporary/ox16-status-meeting-organizer.png
+%patch100 -p0 -b .kmail-fonts
%build
@@ -217,6 +216,9 @@ rm -rf %{buildroot}
%changelog
+* Tue Aug 18 2009 Rex Dieter <rdieter at fedoraproject.org> - 4.3.0-4
+- kmail: upstream fix for custom font settings (#kdebug#178402)
+
* Tue Aug 11 2009 Lukáš Tinkl <ltinkl at redhat.com> - 4.3.0-3
- fix kmail default save dir regression (#496988)
More information about the fedora-extras-commits
mailing list