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

« back to all changes in this revision

Viewing changes to DataManagerII/classISQL.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 "classISQL.h"
 
14
#include "classODBC.h"
 
15
#include <qwhatsthis.h>
 
16
#include <sqlucode.h>
 
17
#include <qlistbox.h>
 
18
 
 
19
char *szHelpSQL = \
 
20
"Use this area to type SQL statements for your query.\n" \
 
21
"For example:  SELECT * FROM TABLE1\n"
 
22
"You can cut/paste and save/load text in this area\n" ;
 
23
 
 
24
char *szHelpSQLSlider = \
 
25
"Use this slider to quickly access recent SQL statements.\n" ;
 
26
 
 
27
char *szHelpResults = \
 
28
"This area contains the output from your recent SQL query.\n" \
 
29
"You can cut/paste and save/load data in this area.\n" \
 
30
"NOTE: The max column size is 1024." ;
 
31
 
 
32
char *szHelpStatus = \
 
33
"This area contains status messages.\n" ;
 
34
 
 
35
classISQL::classISQL( SQLHDBC hDbc, QString qsDataSource, QWidget *parent, const char *name )
 
36
  : QWidget( parent, name ), hDbc( hDbc ), qsDataSource( qsDataSource.stripWhiteSpace() ), nSQL( 1 )
 
37
{
 
38
    QVBoxLayout *layoutMain = new QVBoxLayout( this );
 
39
 
 
40
    // SET FONT
 
41
    QFont qf( "Fixed", 12 );
 
42
    qf.setFixedPitch( TRUE );
 
43
 
 
44
    // TAB BAR
 
45
    pTabBar = new QTabBar( this );
 
46
    pTabBar->setGeometry( 0, 0, 150, 20 );
 
47
    pTabBar->addTab( new QTab( "SQL"     ) ) ;
 
48
    pTabBar->addTab( new QTab( "Results" ) ) ;
 
49
    connect( pTabBar, SIGNAL(selected(int)), SLOT(ChangeTextType(int)) );
 
50
 
 
51
    // SQL ENTRY GUI
 
52
    txtSQL = new QMultiLineEdit( this, "txtSQL" );
 
53
    txtSQL->setFocusPolicy( QWidget::StrongFocus );
 
54
    txtSQL->setBackgroundMode( QWidget::PaletteBase );
 
55
    txtSQL->insertLine( "" );
 
56
    txtSQL->setReadOnly( FALSE );
 
57
    txtSQL->setOverwriteMode( FALSE );
 
58
    txtSQL->setFont( qf );
 
59
 
 
60
    // SQL DATA RESULTS GUI
 
61
    txtResults = new QMultiLineEdit( this, "txtResults" );
 
62
    txtResults->setFocusPolicy( QWidget::StrongFocus );
 
63
    txtResults->setBackgroundMode( QWidget::PaletteBase );
 
64
    txtResults->insertLine( "" );
 
65
    txtResults->setReadOnly( FALSE );
 
66
    txtResults->setOverwriteMode( FALSE );
 
67
    txtResults->setFont( qf );
 
68
    txtResults->hide();
 
69
 
 
70
    // QUICK ACCESS SLIDER
 
71
    pSliderRecentSQL = new QSlider( QSlider::Horizontal, this );
 
72
    pSliderRecentSQL->setTickmarks( QSlider::Left );
 
73
    pSliderRecentSQL->setTickInterval( 1 );
 
74
    pSliderRecentSQL->setLineStep( 1 );
 
75
    pSliderRecentSQL->setPageStep( 1 );
 
76
    pSliderRecentSQL->setMinValue( nSQL );
 
77
    pSliderRecentSQL->setMaxValue( nSQL );
 
78
    pSliderRecentSQL->setValue( nSQL );
 
79
    connect( pSliderRecentSQL, SIGNAL(valueChanged(int)), SLOT(gotoHistoryItem(int)) );
 
80
    listSQL.append( "" );
 
81
 
 
82
    // STATUS LABEL
 
83
    QLabel *labelStatus = new QLabel( "STATUS", this );
 
84
    labelStatus->setAlignment( AlignCenter );
 
85
 
 
86
    // STATUS LISTBOX
 
87
    listStatus = new QListBox( this );
 
88
    listStatus->setSelectionMode( QListBox::NoSelection );
 
89
 
 
90
    // HELP TIPS
 
91
    QWhatsThis::add( txtSQL           , szHelpSQL       );
 
92
    QWhatsThis::add( pSliderRecentSQL , szHelpSQLSlider );
 
93
    QWhatsThis::add( txtResults       , szHelpResults   );
 
94
    QWhatsThis::add( labelStatus      , szHelpStatus    );
 
95
    QWhatsThis::add( listStatus       , szHelpStatus    );
 
96
 
 
97
    // LAYOUT GUI
 
98
    layoutMain->addWidget( pTabBar          );
 
99
    layoutMain->addWidget( txtSQL,     6    );
 
100
    layoutMain->addWidget( txtResults, 6    );
 
101
    layoutMain->addWidget( pSliderRecentSQL );
 
102
    layoutMain->addWidget( labelStatus      );
 
103
    layoutMain->addWidget( listStatus, 2    );
 
104
 
 
105
    // SETUP SIZE
 
106
    setMinimumSize( 50, 50 );
 
107
    setMaximumSize( 32767, 32767 );
 
108
    resize( parent->size() );
 
109
}
 
