# HG changeset patch # User Raimund Renkert # Date 1397132096 -7200 # Node ID e6aa82466420bca445aa918e2e5512879a27bfb3 # Parent dde533ba4fcc47188262ceb915943462762c7060 Use the table item delegate for certificates and make the model editable. diff -r dde533ba4fcc -r e6aa82466420 ui/CMakeLists.txt --- a/ui/CMakeLists.txt Thu Apr 10 14:13:34 2014 +0200 +++ b/ui/CMakeLists.txt Thu Apr 10 14:14:56 2014 +0200 @@ -31,6 +31,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/administrator.cpp ${CMAKE_CURRENT_SOURCE_DIR}/administratorwindow.cpp ${CMAKE_CURRENT_SOURCE_DIR}/certificatetablemodel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/certificatetabledelegate.cpp ${CERTIFICATELIST_SOURCES} ) diff -r dde533ba4fcc -r e6aa82466420 ui/administratorwindow.cpp --- a/ui/administratorwindow.cpp Thu Apr 10 14:13:34 2014 +0200 +++ b/ui/administratorwindow.cpp Thu Apr 10 14:14:56 2014 +0200 @@ -15,6 +15,8 @@ #include #include +#include "certificatetabledelegate.h" + AdministratorWindow::AdministratorWindow() { createActions(); createMenuBar(); @@ -61,8 +63,10 @@ QGroupBox *certBox = new QGroupBox(tr("Managed Certificates")); certificateView = new QTableView; certificateModel = new CertificateTabelModel(); + CertificateTableDelegate *delegate = new CertificateTableDelegate(certificateView); certificateView->setModel(certificateModel); - certificateView->setColumnWidth(0, 60); + certificateView->setItemDelegate(delegate); + certificateView->setColumnWidth(0, 50); certificateView->setColumnWidth(2, 130); certificateView->setColumnWidth(3, 130); certificateView->setColumnWidth(4, 200); diff -r dde533ba4fcc -r e6aa82466420 ui/certificatetablemodel.cpp --- a/ui/certificatetablemodel.cpp Thu Apr 10 14:13:34 2014 +0200 +++ b/ui/certificatetablemodel.cpp Thu Apr 10 14:14:56 2014 +0200 @@ -42,6 +42,13 @@ return QVariant(); } +bool CertificateTabelModel::setData(const QModelIndex &index, + const QVariant &value, int role) +{ + //TODO + return true; +} + QVariant CertificateTabelModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -61,4 +68,14 @@ return header.size(); } +Qt::ItemFlags CertificateTabelModel::flags(const QModelIndex &index) const +{ + if (!index.isValid ()) + return Qt::ItemIsSelectable; + if (index.column() == 0) { + return QAbstractTableModel::flags(index) | Qt::ItemIsEditable; + } + + return QAbstractTableModel::flags(index); +} diff -r dde533ba4fcc -r e6aa82466420 ui/certificatetablemodel.h --- a/ui/certificatetablemodel.h Thu Apr 10 14:13:34 2014 +0200 +++ b/ui/certificatetablemodel.h Thu Apr 10 14:14:56 2014 +0200 @@ -22,8 +22,12 @@ int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + bool setData(const QModelIndex &index, const QVariant &value, + int role = Qt::EditRole); QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; + int role = Qt::DisplayRole) const; + + Qt::ItemFlags flags(const QModelIndex &index) const; private: QList certificates;