changeset 463:5200b8e9b2ae

Rename tablemodel certificates and add accessors
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 23 Apr 2014 15:33:09 +0000
parents 091ad56c2715
children 2e100d3e414a
files ui/administratorwindow.h ui/certificatetablemodel.cpp ui/certificatetablemodel.h
diffstat 3 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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
--- 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;
 };
 

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