mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-02-09 21:28:30 -06:00
Allow selecting fixed format for big integer numbers
The default format changes to scientific format when the width of the number would be longer. The user will be able to select fixed format for integer numbers in the contextual menu. Note that precision is set to 0, because in the fixed format trailing zeros are not omitted. See issue #2498
This commit is contained in:
@@ -34,7 +34,8 @@ PlotDock::PlotDock(QWidget* parent)
|
||||
m_currentPlotModel(nullptr),
|
||||
m_currentTableSettings(nullptr),
|
||||
m_showLegend(false),
|
||||
m_stackedBars(false)
|
||||
m_stackedBars(false),
|
||||
m_fixedFormat(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -97,6 +98,17 @@ PlotDock::PlotDock(QWidget* parent)
|
||||
|
||||
connect(stackedBarsAction, &QAction::toggled, this, &PlotDock::toggleStackedBars);
|
||||
|
||||
QAction* fixedFormatsAction = new QAction(tr("Fixed number format"), m_contextMenu);
|
||||
fixedFormatsAction->setCheckable(true);
|
||||
m_contextMenu->addAction(fixedFormatsAction);
|
||||
|
||||
connect(fixedFormatsAction, &QAction::toggled, this,
|
||||
[=](bool fixed) {
|
||||
m_fixedFormat = fixed;
|
||||
adjustAxisFormat();
|
||||
ui->plotWidget->replot();
|
||||
});
|
||||
|
||||
connect(ui->plotWidget, &QTableView::customContextMenuRequested,
|
||||
[=](const QPoint& pos) {
|
||||
// Show menu
|
||||
@@ -540,6 +552,7 @@ void PlotDock::updatePlot(SqliteTableModel* model, BrowseDataTableSettings* sett
|
||||
}
|
||||
|
||||
adjustBars();
|
||||
adjustAxisFormat();
|
||||
ui->plotWidget->replot();
|
||||
|
||||
// Warn user if not all data has been fetched and hint about the button for loading all the data
|
||||
@@ -973,6 +986,19 @@ void PlotDock::adjustBars()
|
||||
}
|
||||
}
|
||||
|
||||
void PlotDock::adjustAxisFormat()
|
||||
{
|
||||
const QString format = m_fixedFormat? "f" : "gb";
|
||||
ui->plotWidget->xAxis->setNumberFormat(format);
|
||||
ui->plotWidget->yAxis->setNumberFormat(format);
|
||||
ui->plotWidget->yAxis2->setNumberFormat(format);
|
||||
|
||||
const int precision = m_fixedFormat? 0 : 6;
|
||||
ui->plotWidget->xAxis->setNumberPrecision(precision);
|
||||
ui->plotWidget->yAxis->setNumberPrecision(precision);
|
||||
ui->plotWidget->yAxis2->setNumberPrecision(precision);
|
||||
}
|
||||
|
||||
void PlotDock::toggleStackedBars(bool stacked)
|
||||
{
|
||||
m_stackedBars = stacked;
|
||||
|
||||
@@ -96,6 +96,7 @@ private:
|
||||
QMenu* m_contextMenu;
|
||||
bool m_showLegend;
|
||||
bool m_stackedBars;
|
||||
bool m_fixedFormat;
|
||||
Palette m_graphPalette;
|
||||
std::vector<QCPAxis *> yAxes;
|
||||
std::vector<int> PlotColumnY;
|
||||
@@ -108,6 +109,7 @@ private:
|
||||
*/
|
||||
QVariant::Type guessDataType(SqliteTableModel* model, int column) const;
|
||||
void adjustBars();
|
||||
void adjustAxisFormat();
|
||||
|
||||
private slots:
|
||||
void on_treePlotColumns_itemChanged(QTreeWidgetItem* item, int column);
|
||||
|
||||
Reference in New Issue
Block a user