[PATCH] (issue24) Let the string for install / remove be set for each item individually

Wald Commits scm-commit at wald.intevation.org
Tue Jul 1 12:49:23 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1404211759 -7200
# Node ID 973a7ce19658dd148c953341a844ed8d8fd55fd8
# Parent  a2e94e88d3044cb47bdfa8c4c2c1f6b105cb4867
(issue24) Let the string for install / remove be set for each item individually

diff -r a2e94e88d304 -r 973a7ce19658 ui/certificateitemwidget.cpp
--- 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 {
diff -r a2e94e88d304 -r 973a7ce19658 ui/certificateitemwidget.h
--- 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);
diff -r a2e94e88d304 -r 973a7ce19658 ui/certificatelistwidget.cpp
--- 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());
diff -r a2e94e88d304 -r 973a7ce19658 ui/certificatelistwidget.h
--- 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);
diff -r a2e94e88d304 -r 973a7ce19658 ui/mainwindow.cpp
--- 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 {


More information about the Trustbridge-commits mailing list