annotate ui/listupdatedialog.cpp @ 249:6a7eb102716d

Remove code duplication by unifying the certificatelist. You should now check for isInstallCert to determine wether this certificate should be installed or removed. Leaving the getInstallCertificates and getRemoveCertificates in place for compatibilty would have been easier to keep the tests stable.
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 31 Mar 2014 08:06:17 +0000
parents 431b058e903d
children 06089ba2614a
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"
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
2 #include <QCoreApplication>
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 #include <QDebug>
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
4 #include <QDir>
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
5 #include <QFileInfo>
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
6 #include <QProcess>
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
7 #include <QPushButton>
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
8 #include <QGroupBox>
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
9 #include <QHBoxLayout>
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
10 #include <QListWidget>
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
11 #include <QVBoxLayout>
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
12 #include <QLabel>
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
13 #include "certificate.h"
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14
153
252ffe6e27fd Changed type of MainWindow from QDialog to QMainWindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 129
diff changeset
15 ListUpdateDialog::ListUpdateDialog(QMainWindow *parent,
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 const CertificateList &listToInstall) :
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 QDialog(parent),
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 mCertificateList(listToInstall)
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 {
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 setupGUI();
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 }
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 void ListUpdateDialog::setupGUI()
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 {
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
25 /* Top level layout / widgets */
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
26 QVBoxLayout *topLayout = new QVBoxLayout;
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
27 QHBoxLayout *headerLayout = new QHBoxLayout;
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
28 QHBoxLayout *listLayout = new QHBoxLayout;
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
29 QHBoxLayout *bottomLayout = new QHBoxLayout;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
30
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
31 QImage *logoImage = new QImage(":/img/logo-small.png");
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
32 QLabel *logo = new QLabel;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
33 logo->setBackgroundRole(QPalette::Base);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
34 logo->setPixmap(QPixmap::fromImage(*logoImage));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
35 QLabel *title = new QLabel("<h3>" + tr("Update Certificate") + "</h3>");
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
36 headerLayout->addWidget(logo);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
37 headerLayout->addWidget(title);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
38 headerLayout->setStretch(0, 0);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
39 headerLayout->setStretch(1, 10);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
40
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
41 QPushButton *executeUpdate = new QPushButton(tr("Update Stores"));
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
42 connect(executeUpdate, &QPushButton::clicked,
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
43 this, &ListUpdateDialog::executeUpdate);
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
44 QPushButton *install = new QPushButton(tr("Install selected"));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
45 QPushButton *later = new QPushButton(tr("Remind me later"));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
46 bottomLayout->insertStretch(0, 10);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
47 bottomLayout->addWidget(executeUpdate);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
48 bottomLayout->addWidget(install);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
49 bottomLayout->addWidget(later);
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
50
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
51 /* The certificate groups */
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
52 mCertListWidget = new QListWidget;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
53 connect(mCertListWidget, SIGNAL(itemClicked(QListWidgetItem*)),
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
54 this, SLOT(showDetails(QListWidgetItem*)));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
55 mDetailWidget = new QTextEdit;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
56 mDetailWidget->setReadOnly(true);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
57 listLayout->addWidget(mCertListWidget);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
58 listLayout->addWidget(mDetailWidget);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
59 QGroupBox *certGroup = new QGroupBox(tr("Select certificates"));
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
60 certGroup->setLayout(listLayout);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
61
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 221
diff changeset
62 foreach (const Certificate& cert, mCertificateList.getCertificates()) {
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
63 if (!cert.isValid()) {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
64 qWarning() << "Invalid certificate in list";
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
65 continue;
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
66 }
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
67 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
68 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
69 item->setData(Qt::ToolTipRole, cert.details());
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
70 item->setData(Qt::UserRole, cert.base64Line());
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
71 item->setCheckState(Qt::Checked);
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 221
diff changeset
72 QIcon *certIcon = cert.isInstallCert() ? new QIcon(":/img/list-add.png") :
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 221
diff changeset
73 new QIcon(":/img/list-remove.png");
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
74 item->setIcon(*certIcon);
249
6a7eb102716d Remove code duplication by unifying the certificatelist.
Andre Heinecke <aheinecke@intevation.de>
parents: 221
diff changeset
75
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
76 mCertListWidget->addItem(item);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
77 }
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
78
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
79 /* Fill top level layout */
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
80 topLayout->addLayout(headerLayout);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
81 topLayout->addWidget(certGroup);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
82 topLayout->addLayout(bottomLayout);
80
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
83
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
84 setLayout(topLayout);
01286d0872ca Add some UI in listupdatedialog
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
85
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 return;
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
87 }
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
88
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
89 void ListUpdateDialog::executeUpdate() {
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
90 /* TODO move this in another dialog and call it async*/
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
91 QProcess installerProcess;
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
92 QFileInfo fi(QCoreApplication::applicationFilePath());
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
93 QDir myDir = fi.absoluteDir();
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
94 QString instProcName = "cinst";
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
95 if (!fi.suffix().isEmpty()) {
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
96 instProcName += "." + fi.suffix();
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
97 }
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
98 QString instPath = myDir.absoluteFilePath(instProcName);
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
99
127
04dcc0fb1eca Set cinst process path to be the directory of the executable running
Andre Heinecke <aheinecke@intevation.de>
parents: 98
diff changeset
100 installerProcess.setProgram(instPath);
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
101 installerProcess.start();
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
102 installerProcess.waitForStarted();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
103 if (installerProcess.state() == QProcess::NotRunning) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
104 qWarning() << "Failed to start installer Process.";
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
105 /* TODO ERROR message for the user */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
106 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
107 }
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
108
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
109 installerProcess.write("-----BEGIN CERTIFICATE LIST-----\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
110 installerProcess.write(mCertificateList.rawData().toLatin1());
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
111 installerProcess.write("-----END CERTIFICATE LIST-----\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
112
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
113 /* Items to install */
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
114 for (int i = 0; i < mCertListWidget->count(); i++) {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
115 QListWidgetItem *item = mCertListWidget->item(i);
221
431b058e903d Fix typo that happend in rebase conflict resolution
Andre Heinecke <aheinecke@intevation.de>
parents: 214
diff changeset
116 if (item->checkState() != Qt::Checked &&
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
117 item->data(Qt::UserRole).toString().startsWith("I:")) {
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
118 continue;
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
119 }
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
120 installerProcess.write(item->data(Qt::UserRole).toString().toLatin1());
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
121 installerProcess.write("\r\n");
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
122 }
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
123
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
124 /* Items to remove */
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
125 for (int i = 0; i < mCertListWidget->count(); i++) {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
126 QListWidgetItem *item = mCertListWidget->item(i);
214
aab742690bee Fix check for selected items and wait for bytes written.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 213
diff changeset
127 if (!item->checkState() != Qt::Checked &&
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
128 item->data(Qt::UserRole).toString().startsWith("R:")) {
128
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
129 continue;
95d35ec93bbe Supply the cinst process with checked items not with selected ones
Andre Heinecke <aheinecke@intevation.de>
parents: 127
diff changeset
130 }
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
131 installerProcess.write(item->data(Qt::UserRole).toString().toLatin1());
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
132 installerProcess.write("\r\n");
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
133 }
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
134
214
aab742690bee Fix check for selected items and wait for bytes written.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 213
diff changeset
135 installerProcess.waitForBytesWritten();
85
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
136 installerProcess.closeWriteChannel();
e52df5870c4f Add basic interaction with another process
Andre Heinecke <aheinecke@intevation.de>
parents: 82
diff changeset
137 installerProcess.waitForFinished();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
138
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
139 if (installerProcess.exitStatus() == QProcess::CrashExit) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
140 /* Woops */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
141 qWarning() << "Installer process crashed";
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
142 } else if (installerProcess.exitStatus() != QProcess::NormalExit) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
143 /* Can not Happen. there are only those two values but maybe
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
144 * qt changed.. */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
145 qWarning() << "Exit status neither normal nor crash.";
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
146 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
147 }
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
148
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
149 if (installerProcess.exitCode() == 0) {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
150 qDebug() << "Success!";
129
39b7930fbca9 Print debug output also on success
Andre Heinecke <aheinecke@intevation.de>
parents: 128
diff changeset
151 qDebug() << "output: " << installerProcess.readAllStandardOutput();
98
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
152 } else {
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
153 /* TODO handle errors defined by errorcodes.h */
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
154 qDebug() << "Installer Process returned: " << installerProcess.exitCode();
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
155 qDebug() << "output: " << installerProcess.readAllStandardOutput();
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
156 return;
6090e673c707 Add some error handling. Change process path for testing
Andre Heinecke <aheinecke@intevation.de>
parents: 85
diff changeset
157 }
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 80
diff changeset
158 }
213
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
159
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
160 void ListUpdateDialog::showDetails(QListWidgetItem *item)
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
161 {
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
162 QString details = item->data(Qt::ToolTipRole).toString();
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
163 mDetailWidget->setPlainText(details);
3ebebd055d3a Refactored the list update dialog. Now it looks a bit more like the mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 153
diff changeset
164 }

http://wald.intevation.org/projects/trustbridge/