[PATCH 2 of 7] Rename tablemodel certificates and add accessors

Wald Commits scm-commit at wald.intevation.org
Wed Apr 23 18:21:54 CEST 2014


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1398267189 0
# Node ID 5200b8e9b2aed246dd9295deb6643ac38d92b589
# Parent  091ad56c2715b74d474af866ab2b02bdfdb2c4fa
Rename tablemodel certificates and add accessors

diff -r 091ad56c2715 -r 5200b8e9b2ae ui/administratorwindow.h
--- a/ui/administratorwindow.h	Wed Apr 23 15:32:24 2014 +0000
+++ b/ui/administratorwindow.h	Wed Apr 23 15:33:09 2014 +0000
@@ -32,10 +32,12 @@
 public:
     AdministratorWindow();
 
-    /** @brief obtain a const reference to the certificate List
-     * @returns the current certificatelist
+    /** @brief obtain a reference to the certificates currently in the model
+     * @returns the currently shown certificates
      */
-    const CertificateList& certList() const {return mCertList;}
+    const QList<Certificate>& certificates() const {
+        return certificateModel->certificates();
+    }
 
     /** @brief get the settings for this application
      * @returns a reference the applications settings object
diff -r 091ad56c2715 -r 5200b8e9b2ae ui/certificatetablemodel.cpp
--- a/ui/certificatetablemodel.cpp	Wed Apr 23 15:32:24 2014 +0000
+++ b/ui/certificatetablemodel.cpp	Wed Apr 23 15:33:09 2014 +0000
@@ -27,8 +27,8 @@
     bool editable)
 {
     beginInsertRows(QModelIndex(), rowCount(), rowCount());
-    certificates.append(certificate);
-    certificates.last().setEditable(editable);
+    mCertificates.append(certificate);
+    mCertificates.last().setEditable(editable);
     endInsertRows();
 }
 
@@ -36,11 +36,11 @@
     const QModelIndex &index)
 {
     beginRemoveRows(QModelIndex(), row, row + count - 1);
-    if ((row + count - 1) > certificates.size()) {
+    if ((row + count - 1) > mCertificates.size()) {
         return false;
     }
     for (int i = row + count - 1; i >= row; i--) {
-        certificates.removeAt(i);
+        mCertificates.removeAt(i);
     }
     endRemoveRows();
     return true;
@@ -48,18 +48,18 @@
 
 bool CertificateTabelModel::removeAll()
 {
-    return removeRows(0, certificates.size(), QModelIndex());
+    return removeRows(0, mCertificates.size(), QModelIndex());
 }
 
 QVariant CertificateTabelModel::data(const QModelIndex &index,
         int role) const
 {
-    if (index.row() > certificates.size() || index.row() < 0) {
+    if (index.row() > mCertificates.size() || index.row() < 0) {
         return QVariant();
     }
 
     if (role == Qt::DisplayRole) {
-        Certificate cert = certificates.at(index.row());
+        Certificate cert = mCertificates.at(index.row());
         QVariant ret;
         switch(index.column()) {
         case 0: ret = cert.isInstallCert(); break;
@@ -75,7 +75,7 @@
         return ret;
     }
     if (role == Qt::UserRole) {
-        Certificate cert = certificates.at(index.row());
+        Certificate cert = mCertificates.at(index.row());
         return cert.isEditable();
     }
     if (role == Qt::FontRole && index.column() == 7) {
@@ -89,12 +89,12 @@
 bool CertificateTabelModel::setData(const QModelIndex &index,
     const QVariant &value, int role)
 {
-    if (index.row() > certificates.size() || index.row() < 0) {
+    if (index.row() > mCertificates.size() || index.row() < 0) {
         return false;
     }
 
     bool newValue = value.toBool();
-    Certificate &cert = certificates[index.row()];
+    Certificate &cert = mCertificates[index.row()];
     if (!cert.isEditable()) {
         return false;
     }
@@ -116,7 +116,7 @@
 
 int CertificateTabelModel::rowCount(const QModelIndex&) const
 {
-    return certificates.size();
+    return mCertificates.size();
 }
 
 int CertificateTabelModel::columnCount(const QModelIndex&) const
diff -r 091ad56c2715 -r 5200b8e9b2ae ui/certificatetablemodel.h
--- a/ui/certificatetablemodel.h	Wed Apr 23 15:32:24 2014 +0000
+++ b/ui/certificatetablemodel.h	Wed Apr 23 15:33:09 2014 +0000
@@ -38,8 +38,10 @@
 
     Qt::ItemFlags flags(const QModelIndex &index) const;
 
+    const QList<Certificate>& certificates() {return mCertificates;}
+
 private:
-    QList<Certificate> certificates;
+    QList<Certificate> mCertificates;
     QList<QString> header;
 };
 


More information about the Trustbridge-commits mailing list