summaryrefslogtreecommitdiff
authorzecke <zecke>2005-06-27 18:08:35 (UTC)
committer zecke <zecke>2005-06-27 18:08:35 (UTC)
commitcecffa1dc3a7bd1526be00e7bc4a4a151e6f2c9c (patch) (side-by-side diff)
treef1507ae7e0ba8d3c41e0381b84827c97823edeca
parent058e3b6b0bc8f29314ee794bf7e993ebf3bfe072 (diff)
downloadopie-cecffa1dc3a7bd1526be00e7bc4a4a151e6f2c9c.zip
opie-cecffa1dc3a7bd1526be00e7bc4a4a151e6f2c9c.tar.gz
opie-cecffa1dc3a7bd1526be00e7bc4a4a151e6f2c9c.tar.bz2
-Fix compile warning (signed vs unsigned)
-Somehow the split up patches missed the query string... (I knew I would mess up)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index 6aaa14c..f684f8c 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -603,97 +603,97 @@ UIDArray OPimContactAccessBackend_SQL::queryByExample ( const UIDArray& uidlist,
.arg( QString::number( startDate.month() ).rightJustify( 2, '0' ) )
.arg( QString::number( startDate.day() ).rightJustify( 2, '0' ) ) ;
}
if ( settings & OPimContactAccess::DateYear ){
searchQuery += QString( " (\"%1\" LIKE '%2-%')" )
.arg( *it )
.arg( QString::number( endDate->year() ).rightJustify( 4, '0' ) );
}
if ( settings & OPimContactAccess::DateMonth ){
if ( settings & OPimContactAccess::DateYear )
searchQuery += " AND";
searchQuery += QString( " (\"%1\" LIKE '%-%2-%')" )
.arg( *it )
.arg( QString::number( endDate->month() ).rightJustify( 2, '0' ) );
}
if ( settings & OPimContactAccess::DateDay ){
if ( ( settings & OPimContactAccess::DateYear )
|| ( settings & OPimContactAccess::DateMonth ) )
searchQuery += " AND";
searchQuery += QString( " (\"%1\" LIKE '%-%-%2')" )
.arg( *it )
.arg( QString::number( endDate->day() ).rightJustify( 2, '0' ) );
}
break;
default:
// Switching between case sensitive and insensitive...
// LIKE is not case sensitive, GLOB is case sensitive
// Do exist a better solution to switch this ?
if ( settings & OPimContactAccess::IgnoreCase )
searchQuery += " (\"" + *it + "\"" + " LIKE " + "'"
+ queryStr.replace(QRegExp("\\*"),"%") + "'" + ")";
else
searchQuery += " (\"" + *it + "\"" + " GLOB " + "'"
+ queryStr + "'" + ")";
}
}
delete endDate;
// The following if line is a replacement for
// if ( searchQuery.endsWith( "AND" ) )
- if ( searchQuery.findRev( "AND" ) == ( searchQuery.length() - 3 ) ){
+ if ( searchQuery.findRev( "AND" ) == static_cast<int>( searchQuery.length() - 3 ) ){
odebug << "remove AND" << oendl;
searchQuery.remove( searchQuery.length()-3, 3 ); // Hmmmm..
}
}
// Now compose the complete query
QString qu = "SELECT uid FROM addressbook WHERE " + uid_query;
if ( !datediff_query.isEmpty() && !searchQuery.isEmpty() ){
// If we use DateDiff, we have to intersect two queries.
qu = datediff_query + QString( " INTERSECT " ) + qu + searchQuery;
} else if ( datediff_query.isEmpty() && !searchQuery.isEmpty() ){
qu += searchQuery;
} else if ( !datediff_query.isEmpty() && searchQuery.isEmpty() ){
qu = datediff_query;
} else if ( datediff_query.isEmpty() && searchQuery.isEmpty() ){
UIDArray empty;
return empty;
}
odebug << "queryByExample query: " << qu << "" << oendl;
// Execute query and return the received uid's
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success ){
UIDArray empty;
return empty;
}
UIDArray list = extractUids( res );
return list;
}
UIDArray OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
{
#if 0
QArray<int> nix(0);
return nix;
#else
QString qu = "SELECT uid FROM addressbook WHERE (";
QString searchlist;
QStringList fieldList = OPimContactFields::untrfields( false );
// QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
@@ -828,96 +828,102 @@ UIDArray OPimContactAccessBackend_SQL::sorted( const UIDArray& ar, bool asc, int
}
query += " ORDER BY";
switch ( sortOrder ) {
case OPimContactAccess::SortSummary:
query += " \"Notes\"";
break;
case OPimContactAccess::SortByCategory:
query += " \"Categories\"";
break;
case OPimContactAccess::SortByDate:
query += " \"\"";
break;
case OPimContactAccess::SortTitle:
query += " \"Name Title\"";
break;
case OPimContactAccess::SortFirstName:
query += " \"First Name\"";
break;
case OPimContactAccess::SortMiddleName:
query += " \"Middle Name\"";
break;
case OPimContactAccess::SortLastName:
query += " \"Last Name\"";
break;
case OPimContactAccess::SortFileAsName:
query += " \"File As\"";
break;
case OPimContactAccess::SortSuffix:
query += " \"Suffix\"";
break;
case OPimContactAccess::SortEmail:
query += " \"Default Email\"";
break;
case OPimContactAccess::SortNickname:
query += " \"Nickname\"";
break;
case OPimContactAccess::SortAnniversary:
query += " \"Anniversary\"";
break;
case OPimContactAccess::SortBirthday:
query += " \"Birthday\"";
break;
case OPimContactAccess::SortGender:
query += " \"Gender\"";
break;
+ case OPimContactAccess::SortBirthdayWithoutYear:
+ query += " substr(\"Birthday\", 6, 10)";
+ break;
+ case OPimContactAccess::SortAnniversaryWithoutYear:
+ query += " substr(\"Anniversary\", 6, 10)";
+ break;
default:
query += " \"Last Name\"";
}
if ( !asc )
query += " DESC";
odebug << "sorted query is: " << query << "" << oendl;
OSQLRawQuery raw( query );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success ){
UIDArray empty;
return empty;
}
UIDArray list = extractUids( res );
odebug << "sorted needed " << t.elapsed() << " ms!" << oendl;
return list;
}
void OPimContactAccessBackend_SQL::update()
{
odebug << "Update starts" << oendl;
QTime t;
t.start();
// Now load the database set and extract the uid's
// which will be held locally
LoadQuery lo;
OSQLResult res = m_driver->query(&lo);
if ( res.state() != OSQLResult::Success )
return;
m_uids = extractUids( res );
m_changed = false;
odebug << "Update ends " << t.elapsed() << " ms" << oendl;
}
UIDArray OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
{
odebug << "extractUids" << oendl;