[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevplatform/1.6] shell: Session chooser: Fix selection of default entry
From:       Kevin Funk <kevin () kfunk ! org>
Date:       2014-02-04 17:11:37
Message-ID: E1WAjX7-0005WO-OF () scm ! kde ! org
[Download RAW message or body]

Git commit 6388442c0745f561619b228ce862102488adc5ba by Kevin Funk.
Committed on 04/02/2014 at 14:05.
Pushed by kfunk into branch '1.6'.

Session chooser: Fix selection of default entry

Before that patch, the default index was selected more or less randomly.
We cannot rely on the row number for remembering the row with the
default session, because the model is sorted afterwards.

M  +2    -8    shell/sessioncontroller.cpp

http://commits.kde.org/kdevplatform/6388442c0745f561619b228ce862102488adc5ba

diff --git a/shell/sessioncontroller.cpp b/shell/sessioncontroller.cpp
index 8ec6d5f..2c6dec8 100644
--- a/shell/sessioncontroller.cpp
+++ b/shell/sessioncontroller.cpp
@@ -865,7 +865,6 @@ QString SessionController::showSessionChooserDialog(QString \
headerText, bool onl  filter->setFocus();
 
     int row = 0;
-    int defaultRow = 0;
 
     QString defaultSession = KGlobal::config()->group( cfgSessionGroup() \
).readEntry( cfgActiveSessionEntry(), "default" );  
@@ -880,16 +879,10 @@ QString SessionController::showSessionChooserDialog(QString \
headerText, bool onl  if(onlyRunning && !running)
             continue;
 
-        if(si.uuid.toString() == defaultSession)
-            defaultRow = row;
-
         model->setItem(row, 0, new QStandardItem(si.uuid.toString()));
         model->setItem(row, 1, new QStandardItem(si.description));
         model->setItem(row, 2, new QStandardItem);
 
-        if(defaultRow == row && running)
-            ++defaultRow;
-
         ++row;
     }
     model->sort(1);
@@ -902,7 +895,8 @@ QString SessionController::showSessionChooserDialog(QString \
headerText, bool onl  dialog.updateState();
     dialog.mainWidget()->layout()->setContentsMargins(0,0,0,0);
 
-    view->selectionModel()->setCurrentIndex(proxy->mapFromSource(model->index(defaultRow, \
0)), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); +    const \
QModelIndex defaultSessionIndex = model->match(model->index(0, 0), Qt::DisplayRole, \
defaultSession, 1, Qt::MatchExactly).value(0); +    \
view->selectionModel()->setCurrentIndex(proxy->mapFromSource(defaultSessionIndex), \
                QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
     view->setSizePolicy(QSizePolicy::MinimumExpanding, \
                QSizePolicy::MinimumExpanding);
     ///@todo We need a way to get a proper size-hint from the view, but \
unfortunately, that only seems possible after the view was shown.  \
dialog.setInitialSize(QSize(900, 600));


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic