From 11bff0ded839c7d4b6b5eea6118ac44938515ce5 Mon Sep 17 00:00:00 2001 From: Vladislav Tronko Date: Sat, 3 Sep 2016 21:09:26 +0300 Subject: [PATCH] Add cell symbol limit preference --- src/PreferencesDialog.cpp | 4 ++++ src/PreferencesDialog.ui | 32 ++++++++++++++++++++++++++++++++ src/sqlitetablemodel.cpp | 6 ++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp index 5d2a6b87..9dbce7cd 100644 --- a/src/PreferencesDialog.cpp +++ b/src/PreferencesDialog.cpp @@ -88,6 +88,7 @@ void PreferencesDialog::loadSettings() loadColorSetting(ui->fr_bin_fg, "bin_fg"); loadColorSetting(ui->fr_bin_bg, "bin_bg"); + ui->spinSymbolLimit->setValue(getSettingsValue("databrowser", "symbol_limit").toInt()); ui->txtNull->setText(getSettingsValue("databrowser", "null_text").toString()); ui->editFilterEscape->setText(getSettingsValue("databrowser", "filter_escape").toString()); ui->spinFilterDelay->setValue(getSettingsValue("databrowser", "filter_delay").toInt()); @@ -147,6 +148,7 @@ void PreferencesDialog::saveSettings() saveColorSetting(ui->fr_reg_bg, "reg_bg"); saveColorSetting(ui->fr_bin_fg, "bin_fg"); saveColorSetting(ui->fr_bin_bg, "bin_bg"); + setSettingsValue("databrowser", "symbol_limit", ui->spinSymbolLimit->value()); setSettingsValue("databrowser", "null_text", ui->txtNull->text()); setSettingsValue("databrowser", "filter_escape", ui->editFilterEscape->text()); setSettingsValue("databrowser", "filter_delay", ui->spinFilterDelay->value()); @@ -300,6 +302,8 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const return QFont().defaultFamily(); if(name == "fontsize") return 10; + if(name == "symbol_limit") + return 5000; if(name == "null_text") return "NULL"; if(name == "filter_escape") diff --git a/src/PreferencesDialog.ui b/src/PreferencesDialog.ui index b7e01139..4a9cfff3 100644 --- a/src/PreferencesDialog.ui +++ b/src/PreferencesDialog.ui @@ -339,6 +339,38 @@ + + + + Content + + + + + + Symbol limit in cell + + + + + + + + 0 + 0 + + + + 1000 + + + 20000 + + + + + + diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index df338930..1e55f846 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -224,8 +224,10 @@ QVariant SqliteTableModel::data(const QModelIndex &index, int role) const return PreferencesDialog::getSettingsValue("databrowser", "null_text").toString(); else if(role == Qt::DisplayRole && isBinary(index)) return "BLOB"; - else - return decode(m_data.at(index.row()).at(index.column())); + else { + int limit = PreferencesDialog::getSettingsValue("databrowser", "symbol_limit").toInt(); + return decode(m_data.at(index.row()).at(index.column()).left(limit)); + } } else if(role == Qt::FontRole) { QFont font; if(m_data.at(index.row()).at(index.column()).isNull() || isBinary(index))