You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.1 KiB
123 lines
3.1 KiB
15 years ago
|
/**********************************************************************
|
||
|
** Copyright (C) 2000 Trolltech AS. All rights reserved.
|
||
|
**
|
||
14 years ago
|
** This file is part of TQt Designer.
|
||
15 years ago
|
**
|
||
|
** This file may be distributed and/or modified under the terms of the
|
||
|
** GNU General Public License version 2 as published by the Free Software
|
||
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||
|
** packaging of this file.
|
||
|
**
|
||
14 years ago
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||
15 years ago
|
** Agreement provided with the Software.
|
||
|
**
|
||
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||
|
**
|
||
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||
14 years ago
|
** information about TQt Commercial License Agreements.
|
||
15 years ago
|
**
|
||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||
|
** not clear to you.
|
||
|
**
|
||
|
**********************************************************************/
|
||
|
|
||
|
#if defined(DESIGNER)
|
||
|
#include "database.h"
|
||
|
#else
|
||
|
#include "database2.h"
|
||
|
#endif
|
||
|
|
||
14 years ago
|
#ifndef TQT_NO_SQL
|
||
15 years ago
|
|
||
|
#if defined(DESIGNER)
|
||
|
#include "formwindow.h"
|
||
|
#include "mainwindow.h"
|
||
|
#endif
|
||
|
|
||
15 years ago
|
#include <tqsqldatabase.h>
|
||
|
#include <tqsqlform.h>
|
||
|
#include <tqsqlcursor.h>
|
||
|
#include <tqsqlrecord.h>
|
||
15 years ago
|
|
||
|
DatabaseSupport::DatabaseSupport()
|
||
|
{
|
||
|
con = 0;
|
||
|
frm = 0;
|
||
14 years ago
|
parent = 0;
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void DatabaseSupport::initPreview( const TQString &connection, const TQString &table, TQObject *o,
|
||
|
const TQMap<TQString, TQString> &databaseControls )
|
||
15 years ago
|
{
|
||
|
tbl = table;
|
||
|
dbControls = databaseControls;
|
||
14 years ago
|
parent = o;
|
||
15 years ago
|
|
||
|
if ( connection != "(default)" )
|
||
15 years ago
|
con = TQSqlDatabase::database( connection );
|
||
15 years ago
|
else
|
||
15 years ago
|
con = TQSqlDatabase::database();
|
||
|
frm = new TQSqlForm( o, table );
|
||
|
for ( TQMap<TQString, TQString>::Iterator it = dbControls.begin(); it != dbControls.end(); ++it ) {
|
||
14 years ago
|
TQObject *chld = parent->child( it.key(), TQWIDGET_OBJECT_NAME_STRING );
|
||
15 years ago
|
if ( !chld )
|
||
|
continue;
|
||
15 years ago
|
frm->insert( (TQWidget*)chld, *it );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
QDesignerDataBrowser::QDesignerDataBrowser( TQWidget *parent, const char *name )
|
||
|
: TQDataBrowser( parent, name )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
bool QDesignerDataBrowser::event( TQEvent* e )
|
||
15 years ago
|
{
|
||
15 years ago
|
bool b = TQDataBrowser::event( e );
|
||
15 years ago
|
#if defined(DESIGNER)
|
||
|
if ( MainWindow::self->isPreviewing() ) {
|
||
|
#endif
|
||
15 years ago
|
if ( e->type() == TQEvent::Show ) {
|
||
15 years ago
|
if ( con ) {
|
||
15 years ago
|
TQSqlCursor* cursor = new TQSqlCursor( tbl, TRUE, con );
|
||
15 years ago
|
setSqlCursor( cursor, TRUE );
|
||
|
setForm( frm );
|
||
|
refresh();
|
||
|
first();
|
||
|
}
|
||
|
return TRUE;
|
||
|
}
|
||
|
#if defined(DESIGNER)
|
||
|
}
|
||
|
#endif
|
||
|
return b;
|
||
|
}
|
||
|
|
||
14 years ago
|
QDesignerDataView::QDesignerDataView( TQWidget *parent, const char *name )
|
||
|
: TQDataView( parent, name )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
bool QDesignerDataView::event( TQEvent* e )
|
||
15 years ago
|
{
|
||
15 years ago
|
bool b = TQDataView::event( e );
|
||
15 years ago
|
#if defined(DESIGNER)
|
||
|
if ( MainWindow::self->isPreviewing() ) {
|
||
|
#endif
|
||
15 years ago
|
if ( e->type() == TQEvent::Show ) {
|
||
15 years ago
|
setForm( frm );
|
||
|
readFields();
|
||
|
return TRUE;
|
||
|
}
|
||
|
#if defined(DESIGNER)
|
||
|
}
|
||
|
#endif
|
||
|
return b;
|
||
|
}
|
||
|
|
||
|
|
||
|
#endif
|