Skip to content

Commit f87598a

Browse files
author
Michal
committed
Replaced stackedWidget with TabWidget
1 parent 8df01a1 commit f87598a

File tree

3 files changed

+398
-440
lines changed

3 files changed

+398
-440
lines changed

src/mainwindow.cpp

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ void MainWindow::setupGUI()
111111
ui->lineEditSaveFileName->setText("Log.txt");
112112
ui->lineEditSaveLogPath->setText(qApp->applicationDirPath() + "/Logs");
113113
ui->splitterGraphTable->setSizes({this->height(), 0});
114-
ui->stackedWidgetTableView->setCurrentIndex(ui->comboBoxTableViewMode->currentIndex());
115114

116115
emit on_checkBoxAutoLogging_toggled(ui->checkBoxAutoLogging->isChecked());
117116
emit on_checkBoxShowLegend_toggled(ui->checkBoxShowLegend->isChecked());
@@ -165,8 +164,6 @@ void MainWindow::createChart()
165164

166165
ui->textBrowserLogs->setHighlightEnabled(false);
167166
emit on_comboBoxLogFormat_currentIndexChanged(ui->comboBoxLogFormat->currentIndex());
168-
169-
ui->pushButtonEnableTableLog->toggle();
170167
}
171168

172169
void MainWindow::create3DView()
@@ -215,7 +212,7 @@ void MainWindow::settingsLoadAll()
215212
}
216213

