Skip to content

Commit 9207e46

Browse files
committed
Add option to remove all line breaks in the DB Schema view
Add an option to the preferences dialog (by default disabled) which, when activated, removes all line breaks from the Schema column in the Database Structure tab and the DB Schema pane. Especially if there are many tables this might make things clearer.
1 parent 7b6bee1 commit 9207e46

3 files changed

Lines changed: 34 additions & 14 deletions

File tree

src/DbStructureModel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "DbStructureModel.h"
22
#include "sqlitedb.h"
33
#include "sqlitetablemodel.h"
4+
#include "PreferencesDialog.h"
45

56
#include <QTreeWidgetItem>
67
#include <QMimeData>
@@ -36,7 +37,7 @@ QVariant DbStructureModel::data(const QModelIndex& index, int role) const
3637

3738
// Depending on the role either return the text or the icon
3839
if(role == Qt::DisplayRole)
39-
return item->text(index.column());
40+
return PreferencesDialog::getSettingsValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ") : item->text(index.column());
4041
else if(role == Qt::DecorationRole)
4142
return item->icon(index.column());
4243
else

src/PreferencesDialog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void PreferencesDialog::loadSettings()
4343
{
4444
ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(getSettingsValue("db", "defaultencoding").toString(), Qt::MatchFixedString));
4545
ui->locationEdit->setText(getSettingsValue("db", "defaultlocation").toString());
46+
ui->checkHideSchemaLinebreaks->setChecked(getSettingsValue("db", "hideschemalinebreaks").toBool());
4647
ui->foreignKeysCheckBox->setChecked(getSettingsValue("db", "foreignkeys").toBool());
4748
ui->spinPrefetchSize->setValue(getSettingsValue("db", "prefetchsize").toInt());
4849

@@ -68,6 +69,7 @@ void PreferencesDialog::saveSettings()
6869
{
6970
setSettingsValue("db", "defaultencoding", ui->encodingComboBox->currentText());
7071
setSettingsValue("db", "defaultlocation", ui->locationEdit->text());
72+
setSettingsValue("db", "hideschemalinebreaks", ui->checkHideSchemaLinebreaks->isChecked());
7173
setSettingsValue("db", "foreignkeys", ui->foreignKeysCheckBox->isChecked());
7274
setSettingsValue("db", "prefetchsize", ui->spinPrefetchSize->value());
7375

@@ -130,6 +132,10 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const
130132
if(group == "db" && name == "defaultlocation")
131133
return QDir::homePath();
132134

135+
// db/hideschemalinebreaks?
136+
if(group == "db" && name == "hideschemalinebreaks")
137+
return false;
138+
133139
// db/foreignkeys?
134140
if(group == "db" && name == "foreignkeys")
135141
return true;

src/PreferencesDialog.ui

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
</item>
103103
</layout>
104104
</item>
105-
<item row="3" column="0">
105+
<item row="4" column="0">
106106
<widget class="QLabel" name="label_2">
107107
<property name="text">
108108
<string>&amp;Prefetch block size</string>
@@ -112,7 +112,7 @@
112112
</property>
113113
</widget>
114114
</item>
115-
<item row="3" column="1">
115+
<item row="4" column="1">
116116
<widget class="QSpinBox" name="spinPrefetchSize">
117117
<property name="minimum">
118118
<number>255</number>
@@ -122,6 +122,19 @@
122122
</property>
123123
</widget>
124124
</item>
125+
<item row="3" column="0">
126+
<widget class="QLabel" name="label_8">
127+
<property name="text">
128+
<string>Remove line breaks in schema view</string>
129+
</property>
130+
<property name="buddy">
131+
<cstring>checkHideSchemaLinebreaks</cstring>
132+
</property>
133+
</widget>
134+
</item>
135+
<item row="3" column="1">
136+
<widget class="QCheckBox" name="checkHideSchemaLinebreaks"/>
137+
</item>
125138
</layout>
126139
</widget>
127140
<widget class="QWidget" name="tab_2">
@@ -412,14 +425,14 @@
412425
<tabstop>foreignKeysCheckBox</tabstop>
413426
<tabstop>locationEdit</tabstop>
414427
<tabstop>setLocationButton</tabstop>
428+
<tabstop>checkHideSchemaLinebreaks</tabstop>
415429
<tabstop>spinPrefetchSize</tabstop>
416430
<tabstop>treeSyntaxHighlighting</tabstop>
417431
<tabstop>spinEditorFontSize</tabstop>
418432
<tabstop>spinLogFontSize</tabstop>
419433
<tabstop>listExtensions</tabstop>
420434
<tabstop>buttonAddExtension</tabstop>
421435
<tabstop>buttonRemoveExtension</tabstop>
422-
<tabstop>buttonBox</tabstop>
423436
</tabstops>
424437
<resources>
425438
<include location="icons/icons.qrc"/>
@@ -432,8 +445,8 @@
432445
<slot>saveSettings()</slot>
433446
<hints>
434447
<hint type="sourcelabel">
435-
<x>260</x>
436-
<y>265</y>
448+
<x>269</x>
449+
<y>395</y>
437450
</hint>
438451
<hint type="destinationlabel">
439452
<x>155</x>
@@ -448,8 +461,8 @@
448461
<slot>reject()</slot>
449462
<hints>
450463
<hint type="sourcelabel">
451-
<x>328</x>
452-
<y>265</y>
464+
<x>337</x>
465+
<y>395</y>
453466
</hint>
454467
<hint type="destinationlabel">
455468
<x>286</x>
@@ -464,8 +477,8 @@
464477
<slot>chooseLocation()</slot>
465478
<hints>
466479
<hint type="sourcelabel">
467-
<x>478</x>
468-
<y>107</y>
480+
<x>568</x>
481+
<y>119</y>
469482
</hint>
470483
<hint type="destinationlabel">
471484
<x>459</x>
@@ -496,8 +509,8 @@
496509
<slot>addExtension()</slot>
497510
<hints>
498511
<hint type="sourcelabel">
499-
<x>464</x>
500-
<y>64</y>
512+
<x>567</x>
513+
<y>88</y>
501514
</hint>
502515
<hint type="destinationlabel">
503516
<x>245</x>
@@ -512,8 +525,8 @@
512525
<slot>removeExtension()</slot>
513526
<hints>
514527
<hint type="sourcelabel">
515-
<x>464</x>
516-
<y>93</y>
528+
<x>567</x>
529+
<y>117</y>
517530
</hint>
518531
<hint type="destinationlabel">
519532
<x>245</x>

0 commit comments

Comments
 (0)