-rw-r--r-- | libopie2/opiedb/opiedb.pro | 3 | ||||
-rw-r--r-- | libopie2/opiedb/osqlbackend.cpp | 7 | ||||
-rw-r--r-- | libopie2/opiedb/osqlmanager.cpp | 7 |
3 files changed, 14 insertions, 3 deletions
diff --git a/libopie2/opiedb/opiedb.pro b/libopie2/opiedb/opiedb.pro index e5b1ac9..8432674 100644 --- a/libopie2/opiedb/opiedb.pro +++ b/libopie2/opiedb/opiedb.pro @@ -1,42 +1,43 @@ TEMPLATE = lib CONFIG += qt warn_on DESTDIR = $(OPIEDIR)/lib HEADERS = osqlbackend.h \ osqldriver.h \ osqlerror.h \ osqlmanager.h \ osqlquery.h \ osqlresult.h \ osqltable.h \ osqlbackendmanager.h \ osqlitedriver.h + SOURCES = osqlbackend.cpp \ osqldriver.cpp \ osqlerror.cpp \ osqlmanager.cpp \ osqlquery.cpp \ osqlresult.cpp \ osqltable.cpp \ osqlbackendmanager.cpp \ osqlitedriver.cpp -INTERFACES = + TARGET = opiedb2 VERSION = 1.9.0 INCLUDEPATH = $(OPIEDIR)/include DEPENDPATH = $(OPIEDIR)/include LIBS += -lopiecore2 -lqpe -lsqlite !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } !isEmpty( LIBSQLITE_INC_DIR ) { INCLUDEPATH = $$LIBSQLITE_INC_DIR $$INCLUDEPATH } !isEmpty( LIBSQLITE_LIB_DIR ) { LIBS = -L$$LIBSQLITE_LIB_DIR $$LIBS } diff --git a/libopie2/opiedb/osqlbackend.cpp b/libopie2/opiedb/osqlbackend.cpp index 6e5159f..aede7c1 100644 --- a/libopie2/opiedb/osqlbackend.cpp +++ b/libopie2/opiedb/osqlbackend.cpp @@ -1,75 +1,80 @@ #include "osqlbackend.h" -using namespace Opie::DB; +namespace Opie { +namespace DB { OSQLBackEnd::OSQLBackEnd( const QString& name, const QString& vendor, const QString& license, const QCString& lib ) : m_name( name), m_vendor( vendor), m_license( license ), m_lib( lib ) { m_default = false; m_pref = -1; } OSQLBackEnd::OSQLBackEnd( const OSQLBackEnd& back ) { (*this) = back; } OSQLBackEnd::~OSQLBackEnd() { } bool OSQLBackEnd::operator==( const OSQLBackEnd& other ) { if ( m_pref != other.m_pref ) return false; if ( m_default != other.m_default ) return false; if ( m_name != other.m_name ) return false; if ( m_vendor != other.m_vendor ) return false; if ( m_license != other.m_license ) return false; if ( m_lib != other.m_lib ) return false; return true; } OSQLBackEnd &OSQLBackEnd::operator=(const OSQLBackEnd& back ) { m_name = back.m_name; m_vendor = back.m_vendor; m_license = back.m_license; m_lib = back.m_lib; m_pref = back.m_pref; m_default = back.m_default; return *this; } QString OSQLBackEnd::name() const { return m_name; } QString OSQLBackEnd::vendor() const { return m_vendor; } QString OSQLBackEnd::license() const { return m_license; } QCString OSQLBackEnd::library() const { return m_lib; } bool OSQLBackEnd::isDefault()const { return m_default; } int OSQLBackEnd::preference()const { return m_pref; } void OSQLBackEnd::setName( const QString& name ) { m_name = name; } void OSQLBackEnd::setVendor( const QString& vendor ) { m_vendor = vendor; } void OSQLBackEnd::setLicense( const QString & license ) { m_license = license; } void OSQLBackEnd::setLibrary( const QCString& lib ) { m_lib = lib; } void OSQLBackEnd::setDefault( bool def) { m_default = def; } void OSQLBackEnd::setPreference( int pref ) { m_pref = pref; } + + +} +}
\ No newline at end of file diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp index a6498df..f093766 100644 --- a/libopie2/opiedb/osqlmanager.cpp +++ b/libopie2/opiedb/osqlmanager.cpp @@ -1,83 +1,88 @@ #include <stdlib.h> #include "osqlmanager.h" #include "osqlbackendmanager.h" #include "osqlitedriver.h" -using namespace Opie::DB; +namespace Opie { +namespace DB { OSQLManager::OSQLManager() { } OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { m_list.clear(); QString opie = QString::fromLatin1( getenv("OPIEDIR") ); QString qpe = QString::fromLatin1( getenv("QPEDIR") ); if ( !m_path.contains(opie) && !opie.isEmpty() ) m_path << opie; if ( !m_path.contains(qpe) && !qpe.isEmpty() ) m_path << qpe; OSQLBackEndManager mng( m_path ); m_list = mng.scan(); m_list += builtIn(); return m_list; } /* * loading dso's is currently not enabled due problems with QLibrary * beeing in libqpe and not libqte */ OSQLDriver* OSQLManager::load( const QString& name ) { OSQLDriver* driver = 0l; if ( name == "SQLite" ) { driver = new Opie::DB::Internal::OSQLiteDriver; } return driver; } /* * same as above */ OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { OSQLDriver *driver = 0l; if ( end.library() == "builtin" && end.name() == "SQLite" ) driver = new Opie::DB::Internal::OSQLiteDriver; return driver; } /* * let's find the a default with the highes preference */ OSQLDriver* OSQLManager::standard() { OSQLDriver* driver =0l; if ( m_list.isEmpty() ) queryBackEnd(); OSQLBackEnd::ValueList::Iterator it; OSQLBackEnd back; for ( it = m_list.begin(); it != m_list.end(); ++it ) { if ( (*it).isDefault() && back.preference() < (*it).preference() ) { back = (*it); } } driver = load( back ); return driver; } void OSQLManager::registerPath( const QString& path ) { m_path << path; } bool OSQLManager::unregisterPath( const QString& path ) { m_path.remove( path ); return true; } OSQLBackEnd::ValueList OSQLManager::builtIn()const { OSQLBackEnd::ValueList list; // create the OSQLiteBackend OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); back.setDefault( true ); back.setPreference( 50 ); list.append( back ); return list; } + + +} +} |