- // color codes!
- if(ftype & 0x00400000) fmt.merge(format((FormatType)(ftype & 0x0f400000))); // foreground
- if(ftype & 0x00800000) fmt.merge(format((FormatType)(ftype & 0xf0800000))); // background
- // Sender auto colors
- if((ftype & 0xfff) == 0x200 && (ftype & 0xff000200) != 0x200) fmt.merge(format((FormatType)(ftype & 0xff000200)));
+
+ setCachedFormat(fmt, ftype, label_);
+ return fmt;
+}
+
+void UiStyle::mergeFormat(QTextCharFormat &fmt, quint32 ftype, quint64 label) {
+ mergeSubElementFormat(fmt, ftype & 0x000f, label);
+
+ // TODO: allow combinations for mirc formats and colors (each), e.g. setting a special format for "bold and italic"
+ // or "foreground 01 and background 03"
+ if((ftype & 0xfff0)) { // element format
+ for(quint32 mask = 0x0010; mask <= 0x2000; mask <<= 1) {
+ if(ftype & mask) {
+ mergeSubElementFormat(fmt, mask | 0x0f, label);
+ }
+ }
+ }
+
+ // Now we handle color codes
+ // We assume that those can't be combined with subelement and message types.
+ if(ftype & 0x00400000)
+ mergeSubElementFormat(fmt, ftype & 0x0f400000, label); // foreground
+ if(ftype & 0x00800000)
+ mergeSubElementFormat(fmt, ftype & 0xf0800000, label); // background
+ if((ftype & 0x00c00000) == 0x00c00000)
+ mergeSubElementFormat(fmt, ftype & 0xffc00000, label); // combination
+