File: classODBC.cpp

package info (click to toggle)
unixodbc 2.1.1-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 12,668 kB
  • ctags: 12,486
  • sloc: ansic: 107,685; cpp: 33,663; sh: 13,300; makefile: 2,926; yacc: 499; lex: 241; sed: 93; sql: 1
file content (83 lines) | stat: -rw-r--r-- 1,984 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**************************************************
 *
 *
 **************************************************
 * This code was created by Peter Harvey @ CodeByDesign.
 * Released under GPL 18.FEB.99
 *
 * Contributions from...
 * -----------------------------------------------
 * Peter Harvey		- pharvey@codebydesign.com
 **************************************************/
#include "classODBC.h"
#include "odbc.xpm"

classODBC::classODBC( QListView *pParent, classCanvas *pCanvas )
    : classNode( pParent, pCanvas )
{
	Init();
}

classODBC::classODBC( QListViewItem *pParent, classCanvas *pCanvas )
    : classNode( pParent, pCanvas )
{
	Init();
}

classODBC::~classODBC()
{
	if (( void * ) hEnv != 0 )
	{
		SQLFreeEnv( hEnv );
	}
}

void classODBC::Init()
{
	hEnv 				= 0;
	this->pCanvas 		= pCanvas;
	pDrivers			= 0;
	pDataSourcesUser	= 0;
	pDataSourcesSystem	= 0;
	setPixmap( 0, QPixmap(odbc_xpm) );
	setText( 0, "ODBC" );
	setText( 1, "" );
	setText( 2, "Open Database Connectivity" );
}

void classODBC::setOpen( bool o )
{
    if ( o && !childCount() )
	{
		// CREATE AN ODBC ENVIRONMENT
		if ( SQLAllocEnv( &hEnv ) != SQL_SUCCESS )
		{
			QMessageBox::critical( pCanvas, "Data Manager", "Call to the ODBC Driver Manager failed" );
			return;
		}

		// ADD CHILD NODES; only classODBC knows what they may be
		pDrivers 			= new classDrivers( this, pCanvas, hEnv );
		pDataSourcesSystem	= new classDataSources( this, pDrivers, pCanvas, classDataSources::System, hEnv );
		pDataSourcesUser	= new classDataSources( this, pDataSourcesSystem, pCanvas, classDataSources::User, hEnv );
    }
    QListViewItem::setOpen( o );
}

void classODBC::setup()
{
    setExpandable( TRUE );
    QListViewItem::setup();
}

void classODBC::selectionChanged( QListViewItem *p )
{
	if ( pDrivers ) pDrivers->selectionChanged( p );
	if ( pDataSourcesUser ) pDataSourcesUser->selectionChanged( p );
	if ( pDataSourcesSystem ) pDataSourcesSystem->selectionChanged( p );

	if ( p == this )
	{
	}

}