217214
if (appSettings.value("Info/organizationName").value<QString>() != appSettings.organizationName() ||
218-
appSettings.value("Info/applicationName").value<QString>() != appSettings.applicationName())
215+
appSettings.value("Info/applicationName").value<QString>() != appSettings.applicationName())
219216
{
220217
qDebug() << "Abort loading settings ! organizationName or applicationName incorrect. Config file might be missing.";
221218
addLog("App >>\t Error loading settings. Config file incorrect !", true);
@@ -280,10 +277,7 @@ void MainWindow::settingsLoadAll()
280277
ui->checkBoxWrapText->setChecked(appSettings.value("GUI_Elements/checkBoxWrapText.isChecked").value<bool>());
281278
ui->checkBoxAutoScrollLogTable->setChecked(appSettings.value("GUI_Elements/checkBoxAutoScrollLogTable.isChecked", true).value<bool>());
282279
ui->checkBoxAutoSizeColumnsLogTable->setChecked(appSettings.value("GUI_Elements/checkBoxAutoSizeColumnsLogTable.isChecked", true).value<bool>());
283-
ui->checkBoxScrollLogEnableSorting->setChecked(appSettings.value("GUI_Elements/checkBoxScrollLogEnableSorting.isChecked", true).value<bool>());
284-
ui->checkBoxAutoSizeColumnsLogTable->setChecked(appSettings.value("GUI_Elements/checkBoxAutoSizeColumnsLogTable.isChecked", true).value<bool>());
285-
ui->checkBoxAutoScrollLogTable->setChecked(appSettings.value("GUI_Elements/checkBoxAutoScrollLogTable.isChecked", true).value<bool>());
286-
ui->checkBoxScrollLogEnableSorting->setChecked(appSettings.value("GUI_Elements/checkBoxScrollLogEnableSorting.isChecked", true).value<bool>());
280+
ui->checkBoxScrollLogEnableSorting->setChecked(appSettings.value("GUI_Elements/checkBoxScrollLogEnableSorting.isChecked", true).value<bool>()); ui->checkBoxScrollLogEnableSorting->setChecked(appSettings.value("GUI_Elements/checkBoxScrollLogEnableSorting.isChecked", true).value<bool>());
287281
ui->comboBoxAddTextMode->setCurrentIndex(appSettings.value("GUI_Elements/comboBoxAddTextMode.currentIndex").value<int>());
288282
ui->comboBoxBaudRates->setCurrentIndex(appSettings.value("GUI_Elements/comboBoxBaudRates.currentIndex").value<int>());
289283
ui->comboBoxClockSource->setCurrentIndex(appSettings.value("GUI_Elements/comboBoxClockSource.currentIndex").value<int>());
@@ -302,15 +296,15 @@ void MainWindow::settingsLoadAll()
302296
ui->comboBoxTracerStyle->setCurrentIndex(appSettings.value("GUI_Elements/comboBoxTracerStyle.currentIndex").value<int>());
303297
ui->comboBoxUDPReceiveMode->setCurrentIndex(appSettings.value("GUI_Elements/comboBoxUDPReceiveMode.currentIndex").value<int>());
304298
ui->comboBoxUDPSendMode->setCurrentIndex(appSettings.value("GUI_Elements/comboBoxUDPSendMode.currentIndex").value<int>());
305-
ui->comboBoxTableViewMode->setCurrentIndex(appSettings.value("GUI_Elements/comboBoxTableViewMode.currentIndex").value<int>());
299+
ui->tabWidgetTableView->setCurrentIndex(appSettings.value("GUI_Elements/tabWidgetTableView.currentIndex").value<int>());
306300
ui->lineEditCustomParsingRules->setText(appSettings.value("data/lineEditCustomParsingRules.text").value<QString>());
307301
ui->lineEditExternalClockLabel->setText(appSettings.value("data/lineEditExternalClockLabel.text").value<QString>());
308302
ui->lineEditLoadFilePath->setText(appSettings.value("data/lineEditLoadFilePath.text").value<QString>());
309303
ui->lineEditSaveFileName->setText(appSettings.value("data/lineEditSaveFileName.text").value<QString>());
310304
ui->lineEditSaveLogPath->setText(appSettings.value("data/lineEditSaveLogPath.text").value<QString>());
311305
ui->lineEditUDPTargetIP->setText(appSettings.value("data/lineEditUDPTargetIP.text").value<QString>());
312306
ui->pushButtonEnablePlot->setChecked(appSettings.value("GUI_Elements/pushButtonEnablePlot.isChecked", false).value<bool>());
313-
ui->pushButtonEnableTableLog->setChecked(appSettings.value("GUI_Elements/pushButtonEnableTableLog.isChecked", false).value<bool>());
307+
ui->pushButtonEnableTableLog->setChecked(appSettings.value("GUI_Elements/pushButtonEnableTableLog.isChecked", true).value<bool>());
314308
ui->spinBoxMaxGraphs->setValue(appSettings.value("layout/spinBoxMaxGraphs.value").value<int>());
315309
ui->spinBoxMaxLines->setValue(appSettings.value("layout/spinBoxMaxLines.value").value<int>());
316310
ui->spinBoxMaxTimeRange->setValue(appSettings.value("layout/spinBoxMaxTimeRange.value").value<int>());
@@ -392,12 +386,9 @@ void MainWindow::settingsSaveAll()
392386
appSettings.setValue("GUI_Elements/checkBoxTableAutoResize.isChecked", ui->checkBoxTableAutoResize->isChecked());
393387
appSettings.setValue("GUI_Elements/checkBoxTruncateFileOnSave.isChecked", ui->checkBoxTruncateFileOnSave->isChecked());
394388
appSettings.setValue("GUI_Elements/checkBoxWrapText.isChecked", ui->checkBoxWrapText->isChecked());
395-
appSettings.setValue("GUI_Elements/checkBoxAutoScrollLogTable.isChecked", ui->checkBoxAutoScrollLogTable->isChecked());
396-
appSettings.setValue("GUI_Elements/checkBoxAutoSizeColumnsLogTable.isChecked", ui->checkBoxAutoSizeColumnsLogTable->isChecked());
397389
appSettings.setValue("GUI_Elements/checkBoxScrollLogEnableSorting.isChecked", ui->checkBoxScrollLogEnableSorting->isChecked());
398390
appSettings.setValue("GUI_Elements/checkBoxAutoSizeColumnsLogTable.isChecked", ui->checkBoxAutoSizeColumnsLogTable->isChecked());
399391
appSettings.setValue("GUI_Elements/checkBoxAutoScrollLogTable.isChecked", ui->checkBoxAutoScrollLogTable->isChecked());
400-
appSettings.setValue("GUI_Elements/checkBoxScrollLogEnableSorting.isChecked", ui->checkBoxScrollLogEnableSorting->isChecked());
401392
appSettings.setValue("GUI_Elements/comboBoxAddTextMode.currentIndex", ui->comboBoxAddTextMode->currentIndex());
402393
appSettings.setValue("GUI_Elements/comboBoxBaudRates.currentIndex", ui->comboBoxBaudRates->currentIndex());
403394
appSettings.setValue("GUI_Elements/comboBoxClockSource.currentIndex", ui->comboBoxClockSource->currentIndex());
@@ -416,7 +407,7 @@ void MainWindow::settingsSaveAll()
416407
appSettings.setValue("GUI_Elements/comboBoxTracerStyle.currentIndex", ui->comboBoxTracerStyle->currentIndex());
417408
appSettings.setValue("GUI_Elements/comboBoxUDPReceiveMode.currentIndex", ui->comboBoxUDPReceiveMode->currentIndex());
418409
appSettings.setValue("GUI_Elements/comboBoxUDPSendMode.currentIndex", ui->comboBoxUDPSendMode->currentIndex());
419-
appSettings.setValue("GUI_Elements/comboBoxTableViewMode.currentIndex", ui->comboBoxTableViewMode->currentIndex());
410+
appSettings.setValue("GUI_Elements/tabWidgetTableView.currentIndex", ui->tabWidgetTableView->currentIndex());
420411
appSettings.setValue("GUI_Elements/pushButtonEnablePlot.isChecked", ui->pushButtonEnablePlot->isChecked());
421412
appSettings.setValue("GUI_Elements/tabWidgetControlSection.currentIndex", ui->tabWidgetControlSection->currentIndex());
422413
appSettings.setValue("layout/spinBoxMaxGraphs.value", ui->spinBoxMaxGraphs->value());
@@ -509,9 +500,11 @@ void MainWindow::processLogTable(QList<long> timeTable, QStringList labelTable,
509500
for (auto i = 0; i < ui->tableWidgetLogTable->columnCount(); ++i)
510501
firstRow.append(ui->tableWidgetLogTable->horizontalHeaderItem(i)->text().trimmed());
511502

503+
bool resizeFlag = false;
504+
512505
foreach (auto label, labelTable)
513506
{
514-
while (firstRow.contains(label) == false) // optimise
507+
if (firstRow.contains(label) == false) // optimise
515508
{
516509
ui->tableWidgetLogTable->setColumnCount(ui->tableWidgetLogTable->columnCount() + 1);
517510
ui->tableWidgetLogTable->setHorizontalHeaderItem(ui->tableWidgetLogTable->columnCount() - 1, new QTableWidgetItem(label.trimmed()));
@@ -520,25 +513,24 @@ void MainWindow::processLogTable(QList<long> timeTable, QStringList labelTable,
520513
for (auto i = 0; i < ui->tableWidgetLogTable->columnCount(); ++i)
521514
firstRow.append(ui->tableWidgetLogTable->horizontalHeaderItem(i)->text().trimmed());
522515

523-
if (ui->checkBoxAutoSizeColumnsLogTable->isChecked())
524-
ui->tableWidgetLogTable->resizeColumnsToContents();
516+
resizeFlag = true;
525517
}
526-
527-
if (firstRow.contains(label))
518+
else
528519
{
529520
if (oldRowCount == ui->tableWidgetLogTable->rowCount())
530-
{
531521
ui->tableWidgetLogTable->setRowCount(oldRowCount + 1);
532-
ui->tableWidgetLogTable->setItem(oldRowCount, 0, new QTableWidgetItem(QTime::fromMSecsSinceStartOfDay(timeTable[labelTable.indexOf(label)]).toString(parser.searchTimeFormatList[0])));
533-
}
534522

523+
ui->tableWidgetLogTable->setItem(oldRowCount, 0, new QTableWidgetItem(QTime::fromMSecsSinceStartOfDay(timeTable[labelTable.indexOf(label)]).toString(parser.searchTimeFormatList[0])));
535524
ui->tableWidgetLogTable->setItem(oldRowCount, firstRow.indexOf(label), new QTableWidgetItem(QString::number(valueTable[labelTable.indexOf(label)])));
536525
}
537526
}
538527

539528
if (ui->checkBoxAutoScrollLogTable->isChecked())
540529
ui->tableWidgetLogTable->scrollToBottom();
541530

531+
if (ui->checkBoxAutoSizeColumnsLogTable->isChecked() && resizeFlag)
532+
ui->tableWidgetLogTable->resizeColumnsToContents();
533+
542534
if (ui->spinBoxMaxRowsLogTable->value() > 0)
543535
{
544536
while (ui->tableWidgetLogTable->rowCount() > ui->spinBoxMaxRowsLogTable->value())
@@ -832,9 +824,9 @@ void MainWindow::on_tracerShowPointValue(QMouseEvent *event)
832824
"<td>Y: %L3</td>"
833825
"</tr>"
834826
"</table>")
835-
.arg(graph->name())
836-
.arg(QTime::fromMSecsSinceStartOfDay(temp.x() * 1000).toString("hh:mm:ss:zzz"))
837-
.arg(QString::number(temp.y(), 'f', 5)),
827+
.arg(graph->name())
828+
.arg(QTime::fromMSecsSinceStartOfDay(temp.x() * 1000).toString("hh:mm:ss:zzz"))
829+
.arg(QString::number(temp.y(), 'f', 5)),
838830
ui->widgetChart, ui->widgetChart->rect());
839831
}
840832

@@ -1049,11 +1041,16 @@ void MainWindow::on_processSerial()
10491041
QList<double> numericDataList = parser.getListNumericValues();
10501042
QList<long> timeStamps = parser.getListTimeStamp();
10511043

1052-
this->processLogWrite(serialInput, labelList, numericDataList, timeStamps);
10531044
this->processChart(labelList, numericDataList, timeStamps);
1045+
this->processLogWrite(serialInput, labelList, numericDataList, timeStamps);
10541046
this->saveToRAM(labelList, numericDataList, timeStamps, ui->comboBoxRAMSaveMode->currentIndex(), serialInput);
1055-
this->processTable(labelList, numericDataList); // Fill tableWidget
1047+
this->processTable(labelList, numericDataList);
10561048
this->processLogTable(timeStamps, labelList, numericDataList);
1049+
1050+
// QFuture<void> future = QtConcurrent::run([=]() // Cool !
1051+
// {
1052+
1053+
// });
10571054
}
10581055
}
10591056

