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 
00178         KexiProjectData *data() const;
00179 
00183         KexiDialogBase* openObject(KexiMainWindow *wnd, KexiPart::Item& item, 
00184             int viewMode = Kexi::DataViewMode, QMap<QString,QString>* staticObjectArgs = 0);
00185 
00187         KexiDialogBase* openObject(KexiMainWindow *wnd, const QCString &mimeType, 
00188             const QString& name, int viewMode = Kexi::DataViewMode);
00189 
00192         bool removeObject(KexiMainWindow *wnd, KexiPart::Item& item);
00193 
00196         bool renameObject(KexiMainWindow *wnd, KexiPart::Item& item, const QString& newName);
00197 
00212         KexiPart::Item* createPartItem(KexiPart::Info *info, 
00213             const QString& suggestedCaption = QString::null );
00214 
00216         KexiPart::Item* createPartItem(KexiPart::Part *part, 
00217             const QString& suggestedCaption = QString::null);
00218 
00223         void addStoredItem(KexiPart::Info *info, KexiPart::Item *item);
00224 
00228         void deleteUnstoredItem(KexiPart::Item *item);
00229 
00230 #if 0 //remove?
00231 
00238         bool createObject(KexiDialogBase *dlg);
00239 #endif
00240 
00241         KexiDB::Parser* sqlParser();
00242 
00249         static KexiProject* createBlankProject(bool &cancelled, KexiProjectData* data,
00250             KexiDB::MessageHandler* handler = 0);
00251 
00254         static tristate dropProject(KexiProjectData* data, 
00255             KexiDB::MessageHandler* handler, bool dontAsk = false);
00256 
00258 //      void setQuerySchemaObsolete( const QString& queryName );
00259 
00260 //      /** used to emit objectCreated() signal */
00261 //      void emitObjectCreated(const QCString &mime, const QCString& name) { emit objectCreated(mime, name); }
00262 //      void emitTableCreated(KexiDB::TableSchema& schema) { emit tableCreated(schema); }
00263 
00264     protected:
00268         bool createConnection();
00269         
00270         bool closeConnection();
00271 
00272         bool initProject();
00273 
00275         tristate openInternal(bool *incompatibleWithKexi);
00276 
00296         bool createInternalStructures(bool insideTransaction);
00297 
00299         KexiPart::Part *findPartFor(KexiPart::Item& item);
00300 
00301     signals:
00303         void error(const QString &title, KexiDB::Object *obj);
00304 
00306         void error(const QString &msg, const QString &desc);
00307 
00309         void newItemStored(KexiPart::Item& item);
00310 
00312         void itemRemoved(const KexiPart::Item &item);
00313 
00315         void itemRenamed(const KexiPart::Item &item, const QCString& oldName);
00316 
00317 //      /** new table \a schema created */
00318 //      void tableCreated(KexiDB::TableSchema& schema);
00319 //      /** New object of mimetype \a mime and \a name has been created. */
00320 //      void objectCreated(const QCString &mime, const QCString& name);
00321 
00322     protected:
00325         bool checkWritable();
00326 
00327         class Private;
00328         Private *d;
00329 
00330         friend class KexiMainWindowImpl;
00331 };
00332 
00333 
00334 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys