Select last used profile by default

This commit is contained in:
Mark Watkins 2011-10-02 00:08:43 +10:00
parent 265fda727b
commit 4eb6ba5d23
2 changed files with 6 additions and 0 deletions

View File

@ -114,5 +114,6 @@ int main(int argc, char *argv[])
MainWindow w; MainWindow w;
mainwin=&w; mainwin=&w;
w.show(); w.show();
return a.exec(); return a.exec();
} }

View File

@ -24,6 +24,7 @@ ProfileSelect::ProfileSelect(QWidget *parent) :
int i=0; int i=0;
int sel=-1;
for (QHash<QString,Profile *>::iterator p=Profiles::profiles.begin();p!=Profiles::profiles.end();p++) { for (QHash<QString,Profile *>::iterator p=Profiles::profiles.begin();p!=Profiles::profiles.end();p++) {
//str.append(p.key()); //str.append(p.key());
Profile &profile=**p; Profile &profile=**p;
@ -31,6 +32,9 @@ ProfileSelect::ProfileSelect(QWidget *parent) :
// if (!profile["FirstName"].toString().isEmpty()) // if (!profile["FirstName"].toString().isEmpty())
// name+=" ("+profile["FirstName"].toString()+" "+profile["LastName"].toString()+")"; // name+=" ("+profile["FirstName"].toString()+" "+profile["LastName"].toString()+")";
QStandardItem *item=new QStandardItem(*new QIcon(":/icons/moon.png"),name); QStandardItem *item=new QStandardItem(*new QIcon(":/icons/moon.png"),name);
if (pref.Exists("Profile") && (name==pref["Profile"].toString())) {
sel=i;
}
item->setData(p.key()); item->setData(p.key());
item->setEditable(false); item->setEditable(false);
item->setFont(QFont("Sans Serif",18,QFont::Bold,false)); item->setFont(QFont("Sans Serif",18,QFont::Bold,false));
@ -40,6 +44,7 @@ ProfileSelect::ProfileSelect(QWidget *parent) :
ui->listView->setModel(model); ui->listView->setModel(model);
ui->listView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->listView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->listView->setSelectionMode(QAbstractItemView::SingleSelection); ui->listView->setSelectionMode(QAbstractItemView::SingleSelection);
if (sel>=0) ui->listView->setCurrentIndex(model->item(sel)->index());
m_tries=0; m_tries=0;
} }