~ubuntu-branches/ubuntu/jaunty/kde4libs/jaunty-updates

« back to all changes in this revision

Viewing changes to kate/completion/expandingtree/expandingwidgetmodel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2008-12-11 18:26:08 UTC
  • mfrom: (1.1.24 upstream)
  • Revision ID: james.westby@ubuntu.com-20081211182608-tsu6p8ncbw1gnqxt
Tags: 4:4.1.85-0ubuntu1
* New upstream release
* Patches:
  + Removed 15_kfreebsd_support.diff from patches/series (doesn't apply and
    has no use for Ubuntu)
  + Redid 20_use_dejavu_as_default_font.diff
  + Completely removed kubuntu_09_fix_application_menu.diff (applied upstream)
  + Refreshed kubuntu_54_use_xdg_menu_prefix.diff
  + Dropped plasma/widgets/toolbutton.cpp from kubuntu_qt_ftbfs.diff (applied
    upstream)
  + Global quilt refresh

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <ktexteditor/codecompletionmodel.h>
26
26
#include <kiconloader.h>
27
27
#include <ktextedit.h>
 
28
#include "kcolorutils.h"
28
29
 
29
30
#include "expandingdelegate.h"
 
31
#include <qapplication.h>
30
32
 
31
33
QIcon ExpandingWidgetModel::m_expandedIcon;
32
34
QIcon ExpandingWidgetModel::m_collapsedIcon;
46
48
    clearExpanding();
47
49
}
48
50
 
 
51
static QColor doAlternate(QColor color) {
 
52
  QColor background = QApplication::palette().background().color();
 
53
  return KColorUtils::mix(color, background, 0.15);
 
54
}
 
55
 
49
56
uint ExpandingWidgetModel::matchColor(const QModelIndex& index) const {
50
57
  
51
58
  int matchQuality = contextMatchQuality( index.sibling(index.row(), 0) );
52
59
  
53
 
  if( matchQuality != -1 )
 
60
  if( matchQuality > 0 )
54
61
  {
55
62
    bool alternate = index.row() & 1;
56
63
    
57
 
    quint64 badMatchColor = 0xff7777ff; //Full blue
58
 
    quint64 goodMatchColor = 0xff77ff77; //Full green
59
 
 
60
 
    if( alternate ) {
61
 
      badMatchColor += 0x00080000;
62
 
      goodMatchColor += 0x00080000;
63
 
    }
64
 
    uint totalColor = (badMatchColor*(10-matchQuality) + goodMatchColor*matchQuality)/10;
65
 
    return totalColor;
 
64
    QColor badMatchColor(0xff00aa44); //Blueish green
 
65
    QColor goodMatchColor(0xff00ff00); //Green
 
66
 
 
67
    QColor background = treeView()->palette().light().color();
 
68
    
 
69
    QColor totalColor = KColorUtils::mix(badMatchColor, goodMatchColor, ((float)matchQuality)/10.0);
 
70
 
 
71
    if(alternate)
 
72
      totalColor = doAlternate(totalColor);
 
73
    
 
74
    const float dynamicTint = 0.2;
 
75
    const float minimumTint = 0.2;
 
76
    double tintStrength = (dynamicTint*matchQuality)/10;
 
77
    if(tintStrength)
 
78
      tintStrength += minimumTint; //Some minimum tinting strength, else it's not visible any more
 
79
    
 
80
    return KColorUtils::tint(background, totalColor, tintStrength ).rgb();
66
81
  }else{
67
82
    return 0;
68
83
  }
69
84
}
70
 
    
71
85
 
72
86
QVariant ExpandingWidgetModel::data( const QModelIndex & index, int role ) const
73
87
{
80
94
        if( color )
81
95
          return QBrush( color );
82
96
      }
83
 
      ///@todo Choose a color from the color scheme
84
97
      //Use a special background-color for expanded items
85
98
      if( isExpanded(index) ) {
86
 
        if( index.row() & 1 )
87
 
          return QBrush(0xffd8ca6c);
88
 
        else
89
 
          return QBrush(0xffeddc6a);
 
99
        if( index.row() & 1 ) {
 
100
          return doAlternate(treeView()->palette().toolTipBase().color());
 
101
        } else {
 
102
          return treeView()->palette().toolTipBase();
 
103
        }
90
104
      }
91
105
    }
92
106
  }
422
436
 
423
437
void ExpandingWidgetModel::cacheIcons() const {
424
438
    if( m_expandedIcon.isNull() )
425
 
      m_expandedIcon = KIconLoader::global()->loadIcon("go-down", KIconLoader::Small);
 
439
      m_expandedIcon = KIconLoader::global()->loadIcon("arrow-down", KIconLoader::Small, 10);
426
440
    
427
441
    if( m_collapsedIcon.isNull() )
428
 
      m_collapsedIcon = KIconLoader::global()->loadIcon("go-next", KIconLoader::Small);
 
442
      m_collapsedIcon = KIconLoader::global()->loadIcon("arrow-right", KIconLoader::Small, 10);
429
443
}
430
444
 
431
445
QList<QVariant> mergeCustomHighlighting( int leftSize, const QList<QVariant>& left, int rightSize, const QList<QVariant>& right )