kexi

kexiproject.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3 Copyright (C) 2003-2006 Jaroslaw Staniek <js@iidea.pl>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KEXIPROJECT_H
22#define KEXIPROJECT_H
23
24#include <tqobject.h>
25#include <tqintdict.h>
26#include <tqptrdict.h>
27#include <tqguardedptr.h>
28
29#include <kexiutils/tristate.h>
30#include <kexidb/object.h>
31#include "kexiprojectdata.h"
32#include "kexipartitem.h"
33#include "kexi.h"
34
41
42#define KEXIPROJECT_VERSION_MAJOR 1
43#define KEXIPROJECT_VERSION_MINOR 0
44
45namespace KexiDB
46{
47 class DriverManager;
48 class Driver;
49 class Connection;
50 class Parser;
51}
52
53namespace KexiPart
54{
55 class Part;
56 class Info;
57}
58
59class KexiMainWindow;
60class KexiDialogBase;
61
67class KEXICORE_EXPORT KexiProject : public TQObject, public KexiDB::Object
68{
69 TQ_OBJECT
70
71
72 public:
78
84 KexiDB::Connection* conn);
85
86// KexiProject(KexiDB::ConnectionData *cdata);
87
89
92 int versionMajor() const;
93
96 int versionMinor() const;
97
100 tristate open();
101
112 tristate open(bool &incompatibleWithKexi);
113
123 tristate create(bool forceOverwrite = false);
124
126 bool error() const { return KexiDB::Object::error(); }
127
131 bool isConnected();
132
136 KexiPart::ItemDict* items(KexiPart::Info *i);
137
142 KexiPart::ItemDict* itemsForMimeType(const TQCString &mimeType);
143
148 void getSortedItems(KexiPart::ItemList& list, KexiPart::Info *i);
149
154 void getSortedItemsForMimeType(KexiPart::ItemList& list, const TQCString &mimeType);
155
159 KexiPart::Item* itemForMimeType(const TQCString &mimeType, const TQString &name);
160
164 KexiPart::Item* item(KexiPart::Info *i, const TQString &name);
165
169 KexiPart::Item* item(int identifier);
170
174 KexiDB::Connection *dbConnection() const;
175
179 KexiProjectData *data() const;
180
184 KexiDialogBase* openObject(KexiMainWindow *wnd, KexiPart::Item& item,
185 int viewMode = Kexi::DataViewMode, TQMap<TQString,TQString>* staticObjectArgs = 0);
186
188 KexiDialogBase* openObject(KexiMainWindow *wnd, const TQCString &mimeType,
189 const TQString& name, int viewMode = Kexi::DataViewMode);
190
193 bool removeObject(KexiMainWindow *wnd, KexiPart::Item& item);
194
197 bool renameObject(KexiMainWindow *wnd, KexiPart::Item& item, const TQString& newName);
198
213 KexiPart::Item* createPartItem(KexiPart::Info *info,
214 const TQString& suggestedCaption = TQString() );
215
217 KexiPart::Item* createPartItem(KexiPart::Part *part,
218 const TQString& suggestedCaption = TQString());
219
224 void addStoredItem(KexiPart::Info *info, KexiPart::Item *item);
225
229 void deleteUnstoredItem(KexiPart::Item *item);
230
231#if 0 //remove?
239 bool createObject(KexiDialogBase *dlg);
240#endif
241
242 KexiDB::Parser* sqlParser();
243
250 static KexiProject* createBlankProject(bool &cancelled, KexiProjectData* data,
251 KexiDB::MessageHandler* handler = 0);
252
255 static tristate dropProject(KexiProjectData* data,
256 KexiDB::MessageHandler* handler, bool dontAsk = false);
257
259// void setQuerySchemaObsolete( const TQString& queryName );
260
261// /** used to emit objectCreated() signal */
262// void emitObjectCreated(const TQCString &mime, const TQCString& name) { emit objectCreated(mime, name); }
263// void emitTableCreated(KexiDB::TableSchema& schema) { emit tableCreated(schema); }
264
265 protected:
269 bool createConnection();
270
271 bool closeConnection();
272
273 bool initProject();
274
276 tristate openInternal(bool *incompatibleWithKexi);
277
297 bool createInternalStructures(bool insideTransaction);
298
300 KexiPart::Part *findPartFor(KexiPart::Item& item);
301
302 signals:
304 void error(const TQString &title, KexiDB::Object *obj);
305
307 void error(const TQString &msg, const TQString &desc);
308
311
314
316 void itemRenamed(const KexiPart::Item &item, const TQCString& oldName);
317
318// /** new table \a schema created */
319// void tableCreated(KexiDB::TableSchema& schema);
320// /** New object of mimetype \a mime and \a name has been created. */
321// void objectCreated(const TQCString &mime, const TQCString& name);
322
323 protected:
326 bool checkWritable();
327
328 class Private;
329 Private *d;
330
331 friend class KexiMainWindowImpl;
332};
333
334
335#endif
Provides database connection, allowing queries and data modification.
Definition connection.h:62
Database driver management, e.g. finding and loading drivers.
Generic database abstraction.
Definition driver.h:67
bool error() const
Definition object.h:38
Parser for SQL statements.
Definition parser.h:113
Base class for child window of Kexi's main application window.
Kexi's main window interface This interface is implemented by KexiMainWindowImpl class.
Information about a Kexi Part (plugin).
Part item list with reimplemented compareItems() method.
Information about a single object that can be instantiated using Kexi Part.
The main class for kexi frontend parts like tables, queries, forms and reports.
Definition kexipart.h:66
Kexi project core data member.
A project's main controller.
Definition kexiproject.h:68
bool error() const
KexiPart::Item * item(KexiPart::Info *i, const TQString &name)
int versionMinor() const
KexiProject(KexiProjectData *pdata, KexiDB::MessageHandler *handler=0)
tristate open()
void itemRemoved(const KexiPart::Item &item)
instance pointed by item is removed
void newItemStored(KexiPart::Item &item)
New item has been stored.
int versionMajor() const
void error(const TQString &msg, const TQString &desc)
signal emitted on error (not KexiDB-related)
void itemRenamed(const KexiPart::Item &item, const TQCString &oldName)
instance pointed by item is renamed
tristate create(bool forceOverwrite=false)
bool checkWritable()
new table schema created
void error(const TQString &title, KexiDB::Object *obj)
signal emitted on error
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition tristate.h:100
High-level database connectivity library with database backend drivers.