comparison ui/mainwindow.cpp @ 189:5f0d45ca9de4

Show certificates in the list view and details in the textfield.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 26 Mar 2014 11:44:16 +0100
parents 0c06a608e15f
children 246c21b1727f
comparison
equal deleted inserted replaced
188:a3bde2aaabd9 189:5f0d45ca9de4
8 #include <QMenu> 8 #include <QMenu>
9 #include <QApplication> 9 #include <QApplication>
10 #include <QFile> 10 #include <QFile>
11 #include <QTimer> 11 #include <QTimer>
12 #include <QHBoxLayout> 12 #include <QHBoxLayout>
13 #include <QListWidget>
14 #include <QVBoxLayout> 13 #include <QVBoxLayout>
15 #include <QGroupBox> 14 #include <QGroupBox>
16 #include <QPushButton> 15 #include <QPushButton>
16 #include <QSplitter>
17 17
18 // The amount of time in minutes stay silent if we have 18 // The amount of time in minutes stay silent if we have
19 // something to say 19 // something to say
20 #define NAG_INTERVAL_MINUTES 2 20 #define NAG_INTERVAL_MINUTES 2
21 21
122 QTimer::singleShot(600000 + (qrand() % 60000), this, SLOT(checkUpdates())); 122 QTimer::singleShot(600000 + (qrand() % 60000), this, SLOT(checkUpdates()));
123 } else { 123 } else {
124 mCurMessage = tr("An updated certificate list is available. Click here to install."); 124 mCurMessage = tr("An updated certificate list is available. Click here to install.");
125 setState(NewListAvailable); 125 setState(NewListAvailable);
126 showMessage(); 126 showMessage();
127 loadCertificateList();
127 } 128 }
128 } 129 }
129 130
130 void MainWindow::handleNewSW(const QString& fileName, const QDateTime& modDate) { 131 void MainWindow::handleNewSW(const QString& fileName, const QDateTime& modDate) {
131 mCurMessage = tr("An update for %1 is available. Click here to install.").arg( 132 mCurMessage = tr("An update for %1 is available. Click here to install.").arg(
227 QVBoxLayout *mainLayout = new QVBoxLayout; 228 QVBoxLayout *mainLayout = new QVBoxLayout;
228 QHBoxLayout *certLayout = new QHBoxLayout; 229 QHBoxLayout *certLayout = new QHBoxLayout;
229 QHBoxLayout *bottomLayout = new QHBoxLayout; 230 QHBoxLayout *bottomLayout = new QHBoxLayout;
230 231
231 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); 232 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
232 QListWidget *certificates = new QListWidget; 233 certificateList = new QListWidget;
233 QListWidget *details = new QListWidget; 234 connect(certificateList, SIGNAL(itemClicked(QListWidgetItem*)),
234 certLayout->addWidget(certificates); 235 this, SLOT(showDetails(QListWidgetItem*)));
235 certLayout->addWidget(details); 236 certificateDetails = new QTextEdit;
237 certificateDetails->setReadOnly(true);
238 QSplitter *splitter = new QSplitter(certBox);
239 splitter->addWidget(certificateList);
240 splitter->addWidget(certificateDetails);
241 certLayout->addWidget(splitter);
236 certBox->setLayout(certLayout); 242 certBox->setLayout(certLayout);
237 243
238 QPushButton *update = new QPushButton("Search for Updates"); 244 QPushButton *update = new QPushButton("Search for Updates");
239 connect(update, SIGNAL(clicked()), this, SLOT(checkUpdates())); 245 connect(update, SIGNAL(clicked()), this, SLOT(checkUpdates()));
240 bottomLayout->insertStretch(0, 10); 246 bottomLayout->insertStretch(0, 10);
246 // managed in the central widget. 252 // managed in the central widget.
247 base->setLayout(mainLayout); 253 base->setLayout(mainLayout);
248 setCentralWidget(base); 254 setCentralWidget(base);
249 } 255 }
250 256
251 void MainWindow::showSettings() { 257 void MainWindow::loadCertificateList()
258 {
259 qDebug() << "display certificates";
260 certificateList->clear();
261 foreach (const Certificate &cert, mListToInstall.getInstallCertificates()) {
262 if (!cert.isValid()) {
263 qWarning() << "Invalid certificate in list";
264 continue;
265 }
266 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
267 item->setData(Qt::UserRole, cert.details());
268 QIcon *certIcon = new QIcon(":/img/tray_22.png");
269 item->setIcon(*certIcon);
270 certificateList->addItem(item);
271 }
272 foreach (const Certificate& cert, mListToInstall.getRemoveCertificates()) {
273 if (!cert.isValid()) {
274 qWarning() << "Invalid certificate in list";
275 continue;
276 }
277 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
278 item->setData(Qt::UserRole, cert.details());
279 QIcon *certIcon = new QIcon(":/img/tray_22.png");
280 item->setIcon(*certIcon);
281 certificateList->addItem(item);
282 }
283 }
284
285 void MainWindow::showSettings()
286 {
252 qDebug() << "show settingsdialog"; 287 qDebug() << "show settingsdialog";
253 } 288 }
254 289
255 void MainWindow::showHelp() 290 void MainWindow::showHelp()
256 { 291 {
260 void MainWindow::showAbout() 295 void MainWindow::showAbout()
261 { 296 {
262 qDebug() << "show aboutdialog"; 297 qDebug() << "show aboutdialog";
263 } 298 }
264 299
300 void MainWindow::showDetails(QListWidgetItem *item)
301 {
302 qDebug() << "show details";
303 QString details = item->data(Qt::UserRole).toString();
304 certificateDetails->setPlainText(details);
305 }

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