Bug 117479

Summary: Changes to"highlighting text styles" colors not remembered
Product: [Applications] kate Reporter: Matthew Woehlke <mwoehlke.floss>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Previous changes in a useful format

Description Matthew Woehlke 2005-12-02 01:57:56 UTC
Version:            (using KDE KDE 3.4.3)
Installed from:    Compiled From Sources
Compiler:          gcc 3.4.3 
OS:                Linux

Un-setting background colors in kate's "highlighting text styles" tab is not remembered. This includes unsetting colors and changing colors back to 'default'.

I managed to fix this by beating it until it worked. I doubt all of the following changes are needed, but here they are:

::: katehighlight.cpp
1691,1698c1691
<         if ( tmp != "-" )
<         {
<           col=tmp.toUInt(0,16);
<           p->setBGColor(col);
<         }
<         else
<           p->clearAttribute(KateAttribute::BGColor);
<       }
---
>          col=tmp.toUInt(0,16); p->setBGColor(col); }
1701,1708c1694
<         if ( tmp != "-" )
<         {
<           col=tmp.toUInt(0,16);
<           p->setSelectedBGColor(col);
<         }
<         else
<           p->clearAttribute(KateAttribute::SelectedBGColor);
<       }
---
>          col=tmp.toUInt(0,16); p->setSelectedBGColor(col); }
1738,1739c1724,1725
<     settings<<(p->itemSet(KateAttribute::BGColor)?QString::number(p->bgColor().rgb(),16):"-");
<     settings<<(p->itemSet(KateAttribute::SelectedBGColor)?QString::number(p->selectedBGColor().rgb(),16):"-");
---
>     settings<<(p->itemSet(KateAttribute::BGColor)?QString::number(p->bgColor().rgb(),16):"");
>     settings<<(p->itemSet(KateAttribute::SelectedBGColor)?QString::number(p->selectedBGColor().rgb(),16):"");
2369c2355
<   if (noHl)  // if this a highlighting for "normal texts" only, there is no need for a context list creation
---
>   if (noHl)  // if this a highlighting for "normal texts" only, tere is no need for a context list creation
2447c2433
<   // to include the context from a different definition, than the one the rule
---
>   // to include the context0 from a different definition, than the one the rule
::: kateschema.cpp
896,901d895
<
<   // clear all attributes
<   for (int i = 0; i < KateHlManager::self()->highlights(); ++i)
<     KateHlManager::self()->getHl (i)->clearAttributeArrays ();
<
<   // than reload the whole stuff
1253,1256d1246
<   else if ( st->itemSet(KateAttribute::BGColor) )
<   {
<     st->clearAttribute(KateAttribute::BGColor);
<   }
1263,1266d1252
<   else if ( st->itemSet(KateAttribute::SelectedBGColor) )
<   {
<     st->clearAttribute(KateAttribute::SelectedBGColor);
<   }
1356,1359d1341
<
<     updateStyle ();
<     ((KateStyleListView*)listView())->emitChanged();
<
1453,1455d1434
<
<   updateStyle ();
<   ((KateStyleListView*)listView())->emitChanged();
::: kateattribute.h
71c71
<   { if (itemSet(item)) changed(); m_itemsSet &= (~item); }
---
>   { m_itemsSet &= (~item); }
Comment 1 Matthew Woehlke 2005-12-02 01:58:50 UTC
NOTE: The above diffs are backwards; sorry about that
Comment 2 Matthew Woehlke 2005-12-02 17:01:34 UTC
Created attachment 13741 [details]
Previous changes in a useful format

Ok, clearly I'm still figuring out how to give useful diff's. Hopefully the
attached form is more useful!
Comment 3 Dominik Haumann 2006-06-27 17:10:18 UTC
SVN commit 555481 by dhaumann:

fix: make it possible to reset the background and selected background color.
Matthew Woehlke, please try again with upcoming KDE 3.5.4.

BUG:117479


 M  +1 -0      kateschema.cpp  


--- branches/KDE/3.5/kdelibs/kate/part/kateschema.cpp #555480:555481
@@ -1450,6 +1450,7 @@
     is->clearAttribute(KateAttribute::BGColor);
   else if ( c == 101 && is->itemSet(KateAttribute::SelectedBGColor) )
     is->clearAttribute(KateAttribute::SelectedBGColor);
