1 #include "selectremotedlg.h"
4 #include "remotelistwidgetitem.h"
10 #include <QListWidgetItem>
14 #include <QMessageBox>
15 #include <QPushButton>
17 SelectRemoteDlg::SelectRemoteDlg(QWidget *parent)
20 this->setWindowTitle(tr("Select remote"));
21 this->setMinimumHeight(320);
23 layout = new QHBoxLayout(this);
25 alphabetList = new QListWidget(this);
26 alphabetList->setMaximumWidth(96);
27 layout->addWidget(alphabetList);
29 SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
31 SLOT(alphabetItemChanged(QListWidgetItem*, QListWidgetItem*)));
33 mfgList = new QListWidget(this);
34 layout->addWidget(mfgList);
36 SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
38 SLOT(mfgItemChanged(QListWidgetItem*, QListWidgetItem*)));
40 modelList = new QListWidget(this);
41 layout->addWidget(modelList);
43 downloadBtn = new QPushButton(tr("Download"), this);
44 layout->addWidget(downloadBtn);
45 connect(downloadBtn, SIGNAL(clicked()),
46 this, SLOT(downloadRemote()));
48 this->setLayout(layout);
49 connect(&remoteDBMgr, SIGNAL(dbReady(RemoteDB*)),
50 this, SLOT(setDB(RemoteDB*)));
53 SelectRemoteDlg::~SelectRemoteDlg()
58 void SelectRemoteDlg::setDB(RemoteDB *db)
61 alphabetList->addItems(remoteDB->keys());
65 void SelectRemoteDlg::setBusy(bool busy)
67 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, busy);
71 void SelectRemoteDlg::alphabetItemChanged(QListWidgetItem *current,
72 QListWidgetItem * /*previous*/)
78 mfgList->addItems((*remoteDB)[current->text()].keys());
82 void SelectRemoteDlg::mfgItemChanged(QListWidgetItem *current,
83 QListWidgetItem * /*previous*/)
89 (*remoteDB)[alphabetList->currentItem()->text()][current->text()];
90 foreach(Remote *remote, remotes) {
91 modelList->addItem(new RemoteListWidgetItem(remote));
96 void SelectRemoteDlg::downloadRemote()
98 RemoteListWidgetItem *currentModel =
99 static_cast<RemoteListWidgetItem *>(modelList->currentItem());
103 connect(currentModel->remote(), SIGNAL(saveFinished()),
104 this, SLOT(close()));
105 currentModel->remote()->saveToFile();
107 emit remoteChanged(*(currentModel->remote()));
111 void SelectRemoteDlg::refreshDB()
114 if (onlinePollerThread != NULL) {
115 delete onlinePollerThread;
117 onlinePollerThread = new OnlinePollerThread();
118 connect(onlinePollerThread, SIGNAL(online()),
119 this, SLOT(getDB()));
120 onlinePollerThread->run();
123 void SelectRemoteDlg::showEvent(QShowEvent *event)
126 QDialog::showEvent(event);