Enable setting of tag background color in configure dialog. Honor

setting in message list view.

FEATURE:

svn path=/trunk/KDE/kdepim/; revision=986329
wilder-work
Jonathan Armond 17 years ago
parent 7d00555dff
commit 06ee4056de
  1. 27
      configuredialog.cpp
  2. 4
      configuredialog_p.h
  3. 6
      kmmessagetag.cpp
  4. 7
      messagelistview/core/messageitem.h
  5. 7
      messagelistview/core/themedelegate.cpp
  6. 194
      messagelistview/storagemodel.cpp

@ -2364,12 +2364,27 @@ AppearancePageMessageTagTab::AppearancePageMessageTagTab( QWidget * parent )
connect( mTextColorCombo, SIGNAL( activated( int ) ),
this, SLOT( slotEmitChangeCheck( void ) ) );
//Third for font selection
//Third row for text background color
mBackgroundColorCheck = new QCheckBox( i18n("Change &background color:"),
mTagSettingGroupBox );
settings->addWidget( mBackgroundColorCheck, 3, 0 );
mBackgroundColorCombo = new KColorCombo( mTagSettingGroupBox );
settings->addWidget( mBackgroundColorCombo, 3, 1 );
connect( mBackgroundColorCheck, SIGNAL( toggled( bool ) ),
mBackgroundColorCombo, SLOT( setEnabled( bool ) ) );
connect( mBackgroundColorCheck, SIGNAL( stateChanged( int ) ),
this, SLOT( slotEmitChangeCheck( void ) ) );
connect( mBackgroundColorCombo, SIGNAL( activated( int ) ),
this, SLOT( slotEmitChangeCheck( void ) ) );
//Fourth for font selection
mTextFontCheck = new QCheckBox( i18n("Change fo&nt:"), mTagSettingGroupBox );
settings->addWidget( mTextFontCheck, 3, 0 );
settings->addWidget( mTextFontCheck, 4, 0 );
mFontRequester = new KFontRequester( mTagSettingGroupBox );
settings->addWidget( mFontRequester, 3, 1 );
settings->addWidget( mFontRequester, 4, 1 );
connect( mTextFontCheck, SIGNAL( toggled( bool ) ),
mFontRequester, SLOT( setEnabled( bool ) ) );
@ -2378,7 +2393,7 @@ AppearancePageMessageTagTab::AppearancePageMessageTagTab( QWidget * parent )
connect( mFontRequester, SIGNAL( fontSelected( const QFont& ) ),
this, SLOT( slotEmitChangeCheck( void ) ) );
//Fourth for toolbar icon
//Fifth for toolbar icon
mIconButton = new KIconButton( mTagSettingGroupBox );
mIconButton->setIconSize( 16 );
mIconButton->setIconType( KIconLoader::NoGroup, KIconLoader::Action );
@ -2394,7 +2409,7 @@ AppearancePageMessageTagTab::AppearancePageMessageTagTab( QWidget * parent )
connect( mIconButton, SIGNAL( iconChanged( QString ) ),
this, SLOT( slotEmitChangeCheck( void ) ) );
//Fifth for shortcut
//Sixth for shortcut
mKeySequenceWidget = new KKeySequenceWidget( mTagSettingGroupBox );
settings->addWidget( mKeySequenceWidget, 6, 1 );
QLabel *sclabel = new QLabel( i18n("Shortc&ut:") , mTagSettingGroupBox );
@ -2406,7 +2421,7 @@ AppearancePageMessageTagTab::AppearancePageMessageTagTab( QWidget * parent )
connect( mKeySequenceWidget, SIGNAL( keySequenceChanged( const QKeySequence & ) ),
this, SLOT( slotEmitChangeCheck() ) );
//Sixth for Toolbar checkbox
//Seventh for Toolbar checkbox
mInToolbarCheck = new QCheckBox( i18n("Enable &toolbar button"),
mTagSettingGroupBox );
settings->addWidget( mInToolbarCheck, 7, 0 );

@ -592,12 +592,12 @@ private: // data
QListWidget *mTagListBox;
QCheckBox *mTextColorCheck,
QCheckBox *mTextColorCheck, *mBackgroundColorCheck,
*mTextFontCheck, *mInToolbarCheck;
QGroupBox *mTagsGroupBox, *mTagSettingGroupBox;
KColorCombo *mTextColorCombo;
KColorCombo *mTextColorCombo, *mBackgroundColorCombo;
KFontRequester *mFontRequester;

@ -80,10 +80,10 @@ KMMessageTagDescription::KMMessageTagDescription( const KConfigGroup& aGroup )
void KMMessageTagDescription::setLabel( const QString& aLabel ) { mLabel = aLabel; }
void KMMessageTagDescription::setName( const QString& aName ) { mName = aName; }
/*void KMMessageTagDescription::setBackgroundColor( const QColor& aBackgroundColor )
void KMMessageTagDescription::setBackgroundColor( const QColor& aBackgroundColor )
{
mBackgroundColor = aBackgroundColor;
}*/
}
void KMMessageTagDescription::setTextColor( const QColor& aTextColor )
{
mTextColor = aTextColor;
@ -136,6 +136,8 @@ void KMMessageTagDescription::writeConfig( KConfigGroup &group ) const
group.writeEntry( "Name", mName );
if ( mTextColor.isValid() )
group.writeEntry( "text-color", mTextColor );
if ( mBackgroundColor.isValid() )
group.writeEntry( "background-color", mBackgroundColor );
if ( mTextFont != QFont() )
group.writeEntry( "text-font", mTextFont );

@ -101,6 +101,7 @@ private:
SignatureState mSignatureState;
QList< Tag * > * mTagList; ///< Usually 0....
QColor mTextColor; ///< If invalid, use default text color
QColor mBackgroundColor; ///< If invalid, use default background color
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 +131,15 @@ public:
const QColor & textColor() const
{ return mTextColor; };
const QColor & backgroundColor() const
{ return mBackgroundColor; };
void setTextColor( const QColor &clr )
{ mTextColor = clr; };
void setBackgroundColor( const QColor &clr )
{ mBackgroundColor = clr; };
SignatureState signatureState() const
{ return mSignatureState; };

@ -555,6 +555,13 @@ void ThemeDelegate::paint( QPainter * painter, const QStyleOptionViewItem & opti
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 );

@ -290,46 +290,15 @@ bool StorageModel::containsOutboundMessages() const
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 +306,16 @@ bool StorageModel::initializeMessageItem( Core::MessageItem * mi, int row, bool
{
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 +328,18 @@ bool StorageModel::initializeMessageItem( Core::MessageItem * mi, int row, bool
}
}
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 +349,17 @@ bool StorageModel::initializeMessageItem( Core::MessageItem * mi, int row, bool
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,12 +369,60 @@ bool StorageModel::initializeMessageItem( Core::MessageItem * mi, int row, bool
mi->setSignatureState( Core::MessageItem::PartiallySigned );
break;
case KMMsgSignatureStateUnknown:
case KMMsgSignatureProblematic:
mi->setSignatureState( Core::MessageItem::SignatureStateUnknown );
break;
default:
mi->setSignatureState( Core::MessageItem::NotSigned );
break;
}
}
bool StorageModel::initializeMessageItem( Core::MessageItem * mi, int row, bool bUseReceiver ) const
{
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
);
setMessageItemEncryptionState( mi, msg );
setMessageItemSignatureState( mi, msg );
QColor clr;
QColor backClr;
QList< Core::MessageItem::Tag * > * tagList;
tagList = fillTagList( msg, clr, backClr );
mi->setTagList( tagList );
if ( !clr.isValid() )
{
@ -412,6 +438,8 @@ bool StorageModel::initializeMessageItem( Core::MessageItem * mi, int row, bool
if ( clr.isValid() )
mi->setTextColor( clr );
if ( backClr.isValid() )
mi->setBackgroundColor( backClr );
return true;
}
@ -429,82 +457,17 @@ void StorageModel::updateMessageItemData( Core::MessageItem * mi, int row ) cons
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;
}
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;
}
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;
}
}
}
setMessageItemEncryptionState( mi, msg );
setMessageItemSignatureState( mi, msg );
QColor clr;
QColor backClr;
QList< Core::MessageItem::Tag * > * tagList;
tagList = fillTagList( msg, clr, backClr );
mi->setTagList( tagList );
if ( !clr.isValid() )
@ -520,6 +483,7 @@ void StorageModel::updateMessageItemData( Core::MessageItem * mi, int row ) cons
}
mi->setTextColor( clr ); // set even if invalid (->default color)
mi->setBackgroundColor( backClr );
// FIXME: Handle MDN State ?
}

Loading…
Cancel
Save