summaryrefslogtreecommitdiff
authorerik <erik>2007-01-31 21:57:44 (UTC)
committer erik <erik>2007-01-31 21:57:44 (UTC)
commit958e042c5a4d4e38fd1baae50b78a2febfd306ab (patch) (side-by-side diff)
tree7d86d03549cea01b03ce08926624a50fb086890c
parent6b321230cf24e50b11783b3511a457f22ae79a58 (diff)
downloadopie-958e042c5a4d4e38fd1baae50b78a2febfd306ab.zip
opie-958e042c5a4d4e38fd1baae50b78a2febfd306ab.tar.gz
opie-958e042c5a4d4e38fd1baae50b78a2febfd306ab.tar.bz2
The queryByExample member function was not properly overridden by the child
class. This means that the last child in the chain would be called instead. Seeing as how the function is not really implemented in this class I am sure that they do want the override so a user is A. not fooled into thinking it is and B. running into a parent function doing the wrong thing.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp2
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index 629e4da..78c3bf7 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -162,97 +162,97 @@ bool ODateBookAccessBackend_SQL::load()
QMap<int, QString>::Iterator it;
for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
}
qu += " );";
qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success )
return false;
update();
return true;
}
void ODateBookAccessBackend_SQL::update()
{
QString qu = "select uid from datebook";
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
if ( res.state() != OSQLResult::Success ){
// m_uids.clear();
return;
}
m_uids = extractUids( res );
}
bool ODateBookAccessBackend_SQL::reload()
{
return load();
}
bool ODateBookAccessBackend_SQL::save()
{
return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
}
QArray<int> ODateBookAccessBackend_SQL::allRecords()const
{
return m_uids;
}
-QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) {
+QArray<int> ODateBookAccessBackend_SQL::queryByExample(const int& unUsed, int settings, const QDateTime& ) {
qDebug( "Accessing ODateBookAccessBackend_SQL::queryByExample() which is not implemented!" );
return QArray<int>();
}
void ODateBookAccessBackend_SQL::clear()
{
QString qu = "drop table datebook;";
qu += "drop table custom_data;";
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
reload();
}
OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{
odebug << "ODateBookAccessBackend_SQL::find( " << uid << " )" << oendl;
QString qu = "select *";
qu += "from datebook where uid = " + QString::number(uid);
odebug << "Query: " << qu << "" << oendl;
OSQLRawQuery raw( qu );
OSQLResult res = m_driver->query( &raw );
OSQLResultItem resItem = res.first();
// Create Map for date event and insert UID
QMap<int,QString> dateEventMap;
dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) );
// Now insert the data out of the columns into the map.
QMapConstIterator<int, QString> it;
for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) );
}
// Last step: Put map into date event, add custom map and return it
OPimEvent retDate( dateEventMap );
retDate.setExtraMap( requestCustom( uid ) );
odebug << "ODateBookAccessBackend_SQL::find( " << uid << " ) end" << oendl;
return retDate;
}
// FIXME: Speed up update of uid's..
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
index a649d25..2de2dca 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
@@ -14,85 +14,85 @@
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
#include <qmap.h>
#include <opie2/osqlresult.h>
#include <opie2/odatebookaccessbackend.h>
namespace Opie {
namespace DB {
class OSQLDriver;
}
}
namespace Opie {
/**
* This is the default SQL implementation for DateBoook SQL storage
* It fully implements the interface
* @see ODateBookAccessBackend
* @see OPimAccessBackend
*/
class ODateBookAccessBackend_SQL : public ODateBookAccessBackend {
public:
ODateBookAccessBackend_SQL( const QString& appName,
const QString& fileName = QString::null);
~ODateBookAccessBackend_SQL();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> matchRegexp(const QRegExp &r) const;
- QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() );
+ QArray<int> queryByExample( const int& unUsed, int settings, const QDateTime& d = QDateTime() );
OPimEvent find( int uid )const;
void clear();
bool add( const OPimEvent& ev );
bool remove( int uid );
bool replace( const OPimEvent& ev );
QArray<UID> rawRepeats()const;
QArray<UID> nonRepeats()const;
OPimEvent::ValueList directNonRepeats()const;
OPimEvent::ValueList directRawRepeats()const;
private:
bool loadFile();
QString m_fileName;
QArray<int> m_uids;
QMap<int, QString> m_fieldMap;
QMap<QString, int> m_reverseFieldMap;
Opie::DB::OSQLDriver* m_driver;
class Private;
Private *d;
void initFields();
void update();
QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
QMap<QString, QString> requestCustom( int uid ) const;
};
}
#endif