@@ -116,6 +116,7 @@ void MainWindow::init()
116
116
connect (ui->dataTable ->filterHeader (), SIGNAL (filterChanged (int ,QString)), this , SLOT (setRecordsetLabel ()));
117
117
connect (ui->dataTable ->filterHeader (), SIGNAL (sectionClicked (int )), this , SLOT (browseTableHeaderClicked (int )));
118
118
connect (ui->dataTable ->verticalScrollBar (), SIGNAL (valueChanged (int )), this , SLOT (setRecordsetLabel ()));
119
+ connect (ui->dataTable ->horizontalHeader (), SIGNAL (sectionResized (int ,int ,int )), this , SLOT (updateBrowseDataColumnWidth (int ,int ,int )));
119
120
connect (editWin, SIGNAL (goingAway ()), this , SLOT (editWinAway ()));
120
121
connect (editWin, SIGNAL (updateRecordText (int , int , QByteArray)), this , SLOT (updateRecordText (int , int , QByteArray)));
121
122
connect (ui->dbTreeWidget ->selectionModel (), SIGNAL (currentChanged (QModelIndex,QModelIndex)), this , SLOT (changeTreeSelection ()));
@@ -293,6 +294,19 @@ void MainWindow::populateTable( const QString & tablename)
293
294
m_browseTableModel->setTable (tablename);
294
295
ui->dataTable ->setColumnHidden (0 , true );
295
296
297
+ // Restore column widths
298
+ QMap<QString, QMap<int , int > >::ConstIterator colWidthsIt;
299
+ if ((colWidthsIt = browseTableColumnWidths.constFind (tablename)) != browseTableColumnWidths.constEnd ())
300
+ {
301
+ // There are some column widths stored for this table
302
+ for (QMap<int , int >::ConstIterator it=colWidthsIt.value ().constBegin ();it!=colWidthsIt.value ().constEnd ();++it)
303
+ ui->dataTable ->setColumnWidth (it.key (), it.value ());
304
+ } else {
305
+ // There aren't any column widths stored for this table yet, so set default widths
306
+ for (int i=1 ;i<m_browseTableModel->columnCount ();i++)
307
+ ui->dataTable ->setColumnWidth (i, ui->dataTable ->horizontalHeader ()->defaultSectionSize ());
308
+ }
309
+
296
310
// Reset sorting
297
311
curBrowseOrderByIndex = 0 ;
298
312
curBrowseOrderByMode = Qt::AscendingOrder;
@@ -367,6 +381,9 @@ void MainWindow::fileClose()
367
381
m_browseTableModel = new SqliteTableModel (this , &db, PreferencesDialog::getSettingsValue (" db" , " prefetchsize" ).toInt ());
368
382
connect (ui->dataTable ->filterHeader (), SIGNAL (filterChanged (int ,QString)), m_browseTableModel, SLOT (updateFilter (int ,QString)));
369
383
384
+ // Remove all stored column widths for the browse data table
385
+ browseTableColumnWidths.clear ();
386
+
370
387
// Manually update the recordset label inside the Browse tab now
371
388
setRecordsetLabel ();
372
389
@@ -1662,3 +1679,8 @@ void MainWindow::on_actionWebsite_triggered()
1662
1679
{
1663
1680
QDesktopServices::openUrl (QUrl (" http://sqlitebrowser.org" ));
1664
1681
}
1682
+
1683
+ void MainWindow::updateBrowseDataColumnWidth (int section, int /* old_size*/ , int new_size)
1684
+ {
1685
+ browseTableColumnWidths[ui->comboBrowseTable ->currentText ()][section] = new_size;
1686
+ }
0 commit comments