author | zecke <zecke> | 2004-03-13 19:51:45 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-13 19:51:45 (UTC) |
commit | 6d08277737e22b7a1527124623f3571969073ddf (patch) (side-by-side diff) | |
tree | 4129e674e21df767b31299e873dd44e33a308e1b /libopie2/opiedb/osqlbackendmanager.cpp | |
parent | 8e28911f7199f4450ac5eef09482069f9b9caea2 (diff) | |
download | opie-6d08277737e22b7a1527124623f3571969073ddf.zip opie-6d08277737e22b7a1527124623f3571969073ddf.tar.gz opie-6d08277737e22b7a1527124623f3571969073ddf.tar.bz2 |
Move XML class to internal PIM
Add namespaces!!!
Opie::Core and Opie::Core::Private
Opie::Net and Opie::Net::Private
Opie::Ui and Opie::Ui::Private
Opie::MM and Opie::MM::Private
Opie::DB and Opie::DB::Private
PIM classes are not yet converted because we will do other work
on it as well
Diffstat (limited to 'libopie2/opiedb/osqlbackendmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiedb/osqlbackendmanager.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libopie2/opiedb/osqlbackendmanager.cpp b/libopie2/opiedb/osqlbackendmanager.cpp index 95ed77b..fc18e07 100644 --- a/libopie2/opiedb/osqlbackendmanager.cpp +++ b/libopie2/opiedb/osqlbackendmanager.cpp @@ -1,98 +1,106 @@ #include <qdir.h> #include <qmap.h> #include "osqlbackendmanager.h" +/** + * \todo FIXME CONFIG!!! + */ + namespace { class Config { typedef QMap<QString, QString> List; public: Config( const QString& fileName ); /** * Quite simple layout in nature * BeginFile * Key = Value */ bool load(); QString value( const QString& key ); private: List m_list; QString m_fileName; }; Config::Config( const QString& fileName ) : m_fileName( fileName ) { } bool Config::load() { if (!QFile::exists( m_fileName ) ) return false; QFile file( m_fileName ); if (!file.open(IO_ReadOnly ) ) return false; QStringList list = QStringList::split( '\n', file.readAll() ); QStringList::Iterator it; QString line; for (it = list.begin(); it != list.end(); ++it ) { line = (*it).stripWhiteSpace(); qWarning("Anonymous::Config:" + line ); QStringList test = QStringList::split(' ', line ); m_list.insert( test[0], test[2] ); } return true; } QString Config::value( const QString& key ) { return m_list[key]; } }; + + +using namespace Opie::DB; + OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) :m_path( path ) { } OSQLBackEndManager::~OSQLBackEndManager() { } /** * scan dirs */ OSQLBackEnd::ValueList OSQLBackEndManager::scan() { OSQLBackEnd::ValueList list; if (!m_path.isEmpty() ) { QStringList::Iterator it; for ( it = m_path.begin(); it != m_path.end(); ++it ) { list += scanDir( (*it) ); } } return list; } /** * scan a specified dir for *.osql */ OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) { OSQLBackEnd::ValueList list; QDir dir( dirName ); if (dir.exists() ) { QStringList files = dir.entryList( "*.osql" ); QStringList::Iterator it; for ( it = files.begin(); it != files.end(); ++it ) { list.append( file2backend( (*it) ) ); } } return list; } /** * read a config file and convert it to a OSQLBackEnd */ OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { OSQLBackEnd end; qWarning("fileName: " + file ); Config cfg( file ); if (cfg.load() ) { end.setName( cfg.value( "Name") ); end.setVendor( cfg.value("Vendor") ); end.setLicense( cfg.value("License") ); end.setLibrary( cfg.value("Library").local8Bit() ); end.setDefault( cfg.value("Default").toInt() ); end.setPreference( cfg.value("Preference").toInt() ); } return end; } |