Switch to lowercase for subelement and message types in QssParser
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 11 Jun 2009 14:26:44 +0000 (16:26 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Aug 2009 18:23:28 +0000 (20:23 +0200)
Lowercase seems to be the convention in stylesheet syntax, so we adhere to
that. Even though we do bend the original definitions of "subelement" and
"objectname" a bit to fit our purposes :)

src/uisupport/qssparser.cpp
src/uisupport/uistyle.cpp

index 88cf885..11a8f53 100644 (file)
@@ -83,7 +83,7 @@ void QssParser::loadStyleSheet(const QString &styleSheet) {
   while((pos = blockrx.indexIn(ss, pos)) >= 0) {
     //qDebug() << blockrx.cap(1) << blockrx.cap(2);
 
   while((pos = blockrx.indexIn(ss, pos)) >= 0) {
     //qDebug() << blockrx.cap(1) << blockrx.cap(2);
 
-    if(blockrx.cap(2) == "ChatLine")
+    if(blockrx.cap(1).startsWith("ChatLine"))
       parseChatLineData(blockrx.cap(1).trimmed(), blockrx.cap(2).trimmed());
     //else
     // TODO: add moar here
       parseChatLineData(blockrx.cap(1).trimmed(), blockrx.cap(2).trimmed());
     //else
     // TODO: add moar here
@@ -137,15 +137,15 @@ quint64 QssParser::parseFormatType(const QString &decl) {
 
   // First determine the subelement
   if(!subElement.isEmpty()) {
 
   // First determine the subelement
   if(!subElement.isEmpty()) {
-    if(subElement == "Timestamp")
+    if(subElement == "timestamp")
       fmtType |= UiStyle::Timestamp;
       fmtType |= UiStyle::Timestamp;
-    else if(subElement == "Sender")
+    else if(subElement == "sender")
       fmtType |= UiStyle::Sender;
       fmtType |= UiStyle::Sender;
-    else if(subElement == "Nick")
+    else if(subElement == "nick")
       fmtType |= UiStyle::Nick;
       fmtType |= UiStyle::Nick;
-    else if(subElement == "Hostmask")
+    else if(subElement == "hostmask")
       fmtType |= UiStyle::Hostmask;
       fmtType |= UiStyle::Hostmask;
-    else if(subElement == "ModeFlags")
+    else if(subElement == "modeflags")
       fmtType |= UiStyle::ModeFlags;
     else {
       qWarning() << Q_FUNC_INFO << tr("Invalid subelement name in %1").arg(decl);
       fmtType |= UiStyle::ModeFlags;
     else {
       qWarning() << Q_FUNC_INFO << tr("Invalid subelement name in %1").arg(decl);
@@ -155,27 +155,27 @@ quint64 QssParser::parseFormatType(const QString &decl) {
 
   // Now, figure out the message type
   if(!msgType.isEmpty()) {
 
   // Now, figure out the message type
   if(!msgType.isEmpty()) {
-    if(msgType == "Plain")
+    if(msgType == "plain")
       fmtType |= UiStyle::PlainMsg;
       fmtType |= UiStyle::PlainMsg;
-    else if(msgType == "Notice")
+    else if(msgType == "notice")
       fmtType |= UiStyle::NoticeMsg;
       fmtType |= UiStyle::NoticeMsg;
-    else if(msgType == "Server")
+    else if(msgType == "server")
       fmtType |= UiStyle::ServerMsg;
       fmtType |= UiStyle::ServerMsg;
-    else if(msgType == "Error")
+    else if(msgType == "error")
       fmtType |= UiStyle::ErrorMsg;
       fmtType |= UiStyle::ErrorMsg;
-    else if(msgType == "Join")
+    else if(msgType == "join")
       fmtType |= UiStyle::JoinMsg;
       fmtType |= UiStyle::JoinMsg;
-    else if(msgType == "Part")
+    else if(msgType == "part")
       fmtType |= UiStyle::PartMsg;
       fmtType |= UiStyle::PartMsg;
-    else if(msgType == "Quit")
+    else if(msgType == "quit")
       fmtType |= UiStyle::QuitMsg;
       fmtType |= UiStyle::QuitMsg;
-    else if(msgType == "Kick")
+    else if(msgType == "kick")
       fmtType |= UiStyle::KickMsg;
       fmtType |= UiStyle::KickMsg;
-    else if(msgType == "Rename")
+    else if(msgType == "rename")
       fmtType |= UiStyle::RenameMsg;
       fmtType |= UiStyle::RenameMsg;
-    else if(msgType == "Mode")
+    else if(msgType == "mode")
       fmtType |= UiStyle::ModeMsg;
       fmtType |= UiStyle::ModeMsg;
-    else if(msgType == "Action")
+    else if(msgType == "action")
       fmtType |= UiStyle::ActionMsg;
     else {
       qWarning() << Q_FUNC_INFO << tr("Invalid message type in %1").arg(decl);
       fmtType |= UiStyle::ActionMsg;
     else {
       qWarning() << Q_FUNC_INFO << tr("Invalid message type in %1").arg(decl);
index 96e8686..6322fb8 100644 (file)
@@ -105,7 +105,7 @@ QTextCharFormat UiStyle::format(quint32 ftype, quint32 label) {
 
   // check if we have exactly this format readily cached already
   QTextCharFormat fmt = cachedFormat(key);
 
   // check if we have exactly this format readily cached already
   QTextCharFormat fmt = cachedFormat(key);
-  if(fmt.isValid())
+  if(fmt.properties().count())
     return fmt;
 
   fmt.merge(cachedFormat(key & 0x0000000000000000));  // basic
     return fmt;
 
   fmt.merge(cachedFormat(key & 0x0000000000000000));  // basic