Account Table form

This commit is contained in:
Krad
2021-12-08 15:10:56 +08:00
parent f00501f680
commit a65d293fb2
5 changed files with 117 additions and 2 deletions

47
src/AccountTableForm.cpp Normal file
View File

@@ -0,0 +1,47 @@
//
// Created by Krad on 2021/12/8.
//
#include "AccountTableForm.h"
#include <QVBoxLayout>
#include <QHeaderView>
#include <src/components/AccountRoleComboDelegate.h>
#include "db/SQLHelper.h"
#include "components/SlideableTableView.h"
AccountTableForm::AccountTableForm(QWidget *parent) {
layout = new QVBoxLayout(this);
QTableView* table = new SlideableTableView(this);
layout->addWidget(table);
// TableView for patient
table->setAlternatingRowColors(true);
table->setSelectionMode(QAbstractItemView::SingleSelection);
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->setSelectionBehavior(QAbstractItemView::SelectRows);
table->verticalHeader()->setDefaultSectionSize(38);
table->horizontalHeader()->setStretchLastSection(true);
//data from SQLITE
auto model = SQLHelper::getTable("Account");
model->sort(5,Qt::DescendingOrder);
model->select();
model->setHeaderData(1,Qt::Horizontal,"ID");
model->setHeaderData(2,Qt::Horizontal,"Name");
model->setHeaderData(4,Qt::Horizontal,"Role");
model->setHeaderData(5,Qt::Horizontal,"Comment");
table->setModel((QAbstractItemModel*)model);
table->hideColumn(0);
table->hideColumn(3);
AccountRoleComboDelegate* comboDelegate = new AccountRoleComboDelegate(this);
table->setItemDelegateForColumn(4,comboDelegate);
table->show();
// table->setSortingEnabled(true);
table->setColumnWidth(1,250);
table->setColumnWidth(2,250);
table->setColumnWidth(4,150);
}
AccountTableForm::~AccountTableForm() {
}