From 6853298d912ce9d4bc339187e8a53963b8ec3c41 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 30 Jul 2009 00:39:59 +0200 Subject: [PATCH] Prepare for more than 15 message types --- src/uisupport/uistyle.cpp | 12 ++++++------ src/uisupport/uistyle.h | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 35d3162d..f497c49b 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -168,14 +168,14 @@ QTextCharFormat UiStyle::format(quint32 ftype, quint32 label_) { } void UiStyle::mergeFormat(QTextCharFormat &fmt, quint32 ftype, quint64 label) { - mergeSubElementFormat(fmt, ftype & 0x000f, label); + mergeSubElementFormat(fmt, ftype & 0x00ff, 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) { + for(quint32 mask = 0x00100; mask <= 0x40000; mask <<= 1) { if(ftype & mask) { - mergeSubElementFormat(fmt, mask | 0x0f, label); + mergeSubElementFormat(fmt, mask | 0xff, label); } } } @@ -197,9 +197,9 @@ void UiStyle::mergeFormat(QTextCharFormat &fmt, quint32 ftype, quint64 label) { // Merge a subelement format into an existing message format void UiStyle::mergeSubElementFormat(QTextCharFormat& fmt, quint32 ftype, quint64 label) { quint64 key = ftype | label; - fmt.merge(cachedFormat(key & Q_UINT64_C(0x0000fffffffffff0))); // label + subelement + fmt.merge(cachedFormat(key & Q_UINT64_C(0x0000ffffffffff00))); // label + subelement fmt.merge(cachedFormat(key & Q_UINT64_C(0x0000ffffffffffff))); // label + subelement + msgtype - fmt.merge(cachedFormat(key & Q_UINT64_C(0xfffffffffffffff0))); // label + subelement + nickhash + fmt.merge(cachedFormat(key & Q_UINT64_C(0xffffffffffffff00))); // label + subelement + nickhash fmt.merge(cachedFormat(key & Q_UINT64_C(0xffffffffffffffff))); // label + subelement + nickhash + msgtype } @@ -300,7 +300,7 @@ UiStyle::StyledString UiStyle::styleString(const QString &s_, quint32 baseFormat length = 6; } } else if(s[pos+1] == 'O') { // reset formatting - curfmt &= 0x0000000f; // we keep message type-specific formatting + curfmt &= 0x000000ff; // we keep message type-specific formatting length = 2; } else if(s[pos+1] == 'R') { // reverse // TODO: implement reverse formatting diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index ca411fae..928b07bf 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -50,7 +50,7 @@ public: */ enum FormatType { None = 0x00000000, - Invalid = 0x11111111, + Invalid = 0xffffffff, // Message Formats (mutually exclusive!) PlainMsg = 0x00000001, @@ -69,19 +69,19 @@ public: DayChangeMsg = 0x0000000e, // Standard Formats - Bold = 0x00000010, - Italic = 0x00000020, - Underline = 0x00000040, - Reverse = 0x00000080, + Bold = 0x00000100, + Italic = 0x00000200, + Underline = 0x00000400, + Reverse = 0x00000800, // Individual parts of a message - Timestamp = 0x00000100, - Sender = 0x00000200, - Contents = 0x00000400, - Nick = 0x00000800, - Hostmask = 0x00001000, - ChannelName = 0x00002000, - ModeFlags = 0x00004000, + Timestamp = 0x00001000, + Sender = 0x00002000, + Contents = 0x00004000, + Nick = 0x00008000, + Hostmask = 0x00010000, + ChannelName = 0x00020000, + ModeFlags = 0x00040000, // URL is special, we want that to take precedence over the rest... Url = 0x00080000 -- 2.20.1