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     adminTools = 0;
00046 
00047     properties["client_library_version"] = "";
00048     propertyCaptions["client_library_version"] =
00049       i18n("Client library version");
00050 
00051     properties["default_server_encoding"] = "";
00052     propertyCaptions["default_server_encoding"] =
00053       i18n("Default character encoding on server");
00054 }
00055 
00056 void DriverPrivate::initInternalProperties()
00057 {
00058     properties["is_file_database"] = QVariant(isFileDriver, 1);
00059     propertyCaptions["is_file_database"] = i18n("File-based database driver");
00060     if (isFileDriver) {
00061         properties["file_database_mimetype"] = fileDBDriverMimeType;
00062         propertyCaptions["file_database_mimetype"] = i18n("File-based database's MIME type");
00063     }
00064 
00065 #if 0
00066     QString str;
00067     if (features & Driver::SingleTransactions)
00068         str = i18n("Single transactions");
00069     else if (features & Driver::MultipleTransactions)
00070         str = i18n("Multiple transactions");
00071     else if (features & Driver::NestedTransactions)
00072         str = i18n("Nested transactions");
00073     else if (features & Driver::IgnoreTransactions)
00074         str = i18n("Ignored");
00075     else
00076         str = i18n("None");
00077 #endif
00078 //  properties["transaction_support"] = features & Driver::TransactionsMask;
00079 //  propertyCaptions["transaction_support"] = i18n("Transaction support");
00080     properties["transaction_single"] = QVariant(features & Driver::SingleTransactions, 1);
00081     propertyCaptions["transaction_single"] = i18n("Single transactions support");
00082     properties["transaction_multiple"] = QVariant(features & Driver::MultipleTransactions, 1);
00083     propertyCaptions["transaction_multiple"] = i18n("Multiple transactions support");
00084     properties["transaction_nested"] = QVariant(features & Driver::NestedTransactions, 1);
00085     propertyCaptions["transaction_nested"] = i18n("Nested transactions support");
00086 
00087     properties["kexidb_driver_version"] =
00088       QString("%1.%2").arg(version().major).arg(version().minor);
00089     propertyCaptions["kexidb_driver_version"] =
00090       i18n("KexiDB driver version");
00091 }
00092 
00093 DriverPrivate::~DriverPrivate()
00094 {
00095     delete driverSQLDict;
00096     delete adminTools;
00097 }
00098 
00099 
00100 void DriverPrivate::initKexiKeywords() {
00101     // QAsciiDict constructor args:
00102     //   size (preferable prime)
00103     //   case sensitive flag (false)
00104     //   copy strings (false)
00105     if(!kexiSQLDict) {
00106         kexiSQLDict = new QAsciiDict<bool>(79, false, false);
00107         initKeywords(kexiSQLKeywords, *kexiSQLDict);
00108     }
00109 }
00110 
00111 void DriverPrivate::initDriverKeywords(const char* keywords[], int hashSize) {
00112     driverSQLDict = new QAsciiDict<bool>(hashSize, false, false);
00113     initKeywords(keywords, *driverSQLDict);
00114 }
00115 
00116 void DriverPrivate::initKeywords(const char* keywords[], 
00117     QAsciiDict<bool>& dict) {
00118     for(int i = 0; keywords[i] != 0; i++) {
00119         dict.insert(keywords[i], &_dummy);
00120     }
00121 }
00122 
00123 AdminTools::Private::Private()
00124 {
00125 }
00126 
00127 AdminTools::Private::~Private()
00128 {
00129 }
KDE Home | KDE Accessibility Home | Description of Access Keys