+  updateStyle();
 }
 
 void KateStyleListItem::paintCell( QPainter *p, const QColorGroup& /*cg*/, int col, int width, int align )
Comment 4 Dominik Haumann 2006-06-28 10:53:17 UTC
SVN commit 555680 by dhaumann:

forward port SVN commit 511726 by alund:

Make updateStyle() work: colors can be unset, and so can other items if we
reset to default (oh, and call it too in the latter case)

CCBUG: 117479


 M  +11 -0     katestyletreewidget.cpp  


--- trunk/KDE/kdelibs/kate/part/katestyletreewidget.cpp #555679:555680
@@ -464,54 +464,63 @@
     if ( currentStyle->fontWeight() != actualStyle->fontWeight())
       actualStyle->setFontWeight( currentStyle->fontWeight() );
   }
+  else actualStyle->clearProperty( QTextFormat::FontWeight );
 
   if ( currentStyle->hasProperty(QTextFormat::FontItalic) )
   {
     if ( currentStyle->fontItalic() != actualStyle->fontItalic())
       actualStyle->setFontItalic( currentStyle->fontItalic() );
   }
+  else actualStyle->clearProperty( QTextFormat::FontItalic );
 
   if ( currentStyle->hasProperty(QTextFormat::FontStrikeOut) )
   {
     if ( currentStyle->fontStrikeOut() != actualStyle->fontStrikeOut())
       actualStyle->setFontStrikeOut( currentStyle->fontStrikeOut() );
   }
+  else actualStyle->clearProperty( QTextFormat::FontStrikeOut );
 
   if ( currentStyle->hasProperty(QTextFormat::FontUnderline) )
   {
     if ( currentStyle->fontUnderline() != actualStyle->fontUnderline())
       actualStyle->setFontUnderline( currentStyle->fontUnderline() );
   }
+  else actualStyle->clearProperty( QTextFormat::FontUnderline );
 
   if ( currentStyle->hasProperty(KTextEditor::Attribute::Outline) )
   {
     if ( currentStyle->outline() != actualStyle->outline())
       actualStyle->setOutline( currentStyle->outline() );
   }
+  else actualStyle->clearProperty( KTextEditor::Attribute::Outline );
 
   if ( currentStyle->hasProperty(QTextFormat::ForegroundBrush) )
   {
     if ( currentStyle->foreground() != actualStyle->foreground())
       actualStyle->setForeground( currentStyle->foreground() );
   }
+  else actualStyle->clearProperty( QTextFormat::ForegroundBrush );
 
   if ( currentStyle->hasProperty(KTextEditor::Attribute::SelectedForeground) )
   {
     if ( currentStyle->selectedForeground() != actualStyle->selectedForeground())
       actualStyle->setSelectedForeground( currentStyle->selectedForeground() );
   }
+  else actualStyle->clearProperty( KTextEditor::Attribute::SelectedForeground );
 
   if ( currentStyle->hasProperty(QTextFormat::BackgroundBrush) )
   {
     if ( currentStyle->background() != actualStyle->background())
       actualStyle->setBackground( currentStyle->background() );
   }
+  else actualStyle->clearProperty( QTextFormat::BackgroundBrush );
 
   if ( currentStyle->hasProperty(KTextEditor::Attribute::SelectedBackground) )
   {
     if ( currentStyle->selectedBackground() != actualStyle->selectedBackground())
       actualStyle->setSelectedBackground( currentStyle->selectedBackground() );
   }
+  else actualStyle->clearProperty( KTextEditor::Attribute::SelectedBackground );
 }
 
 /* only true for a hl mode item using it's default style */
@@ -550,6 +559,7 @@
   }
   else {
     currentStyle = KTextEditor::Attribute::Ptr(new KTextEditor::Attribute( *defaultStyle ));
+    updateStyle();
     //FIXME
     //repaint();
   }
@@ -645,6 +655,7 @@
     currentStyle->clearProperty(QTextFormat::BackgroundBrush);
   else if ( c == 101 && currentStyle->hasProperty(KTextEditor::Attribute::SelectedBackground) )
     currentStyle->clearProperty(KTextEditor::Attribute::SelectedBackground);
+  updateStyle();
 }
 
 KateStyleTreeWidget* KateStyleTreeWidgetItem::treeWidget() const