~ubuntu-branches/debian/sid/unixodbc/sid

« back to all changes in this revision

Viewing changes to DataManagerII/classODBC.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2004-10-15 03:07:52 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041015030752-dzw4vhxlgycz3woj
Tags: 2.2.4-11
Brown paper bag me: conflicts do not write themselves just because
you add a line to the changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************
 
2
 *
 
3
 *
 
4
 **************************************************
 
5
 * This code was created by Peter Harvey @ CodeByDesign.
 
6
 * Released under GPL 18.FEB.99
 
7
 *
 
8
 * Contributions from...
 
9
 * -----------------------------------------------
 
10
 * Peter Harvey         - pharvey@codebydesign.com
 
11
 **************************************************/
 
12
 
 
13
#include "classODBC.h"
 
14
#include <qpixmap.h>
 
15
#include <classDrivers.h>
 
16
#include <classDataSources.h>
 
17
#include "ODBC.xpm"
 
18
 
 
19
// ***********************************
 
20
//   Common Utilities
 
21
// ***********************************
 
22
 
 
23
void my_msgBox( const QString & className,
 
24
             const QString & actionName,
 
25
             SQLRETURN rc,
 
26
             SQLHENV  hEnv,
 
27
             SQLHDBC  hDbc,
 
28
             SQLHSTMT hStmt,
 
29
             const QString & moreInfo,
 
30
             QMessageBox::Icon icon )
 
31
{
 
32
  QString caption = "DataManager - " + className + " - " + actionName ;
 
33
  QString text = actionName ;
 
34
 
 
35
  if ( rc )
 
36
    text += " failed, rc=" + QString::number(rc) ;
 
37
 
 
38
  if ( hEnv || hDbc || hStmt )
 
39
  {
 
40
    char szState[SQL_SQLSTATE_SIZE+1]    ; szState[0] = 0 ;
 
41
    char szBuf[SQL_MAX_MESSAGE_LENGTH+1] ; szBuf[0]   = 0 ;
 
42
    SQLINTEGER  sqlCode = 0;
 
43
    SQLSMALLINT length  = 0 ;
 
44
    int nRec = 0 ;
 
45
    while (SQL_SUCCEEDED(SQLGetDiagRec( hStmt ? SQL_HANDLE_STMT : hDbc ? SQL_HANDLE_DBC : SQL_HANDLE_ENV,
 
46
                                       hStmt ? hStmt           : hDbc ? hDbc           : hEnv,
 
47
                                       ++nRec,
 
48
                                       (SQLCHAR*)szState,
 
49
                                       &sqlCode,
 
50
                                       (SQLCHAR*)szBuf,
 
51
                                       sizeof(szBuf),
 
52
                                       &length) ) )
 
53
      text += QString().sprintf("\n[%d] SQLSTATE:%s SQLCODE:%d %s", nRec, szState, sqlCode, szBuf) ;
 
54
  }
 
55
 
 
56
  if ( !moreInfo.isEmpty() )
 
57
    text += "\n\nInfo:" + moreInfo ;
 
58
 
 
59
  QMessageBox(caption, text, icon, QMessageBox::Ok | QMessageBox::Default | QMessageBox::Escape, QMessageBox::NoButton, QMessageBox::NoButton ).exec() ;
 
60
}
 
61
 
 
62
// ***********************************
 
63
// ***********************************
 
64
 
 
65
classODBC::classODBC( QListView *pParent, classCanvas *pCanvas )
 
66
    : classNode( pParent, pCanvas ) , pDrivers ( NULL ) , pDataSourcesUser( NULL ) , pDataSourcesSystem( NULL )
 
67
{
 
68
  setPixmap( 0, QPixmap(xpmODBC) );
 
69
  setText( 0, "ODBC" );
 
70
  setText( 1, "" );
 
71
  setText( 2, "Open Database Connectivity" );
 
72
  setExpandable( TRUE );
 
73
}
 
74
 
 
75
void classODBC::setOpen( bool bOpen )
 
76
{
 
77
  if ( bOpen && !childCount() ) // Only create item once
 
78
  {
 
79
    // ADD CHILD NODES; only classODBC knows what they may be
 
80
    pDrivers           = new classDrivers    ( this, NULL,               pCanvas         );
 
81
    pDataSourcesSystem = new classDataSources( this, pDrivers,           pCanvas, System );
 
82
    pDataSourcesUser   = new classDataSources( this, pDataSourcesSystem, pCanvas, User   );
 
83
  }
 
84
 
 
85
  QListViewItem::setOpen( bOpen );
 
86
}
 
87
 
 
88
void classODBC::selectionChanged( QListViewItem *p )
 
89
{
 
90
  if ( pDataSourcesUser )   pDataSourcesUser->selectionChanged( p );
 
91
  if ( pDataSourcesSystem ) pDataSourcesSystem->selectionChanged( p );
 
92
}
 
93