[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdereview/ktimechooser
From:       Laurent Montel <montel () kde ! org>
Date:       2010-09-12 21:23:55
Message-ID: 20100912212355.E9D44AC887 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1174590 by mlaurent:

Compile with "-DQT_NO_CAST_FROM_ASCII" and " -DQT_NO_CAST_TO_ASCII"


 M  +38 -38    ktimevalidator.cpp  


--- trunk/kdereview/ktimechooser/ktimevalidator.cpp #1174589:1174590
@@ -49,7 +49,7 @@
     }
     // remove the separator sign before the seconds
     // and assume that works everywhere
-    if (curPos >= 0 && inout.at(curPos).isPunct() && inout.at(curPos) != '%') {
+    if (curPos >= 0 && inout.at(curPos).isPunct() && inout.at(curPos) != QLatin1Char('%')) {
         curPos--;
     }
     // remove spaces (#163813)
@@ -76,7 +76,7 @@
         // first element, eat succeeding punctuation and spaces
         ppos = 2;
         while (ppos < length && (inout.at(ppos).isSpace() || inout.at(ppos).isPunct()) &&
-            inout.at(ppos) != '%') {
+            inout.at(ppos) != QLatin1Char('%')) {
             ppos++;
         }
         inout = inout.mid(ppos);
@@ -124,8 +124,8 @@
 {
     QString timeFormat(KGlobal::locale()->timeFormat());
 
-    expAcceptable = '^';
-    expIntermediate = '^';
+    expAcceptable = QLatin1Char('^');
+    expIntermediate = QLatin1Char('^');
 
     bool excludeSecs = ((options & KLocale::TimeWithoutSeconds) == KLocale::TimeWithoutSeconds);
 
@@ -149,37 +149,37 @@
             } else if (!timeFormat.at(pos).isSpace()) {
                 // spaces are ignored (and stripped from the validator's input as well)
                 QString escaped(QRegExp::escape(timeFormat.at(pos)));
-                expIntermediate += escaped + '?';
+                expIntermediate += escaped + QLatin1Char('?');
                 expAcceptable += escaped;
             } else {
                 // spaces are optional
-                expIntermediate += "\\s?";
-                expAcceptable += "\\s";
+                expIntermediate += QLatin1String("\\s?");
+                expAcceptable += QLatin1String("\\s");
             }
         } else {
             switch (timeFormat.at(pos).toLatin1()) {
 
             case 'H':
             case 'k': // no need to distinguish '5' and '05'
-                expIntermediate += "([0-1]?\\d?|2?[0-3]?)";
-                expAcceptable += "([0-1]?\\d|2[0-3])";
+                expIntermediate += QLatin1String("([0-1]?\\d?|2?[0-3]?)");
+                expAcceptable += QLatin1String("([0-1]?\\d|2[0-3])");
                 break;
 
             case 'I':
             case 'l': // no need to distinguish here either
                 if ((options & KLocale::TimeDuration) == KLocale::TimeDuration) {
-                    expIntermediate += "([0-1]?\\d?|2?[0-3]?)";
-                    expAcceptable += "([0-1]?\\d|2[0-3])";
+                    expIntermediate += QLatin1String("([0-1]?\\d?|2?[0-3]?)");
+                    expAcceptable += QLatin1String("([0-1]?\\d|2[0-3])");
                 } else {
-                    expIntermediate += "(?:0?\\d?|1?[0-2]?)";
-                    expAcceptable += "(0?\\d|1[0-2])";
+                    expIntermediate += QLatin1String("(?:0?\\d?|1?[0-2]?)");
+                    expAcceptable += QLatin1String("(0?\\d|1[0-2])");
                 }
                 break;
 
             case 'M':
             case 'S': // same format for minutes and seconds
-                expIntermediate += "[0-5]?[0-9]?";
-                expAcceptable += "([0-5][0-9])";
+                expIntermediate += QLatin1String("[0-5]?[0-9]?");
+                expAcceptable += QLatin1String("([0-5][0-9])");
                 break;
 
             case 'p': // TODO: suffix "?" for every letter
@@ -189,13 +189,13 @@
                 QString amExp;
                 QString pmExp;
                 Q_FOREACH(const QChar &c, am) {
-                    amExp += QRegExp::escape(c) + '?';
+                    amExp += QRegExp::escape(c) + QLatin1Char('?');
                 }
                 Q_FOREACH(const QChar &c, pm) {
-                    pmExp += QRegExp::escape(c) + '?';
+                    pmExp += QRegExp::escape(c) + QLatin1Char('?');
                 }
-                expIntermediate += QString("(?:%1|%2)").arg(amExp, pmExp);
-                expAcceptable += QString("(?:%1|%2)").arg(QRegExp::escape(am),
+                expIntermediate += QString(QLatin1String("(?:%1|%2)")).arg(amExp, pmExp);
+                expAcceptable += QString(QLatin1String("(?:%1|%2)")).arg(QRegExp::escape(am),
                                                           QRegExp::escape(pm));
                 break;
             }
@@ -203,12 +203,12 @@
             default: // NOTE: Like this "%%H" will not be identified
                 if (!timeFormat.at(pos).isSpace()) {
                     QString escaped(QRegExp::escape(timeFormat.at(pos)));
-                    expIntermediate += escaped + '?';
+                    expIntermediate += escaped + QLatin1Char('?');
                     expAcceptable += escaped;
                 } else {
                     // spaces are optional
-                    expIntermediate += "\\s?";
-                    expAcceptable += "\\s";
+                    expIntermediate += QLatin1String("\\s?");
+                    expAcceptable += QLatin1String("\\s");
                 }
                 break;
             }
@@ -216,8 +216,8 @@
         }
     }
 