110
 
 
111
void classISQL::addStatus( const QString &statusMsg )
 
112
{
 
113
  if ( listStatus->count() == 300 )
 
114
    listStatus->removeItem( 0 ) ;
 
115
 
 
116
  listStatus->insertItem( statusMsg ) ;
 
117
  listStatus->setBottomItem( listStatus->count()-1 ) ;
 
118
}
 
119
 
 
120
void classISQL::ExecSQL(View view)
 
121
{
 
122
    CursorScoper s(this) ;
 
123
    QString      qsHorizSep;
 
124
    SQLLEN       nRowsAffected;
 
125
    SWORD        nColumns;
 
126
    SQLRETURN    nReturn;
 
127
 
 
128
    txtResults->clear();
 
129
 
 
130
    addStatus( QString().sprintf( "RUN: view=%s sql=%s", view == Text ? "Text" : view == TextDelimited ? "TextDelimited" : "HTML", txtSQL->text().simplifyWhiteSpace().data() ) ) ;
 
131
 
 
132
    // CREATE A STATEMENT
 
133
    StatementScoper stmt( hDbc ) ; if ( !stmt() ) return ;
 
134
 
 
135
    // PREPARE
 
136
    if (!SQL_SUCCEEDED(nReturn=SQLPrepare(stmt(), (SQLCHAR*)txtSQL->text().simplifyWhiteSpace().data(), SQL_NTS) ) )
 
137
      return my_msgBox( "classISQL", "SQLPrepare", nReturn, NULL, NULL, stmt(), txtSQL->text() ) ;
 
138
 
 
139
    // EXECUTE
 
140
    if (!SQL_SUCCEEDED(nReturn=SQLExecute( stmt() ) ) )
 
141
      return my_msgBox( "classISQL", "SQLExecute", nReturn, NULL, NULL, stmt(), txtSQL->text() ) ;
 
142
 
 
143
    // UPDATE HISTORY
 
144
    appendHistoryItem();
 
145
 
 
146
    // GET NUMBER OF COLUMNS RETURNED
 
147
    if (!SQL_SUCCEEDED(SQLNumResultCols( stmt(), &nColumns ) ) )
 
148
        nColumns = 0;
 
149
 
 
150
    txtResults->setAutoUpdate( FALSE );
 
151
 
 
152
    switch ( view )
 
153
    {
 
154
      case Text:
 
155
      {
 
156
        QString qsHorizSep;
 
157
        QArray<int> colWidths(nColumns) ;
 
158
        // GET A RESULTS HEADER (column headers)
 
159
        getResultsHeader( stmt(), nColumns, qsHorizSep, colWidths );
 
160
        // GET A RESULTS BODY (data)
 
161
        nRowsAffected = getResultsBody( stmt(), nColumns, qsHorizSep, colWidths );
 
162
      }
 
163
      break ;
 
164
 
 
165
      case TextDelimited:
 
166
      {
 
167
        int nCol ;
 
168
        QString qsLine ;
 
169
        const char **colChar = new const char * [nColumns ];
 
170
 
 
171
        // Get Column Names
 
172
        for ( nCol = 1; nCol <= nColumns; nCol++ )
 
173
        {
 
174
          SQLCHAR szColumnName[MAX_COLUMN_WIDTH];
 
175
          if (SQL_SUCCEEDED(SQLColAttribute( stmt(), nCol, SQL_DESC_LABEL, szColumnName, sizeof(szColumnName), 0, 0 ) ) )
 
176
            qsLine += QString("\"") + QString((const char *)szColumnName).stripWhiteSpace() + "\","  ;
 
177
          else
 
178
            qsLine += "\"ERR\"," ;
 
179
 
 
180
          // Determine if this column needs to have quotes around it
 
181
          SQLINTEGER nConciseType = 0 ;
 
182
          colChar[nCol]           = "" ;
 
183
          if (SQL_SUCCEEDED(SQLColAttribute( stmt(), nCol, SQL_DESC_CONCISE_TYPE, 0, 0, 0, &nConciseType ) ) )
 
184
          {
 
185
            switch (nConciseType)
 
186
            {
 
187
              case SQL_CHAR:         // =1
 
188
              case SQL_VARCHAR:      // =12
 
189
              case SQL_LONGVARCHAR:  // =-1
 
190
              case SQL_WCHAR:        // =-8
 
191
              case SQL_WVARCHAR:     // =-9
 
192
              case SQL_WLONGVARCHAR: // =-10
 
193
                colChar[nCol] = "\"" ;
 
194
              break ;
 
195
 
 
196
              default:
 
197
              break;
 
198
            }
 
199
          }
 
200
        }
 
201
        txtResults->insertLine( qsLine );
 
202
 
 
203
        // Get Data
 
204
        int nRow = 0;
 
205
        while ( SQL_SUCCEEDED(SQLFetch(stmt() ) ) )
 
206
        {
 
207
          nRow++;
 
208
          qsLine = "";
 
209
          // Process all columns
 
210
          for ( nCol = 1; nCol <= nColumns; nCol++ )
 
211
          {
 
212
            char szData[MAX_COLUMN_WIDTH];
 
213
            memset(szData, 0, sizeof(szData) ) ; // Handle broken drivers that don't properly null terminate
 
214
            SQLLEN nIndicator               = 0;
 
215
            if (SQL_SUCCEEDED(SQLGetData( stmt(), nCol, SQL_C_CHAR, (SQLPOINTER)szData, sizeof(szData), &nIndicator ) ) )
 
216
              qsLine += QString().sprintf("%s%s%s,", colChar[nCol], nIndicator != SQL_NULL_DATA ? QString(szData).stripWhiteSpace().data() : "", colChar[nCol] ) ;
 
217
            else
 
218
              qsLine += QString("\"ERR\",")  ;
 
219
          }
 
220
          txtResults->insertLine( qsLine );
 
221
        }
 
222
        nRowsAffected = nRow ;
 
223
 
 
224
        delete colChar;
 
225
      }
 
226
      break ;
 
227
 
 
228
      case HTMLSource:
 
229
      {
 
230
        int nCol ;
 
231
        txtResults->insertLine( "<html>"  ) ;
 
232
        txtResults->insertLine( "<body>"  ) ;
 
233
        txtResults->insertLine( "<table border>" ) ;
 
234
        txtResults->insertLine( QString().sprintf("<caption>%s</caption>", txtSQL->text().data() ) ) ;
 
235
        // Get Column Names
 
236
        txtResults->insertLine( "  <tr>"    );
 
237
        SQLCHAR szColumnName[MAX_COLUMN_WIDTH] ;
 
238
        for ( nCol = 1; nCol <= nColumns; nCol++ )
 
239
        {
 
240
          if (SQL_SUCCEEDED(SQLColAttribute( stmt(), nCol, SQL_DESC_LABEL, szColumnName, sizeof(szColumnName), 0, 0 ) ) )
 
241
            txtResults->insertLine( QString().sprintf("    <th>%s</th>", QString((const char *)szColumnName).stripWhiteSpace().data() ) ) ;
 
242
          else
 
243
            txtResults->insertLine( "    <th>ERR</th>" ) ;
 
244
        }
 
245
        txtResults->insertLine( "  </tr>"   );
 
246
 
 
247
        // Get Data
 
248
        int nRow = 0;
 
249
        while ( SQL_SUCCEEDED(SQLFetch(stmt() ) ) )
 
250
        {
 
251
          nRow++;
 
252
          txtResults->insertLine( "  <tr>" );
 
253
          // Process all columns
 
254
          for ( nCol = 1; nCol <= nColumns; nCol++ )
 
255
          {
 
256
            char   szData[MAX_COLUMN_WIDTH] ;
 
257
            SQLLEN nIndicator = 0;
 
258
            memset(szData, 0, sizeof(szData) ) ; // Handle broken drivers that don't properly null terminate
 
259
            if (SQL_SUCCEEDED(SQLGetData( stmt(), nCol, SQL_C_CHAR, (SQLPOINTER)szData, sizeof(szData), &nIndicator ) ) )
 
260
              txtResults->insertLine( QString().sprintf("    <td>%s</td>", nIndicator != SQL_NULL_DATA ? QString((const char *)szData).stripWhiteSpace().data() : "" ) ) ;
 
261
            else
 
262
              txtResults->insertLine( "    <td>ERR</td>" ) ;
 
263
          }
 
264
          txtResults->insertLine( "  </tr>" );
 
265
        }
 
266
 
 
267
        txtResults->insertLine( "</table>" ) ;
 
268
        txtResults->insertLine( "</body>"  ) ;
 
269
        txtResults->insertLine( "</html>"  ) ;
 
270
        nRowsAffected = nRow ;
 
271
      }
 
272
      break ;
 
273
    }
 
274
 
 
275
    // UPDATE THE GUI
 
276
    pTabBar->setCurrentTab( 1 );
 
277
    txtResults->show();
 
278
    txtSQL->hide();
 
279
    txtResults->setAutoUpdate( TRUE );
 
280
    txtResults->repaint();
 
281
    addStatus( QString().sprintf( "RUN: %d rows and %d columns affected", nRowsAffected, nColumns ) ) ;
 
282
}
 
283
 
 
284
void classISQL::getResultsHeader( SQLHSTMT hStmt, SWORD nColumns, QString &qsHorizSep, QArray<int> &colWidths )
 
285
{
 
286
    QString qsColumnHeader;
 
287
    QString qsFill ; qsFill.fill('-', MAX_COLUMN_WIDTH);
 
288
    for ( int nCol = 1; nCol <= nColumns; nCol++ )
 
289
    {
 
290
        unsigned int nMaxLength;
 
291
        SQLCHAR      szColumnName[MAX_COLUMN_WIDTH]; szColumnName[0] = 0;
 
292
        // Grab the column name and display size
 
293
        SQLColAttribute( hStmt, nCol, SQL_DESC_DISPLAY_SIZE, 0, 0, 0, &nMaxLength );
 
294
        SQLColAttribute( hStmt, nCol, SQL_DESC_LABEL, szColumnName, sizeof(szColumnName), 0, 0 ) ;
 
295
        QString qsColumnName( QString((const char *)szColumnName).stripWhiteSpace() ) ;
 
296
        // Calc the column width
 
297
        int nWidth = max( nMaxLength, qsColumnName.length() ) ;
 
298
        nWidth = min( nWidth, MAX_COLUMN_WIDTH );
 
299
        // Buld the formatted column
 
300
        qsHorizSep     += QString().sprintf( "+%-*.*s-" , nWidth, nWidth, qsFill.data()       ) ;
 
301
        qsColumnHeader += QString().sprintf( "| %-*.*s" , nWidth, nWidth, qsColumnName.data() ) ;
 
302
        colWidths[nCol-1] = nWidth ;
 
303
    }
 
304
    qsHorizSep += "+";
 
305
    qsColumnHeader += "|";
 
306
 
 
307
    txtResults->insertLine( qsHorizSep );
 
308
    txtResults->insertLine( qsColumnHeader );
 
309
    txtResults->insertLine( qsHorizSep );
 
310
}
 
