Commit 9102b4b9 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

AkonadiConsole: sort tables and records in DB Browser tab

parent 985acef6
......@@ -28,8 +28,14 @@ DbBrowser::DbBrowser(QWidget* parent) :
{
ui.setupUi( this );
if ( DbAccess::database().isOpen() )
ui.tableBox->addItems( DbAccess::database().tables(QSql::AllTables) );
if ( DbAccess::database().isOpen() ) {
QStringList userTables = DbAccess::database().tables(QSql::Tables);
userTables.sort();
QStringList systemTables = DbAccess::database().tables(QSql::SystemTables);
systemTables.sort();
ui.tableBox->addItems( QStringList() << userTables << systemTables );
}
ui.refreshButton->setIcon( KIcon( "view-refresh" ) );
connect( ui.refreshButton, SIGNAL(clicked()), SLOT(refreshClicked()) );
......@@ -46,5 +52,12 @@ void DbBrowser::refreshClicked()
mTableModel->setEditStrategy( QSqlTableModel::OnRowChange );
mTableModel->select();
ui.tableView->setModel( mTableModel );
connect( ui.tableView->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
this, SLOT(onSortIndicatorChanged(int,Qt::SortOrder)) );
}
void DbBrowser::onSortIndicatorChanged( int column, Qt::SortOrder order )
{
mTableModel->sort( column, order );
}
......@@ -32,6 +32,7 @@ class DbBrowser : public QWidget
private slots:
void refreshClicked();
void onSortIndicatorChanged( int column, Qt::SortOrder order );
private:
Ui::DbBrowser ui;
......
......@@ -32,7 +32,11 @@
</layout>
</item>
<item>
<widget class="QTableView" name="tableView" />
<widget class="QTableView" name="tableView">
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment