Mercurial > trustbridge
changeset 399:55cbe0a482ce
merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 16 Apr 2014 10:01:02 +0200 |
parents | 9e6a2c2033ed (diff) ae2ef965a41b (current diff) |
children | d481b1d0956f |
files | packaging/renameme_installer.ico |
diffstat | 3 files changed, 29 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/administratorwindow.cpp Tue Apr 15 20:27:26 2014 +0200 +++ b/ui/administratorwindow.cpp Wed Apr 16 10:01:02 2014 +0200 @@ -14,15 +14,22 @@ #include <QCheckBox> #include <QHeaderView> #include <QFileDialog> +#include <QStandardPaths> +#include <QSortFilterProxyModel> #include "certificatetabledelegate.h" #include "createinstallerdialog.h" #include "createcertlistdialog.h" AdministratorWindow::AdministratorWindow() { + QString path = QStandardPaths::locate( + QStandardPaths::DataLocation, QString("certlist_last.txt")); + certList.readList(path.toLocal8Bit()); createActions(); createMenuBar(); createContent(); + loadCertificateTable(); + resize(1110, 700); } void AdministratorWindow::createActions() @@ -65,17 +72,18 @@ QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); certificateView = new QTableView; certificateModel = new CertificateTabelModel(); + QSortFilterProxyModel *filterModel = new QSortFilterProxyModel(this); + filterModel->setSourceModel(certificateModel); CertificateTableDelegate *delegate = new CertificateTableDelegate(certificateView); - certificateView->setModel(certificateModel); + certificateView->setModel(filterModel); certificateView->setItemDelegate(delegate); - certificateView->setColumnWidth(0, 50); - certificateView->setColumnWidth(2, 130); - certificateView->setColumnWidth(3, 130); - certificateView->setColumnWidth(4, 200); + certificateView->resizeColumnsToContents(); + certificateView->setColumnWidth(0, 60); certificateView->setSelectionBehavior(QAbstractItemView::SelectRows); connect(certificateView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(clickedCertificate(const QModelIndex&))); certificateView->verticalHeader()->setVisible(false); + certificateView->setSortingEnabled(true); certLayout->addWidget(certificateView); certBox->setLayout(certLayout); @@ -119,8 +127,6 @@ // managed in the central widget. base->setLayout(mainLayout); setCentralWidget(base); - certificateView->horizontalHeader()->setSectionResizeMode(1, - QHeaderView::Stretch); } void AdministratorWindow::loadCertificateFile() @@ -133,6 +139,7 @@ qDebug() << "Not a valid list."; } else { + certificateModel->removeAll(); loadCertificateTable(); } } @@ -163,6 +170,8 @@ foreach(const Certificate &cert, certList.getCertificates()) { certificateModel->addCertificate(cert, true); } + certificateView->resizeColumnsToContents(); + certificateView->setColumnWidth(0, 60); } void AdministratorWindow::addToCertificateTable(const QList<Certificate> &certs)
--- a/ui/certificatetablemodel.cpp Tue Apr 15 20:27:26 2014 +0200 +++ b/ui/certificatetablemodel.cpp Wed Apr 16 10:01:02 2014 +0200 @@ -1,5 +1,7 @@ #include "certificatetablemodel.h" +#include <QFont> + CertificateTabelModel::CertificateTabelModel(QObject *parent) : QAbstractTableModel(parent) { @@ -31,14 +33,17 @@ return false; } for (int i = row + count - 1; i >= row; i--) { - if (!certificates.at(i).isEditable()) { - certificates.removeAt(i); - } + certificates.removeAt(i); } endRemoveRows(); return true; } +bool CertificateTabelModel::removeAll() +{ + return removeRows(0, certificates.size(), QModelIndex()); +} + QVariant CertificateTabelModel::data(const QModelIndex &index, int role) const { @@ -66,6 +71,10 @@ Certificate cert = certificates.at(index.row()); return cert.isEditable(); } + if (role == Qt::FontRole && index.column() == 7) { + QFont block("DejaVu Sans Mono"); + return block; + } return QVariant(); }
--- a/ui/certificatetablemodel.h Tue Apr 15 20:27:26 2014 +0200 +++ b/ui/certificatetablemodel.h Wed Apr 16 10:01:02 2014 +0200 @@ -19,6 +19,7 @@ void addCertificate(const Certificate &certificate, bool editable); bool removeRows(int row, int count, const QModelIndex&); + bool removeAll(); int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const;