Skip to content

Commit

Permalink
Return the configured font for data browser in the model
Browse files Browse the repository at this point in the history
Otherwise it cannot be used by the format toolbar to get the cell font when
the default has not been overwritten.

See comment in issue #1976

# Conflicts:
#	src/TableBrowser.cpp
  • Loading branch information
mgrojo committed Aug 22, 2020
1 parent f28ecc0 commit c4b2ffc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/TableBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,11 @@ TableBrowser::TableBrowser(QWidget* parent) :

connect(ui->dataTable, &ExtendedTableWidget::currentIndexChanged, this, [this](const QModelIndex &current, const QModelIndex &) {
// Get cell current format for updating the format toolbar values. Block signals, so the format change is not reapplied.
QString font_string = m_model->data(current, Qt::FontRole).toString();
QFont font;
font.fromString(m_model->data(current, Qt::FontRole).toString());
if(!font_string.isEmpty())
font.fromString(font_string);

ui->fontComboBox->blockSignals(true);
ui->fontComboBox->setCurrentFont(font);
ui->fontComboBox->blockSignals(false);
Expand Down
4 changes: 3 additions & 1 deletion src/sqlitetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ QVariant SqliteTableModel::data(const QModelIndex &index, int role) const
return QVariant();
return decode(data);
} else if(role == Qt::FontRole) {
QFont font;
QFont font = m_font;
if(!row_available || data.isNull() || isBinary(data))
font.setItalic(true);
else {
Expand Down Expand Up @@ -1175,6 +1175,8 @@ void SqliteTableModel::reloadSettings()
m_nullBgColour = QColor(Settings::getValue("databrowser", "null_bg_colour").toString());
m_binFgColour = QColor(Settings::getValue("databrowser", "bin_fg_colour").toString());
m_binBgColour = QColor(Settings::getValue("databrowser", "bin_bg_colour").toString());
m_font = QFont(Settings::getValue("databrowser", "font").toString());
m_font.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
m_symbolLimit = Settings::getValue("databrowser", "symbol_limit").toInt();
m_imagePreviewEnabled = Settings::getValue("databrowser", "image_preview").toBool();
m_chunkSize = static_cast<std::size_t>(Settings::getValue("db", "prefetchsize").toUInt());
Expand Down
2 changes: 2 additions & 0 deletions src/sqlitetablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QAbstractTableModel>
#include <QColor>
#include <QFont>

#include <map>
#include <memory>
Expand Down Expand Up @@ -235,6 +236,7 @@ public slots:
QColor m_nullBgColour;
QColor m_binFgColour;
QColor m_binBgColour;
QFont m_font;
int m_symbolLimit;
bool m_imagePreviewEnabled;

Expand Down

0 comments on commit c4b2ffc

Please sign in to comment.