@@ -1155,13 +1152,13 @@ void MainWindow::processChart(QStringList labelList, QList<double> numericDataLi
11551152

11561153
if (canAddGraph && ui->widgetChart->graphCount() < ui->spinBoxMaxGraphs->value() &&
11571154

1158-
((ui->comboBoxGraphDisplayMode->currentIndex() == 0) ||
1155+
((ui->comboBoxGraphDisplayMode->currentIndex() == 0) ||
11591156

1160-
(ui->comboBoxGraphDisplayMode->currentIndex() == 1 &&
1161-
ui->lineEditCustomParsingRules->text().simplified().contains(label, Qt::CaseSensitivity::CaseSensitive)) ||
1157+
(ui->comboBoxGraphDisplayMode->currentIndex() == 1 &&
1158+
ui->lineEditCustomParsingRules->text().simplified().contains(label, Qt::CaseSensitivity::CaseSensitive)) ||
11621159

1163-
(ui->comboBoxGraphDisplayMode->currentIndex() == 2 &&
1164-
!ui->lineEditCustomParsingRules->text().simplified().contains(label, Qt::CaseSensitivity::CaseSensitive))))
1160+
(ui->comboBoxGraphDisplayMode->currentIndex() == 2 &&
1161+
!ui->lineEditCustomParsingRules->text().simplified().contains(label, Qt::CaseSensitivity::CaseSensitive))))
11651162
{
11661163
ui->widgetChart->addGraph();
11671164
ui->widgetChart->graph()->setName(label);
@@ -2320,11 +2317,6 @@ void MainWindow::on_comboBoxGraphDisplayMode_currentIndexChanged(int index)
23202317
}
23212318
}
23222319

2323-
void MainWindow::on_comboBoxTableViewMode_currentIndexChanged(int index)
2324-
{
2325-
this->ui->stackedWidgetTableView->setCurrentIndex(index);
2326-
}
2327-
23282320
void MainWindow::on_pushButtonClearLogTable_clicked()
23292321
{
23302322
ui->tableWidgetLogTable->setRowCount(0);

src/mainwindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
//#include <q3dsruntimeglobal.h>
3838
//#include <Q3DSWidget>
3939
//#include <Q3DSPresentation>
40+
//#include <QtConcurrent/QtConcurrent>
4041

4142
namespace Ui
4243
{
@@ -100,7 +101,6 @@ private slots:
100101
void on_comboBoxLoggingMode_currentIndexChanged(int index);
101102
void on_comboBoxSendReturnPressedSlot();
102103
void on_comboBoxSerialReadMode_currentIndexChanged(int index);
103-
void on_comboBoxTableViewMode_currentIndexChanged(int index);
104104
void on_comboBoxTracerStyle_currentIndexChanged(const QString &arg1);
105105
void on_comboBoxUDPReceiveMode_currentIndexChanged(const QString &arg1);
106106
void on_comboBoxUDPSendMode_currentIndexChanged(const QString &arg1);

0 commit comments

Comments
 (0)