Added AppTableViewDelegate class for painting tableview (painting not yet done, just...
[meego-garage:garage-netbook-ui.git] / settingsdialog.cpp
1 #include "settingsdialog.h"
2 #include "ui_settingsdialog.h"
3
4 #include <Qt/QtGui>
5
6 SettingsDialog::SettingsDialog(QWidget *parent) :
7     QDialog(parent),
8     ui(new Ui::SettingsDialog)
9 {
10     //get form design (mainwindow.ui)
11     ui->setupUi(this);
12
13     //load listview
14     QStandardItemModel *model = new QStandardItemModel(this);
15     model->setColumnCount(1);
16     model->appendRow (new QStandardItem (QIcon(":/settings-general.png"), "General"));
17     model->appendRow (new QStandardItem (QIcon(":/settings-repo.png"), "Repositories"));
18     model->appendRow (new QStandardItem (QIcon(":/settings-proxy.png"), "Network Proxy"));
19     model->appendRow (new QStandardItem (QIcon(":/settings-history.png"), "History"));
20     ui->settingsListView->setModel(model);
21
22     connect (ui->settingsListView->selectionModel(),
23              SIGNAL (selectionChanged (const QItemSelection &, const QItemSelection &)),
24              this, SLOT (selectionChanged (const QItemSelection&,
25                                            const QItemSelection&)));
26     //select first item
27     QModelIndex index = ui->settingsListView->model()->index (0,0);
28     if (index.isValid()) {
29         ui->settingsListView->selectionModel()->select(index, QItemSelectionModel::SelectCurrent);
30     }
31
32 }
33
34 void SettingsDialog::selectionChanged ( const QItemSelection & selected,
35                                         const QItemSelection & deselected )
36 {
37     Q_UNUSED (deselected);
38     //set tab.
39     QModelIndexList indexList = selected.indexes();
40     if (indexList.count() < 1) {
41         return;
42     }
43     ui->settingsStackedWidget->setCurrentIndex(indexList.first().row());
44     qDebug() << "Selection changed";
45 }