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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/**************************************************
*
*
**************************************************
* This code was created by Peter Harvey @ CodeByDesign.
* Released under GPL 30.NOV.00
*
* Contributions from...
* -----------------------------------------------
* Peter Harvey - pharvey@codebydesign.com
**************************************************/
#include "classBrowseFrame.h"
#include "classBrowse.h"
#ifdef QT_V4LAYOUT
#include <Qt/qtoolbutton.h>
#include <Qt/q3toolbar.h>
#include <Qt/qmenubar.h>
#include <Qt/qpixmap.h>
#include <Qt/qwhatsthis.h>
#else
#include <qtoolbutton.h>
#include <qtoolbar.h>
#include <qmenubar.h>
#include <qpixmap.h>
#include <qwhatsthis.h>
#endif
#include "run.xpm"
#include "new.xpm"
#include "open.xpm"
#include "save.xpm"
classBrowseFrame::classBrowseFrame( SQLHDBC hDbc, const QString &qsTable, const QString &qsLibrary, QWidget *parent, const char *name )
#ifdef QT_V4LAYOUT
: Q3MainWindow( parent, name, 0 )
#else
: QMainWindow( parent, name, 0 )
#endif
{
// CLIENT AREA
browse = new classBrowse( hDbc, qsTable, qsLibrary, this );
setCentralWidget( browse );
// SETUP MAIN MENU
QMenuBar *menubarMain = new QMenuBar( this );
#ifdef QT_V4LAYOUT
Q3PopupMenu *pFile = new Q3PopupMenu();
pFile->insertItem( QPixmap( new_xpm ), tr("&Clear" ), browse, SLOT(Clear() ), Qt::CTRL+Qt::Key_C );
pFile->insertItem( QPixmap( save_xpm ), tr("&Save" ), browse, SLOT(Save() ), Qt::CTRL+Qt::Key_S );
pFile->insertItem( QPixmap( save_xpm ), tr("Save &As" ), browse, SLOT(SaveAs() ), Qt::CTRL+Qt::Key_A );
pFile->insertItem( QPixmap( save_xpm ), tr("Save S&QL"), browse, SLOT(SaveSQL()), Qt::CTRL+Qt::Key_Q );
#else
QPopupMenu *pFile = new QPopupMenu();
pFile->insertItem( QPixmap( new_xpm ), tr("&Clear" ), browse, SLOT(Clear() ), CTRL+Key_C );
pFile->insertItem( QPixmap( save_xpm ), tr("&Save" ), browse, SLOT(Save() ), CTRL+Key_S );
pFile->insertItem( QPixmap( save_xpm ), tr("Save &As" ), browse, SLOT(SaveAs() ), CTRL+Key_A );
pFile->insertItem( QPixmap( save_xpm ), tr("Save S&QL"), browse, SLOT(SaveSQL()), CTRL+Key_Q );
#endif
menubarMain->insertItem( tr("&File"), pFile );
#ifdef QT_V4LAYOUT
Q3PopupMenu *pEdit = new Q3PopupMenu();
#else
QPopupMenu *pEdit = new QPopupMenu();
#endif
pEdit->insertItem( tr("Select All Columns"), browse, SLOT(SelectAllColumns() ) );
pEdit->insertItem( tr("Unselect All Columns"), browse, SLOT(UnSelectAllColumns()) );
pEdit->insertItem( tr("Clear All Column Sorting"), browse, SLOT(UnSortAllColumns() ) );
pEdit->insertItem( tr("Clear All Column Expressions"), browse, SLOT(UnExprAllColumns() ) );
menubarMain->insertItem( tr("&Filter"), pEdit );
#ifdef QT_V4LAYOUT
pResults = new Q3PopupMenu();
#else
pResults = new QPopupMenu();
#endif
pResults->insertItem( tr("Delete Selected Rows"), browse, SLOT(DeleteRows() ) );
pResults->insertItem( tr("Insert Selected Rows"), browse, SLOT(InsertRows() ) );
pResults->insertSeparator();
pResults->insertItem( tr("Add blank row for inserting"), browse, SLOT(AddRow() ) );
pResults->insertItem( tr("Copy selected row for inserting"), browse, SLOT(CopyRow() ) );
pResults->insertSeparator();
nAutoRefresh = pResults->insertItem( tr("Auto refresh after Delete/Insert"), this, SLOT(autoRefresh() ) );
pResults->setItemChecked( nAutoRefresh , true );
menubarMain->insertItem( tr("&Results"), pResults );
QString t ; t.sprintf(" [%s.%s] ", qsLibrary.ascii(), qsTable.ascii() ) ;
menubarMain->insertItem( t );
menubarMain->setSeparator( QMenuBar::InWindowsStyle );
// SETUP TOOLBAR
#ifdef QT_V4LAYOUT
Q3ToolBar *toolbarMain = new Q3ToolBar( this );
addToolBar( toolbarMain, tr( "ToolBar" ), Qt::Top, FALSE );
#else
QToolBar *toolbarMain = new QToolBar( this );
addToolBar( toolbarMain, tr( "ToolBar" ), Top, FALSE );
#endif
new QToolButton( QPixmap( new_xpm ), QString(tr("Clear")), "", browse, SLOT(Clear()), toolbarMain );
new QToolButton( QPixmap( save_xpm ), QString(tr("Save") ), "", browse, SLOT(Save() ), toolbarMain );
new QToolButton( QPixmap( run_xpm ), QString(tr("Run") ), "", browse, SLOT(Exec() ), toolbarMain );
QWhatsThis::whatsThisButton( toolbarMain );
// RESIZE
#ifdef QT_V4LAYOUT
connect( parent, SIGNAL(changedSize(int,int)), SLOT(Resize(int,int)) );
#else
connect( parent, SIGNAL(changedSize(int,int)), SLOT(resize(int,int)) );
#endif
resize( parent->size() );
setMinimumSize( 50, 50 );
setMaximumSize( 32767, 32767 );
}
void classBrowseFrame::resizeEvent( QResizeEvent *p )
{
resize( p->size() );
}
void classBrowseFrame::autoRefresh()
{
pResults->setItemChecked( nAutoRefresh, !pResults->isItemChecked( nAutoRefresh ) ) ;
browse->AutoRefresh( pResults->isItemChecked( nAutoRefresh ) ) ;
}
void classBrowseFrame::Resize( int x, int y )
{
resize( x, y );
}
|