Mercurial > trustbridge
annotate ui/listupdatedialog.cpp @ 84:00a93409e93e
Keep raw data around to later pass it to the installer
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 20 Mar 2014 16:21:27 +0000 |
parents | 1f27d6db5ee3 |
children | e52df5870c4f |
rev | line source |
---|---|
71
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 #include "listupdatedialog.h" |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 #include <QDebug> |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
3 #include <QPushButton> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
4 #include <QGroupBox> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
5 #include <QHBoxLayout> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
6 #include <QListWidget> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
7 #include <QVBoxLayout> |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
8 #include "certificate.h" |
71
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 ListUpdateDialog::ListUpdateDialog(QDialog *parent, |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 const CertificateList &listToInstall) : |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 QDialog(parent), |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 mCertificateList(listToInstall) |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
14 { |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 qDebug() << "I am a happy list update dialog"; |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 setupGUI(); |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 } |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 void ListUpdateDialog::setupGUI() |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 { |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
21 /* Top level layout / widgets */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
22 QVBoxLayout *topLayout = new QVBoxLayout; |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
23 QHBoxLayout *listLayout = new QHBoxLayout; |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
24 QPushButton *executeUpdate = new QPushButton(tr("Update Stores")); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
25 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
26 /* The remove groups */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
27 QVBoxLayout *removeGroupLayout = new QVBoxLayout; |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
28 mRemoveListWidget = new QListWidget; |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
29 removeGroupLayout->addWidget(mRemoveListWidget); |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
30 QGroupBox *removeGroup = new QGroupBox(tr("Select certificates to be removed")); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
31 removeGroup->setLayout(removeGroupLayout); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
32 |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
33 foreach (const Certificate& cert, mCertificateList.getRemoveCertificates()) { |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
34 if (!cert.isValid()) { |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
35 qWarning() << "Invalid certificate in list"; |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
36 continue; |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
37 } |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
38 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
39 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
40 item->setCheckState(Qt::Checked); |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
41 mRemoveListWidget->addItem(item); |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
42 } |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
43 |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
44 /* The install group */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
45 QVBoxLayout *installGroupLayout = new QVBoxLayout; |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
46 mInstallListWidget = new QListWidget; |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
47 QGroupBox *installGroup = new QGroupBox(tr("Select certificates to install")); |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
48 installGroupLayout->addWidget(mInstallListWidget); |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
49 installGroup->setLayout(installGroupLayout); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
50 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
51 foreach (const Certificate& cert, mCertificateList.getInstallCertificates()) { |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
52 if (!cert.isValid()) { |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
53 qWarning() << "Invalid certificate in list"; |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
54 continue; |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
55 } |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
56 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
57 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
58 item->setCheckState(Qt::Checked); |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
59 mInstallListWidget->addItem(item); |
80
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
60 } |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
61 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
62 /* Add groups to layout */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
63 listLayout->addWidget(installGroup); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
64 listLayout->addWidget(removeGroup); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
65 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
66 /* Fill top level layout */ |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
67 topLayout->addLayout(listLayout); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
68 topLayout->addWidget(executeUpdate); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
69 |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
70 setLayout(topLayout); |
01286d0872ca
Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents:
71
diff
changeset
|
71 |
71
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
72 return; |
f22a99f7cb69
Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
73 } |
82
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
74 |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
75 void ListUpdateDialog::executeUpdate() { |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
76 |
1f27d6db5ee3
Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents:
80
diff
changeset
|
77 } |