mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-14 15:59:18 -05:00
Add option for showing the rowid column
See issue #408. This isn't working reliably yet on my system: If you enable the fix restoring the previous settings when going back to a table doesn't work and if you disable it that very way is the only way to change the option. Don't know what's going on there :(
This commit is contained in:
@@ -63,7 +63,7 @@ FilterTableHeader::FilterTableHeader(QTableView* parent) :
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
void FilterTableHeader::generateFilters(int number)
|
||||
void FilterTableHeader::generateFilters(int number, bool showFirst)
|
||||
{
|
||||
// Delete all the current filter widgets
|
||||
for(int i=0;i < filterWidgets.size(); ++i)
|
||||
@@ -74,7 +74,10 @@ void FilterTableHeader::generateFilters(int number)
|
||||
for(int i=0;i < number; ++i)
|
||||
{
|
||||
FilterLineEdit* l = new FilterLineEdit(this, &filterWidgets, i);
|
||||
l->setVisible(i>0); // This hides the first input widget which belongs to the hidden rowid column
|
||||
if(!showFirst && i == 0) // This hides the first input widget which belongs to the hidden rowid column
|
||||
l->setVisible(false);
|
||||
else
|
||||
l->setVisible(true);
|
||||
connect(l, SIGNAL(textChanged(QString)), this, SLOT(inputChanged(QString)));
|
||||
filterWidgets.push_back(l);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
void generateFilters(int number);
|
||||
void generateFilters(int number, bool showFirst = false);
|
||||
void adjustPositions();
|
||||
void clearFilters();
|
||||
void setFilter(int column, const QString& value);
|
||||
|
||||
+29
-4
@@ -122,6 +122,7 @@ void MainWindow::init()
|
||||
ui->actionSqlSaveFilePopup->setMenu(popupSaveSqlFileMenu);
|
||||
|
||||
popupBrowseDataHeaderMenu = new QMenu(this);
|
||||
popupBrowseDataHeaderMenu->addAction(ui->actionShowRowidColumn);
|
||||
popupBrowseDataHeaderMenu->addAction(ui->actionBrowseTableEditDisplayFormat);
|
||||
|
||||
// Add menu item for log dock
|
||||
@@ -366,16 +367,16 @@ void MainWindow::populateTable(const QString& tablename)
|
||||
else
|
||||
m_browseTableModel->setTable(tablename, v);
|
||||
}
|
||||
ui->dataTable->setColumnHidden(0, true);
|
||||
|
||||
// Update the filter row
|
||||
qobject_cast<FilterTableHeader*>(ui->dataTable->horizontalHeader())->generateFilters(m_browseTableModel->columnCount());
|
||||
|
||||
// Restore table settings
|
||||
if(storedDataFound)
|
||||
{
|
||||
// There is information stored for this table, so extract it and apply it
|
||||
|
||||
// Show rowid column. Needs to be done before the column widths setting because of the workaround in there and before the filter setting
|
||||
// because of the filter row generation.
|
||||
showRowidColumn(tableIt.value().showRowid);
|
||||
|
||||
// Column widths
|
||||
for(QMap<int, int>::ConstIterator widthIt=tableIt.value().columnWidths.constBegin();widthIt!=tableIt.value().columnWidths.constEnd();++widthIt)
|
||||
ui->dataTable->setColumnWidth(widthIt.key(), widthIt.value());
|
||||
@@ -391,6 +392,9 @@ void MainWindow::populateTable(const QString& tablename)
|
||||
} else {
|
||||
// There aren't any information stored for this table yet, so use some default values
|
||||
|
||||
// Hide rowid column. Needs to be done before the column widths setting because of the workaround in there
|
||||
showRowidColumn(false);
|
||||
|
||||
// Column widths
|
||||
for(int i=1;i<m_browseTableModel->columnCount();i++)
|
||||
ui->dataTable->setColumnWidth(i, ui->dataTable->horizontalHeader()->defaultSectionSize());
|
||||
@@ -1957,6 +1961,7 @@ bool MainWindow::loadProject(QString filename)
|
||||
populateTable(ui->comboBrowseTable->currentText()); // Refresh view
|
||||
ui->dataTable->sortByColumn(browseTableSettings[ui->comboBrowseTable->currentText()].sortOrderIndex,
|
||||
browseTableSettings[ui->comboBrowseTable->currentText()].sortOrderMode);
|
||||
showRowidColumn(browseTableSettings[ui->comboBrowseTable->currentText()].showRowid);
|
||||
xml.skipCurrentElement();
|
||||
}
|
||||
}
|
||||
@@ -2287,3 +2292,23 @@ void MainWindow::editDataColumnDisplayFormat()
|
||||
populateTable(current_table);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showRowidColumn(bool show)
|
||||
{
|
||||
// FIXME: Workaround for actually getting the next line to work reliably
|
||||
//ui->dataTable->setModel(0);
|
||||
//ui->dataTable->setModel(m_browseTableModel);
|
||||
|
||||
// Show/hide rowid column
|
||||
ui->dataTable->setColumnHidden(0, !show);
|
||||
|
||||
// Update checked status of the popup menu action
|
||||
ui->actionShowRowidColumn->setChecked(show);
|
||||
|
||||
// Save settings for this table
|
||||
QString current_table = ui->comboBrowseTable->currentText();
|
||||
browseTableSettings[current_table].showRowid = show;
|
||||
|
||||
// Update the filter row
|
||||
qobject_cast<FilterTableHeader*>(ui->dataTable->horizontalHeader())->generateFilters(m_browseTableModel->columnCount(), show);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
QMap<int, int> columnWidths;
|
||||
QMap<int, QString> filterValues;
|
||||
QMap<int, QString> displayFormats;
|
||||
bool showRowid;
|
||||
|
||||
friend QDataStream& operator<<(QDataStream& stream, const MainWindow::BrowseDataTableSettings& object)
|
||||
{
|
||||
@@ -47,6 +48,7 @@ public:
|
||||
stream << object.columnWidths;
|
||||
stream << object.filterValues;
|
||||
stream << object.displayFormats;
|
||||
stream << object.showRowid;
|
||||
|
||||
return stream;
|
||||
}
|
||||
@@ -59,6 +61,7 @@ public:
|
||||
stream >> object.columnWidths;
|
||||
stream >> object.filterValues;
|
||||
stream >> object.displayFormats;
|
||||
stream >> object.showRowid;
|
||||
|
||||
return stream;
|
||||
}
|
||||
@@ -214,6 +217,7 @@ private slots:
|
||||
void on_comboPointShape_currentIndexChanged(int index);
|
||||
void showDataColumnPopupMenu(const QPoint& pos);
|
||||
void editDataColumnDisplayFormat();
|
||||
void showRowidColumn(bool show);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+51
-23
@@ -324,8 +324,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>509</width>
|
||||
<height>458</height>
|
||||
<width>514</width>
|
||||
<height>579</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
@@ -810,7 +810,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1037</width>
|
||||
<height>19</height>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="fileMenu">
|
||||
@@ -908,7 +908,7 @@
|
||||
<set>QDockWidget::AllDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SQL Log</string>
|
||||
<string>SQL &Log</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
@@ -920,7 +920,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="labelLogSubmittedBy">
|
||||
<property name="text">
|
||||
<string>&Show SQL submitted by</string>
|
||||
<string>Show S&QL submitted by</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboLogSubmittedBy</cstring>
|
||||
@@ -1000,7 +1000,7 @@
|
||||
<set>QDockWidget::AllDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Plot</string>
|
||||
<string>&Plot</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
@@ -1254,7 +1254,7 @@
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dockSchema">
|
||||
<property name="windowTitle">
|
||||
<string>DB Schema</string>
|
||||
<string>DB Sche&ma</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
@@ -1339,7 +1339,7 @@
|
||||
<normaloff>:/icons/db_revert</normaloff>:/icons/db_revert</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Revert Changes</string>
|
||||
<string>&Revert Changes</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Revert database to last saved state</string>
|
||||
@@ -1357,7 +1357,7 @@
|
||||
<normaloff>:/icons/db_save</normaloff>:/icons/db_save</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Write Changes</string>
|
||||
<string>&Write Changes</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Write changes to the database file</string>
|
||||
@@ -1374,7 +1374,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Compact Database</string>
|
||||
<string>Compact &Database</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Compact the database file, removing space wasted by deleted records</string>
|
||||
@@ -1399,7 +1399,7 @@
|
||||
</action>
|
||||
<action name="fileImportSQLAction">
|
||||
<property name="text">
|
||||
<string>Database from SQL file...</string>
|
||||
<string>&Database from SQL file...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Import data from an .sql dump text file into a new or existing database.</string>
|
||||
@@ -1410,7 +1410,7 @@
|
||||
</action>
|
||||
<action name="fileImportCSVAction">
|
||||
<property name="text">
|
||||
<string>Table from CSV file...</string>
|
||||
<string>&Table from CSV file...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open a wizard that lets you import data from a comma separated text file into a database table.</string>
|
||||
@@ -1421,7 +1421,7 @@
|
||||
</action>
|
||||
<action name="fileExportSQLAction">
|
||||
<property name="text">
|
||||
<string>Database to SQL file...</string>
|
||||
<string>&Database to SQL file...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Export a database to a .sql dump text file.</string>
|
||||
@@ -1432,7 +1432,7 @@
|
||||
</action>
|
||||
<action name="fileExportCSVAction">
|
||||
<property name="text">
|
||||
<string>Table(s) as CSV file...</string>
|
||||
<string>&Table(s) as CSV file...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Export a database table as a comma separated text file.</string>
|
||||
@@ -1450,7 +1450,7 @@
|
||||
<normaloff>:/icons/table_create</normaloff>:/icons/table_create</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create Table...</string>
|
||||
<string>&Create Table...</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Open the Create Table wizard, where it is possible to define the name and fields for a new table in the database</string>
|
||||
@@ -1465,7 +1465,7 @@
|
||||
<normaloff>:/icons/table_delete</normaloff>:/icons/table_delete</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete Table...</string>
|
||||
<string>&Delete Table...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete Table</string>
|
||||
@@ -1483,7 +1483,7 @@
|
||||
<normaloff>:/icons/table_modify</normaloff>:/icons/table_modify</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Modify Table...</string>
|
||||
<string>&Modify Table...</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Open the Modify Table wizard, where it is possible to rename an existing table. It is also possible to add or delete fields form a table, as well as modify field names and types.</string>
|
||||
@@ -1498,7 +1498,7 @@
|
||||
<normaloff>:/icons/index_create</normaloff>:/icons/index_create</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create Index...</string>
|
||||
<string>Create &Index...</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Open the Create Index wizard, where it is possible to define a new index on an existing database table.</string>
|
||||
@@ -1539,7 +1539,7 @@
|
||||
<normaloff>:/icons/whatis</normaloff>:/icons/whatis</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>What's This?</string>
|
||||
<string>W&hat's This?</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Shift+F1</string>
|
||||
@@ -1612,7 +1612,7 @@
|
||||
<normaloff>:/icons/load_extension</normaloff>:/icons/load_extension</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load extension</string>
|
||||
<string>&Load extension</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSqlExecuteLine">
|
||||
@@ -1674,7 +1674,7 @@
|
||||
<normaloff>:/icons/project_save</normaloff>:/icons/project_save</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Project</string>
|
||||
<string>Sa&ve Project</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save the current session to a file</string>
|
||||
@@ -1689,7 +1689,7 @@
|
||||
<normaloff>:/icons/project_open</normaloff>:/icons/project_open</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open Project</string>
|
||||
<string>Open &Project</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Load a working session from a file</string>
|
||||
@@ -1712,7 +1712,7 @@
|
||||
<normaloff>:/icons/encryption</normaloff>:/icons/encryption</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set Encryption</string>
|
||||
<string>&Set Encryption</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSqlSaveFileAs">
|
||||
@@ -1768,6 +1768,17 @@
|
||||
<string>Edit the display format of the data in this column</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShowRowidColumn">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show rowid column</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Toggle the visibility of the rowid column</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@@ -2707,6 +2718,22 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionShowRowidColumn</sender>
|
||||
<signal>triggered(bool)</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>showRowidColumn(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>518</x>
|
||||
<y>314</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>fileOpen()</slot>
|
||||
@@ -2764,5 +2791,6 @@
|
||||
<slot>copyCurrentCreateStatement()</slot>
|
||||
<slot>jumpToRow(QString,QString,QByteArray)</slot>
|
||||
<slot>editDataColumnDisplayFormat()</slot>
|
||||
<slot>showRowidColumn(bool)</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user