311
 
 
312
int classISQL::getResultsBody( SQLHSTMT hStmt, SWORD nColumns, const QString &qsHorizSep, const QArray<int> &colWidths )
 
313
{
 
314
  int nRow = 0;
 
315
 
 
316
  // PROCESS ALL ROWS
 
317
  while ( SQL_SUCCEEDED(SQLFetch(hStmt) ) )
 
318
  {
 
319
    nRow++;
 
320
    QString qsLine;
 
321
    // PROCESS ALL COLUMNS
 
322
    for ( int nCol = 1; nCol <= nColumns; nCol++ )
 
323
    {
 
324
      SQLLEN nIndicator;
 
325
      char   szData[MAX_COLUMN_WIDTH]; szData[0] = 0;
 
326
      SQLRETURN nReturn = SQLGetData( hStmt, nCol, SQL_C_CHAR, (SQLPOINTER)szData, sizeof(szData), &nIndicator );
 
327
      // Grab the column data
 
328
      if ( SQL_SUCCEEDED(nReturn) && nIndicator != SQL_NULL_DATA )
 
329
        qsLine += QString().sprintf( "| %-*.*s", colWidths[nCol-1], colWidths[nCol-1], szData );
 
330
      else
 
331
        qsLine += QString().sprintf( "| %-*.*s", colWidths[nCol-1], colWidths[nCol-1], " "    );
 
332
    }
 
333
    txtResults->insertLine( qsLine + "|" );
 
334
  }
 
335
  txtResults->insertLine( qsHorizSep );
 
336
  return nRow ;
 
337
}
 
