diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-02 06:40:27 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-07-02 06:40:27 +0000 |
commit | 2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 (patch) | |
tree | 18a8f0f4ac5a86dacfa74c3537551ec39bc85e75 /src/listviewcomparison.cpp | |
parent | 1d90725a4001fab9d3922b2cbcceeee5e2d1686f (diff) | |
download | tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.tar.gz tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.zip |
TQt4 port tellico
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1239054 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/listviewcomparison.cpp')
-rw-r--r-- | src/listviewcomparison.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/listviewcomparison.cpp b/src/listviewcomparison.cpp index 9bdd10c..e15b1d8 100644 --- a/src/listviewcomparison.cpp +++ b/src/listviewcomparison.cpp @@ -18,13 +18,13 @@ #include "document.h" #include "entryitem.h" -#include <qlistview.h> -#include <qiconview.h> -#include <qpixmap.h> -#include <qdatetime.h> +#include <tqlistview.h> +#include <tqiconview.h> +#include <tqpixmap.h> +#include <tqdatetime.h> namespace { - int compareFloat(const QString& s1, const QString& s2) { + int compareFloat(const TQString& s1, const TQString& s2) { bool ok1, ok2; float n1 = s1.toFloat(&ok1); float n2 = s2.toFloat(&ok2); @@ -51,7 +51,7 @@ Tellico::ListViewComparison* Tellico::ListViewComparison::create(Data::ConstFiel } else if(field_->formatFlag() == Data::Field::FormatTitle) { // Dependent could be title, so put this test after return new TitleComparison(field_); - } else if(field_->property(QString::fromLatin1("lcc")) == Latin1Literal("true") || + } else if(field_->property(TQString::tqfromLatin1("lcc")) == Latin1Literal("true") || (field_->name() == Latin1Literal("lcc") && Data::Document::self()->collection() && (Data::Document::self()->collection()->type() == Data::Collection::Book || @@ -73,8 +73,8 @@ int Tellico::ListViewComparison::compare(int col_, return compare(item1_->key(col_, asc_), item2_->key(col_, asc_)); } -int Tellico::ListViewComparison::compare(const QIconViewItem* item1_, - const QIconViewItem* item2_) +int Tellico::ListViewComparison::compare(const TQIconViewItem* item1_, + const TQIconViewItem* item2_) { return compare(item1_->key(), item2_->key()); } @@ -82,23 +82,23 @@ int Tellico::ListViewComparison::compare(const QIconViewItem* item1_, Tellico::StringComparison::StringComparison(Data::ConstFieldPtr field) : ListViewComparison(field) { } -int Tellico::StringComparison::compare(const QString& str1_, const QString& str2_) { +int Tellico::StringComparison::compare(const TQString& str1_, const TQString& str2_) { return str1_.localeAwareCompare(str2_); } Tellico::TitleComparison::TitleComparison(Data::ConstFieldPtr field) : ListViewComparison(field) { } -int Tellico::TitleComparison::compare(const QString& str1_, const QString& str2_) { - const QString title1 = Data::Field::sortKeyTitle(str1_); - const QString title2 = Data::Field::sortKeyTitle(str2_); +int Tellico::TitleComparison::compare(const TQString& str1_, const TQString& str2_) { + const TQString title1 = Data::Field::sortKeyTitle(str1_); + const TQString title2 = Data::Field::sortKeyTitle(str2_); return title1.localeAwareCompare(title2); } Tellico::NumberComparison::NumberComparison(Data::ConstFieldPtr field) : ListViewComparison(field) { } -int Tellico::NumberComparison::compare(const QString& str1_, const QString& str2_) { +int Tellico::NumberComparison::compare(const TQString& str1_, const TQString& str2_) { // by default, an empty string would get sorted before "1" because toFloat() turns it into "0" // I want the empty strings to be at the end bool ok1, ok2; @@ -119,15 +119,15 @@ int Tellico::NumberComparison::compare(const QString& str1_, const QString& str2 // http://www.mcgees.org/2001/08/08/sort-by-library-of-congress-call-number-in-perl/ Tellico::LCCComparison::LCCComparison(Data::ConstFieldPtr field) : StringComparison(field), - m_regexp(QString::fromLatin1("^([A-Z]+)(\\d+(?:\\.\\d+)?)\\.?([A-Z]*)(\\d*)\\.?([A-Z]*)(\\d*)(?: (\\d\\d\\d\\d))?")) { + m_regexp(TQString::tqfromLatin1("^([A-Z]+)(\\d+(?:\\.\\d+)?)\\.?([A-Z]*)(\\d*)\\.?([A-Z]*)(\\d*)(?: (\\d\\d\\d\\d))?")) { } -int Tellico::LCCComparison::compare(const QString& str1_, const QString& str2_) { +int Tellico::LCCComparison::compare(const TQString& str1_, const TQString& str2_) { // myDebug() << "LCCComparison::compare() - " << str1_ << " to " << str2_ << endl; int pos1 = m_regexp.search(str1_); - const QStringList cap1 = m_regexp.capturedTexts(); + const TQStringList cap1 = m_regexp.tqcapturedTexts(); int pos2 = m_regexp.search(str2_); - const QStringList cap2 = m_regexp.capturedTexts(); + const TQStringList cap2 = m_regexp.tqcapturedTexts(); if(pos1 > -1 && pos2 > -1) { int res = compareLCC(cap1, cap2); // myLog() << "...result = " << res << endl; @@ -136,17 +136,17 @@ int Tellico::LCCComparison::compare(const QString& str1_, const QString& str2_) return StringComparison::compare(str1_, str2_); } -int Tellico::LCCComparison::compareLCC(const QStringList& cap1, const QStringList& cap2) const { +int Tellico::LCCComparison::compareLCC(const TQStringList& cap1, const TQStringList& cap2) const { // the first item in the list is the full match, so start array index at 1 int res = 0; return (res = cap1[1].compare(cap2[1])) != 0 ? res : (res = compareFloat(cap1[2], cap2[2])) != 0 ? res : (res = cap1[3].compare(cap2[3])) != 0 ? res : - (res = compareFloat(QString::fromLatin1("0.") + cap1[4], - QString::fromLatin1("0.") + cap2[4])) != 0 ? res : + (res = compareFloat(TQString::tqfromLatin1("0.") + cap1[4], + TQString::tqfromLatin1("0.") + cap2[4])) != 0 ? res : (res = cap1[5].compare(cap2[5])) != 0 ? res : - (res = compareFloat(QString::fromLatin1("0.") + cap1[6], - QString::fromLatin1("0.") + cap2[6])) != 0 ? res : + (res = compareFloat(TQString::tqfromLatin1("0.") + cap1[6], + TQString::tqfromLatin1("0.") + cap2[6])) != 0 ? res : (res = compareFloat(cap1[7], cap2[7])) != 0 ? res : 0; } @@ -159,8 +159,8 @@ int Tellico::PixmapComparison::compare(int col_, bool asc_) { Q_UNUSED(asc_); - const QPixmap* pix1 = item1_->pixmap(col_); - const QPixmap* pix2 = item2_->pixmap(col_); + const TQPixmap* pix1 = item1_->pixmap(col_); + const TQPixmap* pix2 = item2_->pixmap(col_); if(pix1 && !pix1->isNull()) { if(pix2 && !pix2->isNull()) { // large images come first @@ -173,11 +173,11 @@ int Tellico::PixmapComparison::compare(int col_, return 0; } -int Tellico::PixmapComparison::compare(const QIconViewItem* item1_, - const QIconViewItem* item2_) +int Tellico::PixmapComparison::compare(const TQIconViewItem* item1_, + const TQIconViewItem* item2_) { - const QPixmap* pix1 = item1_->pixmap(); - const QPixmap* pix2 = item2_->pixmap(); + const TQPixmap* pix1 = item1_->pixmap(); + const TQPixmap* pix2 = item2_->pixmap(); if(pix1 && !pix1->isNull()) { if(pix2 && !pix2->isNull()) { // large images come first @@ -205,7 +205,7 @@ int Tellico::DependentComparison::compare(int col_, { Q_UNUSED(col_); Q_UNUSED(asc_); - for(QPtrListIterator<ListViewComparison> it(m_comparisons); it.current(); ++it) { + for(TQPtrListIterator<ListViewComparison> it(m_comparisons); it.current(); ++it) { int res = it.current()->compare(col_, item1_, item2_, asc_); if(res != 0) { return res; @@ -214,10 +214,10 @@ int Tellico::DependentComparison::compare(int col_, return ListViewComparison::compare(col_, item1_, item2_, asc_); } -int Tellico::DependentComparison::compare(const QIconViewItem* item1_, - const QIconViewItem* item2_) +int Tellico::DependentComparison::compare(const TQIconViewItem* item1_, + const TQIconViewItem* item2_) { - for(QPtrListIterator<ListViewComparison> it(m_comparisons); it.current(); ++it) { + for(TQPtrListIterator<ListViewComparison> it(m_comparisons); it.current(); ++it) { int res = it.current()->compare(item1_, item2_); if(res != 0) { return res; @@ -229,7 +229,7 @@ int Tellico::DependentComparison::compare(const QIconViewItem* item1_, Tellico::ISODateComparison::ISODateComparison(Data::ConstFieldPtr field) : ListViewComparison(field) { } -int Tellico::ISODateComparison::compare(const QString& str1, const QString& str2) { +int Tellico::ISODateComparison::compare(const TQString& str1, const TQString& str2) { if(str1.isEmpty()) { return str2.isEmpty() ? 0 : -1; } @@ -239,11 +239,11 @@ int Tellico::ISODateComparison::compare(const QString& str1, const QString& str2 // modelled after Field::formatDate() // so dates would sort as expected without padding month and day with zero // and accounting for "current year - 1 - 1" default scheme - QStringList dlist1 = QStringList::split('-', str1, true); + TQStringList dlist1 = TQStringList::split('-', str1, true); bool ok = true; - int y1 = dlist1.count() > 0 ? dlist1[0].toInt(&ok) : QDate::currentDate().year(); + int y1 = dlist1.count() > 0 ? dlist1[0].toInt(&ok) : TQDate::tqcurrentDate().year(); if(!ok) { - y1 = QDate::currentDate().year(); + y1 = TQDate::tqcurrentDate().year(); } int m1 = dlist1.count() > 1 ? dlist1[1].toInt(&ok) : 1; if(!ok) { @@ -253,12 +253,12 @@ int Tellico::ISODateComparison::compare(const QString& str1, const QString& str2 if(!ok) { d1 = 1; } - QDate date1(y1, m1, d1); + TQDate date1(y1, m1, d1); - QStringList dlist2 = QStringList::split('-', str2, true); - int y2 = dlist2.count() > 0 ? dlist2[0].toInt(&ok) : QDate::currentDate().year(); + TQStringList dlist2 = TQStringList::split('-', str2, true); + int y2 = dlist2.count() > 0 ? dlist2[0].toInt(&ok) : TQDate::tqcurrentDate().year(); if(!ok) { - y2 = QDate::currentDate().year(); + y2 = TQDate::tqcurrentDate().year(); } int m2 = dlist2.count() > 1 ? dlist2[1].toInt(&ok) : 1; if(!ok) { @@ -268,7 +268,7 @@ int Tellico::ISODateComparison::compare(const QString& str1, const QString& str2 if(!ok) { d2 = 1; } - QDate date2(y2, m2, d2); + TQDate date2(y2, m2, d2); if(date1 < date2) { return -1; |