Support alternative display formats in the Browse Data tab

This is a proof-of-concept or even a basic first implementation of a new
feature I'd like to have in DB4S which at the moment I call display
formats.

The idea here is to allow the user to change the data in the Browse Data
tab on a per column basis before displaying it. This means even though
the data is stored in format X in the database it can be shown in format
Y in the browser. This should be useful in cases where the original
format X is hard to read or just not useful in a particular case.

This first implementation allows the user to right click on the header
of a column and open a new dialog for setting the display format which
offers a (limited) list of pre-defined formats. The selected format is
then integrated into the SELECT statement which is sent to SQLite.

While it works, this draft implementation lacks a number of features.
Here are the most prominent ones I'm currently aware of:
* Data not editable (or only via the Edit Dialog) because it isn't
  transformed back yet.
* More display formats needed; maybe customizable ones, too.
* No indication in the UI for which columns a format has been set.
* Could _maybe_ be integrated into the import/export etc. for optional
  use.
This commit is contained in:
Martin Kleusberg
2015-07-06 18:28:30 +02:00
parent 944e22a80d
commit 7c1d237d9b
11 changed files with 349 additions and 10 deletions

View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ColumnDisplayFormatDialog</class>
<widget class="QDialog" name="ColumnDisplayFormatDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>624</width>
<height>205</height>
</rect>
</property>
<property name="windowTitle">
<string>Choose display format</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Display format</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="labelDisplayFormat">
<property name="text">
<string>Choose a display format for the column '%1' which is applied to each value prior to showing it.</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboDisplayFormat"/>
</item>
<item>
<widget class="SqlTextEdit" name="editDisplayFormat">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SqlTextEdit</class>
<extends>QTextEdit</extends>
<header>sqltextedit.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>comboDisplayFormat</tabstop>
<tabstop>editDisplayFormat</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ColumnDisplayFormatDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>227</x>
<y>188</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>204</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ColumnDisplayFormatDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>295</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>204</y>
</hint>
</hints>
</connection>
<connection>
<sender>comboDisplayFormat</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>ColumnDisplayFormatDialog</receiver>
<slot>updateSqlCode()</slot>
<hints>
<hint type="sourcelabel">
<x>125</x>
<y>69</y>
</hint>
<hint type="destinationlabel">
<x>244</x>
<y>4</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>updateSqlCode()</slot>
</slots>
</ui>