kexi

kexiprojectdata.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@gmx.at>
00003    Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
00004 
00005    This library 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 library 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 library; see the file COPYING.LIB.  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 <sys/types.h>
00022 #include <unistd.h>
00023 
00024 #include <qdom.h>
00025 #include <qdir.h>
00026 #include <qfile.h>
00027 #include <qregexp.h>
00028 
00029 #include <kglobal.h>
00030 #include <kstandarddirs.h>
00031 #include <kdebug.h>
00032 #include <kio/netaccess.h>
00033 #include <kurl.h>
00034 #include <klocale.h>
00035 #include <kmessagebox.h>
00036 
00037 #include <kexidb/drivermanager.h>
00038 #include "kexiprojectdata.h"
00039 
00040 
00042 class KexiProjectDataPrivate
00043 {
00044 public:
00045     KexiProjectDataPrivate()
00046      : finalMode(false)
00047     {}
00048     
00049     KexiDB::ConnectionData connData;
00050     QDateTime lastOpened;
00051     bool finalMode : 1;
00052 };
00053 
00054 //---------------------------------------
00055 
00056 KexiProjectData::KexiProjectData()
00057  : QObject(0, "KexiProjectData")
00058  , KexiDB::SchemaData()
00059  , formatVersion(0)
00060  , d( new KexiProjectDataPrivate() )
00061 {
00062 }
00063 
00064 KexiProjectData::KexiProjectData( 
00065     const KexiDB::ConnectionData &cdata, const QString& dbname, const QString& caption )
00066  : QObject(0, "KexiProjectData")
00067  , KexiDB::SchemaData()
00068  , formatVersion(0)
00069  , d( new KexiProjectDataPrivate() )
00070 {
00071     d->connData = cdata;
00072     setDatabaseName(dbname);
00073     setCaption(caption);
00074 }
00075 
00076 KexiProjectData::KexiProjectData( const KexiProjectData& pdata )
00077  : QObject(0, "KexiProjectData"), KexiDB::SchemaData()
00078  , d( 0 )
00079 {
00080     *this = pdata;
00081     autoopenObjects = pdata.autoopenObjects;
00082 /*
00083     d->connData = *pdata.connectionData();
00084     setDatabaseName(pdata.databaseName());
00085     setCaption(pdata.caption());*/
00086 }
00087 
00088 KexiProjectData::~KexiProjectData()
00089 {
00090     delete d;
00091 }
00092 
00093 KexiProjectData& KexiProjectData::operator=(const KexiProjectData& pdata)
00094 {
00095     delete d; //this is old
00096     static_cast<KexiDB::SchemaData&>(*this) = static_cast<const KexiDB::SchemaData&>(pdata);
00097     //deep copy
00098     d = new KexiProjectDataPrivate();
00099     *d = *pdata.d;
00100 //  d->connData = *pdata.constConnectionData();
00101 //  setDatabaseName(pdata.databaseName());
00102 //  setCaption(pdata.caption());
00103 //  setDescription(pdata.description());
00104     return *this;
00105 }
00106 
00107 KexiDB::ConnectionData* KexiProjectData::connectionData()
00108 {
00109     return &d->connData;
00110 }
00111 
00112 const KexiDB::ConnectionData* KexiProjectData::constConnectionData() const
00113 {
00114     return &d->connData;
00115 }
00116 
00117 QString KexiProjectData::databaseName() const
00118 {
00119     return KexiDB::SchemaData::name();
00120 }
00121 
00122 void KexiProjectData::setDatabaseName(const QString& dbName)
00123 {
00124     KexiDB::SchemaData::setName(dbName);
00125 }
00126 
00127 bool KexiProjectData::finalMode() const
00128 {
00129     return d->finalMode;
00130 }
00131 
00132 QDateTime KexiProjectData::lastOpened() const
00133 {
00134     return d->lastOpened;
00135 }
00136 
00137 void KexiProjectData::setLastOpened(const QDateTime& lastOpened)
00138 {
00139     d->lastOpened=lastOpened;
00140 
00141 }
00142 QString KexiProjectData::description() const
00143 {
00144     return KexiDB::SchemaData::description();
00145 }
00146 
00147 void KexiProjectData::setDescription(const QString& desc)
00148 {
00149     return KexiDB::SchemaData::setDescription(desc);
00150 }
00151 
00152 QString KexiProjectData::infoString(bool nobr) const
00153 {
00154     if (constConnectionData()->fileName().isEmpty()) {
00155         //server-based
00156         return QString(nobr ? "<nobr>" : "") + QString("\"%1\"").arg(databaseName()) + (nobr ? "</nobr>" : "")
00157             + (nobr ? " <nobr>" : " ") + i18n("database connection", "(connection %1)")
00158             .arg(constConnectionData()->serverInfoString()) + (nobr ? "</nobr>" : "");
00159     }
00160     //file-based
00161     return QString(nobr ? "<nobr>" : "") 
00162         + QString("\"%1\"").arg(constConnectionData()->fileName()) + (nobr ? "</nobr>" : "");
00163 }
KDE Home | KDE Accessibility Home | Description of Access Keys