338
 
 
339
void classISQL::ChangeTextType( int nTab )
 
340
{
 
341
    if ( nTab == 0 )
 
342
    {
 
343
        pSliderRecentSQL->show();
 
344
        txtSQL->show();
 
345
        txtResults->hide();
 
346
    }
 
347
    else
 
348
    {
 
349
        pSliderRecentSQL->hide();
 
350
        txtSQL->hide();
 
351
        txtResults->show();
 
352
    }
 
353
}
 
354
 
 
355
void classISQL::gotoHistoryItem( int nValue )
 
356
{
 
357
    QValueList<QString>::Iterator it;
 
358
 
 
359
    // SAVE ANY CHANGES
 
360
    it      = listSQL.at( nSQL );
 
361
    (*it)   = txtSQL->text();
 
362
 
 
363
    // MOVE
 
364
    nSQL    = nValue;
 
365
    it      = listSQL.at( nSQL );
 
366
    txtSQL->setText( (*it) );
 
367
 
 
368
    // Lets keep it simple for now, previous sql can be executed again but not edited, force
 
369
    // the user to copy and paste to last sql for editing. Remember; its important to maintain
 
370
    // a history of executed statements, unchanged, so that the user can audit self.
 
371
    QPalette oPalette = txtResults->palette();
 
372
 
 
373
    if ( nSQL == pSliderRecentSQL->maxValue() )
 
374
    {
 
375
        txtSQL->setReadOnly( false );
 
376
        txtSQL->setPalette( oPalette );
 
377
    }
 
378
    else
 
379
    {
 
380
        txtSQL->setReadOnly( true );
 
381
        oPalette.setColor( QColorGroup::Text, txtResults->backgroundColor() );
 
382
        oPalette.setColor( QColorGroup::Base, txtResults->foregroundColor() );
 
383
        txtSQL->setPalette( oPalette );
 
384
    }
 
385
}
 
386
 
 
387
void classISQL::appendHistoryItem()
 
388
{
 
389
    QValueList<QString>::Iterator it;
 
390
 
 
391
    // SAVE ANY CHANGES
 
392
    it      = listSQL.at( nSQL );
 
393
    (*it)   = txtSQL->text();
 
394
 
 
395
    // ADD AS LAST & MOVE TO LAST
 
396
    listSQL.append( txtSQL->text() );
 
397
    pSliderRecentSQL->setMaxValue( pSliderRecentSQL->maxValue() + 1 );
 
398
    pSliderRecentSQL->setValue( pSliderRecentSQL->maxValue() );
 
399
}
 
400
 
 
401
void classISQL::NewSQL()
 
402
{
 
403
    pSliderRecentSQL->setValue( pSliderRecentSQL->maxValue() );
 
404
    txtSQL->clear();
 
405
    qsSQLFileName = "";
 
406
    pTabBar->setCurrentTab( 0 ) ;
 
407
    addStatus( "NEW: sql text cleared" ) ;
 
408
}
 
