kexi

kexiproject.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2003-2006 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 #ifndef KEXIPROJECT_H
00022 #define KEXIPROJECT_H
00023 
00024 #include <qobject.h>
00025 #include <qintdict.h>
00026 #include <qptrdict.h>
00027 #include <qguardedptr.h>
00028 
00029 #include <kexiutils/tristate.h>
00030 #include <kexidb/object.h>
00031 #include "kexiprojectdata.h"
00032 #include "kexipartitem.h"
00033 #include "kexi.h"
00034 
00042 #define KEXIPROJECT_VERSION_MAJOR 1
00043 #define KEXIPROJECT_VERSION_MINOR 0
00044 
00045 namespace KexiDB
00046 {
00047     class DriverManager;
00048     class Driver;
00049     class Connection;
00050     class Parser;
00051 }
00052 
00053 namespace KexiPart
00054 {
00055     class Part;
00056     class Info;
00057 }
00058 
00059 class KexiMainWindow;
00060 class KexiDialogBase;
00061 
00067 class KEXICORE_EXPORT KexiProject : public QObject, public KexiDB::Object
00068 {
00069     Q_OBJECT
00070 
00071     public:
00076         KexiProject(KexiProjectData* pdata, KexiDB::MessageHandler* handler = 0);
00077 
00082         KexiProject(KexiProjectData *pdata, KexiDB::MessageHandler* handler, 
00083             KexiDB::Connection* conn);
00084 
00085 //      KexiProject(KexiDB::ConnectionData *cdata);
00086 
00087         ~KexiProject();
00088 
00091         int versionMajor() const;
00092 
00095         int versionMinor() const;
00096 
00099         tristate open();
00100 
00111         tristate open(bool &incompatibleWithKexi);
00112 
00122         tristate create(bool forceOverwrite = false);
00123 
00125         bool error() const { return KexiDB::Object::error(); }
00126 
00130         bool isConnected();
00131 
00135         KexiPart::ItemDict* items(KexiPart::Info *i);
00136 
00141         KexiPart::ItemDict* itemsForMimeType(const QCString &mimeType);
00142 
00147         void getSortedItems(KexiPart::ItemList& list, KexiPart::Info *i);
00148 
00153         void getSortedItemsForMimeType(KexiPart::ItemList& list, const QCString &mimeType);
00154 
00158         KexiPart::Item* itemForMimeType(const QCString &mimeType, const QString &name);
00159 
00163         KexiPart::Item* item(KexiPart::Info *i, const QString &name);
00164 
00168         KexiPart::Item* item(int identifier);
00169 
00173         KexiDB::Connection *dbConnection() const;
00174 
00175         KexiProjectData *data() const;
00176 
00180         KexiDialogBase* openObject(KexiMainWindow *wnd, KexiPart::Item& item, 
00181             int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0);
00182 
00184         KexiDialogBase* openObject(KexiMainWindow *wnd, const QCString &mimeType, 
00185             const QString& name, int viewMode = Kexi::DataViewMode);
00186 
00189         bool removeObject(KexiMainWindow *wnd, KexiPart::Item& item);
00190 
00193         bool renameObject(KexiMainWindow *wnd, KexiPart::Item& item, const QString& newName);
00194 
00209         KexiPart::Item* createPartItem(KexiPart::Info *info, 
00210             const QString& suggestedCaption = QString::null );
00211 
00213         KexiPart::Item* createPartItem(KexiPart::Part *part, 
00214             const QString& suggestedCaption = QString::null);
00215 
00220         void addStoredItem(KexiPart::Info *info, KexiPart::Item *item);
00221 
00225         void deleteUnstoredItem(KexiPart::Item *item);
00226 
00227 #if 0 //remove?
00228 
00235         bool createObject(KexiDialogBase *dlg);
00236 #endif
00237 
00238         KexiDB::Parser* sqlParser();
00239 
00241         bool final() const;
00242 
00243         void setFinal(bool set);
00244 
00251         static KexiProject* createBlankProject(bool &cancelled, KexiProjectData* data,
00252             KexiDB::MessageHandler* handler = 0);
00253 
00256         static tristate dropProject(KexiProjectData* data, 
00257             KexiDB::MessageHandler* handler, bool dontAsk = false);
00258 
00260 //      void setQuerySchemaObsolete( const QString& queryName );
00261 
00262 //      /** used to emit objectCreated() signal */
00263 //      void emitObjectCreated(const QCString &mime, const QCString& name) { emit objectCreated(mime, name); }
00264 //      void emitTableCreated(KexiDB::TableSchema& schema) { emit tableCreated(schema); }
00265 
00266     protected:
00269         bool createConnection();
00270         
00271         void closeConnection();
00272 
00273         bool initProject();
00274 
00276         tristate openInternal(bool *incompatibleWithKexi);
00277 
00297         bool createInternalStructures(bool insideTransaction);
00298 
00300         KexiPart::Part *findPartFor(KexiPart::Item& item);
00301 
00302     signals:
00304         void error(const QString &title, KexiDB::Object *obj);
00305 
00307         void error(const QString &msg, const QString &desc);
00308 
00310         void newItemStored(KexiPart::Item& item);
00311 
00313         void itemRemoved(const KexiPart::Item &item);
00314 
00316         void itemRenamed(const KexiPart::Item &item, const QCString& oldName);
00317 
00318 //      /** new table \a schema created */
00319 //      void tableCreated(KexiDB::TableSchema& schema);
00320 //      /** New object of mimetype \a mime and \a name has been created. */
00321 //      void objectCreated(const QCString &mime, const QCString& name);
00322 
00323     protected:
00326         bool checkWritable();
00327 
00328         class Private;
00329         Private *d;
00330 
00331         friend class KexiMainWindowImpl;
00332 };
00333 
00334 
00335 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys