[PATCH 2 of 2] Add central place to obtain current change count

Wald Commits scm-commit at wald.intevation.org
Wed Jul 2 16:09:24 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1404310159 -7200
# Node ID 929c3db85eb77fc10c5231fa6071eb30a5f306f4
# Parent  345805165d9bdab8c004f032a4f7709c57e3fce4
Add central place to obtain current change count.

diff -r 345805165d9b -r 929c3db85eb7 ui/mainwindow.cpp
--- a/ui/mainwindow.cpp	Wed Jul 02 16:08:55 2014 +0200
+++ b/ui/mainwindow.cpp	Wed Jul 02 16:09:19 2014 +0200
@@ -829,7 +829,8 @@
 
 void MainWindow::listChanged(int selected)
 {
-    int totalCount = mUpdatesRemove->selectedCertCount() +
+    Q_UNUSED (selected);
+    mChangeCount = mUpdatesRemove->selectedCertCount() +
         mUpdatesNew->selectedCertCount() + mUpdatesManual->certificates().size();
 
     if (mUpdatesManual->certificates().size()) {
@@ -840,7 +841,7 @@
         mUpdatesManualCertificates->hide();
     }
 
-    if (!totalCount) {
+    if (!changeCount()) {
         /* No changes */
         mQuitButton->setText(" " + tr("Quit"));
         mUpdatesHeader->setText("<h2>" + tr("Certificates unchanged") +
@@ -848,7 +849,7 @@
     } else {
         mQuitButton->setText(" " + tr("Quit without saving"));
         mUpdatesHeader->setText("<h2>" + tr("Changes to certificate stores (%1)")
-                .arg(totalCount) +
+                .arg(changeCount()) +
                 "</h2>");
     }
 
@@ -1190,3 +1191,8 @@
         syslog_info_printf(tr("Sucessfully checked for updates.").toUtf8().constData());
     }
 }
+
+int MainWindow::changeCount()
+{
+    return mChangeCount;
+}
diff -r 345805165d9b -r 929c3db85eb7 ui/mainwindow.h
--- a/ui/mainwindow.h	Wed Jul 02 16:08:55 2014 +0200
+++ b/ui/mainwindow.h	Wed Jul 02 16:09:19 2014 +0200
@@ -82,6 +82,14 @@
     void toggleUpdatesNew();
     void toggleUpdatesRemove();
     void toggleUpdatesManual();
+
+    /** Reflect change list states in the UI
+     *
+     * This slot should be called each time the contents or selection
+     * state of one of the certificate lists change to update the
+     * UI elements accordingly.
+     *
+     * @param[in] selected unused. */
     void listChanged(int selected);
 
     /** @brief check for running software that needs to close before installing
@@ -154,6 +162,9 @@
     void installNewSW(const QString& fileName, const QDateTime& modDate);
 
 private:
+    /** @brief the combined number of changes made in all lists */
+    int changeCount();
+
     /** @brief check the integrity of available certificate lists.
      *
      * Note: Do not use this as a local trust check as this only works on
@@ -231,6 +242,8 @@
     QPushButton *mUpdatesDetailsNew;
     QPushButton *mUpdatesDetailsRemove;
     QPushButton *mUpdatesDetailsManual;
+
+    int mChangeCount;
 };
 
 #endif // MAINWINDOW_H


More information about the Trustbridge-commits mailing list