diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 9ee03fd5..b2749192 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -163,6 +163,8 @@ void MainWindow::init() restoreState(PreferencesDialog::getSettingsValue("MainWindow", "windowState").toByteArray()); ui->comboLogSubmittedBy->setCurrentIndex(ui->comboLogSubmittedBy->findText(PreferencesDialog::getSettingsValue("SQLLogDock", "Log").toString())); ui->splitterForPlot->restoreState(PreferencesDialog::getSettingsValue("PlotDock", "splitterSize").toByteArray()); + ui->comboLineType->setCurrentIndex(PreferencesDialog::getSettingsValue("PlotDock", "lineType").toInt()); + ui->comboPointShape->setCurrentIndex(PreferencesDialog::getSettingsValue("PlotDock", "pointShape").toInt()); // plot widgets ui->treePlotColumns->setSelectionMode(QAbstractItemView::NoSelection); @@ -432,6 +434,8 @@ void MainWindow::closeEvent( QCloseEvent* event ) PreferencesDialog::setSettingsValue("MainWindow", "windowState", saveState()); PreferencesDialog::setSettingsValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText()); PreferencesDialog::setSettingsValue("PlotDock", "splitterSize", ui->splitterForPlot->saveState()); + PreferencesDialog::setSettingsValue("PlotDock", "lineType", ui->comboLineType->currentIndex()); + PreferencesDialog::setSettingsValue("PlotDock", "pointShape", ui->comboPointShape->currentIndex()); QMainWindow::closeEvent(event); } else { event->ignore(); @@ -1624,8 +1628,8 @@ void MainWindow::updatePlot(SqliteTableModel *model, bool update) // set some graph styles, this could also be improved to let the user choose // some styling graph->setData(xdata, ydata); - graph->setLineStyle(QCPGraph::lsLine); - graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5)); + graph->setLineStyle((QCPGraph::LineStyle) ui->comboLineType->currentIndex()); + graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)ui->comboPointShape->currentIndex(), 5)); // gather Y label column names yAxisLabels << model->headerData(y, Qt::Horizontal).toString(); @@ -2110,3 +2114,31 @@ void MainWindow::copyCurrentCreateStatement() // Copy the statement to the global application clipboard QApplication::clipboard()->setText(stmt); } + +void MainWindow::on_comboLineType_currentIndexChanged(int index) +{ + Q_ASSERT(index >= QCPGraph::lsNone && + index <= QCPGraph::lsImpulse); + QCPGraph::LineStyle lineStyle = (QCPGraph::LineStyle) index; + for (int i = 0, ie = ui->plotWidget->graphCount(); i < ie; ++i) + { + QCPGraph * graph = ui->plotWidget->graph(i); + if (graph) + graph->setLineStyle(lineStyle); + } + ui->plotWidget->replot(); +} + +void MainWindow::on_comboPointShape_currentIndexChanged(int index) +{ + Q_ASSERT(index >= QCPScatterStyle::ssNone && + index < QCPScatterStyle::ssPixmap); + QCPScatterStyle::ScatterShape shape = (QCPScatterStyle::ScatterShape) index; + for (int i = 0, ie = ui->plotWidget->graphCount(); i < ie; ++i) + { + QCPGraph * graph = ui->plotWidget->graph(i); + if (graph) + graph->setScatterStyle(QCPScatterStyle(shape, 5)); + } + ui->plotWidget->replot(); +} diff --git a/src/MainWindow.h b/src/MainWindow.h index bda79822..709c26ea 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -177,6 +177,8 @@ private slots: void switchToBrowseDataTab(); void on_buttonClearFilters_clicked(); void copyCurrentCreateStatement(); + void on_comboLineType_currentIndexChanged(int index); + void on_comboPointShape_currentIndexChanged(int index); }; #endif diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 808121a8..49fb30ec 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -6,7 +6,7 @@ 0 0 - 1000 + 1037 630 @@ -22,7 +22,7 @@ - 0 + 3 @@ -324,8 +324,8 @@ 0 0 - 294 - 444 + 472 + 531 @@ -809,8 +809,8 @@ 0 0 - 1000 - 19 + 1037 + 25 @@ -1074,6 +1074,144 @@ 0 + + + + Line type: + + + + + + + 1 + + + + None + + + + + Line + + + + + StepLeft + + + + + StepRight + + + + + StepCenter + + + + + Impulse + + + + + + + + Point shape: + + + + + + + 5 + + + + None + + + + + Dot + + + + + Cross + + + + + Plus + + + + + Circle + + + + + Disc + + + + + Square + + + + + Diamond + + + + + Star + + + + + Triangle + + + + + TriangleInverted + + + + + CrossSquare + + + + + PlusSquare + + + + + CrossCircle + + + + + PlusCircle + + + + + Peace + + + + @@ -1656,6 +1794,7 @@ dbTreeWidget comboBrowseTable buttonRefresh + buttonClearFilters buttonNewRecord buttonDeleteRecord dataTable diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp index e8a74c20..9b3f9312 100644 --- a/src/PreferencesDialog.cpp +++ b/src/PreferencesDialog.cpp @@ -300,6 +300,18 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const if(group == "extension" && name == "disableregex") return false; + // PlotDock/lineType or pointShape? + if(group == "PlotDock") + { + // QCPGraph::lsLine + if(name == "lineType") + return 1; + + // QCPScatterStyle::ssDisk + if(name == "pointShape") + return 5; + } + // Unknown combination of group and name? Return an invalid QVariant! return QVariant(); }