src/ldConfig.cc

changeset 840
d077dd19bf9a
parent 806
4240f47aa2d4
child 844
11587d419d2f
equal deleted inserted replaced
839:5f822ad61875 840:d077dd19bf9a
54 // Read in the lines 54 // Read in the lines
55 while (not fp->atEnd()) 55 while (not fp->atEnd())
56 { 56 {
57 QString line = QString::fromUtf8 (fp->readLine()); 57 QString line = QString::fromUtf8 (fp->readLine());
58 58
59 if (line.isEmpty() || line[0] != '0') 59 if (line.isEmpty() or line[0] != '0')
60 continue; // empty or illogical 60 continue; // empty or illogical
61 61
62 line.remove ('\r'); 62 line.remove ('\r');
63 line.remove ('\n'); 63 line.remove ('\n');
64 64
67 67
68 int code = 0, alpha = 255; 68 int code = 0, alpha = 255;
69 QString name, facename, edgename, valuestr; 69 QString name, facename, edgename, valuestr;
70 70
71 // Check 0 !COLOUR, parse the name 71 // Check 0 !COLOUR, parse the name
72 if (not pars.tokenCompare (0, "0") || 72 if (not pars.tokenCompare (0, "0") or
73 not pars.tokenCompare (1, "!COLOUR") || 73 not pars.tokenCompare (1, "!COLOUR") or
74 not pars.getToken (name, 2)) 74 not pars.getToken (name, 2))
75 { 75 {
76 continue; 76 continue;
77 } 77 }
78 78
85 85
86 // Ensure that the code is within [0 - 511] 86 // Ensure that the code is within [0 - 511]
87 bool ok; 87 bool ok;
88 code = valuestr.toShort (&ok); 88 code = valuestr.toShort (&ok);
89 89
90 if (not ok || code < 0 || code >= 512) 90 if (not ok or code < 0 or code >= 512)
91 continue; 91 continue;
92 92
93 // VALUE and EDGE tags 93 // VALUE and EDGE tags
94 if (not parseLDConfigTag (pars, "VALUE", facename) || not parseLDConfigTag (pars, "EDGE", edgename)) 94 if (not parseLDConfigTag (pars, "VALUE", facename) or not parseLDConfigTag (pars, "EDGE", edgename))
95 continue; 95 continue;
96 96
97 // Ensure that our colors are correct 97 // Ensure that our colors are correct
98 QColor faceColor (facename), 98 QColor faceColor (facename),
99 edgeColor (edgename); 99 edgeColor (edgename);
100 100
101 if (not faceColor.isValid() || not edgeColor.isValid()) 101 if (not faceColor.isValid() or not edgeColor.isValid())
102 continue; 102 continue;
103 103
104 // Parse alpha if given. 104 // Parse alpha if given.
105 if (parseLDConfigTag (pars, "ALPHA", valuestr)) 105 if (parseLDConfigTag (pars, "ALPHA", valuestr))
106 alpha = clamp (valuestr.toInt(), 0, 255); 106 alpha = clamp (valuestr.toInt(), 0, 255);

mercurial