+QTextCharFormat UiStyle::cachedFormat(quint64 key) const {
+ return _formatCache.value(key, QTextCharFormat());
+}
+
+QTextCharFormat UiStyle::cachedFormat(quint32 formatType, quint32 messageLabel) const {
+ return cachedFormat(formatType | ((quint64)messageLabel << 32));
+}
+
+void UiStyle::setCachedFormat(const QTextCharFormat &format, quint32 formatType, quint32 messageLabel) {
+ _formatCache[formatType | ((quint64)messageLabel << 32)] = format;
+}
+
+// Merge a subelement format into an existing message format
+void UiStyle::mergeSubElementFormat(QTextCharFormat& fmt, quint32 ftype, quint32 label) {
+ quint64 key = ftype | ((quint64)label << 32);
+
+ // start with the most general format and then specialize
+ fmt.merge(cachedFormat(key & 0x00000000fffffff0)); // basic subelement format
+ fmt.merge(cachedFormat(key & 0x00000000ffffffff)); // subelement + msgtype
+ fmt.merge(cachedFormat(key & 0xffff0000fffffff0)); // subelement + nickhash
+ fmt.merge(cachedFormat(key & 0xffff0000ffffffff)); // subelement + nickhash + msgtype
+ fmt.merge(cachedFormat(key & 0x0000fffffffffff0)); // label + subelement
+ fmt.merge(cachedFormat(key & 0x0000ffffffffffff)); // label + subelement + msgtype
+ fmt.merge(cachedFormat(key & 0xfffffffffffffff0)); // label + subelement + nickhash
+ fmt.merge(cachedFormat(key & 0xffffffffffffffff)); // label + subelement + nickhash + msgtype
+}
+