MCPcopy Create free account
hub / github.com/KDE/kdevelop / matchColor

Method matchColor

plugins/quickopen/expandingtree/expandingwidgetmodel.cpp:45–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45uint ExpandingWidgetModel::matchColor(const QModelIndex& index) const
46{
47 int matchQuality = contextMatchQuality(index.sibling(index.row(), 0));
48
49 if (matchQuality > 0) {
50 bool alternate = index.row() & 1;
51
52 QColor badMatchColor(0xff00aa44); //Blue-ish green
53 QColor goodMatchColor(0xff00ff00); //Green
54
55 QColor background = treeView()->palette().light().color();
56
57 QColor totalColor = KColorUtils::mix(badMatchColor, goodMatchColor, (( float )matchQuality) / 10.0);
58
59 if (alternate) {
60 totalColor = doAlternate(totalColor);
61 }
62
63 const float dynamicTint = 0.2f;
64 const float minimumTint = 0.2f;
65 double tintStrength = (dynamicTint * matchQuality) / 10;
66 if (tintStrength) {
67 tintStrength += minimumTint; //Some minimum tinting strength, else it's not visible any more
68 }
69 return KColorUtils::tint(background, totalColor, tintStrength).rgb();
70 } else {
71 return 0;
72 }
73}
74
75QVariant ExpandingWidgetModel::data(const QModelIndex& index, int role) const
76{

Callers

nothing calls this directly

Calls 3

doAlternateFunction · 0.85
siblingMethod · 0.80
rowMethod · 0.45

Tested by

no test coverage detected