kexi
KexiProject Class Reference
#include <kexiproject.h>
Inheritance diagram for KexiProject:

Detailed Description
A project's main controller.It also contains connection data, current file state, etc.
Definition at line 67 of file kexiproject.h.
Signals | |
void | error (const QString &title, KexiDB::Object *obj) |
void | error (const QString &msg, const QString &desc) |
void | newItemStored (KexiPart::Item &item) |
void | itemRemoved (const KexiPart::Item &item) |
void | itemRenamed (const KexiPart::Item &item, const QCString &oldName) |
Public Member Functions | |
KexiProject (KexiProjectData *pdata, KexiDB::MessageHandler *handler=0) | |
KexiProject (KexiProjectData *pdata, KexiDB::MessageHandler *handler, KexiDB::Connection *conn) | |
~KexiProject () | |
int | versionMajor () const |
int | versionMinor () const |
tristate | open () |
tristate | open (bool &incompatibleWithKexi) |
tristate | create (bool forceOverwrite=false) |
bool | error () const |
bool | isConnected () |
KexiPart::ItemDict * | items (KexiPart::Info *i) |
KexiPart::ItemDict * | itemsForMimeType (const QCString &mimeType) |
void | getSortedItems (KexiPart::ItemList &list, KexiPart::Info *i) |
void | getSortedItemsForMimeType (KexiPart::ItemList &list, const QCString &mimeType) |
KexiPart::Item * | itemForMimeType (const QCString &mimeType, const QString &name) |
KexiPart::Item * | item (KexiPart::Info *i, const QString &name) |
KexiPart::Item * | item (int identifier) |
KexiDB::Connection * | dbConnection () const |
KexiProjectData * | data () const |
KexiDialogBase * | openObject (KexiMainWindow *wnd, KexiPart::Item &item, int viewMode=Kexi::DataViewMode, QMap< QString, QString > *staticObjectArgs=0) |
KexiDialogBase * | openObject (KexiMainWindow *wnd, const QCString &mimeType, const QString &name, int viewMode=Kexi::DataViewMode) |
bool | removeObject (KexiMainWindow *wnd, KexiPart::Item &item) |
bool | renameObject (KexiMainWindow *wnd, KexiPart::Item &item, const QString &newName) |
KexiPart::Item * | createPartItem (KexiPart::Info *info, const QString &suggestedCaption=QString::null) |
KexiPart::Item * | createPartItem (KexiPart::Part *part, const QString &suggestedCaption=QString::null) |
void | addStoredItem (KexiPart::Info *info, KexiPart::Item *item) |
void | deleteUnstoredItem (KexiPart::Item *item) |
KexiDB::Parser * | sqlParser () |
bool | final () const |
void | setFinal (bool set) |
Static Public Member Functions | |
static KexiProject * | createBlankProject (bool &cancelled, KexiProjectData *data, KexiDB::MessageHandler *handler=0) |
static tristate | dropProject (KexiProjectData *data, KexiDB::MessageHandler *handler, bool dontAsk=false) |
Protected Member Functions | |
bool | createConnection () |
void | closeConnection () |
bool | initProject () |
tristate | openInternal (bool *incompatibleWithKexi) |
bool | createInternalStructures (bool insideTransaction) |
KexiPart::Part * | findPartFor (KexiPart::Item &item) |
bool | checkWritable () |
Protected Attributes | |
Private * | d |
Friends | |
class | KexiMainWindowImpl |
Constructor & Destructor Documentation
KexiProject::KexiProject | ( | KexiProjectData * | pdata, | |
KexiDB::MessageHandler * | handler = 0 | |||
) |
Constructor 1. Creates a new object using pdata. pdata which will be then owned by KexiProject object. handler can be provided to receive error messages during entire KexiProject object's lifetime.
- Todo:
- partmanager is outside project, so can be initialised just once:
Definition at line 115 of file kexiproject.cpp.
KexiProject::KexiProject | ( | KexiProjectData * | pdata, | |
KexiDB::MessageHandler * | handler, | |||
KexiDB::Connection * | conn | |||
) |
Constructor 2. Like above but sets predefined connections conn. The connection should be created using the same connection data as pdata->connectionData(). The connection will become owned by created KexiProject object, so do not destroy it.
- Todo:
- partmanager is outside project, so can be initialised just once:
Definition at line 124 of file kexiproject.cpp.
Member Function Documentation
void KexiProject::addStoredItem | ( | KexiPart::Info * | info, | |
KexiPart::Item * | item | |||
) |
Adds item item after it is succesfully stored as an instance of part pointed by info. Also clears 'neverSaved' flag if item. Used by KexiDialogBase::storeNewData().
Definition at line 585 of file kexiproject.cpp.
bool KexiProject::checkWritable | ( | ) | [protected] |
New object of mimetype mime and name has been created.
Checks whether the project's connection is read-only. If so, error message is set and false is returned.
Definition at line 714 of file kexiproject.cpp.
tristate KexiProject::create | ( | bool | forceOverwrite = false |
) |
Creates new, empty project using project data. If forceOverwrite is true, existing database project is silently overwritten. Connection is created (accessible then with KexiProject::dbConnection()).
Since KexiProject inherits KexiDB::Object, it is possible to get error message and other informations on error.
- Returns:
- true on success, false on failure, and cancelled when database exists but forceOverwrite is false.
insideTransaction
- Todo:
- put more props. todo - creator, created date, etc. (also to KexiProjectData)
Definition at line 236 of file kexiproject.cpp.
KexiProject * KexiProject::createBlankProject | ( | bool & | cancelled, | |
KexiProjectData * | data, | |||
KexiDB::MessageHandler * | handler = 0 | |||
) | [static] |
Shows dialog for creating new blank project, ans creates one. Dialog is not shown if option for automatic creation is checked or Kexi::startupHandler().projectData() was provided from command line. cancelled is set to true if creation has been cancelled (e.g. user answered no when asked for database overwriting, etc.
- Returns:
- true if database was created, false on error or when cancel was pressed
- Todo:
- move to KexiMessageHandler
Definition at line 902 of file kexiproject.cpp.
bool KexiProject::createConnection | ( | ) | [protected] |
used to emit objectCreated() signal
Creates connection using project data.
- Returns:
- true on success, otherwise false and appropriate error is set.
- Todo:
- won't work for subsequent connection
Definition at line 426 of file kexiproject.cpp.
bool KexiProject::createInternalStructures | ( | bool | insideTransaction | ) | [protected] |
Kexi itself can define a number of internal database objects (mostly data structures), usually tables for it's own purposes. Even while at KexiDB library level, such "system" tables, like "kexi__objects", "kexi__objectdata" are created automatically on database project creation, this is not enough: there are objects needed specifically for Kexi but not for other applications utilizing KexiDB library. Example table created here for now is "kexi__blobs".
This method is called on create() and open(): creates necessary objects if they are not yet existing. This especially allows to create to create these objects (on open) within a project made with previous Kexi version not supporting all currently defined structurtes. We're trying to be here as much backward compatible as possible. For this purpose, here's the complete list of currently created objects:
- "kexi__blobs" - a table containing BLOBs data taht can be accessed globally at Kexi projects from within any database-aware view (table views, forms, reports, etc.)
- Parameters:
-
insideTransaction Embed entire creation process inside a transaction
- Returns:
- true on successful object's creation. Objects are created only once, they are not overwritten.
- Todo:
- what about read-only db access?
- Todo:
- version differs: should we change something?
just insert this schema
just insert this schema
Definition at line 310 of file kexiproject.cpp.
KexiPart::Item * KexiProject::createPartItem | ( | KexiPart::Part * | part, | |
const QString & | suggestedCaption = QString::null | |||
) |
KexiPart::Item * KexiProject::createPartItem | ( | KexiPart::Info * | info, | |
const QString & | suggestedCaption = QString::null | |||
) |
Creates part item for given part info. Newly item will not be saved to the backend but stored in memory only (owned by project), and marked as "neverSaved" (see KexiPart::Item::neverSaved()). The item will have assigned a new unique caption like e.g. "Table15", and unique name like "table15", but no specific identifier (because id will be assigned on creation at the backend side).
If suggestedCaption is not empty, it will be set as a caption (with number suffix, to avoid duplicated, e.g. "employees7" for "employees" sugested name). Name will be then built based on this caption using KexiUtils::string2Identifier().
This method is used before creating new object.
- Returns:
- newly created part item or NULL on any error.
Definition at line 811 of file kexiproject.cpp.
KexiDB::Connection * KexiProject::dbConnection | ( | ) | const |
- Returns:
- the database connection assosiated with this project
Definition at line 146 of file kexiproject.cpp.
void KexiProject::deleteUnstoredItem | ( | KexiPart::Item * | item | ) |
removes item from internal dictionaries. The item is destroyed after successful removal. Used to delete an unstored part item previusly created with createPartItem().
Definition at line 881 of file kexiproject.cpp.
tristate KexiProject::dropProject | ( | KexiProjectData * | data, | |
KexiDB::MessageHandler * | handler, | |||
bool | dontAsk = false | |||
) | [static] |
Drops project described by data.
- Returns:
- true on success. Use with care: Any KexiProject objects allocated for this project will become invalid!
Definition at line 937 of file kexiproject.cpp.
void KexiProject::error | ( | const QString & | msg, | |
const QString & | desc | |||
) | [signal] |
signal emitted on error (not KexiDB-related)
void KexiProject::error | ( | const QString & | title, | |
KexiDB::Object * | obj | |||
) | [signal] |
signal emitted on error
bool KexiProject::error | ( | ) | const [inline] |
- Returns:
- true if there was error during last operation on the object.
Reimplemented from KexiDB::Object.
Definition at line 125 of file kexiproject.h.
bool KexiProject::final | ( | ) | const |
- Returns:
- true if the project is started in final mode
Definition at line 156 of file kexiproject.cpp.
KexiPart::Part * KexiProject::findPartFor | ( | KexiPart::Item & | item | ) | [protected] |
void KexiProject::getSortedItems | ( | KexiPart::ItemList & | list, | |
KexiPart::Info * | i | |||
) |
Puts a list of items of a type i in this project into list.
You can then sort this list using ItemList::sort().
Definition at line 567 of file kexiproject.cpp.
void KexiProject::getSortedItemsForMimeType | ( | KexiPart::ItemList & | list, | |
const QCString & | mimeType | |||
) |
Puts a sorted list of items of a type mimeType in this project into list.
You can then sort this list using ItemList::sort().
Definition at line 578 of file kexiproject.cpp.
bool KexiProject::isConnected | ( | ) |
KexiPart::Item * KexiProject::item | ( | int | identifier | ) |
KexiPart::Item * KexiProject::item | ( | KexiPart::Info * | i, | |
const QString & | name | |||
) |
KexiPart::Item * KexiProject::itemForMimeType | ( | const QCString & | mimeType, | |
const QString & | name | |||
) |
void KexiProject::itemRemoved | ( | const KexiPart::Item & | item | ) | [signal] |
instance pointed by item is removed
void KexiProject::itemRenamed | ( | const KexiPart::Item & | item, | |
const QCString & | oldName | |||
) | [signal] |
instance pointed by item is renamed
KexiPart::ItemDict * KexiProject::items | ( | KexiPart::Info * | i | ) |
KexiPart::ItemDict * KexiProject::itemsForMimeType | ( | const QCString & | mimeType | ) |
- Returns:
- all items of a type mime in this project It is a convenience function.
Definition at line 560 of file kexiproject.cpp.
void KexiProject::newItemStored | ( | KexiPart::Item & | item | ) | [signal] |
New item has been stored.
tristate KexiProject::open | ( | bool & | incompatibleWithKexi | ) |
Like open().
- Returns:
- true on success. Additional incompatibleWithKexi, is set to false on failure when connection for the project was successfully started bu the project is probably not compatible with Kexi - no valid "kexidb_major_ver" value in "kexi__db" table. This is often the case for native server-based databases. If so, Kexi application can propose importing the database or linking it to parent project (the latter isn't yet implemented). For other types of errors the variable is set to true.
Definition at line 177 of file kexiproject.cpp.
tristate KexiProject::open | ( | ) |
Opens existing project using project data.
- Returns:
- true on success
Definition at line 183 of file kexiproject.cpp.
tristate KexiProject::openInternal | ( | bool * | incompatibleWithKexi | ) | [protected] |
Used in open() and open(bool&).
- Todo:
- <temp> this is temporary workaround as we have no import driver for SQLite
</temp>
Definition at line 189 of file kexiproject.cpp.
KexiDialogBase * KexiProject::openObject | ( | KexiMainWindow * | wnd, | |
const QCString & | mimeType, | |||
const QString & | name, | |||
int | viewMode = Kexi::DataViewMode | |||
) |
KexiDialogBase * KexiProject::openObject | ( | KexiMainWindow * | wnd, | |
KexiPart::Item & | item, | |||
int | viewMode = Kexi::DataViewMode , |
|||
QMap< QString, QString > * | staticObjectArgs = 0 | |||
) |
Opens object pointed by item in a view viewMode. staticObjectArgs can be passed for static object (only works when part for this item is of type KexiPart::StaticPart)
Definition at line 688 of file kexiproject.cpp.
bool KexiProject::removeObject | ( | KexiMainWindow * | wnd, | |
KexiPart::Item & | item | |||
) |
Remove a part instance pointed by item.
- Returns:
- true on success.
Definition at line 722 of file kexiproject.cpp.
bool KexiProject::renameObject | ( | KexiMainWindow * | wnd, | |
KexiPart::Item & | item, | |||
const QString & | newName | |||
) |
Renames a part instance pointed by item to a new name newName.
- Returns:
- true on success.
Definition at line 761 of file kexiproject.cpp.
int KexiProject::versionMajor | ( | ) | const |
- Returns:
- major version of KexiProject object. This information is retrieved from database when existing project is opened.
Definition at line 166 of file kexiproject.cpp.
int KexiProject::versionMinor | ( | ) | const |
- Returns:
- minor version of KexiProject object.
- See also:
- versionMajor()
Definition at line 171 of file kexiproject.cpp.
Member Data Documentation
Private* KexiProject::d [protected] |
for future extensions
Reimplemented from KexiDB::Object.
Definition at line 328 of file kexiproject.h.
The documentation for this class was generated from the following files: