File: classConnectionFrame.cpp

package info (click to toggle)
unixodbc 2.2.14p2-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 14,620 kB
  • sloc: ansic: 104,255; cpp: 38,573; sh: 15,958; makefile: 2,728; sql: 1
file content (177 lines) | stat: -rw-r--r-- 5,487 bytes parent folder | download | duplicates (2)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**************************************************
 *
 *
 **************************************************
 * This code was created by Peter Harvey @ CodeByDesign.
 * Released under GPL 30.NOV.00
 *
 * Contributions from...
 * -----------------------------------------------
 * Peter Harvey		- pharvey@codebydesign.com
 **************************************************/
#include "classConnectionFrame.h"

#include "run.xpm"
#include "new.xpm"
#include "open.xpm"
#include "save.xpm"

classConnectionFrame::classConnectionFrame( SQLHDBC hDbc, QString qsDataSource, QWidget *parent, const char *name )
#ifdef QT_V4LAYOUT
	: Q3MainWindow( parent, name, 0 )
#else
	: QMainWindow( parent, name, 0 )
#endif
{
    QString         qsCaption;

	qsCaption.sprintf( "Connected to %s", (const char *)qsDataSource );
    setCaption( qsCaption );
 
    // CLIENT AREA
    isql = new classISQL( hDbc, qsDataSource, this ); 
    setCentralWidget( isql );

    // SETUP MAIN MENU
    menubarMain = new QMenuBar( this );
    menubarMain->setFrameStyle( QFrame::NoFrame );

#ifdef QT_V4LAYOUT
    Q3PopupMenu *pFile = new Q3PopupMenu();
#else
    QPopupMenu *pFile = new QPopupMenu();
#endif
#ifdef QT_V4LAYOUT
    pFile->insertItem( QPixmap( new_xpm ), tr("&New"),  this, SLOT(New()), Qt::CTRL+Qt::Key_N );
    pFile->insertItem( QPixmap( open_xpm ), tr("&Open"),  this, SLOT(Open()), Qt::CTRL+Qt::Key_O );
    pFile->insertItem( QPixmap( save_xpm ), tr("&Save"), this, SLOT(Save()), Qt::CTRL+Qt::Key_S );
    pFile->insertItem( tr("Save &As"), this, SLOT(SaveAs()), Qt::CTRL+Qt::Key_A );
    pFile->insertItem( QPixmap( run_xpm ), tr("&Run"), this, SLOT(Exec()), Qt::CTRL+Qt::Key_R );
#else
    pFile->insertItem( QPixmap( new_xpm ), tr("&New"),  this, SLOT(New()), CTRL+Key_N );
    pFile->insertItem( QPixmap( open_xpm ), tr("&Open"),  this, SLOT(Open()), CTRL+Key_O );
    pFile->insertItem( QPixmap( save_xpm ), tr("&Save"), this, SLOT(Save()), CTRL+Key_S );
    pFile->insertItem( tr("Save &As"), this, SLOT(SaveAs()), CTRL+Key_A );
    pFile->insertItem( QPixmap( run_xpm ), tr("&Run"), this, SLOT(Exec()), CTRL+Key_R );
#endif
    menubarMain->insertItem( tr("&File"), pFile );
    
#ifdef QT_V4LAYOUT
    pView = new Q3PopupMenu();
#else
    pView = new QPopupMenu();
#endif
    nView = nViewGUI    = pView->insertItem( tr("GUI Table"), this, SLOT(setViewGUI()) );
    nViewText           = pView->insertItem( tr("Text Table"), this, SLOT(setViewText()) );
    nViewTextDelimited  = pView->insertItem( tr("Text Delimited"), this, SLOT(setViewTextDelimited()) );
    nViewHTML           = pView->insertItem( tr("HTML Table"), this, SLOT(setViewHTML()) );
    nViewHTMLSource     = pView->insertItem( tr("HTML Source"), this, SLOT(setViewHTMLSource()) );
    pView->setItemChecked( nView, true );
    menubarMain->insertItem( tr("&View"), pView );

    menubarMain->setSeparator( QMenuBar::InWindowsStyle );

    // SETUP TOOLBAR
#ifdef QT_V4LAYOUT
    toolbarMain = new Q3ToolBar( this );
    addToolBar( toolbarMain, tr( "ToolBar" ), Qt::Top, FALSE );
#else
    toolbarMain = new QToolBar( this );
    addToolBar( toolbarMain, tr( "ToolBar" ), Top, FALSE );
#endif

    QToolButton *toolbutton = new QToolButton( QPixmap( new_xpm ), QString(tr("New")), QString(""), this, SLOT(New()), toolbarMain );
    toolbutton = new QToolButton( QPixmap( open_xpm ), QString(tr("Open")), QString(""), this, SLOT(Open()), toolbarMain );
    toolbutton = new QToolButton( QPixmap( save_xpm ), QString(tr("Save")), QString(""), this, SLOT(Save()), toolbarMain );
    toolbutton = new QToolButton( QPixmap( run_xpm ), QString(tr("Run")), QString(""), this, SLOT(Exec()), toolbarMain );
    QWhatsThis::whatsThisButton ( toolbarMain );

    // STATUS BAR
//    statusbarMain = new QStatusBar( this );

    // 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 );
}


classConnectionFrame::~classConnectionFrame()
{
}

void classConnectionFrame::resizeEvent( QResizeEvent *p )
{
    resize( p->size() );
}


void classConnectionFrame::New()         // CLEAR QUERY AND DATA
{
    isql->NewSQL();
}

void classConnectionFrame::Open()         // CLEAR QUERY AND DATA
{
    isql->OpenSQL();
}

void classConnectionFrame::Save()        // DATA
{
    isql->SaveSQL();
}

void classConnectionFrame::SaveAs()      // DATA
{
    isql->SaveAsSQL();
}

void classConnectionFrame::Exec()        // RUN QUERY
{
    isql->ExecSQL();
}

void classConnectionFrame::setViewHTML()
{
    pView->setItemChecked( nView, false );
    nView = nViewHTML;
    pView->setItemChecked( nView, true );
}

void classConnectionFrame::setViewHTMLSource()
{
    pView->setItemChecked( nView, false );
    nView = nViewHTMLSource;
    pView->setItemChecked( nView, true );
}

void classConnectionFrame::setViewGUI()
{
    pView->setItemChecked( nView, false );
    nView = nViewGUI;
    pView->setItemChecked( nView, true );
}

void classConnectionFrame::setViewText()
{
    pView->setItemChecked( nView, false );
    nView = nViewText;
    pView->setItemChecked( nView, true );
}

void classConnectionFrame::setViewTextDelimited()
{
    pView->setItemChecked( nView, false );
    nView = nViewTextDelimited;
    pView->setItemChecked( nView, true );
}

void classConnectionFrame::Resize( int x, int y )
{
	resize( x, y );
}