Prepare for more than 15 message types
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 29 Jul 2009 22:39:59 +0000 (00:39 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Aug 2009 18:25:06 +0000 (20:25 +0200)
src/uisupport/uistyle.cpp
src/uisupport/uistyle.h

index 35d3162..f497c49 100644 (file)
@@ -168,14 +168,14 @@ QTextCharFormat UiStyle::format(quint32 ftype, quint32 label_) {
 }
 
 void UiStyle::mergeFormat(QTextCharFormat &fmt, quint32 ftype, quint64 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
 
   // 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) {
       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;
 // 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(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
 }
 
   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
         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
       length = 2;
     } else if(s[pos+1] == 'R') { // reverse
       // TODO: implement reverse formatting
index ca411fa..928b07b 100644 (file)
@@ -50,7 +50,7 @@ public:
    */
   enum FormatType {
     None            = 0x00000000,
    */
   enum FormatType {
     None            = 0x00000000,
-    Invalid         = 0x11111111,
+    Invalid         = 0xffffffff,
 
     // Message Formats (mutually exclusive!)
     PlainMsg        = 0x00000001,
 
     // Message Formats (mutually exclusive!)
     PlainMsg        = 0x00000001,
@@ -69,19 +69,19 @@ public:
     DayChangeMsg    = 0x0000000e,
 
     // Standard Formats
     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
 
     // 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
 
     // URL is special, we want that to take precedence over the rest...
     Url             = 0x00080000