Visual warning when plotting if not all data has been fetched

Warn user if not all data has been fetched and hint about the button for
loading all the data. The attention to this button is attracted changing
its background to a reddish colour and showing a warning in its tool-tip,
which is automatically shown for its default duration.

Default message is simplified and the button is only enabled when it is
useful (users of non-big databases would never be distracted about the
fetching mechanism).

Since this button is also useful for resetting the zoom and axis range,
it is also enabled if the user performs one of these interactions over the
plot.

See discussion at issue #838.
This commit is contained in:
mgrojo
2017-12-13 23:05:56 +01:00
parent e34d36085d
commit 6d3228a0e3
2 changed files with 19 additions and 4 deletions

View File

@@ -193,8 +193,20 @@ 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)
@@ -603,9 +615,11 @@ void PlotDock::selectionChanged()
}
void PlotDock::mousePress()
{
// Allow user to reset the plot
ui->buttonLoadAllData->setEnabled(true);
// if an axis (or axis labels) is selected, only allow the direction of that axis to be dragged
// if no axis (or axis labels) is selected, both directions may be dragged
if (ui->plotWidget->xAxis->selectedParts().testFlag(QCPAxis::spAxis) ||
ui->plotWidget->xAxis->selectedParts().testFlag(QCPAxis::spTickLabels) ||
ui->plotWidget->xAxis->selectedParts().testFlag(QCPAxis::spAxisLabel))
@@ -620,9 +634,11 @@ void PlotDock::mousePress()
void PlotDock::mouseWheel()
{
// Allow user to reset the plot
ui->buttonLoadAllData->setEnabled(true);
// if an axis (or axis labels) is selected, only allow the direction of that axis to be zoomed
// if no axis (or axis labels) is selected, both directions may be zoomed
if (ui->plotWidget->xAxis->selectedParts().testFlag(QCPAxis::spAxis) ||
ui->plotWidget->xAxis->selectedParts().testFlag(QCPAxis::spTickLabels) ||
ui->plotWidget->xAxis->selectedParts().testFlag(QCPAxis::spAxisLabel))

View File

@@ -274,8 +274,7 @@ Select the axes or axes labels to drag and zoom only in that orientation.</strin
<item>
<widget class="QToolButton" name="buttonLoadAllData">
<property name="toolTip">
<string>Load all data and redraw plot.
Data loading has only an effect if not all data has been fetched from the table yet due to the partial fetch mechanism.</string>
<string>Load all data and redraw plot</string>
</property>
<property name="icon">
<iconset resource="icons/icons.qrc">