kexi

driver_p.cpp

00001 /* This file is part of the KDE project
00002     Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
00003     Copyright (C) 2004 Martin Ellis <martin.ellis@kdemail.net>
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this program; see the file COPYING.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <kdebug.h>
00022 #include <qdict.h>
00023 #include <qvaluevector.h>
00024 #include "driver_p.h"
00025 
00026 using namespace KexiDB;
00027 
00028 namespace KexiDB {
00029     QAsciiDict<bool>* DriverPrivate::kexiSQLDict = 0;
00030     
00034   static bool _dummy;
00035 }
00036 
00037 
00038 DriverPrivate::DriverPrivate()
00039  : isFileDriver(false)
00040  , isDBOpenedAfterCreate(false)
00041  , features(Driver::NoFeatures)
00042 {
00043     kexiSQLDict = 0;
00044     driverSQLDict = 0;
00045 
00046     properties["client_library_version"] = "";
00047     propertyCaptions["client_library_version"] =
00048       i18n("Client library version");
00049 
00050     properties["default_server_encoding"] = "";
00051     propertyCaptions["default_server_encoding"] =
00052       i18n("Default character encoding on server");
00053 }
00054 
00055 void DriverPrivate::initInternalProperties()
00056 {
00057     properties["is_file_database"] = QVariant(isFileDriver, 1);
00058     propertyCaptions["is_file_database"] = i18n("File-based database driver");
00059     if (isFileDriver) {
00060         properties["file_database_mimetype"] = fileDBDriverMimeType;
00061         propertyCaptions["file_database_mimetype"] = i18n("File-based database's MIME type");
00062     }
00063 
00064 #if 0
00065     QString str;
00066     if (features & Driver::SingleTransactions)
00067         str = i18n("Single transactions");
00068     else if (features & Driver::MultipleTransactions)
00069         str = i18n("Multiple transactions");
00070     else if (features & Driver::NestedTransactions)
00071         str = i18n("Nested transactions");
00072     else if (features & Driver::IgnoreTransactions)
00073         str = i18n("Ignored");
00074     else
00075         str = i18n("None");
00076 #endif
00077 //  properties["transaction_support"] = features & Driver::TransactionsMask;
00078 //  propertyCaptions["transaction_support"] = i18n("Transaction support");
00079     properties["transaction_single"] = QVariant(features & Driver::SingleTransactions, 1);
00080     propertyCaptions["transaction_single"] = i18n("Single transactions support");
00081     properties["transaction_multiple"] = QVariant(features & Driver::MultipleTransactions, 1);
00082     propertyCaptions["transaction_multiple"] = i18n("Multiple transactions support");
00083     properties["transaction_nested"] = QVariant(features & Driver::NestedTransactions, 1);
00084     propertyCaptions["transaction_nested"] = i18n("Nested transactions support");
00085 
00086     properties["kexidb_driver_version"] =
00087       QString("%1.%2").arg(versionMajor()).arg(versionMinor());
00088     propertyCaptions["kexidb_driver_version"] =
00089       i18n("KexiDB driver version");
00090 }
00091 
00092 DriverPrivate::~DriverPrivate() {
00093     delete driverSQLDict;
00094 }
00095 
00096 
00097 void DriverPrivate::initKexiKeywords() {
00098     // QAsciiDict constructor args:
00099     //   size (preferable prime)
00100     //   case sensitive flag (false)
00101     //   copy strings (false)
00102     if(!kexiSQLDict) {
00103         kexiSQLDict = new QAsciiDict<bool>(79, false, false);
00104         initKeywords(kexiSQLKeywords, *kexiSQLDict);
00105     }
00106 }
00107 
00108 void DriverPrivate::initDriverKeywords(const char* keywords[], int hashSize) {
00109     driverSQLDict = new QAsciiDict<bool>(hashSize, false, false);
00110     initKeywords(keywords, *driverSQLDict);
00111 }
00112 
00113 void DriverPrivate::initKeywords(const char* keywords[], 
00114     QAsciiDict<bool>& dict) {
00115     for(int i = 0; keywords[i] != 0; i++) {
00116         dict.insert(keywords[i], &_dummy);
00117     }
00118 }
00119 
KDE Home | KDE Accessibility Home | Description of Access Keys