Kexi API Documentation (2.0 alpha)

KexiProject Class Reference

#include <kexiproject.h>

Inheritance diagram for KexiProject:

KexiDB::Object List of all members.

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)
 signal emitted on error
void error (const QString &msg, const QString &desc)
 signal emitted on error (not KexiDB-related)
void newItemStored (KexiPart::Item &item)
 New item has been stored.
void itemRemoved (const KexiPart::Item &item)
 instance pointed by item is removed
void itemRenamed (const KexiPart::Item &item, const QCString &oldName)
 instance pointed by item is renamed

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::ItemDictitems (KexiPart::Info *i)
KexiPart::ItemDictitemsForMimeType (const QCString &mimeType)
void getSortedItems (KexiPart::ItemList &list, KexiPart::Info *i)
 Puts a list of items of a type i in this project into list.
void getSortedItemsForMimeType (KexiPart::ItemList &list, const QCString &mimeType)
 Puts a sorted list of items of a type mimeType in this project into list.
KexiPart::ItemitemForMimeType (const QCString &mimeType, const QString &name)
KexiPart::Itemitem (KexiPart::Info *i, const QString &name)
KexiPart::Itemitem (int identifier)
KexiDB::ConnectiondbConnection () const
KexiProjectDatadata () const
KexiDialogBaseopenObject (KexiMainWindow *wnd, KexiPart::Item &item, int viewMode=Kexi::DataViewMode, QMap< QString, QString > *staticObjectArgs=0)
KexiDialogBaseopenObject (KexiMainWindow *wnd, const QCString &mimeType, const QString &name, int viewMode=Kexi::DataViewMode)
 For convenience.
bool removeObject (KexiMainWindow *wnd, KexiPart::Item &item)
bool renameObject (KexiMainWindow *wnd, KexiPart::Item &item, const QString &newName)
KexiPart::ItemcreatePartItem (KexiPart::Info *info, const QString &suggestedCaption=QString::null)
KexiPart::ItemcreatePartItem (KexiPart::Part *part, const QString &suggestedCaption=QString::null)
 Added for convenience.
void addStoredItem (KexiPart::Info *info, KexiPart::Item *item)
void deleteUnstoredItem (KexiPart::Item *item)
KexiDB::ParsersqlParser ()
bool final () const
void setFinal (bool set)

Static Public Member Functions

static KexiProjectcreateBlankProject (bool &cancelled, KexiProjectData *data, KexiDB::MessageHandler *handler=0)
static tristate dropProject (KexiProjectData *data, KexiDB::MessageHandler *handler, bool dontAsk=false)

Protected Member Functions

bool createConnection ()
 used to emit objectCreated() signal
bool closeConnection ()
bool initProject ()
tristate openInternal (bool *incompatibleWithKexi)
 Used in open() and open(bool&).
bool createInternalStructures (bool insideTransaction)
KexiPart::PartfindPartFor (KexiPart::Item &item)
bool checkWritable ()
 New object of mimetype mime and name has been created.

Protected Attributes

Private * d
 for future extensions

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.

Definition at line 115 of file kexiproject.cpp.

References d, and Kexi::partManager().

Referenced by createBlankProject().

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.

Definition at line 124 of file kexiproject.cpp.

References d, KexiDB::Connection::data(), and Kexi::partManager().

KexiProject::~KexiProject  ) 
 

Definition at line 140 of file kexiproject.cpp.

References closeConnection(), and d.


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 634 of file kexiproject.cpp.

References d, items(), newItemStored(), and KexiPart::Item::setNeverSaved().

Referenced by KexiCSVImportDialog::accept().

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 766 of file kexiproject.cpp.

References d, and KexiDB::Object::setError().

Referenced by create(), removeObject(), and renameObject().

bool KexiProject::closeConnection  )  [protected]
 

Definition at line 508 of file kexiproject.cpp.

References d, and KexiDB::Object::setError().

Referenced by KexiMainWindowImpl::closeProject(), create(), createConnection(), openInternal(), and ~KexiProject().

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 information on error.

Returns:
true on success, false on failure, and cancelled when database exists but forceOverwrite is false.

Definition at line 237 of file kexiproject.cpp.

References KexiDB::Transaction::active(), cancelled, checkWritable(), closeConnection(), createConnection(), createInternalStructures(), d, initProject(), KexiDB::Transaction::isNull(), KexiDB::DatabaseProperties::setCaption(), KexiDB::Object::setError(), and KexiDB::DatabaseProperties::setValue().

Referenced by createBlankProject(), KexiMainWindowImpl::createBlankProject(), and KexiMigration::KexiMigrate::performImport().

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

Definition at line 963 of file kexiproject.cpp.

References create(), data(), and KexiProject().

Referenced by KexiStartupHandler::init().

bool KexiProject::createConnection  )  [protected]
 

used to emit objectCreated() signal

Creates connection using project data. The connection will be readonly if data()->isReadOnly().

Returns:
true on success, otherwise false and appropriate error is set.

Definition at line 466 of file kexiproject.cpp.

References KexiDB::Object::clearError(), closeConnection(), KexiDB::Driver::createConnection(), d, Kexi::driverManager(), KexiDB::Object::errorMsg(), KexiDB::Driver::ReadOnlyConnection, KexiBLOBBuffer::setConnection(), and KexiDB::Object::setError().

Referenced by create(), and openInternal().

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 that 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.

Definition at line 311 of file kexiproject.cpp.

References KexiDB::FieldList::addField(), KexiDB::Field::AutoInc, KexiDB::Field::BLOB, KexiDB::TransactionGuard::commit(), d, KexiDB::Field::Integer, KEXIPROJECT_VERSION_MAJOR, KEXIPROJECT_VERSION_MINOR, KexiDB::Field::NotNull, KexiDB::Field::PrimaryKey, KexiDB::DatabaseProperties::setCaption(), KexiDB::SchemaData::setName(), KexiDB::TransactionGuard::setTransaction(), KexiDB::DatabaseProperties::setValue(), KexiDB::FieldList::subList(), KexiDB::Field::Text, KexiDB::TransactionGuard::transaction(), KexiDB::Field::Unsigned, and KexiDB::DatabaseProperties::value().

Referenced by create(), and openInternal().

KexiPart::Item * KexiProject::createPartItem KexiPart::Part part,
const QString suggestedCaption = QString::null
 

Added for convenience.

Definition at line 937 of file kexiproject.cpp.

References createPartItem().

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 869 of file kexiproject.cpp.

References KexiDB::Object::clearError(), d, data(), KexiPart::Part::instanceCaption(), KexiPart::Part::instanceName(), item(), items(), KexiPart::Info::mimeType(), Kexi::partManager(), KexiPart::Item::setCaption(), KexiDB::Object::setError(), KexiPart::Item::setIdentifier(), KexiPart::Item::setMimeType(), KexiPart::Item::setName(), KexiPart::Item::setNeverSaved(), and KexiUtils::string2Identifier().

Referenced by KexiCSVImportDialog::accept(), createPartItem(), KexiMainWindowImpl::newObject(), and KexiMainWindowImpl::printActionForItem().

KexiProjectData * KexiProject::data  )  const
 

Returns:
the project's data

Definition at line 151 of file kexiproject.cpp.

References d.

Referenced by createBlankProject(), createPartItem(), openObject(), removeObject(), renameObject(), KexiMainWindowImpl::slotAutoOpenObjectsLater(), KexiMainWindowImpl::slotToolsCompactDatabase(), and KexiMainWindowImpl::updateAppCaption().

KexiDB::Connection * KexiProject::dbConnection  )  const
 

Returns:
the database connection associated with this project

Definition at line 146 of file kexiproject.cpp.

References d.

Referenced by KexiCSVImportDialog::accept(), dropProject(), KexiMainWindowImpl::initUserActions(), KexiMainWindowImpl::initUserMode(), KexiMainWindowImpl::invalidateProjectWideActions(), KexiMigration::KexiMigrate::performImport(), KexiMainWindowImpl::slotToolsCompactDatabase(), and KexiMainWindowImpl::updateReadOnlyState().

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 942 of file kexiproject.cpp.

References d.

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 996 of file kexiproject.cpp.

References cancelled, dbConnection(), KexiDB::SchemaData::objectName(), open(), and KexiDB::MessageHandler::showErrorMessage().

Referenced by KexiStartupHandler::init().

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.

References KexiDB::Object::error().

Referenced by initProject(), and KexiMigration::KexiMigrate::performImport().

bool KexiProject::final  )  const
 

Returns:
true if the project is started in final mode

Definition at line 156 of file kexiproject.cpp.

References d.

KexiPart::Part * KexiProject::findPartFor KexiPart::Item item  )  [protected]
 

Returns:
Kexi part for item.

Definition at line 727 of file kexiproject.cpp.

References KexiDB::Object::clearError(), Kexi::partManager(), and KexiDB::Object::setError().

Referenced by openObject(), removeObject(), and renameObject().

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 616 of file kexiproject.cpp.

References items().

Referenced by getSortedItemsForMimeType(), and KexiDataSourceComboBox::setProject().

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 627 of file kexiproject.cpp.

References getSortedItems(), and Kexi::partManager().

bool KexiProject::initProject  )  [protected]
 

Definition at line 524 of file kexiproject.cpp.

References d, error(), Kexi::partManager(), KexiDB::Object::setError(), and KexiDB::DatabaseProperties::value().

Referenced by create(), and openInternal().

bool KexiProject::isConnected  ) 
 

Returns:
true if a we are connected to a database

Definition at line 553 of file kexiproject.cpp.

References d.

Referenced by KexiMainWindowImpl::initNavigator(), and items().

KexiPart::Item * KexiProject::item int  identifier  ) 
 

Returns:
item for identifier

Definition at line 675 of file kexiproject.cpp.

References d, and item().

KexiPart::Item * KexiProject::item KexiPart::Info i,
const QString name
 

Returns:
item of type i and name name

Definition at line 661 of file kexiproject.cpp.

References items().

Referenced by KexiFormEventAction::activate(), createPartItem(), KexiMainWindowImpl::initUserMode(), item(), and KexiMainWindowImpl::slotAutoOpenObjectsLater().

KexiPart::Item * KexiProject::itemForMimeType const QCString &  mimeType,
const QString name
 

Returns:
item of type mime and name name

Definition at line 647 of file kexiproject.cpp.

References itemsForMimeType().

Referenced by KexiMainWindowImpl::highlightObject(), openObject(), and KexiMainWindowImpl::openObject().

void KexiProject::itemRemoved const KexiPart::Item item  )  [signal]
 

instance pointed by item is removed

Referenced by removeObject().

void KexiProject::itemRenamed const KexiPart::Item item,
const QCString &  oldName
[signal]
 

instance pointed by item is renamed

Referenced by renameObject().

KexiPart::ItemDict * KexiProject::items KexiPart::Info i  ) 
 

Returns:
all items of a type i in this project

Definition at line 562 of file kexiproject.cpp.

References d, KexiDB::Cursor::eof(), KexiPart::Item::identifier(), isConnected(), KexiUtils::isIdentifier(), KexiPart::Info::mimeType(), KexiDB::Cursor::moveFirst(), KexiDB::Cursor::moveNext(), KexiPart::Info::projectPartID(), KexiPart::Item::setCaption(), KexiPart::Item::setIdentifier(), KexiPart::Item::setMimeType(), KexiPart::Item::setName(), and KexiDB::Cursor::value().

Referenced by addStoredItem(), createPartItem(), getSortedItems(), item(), itemsForMimeType(), and KexiBrowser::setProject().

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 609 of file kexiproject.cpp.

References items(), and Kexi::partManager().

Referenced by itemForMimeType().

void KexiProject::newItemStored KexiPart::Item item  )  [signal]
 

New item has been stored.

Referenced by addStoredItem().

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.

References openInternal().

tristate KexiProject::open  ) 
 

Opens existing project using project data.

Returns:
true on success

Definition at line 183 of file kexiproject.cpp.

References openInternal().

Referenced by dropProject(), KexiMainWindowImpl::initUserMode(), and KexiMainWindowImpl::openProject().

tristate KexiProject::openInternal bool *  incompatibleWithKexi  )  [protected]
 

Used in open() and open(bool&).

Todo:
this is temporary workaround as we have no import driver for SQLite

Definition at line 189 of file kexiproject.cpp.

References cancelled, closeConnection(), createConnection(), createInternalStructures(), d, ERR_NO_DB_PROPERTY, initProject(), and KexiDB::Object::setError().

Referenced by open().

KexiDialogBase * KexiProject::openObject KexiMainWindow wnd,
const QCString &  mimeType,
const QString name,
int  viewMode = Kexi::DataViewMode
 

For convenience.

Definition at line 759 of file kexiproject.cpp.

References itemForMimeType(), and openObject().

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 737 of file kexiproject.cpp.

References KexiDB::Object::clearError(), data(), Kexi::DataViewMode, findPartFor(), KexiPart::Part::lastOperationStatus(), KexiPart::Item::name(), KexiPart::Part::openInstance(), and KexiDB::Object::setError().

Referenced by openObject(), and KexiMainWindowImpl::openObject().

bool KexiProject::removeObject KexiMainWindow wnd,
KexiPart::Item item
 

Remove a part instance pointed by item.

Returns:
true on success.

Definition at line 774 of file kexiproject.cpp.

References checkWritable(), KexiDB::Object::clearError(), KexiDB::TransactionGuard::commit(), d, data(), findPartFor(), KexiPart::Item::identifier(), KexiPart::Part::info(), itemRemoved(), KexiPart::Item::neverSaved(), KexiPart::Part::remove(), KexiDB::Object::setError(), and KexiDB::TransactionGuard::transaction().

Referenced by KexiMainWindowImpl::removeObject().

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 816 of file kexiproject.cpp.

References checkWritable(), KexiDB::Object::clearError(), KexiDB::TransactionGuard::commit(), d, data(), findPartFor(), KexiPart::Item::identifier(), itemRenamed(), KexiPart::Part::lastOperationStatus(), KexiPart::Item::mimeType(), KexiPart::Item::name(), KexiPart::Part::rename(), KexiDB::Object::setError(), KexiPart::Item::setName(), KexiDB::Field::Text, and KexiDB::TransactionGuard::transaction().

Referenced by KexiMainWindowImpl::renameObject().

void KexiProject::setFinal bool  set  ) 
 

Definition at line 161 of file kexiproject.cpp.

References d.

KexiDB::Parser * KexiProject::sqlParser  ) 
 

Definition at line 949 of file kexiproject.cpp.

References d.

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.

References d.

int KexiProject::versionMinor  )  const
 

Returns:
minor version of KexiProject object.
See also:
versionMajor()

Definition at line 171 of file kexiproject.cpp.

References d.


Friends And Related Function Documentation

friend class KexiMainWindowImpl [friend]
 

Definition at line 335 of file kexiproject.h.


Member Data Documentation

Private* KexiProject::d [protected]
 

for future extensions

Reimplemented from KexiDB::Object.

Definition at line 332 of file kexiproject.h.

Referenced by addStoredItem(), checkWritable(), closeConnection(), create(), createConnection(), createInternalStructures(), createPartItem(), data(), dbConnection(), deleteUnstoredItem(), final(), initProject(), isConnected(), item(), items(), KexiProject(), openInternal(), removeObject(), renameObject(), setFinal(), sqlParser(), versionMajor(), versionMinor(), and ~KexiProject().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:50:15 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003