comparison ui/listupdatedialog.cpp @ 85:e52df5870c4f

Add basic interaction with another process
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 20 Mar 2014 16:22:16 +0000
parents 1f27d6db5ee3
children 6090e673c707
comparison
equal deleted inserted replaced
84:00a93409e93e 85:e52df5870c4f
1 #include "listupdatedialog.h" 1 #include "listupdatedialog.h"
2 #include <QDebug> 2 #include <QDebug>
3 #include <QProcess>
3 #include <QPushButton> 4 #include <QPushButton>
4 #include <QGroupBox> 5 #include <QGroupBox>
5 #include <QHBoxLayout> 6 #include <QHBoxLayout>
6 #include <QListWidget> 7 #include <QListWidget>
7 #include <QVBoxLayout> 8 #include <QVBoxLayout>
20 { 21 {
21 /* Top level layout / widgets */ 22 /* Top level layout / widgets */
22 QVBoxLayout *topLayout = new QVBoxLayout; 23 QVBoxLayout *topLayout = new QVBoxLayout;
23 QHBoxLayout *listLayout = new QHBoxLayout; 24 QHBoxLayout *listLayout = new QHBoxLayout;
24 QPushButton *executeUpdate = new QPushButton(tr("Update Stores")); 25 QPushButton *executeUpdate = new QPushButton(tr("Update Stores"));
26 connect(executeUpdate, &QPushButton::clicked,
27 this, &ListUpdateDialog::executeUpdate);
25 28
26 /* The remove groups */ 29 /* The remove groups */
27 QVBoxLayout *removeGroupLayout = new QVBoxLayout; 30 QVBoxLayout *removeGroupLayout = new QVBoxLayout;
28 mRemoveListWidget = new QListWidget; 31 mRemoveListWidget = new QListWidget;
29 removeGroupLayout->addWidget(mRemoveListWidget); 32 removeGroupLayout->addWidget(mRemoveListWidget);
53 qWarning() << "Invalid certificate in list"; 56 qWarning() << "Invalid certificate in list";
54 continue; 57 continue;
55 } 58 }
56 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription()); 59 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
57 item->setFlags(item->flags() | Qt::ItemIsUserCheckable); 60 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
61 item->setData(Qt::ToolTipRole, cert.details());
62 item->setData(Qt::UserRole, cert.base64Line());
58 item->setCheckState(Qt::Checked); 63 item->setCheckState(Qt::Checked);
59 mInstallListWidget->addItem(item); 64 mInstallListWidget->addItem(item);
60 } 65 }
61 66
62 /* Add groups to layout */ 67 /* Add groups to layout */
71 76
72 return; 77 return;
73 } 78 }
74 79
75 void ListUpdateDialog::executeUpdate() { 80 void ListUpdateDialog::executeUpdate() {
81 /* TODO move this in another dialog and call it async*/
82 QProcess installerProcess;
76 83
84 installerProcess.setProgram("cinst");
85 installerProcess.start();
86 installerProcess.waitForStarted();
87 installerProcess.write("-----BEGIN CERTIFICATE LIST-----\r\n");
88 installerProcess.write(mCertificateList.rawData().toLatin1());
89 installerProcess.write("-----END CERTIFICATE LIST-----\r\n");
90
91 QList<QListWidgetItem *> selectedItems = mInstallListWidget->selectedItems();
92 selectedItems << mRemoveListWidget->selectedItems();
93
94 foreach (const QListWidgetItem * item, selectedItems) {
95 installerProcess.write(item->data(Qt::UserRole).toString().toLatin1());
96 installerProcess.write("\r\n");
97 }
98
99 installerProcess.closeWriteChannel();
100 installerProcess.waitForFinished();
101 qDebug() << "cinst output: " << installerProcess.readAllStandardOutput();
102 qDebug() << " Done " << " exitCode: " << installerProcess.exitCode();
103 qDebug() << " Done " << " exitStatus: " << installerProcess.exitStatus();
77 } 104 }

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