mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Avoid crash performing the correct check to know if the plot has graphs
This crash was introduced in 6d3228a0e3. It
happened when no previous settings were saved for the plot.
Additionally the plot interaction are set once for the plot widget.
This was reported at issue #838.
This commit is contained in:
@@ -29,6 +29,12 @@ PlotDock::PlotDock(QWidget* parent)
|
||||
connect(ui->plotWidget, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
|
||||
connect(ui->plotWidget, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));
|
||||
|
||||
// Enable: click on items to select them, Ctrl+Click for multi-selection, mouse-wheel for zooming and mouse drag for
|
||||
// changing the visible range.
|
||||
// Select one axis for zoom and drag applying only to that orientation.
|
||||
ui->plotWidget->setInteractions(QCP::iSelectPlottables | QCP::iMultiSelect | QCP::iRangeZoom | QCP::iRangeDrag | QCP::iSelectAxes);
|
||||
ui->plotWidget->setSelectionRectMode(QCP::srmNone);
|
||||
|
||||
QShortcut* shortcutCopy = new QShortcut(QKeySequence::Copy, ui->plotWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(shortcutCopy, SIGNAL(activated()), this, SLOT(copy()));
|
||||
|
||||
@@ -193,20 +199,8 @@ void PlotDock::updatePlot(SqliteTableModel* model, BrowseDataTableSettings* sett
|
||||
ui->plotWidget->xAxis->setLabel(QString());
|
||||
ui->plotWidget->yAxis->setLabel(QString());
|
||||
|
||||
ui->buttonLoadAllData->setEnabled(false);
|
||||
ui->buttonLoadAllData->setStyleSheet("");
|
||||
ui->buttonLoadAllData->setToolTip(tr("Load all data and redraw plot"));
|
||||
|
||||
if(xitem)
|
||||
{
|
||||
// Warn user if not all data has been fetched and hint about the button for loading all the data
|
||||
if (m_currentTableSettings->plotYAxes.count() && model && model->canFetchMore()) {
|
||||
ui->buttonLoadAllData->setEnabled(true);
|
||||
ui->buttonLoadAllData->setStyleSheet("color: white; background-color: rgb(255, 102, 102)");
|
||||
ui->buttonLoadAllData->setToolTip(tr("Load all data and redraw plot.\n"
|
||||
"Warning: not all data has been fetched from the table yet due to the partial fetch mechanism."));
|
||||
QToolTip::showText(ui->buttonLoadAllData->mapToGlobal(QPoint(0, 0)), ui->buttonLoadAllData->toolTip());
|
||||
}
|
||||
// regain the model column index and the datatype
|
||||
// leading 16 bit are column index, the other 16 bit are the datatype
|
||||
// right now datatype is only important for X axis (date, non date)
|
||||
@@ -241,11 +235,6 @@ void PlotDock::updatePlot(SqliteTableModel* model, BrowseDataTableSettings* sett
|
||||
|
||||
graph->setPen(QPen(item->backgroundColor(PlotColumnY)));
|
||||
graph->setSelectable (QCP::stDataRange);
|
||||
// Enable: click on items to select them, Ctrl+Click for multi-selection, mouse-wheel for zooming and mouse drag for
|
||||
// changing the visible range.
|
||||
// Select one axis for zoom and drag applying only to that orientation.
|
||||
ui->plotWidget->setInteractions(QCP::iSelectPlottables | QCP::iMultiSelect | QCP::iRangeZoom | QCP::iRangeDrag | QCP::iSelectAxes);
|
||||
ui->plotWidget->setSelectionRectMode(QCP::srmNone);
|
||||
|
||||
// prepare the data vectors for qcustomplot
|
||||
// possible improvement might be a QVector subclass that directly
|
||||
@@ -309,6 +298,19 @@ void PlotDock::updatePlot(SqliteTableModel* model, BrowseDataTableSettings* sett
|
||||
ui->plotWidget->yAxis->setLabel(yAxisLabels.join("|"));
|
||||
}
|
||||
ui->plotWidget->replot();
|
||||
|
||||
// Warn user if not all data has been fetched and hint about the button for loading all the data
|
||||
if (ui->plotWidget->graphCount() > 0 && model->canFetchMore()) {
|
||||
ui->buttonLoadAllData->setEnabled(true);
|
||||
ui->buttonLoadAllData->setStyleSheet("color: white; background-color: rgb(255, 102, 102)");
|
||||
ui->buttonLoadAllData->setToolTip(tr("Load all data and redraw plot.\n"
|
||||
"Warning: not all data has been fetched from the table yet due to the partial fetch mechanism."));
|
||||
QToolTip::showText(ui->buttonLoadAllData->mapToGlobal(QPoint(0, 0)), ui->buttonLoadAllData->toolTip());
|
||||
} else {
|
||||
ui->buttonLoadAllData->setEnabled(false);
|
||||
ui->buttonLoadAllData->setStyleSheet("");
|
||||
ui->buttonLoadAllData->setToolTip(tr("Load all data and redraw plot"));
|
||||
}
|
||||
}
|
||||
|
||||
void PlotDock::on_treePlotColumns_itemChanged(QTreeWidgetItem* changeitem, int column)
|
||||
|
||||
Reference in New Issue
Block a user