changeset 687:973a7ce19658

(issue24) Let the string for install / remove be set for each item individually
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 01 Jul 2014 12:49:19 +0200
parents a2e94e88d304
children b430f890d3ee
files ui/certificateitemwidget.cpp ui/certificateitemwidget.h ui/certificatelistwidget.cpp ui/certificatelistwidget.h ui/mainwindow.cpp
diffstat 5 files changed, 27 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ui/certificateitemwidget.cpp	Tue Jul 01 12:14:10 2014 +0200
+++ b/ui/certificateitemwidget.cpp	Tue Jul 01 12:49:19 2014 +0200
@@ -10,11 +10,15 @@
 #include <QHBoxLayout>
 #include <QDebug>
 
-CertificateItemWidget::CertificateItemWidget(
-    QWidget *parent,
-    const Certificate &cert,
-    bool state,
-    bool editable) : QWidget(parent)
+CertificateItemWidget::CertificateItemWidget(QWidget *parent,
+                                             const Certificate &cert,
+                                             bool state,
+                                             bool editable,
+                                             const QString &installLabel,
+                                             const QString &removeLabel) :
+    QWidget(parent),
+    mInstallLabel (installLabel),
+    mRemoveLabel (removeLabel)
 {
     mCertificate = cert;
     mState = state;
@@ -32,8 +36,8 @@
 
     QHBoxLayout *layout = new QHBoxLayout;
     if (mCertificate.isInstallCert()) {
-        mComboBox->addItem(QIcon(":/img/security-high.png"), tr("install"), QVariant("true"));
-        mComboBox->addItem(QIcon(":/img/security-low.png"), tr("remove"), QVariant("false"));
+        mComboBox->addItem(QIcon(":/img/security-high.png"), mInstallLabel, QVariant("true"));
+        mComboBox->addItem(QIcon(":/img/security-low.png"), mRemoveLabel, QVariant("false"));
         if (mState)
             mComboBox->setCurrentIndex(0);
         else {
--- a/ui/certificateitemwidget.h	Tue Jul 01 12:14:10 2014 +0200
+++ b/ui/certificateitemwidget.h	Tue Jul 01 12:49:19 2014 +0200
@@ -26,7 +26,9 @@
         QWidget *parent = 0,
         const Certificate &cert = Certificate(),
         bool state = false,
-        bool edtiable = true);
+        bool editable = true,
+        const QString& installLabel = tr("install"),
+        const QString& removeLabel = tr("remove"));
 
     bool state();
     void setState(bool state);
@@ -40,6 +42,8 @@
     bool mEditable;
     QLabel *mLabel;
     QComboBox *mComboBox;
+    QString mInstallLabel;
+    QString mRemoveLabel;
 
 private slots:
     void currentStateChanged(int ndx);
--- a/ui/certificatelistwidget.cpp	Tue Jul 01 12:14:10 2014 +0200
+++ b/ui/certificatelistwidget.cpp	Tue Jul 01 12:49:19 2014 +0200
@@ -70,14 +70,17 @@
 void CertificateListWidget::addCertificate(
     const Certificate &certificate,
     bool state,
-    bool editable)
+    bool editable,
+    const QString &installLabel,
+    const QString &removeLabel)
 {
     QListWidgetItem* item = new QListWidgetItem(mCertificateList);
     item->setData(Qt::UserRole,
         QVariant::fromValue(certificate));
     mCertificateList->addItem(item);
     CertificateItemWidget *widget =
-        new CertificateItemWidget(mCertificateList, certificate, state, editable);
+        new CertificateItemWidget(mCertificateList, certificate, state, editable,
+                installLabel, removeLabel);
     connect(widget, SIGNAL(stateChanged(bool, const Certificate&)),
         this, SLOT(certStateChanged(bool, const Certificate&)));
     item->setSizeHint(widget->minimumSizeHint());
--- a/ui/certificatelistwidget.h	Tue Jul 01 12:14:10 2014 +0200
+++ b/ui/certificatelistwidget.h	Tue Jul 01 12:49:19 2014 +0200
@@ -27,7 +27,10 @@
 public:
     CertificateListWidget(QWidget *parent, Qt::WindowFlags flags = 0);
 
-    void addCertificate(const Certificate &certificate, bool state, bool editable = true);
+    void addCertificate(const Certificate &certificate, bool state,
+                        bool editable = true,
+                        const QString& installLabel = tr("install"),
+                        const QString& removeLabel = tr("remove"));
     void addCertificates(const QList<Certificate> &list);
     void removeCertificate(const Certificate &cert);
     void setCertState(bool state, const Certificate &cert);
--- a/ui/mainwindow.cpp	Tue Jul 01 12:14:10 2014 +0200
+++ b/ui/mainwindow.cpp	Tue Jul 01 12:49:19 2014 +0200
@@ -862,7 +862,8 @@
                 else {
                     // Is a brand new certificate
                     newInstallCerts.append(cert);
-                    mUpdatesNew->addCertificate(cert, state);
+                    mUpdatesNew->addCertificate(cert, state, true,
+                            tr("install"), tr("ignore"));
                 }
             }
             else {

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