-    expIntermediate.append("$");
-    expAcceptable.append("$");
+    expIntermediate.append(QLatin1Char('$'));
+    expAcceptable.append(QLatin1Char('$'));
 }
 
 class KTimeValidator::Private
@@ -226,11 +226,11 @@
     Private()
         : m_ampmposition(AmPmNotPresent), m_options(KLocale::TimeDefault),
           m_automaticFixup(true),
-          m_rxMil("^([0-1]?\\d?|2?[0-3]?)([0-5]?\\d?)$"),
-          m_rxMilWs("^([0-1]?\\d?|2?[0-3]?)([0-5]?\\d)([0-5]?\\d?)$"),
+          m_rxMil(QLatin1String("^([0-1]?\\d?|2?[0-3]?)([0-5]?\\d?)$")),
+          m_rxMilWs(QLatin1String("^([0-1]?\\d?|2?[0-3]?)([0-5]?\\d)([0-5]?\\d?)$")),
           m_lenMil(4), m_lenMilWs(6),
-          m_rxReg("^([0-1]?\\d?|2?[0-3]?):?([0-5]?\\d?)$"),
-          m_rxRegWs("^([0-1]?\\d?|2?[0-3]?):?([0-5]?\\d):?([0-5]?\\d?)$"),
+          m_rxReg(QLatin1String("^([0-1]?\\d?|2?[0-3]?):?([0-5]?\\d?)$")),
+          m_rxRegWs(QLatin1String("^([0-1]?\\d?|2?[0-3]?):?([0-5]?\\d):?([0-5]?\\d?)$")),
           m_lenReg(5), m_lenRegWs(8)
     {
     }
