25
25
#include <ktexteditor/codecompletionmodel.h>
26
26
#include <kiconloader.h>
27
27
#include <ktextedit.h>
28
#include "kcolorutils.h"
29
30
#include "expandingdelegate.h"
31
#include <qapplication.h>
31
33
QIcon ExpandingWidgetModel::m_expandedIcon;
32
34
QIcon ExpandingWidgetModel::m_collapsedIcon;
51
static QColor doAlternate(QColor color) {
52
QColor background = QApplication::palette().background().color();
53
return KColorUtils::mix(color, background, 0.15);
49
56
uint ExpandingWidgetModel::matchColor(const QModelIndex& index) const {
51
58
int matchQuality = contextMatchQuality( index.sibling(index.row(), 0) );
53
if( matchQuality != -1 )
60
if( matchQuality > 0 )
55
62
bool alternate = index.row() & 1;
57
quint64 badMatchColor = 0xff7777ff; //Full blue
58
quint64 goodMatchColor = 0xff77ff77; //Full green
61
badMatchColor += 0x00080000;
62
goodMatchColor += 0x00080000;
64
uint totalColor = (badMatchColor*(10-matchQuality) + goodMatchColor*matchQuality)/10;
64
QColor badMatchColor(0xff00aa44); //Blueish green
65
QColor goodMatchColor(0xff00ff00); //Green
67
QColor background = treeView()->palette().light().color();
69
QColor totalColor = KColorUtils::mix(badMatchColor, goodMatchColor, ((float)matchQuality)/10.0);
72
totalColor = doAlternate(totalColor);
74
const float dynamicTint = 0.2;
75
const float minimumTint = 0.2;
76
double tintStrength = (dynamicTint*matchQuality)/10;
78
tintStrength += minimumTint; //Some minimum tinting strength, else it's not visible any more
80
return KColorUtils::tint(background, totalColor, tintStrength ).rgb();
72
86
QVariant ExpandingWidgetModel::data( const QModelIndex & index, int role ) const
81
95
return QBrush( color );
83
///@todo Choose a color from the color scheme
84
97
//Use a special background-color for expanded items
85
98
if( isExpanded(index) ) {
87
return QBrush(0xffd8ca6c);
89
return QBrush(0xffeddc6a);
99
if( index.row() & 1 ) {
100
return doAlternate(treeView()->palette().toolTipBase().color());
102
return treeView()->palette().toolTipBase();
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);
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);
431
445
QList<QVariant> mergeCustomHighlighting( int leftSize, const QList<QVariant>& left, int rightSize, const QList<QVariant>& right )