diff options
Diffstat (limited to 'src/isbnvalidator.cpp')
-rw-r--r-- | src/isbnvalidator.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/isbnvalidator.cpp b/src/isbnvalidator.cpp index 6f33c67..4832cdd 100644 --- a/src/isbnvalidator.cpp +++ b/src/isbnvalidator.cpp @@ -18,7 +18,7 @@ using Tellico::ISBNValidator; //static TQString ISBNValidator::isbn10(TQString isbn13) { - if(!isbn13.startsWith(TQString::tqfromLatin1("978"))) { + if(!isbn13.startsWith(TQString::fromLatin1("978"))) { myDebug() << "ISBNValidator::isbn10() - can't convert, must start with 978: " << isbn13 << endl; return isbn13; } @@ -34,14 +34,14 @@ TQString ISBNValidator::isbn10(TQString isbn13) { TQString ISBNValidator::isbn13(TQString isbn10) { isbn10.remove('-'); - if(isbn10.startsWith(TQString::tqfromLatin1("978")) || - isbn10.startsWith(TQString::tqfromLatin1("979"))) { + if(isbn10.startsWith(TQString::fromLatin1("978")) || + isbn10.startsWith(TQString::fromLatin1("979"))) { return isbn10; } // remove checksum isbn10.truncate(isbn10.length()-1); // begins with 978 - isbn10.prepend(TQString::tqfromLatin1("978")); + isbn10.prepend(TQString::fromLatin1("978")); // add new checksum isbn10 += checkSum13(isbn10); staticFixup(isbn10); @@ -49,7 +49,7 @@ TQString ISBNValidator::isbn13(TQString isbn10) { } TQString ISBNValidator::cleanValue(TQString isbn) { - isbn.remove(TQRegExp(TQString::tqfromLatin1("[^xX0123456789]"))); + isbn.remove(TQRegExp(TQString::fromLatin1("[^xX0123456789]"))); return isbn; } @@ -58,8 +58,8 @@ ISBNValidator::ISBNValidator(TQObject* parent_, const char* name_/*=0*/) } TQValidator::State ISBNValidator::validate(TQString& input_, int& pos_) const { - if(input_.startsWith(TQString::tqfromLatin1("978")) || - input_.startsWith(TQString::tqfromLatin1("979"))) { + if(input_.startsWith(TQString::fromLatin1("978")) || + input_.startsWith(TQString::fromLatin1("979"))) { return validate13(input_, pos_); } else { return validate10(input_, pos_); @@ -71,9 +71,9 @@ void ISBNValidator::fixup(TQString& input_) const { } void ISBNValidator::staticFixup(TQString& input_) { - if((input_.startsWith(TQString::tqfromLatin1("978")) - || input_.startsWith(TQString::tqfromLatin1("979"))) - && input_.contains(TQRegExp(TQString::tqfromLatin1("\\d"))) > 10) { + if((input_.startsWith(TQString::fromLatin1("978")) + || input_.startsWith(TQString::fromLatin1("979"))) + && input_.contains(TQRegExp(TQString::fromLatin1("\\d"))) > 10) { return fixup13(input_); } return fixup10(input_); @@ -84,7 +84,7 @@ TQValidator::State ISBNValidator::validate10(TQString& input_, int& pos_) const // A perfect ISBN has 9 digits plus either an 'X' or another digit // A perfect ISBN may have 2 or 3 hyphens // The final digit or 'X' is the correct check sum - static const TQRegExp isbn(TQString::tqfromLatin1("(\\d-?){9,11}-[\\dX]")); + static const TQRegExp isbn(TQString::fromLatin1("(\\d-?){9,11}-[\\dX]")); uint len = input_.length(); /* // Don't do this since the hyphens may be in the wrong place, can't put that in a regexp @@ -113,7 +113,7 @@ TQValidator::State ISBNValidator::validate10(TQString& input_, int& pos_) const // fix the case where the user attempts to delete the checksum; the // solution is to delete the last digit as well - static const TQRegExp digit(TQString::tqfromLatin1("\\d")); + static const TQRegExp digit(TQString::fromLatin1("\\d")); if(atEnd && input_.contains(digit) == 9 && input_[len-1] == '-') { input_.truncate(len-2); pos_ -= 2; @@ -139,7 +139,7 @@ TQValidator::State ISBNValidator::validate13(TQString& input_, int& pos_) const // A perfect ISBN13 has 13 digits // A perfect ISBN13 may have 3 or 4 hyphens // The final digit is the correct check sum - static const TQRegExp isbn(TQString::tqfromLatin1("(\\d-?){13,17}")); + static const TQRegExp isbn(TQString::fromLatin1("(\\d-?){13,17}")); uint len = input_.length(); const uint countX = input_.contains('X', false); @@ -166,7 +166,7 @@ TQValidator::State ISBNValidator::validate13(TQString& input_, int& pos_) const // fix the case where the user attempts to delete the checksum; the // solution is to delete the last digit as well - static const TQRegExp digit(TQString::tqfromLatin1("\\d")); + static const TQRegExp digit(TQString::fromLatin1("\\d")); const uint countN = input_.contains(digit); if(atEnd && (countN == 12 || countN == 9) && input_[len-1] == '-') { input_.truncate(len-2); @@ -199,10 +199,10 @@ void ISBNValidator::fixup10(TQString& input_) { } //replace "x" with "X" - input_.replace('x', TQString::tqfromLatin1("X")); + input_.replace('x', TQString::fromLatin1("X")); // remove invalid chars - static const TQRegExp badChars(TQString::tqfromLatin1("[^\\d-X]")); + static const TQRegExp badChars(TQString::fromLatin1("[^\\d-X]")); input_.remove(badChars); // special case for EAN values that start with 978 or 979. That's the case @@ -214,8 +214,8 @@ void ISBNValidator::fixup10(TQString& input_) { // I consider the likelihood that someone wants to input an EAN to be higher than someone // using a Nigerian ISBN and not noticing that the checksum gets added automatically. if(input_.length() > 12 - && (input_.startsWith(TQString::tqfromLatin1("978")) - || input_.startsWith(TQString::tqfromLatin1("979")))) { + && (input_.startsWith(TQString::fromLatin1("978")) + || input_.startsWith(TQString::fromLatin1("979")))) { // Strip the first 4 characters (the invalid publisher) input_ = input_.right(input_.length() - 3); } @@ -251,8 +251,8 @@ void ISBNValidator::fixup10(TQString& input_) { // If we can find it, add the checksum // but only if not started with 978 or 979 if(input_.length() > 8 - && !input_.startsWith(TQString::tqfromLatin1("978")) - && !input_.startsWith(TQString::tqfromLatin1("979"))) { + && !input_.startsWith(TQString::fromLatin1("978")) + && !input_.startsWith(TQString::fromLatin1("979"))) { input_[9] = checkSum10(input_); } @@ -293,7 +293,7 @@ void ISBNValidator::fixup13(TQString& input_) { } // remove invalid chars - static const TQRegExp badChars(TQString::tqfromLatin1("[^\\d-]")); + static const TQRegExp badChars(TQString::fromLatin1("[^\\d-]")); input_.remove(badChars); // hyphen placement for some languages publishers is well-defined |