From c5590f835aba2cd4d0b622b0c63ec4f5796d9548 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 14 May 2013 08:34:16 -0300 Subject: Fix the focus issues, load a profile when load a file. Signed-off-by: Tomaz Canabrava --- qt-ui/mainwindow.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 60a4623c7..0b7f9f25d 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -36,6 +36,8 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), sortModel->setSourceModel(model); ui->ListWidget->setModel(sortModel); setWindowIcon(QIcon(":subsurface-icon")); + connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); + ui->ProfileWidget->setFocusProxy(ui->ListWidget); QModelIndex firstDiveOrTrip = sortModel->index(0,0); if (sortModel->index(0,0, firstDiveOrTrip).isValid()) @@ -43,7 +45,7 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), else ui->ListWidget->setCurrentIndex(firstDiveOrTrip); - connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); + ui->ListWidget->setFocus(); } void MainWindow::current_dive_changed(int divenr) @@ -91,6 +93,13 @@ void MainWindow::on_actionOpen_triggered() model = new DiveTripModel(this); sortModel->setSourceModel(model); ui->ListWidget->sortByColumn(0, Qt::DescendingOrder); + + QModelIndex firstDiveOrTrip = sortModel->index(0,0); + if (sortModel->index(0,0, firstDiveOrTrip).isValid()) + ui->ListWidget->setCurrentIndex(sortModel->index(0,0, firstDiveOrTrip)); + else + ui->ListWidget->setCurrentIndex(firstDiveOrTrip); + ui->ListWidget->setFocus(); } void MainWindow::on_actionSave_triggered() -- cgit v1.2.3-70-g09d2