Source: /app/hbasic/hbasic/src/hbdatabase.h


Annotated List
Files
Globals
Hierarchy
Index
/* **************************************************************************
 File: hbdatabase.h
 ----------------------------------------------------------------------------
	copyright            : (C) 2001 HBasic project (Marcus Engels)
 ***************************************************************************/

/* **************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

/* ----------------------------------------------------------------------- */
/* Classlist: List of classes that will be defined in this source file.    */
/* ----------------------------------------------------------------------- */

/**
  Class HBDatabase: This class will be used as an interface to all
   database access functions. Every connection to a database needs
   at least one HBDatabase.
*/

/* ----------------------------------------------------------------------- */
/* Changelog: Description of important changes within this file.           */
/*            Please report with date, maintainer and change description.  */
/* ----------------------------------------------------------------------- */

#ifndef HBDATABASE_H
#define HBDATABASE_H

#include 
#include 

#include 
#include 
#include 
#include 
#include 

#include "../hbdata/hbobject.h"
#include "../hbdata/hbsublist.h"
#include "../src/structs.h"

#define STR_LENGTH 100

class QString;
class QPushButton;
class QDataBrowser;
class QSqlForm;

/* Global defined methods in hbdatabase.cpp */

void readDatabaseList(void);
void saveDbListToFile( void );
int getCurrentDriverType( void );

#define DTYPE_UNDEF 0
#define DTYPE_MYSQL3 1
#define DTYPE_PSQL7 2

class HBDatabase : public QObject, public HBObject
{
Q_OBJECT

Q_PROPERTY( QString dbname READ getDbName WRITE setDbName )
Q_PROPERTY( QString host READ getHost WRITE setHost )
Q_PROPERTY( QString driver READ getDriver WRITE setDriver )
Q_PROPERTY( QString user READ getUser WRITE setUser )
Q_PROPERTY( QString password READ getPassword WRITE setPassword )
Q_PROPERTY( QString desc READ getDesc WRITE setDesc )

public:
	HBDatabase( char *name );
	short prepareConnect( void );

	HBSubList *getColumnList( HBDbTable *table_ptr );
	short loadTableList( short force_rebuild );
	HBDbTable *findTableDesc( char *table_name );
	HBDbTable *bindQueryColumns( QSqlCursor *query_cursor );
	long compMemLength( HBDbColumn *query_column_ptr );
	HBDbColumn *prepareQueryDesc( void );
	void getDbControl( QString *dsn_name );
	void execDirect( QString *statement );

	/**
	 * Create a connection to a QT database description.
	 */

	short connectDatabase( void );

	/**
	 * Close current database connection.
	 */

	void closeConnection( void );

	/* db_desc */

public:
	/* Name of database driver description in name-field of Qobject */
	/* dbname is the name of the database on the server */
	QString *dbname;
	QString *str_host;
	QString *driver;
	QString *desc;
	QString *user;
	QString *password;
	short save_pw;         /* TRUE if password should be saved to file for this DSN */

	QSqlDatabase *qt_db_desc;   /* pointer to qt database description widget. */

	void loadColumnList( HBDbTable *table_ptr );

	void setDbName( QString new_name );
	QString getDbName( void ) const;
	void setHost( QString new_name );
	QString getHost( void ) const;
	void setDriver( QString new_name );
	QString getDriver( void ) const;
	void setUser( QString new_name );
	QString getUser( void ) const;
	void setPassword( QString new_name );
	QString getPassword( void ) const;
	void setDesc( QString new_name );
	QString getDesc( void ) const;

private:
	void prepareQuery(void);
};

class DBCursorForm : public QWidget
{
	Q_OBJECT

	Q_PROPERTY( QString DB_TABLE READ getDbTable WRITE setDbTable )

private:
	QDataBrowser *db_browse;
	QSqlCursor *sql_cursor;
	QString *table_name;
	QWidget *wgt_ptr;
	HBDatabase *db_control;

public:
	DBCursorForm( QWidget *parent );
	void resizeEvent( QResizeEvent *evt );
	void initDataBrowser( QWidget *wgt );
	QSqlForm *form_ptr;

private:
	QPushButton *btn_first;
	QPushButton *btn_previous;
	QPushButton *btn_next;
	QPushButton *btn_last;

	QPushButton *btn_add;
	QPushButton *btn_delete;

	QString prop_db_table;

private slots:
	void slotBtnFirstClicked( void );
	void slotBtnPreviousClicked( void );
	void slotBtnNextClicked( void );
	void slotBtnLastClicked( void );
	void slotBtnAddClicked( void );
	void slotBtnDeleteClicked( void );

public slots:
	/* Property db_table */
	QString getDbTable( void ) const;
	void setDbTable( const QString & );
};

/*-------------------------------------------------------------------------- */

class ColumnEditor : public QLineEdit
{
	Q_OBJECT

	Q_PROPERTY( QString DB_COLUMN READ getDbColumn WRITE setDbColumn )

public:
	ColumnEditor( QWidget *parent );

private:
	QString prop_db_column;

public slots:
	/* Property db_table */
	QString getDbColumn( void ) const;
	void setDbColumn( const QString & );
};


#endif


Generated by: root on linux on Sun Jul 13 18:06:35 2003, using kdoc 2.0a54.