44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
|
|
//
|
||
|
|
// Created by Krad on 2021/11/23.
|
||
|
|
//
|
||
|
|
|
||
|
|
#include "UserOperationLogForm.h"
|
||
|
|
#include <QVBoxLayout>
|
||
|
|
#include <QAbstractListModel>
|
||
|
|
#include "log/UserOperationLog.h"
|
||
|
|
#include "log/LogFileTableModel.h"
|
||
|
|
#include <QHeaderView>
|
||
|
|
|
||
|
|
UserOperationLogForm::UserOperationLogForm(QWidget *parent) {
|
||
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||
|
|
QWidget* header = new QWidget(this);
|
||
|
|
table = new QTableView(this);
|
||
|
|
layout->addWidget(header);
|
||
|
|
layout->addWidget(table);
|
||
|
|
//暂时先放构造函数,之后需要移除,等需要时再调用
|
||
|
|
loadUserOperationLog();
|
||
|
|
}
|
||
|
|
|
||
|
|
UserOperationLogForm::~UserOperationLogForm() {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void UserOperationLogForm::loadUserOperationLog() {
|
||
|
|
LogFileTableModel* model = new LogFileTableModel(this);
|
||
|
|
QString filePath = UserOperationLog::Default()->currentLogFile();
|
||
|
|
model->setFileName(filePath);
|
||
|
|
QStringList header;
|
||
|
|
header<<"Operation Date"<<"Operation Time"<<"User"<<"Operation";
|
||
|
|
model->setHeader(header);
|
||
|
|
// UserOperationLog::getHistoryLogFiles();
|
||
|
|
table->setModel(model);
|
||
|
|
table->setAlternatingRowColors(true);
|
||
|
|
table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||
|
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||
|
|
table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||
|
|
table->verticalHeader()->setDefaultSectionSize(38);
|
||
|
|
table->horizontalHeader()->setStretchLastSection(true);
|
||
|
|
table->setColumnWidth(0,250);
|
||
|
|
table->setColumnWidth(1,250);
|
||
|
|
}
|