-
Notifications
You must be signed in to change notification settings - Fork 3
/
fix8WindowSlots.cpp
262 lines (238 loc) · 10.7 KB
/
fix8WindowSlots.cpp
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
//-------------------------------------------------------------------------------------------------
/*
Fix8logviewer is released under the GNU LESSER GENERAL PUBLIC LICENSE Version 3.
Fix8logviewer Open Source FIX Log Viewer.
Copyright (C) 2010-14 David N Boosalis [email protected], David L. Dight <[email protected]>
Fix8logviewer is free software: you can redistribute it and / or modify it under the terms of the
GNU Lesser General Public License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.
Fix8logviewer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU Lesser General Public License along with Fix8.
If not, see <http://www.gnu.org/licenses/>.
BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO
THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO
THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT
HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED
ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
//-------------------------------------------------------------------------------------------------
#include "database.h"
#include "fix8log.h"
#include "fix8sharedlib.h"
#include "fixmimedata.h"
#include "globals.h"
#include "mainwindow.h"
#include "messagefield.h"
#include "newwindowwizard.h"
#include "schemaeditordialog.h"
#include "searchDialog.h"
#include "worksheetmodel.h"
#include "windowdata.h"
#include <QApplication>
#include <QDebug>
#include <QDialog>
#include <QQuickView>
#include <QQmlContext>
#include <QtWidgets>
#include "worksheetmodel.h"
#include <fix8/f8includes.hpp>
#include "fix8/field.hpp"
#include "fix8/message.hpp"
#include <fix8/f8types.hpp>
#include <iostream>
#include <string.h>
using namespace GUI;
using namespace FIX8;
using namespace std;
void Fix8Log::copyWindowSlot(MainWindow *mw)
{
if (!mw) {
qWarning() << "Error no window found to copy" << __FILE__ << __LINE__;
return;
}
MainWindow *newMW = new MainWindow(database);
WindowData wd = mw->getWindowData();
newMW->setWindowData(wd);
Fix8SharedLib *fixLib = mw->getSharedLibrary();
QList <WorkSheetData> wsdList = mw->getWorksheetData(0);
newMW->setSharedLibrary(fixLib);
//newMW->setTableSchema(wd.tableSchema);
newMW->setFieldUsePair(&(fixLib->fieldUsePairList));
newMW->setSearchFunctions(searchFunctionList);
newMW->setFilterFunctions(filterFunctionList);
wireSignalAndSlots(newMW);
mainWindows.append(newMW);
int xx = newMW->x();
int yy = newMW->y();
xx = xx + 150;
yy = yy + 100;
newMW->move(xx,yy);
newMW->show();
newMW->setAutoSaveOn(autoSaveOn);
// have to set style sheet after show to see it take effect
newMW->mainMenuBar->setStyleSheet(wd.menubarStyleSheet);
QListIterator <WorkSheetData> iter2(wsdList);
while(iter2.hasNext()) {
WorkSheetData wsd = iter2.next();
newMW->addWorkSheet(wsd); // do not create model, have code reuse and redo busy screen for each tab
newMW->setCurrentTabAndSelectedRow(wd.currentTab,2);
}
}
void Fix8Log::createNewWindowSlot(MainWindow *mw)
{
Fix8SharedLib *f8lib;
QString str;
newWindowWizard = new NewWindowWizard(fix8ShareLibList);
int status = newWindowWizard->exec();
newWindowWizard->saveSettings();
if (status == QDialog::Accepted ) {
QString fileName = newWindowWizard->getSelectedFile();
QString libName = newWindowWizard->getSelectedLib();
//qDebug() << "Selected File = " << fileName << __FILE__ << __LINE__;
// qDebug() << "Selected Lib = " << libName << __FILE__ << __LINE__;
f8lib = fix8ShareLibList.findByFileName(libName);
if (!f8lib) {
f8lib = Fix8SharedLib::create(libName);
if (!f8lib) {
str = "Error1 - failed to load FIX8 sharelib: " + libName;
QMessageBox::warning(0,Globals::appName,str);
newWindowWizard->deleteLater();
return;
}
if (!f8lib->isOK) {
str = "Error - " + f8lib->errorMessage;
QMessageBox::warning(0,Globals::appName,str);
delete f8lib;
newWindowWizard->deleteLater();
return;
}
}
MainWindow *newMW =new MainWindow(*mw,database);
newMW->setSearchFunctions(searchFunctionList);
wireSignalAndSlots(newMW);
newMW->setSharedLibrary(f8lib);
newMW->setFieldUsePair(&(f8lib->fieldUsePairList));
newMW->setAutoSaveOn(autoSaveOn);
newMW->setWindowData(mw->getWindowData());
newMW->show();
QElapsedTimer loadTimer;
loadTimer.start();
newMW->loadFile(fileName);
float timeOfLoad = (double)(loadTimer.elapsed())/1000.0;
str = "Loading of file " + fileName + " completed in " + QString::number(timeOfLoad,'g',3) + " seconds";
GUI::ConsoleMessage msg(str);
mainWindows.append(newMW);
}
newWindowWizard->saveSettings();
newWindowWizard->deleteLater();
/*
newWindowWizard = new QQuickView(QUrl("qrc:qml/newMainWindow.qml"));
QQmlContext *context = newWindowWizard->rootContext();
newWinWizObject = newWindowWizard->rootObject();
QObject *schemaPage = newWinWizObject->findChild<QObject*>("schemaPage");
QObject *filePage = newWinWizObject->findChild<QObject*>("filePage");
newWindowWizard->setResizeMode(QQuickView::SizeRootObjectToView);
newWindowDialog = new QDialog(0);
schemaPage->setProperty("color", newWindowDialog->palette().color(QPalette::Window));
//filePage->setProperty("color", newWindowDialog->palette().color(QPalette::Window));
QFont fnt = newWindowDialog->font();
schemaPage->setProperty("fontPointSize",fnt.pointSize()+2);
//filePage->setProperty("fontPointSize",fnt.pointSize()+2);
newWindowWidget = QWidget::createWindowContainer(newWindowWizard,newWindowDialog);
// newWindowWizard->setProperty("backgroundColor", newWindowDialog->palette().color(QPalette::Window));
QVBoxLayout *vbox = new QVBoxLayout(newWindowDialog);
newWindowDialog->setLayout(vbox);
vbox->addWidget(newWindowWidget);
newWindowDialog->resize(640,480);
newWindowDialog->exec();
*/
/*
MainWindow *newMW =new MainWindow(*mw,database);
newMW->setSearchFunctions(searchFunctionList);
wireSignalAndSlots(newMW);
newMW->show();
newMW->showFileDialog();
mainWindows.append(newMW);
*/
//const GeneratedTable<const char *, BaseMsgEntry>::Pair *p = TEX::ctx()._bme.at(1);
}
void Fix8Log::deleteMainWindowSlot(MainWindow *mw)
{
//qDebug() << "DELETE MAIN WINDOW SLOT, window count = "<< mainWindows.count() << __FILE__ << __LINE__;
if (mainWindows.count() == 1) {
if (autoSaveOn) {
// qDebug() << "\tSavie Session....";
saveSession();
}
}
if (searchDialog && (searchDialog->getMainWindow() == mw)) {
searchDialog->deleteLater();
searchDialog = 0;
}
mainWindows.removeOne(mw);
mw->hide();
mw->deleteLater();
if (mainWindows.count() < 1) {
if (schemaEditorDialog)
schemaEditorDialog->windowDeleted(mw);
writeSettings();
qApp->closeAllWindows(); // close any dialog
qApp->exit();
}
}
void Fix8Log::lastWindowClosedSlot()
{
qDebug() << "Last Window closed";
qApp->exit();
}
void Fix8Log::wireSignalAndSlots(MainWindow *mw)
{
if (!mw) {
qWarning() << "Error - wire signals and slots, window is null" << __FILE__ << __LINE__;
return;
}
connect(mw,SIGNAL(toolButtonStyleModified(Qt::ToolButtonStyle)),
this,SLOT(toolButtonStyleModfiedSlot(Qt::ToolButtonStyle)));
connect(mw,SIGNAL(createWindow(MainWindow*)),this,SLOT(createNewWindowSlot(MainWindow*)));
connect(mw,SIGNAL(copyWindow(MainWindow*)),this,SLOT(copyWindowSlot(MainWindow*)));
connect(mw,SIGNAL(deleteWindow(MainWindow*)),this,SLOT(deleteMainWindowSlot(MainWindow*)));
connect(mw,SIGNAL(exitApp()),this,SLOT(exitAppSlot()));
connect(mw,SIGNAL(autoSaveOn(bool)),this,SLOT(autoSaveOnSlot(bool)));
connect(mw,SIGNAL(cancelSessionRestore()),this,SLOT(cancelSessionRestoreSlot()));
connect(mw,SIGNAL(notifyTimeFormatChanged(GUI::Globals::TimeFormat)),
this,SLOT(setTimeFormatSlot(GUI::Globals::TimeFormat)));
connect(this,SIGNAL(notifyTimeFormatChanged(GUI::Globals::TimeFormat)),
mw,SLOT(setTimeFormatSlot(GUI::Globals::TimeFormat)));
connect(mw,SIGNAL(modelDropped(FixMimeData*)),this,SLOT(modelDroppedSlot(FixMimeData*)));
connect(mw,SIGNAL(editSchema(MainWindow*)),this,SLOT(editSchemaSlot(MainWindow *)));
connect(mw,SIGNAL(tableSchemaChanged(TableSchema*)),this,SLOT(tableSchemaSelectedSlot(TableSchema *)));
connect(mw,SIGNAL(showSearchDialog()),this,SLOT(showSearchDialogSlot()));
connect(mw,SIGNAL(showSearchDialogAddMode(QString)),this,SLOT(showSearchDialogAddModeSlot(QString)));
connect(mw,SIGNAL(showFilterDialog()),this,SLOT(showFilterDialogSlot()));
connect(mw,SIGNAL(showFilterDialogAddMode(QString)),this,SLOT(showFilterDialogAddModeSlot(QString)));
connect(mw->aboutA,SIGNAL(triggered()),this,SLOT(aboutSlot()));
mw->setAutoSaveOn(autoSaveOn);
}
void Fix8Log::newMainWindowWizardSlot()
{
qDebug() << "REMOVE THIS SLOT" << __FILE__ << __LINE__;
/* newWindowWizard = new QQuickView(QUrl("qrc:qml/newMainWindow.qml"));
newWinWizObject = newWindowWizard->rootObject();
if (!newWinWizObject) {
qWarning() << "qml root object not found for New Window Wizard" << __FILE__ << __LINE__ ;
return;
}
//else
// connect(newWinWizObject,SIGNAL(cancel()),this,SLOT(cancelSessionRestoreSlot()));
*/
}