@@ -276,7 +276,7 @@
     m_ampmposition = AmPmNotPresent;
     if ((m_options & KLocale::TimeWithoutAmPm) != KLocale::TimeWithoutAmPm) {
         QString format(KGlobal::locale()->timeFormat());
-        int percpos = format.indexOf(QChar('%'));
+        int percpos = format.indexOf(QLatin1Char('%'));
         int ppos = format.indexOf(QLatin1String("%p"));
         if (ppos != -1) {
             if (percpos == ppos) {
@@ -415,7 +415,7 @@
         // but lack spaces.
         if (d->m_rxLocWsIn.cap(1).size() == 1) {
             // 1-digit hour, reformat
-            input.insert(d->m_rxLocWsIn.pos(1), QChar('0'));
+            input.insert(d->m_rxLocWsIn.pos(1), QLatin1Char('0'));
         }
         time = KGlobal::locale()->readLocaleTime(input, &ok, d->m_options, false);
         if (!ok) {
@@ -439,7 +439,7 @@
         // but lack spaces.
         if (d->m_rxLocIn.cap(1).size() == 1) {
             // 1-digit hour, reformat
-            input.insert(d->m_rxLocIn.pos(1), QChar('0'));
+            input.insert(d->m_rxLocIn.pos(1), QLatin1Char('0'));
         }
         time = KGlobal::locale()->readLocaleTime(input, &ok,
                                                  d->m_options | KLocale::TimeWithoutSeconds,
@@ -454,7 +454,7 @@
         validateOther(input, d->m_rxRegWs, d->m_lenRegWs) == QValidator::Acceptable) {
         if (d->m_rxRegWs.cap(1).size() == 1) {
             // 1-digit hour, reformat
-            input.insert(d->m_rxRegWs.pos(1), QChar('0'));
+            input.insert(d->m_rxRegWs.pos(1), QLatin1Char('0'));
         }
         time = QTime::fromString(input, QLatin1String("hh:mm:ss"));
         amPmDecideable = true;
@@ -463,7 +463,7 @@
         validateOther(input, d->m_rxReg, d->m_lenReg) == QValidator::Acceptable) {
         if (d->m_rxReg.cap(1).size() == 1) {
             // 1-digit hour, reformat
-            input.insert(d->m_rxReg.pos(1), QChar('0'));
+            input.insert(d->m_rxReg.pos(1), QLatin1Char('0'));
         }
         time = QTime::fromString(input, QLatin1String("hh:mm"));
         amPmDecideable = true;
@@ -472,12 +472,12 @@
         // insert ":" into time and check with "regular" regexp to see if
         // it's military time.
         QString militaryInput(input);
-        militaryInput.insert(militaryInput.size() - 2, QChar(':'));
-        militaryInput.insert(militaryInput.size() - 5, QChar(':'));
+        militaryInput.insert(militaryInput.size() - 2, QLatin1Char(':'));
+        militaryInput.insert(militaryInput.size() - 5, QLatin1Char(':'));
         if (validateOther(militaryInput, d->m_rxRegWs, d->m_lenRegWs) == QValidator::Acceptable) {
             if (d->m_rxRegWs.cap(1).size() == 1) {
                 // 1-digit hour, reformat
-                militaryInput.insert(d->m_rxRegWs.pos(1), QChar('0'));
+                militaryInput.insert(d->m_rxRegWs.pos(1), QLatin1Char('0'));
             }
             time = QTime::fromString(militaryInput, QLatin1String("hh:mm:ss"));
             amPmDecideable = true;
@@ -487,11 +487,11 @@
         // insert ":" into time and check with "regular" regexp to see if
         // it's military time.
         QString militaryInput(input);
-        militaryInput.insert(militaryInput.size() - 2, QChar(':'));
+        militaryInput.insert(militaryInput.size() - 2, QLatin1Char(':'));
         if (validateOther(militaryInput, d->m_rxReg, d->m_lenReg) == QValidator::Acceptable) {
             if (d->m_rxReg.cap(1).size() == 1) {
                 // 1-digit hour, reformat
-                militaryInput.insert(d->m_rxRegWs.pos(1), QChar('0'));
+                militaryInput.insert(d->m_rxRegWs.pos(1), QLatin1Char('0'));
             }
             time = QTime::fromString(militaryInput, QLatin1String("hh:mm"));
             amPmDecideable = true;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic