kexi

#include <kexiproject.h>

Inheritance diagram for KexiProject:
KexiDB::Object

Signals

void error (const TQString &title, KexiDB::Object *obj)
 
void error (const TQString &msg, const TQString &desc)
 
void newItemStored (KexiPart::Item &item)
 
void itemRemoved (const KexiPart::Item &item)
 
void itemRenamed (const KexiPart::Item &item, const TQCString &oldName)
 

Public Member Functions

 KexiProject (KexiProjectData *pdata, KexiDB::MessageHandler *handler=0)
 
 KexiProject (KexiProjectData *pdata, KexiDB::MessageHandler *handler, KexiDB::Connection *conn)
 
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 TQCString &mimeType)
 
void getSortedItems (KexiPart::ItemList &list, KexiPart::Info *i)
 
void getSortedItemsForMimeType (KexiPart::ItemList &list, const TQCString &mimeType)
 
KexiPart::Item * itemForMimeType (const TQCString &mimeType, const TQString &name)
 
KexiPart::Item * item (KexiPart::Info *i, const TQString &name)
 
KexiPart::Item * item (int identifier)
 
KexiDB::Connection * dbConnection () const
 
KexiProjectData * data () const
 
KexiDialogBase * openObject (KexiMainWindow *wnd, KexiPart::Item &item, int viewMode=Kexi::DataViewMode, TQMap< TQString, TQString > *staticObjectArgs=0)
 
KexiDialogBase * openObject (KexiMainWindow *wnd, const TQCString &mimeType, const TQString &name, int viewMode=Kexi::DataViewMode)
 
bool removeObject (KexiMainWindow *wnd, KexiPart::Item &item)
 
bool renameObject (KexiMainWindow *wnd, KexiPart::Item &item, const TQString &newName)
 
KexiPart::Item * createPartItem (KexiPart::Info *info, const TQString &suggestedCaption=TQString())
 
KexiPart::Item * createPartItem (KexiPart::Part *part, const TQString &suggestedCaption=TQString())
 
void addStoredItem (KexiPart::Info *info, KexiPart::Item *item)
 
void deleteUnstoredItem (KexiPart::Item *item)
 
KexiDB::Parser * sqlParser ()
 
- Public Member Functions inherited from KexiDB::Object
bool error () const
 
const TQString & errorMsg () const
 
int errorNum () const
 
int previousServerResult () const
 
TQString previousServerResultName () const
 
void debugError ()
 
virtual void clearError ()
 
virtual TQString serverErrorMsg ()
 
virtual int serverResult ()
 
virtual TQString serverResultName ()
 
TQString msgTitle () const
 
const TQString recentSQLString () const
 

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 ()
 
bool closeConnection ()
 
bool initProject ()
 
tristate openInternal (bool *incompatibleWithKexi)
 
bool createInternalStructures (bool insideTransaction)
 
KexiPart::Part * findPartFor (KexiPart::Item &item)
 
bool checkWritable ()
 
- Protected Member Functions inherited from KexiDB::Object
 Object (MessageHandler *handler=0)
 
virtual void setError (int code=ERR_OTHER, const TQString &msg=TQString())
 
virtual void setError (const TQString &msg)
 
virtual void setError (const TQString &title, const TQString &msg)
 
void setError (KexiDB::Object *obj, const TQString &prependMessage=TQString())
 
virtual void setError (KexiDB::Object *obj, int code, const TQString &prependMessage=TQString())
 
virtual int askQuestion (const TQString &message, KMessageBox::DialogType dlgType, KMessageBox::ButtonCode defaultResult, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontShowAskAgainName=TQString(), int options=KMessageBox::Notify, MessageHandler *msgHandler=0)
 
virtual void drv_clearServerResult ()
 

Protected Attributes

Private * d
 
- Protected Attributes inherited from KexiDB::Object
TQString m_sql
 
TQString m_errorSql
 
int m_serverResult
 
TQString m_serverResultName
 
TQString m_serverErrorMsg
 
TQString m_errMsg
 

Friends

class KexiMainWindowImpl
 

Detailed Description

A project's main controller.

It also contains connection data, current file state, etc.

Definition at line 67 of file kexiproject.h.

Constructor & Destructor Documentation

◆ KexiProject() [1/2]

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

◆ KexiProject() [2/2]

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

◆ ~KexiProject()

KexiProject::~KexiProject ( )

Definition at line 138 of file kexiproject.cpp.

Member Function Documentation

◆ addStoredItem()

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

◆ checkWritable()

bool KexiProject::checkWritable ( )
protected

Checks whether the project's connection is read-only. If so, error message is set and false is returned.

Definition at line 754 of file kexiproject.cpp.

◆ closeConnection()

bool KexiProject::closeConnection ( )
protected

Definition at line 496 of file kexiproject.cpp.

◆ create()

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.

insideTransaction

Todo:
put more props. todo - creator, created date, etc. (also to KexiProjectData)

Definition at line 225 of file kexiproject.cpp.

◆ createBlankProject()

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

◆ createConnection()

bool KexiProject::createConnection ( )
protected
See also
KexiDB::Connection::setQuerySchemaObsolete( const TQString& queryName )

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

Returns
true on success, otherwise false and appropriate error is set.
Todo:
won't work for subsequent connection

Definition at line 454 of file kexiproject.cpp.

◆ createInternalStructures()

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
insideTransactionEmbed 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:
what to do for readonly connections? Should we alter kexi__blobs in memory?
Todo:
version differs: should we change something?

just insert this schema

just insert this schema

Definition at line 299 of file kexiproject.cpp.

◆ createPartItem() [1/2]

KexiPart::Item * KexiProject::createPartItem ( KexiPart::Info *  info,
const TQString &  suggestedCaption = TQString() 
)

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

◆ createPartItem() [2/2]

KexiPart::Item * KexiProject::createPartItem ( KexiPart::Part *  part,
const TQString &  suggestedCaption = TQString() 
)

Added for convenience.

Definition at line 925 of file kexiproject.cpp.

◆ data()

KexiProjectData * KexiProject::data ( ) const
Returns
the project's data

Definition at line 149 of file kexiproject.cpp.

◆ dbConnection()

KexiDB::Connection * KexiProject::dbConnection ( ) const
Returns
the database connection associated with this project

Definition at line 144 of file kexiproject.cpp.

◆ deleteUnstoredItem()

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

◆ dropProject()

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

◆ error() [1/3]

bool KexiProject::error ( ) const
inline
Returns
true if there was error during last operation on the object.

Definition at line 126 of file kexiproject.h.

◆ error [2/3]

void KexiProject::error ( const TQString &  msg,
const TQString &  desc 
)
signal

signal emitted on error (not KexiDB-related)

◆ error [3/3]

void KexiProject::error ( const TQString &  title,
KexiDB::Object *  obj 
)
signal

signal emitted on error

◆ findPartFor()

KexiPart::Part * KexiProject::findPartFor ( KexiPart::Item &  item)
protected
Returns
Kexi part for item.

Definition at line 715 of file kexiproject.cpp.

◆ getSortedItems()

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

◆ getSortedItemsForMimeType()

void KexiProject::getSortedItemsForMimeType ( KexiPart::ItemList &  list,
const TQCString &  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 615 of file kexiproject.cpp.

◆ initProject()

bool KexiProject::initProject ( )
protected

Definition at line 512 of file kexiproject.cpp.

◆ isConnected()

bool KexiProject::isConnected ( )
Returns
true if a we are connected to a database

Definition at line 541 of file kexiproject.cpp.

◆ item() [1/2]

KexiPart::Item * KexiProject::item ( int  identifier)
Returns
item for identifier

Definition at line 663 of file kexiproject.cpp.

◆ item() [2/2]

KexiPart::Item * KexiProject::item ( KexiPart::Info *  i,
const TQString &  name 
)
Returns
item of type i and name name

Definition at line 649 of file kexiproject.cpp.

◆ itemForMimeType()

KexiPart::Item * KexiProject::itemForMimeType ( const TQCString &  mimeType,
const TQString &  name 
)
Returns
item of type mime and name name

Definition at line 635 of file kexiproject.cpp.

◆ itemRemoved

void KexiProject::itemRemoved ( const KexiPart::Item &  item)
signal

instance pointed by item is removed

◆ itemRenamed

void KexiProject::itemRenamed ( const KexiPart::Item &  item,
const TQCString &  oldName 
)
signal

instance pointed by item is renamed

◆ items()

KexiPart::ItemDict * KexiProject::items ( KexiPart::Info *  i)
Returns
all items of a type i in this project

Definition at line 550 of file kexiproject.cpp.

◆ itemsForMimeType()

KexiPart::ItemDict * KexiProject::itemsForMimeType ( const TQCString &  mimeType)
Returns
all items of a type mime in this project It is a convenience function.

Definition at line 597 of file kexiproject.cpp.

◆ newItemStored

void KexiProject::newItemStored ( KexiPart::Item &  item)
signal

New item has been stored.

◆ open() [1/2]

tristate KexiProject::open ( )

Opens existing project using project data.

Returns
true on success

Definition at line 171 of file kexiproject.cpp.

◆ open() [2/2]

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

◆ openInternal()

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

◆ openObject() [1/2]

KexiDialogBase * KexiProject::openObject ( KexiMainWindow *  wnd,
const TQCString &  mimeType,
const TQString &  name,
int  viewMode = Kexi::DataViewMode 
)

For convenience.

Definition at line 747 of file kexiproject.cpp.

◆ openObject() [2/2]

KexiDialogBase * KexiProject::openObject ( KexiMainWindow *  wnd,
KexiPart::Item &  item,
int  viewMode = Kexi::DataViewMode,
TQMap< TQString, TQString > *  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 725 of file kexiproject.cpp.

◆ removeObject()

bool KexiProject::removeObject ( KexiMainWindow *  wnd,
KexiPart::Item &  item 
)

Remove a part instance pointed by item.

Returns
true on success.

Definition at line 762 of file kexiproject.cpp.

◆ renameObject()

bool KexiProject::renameObject ( KexiMainWindow *  wnd,
KexiPart::Item &  item,
const TQString &  newName 
)

Renames a part instance pointed by item to a new name newName.

Returns
true on success.

Definition at line 804 of file kexiproject.cpp.

◆ sqlParser()

KexiDB::Parser * KexiProject::sqlParser ( )

Definition at line 937 of file kexiproject.cpp.

◆ versionMajor()

int KexiProject::versionMajor ( ) const
Returns
major version of KexiProject object. This information is retrieved from database when existing project is opened.

Definition at line 154 of file kexiproject.cpp.

◆ versionMinor()

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

Definition at line 159 of file kexiproject.cpp.

Friends And Related Symbol Documentation

◆ KexiMainWindowImpl

friend class KexiMainWindowImpl
friend

Definition at line 331 of file kexiproject.h.

Member Data Documentation

◆ d

Private* KexiProject::d
protected

Definition at line 329 of file kexiproject.h.


The documentation for this class was generated from the following files: