+QTextCharFormat UiStyle::format(FormatType ftype, Settings::Mode mode) const {
+ if(mode == Settings::Custom && _customFormats.contains(ftype)) return _customFormats.value(ftype);
+ else return _defaultFormats.value(ftype, QTextCharFormat());
+}
+
+// NOTE: This function is intimately tied to the values in FormatType. Don't change this
+// until you _really_ know what you do!
+QTextCharFormat UiStyle::mergedFormat(quint32 ftype) {
+ if(_cachedFormats.contains(ftype)) return _cachedFormats[ftype];
+ if(ftype == Invalid) return QTextCharFormat();
+ // Now we construct the merged format, starting with the default
+ QTextCharFormat fmt = format(None);
+ // First: general message format
+ fmt.merge(format((FormatType)(ftype & 0x0f)));
+ // now more specific ones
+ for(quint32 mask = 0x0010; mask <= 0x2000; mask <<= 1) {
+ if(ftype & mask) fmt.merge(format((FormatType)mask));
+ }
+ // color codes!
+ if(ftype & 0x00400000) fmt.merge(format((FormatType)(ftype & 0x0f400000))); // foreground
+ if(ftype & 0x00800000) fmt.merge(format((FormatType)(ftype & 0xf0800000))); // background
+ // URL
+ if(ftype & Url) fmt.merge(format(Url));
+ return fmt;