409
 
 
410
void classISQL::OpenSQL()
 
411
{
 
412
    QMultiLineEdit *txt;
 
413
 
 
414
    if ( pTabBar->currentTab() == 0 )
 
415
    {
 
416
      pSliderRecentSQL->setValue( pSliderRecentSQL->maxValue() );
 
417
      txt = txtSQL;
 
418
    }
 
419
    else
 
420
      txt = txtResults;
 
421
 
 
422
    // LET USER PICK A FILE
 
423
    QString qsFile = QFileDialog::getOpenFileName();
 
424
    if ( qsFile.isNull() )
 
425
      return;
 
426
 
 
427
    // TRY TO LOAD THE FILE
 
428
    QFile hFile( qsFile );
 
429
    if ( !hFile.open( IO_ReadOnly ) )
 
430
      return my_msgBox( "classISQL", "QFile.open", hFile.status(), NULL, NULL, NULL, qsFile ) ;
 
431
 
 
432
    txt->setAutoUpdate( FALSE );
 
433
    txt->clear();
 
434
 
 
435
    QTextStream t( &hFile );
 
436
    while ( !t.eof() )
 
437
      txt->append( t.readLine() ) ;
 
438
    hFile.close();
 
439
 
 
440
    txt->setAutoUpdate( TRUE );
 
441
    txt->repaint();
 
442
 
 
443
    if ( pTabBar->currentTab() == 0 )
 
444
      qsSQLFileName = qsFile;
 
445
    else
 
446
      qsResultsFileName = qsFile;
 
447
 
 
448
    addStatus( QString().sprintf( "OPEN: file %s opened", qsFile.data() ) ) ;
 
449
}
 
450
 
 
451
void classISQL::SaveSQL()
 
452
{
 
453
    QMultiLineEdit *txt        = pTabBar->currentTab() ? txtResults        : txtSQL        ;
 
454
    const QString  &qsFileName = pTabBar->currentTab() ? qsResultsFileName : qsSQLFileName ;
 
455
 
 
456
    if ( qsFileName.isEmpty() )
 
457
      return SaveAsSQL();
 
458
 
 
459
    // TRY TO SAVE THE FILE
 
460
    QFile hFile( qsFileName );
 
461
    if ( !hFile.open( IO_WriteOnly ) )
 
462
      return my_msgBox( "classISQL", "QFile.open", hFile.status(), NULL, NULL, NULL, qsFileName ) ;
 
463
 
 
464
    hFile.writeBlock( txt->text(), txt->text().length() );
 
465
    hFile.close();
 
466
    addStatus( QString().sprintf( "SAVE: file %s saved", qsFileName.data() ) ) ;
 
467
}
 
468
 
 
469
void classISQL::SaveAsSQL()
 
470
{
 
471
    QMultiLineEdit *txt        = pTabBar->currentTab() ? txtResults        : txtSQL        ;
 
472
    const QString  &qsFileName = pTabBar->currentTab() ? qsResultsFileName : qsSQLFileName ;
 
473
 
 
474
    // LET USER PICK A FILE
 
475
    QString qsFile = QFileDialog::getSaveFileName( qsFileName );
 
476
    if ( qsFile.isNull() )
 
477
        return;
 
478
 
 
479
    // TRY TO SAVE THE FILE
 
480
    QFile hFile( qsFile );
 
481
    if ( !hFile.open( IO_WriteOnly ) )
 
482
      return my_msgBox( "classISQL", "QFile.open", hFile.status(), NULL, NULL, NULL, qsFile ) ;
 
483
 
 
484
    hFile.writeBlock( txt->text(), txt->text().length() );
 
485
    hFile.close();
 
486
 
 
487
    // SAVE THE NEW FILE NAME
 
488
    if ( pTabBar->currentTab() == 0 )
 
489
      qsSQLFileName = qsFile;
 
490
    else
 
491
      qsResultsFileName = qsFile;
 
492
 
 
493
    addStatus( QString().sprintf( "SAVE SQL: file %s saved", qsFile.data() ) ) ;
 
494
}
 
495