summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-06-16 16:22:36 +0200
committerNils Schwabe2014-06-16 16:22:36 +0200
commit231f6c67b00d1e8e2a7810eb8a1737dd7e7d9f90 (patch)
tree9191d1221b0309abce442f0d28775cab9261ab30 /src/dialog.cpp
parentFix refresh again.... (diff)
downloadvmchooser2-231f6c67b00d1e8e2a7810eb8a1737dd7e7d9f90.tar.gz
vmchooser2-231f6c67b00d1e8e2a7810eb8a1737dd7e7d9f90.tar.xz
vmchooser2-231f6c67b00d1e8e2a7810eb8a1737dd7e7d9f90.zip
Fix missing details on startup
Fix that default selection is obscure
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index 5118cbb..f6b67b1 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -23,6 +23,7 @@ Dialog::Dialog(QWidget *parent)
model_[2] = new SessionTreeModel(parent);
ui->setupUi(this);
+
tabs_[0] = ui->tabButtonLocal;
tabs_[1] = ui->tabButtonMyClasses;
tabs_[2] = ui->tabButtonAllClasses;
@@ -47,10 +48,15 @@ Dialog::Dialog(QWidget *parent)
ui->helpBox->hide();
ui->newsBox->hide();
+ oldRow_ = 0; // this is the old row (when switching to a new tab)
+
this->addStatusString(STR_LOADING);
+ /*
+ * TODO: why connect signal/slot when no item was loaded yet?
QObject::connect(ui->treeView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex&, const QModelIndex&)),
this, SLOT(treeView_selectionChanged(const QModelIndex&, const QModelIndex&)));
+ */
this->onTabButtonChanged(2);
@@ -230,7 +236,7 @@ bool Dialog::selectSession(const QString& name) {
// set selection
ui->treeView->selectionModel()->clearSelection();
ui->treeView->selectionModel()
- ->setCurrentIndex(index, QItemSelectionModel::Select);
+ ->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect);
return true;
}
}
@@ -367,6 +373,9 @@ void Dialog::addSessionsAfterDownload(QNetworkReply* reply) {
this->addStatusString(STR_NO_ITEMS);
}
+ // give focus to treeView
+ ui->treeView->setFocus();
+
// select last-session
selectPreviousSession();
}
@@ -442,9 +451,14 @@ void Dialog::onTabButtonChanged(int tab) {
this->ui->filterEdit->setText("");
}
+ // save old row
+ //oldRow_ = ui->treeView->selectionModel()->currentIndex().row();
+
// load the new list
setListModel(model_[tab]);
this->activeTab_ = tab;
+ ui->treeView->selectionModel()->select(ui->treeView->model()->index(0, 0, ui->treeView->rootIndex()), QItemSelectionModel::Select);
+ treeView_selectionChanged(ui->treeView->model()->index(oldRow_, 0, ui->treeView->rootIndex()), ui->treeView->model()->index(0, 0, ui->treeView->rootIndex()));
}
void Dialog::on_filterEdit_textChanged() {
@@ -468,11 +482,13 @@ void Dialog::setListModel(QAbstractItemModel *model) {
ui->treeView->setModel(model);
// reconnect the treeModel
- QObject::connect(ui->treeView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex&, const QModelIndex&)),
+ QObject::connect(ui->treeView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)),
this, SLOT(treeView_selectionChanged(const QModelIndex&, const QModelIndex&)));
- if (ui->treeView->selectionModel()->selectedRows(0).count() == 0) {
- ui->treeView->selectionModel()->setCurrentIndex(ui->treeView->model()->index(0, 0, ui->treeView->rootIndex()), QItemSelectionModel::Select);
+ // select the first element, if no element is selected
+ if (ui->treeView->selectionModel()->selectedRows().count() == 0) {
+ //ui->treeView->selectionModel()->setCurrentIndex(ui->treeView->model()->index(0, 0, ui->treeView->rootIndex()), QItemSelectionModel::Select);
+ ui->treeView->selectionModel()->select(ui->treeView->model()->index(0, 0, ui->treeView->rootIndex()), QItemSelectionModel::Select);
}
}