-
Notifications
You must be signed in to change notification settings - Fork 3
/
mainWindowSlots.cpp
450 lines (429 loc) · 14.8 KB
/
mainWindowSlots.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
//-------------------------------------------------------------------------------------------------
/*
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 "mainwindow.h"
#include "messagearea.h"
#include "fixmimedata.h"
#include "fixtoolbar.h"
#include "globals.h"
#include "nodatalabel.h"
#include "fix8sharedlib.h"
#include "tableschema.h"
#include "worksheet.h"
#include <QDebug>
#include "globals.h"
#include <QtWidgets>
//#include <QStandardItemModel>
void MainWindow::quitSlot()
{
writeSettings();
emit exitApp();
//qApp->quit();
}
void MainWindow::editSchemaSlot()
{
if (tableSchema) {
qDebug() << "Current Table Schema = " << tableSchema->name << __FILE__ << __LINE__;
}
else
qDebug() << "We have null table schema";
emit editSchema(this);
}
void MainWindow::hideColumnActionSlot(QAction *action)
{
WorkSheet *workSheet;
if (!action)
return;
QVariant var = action->data();
qint32 colNum = var.toInt();
for(int i =0;i< tabW->count();i++) {
workSheet = qobject_cast <WorkSheet *> (tabW->widget(i));
if (workSheet)
workSheet->hideColumn(colNum,action->isChecked());
}
}
void MainWindow::iconStyleSlot(QAction *action)
{
QSettings settings("fix8","logviewer");
Qt::ToolButtonStyle tbs = Qt::ToolButtonTextOnly;
tbs = Qt::ToolButtonTextOnly;
if (action == iconsOnlyA)
tbs = Qt::ToolButtonIconOnly;
else if (action == iconsWithTextA)
tbs = Qt::ToolButtonTextUnderIcon;
//setToolButtonStyle(tbs);
emit toolButtonStyleModified(tbs);
settings.setValue("ToolButtonStyle",tbs);
}
void MainWindow::iconSizeSlot(QAction *action)
{
QSettings settings("fix8","logviewer");
QSize is = GUI::Globals::regIconSize;
if (action == iconSizeSmallA)
is = GUI::Globals::smallIconSize;
else if (action == iconSizeLargeA)
is = GUI::Globals::largeIconSize;
mainToolBar->setIconSize(is);
searchToolBar->setIconSize(is);
filterToolBar->setIconSize(is);
settings.setValue("ToolButtonSize",is);
}
void MainWindow::configFGSlot()
{
colorSelectionFG = true;
int status;
QSettings settings("fix8","logviewer");
menuBarStyleSheet = mainMenuBar->styleSheet();
QColorDialog *colorDialog = new QColorDialog(this);
colorDialog->setWindowTitle(tr("Select Menu Bar Text Color"));
colorDialog->setCustomColor(0,GUI::Globals::menubarDefaultColor);
connect(colorDialog,SIGNAL(colorSelected(QColor)),this,SLOT(setColorSlot(QColor)));
connect(colorDialog,SIGNAL(currentColorChanged(QColor)),this,SLOT(currentColorChangedSlot(QColor)));
colorDialog->raise();
status = colorDialog->exec();
if (status != QDialog::Accepted) {
menuBar()->setStyleSheet(menuBarStyleSheet);
}
else {
menuBarStyleSheet = mainMenuBar->styleSheet();
settings.setValue("MenuBarColor",menuBarStyleSheet);
}
colorDialog->deleteLater();
}
void MainWindow::configSlot()
{
int status;
QSettings settings("fix8","logviewer");
colorSelectionFG = false;
menuBarStyleSheet = mainMenuBar->styleSheet();
QColorDialog *colorDialog = new QColorDialog();
colorDialog->setWindowTitle(tr("Select Menu Bar Color"));
colorDialog->setCustomColor(0,GUI::Globals::menubarDefaultColor);
connect(colorDialog,SIGNAL(colorSelected(QColor)),this,SLOT(setColorSlot(QColor)));
connect(colorDialog,SIGNAL(currentColorChanged(QColor)),this,SLOT(currentColorChangedSlot(QColor)));
colorDialog->raise();
status = colorDialog->exec();
if (status != QDialog::Accepted) {
menuBar()->setStyleSheet(menuBarStyleSheet);
fileMenu->setStyleSheet("");
}
else {
menuBarStyleSheet = mainMenuBar->styleSheet();
settings.setValue("MenuBarColor",menuBarStyleSheet);
}
colorDialog->deleteLater();
}
void MainWindow::setColorSlot(QColor color)
{
QString colorStr;
QString colorValue;
QString backgroundValue;
QStringList attributes = menuBarStyleSheet.split(';');
QStringListIterator iter(attributes);
QString attribute;
while(iter.hasNext()) {
attribute = iter.next();
if (attribute.contains("background-color")) {
backgroundValue = attribute;
if (backgroundValue.length() > 2)
backgroundValue = backgroundValue.split(':').last();
else {
backgroundValue = menuBar()->palette().color(QPalette::Window).name();
qDebug() << "Use palette" << backgroundValue << __FILE__ << __LINE__;
}
}
if (attribute.contains("color")) {
colorValue = attribute;
if (colorValue.length() > 2)
colorValue = colorValue.split(':').last();
else
colorValue = menuBar()->palette().color(QPalette::WindowText).name();
}
}
if (backgroundValue.length() < 2)
backgroundValue = menuBar()->palette().color(QPalette::Window).name();
if (colorValue.length() <2)
colorValue = menuBar()->palette().color(QPalette::WindowText).name();
if (colorSelectionFG)
colorValue = color.name();
else
backgroundValue = color.name();
qDebug() << "Attributes: " << attributes;
colorStr = "QMenuBar::item{ background:" + backgroundValue + "; color:" + colorValue + "} QMenuBar{background:" + backgroundValue + ";}";
menuBar()->setStyleSheet(colorStr);
}
void MainWindow::currentColorChangedSlot(QColor color)
{
QString colorStr;
QString colorValue;
QString backgroundValue;
QStringList attributes = menuBarStyleSheet.split(';');
QStringListIterator iter(attributes);
QString attribute;
while(iter.hasNext()) {
attribute = iter.next();
if (attribute.contains("background-color")) {
backgroundValue = attribute;
if (backgroundValue.length() > 2)
backgroundValue = backgroundValue.split(':').last();
else {
backgroundValue = menuBar()->palette().color(QPalette::Window).name();
qDebug() << "Use palette" << backgroundValue << __FILE__ << __LINE__;
}
}
if (attribute.contains("color")) {
colorValue = attribute;
if (colorValue.length() > 2)
colorValue = colorValue.split(':').last();
else
colorValue = menuBar()->palette().color(QPalette::WindowText).name();
}
}
if (backgroundValue.length() < 2)
backgroundValue = menuBar()->palette().color(QPalette::Window).name();
if (colorValue.length() <2)
colorValue = menuBar()->palette().color(QPalette::WindowText).name();
if (colorSelectionFG)
colorValue = color.name();
else
backgroundValue = color.name();
qDebug() << "Attributes: " << attributes;
colorStr = "QMenuBar::item{ background:" + backgroundValue + "; color:" + colorValue + "} QMenuBar{background:" + backgroundValue + ";}";
menuBar()->setStyleSheet(colorStr);
//fileMenu->setStyleSheet(menuStyle);
// optionMenu->setStyleSheet(menuStyle);
// schemaMenu->setStyleSheet(menuStyle);
// helpMenu->setStyleSheet(menuStyle);
}
void MainWindow::editTabNameSlot(bool isOn)
{
QString tabName;
WorkSheet *workSheet;
int index = tabW->currentIndex();
if (isOn) {
tabName = tabW->tabText(index);
cancelEditTabNamePB->show();
tabNameLineEdit->show();
tabNameLineEdit->setFocus();
editTabNamePB->setToolTip("Save");
tabNameLineEdit->setText(tabName);
tabNameLineEdit->selectAll();
}
else {
cancelEditTabNamePB->hide();
tabNameLineEdit->hide();
editTabNamePB->setToolTip("Edit current tab name");
tabName = tabNameLineEdit->text();
tabW->setTabText(index,tabName);
workSheet = qobject_cast <WorkSheet *> (tabW->widget(index));
if (workSheet)
workSheet->setAlias(tabName);
}
}
void MainWindow::cancelTabNameSlot()
{
cancelEditTabNamePB->hide();
tabNameLineEdit->hide();
editTabNamePB->setToolTip("Edit current tab name");
editTabNamePB->setChecked(false);
editTabNamePB->setEnabled(true);
}
void MainWindow::tabNameModifiedSlot(QString str)
{
bool isValid = false;
if (str.length() >0)
isValid = true;
editTabNamePB->setEnabled(isValid);
if(isValid)
tabNameLineEdit->setToolTip(tr("Enter return to change name and exit edit mode"));
else
tabNameLineEdit->setToolTip(tr("Enter tab name"));
}
void MainWindow::tabNameReturnKeySlot()
{
QString tabName;
WorkSheet *worksheet;
int index = tabW->currentIndex();
tabName = tabNameLineEdit->text();
if (tabName.length() < 1)
return;
cancelEditTabNamePB->hide();
tabNameLineEdit->hide();
editTabNamePB->setChecked(false);
editTabNamePB->setToolTip("Edit current tab name");
tabW->setTabText(index,tabName);
worksheet = qobject_cast <WorkSheet *> (tabW->widget(index));
worksheet->setAlias(tabName);
}
void MainWindow::tabCurentChangedSlot(int index)
{
QMenu *senderMenu;
WorkSheet *worksheet = qobject_cast <WorkSheet *> (tabW->widget(index));
if (worksheet) {
SearchFunction sf = worksheet->getSearchFunction();
setSearchFunction(sf);
senderMenu = worksheet->getSenderMenu();
if (senderMenu)
filterSenderMenuA->setMenu(senderMenu);
else
filterSenderMenuA->setMenu(0);
}
if (!editTabNamePB->isChecked())
return;
cancelTabNameSlot();
}
void MainWindow::showMessageArea(bool bstatus)
{
WorkSheet *workSheet;
for(int i=0;i < tabW->count();i++) {
workSheet = qobject_cast <WorkSheet *> (tabW->widget(i));
if(bstatus)
workSheet->messageArea->hide();
else
workSheet->messageArea->show();
}
}
void MainWindow::autoSaveOnSlot(bool isOn)
{
emit autoSaveOn(isOn);
}
void MainWindow::cancelSessionRestoreSlot()
{
loadingActive = false;
if (tabW->count() > 0) {
stackW->setCurrentIndex(ShowTab);
copyTabA->setEnabled(true);
showMessageA->setEnabled(true);
}
else {
stackW->setCurrentIndex(ShowNoDataLabel);
copyTabA->setEnabled(false);
showMessageA->setEnabled(false);
}
emit cancelSessionRestore();
}
void MainWindow::setTimeSlotFromWorkSheet(GUI::Globals::TimeFormat tf)
{
emit notifyTimeFormatChanged(tf);
}
void MainWindow::setTimeFormatSlot(GUI::Globals::TimeFormat tf)
{
WorkSheet *workSheet;
for(int i=0;i < tabW->count();i++) {
workSheet = qobject_cast <WorkSheet *> (tabW->widget(i));
if (workSheet)
workSheet->setTimeFormat(tf);
}
repaint();
}
void MainWindow::toolbarOrientationChangedSlot(Qt::Orientation orient)
{
if (orient == Qt::Vertical) {
searchL->setText("");
//searchLV->setText("Search");
}
else {
searchL->setText("Search");
//searchLV->setText("");
}
}
void MainWindow::modelDroppedSlot(FixMimeData *m)
{
if (!m)
return;
emit modelDropped(m);
}
void MainWindow::schemaSelectedSlot(QAction *action)
{
TableSchema *ts;
WorkSheet *ws;
QVariant var = action->data();
ts = (TableSchema *) var.value<void *>();
if (!ts) {
qWarning() << "Error - Table Schema Not Found" << __FILE__ << __LINE__;
return;
}
schemaV->setText(ts->name);
tableSchema = ts;
QListIterator <WorkSheet *> iter2(workSheetList);
while(iter2.hasNext()) {
ws = iter2.next();
ws->setTableSchema(tableSchema);
}
emit tableSchemaChanged(ts);
}
void MainWindow::setWindowNameSlot()
{
bool ok;
QString str =
QInputDialog::getText(this,"Fix8LogView","Window Title",
QLineEdit::Normal,windowTitle(),&ok);
if (ok && str.length() > 0) {
setWindowTitle(str);
name = str;
}
}
void MainWindow::displayMessageSlot(GUI::ConsoleMessage msg)
{
displayConsoleMessage(msg);
}
void MainWindow::terminatedWorkSheetCopySlot(WorkSheet *ws)
{
qDebug() << "REMOVE THIS SLOT ?" << __FILE__ << __LINE__;
}
void MainWindow::doPopupSlot(const QModelIndex &mi,const QPoint &pt)
{
popupMenu->popup(pt);
}
void MainWindow::popupMenuActionSlot(QAction*)
{
}
void MainWindow::linkSearchSlot(bool turnedOn)
{
qDebug() << "Link Search Enabled " << turnedOn << __FILE__ << __LINE__;
linkSearchOn = turnedOn;
}
void MainWindow::setFontSlot(QAction *fontAction)
{
QFont fnt = font();
int ptSize = fnt.pointSize();
if (fontAction == fontIncreaseA)
ptSize +=1;
else if (fontAction == fontDecreaseA)
ptSize -=1;
else { // set to default
ptSize = GUI::Globals::fontPtSize;
}
fnt.setPointSize(ptSize);
setFont(fnt);
}
void MainWindow::cancelFilterSlot()
{
qDebug() << "Cancel Filter" << __FILE__;
cancelFilter = true;
}